Skip to content

Instantly share code, notes, and snippets.

View davidchase's full-sized avatar
📺
Working from home

David Chase davidchase

📺
Working from home
View GitHub Profile
for (var i = 1; i <= 100; i++) {
var str = '';
if (i % 3 === 0) str += 'Fizz';
if (i % 5 === 0) str += 'Buzz';
console.log(str || i);
}
// More correct way define str outside of loop
// either way gets hoisted to top of scope in this case
// global environment, in browser the window object
@davidchase
davidchase / transitionEnd.js
Created June 16, 2014 18:42
TransitionEnd alternative to Modernizr
// Credits:
// http://stackoverflow.com/questions/5023514/how-do-i-normalize-css3-transition-functions-across-browsers/9090128#9090128
var transitionEndEventName = function() {
var i;
var el = document.createElement('div');
var transitions = {
'transition':'transitionend',
'OTransition':'otransitionend',
'MozTransition':'transitionend',
'WebkitTransition':'webkitTransitionEnd'
// Orginal forked from
// https://gist.github.com/localpcguy/1373518
'use strict';
var Swiper = {
config: {
"touchstart": {
"x": -1,
"y": -1
},
@davidchase
davidchase / hook.sh
Created August 3, 2014 03:56
Before commiting to github run through jshint
#
# Forked from:
# https://raw.githubusercontent.com/goschevski/fronty/master/hooks.sh
#
js_hint='{
"bitwise": false,
"curly": true,
"eqeqeq": true,
"forin": true,
"immed": true,
@davidchase
davidchase / format.js
Last active August 29, 2015 14:05
Format Utility
var format = function () {
var args = Array.apply(null, arguments);
var initial = args.shift();
var replacer = function (text, replacement) {
return text.replace('%s', replacement);
}
return args.reduce(replacer, initial);
}
@davidchase
davidchase / haproxy.cfg
Created August 28, 2014 02:17
haproxy.cfg example based on v1.5.3
global
log 127.0.0.1 local0
log 127.0.0.1 local1 notice
log 127.0.0.1:514 local2 notice
maxconn 4096
pidfile tmp/haproxy-queue.pid
defaults
log global
mode http
@davidchase
davidchase / nodeEC2.md
Last active August 29, 2015 14:06
Setting Up Node on Amazon EC2

EC2 Amazon

Under EC2 select launch instances

Select the first instance linux box and proceed with the setup

Linux Box

@davidchase
davidchase / .eslintrc
Created September 15, 2014 18:27
my eslint config
{
"env": {
"browser": true,
"node": true
},
"rules": {
"block-scoped-var": 2,
"complexity": [1, 5],
"consistent-return": 2,
@davidchase
davidchase / gen.js
Last active August 29, 2015 14:07
Async with generators
// Tackling async events without
// callbacks using es6 generators
// http://kangax.github.io/compat-table/es6/#generators_(yield)
var async = function(parameters, callback) {
setTimeout(function() {
callback(parameters);
}, 1000);
};
var currier = function(fn) {
@davidchase
davidchase / functional.js
Created April 20, 2015 03:29
partial + partialRight
var partial = function partial(fn){
var args = Array.apply(null, arguments).slice(1);
return function(){
var lastArgs = Array.apply(null, arguments);
return fn.apply(this, args.concat(lastArgs));
};
};
var partialRight = function partialRight(fn){
var args = Array.apply(null, arguments).slice(1);