Skip to content

Instantly share code, notes, and snippets.

View deedubs's full-sized avatar
:shipit:
kustomize build all-the-things | kubectl apply -f -

Dan Williams deedubs

:shipit:
kustomize build all-the-things | kubectl apply -f -
View GitHub Profile
curl https://gist.githubusercontent.com/deedubs/322b1d91006defe19845/raw/af74902f15cc5c0b18feea264de37a0b9e4286f9/install-nodejs.sh | bash
@deedubs
deedubs / backend
Last active December 11, 2015 11:38 — forked from shinecita/backend
// 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')
}
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);
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);
$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;
@deedubs
deedubs / gist:1944854
Created February 29, 2012 22:10
callbacking
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
@deedubs
deedubs / Fixed.
Created February 21, 2012 18:20
Post Ban
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');
}
@deedubs
deedubs / index.js
Created January 19, 2012 19:04 — forked from shiawuen/index.js
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);
@deedubs
deedubs / gist:1307483
Created October 23, 2011 15:37 — forked from fbuchinger/gist:1307476
datefromarray
dateFromArray = (dateArr) ->
[year, month, day , hour, minute, second, millisecond] = dateArr
new Date year, month || 0, day || 0, minute || 0, second || 0, millisecond || 0