Skip to content

Instantly share code, notes, and snippets.

View marocchino's full-sized avatar
🏠
Working from home (7am~16pm JST)

marocchino

🏠
Working from home (7am~16pm JST)
View GitHub Profile
def brain
@brain ||= CalculatorBrain.new
end
@marocchino
marocchino / temp.rb
Created April 9, 2011 07:38
레일즈 탬플릿
## 사용법
## 카미나리
## 오이짜응
## 제이쿼리
## Thor
## Ap
<%= new_post_path(:foo=>"&&<?> ' == nil",:bar => 2) %>
/posts/new?bar=2&amp;foo=%26%26%3C%3F%3E+%27+%3D%3D+nil
<%= raw new_post_path(:foo=>"&&<?> ' == nil",:bar => 2) %>
/posts/new?bar=2&foo=%26%26%3C%3F%3E+%27+%3D%3D+ni
@marocchino
marocchino / truncate_master.sh
Created April 13, 2011 07:08
마스터랑 마지 안하고 그냥 현재 해드를 사용하고 싶을때.
git branch new_master
git checkout new_master
git branch -m master old_master
git branch -m new_master master
git branch -D old_master
// Bad no-caching
$('#some-element').css({ 'background-color': '#FF0000' });
$('#some-element').html("I turned red");
// Good caching
var some_element = $('#some-element');
some_element.css({ 'background-color': '#FF0000' });
some_element.html("I turned red");
when type
case 1
Comment.all.length
case 2
@comments = @post.comments.all
@comments.length
case 3
@post.comments.length
end
@marocchino
marocchino / gist:1202294
Created September 8, 2011 00:38
git submoduel update zsh script
for i in $(cat .gitmodules|grep path\\b|sed 's/path = //')
do cd $i
git checkout master
git pull
1
done
var ctx = { rate : 3 };
var sum = (new Function("rate", "a", "b", "return (a + b)*rate;")).bind(this,ctx.rate);
console.log( sum( 5, 7 ) ); // 36 출력
@marocchino
marocchino / gist:1216075
Created September 14, 2011 08:04
search and reply bot
#http://cjohansen.no/en/ruby/twibot_a_microframework_for_twitter_bots_in_ruby
require 'twibot'
{"keyword1"=> "message1",
"keyword2"=> "message2",
"keyword3"=> "message3",
"keyword4"=> "message4",
"keyword5"=> "message5",
"keyword6"=> "message6",
//다른 오브젝트의 함수를 끌어다 쓸수있었네.
var cat, dog, setName;
setName = function(name) {
return this.name = name;
};
cat = {};
cat.setName = setName;
dog = {};
cat.setName.apply(dog, ['yani']);
console.log(dog.name); //yani