Skip to content

Instantly share code, notes, and snippets.

View cyberfox's full-sized avatar

Morgan Schweers cyberfox

View GitHub Profile
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Growl notification</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<base href="%baseurl%" />
<style type="text/css">
@import URL("default.css");
#top,#middle,#bottom {
@cyberfox
cyberfox / growl command.sh
Created September 5, 2008 20:39
undefined
growl -H myhost -n myapp --priority 0 -m '<div id="override"><img src="http://somehost/start_ok.png" alt="icon"></div>Application running...' -t "Started"
#!/bin/sh
svn mkdir svn://svn/test_branching svn://svn/test_branching/trunk svn://svn/test_branching/branches -m"Create a test repository for branching."
mkdir branch_tmp
cd branch_tmp
svn co svn://svn/test_branching/trunk test/
cd test
echo "This is a test." > testme.txt
svn add testme.txt
svn commit testme.txt -m"Add a test file."
svn cp svn://svn/test_branching/trunk svn://svn/test_branching/branches/new_branch -m"Create a new branch with the test file in it."
@cyberfox
cyberfox / gist:137231
Created June 28, 2009 10:31
A cool little, super-simple, shell script for doing calculations.
# Tried to twitter this; FAIL.
$ cat > calc
#!/bin/env ruby
p eval(ARGV[0])
^D
$ chmod a+x calc
$ ./calc 4*Math::PI
$ ./calc "Math::sqrt(15241578750190521)"
$ ./calc 24*7
@cyberfox
cyberfox / gist:139419
Created July 2, 2009 11:01
501 http response error log for JBidwatcher
Tue Jun 30 19:43:31 CEST 2009: JBidwatcher 2.0.1-825
Tue Jun 30 19:43:32 CEST 2009: Sun Microsystems Inc. Java, version 1.6.0_13 on Linux
Tue Jun 30 19:43:35 CEST 2009: Error setting up scripting: java.lang.NoClassDefFoundError: org/jruby/runtime/builtin/IRubyObject
Tue Jun 30 19:43:36 CEST 2009: Loading listings from the database (1/6/6 entries, 6/6 auctions)
Tue Jun 30 19:43:36 CEST 2009: Done with the initial load (got 1 active entries)
Tue Jun 30 19:43:41 CEST 2009: Couldn’t sign in!
Server returned HTTP response code: 501 for URL: http://cgi1.ebay.com/aw-cgi/eBayISAPI.dll?Adult…
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
@cyberfox
cyberfox / Modules can access instance variables of the included-to class
Created October 29, 2009 19:25
Modules can access instance variables of the included-to class
>> module Foo
>> def bar
>> puts @quux
>> end
>> end
=> nil
>> class Baz
>> attr_accessor :quux
>> def xyzzy
@cyberfox
cyberfox / resource_factory.rb
Created November 9, 2009 23:35
Make ActiveResource able to handle authentication w/o acting like a global variable.
# This is a gross hack to make it possible to access the same
# resource from the context of different users at the same time.
# I'm quite positive this is wasteful and bad, but it's the only
# way to 'de-global' subclasses of ActiveResource::Base. :( It's
# also possible it leaks memory if the GC doesn't collect Class
# objects. -- Morgan Schweers, 09-Nov-2009
class ResourceFactory
def self.get(klass)
Class.new(klass) do |resource|
begin-base64 644 auto_shoulda.tar.bz2
QlpoOTFBWSZTWfMxtz8ABAZ/lPyQACBy5/+/eiGeCv/v//QACIABAAhQBR7qp0dBylAUFAylAGmg
BoaAABoA0YmR6gAARFNp6UyZGgBo00BoZNGQA0ADTIaCRCCEpqe01I0P1T1NqeoaDQNqGI9IPU9R
6gNqHDTTIxGE0wEMAmmEYJiZDTI0NAFSSENMpo00NNTaJNMmIaA0AAYmTRppo9Ej0/YnSdhvk0e+
q/GRa0rFA7KSJx0d/u798WggWrGrJEArqr4qLRwh0/HdwtMiQxe0UFSEqQtIshUj8BOyO17Kiqr+
/L1bxloIg7QPCIYgdn6mhnXBsLXGskaRjMPk1RcupnL5GxJI9cioE0CR6sRpRaz07fkhNpjLf69U
jAUGsHL2cJXReb6hs/rVfYDbomNFhfx04Ji3lrfycAGYpSLygdwMQw/fXckIEImFCcAoFGYsqfUI
RlOiRCE9IEgVZmqGTGya0yjUMBQ4hoIPcSfU2M14tczczVRk128eKaP2f2s53AzeuQGaYgOEvTlb
8EQ3Y3uTtg4yX+GHo9tNyttpl24QNxB7sFcn4u0vY8M5VZzi9SRJI0MB7I5MBvgEABoNOZ3K3FKU
5SABpJCDEQANQZQGYMkkqt7MLCRY3pDl1mJY2EzJLz15IuY0vP4JDzpXXMk4xVXebJFMvdRpUpYS
$$('.switch').each(function(elem) {
real_element = elem.id.replace("-switch", "");
if(!$(real_element).visible()) {
table = elem.parentNode.parentNode.parentNode.parentNode;
table.hide();
if(table.previousElementSibling != null) {
if(table.previousElementSibling.tagName == 'BR') {
table.previousElementSibling.hide();
}
}
# Include this in your RAILS_ROOT/test/test_helper.rb
class ActionController::TestCase
def better_cookies
cookies = {}
Array(@response.headers['Set-Cookie']).each do |cookie|
key = nil
details = cookie.split(';').inject({}) do |fields, cookie_field|
pair = cookie_field.split('=').map {|val| Rack::Utils.unescape(val.strip)}
key = pair.first unless key