Skip to content

Instantly share code, notes, and snippets.

View randallb's full-sized avatar
🎬

Randall Bennett randallb

🎬
View GitHub Profile
for relation in relations
for key, value of relation
console.log "#{key}: #{value}"
if typeof value is "object"
for subkey, subvalue of value
console.log "inner: #{subkey}: #{subvalue}"
if subvalue is "newId"
console.log "I changed #{subkey} from #{subvalue} to #{id}."
value[subvalue] = id
console.log subvalue
app.get "/person/:wid("+ people.idRegex +")/remove"
becomes
app.get("/person/:wid(" + people.idRegex(+")/remove"));
when I'm trying to get
app.get("/person/:wid(" + people.idRegex +")/remove");
@randallb
randallb / gist:1108728
Created July 27, 2011 05:15
bugmodel.js
exports.test = function(){
console.log(this)
}
@randallb
randallb / gist:1108725
Created July 27, 2011 05:14
Bug.js app
// Main bug.js app
express = require("express");
app = express.createServer();
bugmodel = require("./bugmodel");
anotherContext = function(req, res, next){
bugmodel.test();
};
var getUsers;
getUsers = function(peopleArray, callback) {
var person, _i, _len, _results;
_results = [];
for (_i = 0, _len = people.length; _i < _len; _i++) {
person = people[_i];
_results.push(getUser(person, function(err, response) {
users.push(response);
return res.users = users;
}));
exports.list = (req, res, next) ->
users = new Array
getList (err, response) ->
if err?
next err
else
people = response
for person in people
getUser person, (err, callback) ->
users.push(response)
exports.register = function(req, res, next) {
var client;
client = this.client;
return exports.validate(req, res, function() {
return client.hmset("person:" + req.body.wid, req.body, function(err, response) {
if (err != null) {
return next(err);
} else {
req.newUser = req.body;
console.log("success. Saved record.");