Skip to content

Instantly share code, notes, and snippets.

View fanktom's full-sized avatar

Thomas Fankhauser fanktom

View GitHub Profile
@fanktom
fanktom / server_side_events.rb
Created May 24, 2012 11:29
Ruby Server Side Events Server implementation with Goliath
require 'goliath'
require 'em-synchrony/em-http'
# After a connect the server streams 10 bomb ticks and then stops with a BOOM. The
# event source needs to listen to source.addEventListener 'bomb', .. to retrieve
# the ticks.
class Stream < Goliath::API
def response(env)
foo
@fanktom
fanktom / gist:1675562
Created January 25, 2012 09:11
Rails 3 CRUD Curls
# list
curl -v http://localhost:3000/organizations.json
# create
curl -v -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '{"organization":{"first_name":"firstname","last_name":"lastname","email":"email@email.com"}}' http://localhost:3000/organizations
# read
url -v http://localhost:3000/organizations/1.json
# update

Keybase proof

I hereby claim:

  • I am fanktom on github.
  • I am fanktom (https://keybase.io/fanktom) on keybase.
  • I have a public key whose fingerprint is A7EF 59CF D39A A601 B86F 6E02 ABAB AAB3 A2F5 1FEA

To claim this, I am signing this object:

@fanktom
fanktom / git-init-root-branch
Last active December 31, 2015 20:08
Init a root branch in a current git repository
#!/bin/bash
git symbolic-ref HEAD refs/heads/$1 && rm .git/index && git clean -fdx
@echo "Created new root branch '$1'"
@fanktom
fanktom / rmateify
Created February 10, 2013 19:14
Automatically copies the rmate ruby script to a remote server to give him rmate support
#!/usr/bin/env bash
# encoding: UTF-8
TEXT_MATE_APP_NAME="TextMate2"
scp /Applications/$TEXT_MATE_APP_NAME.app/Contents/Frameworks/Preferences.framework/Resources/rmate $1:/usr/bin/rmate
# Usage
# Copy this file to localhost /usr/bin/rmateify
# Run rmateify root@servername once
@fanktom
fanktom / .bash_profile
Last active December 12, 2015 09:19
Add this to your .bash_profile to automatically add the SSH tunnel necessary for rmate on server connect
# RMate
ssh_mate(){
ssh -R 52698:localhost:52698 $1
}
alias sshmate=ssh_mate
# Usage
sshmate ubuntu@yourserver
@fanktom
fanktom / gist:3772889
Created September 23, 2012 20:05
Scales API Partials
@partial_html = "<div>Just the Navigation</div>"
@partial_xml = "<track><name>Islandary</name><artist>Thomas Fankhauser</artist></track>"
@partial_json = '{ name : "Islandary", artist : "Thomas Fankhauser" }'
# Push a HTML Partial
Scales.push :html => @partial_html, :to => "navigation"
# Push a XML Partial
Scales.push :xml => @partial_xml, :to => "islandary.xml"
@fanktom
fanktom / gist:3772880
Created September 23, 2012 20:03
Scales API Destroy
# Destroy URLs
Scales.destroy "/", "/tracks", "/overview", "/overview.json", "/overview.xml"
@fanktom
fanktom / gist:3772857
Created September 23, 2012 19:58
Scales API Modify
@html = '
<html>
<body>
<div><h1>Tracks</h1></div>
<div id="tracks">
<p id="track1">Track 1</p>
</div>
</body>
</html>'