Skip to content

Instantly share code, notes, and snippets.

View killtheliterate's full-sized avatar

Garrett Dawson killtheliterate

View GitHub Profile
@gnarf
gnarf / example.js
Created June 1, 2011 23:53
$.fn.newContent
// $.fn.newContent behaves kinda like .live(), it will act on elements that match the
// selector now, or in the future... It automatically runs on any elements immediately
// matched, and also runs once on document ready. You then call .newContent() on any
// freshly created content to trigger searching it
// It will call the given callback function in the context of a
// jQuery set that matches the selector...
$("li.test").newContent(function() {
this.css("color", "red");
@ebinnion
ebinnion / hideMenu.js
Created January 24, 2012 05:12
Jquery Hide/Show Menu Responsive Web Design
$('#menu-button').click(function(){
$('.menu').slideToggle('fast',function() {});
});
function menuHide (){
if ($(window).width() < 1024){
$("body").addClass("mobile");
}
else {
$("body").removeClass("mobile");
@topfunky
topfunky / CHANGES.md
Created August 2, 2012 18:27
Express 3.0 Changes

Changes in Express 3.0 Templates

Related: PeepCode Full Stack Node.js screencast (an included code sample works with Express 3.0).

There are several syntax changes in Express 3.0. They do require modifications to your code, but they aren't too complicated.

The biggest change is that Express templates now use Django style inheritance rather than ERB/Rails style automatic layouts.

Summary

@igstan
igstan / option.js
Last active December 18, 2015 05:49
// `unit` is `return` from Haskell
// `bind` is `>>=` from Haskell, or `flatMap` from Scala
var None = {
bind: function (fn) { return this; },
unit: function (v) { return Option(v); },
getOrElse: function (elseValue) { return elseValue; }
};
var Some = function (value) {
@pixelwhip
pixelwhip / _l-3up.scss
Created July 7, 2013 23:57
Drupal cTools/panels custom layout. Creating dynamic layout classes based on whether or not regions have content.
//
// @file
// Sidebars After Layout.
// One main content area with two sidebars after.
// ----------------------------------------------------------------------------
.l--3up {
@include breakpoint(41em, $no-query: '.lt-ie9') {
.l-main {
@include zen-grid-item(8, 1);
@cbankston
cbankston / .env.service
Created February 23, 2016 20:08
Node Docker Project
RDS_HOSTNAME=db
RDS_USERNAME=root
RDS_PASSWORD=some_pass
NODE_PATH=/app
MESSAGE_SERVICE_USERNAME=guest
MESSAGE_SERVICE_PASSWORD=guest
MESSAGE_SERVICE_PORT=5672
MESSAGE_SERVICE_VHOST=/
MESSAGE_SERVICE_HOST=rabbit
@busypeoples
busypeoples / Simplified-Redux-Reducers.js
Created January 2, 2018 23:21
Simplified Redux Reducers
import Maybe from 'folktale/maybe';
const Inc = 'Inc';
const Dec = 'Dec';
const IncBy = 'IncBy';
const IncFn = state => state + 1;
const DecFn = state => state - 1;
const IncByFn = (state, action) => state + action.incBy;
@fernandezpablo85
fernandezpablo85 / node-curry.js
Created May 4, 2011 15:32
Explanation of the curry function for node.js
function curriedReadFile(path) {
var _done, _error, _result;
var callback = function(error, result) {
_done = true,
_error = error,
_result = result;
};
fs.readFile(path, function(e, r) {
@donabrams
donabrams / checklist.txt
Last active April 25, 2018 23:16
General JWT approach that usually isn't terrible checklist
☐ Put JWT in a cookie
☐ HTTPOnly cookie
☐ Secure cookie
☐ Domain w/ a subdomain (never root)
☐ No authorization in the JWT body (look it up serverside ya lazy asses)
☐ Userid in cookie should NOT exist anywhere but auth service
☐ Short window ( < 15 min) for JWT authentication token
☐ Ability to deauthorize a refresh token chain serverside (but long life on a refresh token is OK)
☐ Ability to monitor requests by refresh token chain
@nikcorg
nikcorg / promisified-hyperquest.js
Last active May 10, 2018 05:44
Promisified Hyperquest -- A quick exercise wrapping Hyperquest in a Promise for an easy thenable API.
var concat = require("concat-stream");
var hyperquest = require("hyperquest");
var Promise = require("bluebird");
var stream = require("stream");
// Wait for the request to finish or fail
function promisify(req) {
return new Promise(function (resolve, reject) {
req.on("error", reject).pipe(concat({ encoding: "string" }, resolve));