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 / 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 / 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 / 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 / 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 / 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 / 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 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 / in.rb
Created September 21, 2011 04:03
Ruby #in method.
# in extension to object.
#
class Object
# Returns true if the object sent #in is included in the argument list.
#
# Usage in conditionals:
#
# if 1.in 1, 2, 3
# puts "1 was included"
# end
@unicornrainbow
unicornrainbow / syntax_highlighting.py
Created August 8, 2011 20:42 — forked from JeanMertz/syntax_highlighting.py
Ruby on Rails syntax highlight switcher for Sublime Text 2
import sublime, sublime_plugin
import os
class DetectFileTypeCommand(sublime_plugin.EventListener):
""" Detects current file type if the file's extension isn't conclusive """
""" Modified for Ruby on Rails and Sublime Text 2 """
""" Original pastie here: http://pastie.org/private/kz8gtts0cjcvkec0d4quqa """
def on_load(self, view):
filename = view.file_name()
@unicornrainbow
unicornrainbow / env.rb
Created April 27, 2011 22:39 — forked from bru/env.rb
monkey patch to fix webrat follow redirect behaviour with rails 3
# features/support/env.rb
require 'webrat'
require 'webrat/core/matchers'
Webrat.configure do |config|
config.mode = :rack
config.open_error_files = false # Set to true if you want error pages to pop up in the browser
end