Skip to content

Instantly share code, notes, and snippets.

View stephenprater's full-sized avatar

Prater stephenprater

View GitHub Profile
class QueryNode.Literal
constructor: (@arg)->
toJSON:()->
switch typeof(@arg)
when 'string' then "\"#{@arg}\""
when 'number', 'boolean' then @arg
when 'object'
if @arg == null
@arg
else
class MyDumbPresenter
attr_accessor :the_thing, :something
attr_writer :the_rest
def initialize(*all_the_things)
self.the_thing, self.something, self.the_rest = all_the_things
end
def has_the_thing?
if the_thing.present?
@stephenprater
stephenprater / gist:7382383
Created November 9, 2013 06:21
explicitly passed block argument is implicitly passed with super - ?
class A
def foo(a = 'foo', &b)
puts a
yield if block_given?
end
end
class B < A
def foo(a, &b)
puts a
[{:id=>"190498", :recordtype=>"inventoryitem", :columns=>{:internalid=>{:name=>"190498", :internalid=>"190498"}, :vendor=>{:name=>"J Tillman", :internalid=>"130669"}, :displayname=>"JT-864-L-GOLD", :custitem22=>10000, :quantitybackordered=>20, :preferredstocklevel=>0, :reorderpoint=>0, :reordermultiple=>6, :custentity_po_transmission_method=>{:name=>"fax", :internalid=>"2"}, :custentity_drop_ship_all=>false, :custentity_min_order_amount=>100, :upccode=>"608134086404", :cost=>9.6, :custentity_automate_po=>true}}, {:id=>"190501", :recordtype=>"inventoryitem", :columns=>{:internalid=>{:name=>"190501", :internalid=>"190501"}, :vendor=>{:name=>"J Tillman", :internalid=>"130669"}, :displayname=>"JT-864-XL-GOLD", :custitem22=>10000, :quantitybackordered=>14, :preferredstocklevel=>0, :reorderpoint=>0, :reordermultiple=>6, :custentity_po_transmission_method=>{:name=>"fax", :internalid=>"2"}, :custentity_drop_ship_all=>false, :custentity_min_order_amount=>100, :upccode=>"608134086442", :cost=>9.6, :custentity_automate_
@stephenprater
stephenprater / diffconflicts.sh
Created June 4, 2013 14:25
vim diff twopane
#!/bin/bash
# Instead of editing a file with <<<< ==== >>> conflict markers, this opens
# each "side" of the conflict markers in a two-way vimdiff window.
#
# Layout:
#
# Tab1 is a two-way diff of the conflicts.
# +--------------------------------+
# | LCONFL | RCONFL |
# +--------------------------------+
@stephenprater
stephenprater / gist:5556109
Last active December 17, 2015 05:09
json sample
{
"user": {
"status": "errors",
"errors": {},
"id": 7,
"wp_id": 6,
"name": "Lysanne Rodriguez",
"email": "esther_zulauf@wolff.us",
"birthdate": "1960-05-14",
"address1": "505 Dave Court",
@stephenprater
stephenprater / gist:5462630
Created April 25, 2013 19:55
database.yml that's not working
# gem install sqlite3
#
# Ensure the SQLite 3 gem is defined in your Gemfile
# gem 'sqlite3'
#legacy:
# adapter: mysql2
# database: Sofab_DW
# user: coll02sa
# password: hbZhGM1uvV7toebV
# host: localhost
host_add() {
sudo echo "${2} ${1}" >> /etc/hosts
sudo killall -HUP mDNSResponder
dscacheutil -q host -a name $1
}
host_del() {
sed "/$1/d" /etc/hosts > /tmp/tmp-host
sudo mv /tmp/tmp-host /etc/hosts
sudo killall -HUP mDNSResponder
@stephenprater
stephenprater / gist:5246103
Created March 26, 2013 15:10
rails date formate
<div class="controls controls-row">
<input id="user_birthdate_2i" name="party[start_time(2i)]" type="hidden" value="4">
<input id="user_birthdate_3i" name="party[start_time(3i)]" type="hidden" value="12">
<input id="user_birthdate_4i" name="party[start_time(4i)]" type="hidden" value="0">
<input id="user_birthdate_5i" name="party[start_time(5i)]" type="hidden" value="0">
</div>
@stephenprater
stephenprater / gist:5190175
Created March 18, 2013 19:38
what the what?
[47] pry(#<Class>)> RSpec::Core::Example.new(self,"whatever",{}, Proc.new { raise "hello" } )
=> #<RSpec::Core::Example:0x007f9282327c08
@example_block=nil,
@example_group_class=nil,
@exception=nil,
@metadata=nil,
@options=nil,
@pending_declared_in_example=nil>