Skip to content

Instantly share code, notes, and snippets.

View kellegous's full-sized avatar

Kelly Norton kellegous

View GitHub Profile
x = True
while x:
print('forever')
while x == True:
print('forever')
y = 2
while y == 2:
print('forever')
class Bucket {
let id : Int
init(id: Int) {
print("\(id) is upon us.")
self.id = id
}
deinit {
print("\(id) has left the building.")
public Stream<Verse> allVerses() {
return books().stream().reduce(
Stream.empty(),
(sa, b) -> b.chapters().stream().reduce(
sa,
(sb, ch) -> Stream.concat(sb, ch.verses().stream()),
(sb, sc) -> Stream.concat(sb, sc)),
(sb, sc) -> Stream.concat(sb, sc));
}
class A[U <: String, V <: Int] {
def foo(u: U) = 1
def foo(v: V) = 2
}
class Api_Resource_Public_Taxonomy_Node implements Api_ResourceSpec_ITyped {
const DESC = "A node in the taxonomy of items on Etsy";
use Api_ResourceSpec_Typed;
use Api_ResourceSpec_Declaration;
/**
* @var array
*/
@kellegous
kellegous / wut.php
Last active September 10, 2015 23:50
<?php
function foo() {
try {
throw new Exception("ex1");
} finally {
try {
throw new Exception("ex2");
} catch (Exception $e) {
printf("caught in finally message=%s\n", $e->getMessage());
}
#!/usr/bin/env python2.7
import optparse
import os
import subprocess
import sys
import tempfile
import time
import math
print(4 * math.pi * math.pow(5, 3) / 3)
# run this with python3 ex2.4.py
def time_to_mins(t):
h, m = [int(x) for x in t.split(':')]
return h*60 + m
#!/usr/bin/env python3
import math
def ex1():
return '%0.3f' % (4 * math.pi * math.pow(5, 3) / 3.0)
def ex2():
return '$%0.2f' % (60*(24.95 * (1 - 0.4)) + 3.00 + 0.75*59)