Skip to content

Instantly share code, notes, and snippets.

View timbuchwaldt's full-sized avatar

Tim Buchwaldt timbuchwaldt

View GitHub Profile
@timbuchwaldt
timbuchwaldt / hookable.rb
Created August 18, 2012 10:17
Ruby Hookable module - class extension to provide instance hooks
module Hookable
def initialize
@hooks = Hash.new
end
# exec all hooks for a given method name (e.g. before_load,after_load)
def exec_hooks(method)
unless @hooks[method.to_s].nil?
@hooks[method.to_s].each do |h|
instance_eval &h
@timbuchwaldt
timbuchwaldt / timerange.rb
Created June 29, 2012 08:27
Timerange comparison
class Range
def intersecting? t2
if self.end <= t2.begin or self.begin >= t2.end
return false
else
return true
end
end
end
@timbuchwaldt
timbuchwaldt / progressbar.js
Created April 9, 2012 11:15
Simple Bootstrap Progress Bar Script
/*
* Simple progressbar control script, for usage with Twitter Bootstrap
*
*
* Instantiate via pbar = new Progressbar("progress")
* first (&only) argument is the id of the container, e.g.:
*
* <div id="progress" class="progress progress-success">
* <div class="bar" style="width: 21%;"></div>
* </div>
@timbuchwaldt
timbuchwaldt / couch.php
Created January 27, 2012 16:35
Minimal PHP CouchDB Layer
<?
/*
* Usage:
* Instantiate class $c = couch::i();
* You can now use $c to make calls
*/
class couch
{
private static $instance = null;
private $curl_object = null;
@timbuchwaldt
timbuchwaldt / License
Created December 20, 2011 20:45
mt - minimal timing in python
Copyright 2011, Tim Buchwaldt. All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are
permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of
conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list
of conditions and the following disclaimer in the documentation and/or other materials
# Knoten beginnen bei 1, Array bei 0
# Matrix dieser Form:
# 1 2 3 4
# 1 - - - -
# 2 0 - - -
# 3 1 1 - -
# 4 1 0 1 -
def calculateHorizontalInterval(n)
return nil if n == 1
Connecting with backend: BotoBackend
Archive dir: None
Found 0 backup chains without signatures.
Found a complete backup chain with matching signature chain:
-------------------------
Chain start time: Tue May 24 14:07:46 2011
Chain end time: Tue May 24 18:51:00 2011
Number of contained backup sets: 4
def gv
g = ""
unless @left.nil?
g += @left.gv
g += "\"#{@value}\" -> \"#{@left.value}\";"
end
unless @right.nil?
g += @right.gv
g += "\"#{@value}\" -> \"#{@right.value}\";"
end
@timbuchwaldt
timbuchwaldt / gist:926048
Created April 18, 2011 19:59
datalog.tex
\documentclass[12pt, a4paper]{scrartcl}
\usepackage{fancyhdr}
\usepackage[ngerman]{babel}
\usepackage{geometry}
\usepackage{graphicx}
\usepackage{setspace}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amssymb}
\newcommand{\abs}[1]{\ensuremath{\left\vert#1\right\vert}}
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!--
Script info: script: webscr, cmd: _login-submit, template: p/acc/validate, date: Jan 8, 2010 19:34:29 PST; country: DE, language: de_DE, xslt server:
web version: 61.0-1159064 branch: live-610_int
content version: -
pexml version: 61.0-1177733