Skip to content

Instantly share code, notes, and snippets.

@tily
tily / HelloAndroid.java
Created May 23, 2010 13:20
hello android
package cc.omora;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class HelloAndroid extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
@tily
tily / patty.rb
Created November 9, 2012 11:26
patty.rb、最小限 Chef 実行
require 'tmpdir'
require 'rubygems'
require 'chef/shef/ext'
require 'chef/providers'
require 'chef/resources'
require 'sinatra/base'
class Patty < Shef::StandAloneSession
def reset!
loading do
require 'digest/md5'
action :sync do
old_checksum = ::File.exists?(new_resource.name) ? ::Digest::MD5.file(new_resource.name) : nil
execute "rsync file" do
command "rsync -a -e '#{new_resource.command}' #{new_resource.source} #{new_resource.name}"
end
ruby_block "see if rsync_file[#{new_resource.name}] was updated" do
@tily
tily / solo.rb
Created October 21, 2012 07:51
カレントディレクトリで chef-solo や knife を使うための設定ファイル
base_path = File.absolute_path(File.dirname(__FILE__))
file_cache_path base_path
cookbook_path File.join(base_path, 'cookbooks')
role_path File.join(base_path, 'roles')
data_bag_path File.join(base_path, 'data_bags')
@tily
tily / example.txt
Created August 6, 2012 15:07
Chef の 10.14.0.beta.1 から導入された dry run 機能 "why run" を試す
root@ubuntu:~# chef-solo -l fatal -c /tmp/chef-solo/solo.rb -j /tmp/chef-solo/nodes/server01.json --why-run
Starting Chef Client, version 10.14.0.beta.3
Compiling Cookbooks...
Converging 19 resources
Recipe: runit::default
* execute[start-runsvdir] action nothing (up to date)
* execute[runit-hup-init] action nothing (skipped due to only_if)
* package[runit] action installRecipe: <Dynamically Defined Resource>
* cookbook_file[/tmp/chef-solo/preseed/runit/runit-2.0.0-1ubuntu4.seed] action create
- Would create a new cookbook_file /tmp/chef-solo/preseed/runit/runit-2.0.0-1ubuntu4.seed
@tily
tily / chef-solo-skelton.rb
Created July 29, 2012 03:33
手軽に chef-solo を実行するためにスケルトンを作ってくれるやつ (ユースケース要検討)
require 'erb'
require 'fileutils'
require 'rubygems'
require 'git'
require 'sinatra/base'
require 'json'
BANNER = 'Usage: ruby chef-solo-sandbox.rb /path/to/dir [cookbook1 [cookbook2 [cookbook3 ...]]]'
def main(argv)
@tily
tily / queen_to_ramen.rb
Created July 8, 2012 04:45
AV 女優の名前をラーメン屋の店名に変換する
# coding:utf-8
require 'uri'
require 'mechanize'
INDICE = %w(あ か さ た な は ま や ら・わ)
URL = "http://ja.wikipedia.org/wiki/AV女優一覧_%s行"
mech = Mechanize.new
mech.user_agent_alias = "Windows IE 7"
kanji_list = []
@tily
tily / result.txt
Created June 21, 2012 13:52
socket.io ネームスペース認証時 callback の挙動を調べる
$ node socket_io_namespace_authorization_test.js localhost 1234
info - socket.io started
/null_true への接続を試行しています
socket 全体で connect を受信しました
名前空間 /null_true で connect を受信しました (理由:undefined)
----------------------------------------------------------------------
/null_false への接続を試行しています
socket 全体で connect を受信しました
名前空間 /null_false で connect_failed を受信しました (理由:unauthorized)
----------------------------------------------------------------------
@tily
tily / mail.txt
Created May 15, 2012 12:39
You need to get a parcel number XXXX (おそらくスパム)
Notification,
Our company’s courier couldn’t make the delivery of parcel.
Reason\It’s not right specified size and the weight of parcel.
LOCATION OF YOUR PARCEL:Albuquerque
STATUS OF YOUR ITEM: not delivered
SERVICE: One-day Shipping
:XXXXXXXXXXXX
INSURANCE: Yes
@tily
tily / chef_solo_in_your_application.rb
Created April 30, 2012 06:17
自分のアプリケーションから Chef Solo を呼び出す
# Usage: ruby chef_solo_in_your_application.rb
require 'rubygems'
require 'chef'
Chef::Config[:solo] = true
Chef::Config[:file_cache_path] = '/path/to/chef-repo'
Chef::Config[:cookbook_path] = ['/path/to/chef-repo/cookbooks']
@chef_solo = Chef::Client.new(JSON.load File.read ARGV.first)
@chef_solo.run