Skip to content

Instantly share code, notes, and snippets.

View aghecht's full-sized avatar

Alan Hecht aghecht

View GitHub Profile
# This code snippet courtesy of http://muness.blogspot.com/2009/01/no-network-after-copying-ubuntu-vmware.html
# Apparently, Ubuntu persists the MAC address of the network device
sudo rm /etc/udev/rules.d/*net.rules
sudo shutdown -r now #to reboot
# This code fixes the error:
# undefined method `relative_url_root' for SessionsController:Class
def requested_url
relative_url_root = self.class.respond_to?(:relative_url_root) ? self.class.relative_url_root.to_s : request.relative_url_root
"#{request.protocol + request.host_with_port + relative_url_root + request.path}"
end
@aghecht
aghecht / gist:1181187
Created August 30, 2011 15:35
Sample jQuery organization using JavaScript objects
var BackButton = {
init: function() {
if (this.sampleFunction()) {
$('.backbutton').click(this.backButtonEvent);
}
},
sampleFunction: function() {
return true;
@aghecht
aghecht / index
Created January 27, 2012 01:48
Demo of Asynchronous JavaScript Events
<html>
<head>
<title>Test Page</title>
</head>
<body>
<p id="paragraph1">This is a list of key-value pairs</p>
<p id="paragraph2"></p>
@aghecht
aghecht / app.rb
Created January 27, 2012 02:40
Sinatra App for Demo JavaScript
require 'sinatra'
require 'erubis'
require 'json'
get '/index' do
erb :index
end
get '/data.json' do
sleep 10
@aghecht
aghecht / jquery.ba-tinypubsub.js
Created February 23, 2012 14:53 — forked from cowboy/HEY-YOU.md
jQuery Tiny Pub/Sub: A really, really, REALLY tiny pub/sub implementation for jQuery.
/* jQuery Tiny Pub/Sub - v0.7 - 10/27/2011
* http://benalman.com/
* Copyright (c) 2011 "Cowboy" Ben Alman; Licensed MIT, GPL */
(function($) {
var o = $({});
$.subscribe = function() {
o.on.apply(o, arguments);
@aghecht
aghecht / ld
Created June 25, 2012 16:41
Serialize/limit link step in OS/X
#!/bin/sh
lockfile=${TMPDIR}/link.lock
count=1;
while !(shlock -f "${lockfile}${count}" -p $$) do
let count=count+1;
if [ ${count} -eq 5 ]; then
let count=1;
sleep 1;
fi
@aghecht
aghecht / clj
Created July 4, 2012 17:21
clojure bash script
#!/bin/bash
# Clojure wrapper script
# with no arguments runs Clojure's REPL
if [ -n "${CLOJURE_EXT:-}" ]; then
OLD="$IFS"
IFS=":"
EXT="$(find -H $CLOJURE_EXT -mindepth 1 -maxdepth 1 -print0 | tr \\0 \:)"
IFS="$OLD"
if [ -n "${CLASSPATH:-}" ]; then
@aghecht
aghecht / install.sh
Created July 7, 2012 15:45
Install Sun JDK 6
sudo apt-add-repository ppa:flexiondotorg/java
sudo apt-get update
sudo apt-get install sun-java6-jdk
@aghecht
aghecht / gist:3090064
Created July 11, 2012 12:25
Emacs Homebrew install
sudo brew install emacs --cocoa --srgb