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
package store
type Query struct {
mongo bson.M
}
func NewQuery() *Query {
return &Query{
mongo: make(bson.M),
}
package main
import (
"io"
"fmt"
"gopkg.in/mgo.v2"
)
type Article struct {
@bodokaiser
bodokaiser / worker.go
Last active August 29, 2015 14:06
Worker Pool in Go
// Example Usage:
//
// type SomeWork struct {
// Value int
// Result chan int
// }
//
// func (w *SomeWork) Do() {
// w.Value += 10000
//
@bodokaiser
bodokaiser / crawler.js
Last active August 29, 2015 14:06
npm install request cheerio && node --stack-size=4096 crawler.js
var url = require('url');
var cheerio = require('cheerio');
var request = require('request');
var cache = [];
crawl(new Page('http://nodejs.org'));
function crawl(page) {
request(page.origin, function(err, res, body) {
package com.satisfeet.core;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.OneToOne;
@Entity
@bodokaiser
bodokaiser / pyplot.py
Last active August 29, 2015 14:10
Robinson und Freitag als Kostenvorteile.
import util
import matplotlib.pylab as pylab
f = util.Person("Friday")
f.learn("meat", 0.20)
f.learn("fish", 0.20)
r = util.Person("Robinson")
r.learn("meat", 1.00)
r.learn("fish", 0.25)
using JuMP
m = Model()
@defVar(m, x1)
@defVar(m, x2)
@defVar(m, x3 >= 0)
@defVar(m, x4 >= 0)
@setObjective(m, Min, 3x1 - 2x2 + 1x3 -4x4)
@bodokaiser
bodokaiser / cesar.py
Created March 9, 2015 11:10
Cesar string encryption.
f = lambda x: ord(x) - 96
g = lambda x: (x + 3) % 26
h = lambda x: chr(x + 96)
cesar = lambda x: ''.join([h(g(f(y))) for y in x])
print(cesar('matrix'))
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@bodokaiser
bodokaiser / opencv.rb
Created April 23, 2015 17:42
Homebrew opencv file with python3 support.
class Opencv < Formula
homepage "http://opencv.org/"
head "https://github.com/Itseez/opencv.git"
stable do
url "https://github.com/Itseez/opencv/archive/2.4.11.tar.gz"
sha256 "b5331ea85a709b0fe871b1ce92e631afcd5ae822423863da6b559dd2cb7845bc"
# Avoid explicit links to a Python framework
# https://github.com/Itseez/opencv/pull/3865