View index.html
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>XML.js Test</title> | |
<script type="text/javascript" src="xml.js"></script> | |
<script type="text/javascript"> | |
var xml = new XML('root'); | |
xml.attr('one', 1); |
View string.rb
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 'citrus' | |
Citrus.eval(<<'CODE') | |
grammar RubyString | |
rule string | |
single_quoted_string | double_quoted_string | |
end | |
# This should be expanded to account for escaped single quotes. | |
rule single_quoted_string |
View fixed-position.html
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<style type="text/css"> | |
#wrapper { | |
width: 800px; | |
margin: 0 auto; | |
background: green; |
View days.rb
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 'citrus' | |
Citrus.eval(<<'CODE') | |
grammar Days | |
rule every_n_days | |
('every ' number ' days') { | |
"INTERVAL=#{number}" | |
} | |
end |
View strftime.js
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
var days = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]; | |
var shortDays = ["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]; | |
var months = ["January","February","March","April","May","June","July","August","September","October","November","December"]; | |
var shortMonths = ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]; | |
function zeropad(n) { | |
return n > 9 ? String(n) : "0" + String(n); | |
} | |
function twelveHour(t) { |
View Array#pick_random.rb
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
class Array | |
# Pick +n+ random items from this array. | |
def pick_random(n=1) | |
sort_by { rand }.slice(0...n) | |
end | |
end |
View events.js
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
// Event handling functions modified from originals by Dean Edwards. | |
// http://dean.edwards.name/my/events.js | |
var guid = 1; | |
// Adds an event handler to the given element. The handler will be called | |
// in the context of the element with the event object as its only argument. | |
function addEvent(element, type, handler) { | |
if (element.addEventListener) { | |
element.addEventListener(type, handler, false); |
View intersect.js
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
// Returns the intersection of two sorted arrays of numbers or strings. | |
function intersectArrays(a, b) { | |
var array = [], ai = 0, alen = a.length, bi = 0, blen = b.length; | |
while (ai < alen && bi < blen) { | |
if (a[ai] < b[bi]) { | |
ai++; | |
} else if (a[ai] > b[bi]) { | |
bi++; | |
} else { |
View blocks.rb
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
def a(*args, &block) | |
puts "a got a block" if block_given? | |
end | |
def b(*args, &block) | |
puts "b got a block" if block_given? | |
end | |
# In this call, `b' is called with the block and the | |
# return value is given to `a' as an argument. |
View mockstream.js
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
var util = require("util"), | |
Stream = require("stream").Stream; | |
module.exports = MockStream; | |
/** | |
* A constructor that inherits from Stream and emits data from the given | |
* `source`. If it's a Stream it will be piped through to this stream. | |
* Otherwise, it should be a string or a Buffer which will be emitted by this | |
* stream as soon as possible. |
OlderNewer