Skip to content

Instantly share code, notes, and snippets.

View jeff-hager-dev's full-sized avatar

Nolan Hager jeff-hager-dev

View GitHub Profile
/*=============================================================================
Description: A thread safe queue using boost::mutex library to do so.
Author: J. Nolan Hager (JNHager)
NOTE (JNhager): boost::mutext::scoped_lock locks all resources in the same
scope until that scope has resolved. This means all scopes within will be
locked as well.
=============================================================================*/
/*=============================================================================
Description: A javascript file full of some helpers I come across as I code
through daily life.
Author: J. Nolan Hager (JNHager)
=============================================================================*/
(function(exports){
exports.jshlprs = {
isEmptyObj: function(obj){ return !Object.keys(obj).length; }
}
@jeff-hager-dev
jeff-hager-dev / layouthelper.js
Created December 11, 2014 18:17
Playing around with a way to dynamically load handlebar templates. I know there are other ways to do it but I wanted to try myself.
(function(exports){
layouts = {
'layoutName':'url-for-layout'
}
exports.layoutHelper = {
getLayout: function(layoutName){
var layoutObj = '';
$.ajax({
url: layouts[layoutName],
@jeff-hager-dev
jeff-hager-dev / app.js
Created December 19, 2014 15:12
Super simple NodeJS/Express Server for testing or prototyping an API call. Also this is set up to avoid CORS issues with testing, so if you want to set it up to act as a mock CDN go for it OR an external API mock do it.
var express = require('express');
var fs = require('fs');
var path = require('path');
var port = 3005;
var staticDir = "staticFiles"
var app = express();
app.use(function (req, res, next) {
//NOTE (JNHager): NEVER DO THIS IN A PRODUCTION SYSTEM. STRICTLY FOR TESTING LOCALLY!!!!
@jeff-hager-dev
jeff-hager-dev / osx_shortcuts.md
Created December 19, 2014 15:16
OSX shortcuts I use a lot
  • Open Spotlight Search: command + spacebar
  • Create terminal tab: command + t
  • Close terminal Tab: command + w
  • Switch terminal Tab: command + shift + arrow_keys OR command + shift + { or }
@jeff-hager-dev
jeff-hager-dev / git_tips.md
Last active August 29, 2015 14:13
A collections of git tricks and tips I have collected in my adventures.

Git Tips and Tricks

Branches and Merging

  • List branches that are already merged. (Found this here: [Stackoverflow post][merged_branches])
    git branch --merged master #lists branches merged into master
    git branch --merged lists #branches merged into HEAD (i.e. tip of current branch)
    git branch --no-merged #lists branches that have not been merged
@jeff-hager-dev
jeff-hager-dev / barsHlpr.js
Last active August 29, 2015 14:14
A simple handlebars helper file to use with NodeJs/Express that is using the handlebars for the view engine.
var moment = require('moment');
var _dateFormats = {
short: "MMMM DD, YYYY",
long: "dddd DD.MM.YYYY HH:mm"
};
var barsHlprs = {};
barsHlprs.ifIn = function (elem, list, options) {
@jeff-hager-dev
jeff-hager-dev / 2d_deepcopy.py
Created February 18, 2015 17:09
Deep Copy a 2d array in python
def twoDim_deep_copy(srcArray, destArray):
destArray = [row[:] for row in srcArray]
@jeff-hager-dev
jeff-hager-dev / string_repeater.js
Created February 24, 2015 17:13
Javascript String Repeater
String.prototype.repeat = string.prototype.repeat || function (rptCnt) {
return new Array(rptCnt).join(this);
};
@jeff-hager-dev
jeff-hager-dev / terminal_git_branch.sh
Last active August 29, 2015 14:16
Git Path and terminal coloring
export PS1="\[\033[36m\]\u\[\033[m\]@\[\033[32m\]\h:\[\033[33;1m\]\w\[\033[m\]\$(parse_git_branch)\[\033[00m\]\$ "
export CLICOLOR=1
export LSCOLORS=DxFxBxDxCxegedabagacad
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}