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
for i in [i * 0.1 for i in range(0, 10)]: | |
print i |
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
def is_prime(n): | |
if n % 2 == 0: | |
return False | |
for i in range(3, n/2, 2): | |
if n % i == 0: | |
return False | |
return True |
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
distance = 2000000 | |
primes = [1] * distance | |
def set_primes(): | |
primes[0] = 0 | |
primes[1] = 0 | |
for i in range(3, distance, 2): | |
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 http = require('http'); | |
var server = http.createServer(function(req, res) { | |
res.writeHead(200); | |
res.end('Hello World'); | |
}); | |
server.listen(8000); |
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 foo = 'foo' | |
, bar = 'bar' | |
, lul = 'lul' | |
; | |
var foo = 'foo', | |
bar = 'bar', | |
lul = 'lul'; |
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
[ | |
{ "name" : "Dustin", "_id" : { "$oid" : "5019968ccc93742e0d0bba0b" }, "age" : 29 }, | |
{ "name" : "Steve", "_id" : { "$oid" : "5019969acc93742e0d0bba0c" } }, | |
] |
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 default_vars = { | |
title: 'Serious Title Stuffs' | |
}; | |
exports.index = function(req, res){ | |
default_vars.title = default_vars.title + ' Index Page'; | |
res.render('index', default_vars); | |
}; | |
exports.dustin = function(req, res) { |
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
controller.index = function(req, res, next) { | |
db.users.find({}, function(err, docs) { | |
console.log(err + ' ' + docs); | |
res.render('user/index', {users: docs}); | |
}); | |
}; |
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
//controller | |
controller.index = function(req, res, next) { | |
var users = db.users.getUsers(); | |
res.render('user/index', {users: users}); | |
}; | |
//model | |
User.statics.getUsers = function(callback) { | |
//somehow return here... this approach is not asynchronous |
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
controller.profile.save = function(req, res, next) { | |
var Profile = db.main.model('Profile'), | |
profile = req.body.profile; | |
Profile.findOne({'_id': profile.id}, function(err, _profile) { | |
if(err) return next(err); | |
if(null == _profile) { | |
_profile = new Profile(profile); |
OlderNewer