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
x = True | |
while x: | |
print('forever') | |
while x == True: | |
print('forever') | |
y = 2 | |
while y == 2: | |
print('forever') |
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 Bucket { | |
let id : Int | |
init(id: Int) { | |
print("\(id) is upon us.") | |
self.id = id | |
} | |
deinit { | |
print("\(id) has left the building.") |
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
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)); | |
} |
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 A[U <: String, V <: Int] { | |
def foo(u: U) = 1 | |
def foo(v: V) = 2 | |
} |
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 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 | |
*/ |
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
<?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()); | |
} |
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
#!/usr/bin/env python2.7 | |
import optparse | |
import os | |
import subprocess | |
import sys | |
import tempfile | |
import time | |
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
import math | |
print(4 * math.pi * math.pow(5, 3) / 3) | |
# run this with python3 ex2.4.py |
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 time_to_mins(t): | |
h, m = [int(x) for x in t.split(':')] | |
return h*60 + m |
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
#!/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) |