Skip to content

Instantly share code, notes, and snippets.

View mpneuried's full-sized avatar
🏠
Working from home

M. Peter mpneuried

🏠
Working from home
View GitHub Profile
@mpneuried
mpneuried / basic.coffee
Last active August 29, 2015 13:56
My Node.js base class
# import the external modules
_ = require('lodash')._
extend = require('extend')
colors = require('colors')
config = require('./config')
# # Basic Module
# ### extends [EventEmitter]
# Basic module to handle errors and initialize modules
@mpneuried
mpneuried / colorhash.coffee
Created May 22, 2014 11:53
Generate a color hash out of a string
hashFnv32a = (str) ->
#jshint bitwise:false
hval = 0x811c9dc5
i = 0
l = str.length
while i < l
hval ^= str.charCodeAt(i)
hval += (hval << 1) + (hval << 4) + (hval << 7) + (hval << 8) + (hval << 24)
i++
@mpneuried
mpneuried / install_new_mac.sh
Created November 6, 2014 10:01
Script to install services and apps on a blank osx
# install a new Mac
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
# install services
brew install node memcached redis mysql caskroom/cask/brew-cask
# install tools
brew cask install sitesucker bettertouchtool dropbox synology-assistant synology-photo-station-uploade vagrant vagrant-manager virtualbox
# install general apps
brew cask install google-chrome firefox libreoffice macdown skype audacity teamviewer inkscape
# install dev apps
@mpneuried
mpneuried / _profile.sh
Last active August 29, 2015 14:17
.profile
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
function list-ps(){
ps -A | grep $1 | awk '{ if ($4 != "grep"){a = ( $1 " " a ) }}END{print a}'
}
function kill-ps(){
ps -A | grep $1 | awk '{ if ($4 != "grep"){a = ( $1 " " a ) }}END{print a}' | xargs kill -9
}
@mpneuried
mpneuried / rsmq_wildcard.js
Last active August 29, 2015 14:21
RSMQ simple wildcard queue example
/*
INSTALL:
Init Testcase by using the module rsmq-cli:
$ rsmq -n wildcard create -q wildlife
$ rsmq -n wildcard create -q wildpark
$ rsmq -n wildcard create -q wildcard
$ rsmq -n wildcard create -q wilderness
$ rsmq -n wildcard create -q safari
@mpneuried
mpneuried / colorhash.coffee
Created June 18, 2015 07:10
Color Hashing: Generate a hex color out of a given string. This works in Node and in the browser
hashFnv32a = (str, asString, seed) ->
#jshint bitwise:false
i = undefined
l = undefined
hval = (if (seed is `undefined`) then 0x811c9dc5 else seed)
i = 0
l = str.length
while i < l
hval ^= str.charCodeAt(i)
@mpneuried
mpneuried / trello_to_markdown.coffee
Created August 7, 2015 19:00
Export a trello board to markdown. Will generate H2 with list titles and a list element with every card name
txt = []
$( ".list" ).each ( idx, tbl )->
txt.push "\n## " + $(tbl).find( "h2" ).text() + "\n"
$(tbl).find( ".js-card-name" ).each (idx, card)->
txt.push "- " + card.lastChild.data
txt.join( "\n" )
@mpneuried
mpneuried / export_browser_module.coffee
Created September 16, 2015 12:14
code to export a browser module by commonjs, amd or global-var
root = @
MYMODULE =
foo: 42
fizzy: ->
return "bubbele"
# Export the module
if typeof module isnt 'undefined' and module.exports
exports = module.exports = MYMODULE
@mpneuried
mpneuried / dh_test.js
Created October 29, 2015 14:48
Diffie-Hellman Tests in Node
// Install: "npm i prompt"
// Usage: "node dh.js"
var crypto, dh, prompt;
crypto = require('crypto');
prompt = require('prompt');
dh = crypto.getDiffieHellman('modp5');
dh.generateKeys();
@mpneuried
mpneuried / start_nsq.sh
Created December 2, 2015 14:41
Start a NSQ environment
nsqlookupd -http-address=127.0.0.1:4161 -tcp-address=127.0.0.1:4160 &
nsqlookupd -http-address=127.0.0.1:4163 -tcp-address=127.0.0.1:4162 &
nsqd -lookupd-tcp-address=127.0.0.1:4160 -lookupd-tcp-address=127.0.0.1:4162 &
nsqadmin -lookupd-http-address=127.0.0.1:4161 -lookupd-http-address=127.0.0.1:4163 &