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 'pg' | |
require 'sequel' | |
if ARGV[0] | |
DB = Sequel.connect(ARGV[0]) | |
else | |
abort "Usage: #$0 postgres://[host]/<database>" | |
end | |
DB.create_schema :lists |
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 sum_nested_list(l) | |
sum = 0 | |
pos_stack = [0] | |
until pos_stack.empty? | |
parent = nil | |
item = l | |
pos_stack.each do |pos| | |
parent = item | |
item = item[pos] |
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
// Note: Object is a trait, and this is a unit test helper. Symbol is a struct. | |
/// Tests the symbol within an Object reference. | |
fn test_symbol_in_object(object: &~Object, string: &str, machine: &Machine) { | |
let symbol = (object as &Any).as_ref::<symbol::Symbol>().unwrap(); | |
assert!(symbol.name(&machine.symbol_map).as_slice() == string) | |
} |
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
pub struct Execution { | |
root: Script, | |
pristine: bool, | |
pc: ~[uint], | |
stack: ~[ObjectRef] | |
} |
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
pub struct Execution { | |
root: Script, | |
pristine: bool, | |
pc: ~[uint], | |
stack: ~[ObjectRef] | |
} |
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
// execution_ref is of type ObjectRef, which is a struct that contains | |
// Rc<RefCell<~Object:'static>>, where Object is is a trait with the | |
// following relevant methods (others omitted): | |
trait Object { | |
fn as_any<'a>(&'a self) -> &'a Any { | |
self as &Any | |
} | |
fn as_any_mut<'a>(&'a mut self) -> &'a mut Any { |
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
@function column-width($span, $columns, $width) { | |
@return (($width - $grid-spacing * ($columns - 1)) / $columns) * $span + | |
$grid-spacing * ($span - 1); | |
} | |
@mixin span-last-columns($span, $columns, $width) { | |
float: left; | |
width: column-width($span, $columns, $width); | |
} |
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
isStaggering n = nChars /= nCharsSorted && nChars /= reverse nCharsSorted | |
where nChars = show n | |
nCharsSorted = sort nChars |
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
#include <stdio.h> | |
int areDigitsIncreasing(int n) { | |
int lastDigit = 9; | |
while (n > 0) { | |
if (lastDigit < n % 10) | |
return 0; | |
lastDigit = n % 10; |
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
abc | |
foo bar (widget dongle) | |
def | |
baz mud | |
wibble wobble | |
spaz |
OlderNewer