Skip to content

Instantly share code, notes, and snippets.

View kyanny's full-sized avatar

Kensuke Nagae kyanny

View GitHub Profile
# app/models/my_model.rb
module MyApp
module Model
def self.included(base)
base.send :include, Mongoid::Document
base.send :include, Mongoid::Timestamps
base.send :include, ActiveAdmin::Mongoid::Patches
end
end
@tricknotes
tricknotes / config.ru
Created November 12, 2011 05:59
config.ru for gollum
require 'rubygems'
require 'bundler/setup'
require 'gollum/frontend/app'
Precious::App.set(:gollum_path, File.dirname(__FILE__))
Precious::App.set(:wiki_options, {})
run Precious::App
@wsargent
wsargent / gist:1258640
Created October 3, 2011 07:46
Setting up a base vagrant box for Oracle
Install instructions for 10.2:
http://download.oracle.com/docs/cd/B19306_01/relnotes.102/b15666/toc.htm
http://download.oracle.com/docs/cd/B19306_01/install.102/b15667/toc.htm
[Required files]
10201_database_linux_x86_64.cpio.gz
10201_companion_linux_x86_64.cpio.gz
p6810189_10204_Linux-x86-64.zip
@twilson63
twilson63 / csidoms.md
Created July 31, 2011 14:03
Common CoffeeScript Idoms - from the little book on CoffeeScript

Common CoffeeScript Idoms

Each

myfunction(item) for item in items

Map

@sasimpson
sasimpson / gist:1112739
Created July 28, 2011 22:37
Ruby Net:HTTP chunked transfer
require 'uri'
require 'net/http'
class Chunked
def initialize(data, chunk_size)
@size = chunk_size
if data.respond_to? :read
@file = data
end
end
@tobert
tobert / config.ru
Created May 18, 2011 02:01
Gollum rackup for Unicorn
$: << 'lib'
require 'rubygems'
require 'gollum'
require 'gollum/frontend/app'
use Rack::ShowExceptions
Precious::App.set(:gollum_path, Dir.pwd)
Precious::App.set(:wiki_options, {})
@juliocesar
juliocesar / best-localStorage-polyfill-evar.js
Created April 18, 2011 23:19
This is the best localStorage polyfill in the world
// I mean, seriously, localStorage is supported even by your mum. How about instead of
// casing the feature out, you give users in-memory (stale) storage instead?
// If they close your application, they deserve to lose data anyway.
// if (!('localStorage' in window)) {
if (!Modernizr.localstorage) {
window.localStorage = {
_data : {},
setItem : function(id, val) { return this._data[id] = String(val); },
getItem : function(id) { return this._data.hasOwnProperty(id) ? this._data[id] : undefined; },
@tyuki39
tyuki39 / waitjob.groovysh
Created February 26, 2011 14:16
Jenkinsで、指定ジョブがビルド中でない場合は即実行、指定ジョブがビルド中の場合は待って実行する例
//
// 1. depjobnameで指定したジョブよりも自分自身が先にキューに入った場合は、自分自身のビルドを即実行する。
// 2. depjobnameで指定したジョブよりも自分自身が後にキューに入った場合は、depjobnameの終了を待つ。
// 2-1. ポーリング方式で終了を待つ
// 2-2. 最大リトライ回数は retrycount で指定
// 2-3. リトライ間隔は sleeptime で指定(単位はミリ秒)
// 3. depjobnameで指定したジョブが存在しなかった場合は、ビルドを失敗させるためにあえて例外が発生する
// ようにしています。
// 4. 設定手順
// 4-1. Groovy Pluginをインストールする
@yoggy
yoggy / ldr2pin.rb
Created January 12, 2011 06:19
Livedoor ReaderのPinをまとめてpinboard.inにブックマークするスクリプト
#!/usr/bin/ruby
#
# ldr2pin.rb - Livedoor ReaderのPinをまとめてpinboard.inにブックマークするスクリプト
#
$KCODE='utf8'
require 'rubygems'
require 'net/netrc'
require 'mechanize'
@keithamus
keithamus / Nano Git Commit Syntax highlighting
Created December 10, 2010 13:58
Add this to your ~/.nanorc and when running "git commit" (if your editor is nano) you'll have syntax highlighting in your commit message. Includes support for "git commit -v" too!
syntax "gitcommit" "COMMIT_EDITMSG$"
color white "#.*"
color green "#.(modified|deleted).*"
color yellow start="# Changes.*" end="# Changed.*"
color cyan start="# Untracked.*" end="diff"
color cyan start="# Untracked.*" end="$$"
color brightred "^deleted file mode .*"
color brightgreen "^\+.*"
color brightred "^-.*"
color brightyellow "^(diff|index|---|\+\+\+).*"