Skip to content

Instantly share code, notes, and snippets.

View processRouteMap.coffee
processRouteMap = (routes) ->
requirejs.config
nodeRequire: require
paths:
"routeMap" : __dirname + "/../../../app/js/" + "routeMap"
"requireConfig" : __dirname + "/../../../app/js/" + "requireConfig.js"
"text" : __dirname + "/../../../app/js/vendors/requirejs-text/text"
requirejs ["routeMap", "text!requireConfig"], (routeMap, requireConfig) ->
console.log "requireConfig", requireConfig
View findNested.coffee
define ->
findNested = (obj, key, memo) ->
i = undefined
memo = [] if Object::toString.call(memo) isnt "[object Array]"
for i of obj
if Object::hasOwnProperty.call(obj, i)
if i is key
memo.push obj[i]
else findNested obj[i], key, memo if Object::toString.call(obj[i]) is "[object Object]"
memo
View extender.coffee
define [
"underscore"
"when"
], (_, When) ->
return (options) ->
extend = (componentDefinition, wire) ->
When.promise (resolve) ->
View AutoCompleteController.coffee
define ->
class AutoCompleteController
# @injected
input: undefined
# @injected
listCollection: undefined
curId: 0
View cola_collection_updating.coffee
# updating collection
@listCollection.forEach (item) =>
item.port = item.port + "__"
@listCollection.update item
View controller.coffee
define ->
class OrderInfoController
getSource: ->
source =
id: "1"
location: "Rome"
return source
View Express-sockjs-server.js
var express = require('express');
var sockjs = require('sockjs');
var http = require('http');
// 1. Echo sockjs server
var sockjs_opts = {sockjs_url: "http://cdn.sockjs.org/sockjs-0.3.min.js"};
var connections = []
var sockjs_echo = sockjs.createServer(sockjs_opts);
@designeng
designeng / onBuildWrite.coffee
Created Sep 24, 2014
requirejs hook for additiional file processing
View onBuildWrite.coffee
onBuildWrite: (moduleName, path, contents) ->
if path.match "/bower_components/"
pathFragments = path.split "/"
index = 0
libName = undefined
for fragment in pathFragments
if fragment is "bower_components"
libName = pathFragments[index + 1]
console.log "libName::::", libName
View runTask.coffee
define ->
runTask = () ->
task = Array::slice.call(arguments, 0, 1)
rest = Array::slice.call(arguments, 1)
@[task].apply @, rest
View randomInteger.coffee
getRandomInt = (min, max) ->
return Math.floor(Math.random() * (max - min + 1)) + min
You can’t perform that action at this time.