Skip to content

Instantly share code, notes, and snippets.

View bodokaiser's full-sized avatar
😀
Happy to be here!

Bodo Kaiser bodokaiser

😀
Happy to be here!
View GitHub Profile
@bodokaiser
bodokaiser / bash_profile.sh
Last active August 29, 2015 14:02
Autoloader for janls cl add on
#!/bin/sh
# https://twitter.com/bodojs/status/476973611753152512
# https://twitter.com/bodojs/status/476974684974501888
# Bash Add-On Autoloader
[[ -d "$HOME/.bash" ]] || mkdir -p "$HOME/.bash"
[[ -f "$HOME/.bash/cl.sh" ]] || curl -o "$HOME/.bash/cl.sh" https://gist.githubusercontent.com/janl/e6ceb14ffcfca3556ba5/raw/b89254f3babe217bbdb085ad9a4df30cbbd6c1d8/cl.sh
source "$HOME/.bash/cl.sh"
@bodokaiser
bodokaiser / supervisor-init
Last active June 15, 2019 03:31
supervisor (node.js) init script - works with nvm and custom paths :)
#!/bin/sh
#
# chkconfig: 35 99 99
# description: node.js /home/bodokaiser/tmp/<name>
#
. /etc/rc.d/init.d/functions
# application name
@bodokaiser
bodokaiser / post-receive
Last active August 29, 2015 14:02
git post receive hook for nvm environments
#!/bin/bash
source $HOME/.bash_profile
set -u
set -e
# directory name
NAME=$(basename $(pwd) .git)
@bodokaiser
bodokaiser / node-init
Last active August 29, 2015 14:02
node init script without supervisor (supervisor takes a few resources)
#!/bin/sh
#
# chkconfig: 35 99 99
# description: node.js /home/bodokaiser/tmp/<name>
#
. /etc/rc.d/init.d/functions
# application name
@bodokaiser
bodokaiser / config.js
Last active August 29, 2015 14:02
Setup environment based configuration with path support.
var path = require('path');
/**
* Your configuration may look like:
*
* {
* "name": "my-app",
* "static": {
* "path": "/public"
* }
@bodokaiser
bodokaiser / parser.js
Last active August 29, 2015 14:02
Ultimate string parsing map reduce action.
var string = 'colors:red, colors:blue, sizes:42, sizes:44';
var obj = string.split(', ')
.map(function(entry) {
return entry.split(':').reduce(function(prev, curr) {
if (!prev.name) {
prev.name = curr;
prev.value = '';
} else {
prev.value += curr;
@bodokaiser
bodokaiser / parser.js
Created June 19, 2014 09:36
nested string parser
var string = 'name:stock, vars:colors:red, vars:colors:blue,vars:sizes:44, really:nasty:nested';
function parse(array) {
return array
.map(function(item) {
var parts = item.split(':');
return {
key: parts.shift(),
value: parts.join(':')
@bodokaiser
bodokaiser / build.js
Created June 23, 2014 14:07
component build script for component bundles
var fs = require('fs');
var path = require('path');
var util = require('util');
var jade = require('builder-jade');
var bundler = require('component-bundler');
var builder = require('component-builder');
var resolver = require('component-resolver');
var runtime = builder.scripts.require + jade.runtime;
@bodokaiser
bodokaiser / config.go
Created June 26, 2014 08:16
Simple example how to merge JSON files.
package main
import (
"log"
"fmt"
"encoding/json"
)
var conf1 = `
{
// in this case we inject the database as argument to another package
package httpd
import (
"net/http"
"path/to/db"
)
var db *db.Database