Skip to content

Instantly share code, notes, and snippets.

# updating collection
@listCollection.forEach (item) =>
item.port = item.port + "__"
@listCollection.update item
define ->
class OrderInfoController
getSource: ->
source =
id: "1"
location: "Rome"
return source
@designeng
designeng / Express-sockjs-server.js
Created July 17, 2014 19:23
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 September 24, 2014 14:01
requirejs hook for additiional file processing
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
getRandomInt = (min, max) ->
return Math.floor(Math.random() * (max - min + 1)) + min
define ->
runTask = () ->
task = Array::slice.call(arguments, 0, 1)
rest = Array::slice.call(arguments, 1)
@[task].apply @, rest
@designeng
designeng / passwordSealer.js
Created October 5, 2015 17:43 — forked from ryasmi/passwordSealer.js
An example of using Douglas Crockford's JavaScript Sealer/Unsealer method for securely authenticating users. http://www.yuiblog.com/blog/2010/02/24/video-crockonjs-3/
var makeSealer = function () {
var users = [], passwords = [];
return {
sealer: function (username, password) {
var i = users.length,
user = {username: username};
users[i] = user;
passwords[i] = password;
return user;
@designeng
designeng / gulpfile.js
Created November 30, 2015 21:01 — forked from danharper/gulpfile.js
New ES6 project with Babel, Browserify & Gulp
var gulp = require('gulp');
var sourcemaps = require('gulp-sourcemaps');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
var browserify = require('browserify');
var watchify = require('watchify');
var babel = require('babelify');
function compile(watch) {
var bundler = watchify(browserify('./src/index.js', { debug: true }).transform(babel));
var app = require('../../server/app.js');
var model = require('../../model.js');
var request = require('supertest');
var apitest = request(app);
describe('integration', function () {
it('model.json post should throw 500 error without args', function (done) {
apitest.post('/model.json')
.expect(500, done);
var ItemsRouter = Router.createClass([
{
route: 'items.length',
get: () => {
return {path: ['items', 'length'], value: data.items.length}
}
}
]);