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
# http://challenge.greplin.com/ | |
# author: Thomas Shaddox | |
# twitter @baddox | |
# facebook.com/tshaddox | |
# tshaddox.com | |
def one(): | |
s = "Fourscoreandsevenyearsagoourfaathersbroughtforthonthiscontainentanew\ | |
nationconceivedinzLibertyanddedicatedtothepropositionthatallmenarecreated\ | |
equalNowweareengagedinagreahtcivilwartestingwhetherthatnaptionoranynartio\ |
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
av = ActionView::Base.new(Rails::Configuration.new.view_path) | |
av.render( | |
{:text => this_goes_to_yield, :layout => "layouts/blah.html.erb"}, # the options hash | |
{:title => 'blah', :body => 'hello'} # the locals hash | |
) |
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
require 'find' | |
require 'mp3info' | |
class ArtistsHash < Hash | |
def initialize | |
super | |
self.default_proc = proc do |h, artist_name| | |
h[artist_name] = AlbumsHash.new | |
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
# Thomas Shaddox | |
# https://github.com/baddox | |
# Assumes birthdays are independent (i.e. uniformly distributed) | |
days = 365 | |
ppl = 290 # I'm so popular | |
trials = 10_000 | |
at_least_four = 0 | |
trials.times do | |
array = [0] * days |
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
{ | |
:stream => [ | |
{ | |
:user => external_hash, # perhaps some sort of partial or ad hoc hash | |
:type => "leaderboard|challenge", | |
# slightly counterintuitively, challenge will always be present | |
# even if type is leaderboard |
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
irb(main):010:0> puts(<<X, <<Y) | |
irb(main):011:1" this is x | |
irb(main):012:1" X | |
irb(main):013:1" this is y | |
irb(main):014:1" Y | |
this is x | |
this is y | |
=> nil |
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
a = [1,2,3] | |
# => [1, 2, 3] | |
enum = a.map! | |
# => #<Enumerator: [1, 2, 3]:map!> | |
enum.map(&:to_s) | |
# => ["1", "2", "3"] | |
a |
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
### Keybase proof | |
I hereby claim: | |
* I am baddox on github. | |
* I am shaddox (https://keybase.io/shaddox) on keybase. | |
* I have a public key whose fingerprint is 326A 3C60 FFEE 147E 9611 6560 413A 661B 220C B38D | |
To claim this, I am signing this object: |
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
# Instructions | |
# install required packages by running: | |
# gem install json typhoeus awesome_print | |
# Download this .rb into a new directory on your PC (called something like "pinboard" or whatever) | |
# Fill out KIPPT_USERNAME, KIPPT_API_TOKEN, and PINBOARD_AUTH_TOKEN (below) by changing xxx to the real value. | |
# Run the script by running |
OlderNewer