Skip to content

Instantly share code, notes, and snippets.

DOWNLOAD_CONCURRENCY = 10
# Data Structures
longPollRequests = []
jobs = {}
downloadQueue = async.queue (photo, callback) ->
# Here we define the task handled by this concurrency-limiting queue.
downloadfile = photo.url
host = url.parse(downloadfile).hostname
filename = url.parse(downloadfile).pathname.split("/").pop()
@machty
machty / Assetfile
Last active December 10, 2015 08:48
Rake Pipeline filter for syncing already-published static content on production with the generated local file via Nokogiri and css selectors
require "rake-pipeline-web-filters"
require "./remote-replace-filter"
# specify output, other configuration
input "app" do
match "slim/whatever.slim" do
tilt { |input| input.sub(/\.slim$/, '.html') }
copy "index.html"
@machty
machty / emblem
Last active December 10, 2015 19:29
Emblem/Emblate: indentation-based templating language targeting Ember Handlebars
Emblem examples:
1) Text / property lookup / helpers
#bar.baz Raw text
#bar.baz
| Raw text
on multiple lines
with {{normal}} Handlebars syntax support
as well as raw <span>HTML</span> support.
@machty
machty / newoperator.coffee
Created January 9, 2013 22:48
Proposal: add block level lambda ~> operator to CoffeeScript to hackishly achieve block level lambda functionality in pre ES6 Javascript. An example of block level lambdas is returning a value from within a .each loop in Ruby. See below.
findTheThingWeWant = (things) ->
things.each (thing) ~>
return item if thing.isWhatWeWant
// Version: v1.0.0-pre.2-318-g075ed98
// Last commit: 075ed98 (2013-01-07 10:58:00 -0800)
(function() {
/*global __fail__*/
/**
Ember Debug
State = (hash) -> Em.State.extend hash
TransitionTo = Em.State.transitionTo
C = null
Receivers.WithdrawController = Em.ObjectController.extend
receiverController: null
router: null
init: ->
@_super()
start = content
content = statement*
statement
= html
/ mustache
html
= htmlMaybeBlock
this.StringScanner = (function() {
var StringScanner;
StringScanner = (function() {
function StringScanner(str) {
this.str = str != null ? str : '';
this.str = '' + this.str;
this.pos = 0;
this.lastMatch = {
reset: function() {
@machty
machty / hackathon
Last active December 12, 2015 10:08
all the emblem.js code i wrote for a hackathon
outlet
a.not-ad href="#" click="read target='view'" style=view.linkStyle
p == title
nav.top-bar
.social
each socials
partial social_item
@machty
machty / spec_spec_spec.js.coffee
Created February 11, 2013 20:33
mini konacha
#= require spec_helper
#= require manifest
#= require application
describe "web app", ->
beforeEach -> window.manifest = MANIFEST
it "exists", ->
assert.ok Fashionhack