Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

M. Peter mpneuried

🏠
Working from home
View GitHub Profile
@mpneuried
mpneuried / basic.coffee
Last active Aug 29, 2015
My Node.js base class
View basic.coffee
# 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
Generate a color hash out of a string
View colorhash.coffee
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 Nov 6, 2014
Script to install services and apps on a blank osx
View install_new_mac.sh
# 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
View _profile.sh
# 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 Aug 29, 2015
RSMQ simple wildcard queue example
View rsmq_wildcard.js
/*
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 Jun 18, 2015
Color Hashing: Generate a hex color out of a given string. This works in Node and in the browser
View colorhash.coffee
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 Aug 7, 2015
Export a trello board to markdown. Will generate H2 with list titles and a list element with every card name
View trello_to_markdown.coffee
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 Sep 16, 2015
code to export a browser module by commonjs, amd or global-var
View export_browser_module.coffee
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 Oct 29, 2015
Diffie-Hellman Tests in Node
View dh_test.js
// 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 Dec 2, 2015
Start a NSQ environment
View start_nsq.sh
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 &