Programming
MkDocsのUnicodeDecodeErrorを解消する
Mac(10.11.6)でMkDocsを起動後、ファイルを保存するとエラーが発生する。
)
)
)
)
)
)
if )
確認
asciiでデコードしようとして発生しているエラーのようなのでUTF-8を扱うように修正するが、まずはasciiを使っているか確認。
)
)
>>> import
>>> print
asciiを使っていることが明確になったので、UTF-8をデフォルトにするように修正する。
Hour of Code - FitPort
今日はAppleのイベントに行ってきた。
▶Apple Store - Hour of Codeワークショップ http://www.apple.com/jp/retail/code/
登壇者が知り合いの知り合いということもあり、 ちょっと変わった感じで仕事を進めている気がしていたから気になっていた。 そんなとき、「Mac新調しようと思うんだけど、見繕って」というメッセージが届き、 ちょうどいいので「アップルストアに集合ね」ってことになった。
…他人のソースコードを読むということ
今日のとある打ち合わせで「チーム内でお互いにソースコードを読んで欲しい」という話があった。 意図としては、
- ソースコードのチェックをしている人が少数できつくなってきているから軽減
- ソースを公開するときに少しでも見せられる状態にしておきたい
- 今後の体制のため(スキルアップ)
というところなんだけど、賛同しない人もいた。
…AltJSはどれを使おうか?
AltJSはどれを使おう?と調べていたけど、いまいちしっくりこないというか…。
候補
候補として挙げていたのはこれ。
- Closure Library
- traceur-compiler
- TypeScript
解決してない人発見
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
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
…
知識がなくても解決できていたのか?
一昨日辺りからOAuth実装してる。
アクセストークンを取るところまでは躓きながらもなんとかなった。
今はそこら中に実装されてるコードがあるから、いざとなったらコピペなんてこともできる。
今後はこのアクセストークンを利用するわけだが、TwitterへのツイートやFlickrへのアップロードとなるとまた小さな壁が登場する。
アクセストークンを取得するには必要最低限のルールで済むけど、APIを利用する際にはさらにちょっとだけ必要な知識が増える。
知識はちょっとでいいんだけど、デバッグとなると知識は大切…と改めて思った。
普段は別にそんなことも気にしないんだけど、仕事で「こういう構成で進めましょう」って話をすることが多いから、なるべく誰でもなんとかなるように…と考えているせいか、「この知識がなかったら解決できたのか?」と自問することがある。
OAuth 1.0実装時のありがちなミス
OAuth 1.0を実装する際にありがちなミスを並べてみた。
ライブラリを使う人は遭遇することはないだろう。
- KeyとSecretが違う
- POSTとGETの指定ミス
- URL encodeミス
- encode忘れ
- encodeしすぎ
- 必要なヘッダーはある?
- ヘッダーに付けすぎ
- ヘッダーはカンマ区切り
- ソート忘れ
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も導入しておくのがよさそう。…
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&" となります。
続いて、署名するための文字列を作成します。
- パラメータを名称順にソート。
- パラメータを連結(key1=value&key2=value2&...)。これを仮に<Params>とする。keyとvalueをそれぞれエンコードする必要があるという情報も見たが、今回はエンコードしても同じなので、してません。
- "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エンコードしているか?
それほど難しいわけじゃないけど、はまるとミスっている箇所を見つけるのがちょっと大変かも。
…