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
pear | |
d | |
c | |
b | |
a | |
banana | |
c | |
a | |
b | |
apple |
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
# Command line progress spinner | |
# As seen here: http://www.youtube.com/watch?v=W-4vEZp67b0 | |
require 'thread' | |
require 'open-uri' | |
Thread.abort_on_exception = true | |
class Spinner | |
GLYPHS = ['|', '/', '-', '\\', '|', '/', '-', '\\'] |
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
module MiniTest::Assertions | |
def assert_content_type_is_json(response) | |
content_type = response.headers['Content-Type'] | |
assert_equal 'application/json;charset=utf-8', content_type | |
end | |
end | |
module MiniTest::Expectations | |
infect_an_assertion :assert_content_type_is_json, :must_be_json, :unary | |
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
# shitty | |
attributes[:name] = options[:name] unless options[:name].blank? | |
attributes[:first_name] = options[:first_name] unless options[:first_name].blank? | |
attributes[:last_name] = options[:last_name] unless options[:last_name].blank? | |
attributes[:linkedin_id] = options[:linkedin_id] unless options[:linkedin_id].blank? | |
attributes[:company] = options[:company] unless options[:company].blank? | |
attributes[:company_id] = options[:company_id] unless options[:company_id].blank? | |
attributes[:linkedin_picture_url] = options[:linkedin_picture_url] unless options[:linkedin_picture_url].blank? |
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
example.com | |
example.org | |
example.net |
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
mongoexport -d <database> -c <collection> -f field1,field2,field3 --csv > out.csv |
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
# Adapted from Lookup Tables With Lambdas | |
# http://www.naildrivin5.com/blog/2012/05/16/lookup-tables-with-lambdas.html | |
# Lookup with lambdas so we can do a database call or something | |
CARD_TYPE_COUNTRIES = { | |
'discover' => lambda { ['US'] }, | |
'maestro' => lambda { ['UK'] }, | |
'amex' => lambda { Array.new(1, 'NOWHERE!') }, # Hit database | |
'default' => lambda { ['US','UK','ZA'] } |
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
# From http://rubyquicktips.com/post/350625885/calculate-the-last-day-of-the-month | |
>> Date.civil(2010, 02, -1) | |
=> Sun, 28 Feb 2010 | |
>> Date.civil(2010, -1, -5) | |
=> Mon, 27 Dec 2010 |
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
#!/usr/bin/perl | |
# by entheon, do whatever the hell you want with this file | |
print "\n"; | |
print "**************************\n"; | |
print "*XTERM 256Color Test Chart\n"; | |
print "**************************\n"; | |
print "* 16 = black\n"; | |
print "* 255 = white\n"; |
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
/ignore * joins quits parts |
OlderNewer