Skip to content

Instantly share code, notes, and snippets.

View ozzzzzzzzzp's full-sized avatar

Ro ozzzzzzzzzp

View GitHub Profile
@ozzzzzzzzzp
ozzzzzzzzzp / calc.rb
Created July 13, 2012 02:26
Code Golf RPN Calculator!
p((_=[gets.split,[],"+-**/"])[0].map{|s|s=~/[\d\.]+/?_[1]<<s.to_f: _[2][s]?_[1]<<_[1].pop(2).inject(s):0}[0][0])
@ozzzzzzzzzp
ozzzzzzzzzp / gist:2632044
Created May 8, 2012 02:17 — forked from rtomayko/gist:2601550
Open beautiful git-scm.com manual pages w/ git help -w
# The new git-scm.com site includes man pages designed for pleasant viewing in a web browser:
#
# http://git-scm.com/docs
#
# The commands below can be used to configure git to open these pages when
# using `git help -w <command>' from the command line. Just enter the config
# commands in your shell to modify your ~/.gitconfig file.
# Create a new browser command and configure help -w to use it.
git config --global browser.gitscm.cmd "/bin/sh -c 'open http://git-scm.com/docs/\$(basename \$1 .html)' --"
@ozzzzzzzzzp
ozzzzzzzzzp / character_reference.rb
Created May 3, 2012 02:14 — forked from norman/character_reference.rb
HTML entities? We don't need no stinkin' HTML entities.
# coding: utf-8
#
# Encode any codepoint outside the ASCII printable range to an HTML character
# reference (http://bit.ly/KNupLT).
def encode(string)
string.each_codepoint.inject("") do |buffer, cp|
cp = "&#x#{cp.to_s(16)};" unless cp >= 0x20 && cp <= 0x7E
buffer << cp
end
end
@ozzzzzzzzzp
ozzzzzzzzzp / tree.md
Created April 24, 2012 11:41 — forked from hrldcpr/tree.md
one-line tree in python

One-line Tree in Python

Using Python's built-in defaultdict we can easily define a tree data structure:

def tree(): return defaultdict(tree)

That's it!

@ozzzzzzzzzp
ozzzzzzzzzp / 1_let.rb
Created March 30, 2012 11:39 — forked from ryanb/1_let.rb
let vs def
desc "A user's comment" do
let(:user) { User.create! name: "John" }
let(:comment) { user.comments.create! }
it "delegates to user's name" do
comment.name.should eq(user.name)
end
end
@ozzzzzzzzzp
ozzzzzzzzzp / maybe.rb
Created March 29, 2012 01:14 — forked from pzol/maybe.rb
Maybe in ruby
def Maybe(obj)
return Maybe.new(Nothing.new) if obj.nil?
return Maybe.new(obj)
end
class Nothing
def method_missing(*args, &block)
self
end