This file contains 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 | |
privateMethod = -> | |
console.log "privateMethod" | |
publicMethod: -> | |
console.log "publicMethod" | |
privateMethod() | |
@staticMethod: -> |
This file contains 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
function getClass(object) { | |
return Object.prototype.toString.call(object).match(/^\[object\s(.*)\]$/)[1].toLowerCase(); | |
} | |
var o = {'hello':'world'}; | |
console.log(typeof o, getClass(o)); // object, object | |
var a = ['hello','world']; | |
console.log(typeof a, getClass(a)); // object, array |
This file contains 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 HelloCoffeeTest | |
@testMain: -> | |
console.log "Hello, CoffeeScripter!" | |
HelloCoffeeTest.testMain() |
This file contains 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
#!/bin/bash | |
set -o errexit | |
# Author: David Underhill | |
# Script to permanently delete files/folders from your git repository. To use | |
# it, cd to your repository's root and then run the script with a list of paths | |
# you want to delete, e.g., git-delete-history path1 path2 | |
if [ $# -eq 0 ]; then | |
exit 0 |
This file contains 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
// http://html5doctor.com/drag-and-drop-to-server/ | |
var acceptedTypes = { | |
'image/png': true, | |
'image/jpeg': true, | |
'image/gif': true | |
}; | |
if (acceptedTypes[file.type] === true) { | |
var reader = new FileReader(); |
This file contains 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
# Full code at https://gist.github.com/1406349/fa7c357b86790c183f3ef81ad6870b78bb2de343 | |
window.assets = { | |
<% | |
Dir.glob(Rails.root.join("app/assets/images/**/*.*")).map do |path| | |
img_name = path.gsub(Rails.root.join("app/assets/images/").to_s, "") %> | |
"<%= img_name %>": "<%= asset_path(img_name) %>", | |
<% end %> | |
} |
This file contains 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 | |
_myPrivateVar = "foo bar" | |
@:: __defineGetter__ "myVar", -> | |
_myPrivateVar | |
@:: __defineSetter__ "myVar", (value) -> | |
_myPrivateVar = value | |
This file contains 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
Show hidden characters
// Add this file in ~/Library/Application Support/Sublime Text 2/Packages/User/ | |
{ | |
"cmd": ["coffee", "-cp", "--bare", "$file"], | |
"selector": "source.coffee", | |
"path": "/usr/bin" | |
} |
This file contains 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
Include = | |
savePrevious: -> | |
@constructor.records[@id].previousAttributes = @attributes() | |
Spine.Model.Dirty = | |
extended: -> | |
@bind 'refresh', -> | |
@each (record) -> record.savePrevious() | |
@bind 'save', (record) -> |
This file contains 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
# A more caffeinated way to call setTimeout and setInterval. By @kneath | |
window.after = (ms, cb) -> setTimeout cb, ms | |
window.every = (ms, cb) -> setInterval cb, ms |
OlderNewer