Skip to content

Instantly share code, notes, and snippets.

@thoughtshop
thoughtshop / zeroisfalsy
Last active December 31, 2015 03:49
evil javascript
if (0) { "good job" }
>> undefined
if (1) { "good job" }
>> "good job"
<settlement>
<pmt1> # Debitware goes first
<devicetype>16</devicetype> # specifies Debitware
<swipe_no>1233</swipe_no> # it's not documented which Debitware fields are required/used
..... # Other Debitware Fields ??????
<amount>100.00</amount> # The amount specified by the guest they would like to pay with their gift card
<tax>12.00</tax> # should this be the proportion of tax paid by the debitware amount?
</pmt1>
<pmt2>
<devicetype>15</devicetype> # is this still optional in this case?
@thoughtshop
thoughtshop / gist:7608619
Created November 22, 2013 23:26
access control headers for node web sockets server
app = require('express')();
...
app.use(function(req, res, next) {
res.header('Access-Control-Allow-Origin', '*');
res.header('Access-Control-Allow-Methods', 'GET, OPTIONS');
res.header('Access-Control-Allow-Headers', 'Content-Type');
return next();
});
@thoughtshop
thoughtshop / gist:7501856
Created November 16, 2013 16:01
TransactionReport vs TransactionReport per StaffMember
if clumsy
staff_members = StaffMember.alphabetical
@reports = staff_members.map {|s| [ s, TransactionReport.where(:staff_member_id => s.id).where(:created_at => @date_range) ]}
end # 3000ms
if smart
report = TransactionReport.where(:created_at => @date_range)
@reports = report.group_by(&:staff_member).sort_by{|g| [g.first.last_name, g.first.first_name] }
end # 8000ms
<h1>hypothesis: first gen ipad is slow when typing in content editables</h1>
<label>textarea. should be snappy.</label>
<textarea rows=5 cols=70></textarea>
<label>content editable. should be laggy</label>
<div style="height: 50px; border: 1px solid #000;" contenteditable></div>
module MultiTenantedCacheKeys
def cache_key
tenant_database_name + "/" + super
end
def tenant_database_name
Apartment::Database.current_database
end
end