Skip to content

Instantly share code, notes, and snippets.

list = [0...10]
otherList = [0...10]
zip = (arrays...) ->
length = 0
for array in arrays when array.length > length
length = array.length
for i in [0...length]
array[i] for array in arrays
clone = (item) ->
newItem = {}
for property, value of item
newItem[property] = value
newItem
var json_data = JSON.stringify({
"STATUS_ID is": status,
"COMMAND is": command_str.trim(),
"RESULT is": result_str
},
null, '\n');
@Dykam
Dykam / gist:808153
Created February 2, 2011 18:42
javascript `with` immitated in coffeescript
withy = (object, props) ->
if typeof props == "function"
props.apply object
else
for property, value of props
object[property] = value
object
console.log withy {},
foo: "bar"
# get all tweets and the number of likes, which is from another source
data
from tweets, as tweet
zip facebook.likes, as likes
# is transformed to
from(tweets, (data, tweet) -> data.tweet = tweet)
.zip(facebook.likes, (data, likes) -> data.likes = likes)
# get all direct messages and bundle the senders last 10 tweets with it
from directMessages, as dm
Foo:
Bar:
class Zar:
constructor: ->
class Zoo:
constructor: ->
#or
Foo:
Bar:
Zar: class
<html>
<head>
<title>foo</title>
</head>
</html>
{
".Foo": [],
".Foo": "ContentWhichYouNeverWillSee"
}
<span id="NotLoggedIn">You are not logged in! Please log in.</span>
@Dykam
Dykam / gist:749167
Created December 20, 2010 22:55
Html templates, my way
<html>
<head>
<title>Template</title>
</head>
<body>
<div class="Content">
<h1>Post Title</h1>
<p class="Item"></p>
<p class="Author"></p>
</div>