Skip to content

Instantly share code, notes, and snippets.

View devyn's full-sized avatar
👨‍💻
Nushell is really cool

Devyn Cairns devyn

👨‍💻
Nushell is really cool
View GitHub Profile
require 'pg'
require 'sequel'
if ARGV[0]
DB = Sequel.connect(ARGV[0])
else
abort "Usage: #$0 postgres://[host]/<database>"
end
DB.create_schema :lists
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]
// 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)
}
pub struct Execution {
root: Script,
pristine: bool,
pc: ~[uint],
stack: ~[ObjectRef]
}
pub struct Execution {
root: Script,
pristine: bool,
pc: ~[uint],
stack: ~[ObjectRef]
}
// 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 {
@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);
}
isStaggering n = nChars /= nCharsSorted && nChars /= reverse nCharsSorted
where nChars = show n
nCharsSorted = sort nChars
#include <stdio.h>
int areDigitsIncreasing(int n) {
int lastDigit = 9;
while (n > 0) {
if (lastDigit < n % 10)
return 0;
lastDigit = n % 10;
abc
foo bar (widget dongle)
def
baz mud
wibble wobble
spaz