Skip to content

Instantly share code, notes, and snippets.

@knu
knu / pipetest.rb
Created May 1, 2012 02:48
Pipe test
#!/usr/bin/env ruby
r, w = IO.pipe
pid = fork {
w.close
$stdin.reopen(r)
r.close
IO.select([$stdin], nil, [$stdin])
exec 'more'
@sowawa
sowawa / .recipe
Created April 28, 2012 03:45
Installing rails 4.0.0 beta
thumbnail: http://pds.exblog.jp/pds/1/201101/16/02/d0055302_13383029.jpg
video: http://www.youtube.com/watch?v=UE27t_LJpx0
[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
>
@Vaysman
Vaysman / s.rb
Created April 11, 2012 07:33 — forked from jacksonwillis/s.rb
Sentences as Ruby code
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! #####
@keikubo
keikubo / README.md
Created March 20, 2012 01:38
Nginx + Unicorn for Rails on Rackhub

Nginx + Unicorn for Rails on Rackhub

Description:

This script enables you to launch your Rails application in production environment (port:80) with Nginx and Unicorn.

Installation:

Please make sure that your Gemfile in your rails application includes unicorn.

@tomykaira
tomykaira / markdown-to-hiki.rb
Created March 2, 2012 08:50
Convert markdown to hiki / markdown テキストから hiki 形式に変換するスクリプト(適当)
# -*- 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(/^ /, ' ').
@bleis-tift
bleis-tift / git-start
Created February 13, 2012 09:15
空コミットを最初のコミットとして作るコマンド(git initの代わり)
#!/bin/sh
msg=${1:-"first commit"}
git init
tree_hash=$(git write-tree)
commit_hash=$(echo -n "$msg" | git commit-tree $tree_hash)
echo $commit_hash > .git/refs/heads/master
@v1nc3ntlaw
v1nc3ntlaw / rbenv-install-system-wide.sh
Last active July 26, 2022 01:08
rbenv install ruby 1.9.3-p448 on Debian 6 Squeeze
# Update, upgrade and install development tools:
apt-get update
apt-get -y upgrade
apt-get -y install build-essential git-core curl libssl-dev \
libreadline5 libreadline5-dev \
zlib1g zlib1g-dev \
libmysqlclient-dev \
libcurl4-openssl-dev \
libxslt-dev libxml2-dev
@thekindofme
thekindofme / start_delayed_job.sh
Created November 27, 2011 15:04
Upstart conf file for starting up delayed job
#!/bin/bash
logger "Trying to start delayed_job"
date >> /home/deployer/scripts/log/start_delayed_job.txt
rvm_path=/home/deployer/.rvm
source "/home/deployer/.rvm/scripts/rvm"
cd /home/deployer/inoty
/usr/bin/env RAILS_ENV=production /home/deployer/.rvm/rubies/ruby-1.9.2-p0/bin/ruby /home/deployer/inoty/script/delayed_job restart &>> /home/deployer/scripts/log/start_delayed_job.txt
@prisoner
prisoner / consistent_hashr.rb
Created July 28, 2011 18:05
A Consistent Hashing implementation for Ruby
require 'zlib'
module ConsistentHashr
@circle = {}
@number_of_replicas = 20
##
# Computes a key
def self.hash_key(key)
Zlib.crc32("#{key}")