This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set -u | |
set -e | |
# Example init script, this can be used with nginx, too, | |
# since nginx and unicorn accept the same signals | |
# Feel free to change any of the following variables for your app: | |
APP_ROOT=/home/deploy/public_html/rm/current | |
PID=$APP_ROOT/tmp/pids/unicorn.pid | |
ENV=production |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Use this for your URL shortening needs | |
# Base 62 is as good as you can easily get for URL shortening | |
# And it's effective: 1_000_000 => '4c92' | |
# Challenge: fork and speed up the implementation! | |
class Fixnum | |
TOKENS = ('0'..'9').to_a + ('a'..'z').to_a + ('A'..'Z').to_a | |
# NOTE returns nil for 0 | |
def to_62_s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Since Git is well structured, Grit uses a method missing (Grit::Git#method_missing) to 'systematically' execute Git commands: | |
require 'grit' | |
include Grit | |
gritty = Grit::Git.new('/tmp/filling-in') | |
gritty.clone({:quiet => false, :verbose => true, :progress => true, :branch => '37s'}, "git://github.com/cookbooks/cc-aws.git", "/tmp/cc-aws2") | |
# => "Initialized empty Git repository in /tmp/cc-aws2/.git/\n" | |
Dir.entries('/tmp/cc-aws2').size | |
# => 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'net/http' | |
require 'uri' | |
require 'json' | |
def get_gist(fileName,content) | |
res = Net::HTTP.post_form(URI.parse('http://gist.github.com/api/v1/json/new'), | |
{ 'files[#{fileName}]' => content, | |
'login' => 'USER NAME HERE', | |
'token' => 'API TOKEN HERE', | |
'description' => 'This is a test description' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
config_eth0="aaa.bbb.ccc.ddd/23" | |
routes_eth0="default via aaa.bbb.ccc.1" | |
dns_servers_eth0="210.224.163.4 210.224.163.3" | |
iptunnel_6rd="mode sit local aaa.bbb.ccc.ddd ttl 64" | |
config_6rd="2001:e41:xxxx:xxxx::1/32" # printf "2001:e41:%02x%02x:%02x%02x::1\n" aaa bbb ccc ddd | |
routes_6rd="::/0 via ::61.211.224.125 dev 6rd" | |
mtu_6rd="1280" | |
postup() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'zlib' | |
module ConsistentHashr | |
@circle = {} | |
@number_of_replicas = 20 | |
## | |
# Computes a key | |
def self.hash_key(key) | |
Zlib.crc32("#{key}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
ARGV.each do |fn| | |
lines = File.readlines(fn) | |
hiki = lines.map { |l| | |
l.sub(/^(#+)\s/){ '!'*($1.length) + ' ' }. | |
sub(/^(-+)\s/){ '*'*($1.length) + ' ' }. | |
gsub(/\!\[([^\]]+)\]\(([^\)]+)\)/){ $2[0..3] == 'http' ? $2 : ('http://goos-lokka.heroku.com' + $2) }. # picture | |
gsub(/\[([^\]]+)\]\(([^\)]+)\)/, '[[\1|\2]]'). # url | |
gsub(/\*\*([^*]*)\*\*/, "'''\\1'''"). | |
sub(/^ /, ' '). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class S; def initialize *w; @s=w; end; def method_missing *w;@s<<w;self;end;def | |
to_ary;[@s.map{ |e| e=~/[\,\.\:\-\(\)\/\'\"]/?[e]:[" ",e] }.join.strip];end;end | |
def Object.const_missing(c);S.new c;end; ###### https://gist.github.com/2354740 | |
puts This.is.a.sentence.represented.by.a.Ruby.expression(",").try.it.out! ##### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ricky@t520 breakpoint]$ echo 'function foo() return "hi" end; print(foo())' | lua -i | |
Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio | |
> function foo() return "hi" end; print(foo()) | |
hi | |
> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
thumbnail: http://pds.exblog.jp/pds/1/201101/16/02/d0055302_13383029.jpg | |
video: http://www.youtube.com/watch?v=UE27t_LJpx0 |
OlderNewer