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
package dim.mars.rovers; | |
import java.io.BufferedReader; | |
import java.io.FileReader; | |
public class MarsRovers { | |
static final String dirs = "NESW"; | |
static final int[][] dirShifts = { { 0, 1 }, { 1, 0 }, { 0, -1 }, { -1, 0 } }; | |
static final int dirCount = dirs.length(); | |
static int xMin = 0, yMin = 0, xMax, yMax; |
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 ActiveRecord::Base | |
class << self | |
[:conditions, :order, :group, :having, :limit, :offset, :joins, :include, :select, :from, :readonly, :lock].each do |m| | |
send(:define_method, m) do |arg| | |
scoped(m => arg) | |
end | |
end | |
alias_method :where, :conditions | |
alias_method :start, :offset |
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
apt-get install xvfb | |
apt-get install firefox |
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
git log --format="%an" | sort | uniq -c | sort -nr |
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 PaypalRecurringGateway < ActiveMerchant::Billing::PaypalGateway | |
NS2 = 'n2:' | |
self.default_currency = 'USD' | |
def create_recurring(money, credit_card, options = {}) | |
request = create_recurring_request(money, credit_card, options) | |
commit("CreateRecurringPaymentsProfile", request) | |
end | |
def update_recurring(money, profile_id, options = {}) |
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 Rover | |
MOVE = { | |
'N' => lambda{ |position| position[:y] += 1 }, | |
'E' => lambda{ |position| position[:x] += 1 }, | |
'S' => lambda{ |position| position[:y] -= 1 }, | |
'W' => lambda{ |position| position[:x] -= 1 } | |
}.freeze | |
ROTATE = { |
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
source :rubygems | |
gem 'rails', '3.0.9' | |
gem 'mysql2', '0.2.10' | |
gem 'devise' | |
gem 'devise_invitable' | |
gem 'validation_reflection' | |
gem 'paperclip' | |
gem 'sass' | |
gem 'activemerchant', :require => 'active_merchant' |
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
Date.today = function() { | |
return (new Date()).beginningOfDay(); | |
} | |
Date.prototype.beginningOfDay = function() { | |
var result = new Date(this); | |
result.setHours(0); | |
result.setMinutes(0); | |
result.setSeconds(0); | |
result.setMilliseconds(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
sudo rm -rf /usr/local/mysql* | |
sudo rm -rf /Library/StartupItems/MySQLCOM | |
sudo rm -rf /Library/PreferencePanes/My* | |
sudo rm -rf /Library/Receipts/mysql* | |
sudo rm -rf /Library/Receipts/MySQL* | |
sudo rm -rf /var/db/receipts/com.mysql.* | |
sudo rm /etc/my.cnf | |
sudo vi /etc/hostconfig and delete string MYSQLCOM=-YES- | |
Download from http://dev.mysql.com/downloads/mysql/5.1.html#downloads |
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
# put the file into spec/support | |
shared_examples_for "ActiveModel" do | |
include ActiveModel::Lint::Tests | |
# to_s is to support ruby-1.9 | |
ActiveModel::Lint::Tests.public_instance_methods.map{|m| m.to_s}.grep(/^test/).each do |m| | |
example m.gsub('_',' ') do | |
send m | |
end | |
end |
OlderNewer