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 / 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;
// in this case we inject the database as argument to another package
package httpd
import (
"net/http"
"path/to/db"
)
var db *db.Database
@bodokaiser
bodokaiser / index.html
Created June 30, 2014 07:54
WebSocket benchmark setup between walve and ws.
<!DOCTYPE html>
<html>
<head>
<title>WebSocket Benchmark</title>
</head>
<body>
<h1>WS Bench</h1>
<form>
<input placeholder="Type a message or drag file." />
</form>
@bodokaiser
bodokaiser / main.go
Last active August 29, 2015 14:03
Runtime error on stream read.
package main
import (
"bytes"
"fmt"
"io/ioutil"
"log"
"net/http"
"net/http/httptest"
)
package parser
type Parser interface {
io.Reader
io.Writer
}
type EmailParser struct {
results [][]byte
}
package main
import (
"bufio"
"fmt"
"io"
"log"
"net/http"
"time"
)
package main
import (
"fmt"
"reflect"
)
type Result interface {
Value() string
}