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
curl https://gist.githubusercontent.com/deedubs/322b1d91006defe19845/raw/af74902f15cc5c0b18feea264de37a0b9e4286f9/install-nodejs.sh | bash |
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
// Gets user avatar url | |
router.get('/:userId/avatar', function(req, res) { | |
console.log("User", req.user.pictureUrl); | |
if (req.user.pictureUrl) { | |
console.log("redirecting avatar") | |
res.redirect(req.user.pictureUrl) | |
} else { | |
console.log("redirecting default") | |
res.redirect('/img/userProfileAvatar.png') | |
} |
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
User.newPassword = function(user, currentUser, done) { | |
pass.hash(password, function(err, salt, hash) { | |
currentUser.__password = { | |
salt: salt, | |
hash: hash | |
} | |
currentUser.updatedAt = new Date(); | |
User | |
.save(currentUser, done); |
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
User.resetToken = function(user, callback) { | |
console.log('in generateResetToken') | |
User.findOne({email: user.email}, function(err, user) { | |
if(err) { | |
console.log('error') | |
res.send(500) | |
} else { | |
var sha = crypto.createHash('sha1'); | |
console.log('sha ', sha) | |
sha.update((new Date()).toString() + user.email); |
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
$scope.getWidth = function() { | |
return $(window).width(); | |
}; | |
$scope.$watch($scope.getWidth, function(newValue, oldValue) { | |
$scope.window_width = newValue; | |
}); | |
window.onresize = function(){ | |
$scope.$apply(function() { | |
if($scope.window_width < 768) { | |
$rootScope.showMap = false; |
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 stats; | |
app.get('/questions', auth.requireUser, function(req, res) { | |
var status = req.query.status || 'Asked'; | |
Question | |
.where('status', status) | |
.find(function(err, questions) { | |
res.locals({ | |
questions: questions | |
, currentStatus: status |
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.post('/user/ban/:userId', function(req, res){ | |
req.user.bannedReason = req.body.bannedReason; | |
req.user.banned = true; | |
console.log(req.user.id) | |
req.user.save(function(err) { | |
if (err) { | |
req.flash('info','User banned:' + req.body.bannedReason); | |
} else { | |
req.flash('info','User cannot be banned'); | |
} |
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 userSchema = new Schema({ | |
email: String | |
, passwordHash: String | |
}); | |
userSchema.pre('validate', function(next) { | |
if (this.password === this.passwordConfirm) { | |
this.set('passwordHash', hash(this.password); | |
this.set('passwordHash',undefined); |
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
dateFromArray = (dateArr) -> | |
[year, month, day , hour, minute, second, millisecond] = dateArr | |
new Date year, month || 0, day || 0, minute || 0, second || 0, millisecond || 0 |