Skip to content

Instantly share code, notes, and snippets.

View gerad's full-sized avatar

Gerad Suyderhoud gerad

View GitHub Profile
@gerad
gerad / add_partner_id_to_sources.sh
Created August 11, 2010 22:58
command line rails migration options example
script/generate migration add_partner_id_to_sources partner_id:string
@gerad
gerad / build_node.sh
Created August 16, 2010 02:14
getting started with node
git clone git://github.com/ry/node.git
cd node
./configure
make
sudo make install
@gerad
gerad / install-openinviter-ubuntu.md
Created September 15, 2010 05:45
setup openinviter on ec2

setup the instance

locally

go to the amazon web interface

note your AWS_USER_ID in the upper right hand corner. create a new AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY.

@gerad
gerad / ec2-ubuntu.sh
Created September 18, 2010 19:38
easy ec2 ubuntu server creation
#! /usr/bin/env bash
if [ -z $1 ]; then
echo "ec2-ubuntu - easy ec2 ubuntu server creation"
echo "Usage: $0 instance-name [instance-type [ami [region]]]"
exit
fi
instancename=$1
instancetype=${2:-'t1.micro'}
ami=${3:-'ami-1234de7b'}
$(function() {
$(window).hashchange(function() {
var tab = window.location.hash.replace(/^#/, '') || initial;
switchTabs(tab);
}).hashchange(); // trigger on page load
});
@gerad
gerad / npm install mongodb
Created March 10, 2011 17:24
npm install mongodb fails on no.de
[node@gerad ~]$ npm install mongodb
npm info it worked if it ends with ok
npm info using [email protected]
npm info using [email protected]
npm info fetch http://registry.npmjs.org/mongodb/-/mongodb-0.9.1.tgz
npm info calculating sha1 /tmp/npm-1299777263646/1299777263646-0.11996227549389005/tmp.tgz
npm info shasum 0b4c97289d9c88fc726a9993a8632d2ebe3284d6
npm info calculating sha1 /home/node/.node_libraries/.npm/.cache/mongodb/0.9.1/package.tgz
npm info shasum 5ea811dd1b55ae50b5ebda38c853e7548c7d86db
npm info preinstall [email protected]
@gerad
gerad / npm-hacks
Created March 11, 2011 03:49
hacky way to run forked npm modules on no.de
[node@gerad ~]$ mkdir npm-hacks
[node@gerad ~]$ cd npm-hacks/
[node@gerad ~/npm-hacks]$ git clone https://github.com/fortnightlabs/twitter-js
Initialized empty Git repository in /home/node/npm-hacks/twitter-js/.git/
remote: Counting objects: 78, done.
remote: Compressing objects: 100% (69/69), done.
remote: Total 78 (delta 27), reused 0 (delta 0)
Unpacking objects: 100% (78/78), done.
[node@gerad ~/npm-hacks]$ cd twitter-js/
[node@gerad ~/npm-hacks/twitter-js]$ npm link .
@gerad
gerad / chrome_form_submission_event_bug.html
Created March 16, 2011 19:47
shows a bug with chrome event handling
<form onsubmit='alert("should not get here");'>
<input id="text" type="text" placeholder="type something and hit enter">
</form>
<script>
var t = document.getElementById('text');
t.addEventListener('keydown', function(e) {
if (e.which === 13) { // hitting return
alert('form submission should be prevented');
e.stopPropagation();
@gerad
gerad / trackmac.rb
Created May 8, 2011 19:36
get information on the currently active mac window in ruby / applescript
require 'rubygems'
require 'bundler/setup'
require 'appscript'
# http://stackoverflow.com/questions/480866/get-the-title-of-the-current-active-window-document-in-mac-os-x
while true
frontmost = Appscript.app('System Events').application_processes.get.select{ |a| a.frontmost.get }.first
if frontmost
puts frontmost.name.get
if frontmost.windows.count > 0
@gerad
gerad / axInfoForProcessIdentifier.m
Created January 20, 2012 04:45
get the name and path of the frontmost window using the carbon mac os accessibility api
// http://stackoverflow.com/questions/2107657/mac-cocoa-getting-a-list-of-windows-using-accessibility-api
// http://stackoverflow.com/questions/853833/how-can-my-app-detect-a-change-to-another-apps-window
// http://cocoatutorial.grapewave.com/tag/axuielementcopyattributevalue/
- (NSDictionary *)axInfoForProcessIdentifier:(NSNumber *)processIdentifier
{
NSMutableDictionary *ret = [NSMutableDictionary dictionaryWithCapacity:2];
pid_t pid = (pid_t) [processIdentifier integerValue];
AXUIElementRef app = AXUIElementCreateApplication(pid);
AXUIElementRef frontWindow = nil;
NSString *title = nil;