Skip to content

Instantly share code, notes, and snippets.

View ahx's full-sized avatar

Andreas Haller ahx

View GitHub Profile
//######### How to send authenticity_token automatically with every Ajax.Request.
//######### This will be obsolete in Rails 3 (as Yehuda mentiones here : https://rails.lighthouseapp.com/projects/8994/tickets/2696-prototypehelper-no-auth-token-param-for-get-requests#ticket-2696-2)
//######### Put this in your application.js
// Monkeypatches Ajax.Base to include authenticity_token parameter unless its already there
(function() {
function insert_auth_token (options) {
var o = options || {};
if (typeof(o.parameters) == "String" && !o.parameters.include("authenticity_token")) {
o.parameters = o.parameters + "&authenticity_token="+AUTH_TOKEN;
<html>
<head>
<title>Coding</title>
<style type="text/css" media="screen">
html {
font-size: 120%;
padding: 1em;
background-color:#FF6;
font-family: Helvetica, sans-serif;
}
@ahx
ahx / app.rb
Created January 5, 2009 07:08
An example for an OpenID consumer using Sinatra
# An example for an OpenID consumer using Sinatra
require 'rubygems'
require 'sinatra'
gem 'ruby-openid', '>=2.1.2'
require 'openid'
require 'openid/store/filesystem'
helpers do
def openid_consumer
// import fullscreen.*;
import processing.video.*;
MovieMaker mm;
// FullScreen fs;
PImage img;
PGraphics mask;
String[] images;
int imgIndex = 0;
int xOffset;
@ahx
ahx / .profile
Created December 29, 2008 17:35
my .profile (aka .bashrc) file
#
# Your previous .profile (if any) is saved as .profile.mpsaved
# Setting the path for MacPorts.
export PATH=/opt/local/bin:/opt/local/sbin:/usr/local/bin:$PATH
# Setting PATH for MacPython 2.5
# The orginal version is saved in .profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/Current/bin:${PATH}"
export PATH
export PATH=/usr/local/graphviz/bin:$PATH
#
# A try to built a simple drummachine using Shoes and Midiator.
# Unfortunalty animation seems to be quite processor heavy. Things might get slow..
# Because of that, the beats don't get highlighted on beat.
#
# You will need a midi input for this.
# On OSX you could use http://notahat.com/midi_patchbay
# and http://notahat.com/simplesynth or Garage Band
#
# Usage:
@ahx
ahx / shoes_midi_keyboard.rb
Created September 1, 2008 16:54
A very simple onscreen midi-keyboard using Shoes and Midator.
#
# A simple onscreen midi-keyboard using Shoes and Midiator.
# No key-up Event.
#
# Set Keyboard layout here:
KEYBOARD_LAYOUT = :de # only :de and :us are supported, by now. See MidiKeymap#map_keys!
#
# You will need a midi input for this.
# On OSX you could use http://notahat.com/midi_patchbay
# and http://notahat.com/simplesynth or Garage Band