Skip to content

Instantly share code, notes, and snippets.

View bxt's full-sized avatar

Bernhard Häussner bxt

View GitHub Profile
@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 / 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 / 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 / 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
# 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 / 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>
@bxt
bxt / routes.rb cheatsheet.txt
Created September 9, 2013 12:19
Example code and output for ruby on rails routes
resource :res do
def create_action action = :action
Proc.new {get action}
end
namespace :ns0, &create_action
namespace :nsp, path: "nspp/nsppi", &create_action
namespace :nsf, module: false, &create_action
namespace :nsm, module: :mod, &create_action
scope &create_action(:sco_a)
scope module: 'scm', &create_action(:scm_a)
@bxt
bxt / setup_osx.md
Last active June 24, 2024 06:31
Setup macOS / OS X so that is does not suck quite that hard (living doc)

Setting up OS X macOS

Things to configure

  • Install latest software update
  • Enable touch ID
  • Make Dock hide and remove some silly apps (photobooth, ...) disable recently used apps
  • Finder:
@bxt
bxt / java-problems.md
Last active December 30, 2015 16:59
Java Problems

Problems with the Language Java (7)

This is my "I love Java, but..." document. And now follows some ranting about Java:

Constructor Rules

super() must be the first statement in the constructor. This is just nonsense, as you can work around this and add more statements by calling methods on the parameters to super(). Thus, all checks involving use of this must be implemented in the compiler anyways.

@bxt
bxt / sinuosity.md
Created March 14, 2014 20:59
Rivier sinuosity

Nile. Length: 6852 km. Linear: 3700 km. Sinuosity: 1.85. Amazon. Length: 6448 km. Linear: 3000 km. Sinuosity: 2.15.