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
bundle.register('.jade', function (body) {
var options = {"client": true, "compileDebug": false};
body = "module.exports = " + jade.compile(body, options).toString() +";";
return body;
});
@deedubs
deedubs / gist:3819486
Created October 2, 2012 14:17
quick hack
var sessionCookie = cookie.parse(handshakeData.headers.cookie)
, parsedCookie = connect.utils.parseJSONCookies(connect.utils.parseSignedCookies(sessionCookie, config.sessionSecret))['connect.sess'];
Chrome 22.0: Executed 5 of 5 SUCCESS (0.28 secs / 0.013 secs)
PhantomJS 1.6: Executed 5 of 5 SUCCESS (0.44 secs / 0.015 secs)
Safari 7534.48: Executed 5 of 5 SUCCESS (4.624 secs / 0.067 secs)
Safari 7534.48: Executed 5 of 5 SUCCESS (4.615 secs / 0.031 secs)
$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:4136146
Created November 23, 2012 15:35
Houston, We have a problem
64 bytes from 74.125.225.34: icmp_seq=242 ttl=56 time=671.851 ms
64 bytes from 74.125.225.34: icmp_seq=243 ttl=56 time=300.758 ms
64 bytes from 74.125.225.34: icmp_seq=244 ttl=56 time=10195.477 ms
64 bytes from 74.125.225.34: icmp_seq=245 ttl=56 time=12608.617 ms
64 bytes from 74.125.225.34: icmp_seq=246 ttl=56 time=11721.149 ms
64 bytes from 74.125.225.34: icmp_seq=247 ttl=56 time=11333.200 ms
64 bytes from 74.125.225.34: icmp_seq=248 ttl=56 time=10350.588 ms
64 bytes from 74.125.225.34: icmp_seq=249 ttl=56 time=9370.136 ms
64 bytes from 74.125.225.34: icmp_seq=250 ttl=56 time=8805.165 ms
64 bytes from 74.125.225.34: icmp_seq=251 ttl=56 time=7809.359 ms
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);
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);
function DuplicateEmail(message) {
this.name = "DuplicateEmail";
this.message = message || "Email already in use";
}
DuplicateEmail.prototype = new Error();
DuplicateEmail.prototype.constructor = DuplicateEmail;
@deedubs
deedubs / gist:4505744
Last active December 10, 2015 22:58
Catch-all for single page apps
// Catch-all for HTML5 content serving.
router.use(function (req, res, next) {
if (req.accepts(['text/html','application/json']) == 'text/html')
res
.sendfile('public/index.html', {maxAge: 60000});
else
next();
});
@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')
}