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
@jeff-hager-dev
jeff-hager-dev / base.js
Last active September 15, 2015 15:19
A super simple base controller that a swagger API can use to do queries of a mongoDB table
var mongodb = require('mongodb');
var MongoClient = mongodb.MongoClient;
var baseController = function (collectionName) {
var _settings = {
url: 'mongodb://localhost:27017/ghfive',
collectionName: collectionName
};
this.default = {
get: function (req, res) {
@jeff-hager-dev
jeff-hager-dev / toObject.js
Created August 18, 2015 06:36
Using Jquery to convert a form to an Object representation of it.
//source: answer to http://stackoverflow.com/questions/1184624/convert-form-data-to-javascript-object-with-jquery
$.fn.serializeObject = function()
{
var o = {};
var a = this.serializeArray();
$.each(a, function() {
if (o[this.name] !== undefined) {
if (!o[this.name].push) {
o[this.name] = [o[this.name]];

Print X one thousands time

[>++++++++<-]><------[>....<-]

Print X one thousands time but to many iterations

+[--->++<]>++>+++>------[<[<.>-]++++>-]
@jeff-hager-dev
jeff-hager-dev / disclaimer.css
Created June 30, 2015 00:57
Cool snippet for disclaimer text. At least a good starting point
/* Found here: http://www.sociallystacked.com/2012/05/style-your-promotions-disclaimer-text/ */
/*Style Promotion Disclaimer Text*/
.ss_promotion_disclaimer{
color: #CCCCCC; /*Color of Disclaimer Text*/
font-size:10px; /*Font Size of Disclaimer Text*/
font-family: Arial, Helvetica, sans-serif; /*Web Safe Font Family of Disclaimer Text*/
}
@jeff-hager-dev
jeff-hager-dev / cron-notifier.js
Created May 7, 2015 18:41
Hipchat Cron Notifier
var HipChatClient = require('hipchat-client'),
CronJob = require('cron').CronJob;
var cfg = {
APIKey: '',
Host: '',
Schedule: '',
FromID: '',
Rooms: [],
notifierSchedule: '',
@jeff-hager-dev
jeff-hager-dev / node_hlprs.js
Last active August 29, 2015 14:19
Some Helper functions for NodeJS
module.exports = {
removeWhitespace: function(str){
return str.replace(/\s+/g, '');
},
randomNumber: function(max, min){
return Math.floor(Math.random() * max) + min;
},
stringRepeater: function (str, rptCnt) {
return new Array(rptCnt).join(str);
},
@jeff-hager-dev
jeff-hager-dev / error_formatter.py
Last active August 29, 2015 14:18
An little file to help with python errors in the terminal
import traceback
defaultDelimiter = '#'
altDelimiter = '='
altTwoDelimter = '%'
def formatError(err, errLocation='main', errMsgDelimiter=defaultDelimiter):
errorHdr = '{dell}{dell}{dell}{dell} {loc} {dell}{dell}{dell}{dell}'.format(dell=errMsgDelimiter, loc=errLocation)
errorFooter = '{dell}{dell}{dell}{dell} END {loc} {dell}{dell}{dell}{dell}'.format(dell=errMsgDelimiter, loc=errLocation)
@jeff-hager-dev
jeff-hager-dev / terminal_tricks.md
Last active September 10, 2015 13:49
OSX Terminal Tricks
  • Visual File structure of directory

    brew install tree
    tree -d ./dir_name/
  • Combine two files

@jeff-hager-dev
jeff-hager-dev / js_tipsAndTricks.md
Last active August 29, 2015 14:17
JS Tips and tricks

Javascript Tips and Tricks

  • Cool [stackoverflow][define_objects] post about defining js objects and when to use one.

  • Conversion Tricks: http://samuli.hakoniemi.net/

    var myVar   = "3.14159",  
    str     = ""+ myVar,//  to string  
    int     = ~~myVar,  //  to integer  
@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)/'
}