Skip to content

Instantly share code, notes, and snippets.

readelf -a hoge.elf
@semind
semind / note_for_locking
Created June 23, 2012 09:15 — forked from zflat/note_for_locking
rails with_lock
see http://guides.rubyonrails.org/3_2_release_notes.html
This makes it possible to write the following:
class Order < ActiveRecord::Base
def cancel!
transaction do
lock!
# ... cancelling logic
@semind
semind / gist:2212390
Created March 27, 2012 03:56
Linux全般
### 2TB以上のHDDを使う場合。partedコマンドでMBRではなくGPTを利用するようにする。
ex) 3TBのディスクの場合
# parted /dev/XXX
(parted) mklabel gpt
(parted) mkpart
Partition name? []?
File system type? [ext2]? ext4
Start? 1
End? 3001GB
@semind
semind / gist:1976636
Created March 5, 2012 04:33
chefのメモ
### デフォルトで使えるパラメータ
node['platform'] - The node's platform. This determines what Providers are used by Resources.
node['platform_version'] - The node's platform version. This may be used in determining Providers as well.
node['ipaddress'] - The node's ipaddress is IPV4 address of the interface that has the default route. If the node does not have a default route, this attribute will be nil. Using the IP of the interface with the default route is deemed the most sane default.
node['macaddress'] - The node's macaddress, from the interface detected for ipaddress above.
node['fqdn'] - The fully qualified domain name, for example from hostname -f on Unix/Linux systems. This is also used as the node name unless otherwise set.
node['hostname'] - The hostname is the first field from splitting the FQDN on "." (dot).
node['domain'] - The domain is the rest of the FQDN after splitting on "." (dot).
node['recipes'] - The node's Run List is expanded for roles and recipes, and recipes are stored in this attribute.
node['rol
@semind
semind / gist:1647875
Created January 20, 2012 15:24
ArelとかRailsのSQLまわりのメモ
#////////// Arel ///////////
### whereを使って完全一致の比較を行う ###
Model.where(:column => param)
### Arelは常に結果を配列で返すようなので一つだけとりだしたい場合(ユニークキーで検索する時とか)は.firstを使うと良い ###
Model.where(:column => param).first
### whereを使って大小の比較を行う ###
Model.where('column > param')
@semind
semind / gist:1626711
Created January 17, 2012 14:01
rubyメモ
### 配列の中身を個々の変数に分割して代入
test = ['a', 'b', 'c']
test << 'd'
p test # => ["a", "b", "c", "d"]
### ファイルからの相対パスでライブラリを読み込むためのイディオム
# $:は$LOAD_PATHと等価
$:.unshift(File.dirname(__FILE__))
$:.unshift(File.dirname(__FILE__) + "/lib")
@semind
semind / nginx.conf
Created December 30, 2011 02:41
nginx cookbook
##### nginxでリバースプロキシして後段でエラーが発生した場合にnginx側でエラーページの制御をしたい時の設定 #####
proxy_intercept_errors on; # errorをproxy側で肩代わりする設定
error_page 403 404 500 502 503 504 /error.html; # /var/www/html/error.htmlを置いておく
location /error.html {
root /var/www/html/;
}
#### headerの値を参照する ####
$http_フィールド名