This file contains hidden or 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
Model.findByName = (name, value, cb) -> | |
model = new @ | |
@find "SELECT * FROM #{model.tableName()} WHERE `#{name}`=`#{value}` LIMIT 1", cb |
This file contains hidden or 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
{ WeekendInfo: | |
{ TrackName: 'okayama short', | |
TrackID: 167, | |
TrackLength: '1.93 km', | |
TrackDisplayName: 'Okayama International Circuit', | |
TrackDisplayShortName: 'Okayama Short', | |
TrackCity: 'Okayama', | |
TrackCountry: 'Japan', | |
TrackAltitude: '265.84 m', | |
TrackLatitude: '34.914295 m', |
This file contains hidden or 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 Foo | |
constructor: -> | |
return new Foo() unless @ instanceof Foo | |
# Guaranteed to be an object here | |
@announce() | |
announce: -> console.log "here!" | |
# These are equivalent now |
This file contains hidden or 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
def do_post(account_id, endpoint, params={}) | |
r = RestClient::Resource.new( | |
api_url(account_id) + endpoint + ".json", | |
:headers => headers | |
) | |
# RestClient doesn't convert the POST parameters to | |
# JSON, so we have to do it manually. This was the | |
# big gotcha, and why we were getting 415 Unsupported | |
# Media Type as the error response. |
This file contains hidden or 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
psd = psd.fromFile "/path/to/file.psd" | |
psd.parse() | |
data = psd.toJSON() | |
# PS <= 5.0 | |
console.log data.layerMask.layers[0].adjustments.legacyEffects | |
# PS >= 6.0 | |
console.log data.layerMask.layers[0].adjustments.effects |
This file contains hidden or 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
// First, initialize Caman (only do this once) | |
caman = Caman("#image-id"); | |
// This will be called when a slider is adjusted | |
var applyFilters = function () { | |
// Revert the canvas to its original state. This is asynchronous. | |
caman.revert(function () { | |
// Once canvas is ready, go through each slider and call filter | |
var slider; | |
for (var key in sliders) { |
This file contains hidden or 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
<style type="text/css"> | |
#parent { position: relative; } | |
#fixed { | |
position: absolute; | |
top: 10px; | |
left: 10px; | |
} | |
#content { overflow: auto; } | |
</style> |
This file contains hidden or 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 Rectangle extends BinData.Record | |
endian: "little" | |
parse: -> | |
uint16 "len" | |
string "name", readLength: len | |
uint32 "width" | |
uint32 "height" | |
r = new Rectangle(file) | |
console.log "Rectangle #{r.name} is #{r.width} x #{r.height}" |
This file contains hidden or 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
parseRLE: -> | |
Log.debug "Attempting to parse RLE encoded image..." | |
# RLE stores the scan line byte counts in the first chunk of data | |
byteCounts = [] | |
for i in [[email protected]] | |
for j in [0...@height] | |
byteCounts.push @file.readShortInt() | |
Log.debug "Read byte counts. Current pos = #{@file.tell()}, Pixels = #{@length}" |
This file contains hidden or 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
parseRLE: -> | |
Log.debug "Attempting to parse RLE encoded image..." | |
# RLE stores the scan line byte counts in the first chunk of data | |
byteCounts = [] | |
for i in [[email protected]] | |
for j in [0...@height] | |
byteCounts.push @file.readShortInt() | |
Log.debug "Read byte counts. Current pos = #{@file.tell()}, Pixels = #{@length}, End = #{@endPos}" |