DRYな備忘録

Don't Repeat Yourself.

2013-07-01から1ヶ月間の記事一覧

MacにScala(sbt)環境構築【sbt】【brew】【MacOSX10.8】

Goal .scalaファイルをsbtでビルドして実行してHello りっちゃん https://gist.github.com/kmizu/1876800 Log [20:33:44]otiai10 % brew --version 0.9.4 [20:33:48]otiai10 % sudo brew install sbt Warning: Your Xcode (4.6.2) is outdated Please instal…

【memo】Pythonの@classmethod

[22:48:38] % python Python 3.3.2 (default, Jul 19 2013, 08:43:31) [GCC 4.4.5] on linux Type "help", "copyright", "credits" or "license" for more information. >>> class Base: ... def func_a(self): ... print('This is func A') ... >>> class F…

Python3でExceptionの詳細を取得したい【Python3.3.2】【try-except】【stackoverflowの回答早すぎワロタな件】

【問題】 Python2系だと、Exceptionのメッセージ取得するのカンタンなのに… [22:41:10] % python --version Python 2.7.1 [22:41:13] % python >>> >>> try: ... {}.encode('utf8') ... except Exception as e: ... print('---- print works ---') ... print…

MacOSXにNode.js+TypeScriptをインストール【TypeScript】【npm】【Node.js】【MacOSX】

Goal macにNode.jsとTypeScriptをインストールしてtscコマンドを実行するまで Log % echo $OSTYPE darwin12.0 % % brew search nodejs nodejs % sudo brew install nodejs Password: Warning: Your Xcode (4.6.2) is outdated Please install Xcode 4.6.3. =…

ファイル読み込めず No such file or directory【iOS】【stringWithContentsOfFile】【Xcode4.6.2】

【問題】 プロジェクト内に配置したtxtファイルを読み込んで処理したい。stringWithContentsOfFileを使うが、No such file or directory なエラーが出る。 2013-07-20 16:49:00.748 filetest[54199:c07] ERROR OCCURRED!!-> Error Domain=NSCocoaErrorDomain…

pyenv使ってみた:Python3.3.2環境構築

Goal pyenvを使ってPython3.3.2環境構築 Log # ここを参照 # http://qiita.com/la_luna_azul/items/3f64016feaad1722805c % cd ~ % git clone git://github.com/yyuu/pyenv.git .pyenv # """ .zshrc直接編集で事足ります """" % echo 'export PYENV_ROOT="${…

ローカルに秘書たんが動くPython2.7環境構築するログ

Goal ローカルマシン(MacOSX10.8.4)で秘書たんを動かす Log % pwd /Users/otiai10 % % echo $OSTYPE darwin12.0 % python --version Python 2.7.2 % ls -la | grep prj drwxr-xr-x 3 otiai10 staff 102 6 22 12:37 prj % cd prj % cd python % ls -la tota…

Pythonのhasattrで詰まったメモ

% python >>> class Foo(): ... hoge = 1 ... _fuga = 2 ... __piyo = 3 ... def __init__(self): ... pass ... >>> f = Foo() >>> hasattr(f, 'hoge') True >>> hasattr(f, '_fuga') True >>> hasattr(f, '__piyo') False >>> __bar で宣言したprivateなプ…

Expecting property name: line 2 column 3 (char 4)【json】【Python】

【問題】 .jsonファイルを作って、Pythonのjsonモジュールのload()メソッドでjsonの内容をdict型で取得しようと思ったら、以下の内容のエラーが出るでござる # 前略 File "myapp.py", line 5, in load pool = json.load(f) File "/usr/lib/python2.6/json/__…

PythonでmongoDBにアクセス【pymongo】【pip】【Python2.6.6】

Goal pythonファイルからmongoDBにwrite pythonファイルからmongoDBをread Reference http://symfoware.blog68.fc2.com/blog-entry-302.html ほとんどコレそのもの Log pymongoってのがあるっぽい % pip search pymongo pymongo - Python driver for MongoDB <http://www.mongodb.org></http://www.mongodb.org>…

PythonでミニマムなTwitterBOTをつくる【python-twitter】【pip】【Python2.6.6】

Goal コマンドラインから特定アカウントにツイートさせる 標準出力に特定アカウントのTLをリアルタイム(仮)表示させる Log まずはパッケージのインストール % python --version Python 2.6.6 % pip --version pip 1.3.1 from /usr/local/lib/python2.6/dis…

Junoをインストール【SinatraっぽいPythonフレームワーク】【easy_install】【pip】【Python2.7.1】

いいかげんeasy_installじゃなくてpipな環境整えろって話ですよ。 Goal Junoをインストールして「Hello,りっちゃん」画面を出すとこまで。 Log % cd % sudo easy_install juno Password: Searching for juno Reading http://pypi.python.org/simple/juno/ Be…

Pythonのrequestsモジュール使ってみる【HTTP Request】【import requests】【Python2.7.1】

簡単にHTTPリクエストできるPythonのモジュール無いかなー、って思ってたらあった。requestsモジュールってのがあるらしい。 log % sudo easy_install requests Password: Searching for requests Reading http://pypi.python.org/simple/requests/ Best mat…

シェルスクリプトでゼロパディング【ゼロ埋め】【shellscript】

printf "%05d" 10 出力 00010

Error: Cannot find module 【NODE_PATH】【npm】【Node.js】

【問題】 npm使ってnodeのモジュールをインストールしますよね % sudo npm install -g argv こんな感じ。で、こんな感じで呼ぼうとしますよね app.js var argv = require('argv'); で、実行すると % node app.js module.js:340 throw err; ^ Error: Cannot f…

リポジトリごとのgit config【git】

【問題】 ローカルの特定のリポジトリだけは、エンタープライズのアカウントではなく、github.comの本垢でコミットしたいんだけど。 git config --global user.name "otiai10" だとglobal設定になっちゃうじゃん。 【解決】 リポジトリごとの設定は、リポジ…