Skip to content

Instantly share code, notes, and snippets.

View unicornrainbow's full-sized avatar
💖
🎈Sharing codes 🔫🛍🛁📐🎉💉🕳🚬💎💰💳

Rashiki Grace unicornrainbow

💖
🎈Sharing codes 🔫🛍🛁📐🎉💉🕳🚬💎💰💳
  • Newstime
  • Daytona Beach, FL
View GitHub Profile
@unicornrainbow
unicornrainbow / array.rb
Created September 21, 2011 05:46
has_each, has_any, and has_none extension to Array.
# has_each, has_any, and has_none extension to Array.
#
class Array
# Returns true is array contains each item in the argument list.
#
# Basic Usage:
#
# [:black, :blue].has_each :black # => true
# [:black, :blue].has_each :black, :red # => false
@unicornrainbow
unicornrainbow / eq.rb
Created September 21, 2011 06:04
==, eql?, equal?. Now we also have .eq
# Use .eq where you would use ==. Avoid accidental assignment.
#
# if 1.eq 1
# puts "They're equal"
# end
#
class Object
def eq(operand)
self == operand
end
@unicornrainbow
unicornrainbow / array.rb
Created September 21, 2011 06:31
An Alternative (and preferred) wording for the has methods
# all_in, any_in, and none_in extension to Array.
#
class Array
# Returns true if the argument list contain every item of the array.
#
# Basic Usage:
#
# [:black, :blue].all_in :black, :blue # => true
# [:black].all_in :black, :red # => true
@unicornrainbow
unicornrainbow / enumerable.rb
Created September 21, 2011 06:50
A refined version of #in, #eq, #any_in, #all_in, and #none_in for object and enumerable.
# all_in, any_in, and none_in extension to Array.
#
module Enumerable
# Returns true if the argument list contain every item of the array.
#
# Basic Usage:
#
# [:black, :blue].all_in :black, :blue # => true
# [:black].all_in :black, :red # => true
@unicornrainbow
unicornrainbow / fixnum-of.rb
Created September 26, 2011 18:13
Fixnum#of
# Example:
#
# 2.of { Factory(:user) } #=> [<User>, <User>]
#
class Fixnum
def of
(1..self).map { |n| yield n }
end
end
@unicornrainbow
unicornrainbow / development.rb
Created October 28, 2011 18:43 — forked from MyArtChannel/development.rb
Use Pry as IRB replacement in rails 3 console
# Add this to the end of your development.rb and add
#
# gem 'pry'
#
# to your Gemfile and run bundle to install.
silence_warnings do
begin
require 'pry'
IRB = Pry
@unicornrainbow
unicornrainbow / gist:1554417
Created January 3, 2012 10:40
A zsh shell alias that acts something like github's branches page.
alias all='git for-each-ref --count=400 --sort=-committerdate refs/heads/ --format='"'"'printf "%%-40s %%4d behind\t%%4d ahead\t%%-20s\t%%30s\n" "$(echo %(refname) | cut -d / -f 3-)" "$(echo $(git log %(objectname)..head --oneline | wc -l))" "$(git log head..%(objectname) --oneline | wc -l)" "%(authorname)" "%(authordate)"'"'"' | $SHELL | less'
@unicornrainbow
unicornrainbow / setup-statsd.sh
Created February 5, 2012 20:09 — forked from coderholic/setup-statsd.sh
Turn an Ubuntu 10.04 linode into a StatsD/Graphite server
# install git
sudo apt-get install g++ curl libssl-dev apache2-utils
sudo apt-get install git-core
# download the Node source, compile and install it
git clone https://github.com/joyent/node.git
cd node
./configure
make
sudo make install
# install the Node package manager for later use
@unicornrainbow
unicornrainbow / hosts
Created March 8, 2012 22:45
Excerpt from my /private/etc/hosts
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
127.0.0.1 localhooker
127.0.0.1 locohost
@unicornrainbow
unicornrainbow / Gemfile
Created March 21, 2012 21:29 — forked from sr/Gemfile
Janky on Heroku
source "http://rubygems.org"
gem "janky", "~>0.9"
gem "pg"
gem "thin"