Skip to content

Instantly share code, notes, and snippets.

View awesome's full-sized avatar

So Awesome Man awesome

View GitHub Profile
@hideo55
hideo55 / heredoc.rb
Created July 17, 2012 11:27
Ruby here document
h = {
hoge: <<EOS,
Hey!
EOS
fuga: <<EOS
Yo!
EOS
}
p h
@repeatedly
repeatedly / ruby_hash_literal_with_here_document.md
Created July 17, 2012 11:15
Why Ruby failed to parse a Hash literal with multiple here documents.

1 element

h = { 
  hoge: <<EOS
Hey!
EOS
}

p h
@xunker
xunker / gist:2481976
Created April 24, 2012 17:50
RVM Error with gemset
#!/usr/bin/env ruby
require 'rubygems'
require 'rvm'
require 'trollop'
opts = Trollop::options do
opt :ruby, "ruby interp to use", :type => :string, :required => true
opt :gem_name, "gem", :type => :string, :required => true
opt :gem_version, "gem", :type => :string, :required => true
end
@antonklava
antonklava / favicon-from-png.sh
Created April 11, 2012 08:18
Super simple script to create a favicon.ico from specified png
#!/bin/bash
#
# Super simple script to create a favicon.ico from specified png.
# Requires imagemagick ( http://www.imagemagick.org )
#
# Usage:
# ./favicon-from-png.sh myimage.png
# ls
# myimage.png favicon.ico
#
@futuremill-ltd
futuremill-ltd / gist:2318876
Created April 6, 2012 11:00
Building Ruby 1.9.3 package for Debian Squeeze
# From a fresh install of squeeze
apt-get install ruby rubygems # Need ruby to use fpm
gem1.8 install fpm --no-ri --no-rdoc
apt-get install build-essential openssl libreadline6 libreadline6-dev zlib1g zlib1g-dev libssl-dev ncurses-dev libyaml-dev
wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p125.tar.gz
tar -zxvf ruby-1.9.3-p125.tar.gz
cd ruby-1.9.3-p125
rm -rf /tmp/ruby193
@hjr3
hjr3 / e-commerce.md
Created April 3, 2012 05:35
Examples of RESTful API calls for E-commerce platforms

Examples of RESTful API calls for E-commerce platforms

These examples are type 3 RESTful API requests and responses. The JSON-HAL specification is used to implement HATEOAS.

Some of the examples are based on my work as architect of the RESTful API at http://www.hautelook.com. All proprietary information has been removed.

Relevant links

@citizen428
citizen428 / with.rb
Created March 21, 2012 12:30
ActionScript-like "with" for Ruby, result of SO discussion
module Kernel
def with(obj, &block)
obj.instance_eval &block
obj
end
end
@ChuckJHardySnippets
ChuckJHardySnippets / string_ext.rb
Created March 8, 2012 11:40 — forked from erskingardner/string_ext.rb
Ruby: Convert String to Boolean
class String
def to_bool
return true if self == true || self =~ (/(true|t|yes|y|1)$/i)
return false if self == false || self.blank? || self =~ (/(false|f|no|n|0)$/i)
raise ArgumentError.new("invalid value for Boolean: \"#{self}\"")
end
end
@pat
pat / my_spec.rb
Created February 29, 2012 07:17
Quick hack: A Capybara that you can tell not to auto-follow redirects
it "does not have to auto-follow redirects", :driver => :tito_driver do
page.driver.stop_following_redirects
# make a web request that redirects
# do whatever you need to do
# the continue...
page.driver.follow_redirects!
end
@chetan
chetan / yardoc_cheatsheet.md
Last active April 13, 2025 14:08
YARD cheatsheet