Skip to content

Instantly share code, notes, and snippets.

View notahat's full-sized avatar

Pete Yandell notahat

View GitHub Profile
% ruby --version
ruby 1.8.6 (2007-09-23 patchlevel 110) [i686-darwin9.0.0]
% sudo gem install rails --version 2.1.1
Password:
Successfully installed activesupport-2.1.1
Successfully installed activerecord-2.1.1
Successfully installed actionpack-2.1.1
Successfully installed actionmailer-2.1.1
Successfully installed activeresource-2.1.1
# This is a teaser for a plugin I'm working on to provide an alternative
# to ActiveRecord fixtures.
#
# It's similar to ThoughtBot's Factory Girl, but I think the syntax is
# a lot nicer.
#
# The models below are the canonical Rails blog examples, i.e. a Post
# has_may Comments.
#
# I'm using the very cool Faker gem to make up values for fields.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>Table Test</title>
<style type="text/css" media="screen">
table { table-layout: fixed; width: 100%; border-collapse: collapse; border-spacing: 0; }
td { padding: 5px; border: 1px solid #888888; }
Why is http://gist.github.com/15704 invalid HTML?
The width of each column is specified as 50%. Section 10.2 of the CSS2 spec tells us:
The percentage is calculated with respect to the width of the generated box's containing block.
The containing block in this case is the table. So let's say the table is, for example, 500px wide.
That means each column is 250px wide, but...
Section 17.6.2 tells us that the row width is:
@notahat
notahat / gist:39132
Created December 22, 2008 21:33 — forked from xaviershay/gist:39075
value = "Don T Alias"
first_name, last_name = value.reverse.split(' ', 2).reverse.collect(&:reverse)
first_name = first_name.to_s
last_name = last_name.to_s
# Refactored to take into account Xavier's pathological aversion to case statements:
words = value.split(' ')
first_name, last_name = if words.size == 0
['', '']
elsif words.size == 1
~$ sudo gem install lachlanhardy-gitjour
Successfully installed lachlanhardy-gitjour-8.1.0
1 gem installed
Installing ri documentation for lachlanhardy-gitjour-8.1.0...
Installing RDoc documentation for lachlanhardy-gitjour-8.1.0...
Could not find main page README.txt
Could not find main page README.txt
Could not find main page README.txt
Could not find main page README.txt
The Ruby daemons gem, as used by daemontools, does this to restart daemons:
@group.stop_all
sleep 1
@group.start_all
The stop_all method does not wait for the daemon to exit before returning.
Anyone see the huge glaring problem here? *grumble*
My traceroute [v0.75]
maxwell.local (0.0.0.0) Fri Mar 27 20:56:20 2009
Keys: Help Display mode Restart statistics Order of fields quit
Packets Pings
Host Loss% Snt Last Avg Best Wrst StDev
1. 192.168.1.254 0.0% 70 1.9 2.9 1.8 12.4 2.1
2. loop0.lns10.mel4.internode.on.ne 0.0% 70 12.0 8.8 7.3 14.7 1.6
3. vl13.cor3.mel4.internode.on.net 0.0% 70 7.8 9.1 7.5 16.3 1.8
4. pos8-0.bdr1.syd7.internode.on.ne 0.0% 70 179.6 185.3 177.6 327.6 24.7
5. pos5-0.bdr1.sjc2.internode.on.ne 0.0% 70 180.2 179.4 177.3 205.0 3.8
#include <avr/interrupt.h>
union TimerCounter {
struct {
unsigned int interval_count_lo, interval_count_hi;
unsigned char overflow_countdown;
};
unsigned long interval_count;
};
require 'test/unit'
require 'enumerator'
class Array
def in_chunks_of(size_of_chunks)
enum_slice(size_of_chunks).to_a
end
end
class TestArrayInChunks < Test::Unit::TestCase