This file contains hidden or 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
desc "The default task; lists tasks" | |
task :default do | |
puts `rake --tasks` | |
end | |
desc "Go ahead, you deserve it" | |
task :endulge do | |
puts "You're great. You really are." | |
end |
This file contains hidden or 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 | |
CHECKSUM=$1 | |
FILE=$2 | |
if [[ -z "$CHECKSUM" ]]; then | |
echo "Usage: $0 md5 file" | |
exit 1 | |
elif [[ -z "$FILE" ]]; then | |
echo "Usage: $0 md5 file" |
This file contains hidden or 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
Capybara.register_driver :selenium_de do |app| | |
require 'selenium/webdriver' | |
profile = Selenium::WebDriver::Firefox::Profile.new | |
profile['intl.accept_languages'] = "de" | |
Capybara::Selenium::Driver.new(app, :profile => profile) | |
end | |
Capybara.javascript_driver = :selenium_de |
see https://github.com/ankidroid/Anki-Android/wiki/Database-Structure for a more maintained version of this
This file contains hidden or 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
############################################################################# | |
## | |
## extended_gcd.rb | |
## | |
## given non-negative integers a > b, compute | |
## coefficients s, t such that gcd(a, b) == s*a + t*b | |
## | |
def extended_gcd(a, b) | |
# trivial case first: gcd(a, 0) == 1*a + 0*0 |
Since this is on Hacker News and reddit...
- No, I don't distribute my résumé like this. A friend of mine made a joke about me being the kind of person who would do this, so I did (the link on that page was added later). My actual résumé is a good bit crazier.
- I apologize for the use of
_t
in my types. I spend a lot of time at a level where I can do that; "reserved for system libraries? I am the system libraries". - Since people kept complaining, I've fixed the assignments of string literals to non-const
char *
s. - My use of
type * name
, however, is entirely intentional. - If you're using an older compiler, you might have trouble with the anonymous unions and the designated initializers - I think gcc 4.4 requires some extra braces to get them working together. Anything reasonably recent should work fine. Clang and gcc (newer than 4.4, at le
This was my solution for a polymorphic many-to-many association
class ItemCountry < ActiveRecord::Base
belongs_to :locatable, :polymorphic => true
belongs_to :country
# fields are :locatable_id, :locatable_type, :country_id
end
class Title < ActiveRecord::Base
has_many :countries, :through => :item_countries, :as => :locatable