Skip to content

Instantly share code, notes, and snippets.

@colrichie
colrichie / yamanote_quine.rb.sh
Created August 25, 2012 10:55
Yamanote Quine
#! /bin/sh
# This source code should be viewed and run with
# more than 58 chars width and more than 100 lines height.
# 10 20 30 40 50
# -------+---------+---------+---------+---------+-------|
#
# The original code is exposed at
# http://www.slideshare.net/mametter/ruby-2012
class RPN
def self.run(exp)
res = tokenize(exp).inject([]) { |m, token| m << evaluate(token, m) }
raise(ArgumentError, "expression is not completed") unless res.size==1
res.first
end
def self.tokenize(s)
s.split
@rummelonp
rummelonp / faraday.md
Last active May 20, 2022 12:23
Ruby の HTTP クライアントライブラリ Faraday が便利そう

Ruby の HTTP クライアントライブラリ Faraday が便利そう

Ruby の HTTP クライアントライブラリ Faraday が便利そう

API ラッパの開発には [RestClient gem][rest_client_gem] だとか
OAuth の必要なものは [Net/HTTP][net_http] + [OAuth gem][oauth_gem] を使ってた

[Twitter gem][twitter_gem] や [Instagram gem][instagram_gem] など API ライブラリのソースを読んでみると
[Faraday gem][faraday_gem] というものがよく使われてた

@udzura
udzura / parameterized_mock_spec.rb
Created February 22, 2012 03:40
parameterized rspec (just a mock)
# Parametarized test with RSpec DSL idea
# Just a mock...
describe "Sample" do
describe "plus" do
labels { a | b | answer }
it "should do additions", :with_sample => true do |a, b, answer|
(a + b).should == answer
end
@burke
burke / 0-readme.md
Created January 27, 2012 13:44 — forked from funny-falcon/cumulative_performance.patch
ruby-1.9.3-p327 cumulative performance patch for rbenv

ruby-1.9.3-p327 cumulative performance patch for rbenv

This installs a patched ruby 1.9.3-p327 with various performance improvements and a backported COW-friendly GC, all courtesy of funny-falcon.

Requirements

You will also need a C Compiler. If you're on Linux, you probably already have one or know how to install one. On OS X, you should install XCode, and brew install autoconf using homebrew.

@amatsuda
amatsuda / http.rb
Created November 1, 2011 12:11
A sample of Ruby's method_missing
require 'open-uri'
class Http
def self./(url)
open("http://#{url}").read
end
end
class String
def com
self + '.com'
@tomykaira
tomykaira / clockwork-init.sh
Created October 25, 2011 10:21
Create a new project with clockwork for heroku.
#!/bin/sh
# Licence: MIT
# Created by tomykaira, 2011-10-25
if [ $# -ne 1 ]; then
echo "Give me your new project name (only)"
exit 1
fi
@devudilip
devudilip / SUBLIME TEXT2 INSTALLATION
Created October 22, 2011 08:54
HOW TO INSTALL SUBLIME TEXT 2 ON UBUNTU 11.10
#BECOME SUPER USER#
sudo -i
#add sublime to repository#
add-apt-repository ppa:webupd8team/sublime-text-2
#update#
@tsukkee
tsukkee / yokohamavim2.vim
Created September 25, 2011 05:23
Yokohama.vim #2 presentation by tsukkee
--
Yokohama.vim #2
キーマッピングを考える
tsukkee