Skip to content

Instantly share code, notes, and snippets.

@benfoxall
benfoxall / 1-enlarge.js
Created January 13, 2010 11:32
minimal image enlarge
// intercept rel=image clicks and make images fade in over the top
$$('a[rel=image]').each(function(link){
link.observe('click',function(e){
Event.stop(e);
i = new Element('img');
i.observe('load',function(){
$('image_mask').appear()
})
// do this afterwards for IE
i.writeAttribute('src',$(this).readAttribute('href'));
#! /usr/bin/ruby
n = 52 # size of deck
s = 8 # number of shuffles
cards = []
n.times {|card| cards << card}
s.times do |shuffle|
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
public class Textonyms {
/**
* Outputs any words from the System.in that could have been generated
@benfoxall
benfoxall / Usage.rb
Created December 17, 2010 12:45
Quick hack to test Rails3 mailers.
mail(:to => ....).dev_deliver('your@email.com') # will deliver through this mailer to 'your@email.com'
@benfoxall
benfoxall / apache-vhost.conf
Created February 28, 2011 11:00
Dev hosting configuration for apache
UseCanonicalName Off
VirtualDocumentRoot /Users/ben/Sites/%1
<Directory /Users/ben/Sites>
Options SymLinksIfOwnerMatch
</Directory>
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-1.5.js"></script>
<style type="text/css" media="screen">
body{font-family: Helvetica, sans-serif}
</style>
<script type="text/javascript" charset="utf-8">
$(function(){
@benfoxall
benfoxall / gist:879785
Created March 21, 2011 17:02
Outline jQuery cssHook
(function($){
if(document.createElement().style.outline == undefined){
/*
This requires the following lines in the document:
<style>v\: * { behavior:url(#default#VML);}</style>
<xml:namespace ns="urn:schemas-microsoft-com:vml" prefix="v" />
*/
$.cssHooks['outline'] = {
/*
Usage:
t = timer();
t('start')
…some slow script…
t('checkpoint');
…some slow script…
list = t('checkpoint2');
@benfoxall
benfoxall / gist:896166
Created March 31, 2011 10:51
Ruby tempfile monkey patch
# based on http://marsorange.com/archives/of-mogrify-ruby-tempfile-dynamic-class-definitions#comment-94
# Monkey patch the temp file so that it maintains the extension
class Tempfile
def make_tmpname basename, n
sprintf('%s%d-%d%s', File::basename(basename, ext), $$, n, File::extname(basename))
end
end
@benfoxall
benfoxall / timer.htm
Created April 12, 2011 00:50
testing times @ timebeacon.duostack.net
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>timer</title>
<script type="text/javascript" charset="utf-8">
;window.timer = function(){