Skip to content

Instantly share code, notes, and snippets.

View kkemple's full-sized avatar

Kurt Kemple kkemple

View GitHub Profile
@kkemple
kkemple / walk.js
Created February 13, 2014 20:54
Function for walking over files in node are requiring them. Great for loading groups of objects such as routes, models, etc.
var walk = function(path) {
fs.readdirSync(path).forEach(function(file) {
var newPath = path + '/' + file;
var stat = fs.statSync(newPath);
if (stat.isFile()) {
if (/(.*)\.(js$|coffee$)/.test(file)) {
require(newPath);
}
} else if (stat.isDirectory()) {
walk(newPath);
@kkemple
kkemple / cluster.js
Created November 26, 2014 01:31
node clustering (to maximize cpu usage)
'use strict';
var cluster = require('cluster');
if (cluster.isMaster) {
var cpuCount = require('os').cpus().length;
for (var i = 0; i < cpuCount; i++) {
cluster.fork();
@kkemple
kkemple / shim-backbone-marionette-browserify.js
Created January 22, 2015 17:41
Shimming Backbone.$ in Marionette Apps - For Browserify
/* shim.js */
var Backbone = require('Backbone');
Backbone.$ = require('jquery');
/* gruntfile.js */
grunt.initConfig({
browserify: {
src: {
files: {

BehaveJS

This framework is an effort to provide common services needed in native web applications while remaining truly independent of each other.

BehaveJS services may tie together seamlessly, but each service can be added in to any application with a few extra lines of code (and in some cases none).

/* Building a TODO app */
import BehaveHistory        from    'behave-history';
import BehaveRouter         from    'behave-router';
var View = Marionette.ItemView.extend({
template: function(modelAttrs) {
// modelAttrs is raw attributes for model, not model itself
switch (modelAttrs[{some unique identifier}]) {
case 'option1':
return Option1ItemView;
case 'option2':
return Option2ItemView;
case 'option3':
return Option3ItemView;
@kkemple
kkemple / gist:b1aa0ce612330b5028cf
Last active August 29, 2015 14:25 — forked from dwwoelfel/gist:b859cee4b5f41af37ffd
Rough notes for setting up elastic beanstalk on CircleCI

In your repo's root directory, check in a requirements.txt with

boto==2.30.0

Then, from the project's Project Settings > Environment Variables page, add the two env vars: AWS_ACCESS_KEY_ID and AWS_SECRET_KEY, with an IAM key that can deploy to eb.

Then create a bash script to set up eb:

@kkemple
kkemple / api-client.js
Created July 14, 2015 18:20
base level api client in ES6
'use strict';
import request from 'superagent';
import Promise from 'bluebird';
//set base headers here
const BASE_HEADERS = {};
// set base url here
const BASE_URL = '';
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.com
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query
* Source: http://core.trac.wordpress.org/browser/tags/3.5.1/wp-includes/query.php
*/
$args = array(
@kkemple
kkemple / group.css
Created November 27, 2013 22:59
clear fixing class for css
.group {
*zoom: 1; /* ie 7 clearfix */
}
.group:before,
.group:after { /* modern browser clearfix */
content: ' ';
display: table;
}
@kkemple
kkemple / smartresize.js
Created November 27, 2013 23:04
stops browser from firing window resize events until window is no longer resizing ( so it only fires once )
//This fucntion stops the browser from firing multiple on resize events and executes code
//once the resizing stops
(function($,sr){
// debouncing function from John Hann
// http://unscriptable.com/index.php/2009/03/20/debouncing-javascript-methods/
var debounce = function (func, threshold, execAsap) {
var timeout;
return function debounced () {