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
var userController = module.exports = { | |
register:function (req, res, next) { | |
var postValues = req.body; | |
var newUser = new userModel(); | |
newUser.saveAndGetErrors(postValues, function(user){ | |
req.session.loggedIn = true; | |
req.session.userId = user._id; | |
if(req.body.returnUrl) res.redirect(res.body.returnUrl); | |
else res.render("/user/profile", {user:user}); | |
}, |
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
app.directive('ngModel', ['$timeout',function($timeout) { | |
return { | |
require: 'ngModel', | |
restrict: 'A', | |
link: function(scope, element, attrs, model) { | |
var timer, | |
delay = 1000; | |
element.bind('keydown change input', function () { | |
if (timer) { |
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
npm config edit | |
change all '\\files' to the local appdata folder eg | |
'\\files\home\maxwillmott\AppData\Roaming\npm\node_modules' | |
to | |
'C:\Users\maxwillmott\AppData\Roaming\npm\node_modules' | |
stuff still won't execute though (karma). create a batch file in the working directory pointing to the relavant command eg |
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
//This could be massively improved and documented | |
function RunRouteActions(dispatcher, routes, state){ | |
var actionsToRun = []; | |
var actionIndex = 0; | |
var activeRouteNames = state.routes.map(function (route) { | |
return route.name; | |
}); |
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
let Rx = require("rx"); | |
Rx.Observable.fromSuperagent = request => () => Rx.Observable.create(observer => { | |
request.end((err, res) => { | |
if (err) { | |
observer.onError(err) | |
} else { | |
observer.onNext(res); | |
} | |
observer.onCompleted(); |
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
let requestStream = Kefir.emitter(); | |
let responseStream = requestStream.map(url => { | |
return Kefir.fromCallback(cb=> request.get(url).end(cb)); | |
}).flatMap(); | |
responseStream.onValue(v=>{ | |
console.log("kefir log",v); | |
}); | |
requestStream.emit("data.json"); |
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
let Kefir = require("kefir"); | |
function BlogStore(actions, initialState) { | |
//map the action stream to a stream which returns a function which modifies the state. | |
let createPost = actions.Post.create.map((newPost) => { | |
//the scan method will call this with the current vaule (allPosts) | |
return (allPosts) => { | |
allPosts.push(newPost); |
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
plugins: [ | |
function () { | |
var distPath = "./dist"; | |
this.plugin("done", function (stats) { | |
var finalFile = stats.toJson().assetsByChunkName.main; | |
fs.readdirSync(distPath).forEach(function (filename) { | |
if (filename !== finalFile) { | |
fs.unlinkSync(distPath + filename); | |
} | |
}) |
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
let d3 = require("d3"); | |
let d3tip = require("d3-tip"); | |
d3tip(d3); |
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
'use 6to5'; | |
const rx = require('rx'); | |
const request = require('request'); | |
const fs = require('fs'); | |
let wrapMethodInRx = (method) => { | |
return function(...args) { | |
return rx.Observable.create((subj) => { | |
// Push the callback as the last parameter |
OlderNewer