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
$ git fetch https://github.com/bnoguchi/everyauth.git | |
$ git fetch https://github.com/bnoguchi/everyauth.git master | |
From https://github.com/bnoguchi/everyauth | |
* branch master -> FETCH_HEAD | |
$ git status | |
# On branch master | |
nothing to commit (working directory clean) | |
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
// testing memory usage | |
function readableBytes(bytes){ | |
var s = ['bytes', 'kb', 'MB', 'GB', 'TB', 'PB']; | |
var e = Math.floor(Math.log(bytes)/Math.log(1024)); | |
return (bytes/Math.pow(1024, Math.floor(e))).toFixed(2)+' '+s[e]; | |
} | |
function memUsage(){ | |
var mem = process.memoryUsage(); | |
var rss = readableBytes(mem.rss); | |
var vsize = readableBytes(mem.vsize); |
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
function fixFocus() { | |
if(navigator.userAgent.indexOf('Chrome') !== -1 && window.externalHost) { | |
var el = document.createElement('div'); | |
el.style.width = 0; | |
el.style.height = 0; | |
el.tabIndex = 1; | |
el.setAttribute('id', 'ChromeFrameWorkaroundDiv'); | |
document.body.insertBefore(el, document.body.firstChild); | |
var inpt = document.getElementById('ChromeFrameWorkaroundDiv'); | |
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
(function($) { | |
// settings | |
var hideDelay = 500; // in milliseconds | |
var opacityFadeDelay = 250; // in milliseconds | |
var linkClass = 'edit-table-link'; // class="edit-table-link" | |
var popoutClass = linkClass+'-popout'; // class="edit-table-link-popout" | |
var hideCSSClass = 'hide-edit-link'; // class to hide edit link | |
var hideCSS = { // css to hide element |
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
/*jslint browser: true, indent: 2 */ | |
/*global $, window */ | |
(function () { | |
var weekdays = ["S", "M", "T", "W", "T", "F", "S"], | |
container = $(["<div class=\"calendar-control\"><p class=\"header\">Select Date</p><ul class=\"date-control month\"><li class=\"link previous\"><a href=\"#\">View Previous Month</a></li><li class=\"link next\"><a href=\"#\">View Next Month</a></li></ul><ul class=\"date-control year\"><li class=\"link previous\"><a href=\"#\">View Previous Year</a></li><li class=\"link next\"><a href=\"#\">View Next Year</a></li></ul><table class=\"dates\"><caption class=\"title\"><span class=\"month\"></span> <span class=\"year\"></span></caption><thead><tr class=\"row weekdays\"><th>", weekdays.join("</th><th>"), "</th></tr></thead><tbody></tbody></table></div>"].join("")), | |
monthTitle = $(".title .month", container), | |
yearTitle = $(".title .year", container), | |
body = $("tbody", container), | |
selectedYear, |
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 Redis = require('redis'); | |
module.exports.configureCache = function(port, host, password) { | |
if(typeof port !== 'undefined' && typeof host !== 'undefined') { | |
console.log('Production Redis: ', port, host); // Production Redis: 6397 10.xxx.xx.xxx | |
Redis.debug_mode = true; | |
cache = Redis.createClient(port, host, null); | |
} else { | |
cache = Redis.createClient(); | |
} |
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 Authentication | |
// dumbed down a bit for this gist | |
function authenticateUser(req, res, next) { | |
//req.session.user = { firstName: 'Brooke', lastName: 'Thomas' }; | |
console.log(req); | |
// If there is a session user | |
if (req.session.user) { | |
database.users.get(req.session.user, function(err, user) { | |
req.user = user; | |
res.local('user', user); |
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
updates: { | |
incrDownload: // new lines added for clarity | |
" | |
function(doc, req) { | |
var program = req.form.field; | |
if(!doc.downloads) doc.downloads = {}; | |
if(!doc.downloads[program]) doc.downloads[program] = {}; | |
if(!doc.downloads[program].count) doc.downloads[program].count = 0; | |
doc.downloads[program].count += 1; | |
return [doc, doc.downloads[program].count]; |
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
$(document).delegate(".field-group-head input[name='add'][type='submit'], input[name$='[remove]'][type='submit']", "click", function addSubFormItem(e) { | |
var form = $(this).closest("form") | |
, submit = $(this); |
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 formSubmitted = false; | |
$(document).on('submit', '.form', function(e) { | |
if(formSubmitted) { | |
e.preventDefault(); | |
} else { | |
formSubmitted = true; | |
} | |
}); |