Skip to content

Instantly share code, notes, and snippets.

View bxt's full-sized avatar

Bernhard Häussner bxt

View GitHub Profile
@bxt
bxt / icosahedron-artistic.html
Last active December 15, 2015 14:49
Some 3D icosahedra
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>3D Icosahedron based on Javascript and Canvas</title>
<style>
* {padding:0;margin:0;}
body {text-align:center;font-size:8px;}
</style>
</head>
# A class-based template for jQuery plugins in Coffeescript
#
# $('.target').myPlugin({ paramA: 'not-foo' });
# $('.target').myPlugin('myMethod', 'Hello, world');
#
# Check out Alan Hogan's original jQuery plugin template:
# https://github.com/alanhogan/Coffeescript-jQuery-Plugin-Template
#
do ($=jQuery) ->
@bxt
bxt / proxy.py
Last active August 30, 2020 15:57
A very basic caching python HTTP proxy server.
# Originally from http://sharebear.co.uk/blog/2009/09/17/very-simple-python-caching-proxy/
#
# Usage:
# A call to http://localhost:80000/example.com/foo.html will cache the file
# at http://example.com/foo.html on disc and not redownload it again.
# To clear the cache simply do a `rm *.cached`. To stop the server simply
# send SIGINT (Ctrl-C). It does not handle any headers or post data.
import BaseHTTPServer
import hashlib
@bxt
bxt / hash_value_transforms.rb
Created March 19, 2013 01:11
Monkey-patches the methods transform into ruby's Hash class to allow easy mapping of hash values.
class Hash
def transform
inject(self.class.new){|acc, (k, v)| acc[k] = yield(v); acc }
end
def transform!
each{|k,v| self[k]=yield(v)}
end
@bxt
bxt / r.rb
Last active November 16, 2016 12:22
Some really weird ruby script showing some awkish/sedish features
$/=%q(/)
$\=%Q(\t)
while DATA.gets
BEGIN {puts "START #{$0}"}
END {puts "DONE."}
print
puts $_[/a(.{2})/,1] || '--'
end
@bxt
bxt / Capfile
Created October 31, 2012 21:10
Rails Deploy Configs
load 'deploy'
# Uncomment if you are using Rails' asset pipeline
load 'deploy/assets'
Dir['vendor/gems/*/recipes/*.rb','vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) }
load 'config/deploy' # remove this line to skip loading any of the default tasks
@bxt
bxt / CD2-README.md
Last active April 9, 2017 19:57
Change shell directory to one of the open directories in other shells

cd2

cd2 is a tiny handy tool for working with multiple console windows at a time. When called, it displays a list of all working directories of your running terminals and lets you choose one by simply entering a number. If you enter nothing it takes you to the last entry listed which makes a good default behavior. This way, when you open a new terminal window and type cd2 and press enter twice you can continue in the same wd as your other bash.

Installing

To install for your user simply run:

@bxt
bxt / see256colors.sh
Last active October 11, 2015 04:37
Handy script for figuring how 256 color terminal colors look like
for i in {0..255}; do echo -e "- \033[38;5;${i}m\\[\\33[38;5;${i}m\\]\033[0m -"; done;
# Prints the code needed for PS1 in the corresponding color.
@bxt
bxt / ListSetTest.java
Created September 28, 2012 12:51
Test Java collection performance against set operations with various input characteristics
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.TreeSet;
public class ListSetTest {
public static void main(String[] args) {
@bxt
bxt / ConsList.java
Created September 27, 2012 16:34
ConsList for Java, draft
import java.util.AbstractList;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
public class ConsList<E> extends AbstractList<E> implements List<E> {
private E element;
private List<E> parent;