This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[color] | |
branch = auto | |
status = auto | |
diff = auto | |
[alias] | |
st = status | |
ci = commit | |
co = checkout | |
br = branch | |
tp = !rake test && git push |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FalseClass | |
def affirmative? | |
false | |
end | |
end | |
class NilClass | |
def affirmative? | |
false | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Widget < ActiveRecord::Base | |
belongs_to :box | |
has_many :categorizations | |
has_many :categories, :through => :categorizations | |
# Returns a sentence of all the categories. | |
def category_names | |
if categories.empty? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sass in Rails 3.1 | |
http://speakerdeck.com/u/chriseppstein/p/sass-the-future-of-stylesheets-in-rails-31 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Car | |
# http://ruby-doc.org/docs/ProgrammingRuby/html/ref_c_object.html#Object.method_missing | |
def method_missing(method, *args, &block) | |
# don't do: | |
method.gsub!("gasoline", "electricity") | |
# also don't do: | |
method = method.to_s | |
# ... | |
super |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def unsubscribe | |
# using base64 encoding in the url to prevent unsubscribe abuse | |
@user = User.find_by_access_token(Base64.decode64(params[:token])) # find the user from the ID in url | |
if @user.opt_out! | |
redirect_to root_url, :notice => "We won't bug you with emails!" # give them a little notice that it worked | |
else | |
render :text => "Could not find your access token, did you copy-paste the correct email from the unsubscribe? Just email us at blah2blah.com" | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Based on: http://www.rapidtables.com/convert/color/rgb-to-cmyk.htm | |
*/ | |
#include <stdio.h> | |
#include <math.h> | |
typedef struct RGB_t { unsigned char red, green, blue; } RGB; | |
typedef struct CMYK_t { unsigned char cyan, magenta, yellow, black; } CMYK; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ resumator_pipeline | |
Name: Johnny Appleseed Applied: 2013-10-18 (2 days ago) Last contact: 2013-10-20 (0 days ago) | |
Name: Charles Quinn Applied: 2013-10-17 (3 days ago) Last contact: 2013-10-18 (2 days ago) | |
Active Applicants: 2 | |
Longest in Pipeline: 3 | |
Longest in Pipeline without contact: 2 | |
Average Days in Pipeline: 2.5 | |
Average Days in Pipeline without contact: 1.0 | |
Standard Deviation: 1.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# From: http://www.openremote.org/display/docs/OpenRemote+2.0+How+To+-+Control+Somfy+Sunshades+with+Raspberry+Pi | |
PIN=$1 | |
/usr/local/bin/gpio mode $PIN out | |
/usr/local/bin/gpio write $PIN 1 | |
sleep 0.1 | |
/usr/local/bin/gpio write $PIN 0 |
OlderNewer