Skip to content

Instantly share code, notes, and snippets.

View tanelsuurhans's full-sized avatar

Tanel Suurhans tanelsuurhans

  • ID.me
  • United States
View GitHub Profile
paypal_response = AdaptivePay::Callback.new(params)
if paypal_response.status == "COMPLETED"
@purchase.complete!
end
subject.location.should == "02108"
subject.location = "02108"
subject.location_changed?.should be_false
'User should not attempt to geocode location if location has not changed' FAILED
expected true to be false
try {
PreparedStatement query = sqlite.prepare("REPLACE INTO homes(player_name, world, x, y, z) values(?, ?, ?, ?, ?)");
query.setString(1, player.getDisplayName());
query.setString(2, player.getWorld().getName());
query.setDouble(3, location.getX());
query.setDouble(4, location.getY());
query.setDouble(5, location.getZ());
try {
PreparedStatement query = sqlite.prepare("SELECT * FROM homes where player_name = ?");
query.setString(1, player.getDisplayName());
ResultSet result = query.executeQuery();
if (result.next()) {
module ActiveRecord
module AdvisoryLock
def obtain_advisory_lock(key, type = nil, &block)
raise ArgumentError, "Method expects a block" unless block_given?
obtain_lock(key, type)
begin
yield block
def value=(value)
write_attribute(:value, value.gsub(/<your regexp>/, ''))
end
class UserPassword
include ActiveModel::Validations
include ActiveModel::Validations::Callbacks
include ActiveModel::Conversion
extend ActiveModel::Naming
extend ActiveModel::Translation
attr_accessor :email
auth = Twitter::OAuth.new(TWITTER_TOKEN, TWITTER_SECRET)
auth.authorize_from_access(TWITTER_ACCESS_TOKEN, TWITTER_ACCESS_SECRET)
base = Twitter::Base.new(auth)
base.update("#{title} - #{url}")
# TODO - add dependent option support
def delete_records(records)
case @reflection.through_reflection.options[:dependent]
when :destroy
records.each do |associate|
@reflection.through_reflection.klass.destroy_all(construct_join_attributes(associate))
end
when :delete_all
@reflection.through_reflection.klass.delete(records.map { |record| record.id })
else
RSpec.configure do |config|
config.include Paperclip::Shoulda::Matchers
config.mock_with :mocha
config.use_transactional_fixtures = true
config.before(:all) do
geocode_payload = GeoKit::GeoLoc.new(:lat => 123.456, :lng => 123.456)
geocode_payload.success = true
GeoKit::Geocoders::MultiGeocoder.stubs(:geocode => nil)
end