Programming

  • 28 6月 2017

MkDocsのUnicodeDecodeErrorを解消する

Mac(10.11.6)でMkDocsを起動後、ファイルを保存するとエラーが発生する。

[E 170626 17:20:09 ioloop:638] Exception in callback <bound method type.poll_tasks of <class 'livereload.handlers.LiveReloadHandler'>>
    Traceback (most recent call last):
      File "/usr/local/lib/python2.7/site-packages/tornado/ioloop.py", line 1026, in _run
        return self.callback()
      File "/usr/local/lib/python2.7/site-packages/livereload/handlers.py", line 67, in poll_tasks
        filepath, delay = cls.watcher.examine()
      File "/usr/local/lib/python2.7/site-packages/livereload/watcher.py", line 73, in examine
        func and func()
      File "/usr/local/lib/python2.7/site-packages/mkdocs/commands/serve.py", line 106, in builder
        build(config, live_server=live_server, dirty=dirty)
      File "/usr/local/lib/python2.7/site-packages/mkdocs/commands/build.py", line 352, in build
        utils.clean_directory(config['site_dir'])
      File "/usr/local/lib/python2.7/site-packages/mkdocs/utils/__init__.py", line 134, in clean_directory
        if entry.startswith('.'):
    UnicodeDecodeError: 'ascii' codec can't decode byte 0xe6 in position 0: ordinal not in range(128)

確認

asciiでデコードしようとして発生しているエラーのようなのでUTF-8を扱うように修正するが、まずはasciiを使っているか確認。

$ python
Python 2.7.13 (default, Dec 17 2016, 23:03:43)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print sys.getdefaultencoding()
ascii

asciiを使っていることが明確になったので、UTF-8をデフォルトにするように修正する。

続きを読む 
  • 20 12月 2016

"main.dev.ts" and "main.prod.ts" have been deprecated.

続きを読む 
  • 20 12月 2016

強引なソリューション

続きを読む 
  • 29 5月 2016

メソッドの分け方は知らないけど、DTOを考える

続きを読む 
  • 10 1月 2016

ひさしぶりに触ってみたCloud IDE

続きを読む 
  • 28 11月 2015

Androidエミュレータのアプリが起動直後に停止

続きを読む 
  • 28 11月 2015

Andoirdエミュレータでアプリが停止する

続きを読む 
  • 26 9月 2015

可変長引数をそのまま…interface{}に渡せるか? - Can I convert a []T to an []interface{}?

続きを読む 
  • 06 9月 2015

IntelliJでGoSDKを設定する

続きを読む 
  • 09 3月 2015

Google App Engine/Goのディレクトリ構成

続きを読む 
  • 09 12月 2014

Hour of Code - FitPort

今日はAppleのイベントに行ってきた。

▶Apple Store - Hour of Codeワークショップ http://www.apple.com/jp/retail/code/

Hour-of-Code

登壇者が知り合いの知り合いということもあり、 ちょっと変わった感じで仕事を進めている気がしていたから気になっていた。 そんなとき、「Mac新調しようと思うんだけど、見繕って」というメッセージが届き、 ちょうどいいので「アップルストアに集合ね」ってことになった。

続きを読む 
  • 27 11月 2014

他人のソースコードを読むということ

今日のとある打ち合わせで「チーム内でお互いにソースコードを読んで欲しい」という話があった。 意図としては、

  • ソースコードのチェックをしている人が少数できつくなってきているから軽減
  • ソースを公開するときに少しでも見せられる状態にしておきたい
  • 今後の体制のため(スキルアップ)

というところなんだけど、賛同しない人もいた。

続きを読む 
  • 04 11月 2014

AltJSはどれを使おうか?

AltJSはどれを使おう?と調べていたけど、いまいちしっくりこないというか…。

候補

候補として挙げていたのはこれ。

  • Closure Library
  • traceur-compiler
  • TypeScript

続きを読む 
  • 26 10月 2014

解決してない人発見

gulpでcordova.d.tsをインストールしようと思ったんだけど、エラーが出た。
仕方ないのでtsdコマンドで直接試してみるか…とやってもだめ。

エラーはこんな感じ。

# gulp tsd [23:23:34] Using gulpfile ~/Project/gulpfile.js [23:23:34] Starting 'tsd'... [23:23:34] [gulp-tsd] execute command: reinstall [23:23:34] [gulp-tsd] config: ./tsd.json [23:23:34] [gulp-tsd] latest: true [23:23:34] [gulp-tsd] running... -> warning path reference not in index: plugins/BatteryStatus.d.ts -> warning path reference not in index: plugins/Camera.d.ts -> warning path reference not in index: plugins/Contacts.d.ts -> warning path reference not in index: plugins/Device.d.ts -> warning path reference not in index: plugins/DeviceMotion.d.ts -> warning path reference not in index: plugins/DeviceOrientation.d.ts -> warning path reference not in index: plugins/Dialogs.d.ts -> warning path reference not in index: plugins/FileSystem.d.ts -> warning path reference not in index: plugins/FileTransfer.d.ts -> warning path reference not in index: plugins/Globalization.d.ts -> warning path reference not in index: plugins/InAppBrowser.d.ts -> warning path reference not in index: plugins/Media.d.ts -> warning path reference not in index: plugins/MediaCapture.d.ts -> warning path reference not in index: plugins/NetworkInformation.d.ts -> warning path reference not in index: plugins/Push.d.ts -> warning path reference not in index: plugins/Splashscreen.d.ts -> warning path reference not in index: plugins/Vibration.d.ts -> warning path reference not in index: plugins/WebSQL.d.ts [23:23:34] [gulp-tsd] finish [23:23:34] Finished 'tsd' after 512 ms

続きを読む 
  • 25 10月 2014

tsdでcordova.d.tsをインストールする

gulpでcordova.d.tsをインストールしようと思ったんだけど、エラーが出た。
仕方ないのでtsdコマンドで直接試してみるか…とやってもだめ。

エラーはこんな感じ。

# gulp tsd
[23:23:34] Using gulpfile ~/Project/gulpfile.js
[23:23:34] Starting 'tsd'...
[23:23:34] [gulp-tsd] execute command: reinstall
[23:23:34] [gulp-tsd] config: ./tsd.json
[23:23:34] [gulp-tsd] latest: true
[23:23:34] [gulp-tsd] running...
-> warning path reference not in index: plugins/BatteryStatus.d.ts
-> warning path reference not in index: plugins/Camera.d.ts
-> warning path reference not in index: plugins/Contacts.d.ts
-> warning path reference not in index: plugins/Device.d.ts
-> warning path reference not in index: plugins/DeviceMotion.d.ts
-> warning path reference not in index: plugins/DeviceOrientation.d.ts
-> warning path reference not in index: plugins/Dialogs.d.ts
-> warning path reference not in index: plugins/FileSystem.d.ts
-> warning path reference not in index: plugins/FileTransfer.d.ts
-> warning path reference not in index: plugins/Globalization.d.ts
-> warning path reference not in index: plugins/InAppBrowser.d.ts
-> warning path reference not in index: plugins/Media.d.ts
-> warning path reference not in index: plugins/MediaCapture.d.ts
-> warning path reference not in index: plugins/NetworkInformation.d.ts
-> warning path reference not in index: plugins/Push.d.ts
-> warning path reference not in index: plugins/Splashscreen.d.ts
-> warning path reference not in index: plugins/Vibration.d.ts
-> warning path reference not in index: plugins/WebSQL.d.ts
[23:23:34] [gulp-tsd] finish
[23:23:34] Finished 'tsd' after 512 ms

続きを読む 
  • 06 5月 2014

知識がなくても解決できていたのか?

一昨日辺りからOAuth実装してる。
アクセストークンを取るところまでは躓きながらもなんとかなった。
今はそこら中に実装されてるコードがあるから、いざとなったらコピペなんてこともできる。

今後はこのアクセストークンを利用するわけだが、TwitterへのツイートやFlickrへのアップロードとなるとまた小さな壁が登場する。
アクセストークンを取得するには必要最低限のルールで済むけど、APIを利用する際にはさらにちょっとだけ必要な知識が増える。
知識はちょっとでいいんだけど、デバッグとなると知識は大切…と改めて思った。
普段は別にそんなことも気にしないんだけど、仕事で「こういう構成で進めましょう」って話をすることが多いから、なるべく誰でもなんとかなるように…と考えているせいか、「この知識がなかったら解決できたのか?」と自問することがある。

続きを読む 
  • 06 5月 2014

OAuth 1.0実装時のありがちなミス

OAuth 1.0を実装する際にありがちなミスを並べてみた。
ライブラリを使う人は遭遇することはないだろう。

  • KeyとSecretが違う
  • POSTとGETの指定ミス
  • URL encodeミス
  • encode忘れ
  • encodeしすぎ
  • 必要なヘッダーはある?
  • ヘッダーに付けすぎ
  • ヘッダーはカンマ区切り
  • ソート忘れ

続きを読む 
  • 10 3月 2014

ioutil.ReadAllすると空っぽになる

続きを読む 
  • 05 3月 2014

GoでJSONを構造体にする

続きを読む 
  • 26 10月 2013

レシーバによる挙動の違いを強引に解決

続きを読む 
  • 26 10月 2013

レシーバの違いによる挙動の違い

続きを読む 
  • 13 10月 2013

バリデーションという言葉とスマートな実装

続きを読む 
  • 14 8月 2013

WordPress投稿時にGoogle+に投稿する

続きを読む 
  • 09 8月 2013

Gitのコミットログのユーザ情報を書き換える方法

git
続きを読む 
  • 06 8月 2013

CodeIQ: 星間飛行ルートを作ろう!

続きを読む 
  • 05 8月 2013

go funcの使い分け

続きを読む 
  • 02 5月 2013

数日触ったTypeScript雑感

続きを読む 
  • 18 9月 2012

Scalaは仕事場では使いづらい

Scalaは仕事場では使いづらい。 個人的にはScalaは好きだけど、環境によっては使いづらくて困る…という話。

続きを読む 
  • 07 8月 2012

Sublime Text 2でsbtコンパイル

Sublime Text 2にensimeを入れてみたものの、完璧ではない。

Sublime Text 2でensimeを利用してみたが…

■ Use Sublime Text 2 for Scala Development « A Pinoy Programmer in Japan http://blog.hugeaim.com/2012/03/22/use-sublime-text-2-for-scala-development/
It seems that the validation is not yet perfect, so I would still use this in combination with an SBT build
こんな記述もあるわけだし、完璧ではないのは承知の上。 エラーがあるのか無いのかよくわからないこともあり、sbtも導入しておくのがよさそう。…

続きを読む 
  • 15 7月 2011

ScalaからDatastoreを更新したい

続きを読む 
  • 09 6月 2011

OAuthでapps scriptとApp Engineをつなぐ

続きを読む 
  • 18 2月 2011

いまさらながらMVC

MVC
続きを読む 
  • 10 1月 2011

IDEA+sbt-appengineで流れるような開発

続きを読む 
  • 10 1月 2011

IDEAからsbt-appengineを起動し、デバッグする

続きを読む 
  • 31 10月 2010

MacでlibusbJavaを使う

続きを読む 
  • 18 10月 2010

EclipseでGAE+Maven+Scalaの環境構築

続きを読む 
  • 05 8月 2010

OAuth EchoでTweetPhotoへアップロード

続きを読む 
  • 03 8月 2010

OAuth EchoでTwitpic投稿への道のり

続きを読む 
  • 29 7月 2010

OAuth EchoのRequestTokenを取得する

Twitter絡みで、OAuth Echoを使いたかったので書いてみた。

ネットの情報を色々と見ていると、人それぞれというか、動くのかな?っていうのもあったりして、軽く振り回された感あり :| 書いたソースコードはgithubに置いておきます&下の方に貼り付けておきます。 http://gist.github.com/497821 お役に立つようでしたら、ご自由にどうぞ。

以下、RequestTokenを取得するURLの作り方を簡単にまとめます。 RequestTokenはTwitterに署名付きのパラメータを送ることによってもらうことが出来きます。

http://twitter.com/oauth/request_token?&<各種パラメータ>&<署名>

この各種パラメータは次の通り。

  • oauth_consumer_key: 各自のConsumerKey
  • oauth_signature_method: "HMAC-SHA1" 他にもあるらしいが今回はこれ固定。
  • oauth_nonce: その場限りの値。ランダム文字列を利用。
  • oauth_timestamp: 現在時刻を秒で表した値。1900年を起算にっていう例のやつ。
  • oauth_version: OAuthのバージョン値。"1.0"固定。

URL構築時にはお約束の key=value を&で連結。

署名がちょっと面倒。 まずは署名の準備。署名にはHMAC-SHA1形式を利用。 キーを作成するときは "ConsumerSecret&OAuthToken" とする。もちろん、ConsumerSecretもOAuthTokenも自分の値で書き換えてください。 初回はOAuthTokenをまだ取得してないので空文字列となり、結果的に "ConsumerSecret&" となります。

続いて、署名するための文字列を作成します。

  1. パラメータを名称順にソート。
  2. パラメータを連結(key1=value&key2=value2&...)。これを仮に<Params>とする。keyとvalueをそれぞれエンコードする必要があるという情報も見たが、今回はエンコードしても同じなので、してません。
  3. "GET&encode(http://twitter.com/oauth/request_token)&encode(<Params>)" を作成。encodeはURLエンコード。

ここで作成した "GET..." という文字列を先程作成したキーで署名します。 署名した値をBase64エンコードし、その後、URLエンコードします。 これがRequestTokenをもらうためのURLの一部となる署名です。

生成したURLを叩いて "oauth_token=..." というレスポンスが帰ってくれば成功です。

もし、うまくいかなかった場合に見直した方がいいと思われるところ。

  • 署名用のキーを生成するところ。ConsumerSecretとOAuthTokenを利用しているか?OAuthTokenが無い場合は "ConsumerSecret&" のように&で終わっているか?
  • 署名する値("GET&http://...")の生成は正しいか?
  • 署名した値をBase64→URLエンコードしているか?

それほど難しいわけじゃないけど、はまるとミスっている箇所を見つけるのがちょっと大変かも。

続きを読む 
  • 29 5月 2010

Scala 2.8.0.RC2でspecs

続きを読む 
  • 13 5月 2010

戻り値が異なる場合の型推論

続きを読む 
  • 21 4月 2010

Scalaの強力な拡張:コレクション

続きを読む 
  • 06 4月 2010

カリー化した関数をカリー化してないように使う

続きを読む 
  • 06 4月 2010

Scalaのブロックを省略したい

続きを読む 
  • 15 3月 2010

JUnit4でScalaをテスト

続きを読む 
  • 15 3月 2010

プラグイン内部のエラーが原因か

続きを読む 
  • 12 3月 2010

Scalaで書いてみて

続きを読む 
  • 09 3月 2010

Base64の76文字制限

続きを読む