Skip to content

Instantly share code, notes, and snippets.

@rgraff
rgraff / custom_hash_handler.rb
Created October 16, 2013 02:19
This is an example of how you might use Oj::ScHandler to replicate the :class_object feature of JSON::Ext::Parser
class CustomHashHandler < Oj::ScHandler
attr_accessor :output
class HandlerHash < Hash
def method_missing(method)
return self[method] if key?(method)
super
end
end
@rgraff
rgraff / gist:1141424
Created August 12, 2011 04:02
Best Nigerian 401 Scam Ever!
Attn:
My name is Sheik Obente Kantanka, the son of late great herbalist, spiritualist and Native Doctor Obisa Kantanka
who dead two years ago.
After the death of my father I inherited his temple and I have been working for so many people, I came across your
name in a local calabash drained with rope and something where written on it saying that you can never receive your
inherited funds in Africa until you uncover what is covered to ordinary humans.
The problem that you are having receiving your funds , gold from Africa is that the owner of the money secured the
def should_assign_to(*names)
names.each do |name|
it "should assign @#{name}" do
# assert assigns(name.to_sym), "The action isn't assigning to @#{name}"
end
end
end
Factory.define :venue do |v|
v.name 'Foo Place'
v.url {Factory.next(:url_slug)}
v.address_hint 'MyString'
v.phone '(805) 555-1212'
v.capacity 'MyString'
v.website 'example.com'
v.image 'MyString'
v.description 'MyText'
v.directions 'MyText'
# done
# -- Matthew Peychich
Factory.define :venue do |v|
v.name 'Foo Place'
v.url {Factory.next(:url_slug)}
v.address_hint 'MyString'
v.phone '(805) 555-1212'
v.capacity 'MyString'
v.website 'example.com'
v.image 'MyString'
# In application_controller
def current_postal
@postal_code ||= PostalCode.find_first_valid_in_united_states(
[params[:postal_code], previous_postal_requests.last, postal_from_geoip, 90013],
:include=>:territory)
end
# In postal_code.rb
Price Range Requirements/Algorithm:
===================================
The price ranges for an offergroup are determined by:
if offergroup has offersets with status 'open' or 'expired' and 1 offer with quantity > 0:
Using only those offersets, find offers that have quantity available:
if any offers have quantity available:
Using those offers, calculate price ranges
replace '$0.00' with 'FREE' in ourprice range
else:
def calc_cached_price_ranges()
cached_our_price = "n/a" # not nil, so we don't perpetually re-calculate
cached_full_price = "n/a" # not nil, so we don't perpetually re-calculate
find active_and_expired_offersets (status IN ('active','expired'))
if (active_and_expired_offersets)
# we have active offersets, so we want to look at all the offers.
@rgraff
rgraff / gist:67895
Created February 21, 2009 04:48 — forked from jseifer/gist:67727
On Feb 20, 2009, at 4:24 PM, "Olusegun A.A" <xxxxxx@gmail.com> wrote:
** CRAIGSLIST ADVISORY --- AVOID SCAMS BY DEALING LOCALLY
** Avoid: wiring money, cross-border deals, work-at-home
** Beware: cashier checks, money orders, escrow, shipping
** More Info: http://www.craigslist.org/about/scams.html
Hello,
Do you still have this item available for sale at the moment? Get back asap.
<script type="text/javascript">
<!--//
var submitted = 0;
function showProcessing() {
if (submitted) {
return;
} else {
submitted = 1;
// show some processing overlay for visual feedback
document.forms.gse_checkout.submit();