This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* From 'Transcending CSS' by Andy Clark */ | |
/* http://www.transcendingcss.com/ */ | |
/* Normalize margin, padding */ | |
body, div, dl, dt, dd, ul, ol, li, h1, h2, h3, h4, h5, h6, pre, form, fieldset, input, p, blockquote, th, td { | |
margin: 0; | |
padding: 0; | |
} | |
/* Normalize font-size for headers */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Snippets from 'JavaScript: The Good Parts' by David Crockford | |
if (typeof Object.beget !== 'function') { | |
Object.beget = function (o) { | |
ver F = Function () {}; | |
F.prototype = 0; | |
return new F(); | |
}; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js'></script> | |
<script> | |
var Tap = {}; | |
$(document).ready(function(){ | |
function debug(str){ $("#debug").append("<p>"+str+"</p>"); }; | |
ws = new WebSocket("ws://localhost:8080/websocket"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Describes everything needed to create the database schema. | |
create sequence emp_seq; | |
create sequence dept_seq; | |
create sequence job_seq; | |
create table dept ( | |
id number(15) not null, | |
name varchar2(20) not null, | |
city varchar2(20) not null, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'test/unit' | |
require 'benchmark' | |
# This benchmark compares the speed of several variations of the escape_html | |
# method in Rack::Utils (4bfb6fc2768312e8899759255904463b781a10cd) | |
# | |
# # Escape ampersands, brackets and quotes to their HTML/XML entities. | |
# def escape_html(string) | |
# string.to_s.gsub("&", "&"). | |
# gsub("<", "<"). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# cut -f 5 tiobe.txt | xargs ruby -e "puts ARGV.inject(0) {|sum, n| sum + n[0..-1].to_f }" | |
1 1 Java 18.033% -2.11% A | |
2 2 C 17.809% +1.03% A | |
3 3 C++ 10.757% +0.16% A | |
4 4 PHP 8.934% -0.74% A | |
5 5 (Visual) Basic 5.868% -2.07% A | |
6 7 C# 5.196% +0.66% A | |
7 6 Python 4.266% -0.49% A | |
8 9 Perl 3.200% -0.71% A |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'benchmark' | |
require 'active_record' | |
ActiveRecord.load_all! | |
# ActiveRecord::Base.logger = Logger.new(STDERR) | |
ActiveRecord::Base.establish_connection( | |
:adapter => "sqlite3", | |
:dbfile => ":memory:" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Patch fixes issue on oracle. | |
class ActiveRecord::Base | |
NONQUOTED_OBJECT_NAME = /[A-Za-z][A-z0-9$#]{0,29}/ | |
NONQUOTED_DATABASE_LINK = /[A-Za-z][A-z0-9$#\.@]{0,127}/ | |
TABLES_IN_STRING = /((?:#{NONQUOTED_OBJECT_NAME}\.)?#{NONQUOTED_OBJECT_NAME}(?:@#{NONQUOTED_DATABASE_LINK})?)\..?/ | |
def self.tables_in_string(string) | |
return [] if string.blank? | |
# string.scan(/([\.a-zA-Z_]+).?\./).flatten | |
string.scan(TABLES_IN_STRING).flatten.map {|str| str.downcase }.uniq - ['raw_sql_'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'test/unit' | |
# These tests illustrate that the tables_in_string will not properly handle | |
# oracle table names containing valid non-word characters like '$' or those | |
# suffixed with a db link. As a consequence, eager loading can revert to the | |
# left-outer-join strategy and ignore select statements on find (see | |
# http://gist.github.com/486750). | |
# | |
# To fix the issue, the regexp in tables_in_string needs to be updated to | |
# handle fully-qualified oracle names. As you can see it's kinda ugly to do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# :startdoc::generator | |
class Doctest < Tap::Generator::Base | |
Utils = Lazydoc::Utils | |
Comment = Lazydoc::Comment | |
def manifest(m, *paths) | |
paths.each do |path| | |
lines = File.read(path).split("\n") | |