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 / crypto.coffee
Last active December 26, 2015 21:29
Simplify the data en/decryption in node.js
### USEAGE
crypto = require( "./crypto" )()
_crypted = crypto.crypt( "myPassowrd", "data123" )
crypto.decrypt( "myPassowrd", _crypted ) # data123
###
crypto = require( "crypto" )
@mpneuried
mpneuried / Backbone.getOrFetchId.coffee
Created November 21, 2013 10:16
Backbone collection extension to solve the problem of getting a model with eventually not exists within a collection. It also handles parallel fetches and distributes a single `.fetch()` to multiple requesters.
###
EXAMPLE USAGE
testColl = new Backbone.Collection.Extended()
# PROMISE USAGE
# define handlers
fnSuccess = ->
console.log( "SUCCESS", arguments )
@mpneuried
mpneuried / Backbone.sub.coffee
Last active December 9, 2016 07:55
Backbone collection extension to solve sub collections.The models withtin the (sub)collection-tree will be distributed within all involved collections under consideration of each filter.
###
EXAMPLE USAGE
parentColl = new Backbone.Collection.Extended()
# by Array
subCollA = parentColl.sub( [ 1, 2, 3 ] )
# or by Object
subCollO = parentColl.sub( { name: "Foo", age: 42 } )
@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 / keybase.md
Last active August 25, 2017 06:59
keybase.md

Keybase proof

I hereby claim:

  • I am mpneuried on github.
  • I am mpneuried (https://keybase.io/mpneuried) on keybase.
  • I have a public key ASA0zWbq3uNz6NmYusSTSfmGI6awm8egCVo6ptn7GWx0nAo

To claim this, I am signing this object:

@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)