new takyam();

Qiitaぽい話はQiitaに書いていくことにする気がする http://qiita.com/takyam

GoCon

今日はGoConだったんですが、所用のため午前中で退席。キーノートは聞けてよかった。

Simplicityを実現するための複雑さというか難しさというか、その辺の話を聞けてよかったし、Goが書きやすさ(楽しさ)よりeasy read, easy understandを求めてるというのも聞いて納得だった。 他の言語のエンジニアがGo書き始めて陥りやすい罠というか、もっとGoならシンプルにわかりやすく表現できる、みたいな話と併せて聞けてGoが素晴らしい言語である事を再認識したりした感じです。

#golang の revel でConfigをControllerで読もうとしてハマったはなし

Golangが熱いので最近触り始めました。
revel を使ってるんですが、とりあえずTwitterのOAuthサンプル 的なのをやってみようと思って、API-KEYとSecret-Keyを取得。
サンプルだとコントローラ内にベタ書きされてたけど流石にそれはいけてねぇよな、app.confとは別のconfにもたせよう、としたところで悲しいエラーが出て悲しい感じに悲しみました。

動くようになったコードが以下でし。

//抜粋
package controllers

import (
    "github.com/revel/revel"
    "fmt"
    "os"
)
var apiKey string = ""
var secretKey string = ""
func init (){
    revel.OnAppStart(func(){
        if twitterConf, err := revel.LoadConfig("twitter.conf"); err != nil {
            fmt.Printf("TwitterConf load failed. [%v]", err);
        }else {
            apiKey, _ = twitterConf.String("twitter.apikey")
            secretKey, _ = twitterConf.String("twitter.secretkey")
        }
        if apiKey == "" || secretKey == "" {
            fmt.Println("Twitter API|SECRET KEY must be set on twitter.conf .")
            os.Exit(1)
        }
    })
}
  • ハマったポイント
    • ifで初期化した変数がifのブロック内でしか有効じゃないぽい?
    • revel.OnAppStart 内でやらないとConfigのLoadで死ぬ
      • runtime error: invalid memory address or nil pointer dereference みたいなエラー出る

Goむずい。まだむずい。俺にとってむずい。がんばる。

Espruino開封の儀

f:id:takyam1213:20140108115638j:plain

Espruino
http://www.espruino.com/

ようやくとどいた!半年待ったわー。
Kickstarterで募集してたので即申し込み。
頼んだのはStarterKitなので箱にぎっしりなんやかんや入ってました。

で、このEspruinoが何者なのかといいますと、ArduinoのJS版みたいなやつ。

以下FAQから抜粋

http://www.espruino.com/FAQ

HOW IS ESPRUINO DIFFERENT TO ARDUINO & RASPBERRY PI?

Espruino v Raspberry Pi : Raspberry Pis are very powerful and flexible, but have a relatively high power consumption, making it very difficult to run them off a battery. You can't schedule actions in real-time on a Raspberry Pi which means that accurate timing is difficult. However they are good at Video and Audio, which Espruino isn't powerful enough to support. Espruino runs JavaScript: this makes it very approachable and easy for beginners. Raspberry Pi on the other hand gives you a choice of programming languages, and generally more RAM and storage. Raspberry Pi also lacks Analog IO, which is supported by Espruino. It also requires an SD card containing the operating system (which Espruino dopesn't).

Espruino v Arduino: Espruino is smaller than most Arduino boards and is much easier to get started with. You don't have to pre-install software on your Mac or PC. Espruino and Arduino both have low power consumption and a lot of functionality. However if you want to add a device to Arduino you'll probably have to use expensive shields. While Espruino can be used with shields via an adaptor, you can also solder devices on directly using our prototyping area. The use of a JavaScript interpreter means Espruino doesn't have to be reset when you make changes to the code, however it also means that the execution speed will be slightly slower. For example, Espruino is too slow for Audio and Video (although a lot of Arduinos are as well).

以下超意訳

ESPRUINO と ARDUINO とか RASPBERRY は何が違うのん?

Espruino v Raspberry Pi :
ラズベリーパイはめっちゃ強力で柔軟なんだけど消費電力高いしバッテリー要るやん。
ラズベリーパイで正確なタイミングでリアルタイムにスケジュールする事が難しいやん(?)
せやけどEspruinoが苦手な動画とかオーディオとかは得意やんね。
EspruinoはJSで動くよ。こいつぁ初心者にやさしいってことよ。
ラズベリーパイはもっとたくさんの言語やRAM、ストレージをサポートしてるけどね。
EspruinoがサポートしてるアナログI/Oもラズベリーパイはもっとらんよね。
OS入りのSDカードも必須やしね(Espruinoはいらんよー)

Espruino v Arduino:
Espruinoは大体のArduinoのボードより小さくて、始めるのが簡単なのよねん。
Mac か PC にソフトをインストールしておく必要もないし。
Espruino も Arduino も消費電力超少なくて多機能ですしおすし。
せやけどArduinoにデバイス追加しようとしたらたぶん高価なシールド使うと思うんです。
Espruinoはアダプター経由でシールドを使うこともできるし、プロトタイプエリアを使うことで直接ハンダ付けする事もできます。
JSのインタプリタを使うということは、Espruinoはコード変更時にリセットする必要がないんだけど、たぶん実行速度が少し遅いと思う。 たとえばEspruinoは動画とかオーディオが超遅い(まぁ多くのArduinoもそうなんだけど)。

みたいな感じで、JSで操るArduinoっぽいの、という認識にそんなに間違い無いとは思うんです。
「始めやすい!」っていってるけどぶっちゃけただのLinuxなRasberryPiのほうが超始めやすいと思うんらけどね(^q^)

というわけで開封の儀

箱表(切手)

超ざっくりしたダンボールに入ってきた。

f:id:takyam1213:20140216004415j:plain

UKからの発送だったので切手がROYAL!かっけー

箱裏

f:id:takyam1213:20140216004739j:plain

Electonic Components !!!

箱あけたところ

f:id:takyam1213:20140216004821j:plain

箱ちっちゃかったんだけど思った以上にいろいろ詰まってた。
流石スターターキット。

箱から取り出してみる

f:id:takyam1213:20140216004857j:plain

何が何のパーツなのか全然わからん(^q^)
電子工作なんてしたことないぽよ

Espruinoの本体

f:id:takyam1213:20140216004936j:plain

マジちっさい。micro(mini?) SDカード指すところと microUSB指すとこが見える。

以上

感想としては予想以上に小さい、に尽きます。 Arduinoのボードより一回り小さい感じな印象。
遊ぶだけなら大きさってそれほど気にならないですが。

サーボモーターとかいろいろ入ってたので遊んでみよー。

とりあえず開封の儀でした。

Mavericksにしたらnodeのコンパイルできん場合

$ nodebew install v0.10.24
(略)
../deps/cares/src/ares_setup.h:79:10: fatal error: 'errno.h' file not found

みたいな場合は、MacのSDKの問題なのでCommand Line Tools (OS X Mavericks) for Xcodeいれればなおると思うお。

「App Store は一時的に利用できません。後でやり直してください。」って言われた。

MacのApp Storeの話。

ずいぶん前から赤丸でアップデートがあるって通知があるんだけど、
いざAppStore開いてアップデートのところ見てもパラソルくるくるーので、
「app store は一時的に利用できません。後でやり直してください」って言われてしょんぼりんぐ。

f:id:takyam1213:20140111013335p:plain

再起動したりDNS変えたりしてもだめー。

ぐぐったらターミナルからアップデートできるっぽかったので試してみる。

$ sudo softwareupdate -l
Software Update Tool
Copyright 2002-2010 Apple

Software Update found the following new or updated software:
   * iTunesX-11.1.3
        iTunes (11.1.3), 224202K [recommended]
   * RemoteDesktopClient-3.7.1
        Remote Desktop クライアントアップデート (3.7.1), 4677K [recommended]
   * JavaForOSX-1.0
        Java for OS X 2013-005 (1.0), 65167K [recommended]
   * MacBookAirFlashStorageFWUpd1.0-1.1
        MacBook Air フラッシュストレージ・ファームウェア・アップデート (1.1), 1947K [recommended] [restart]
   * OSXUpd10.8.5-10.8.5
        OS X アップデート (10.8.5), 293731K [recommended] [restart]

なんかごっつあるわぁ。 上から順に適当にインストールしてみる。

sudo softwareupdate -i iTunesX-11.1.3
Software Update Tool
Copyright 2002-2010 Apple

   Checking packages…
Installing
   About 2 minutes
   Less than a minute
   About 10 seconds
   About 5 seconds
Installed iTunes
Done.

まだエラーでる

$ sudo softwareupdate -i RemoteDesktopClient-3.7.1
Software Update Tool
Copyright 2002-2010 Apple

   Checking packages…
Installing
   About 2 minutes
   Less than a minute
   About 5 seconds
Installed Remote Desktop クライアントアップデート
Done.

まだエラーでる

$ sudo softwareupdate -i JavaForOSX-1.0
Software Update Tool
Copyright 2002-2010 Apple


   Checking packages…
Installing
   About 2 minutes
   Less than a minute
   About 5 seconds
Installed Java for OS X 2013-005
Done.

だめー。というわけで残りリスタートが必要な2つ。

$ sudo softwareupdate -i MacBookAirFlashStorageFWUpd1.0-1.1
Software Update Tool
Copyright 2002-2010 Apple


   Checking packages…
Installing
   About 2 minutes
   Less than a minute
   About 5 seconds
Installed MacBook Air フラッシュストレージ・ファームウェア・アップデート
Done.

You have installed one or more updates that requires that you restart your
computer.  Please restart immediately.

言われるがままに再起動

f:id:takyam1213:20140111015023p:plain

まぁ関係ないだろうなと思ってたけど、やっぱり関係なかった。

最後のやつ。

$ sudo softwareupdate -i OSXUpd10.8.5-10.8.5
Software Update Tool
Copyright 2002-2010 Apple


   Checking packages…
Installing
   About 5 minutes
   About 4 minutes
   About 3 minutes
   About 2 minutes
   Less than a minute
   About 10 seconds
   About 5 seconds
Installed OS X アップデート
Done.

You have installed one or more updates that requires that you restart your
computer.  Please restart immediately.

はいはい再起動させていただきます。

そしてついに!

なおらない。

あるぇー。

$ sudo softwareupdate -l
Password:
Software Update Tool
Copyright 2002-2010 Apple

Software Update found the following new or updated software:
   * Safari6.1.1MountainLion-6.1.1
    Safari (6.1.1), 51687K [recommended]
   * MacBookAirSMCUpdate1.9-1.9
    MacBook Air SMC ファームウェア・アップデート (1.9), 183K [recommended] [restart]

もっかい見たら増えてる。OSXUpd10.8.5-10.8.5が前提条件だったのかしら。
どんどん入れてみる。

$ sudo softwareupdate -i Safari6.1.1MountainLion-6.1.1
Software Update Tool
Copyright 2002-2010 Apple


Downloading Safari
   231 KB of 52.9 MB
   966 KB of 52.9 MB — Less than a minute
   1.9 MB of 52.9 MB — Less than a minute
   3 MB of 52.9 MB — Less than a minute
 (略)
Waiting to install Safari
   Checking packages…
Installing
   About 2 minutes
   About a minute

   Less than a minute
   About 5 seconds
Installed Safari
Done.

何か急にプログレス表示が細かくなった。
まぁ、まだダメなんだけどね。

$ sudo softwareupdate -i MacBookAirSMCUpdate1.9-1.9
Software Update Tool
Copyright 2002-2010 Apple


Downloading MacBook Air SMC ファームウェア・アップデート
   186 KB of 188 KB
Verifying MacBook Air SMC ファームウェア・アップデート
Waiting to install MacBook Air SMC ファームウェア・アップデート
   Checking packages…
Installing
   About 2 minutes
   This may take a few minutes; do not shut down your computer.
Installed MacBook Air SMC ファームウェア・アップデート
Done.

You have installed one or more updates that requires that you restart your
computer.  Please restart immediately.

はいはいりぶーとりぶーと。

でも、だめー。

それでも株は抜けません!ってか。

$ sudo softwareupdate -l
Password:
Software Update Tool
Copyright 2002-2010 Apple

No new software available.

さいごの手段。
てけてけーん「まーべりっくすー」。

はい、というわけで、Marvericksにアップデートして無事解決です。