Skip to content

Instantly share code, notes, and snippets.

@a2ikm
a2ikm / gist:305404
Last active September 4, 2015 10:04
dump database to yaml for fixtures
#
#= dump database to yaml for fixtures
#
# originated by elm200 <http://d.hatena.ne.jp/elm200/20070928/1190947947>
#
#== install
#
# move this file to RAILS_ROOT/lib/tasks/extract_fixtures.rake
#
namespace :db do
@masuidrive
masuidrive / Rakefile
Created June 26, 2010 22:54
build Rakefile for Titanium mobile on OSX
#
# Titanium mobile Rakefile for iPhone build
#
DEV_PROVISIONING_UUID = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
DEV_SIGN = "Developer name"
DEV_APP_NAME = "DevApp"
DEV_APP_ID = 'com.example.dev'
TITANIUM_SDK_VERSION = '1.3.2'
ja:
# extract from activesupport
date:
formats:
default: "%Y/%m/%d"
short: "%m/%d"
long: "%Y年%m月%d日(%a)"
day_names: [日曜日, 月曜日, 火曜日, 水曜日, 木曜日, 金曜日, 土曜日]
abbr_day_names: [日, 月, 火, 水, 木, 金, 土]
@glv
glv / gist:703997
Created November 17, 2010 20:16
USE INDEX with Active Record finders for Rails 3
# for background, see http://m.onkey.org/use-index-with-active-record-finders
# and http://twitter.com/#!/dougalcorn/status/4963159878139904
from = "#{quoted_table_name} USE INDEX(index_activities_on_created_at_and_country_id)"
Activity.from(from).where('created_at >= ? AND country_id = ?', 10.days.ago, 79).all
@llj098
llj098 / Makefile
Created December 23, 2010 01:36
a sample tcp server runs in kernel
obj-m += tcp_svr_sample.o
all:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
clean:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clea
@tatsuosakurai
tatsuosakurai / tork05_sample
Created January 9, 2011 07:13
tork05用メアドをランダムに抽出
require "csv"
MAX = 50
EXISTING = 18
EMAILCOLNUM = 5
DUPLICATE = 1
def create_data
result = []
#csv取得
@3dd13
3dd13 / generate_ssh_keys.rb
Created January 20, 2011 16:59
chef recipe to generate ssh key for a user
define :generate_ssh_keys, :user_account => nil do
username = params[:user_account]
raise ":user_account should be provided." if username.nil?
Chef::Log.debug("generate ssh skys for #{username}.")
execute "generate ssh skys for #{username}." do
user username
creates "/home/#{username}/.ssh/id_rsa.pub"
@jacquescrocker
jacquescrocker / fabrication_ext.rb
Created February 23, 2011 01:01
monkey patch for fabrication gem that allows Fabricate.unique (for mongoid only at the moment). just require this file within config/environments/test.rb and it should work
class Fabricate
class << self
def unique(name, overrides={}, &block)
schematic = Fabrication::Fabricator.schematics[name]
raise Fabrication::UnfabricatableError, "No fabricator found for '#{name}'" unless schematic
# pull out the fabricator_id
fabricator_id = overrides[:fabricator_id] || schematic.attribute(:fabricator_id) || name
# set the overriden fabricator_id
@kusakari
kusakari / small_tag
Created April 14, 2011 23:18
モバイルソーシャルアプリのフォントサイズ
def small_tag_start
return '' unless request.mobile?
case request.mobile
when Jpmobile::Mobile::Docomo
'<span style="font-size:smaller">'
when Jpmobile::Mobile::Au
if ['CA31','CA32','CA33','HI33','HI34','HI35','HI36','SA31','TS31','SH3D'].member?(request.mobile.device_id)
'<font style="font-size:12px">'
elsif ['CA3E','KC35','KC36','KC37','KC38','KC3O','KC3H','KC3K','SH3B','TS3O','TS3H','SN3I','HI3G','KC3R'].member?(request.mobile.device_id)
'<font style="font-size:15px">'
@ijt
ijt / http_get.go
Last active August 23, 2021 12:37
Example of using http.Get in go (golang)
package main
import (
"fmt"
"io"
"log"
"net/http"
"os"
)