This file contains hidden or 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
Churchill: Madam, would you sleep with me for five million pounds? | |
Woman: My goodness, Mr. Churchill… Well, I suppose… we would have to discuss terms, of course… | |
Churchill: Would you sleep with me for five pounds? | |
Woman: Mr. Churchill, what kind of woman do you think I am?! | |
Churchill: Madam, we’ve already established that. Now we are haggling about the price. |
This file contains hidden or 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
@Test(groups = { "functest" }) | |
public class AppTest { | |
/** | |
* Rigourous Test :-) | |
*/ | |
@Test(expectedExceptions = { IllegalArgumentException.class }) | |
public void testApp() { | |
Assert.assertTrue(true); | |
This file contains hidden or 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 java.util.Map; | |
import java.util.HashMap; | |
public class Make { | |
private Make() {}; | |
@SuppressWarnings(value = "unchecked") | |
public static <K, V> Map<K, V> map(Object... items) { | |
if ((items.length % 2) != 0) { | |
throw new IllegalArgumentException( |
This file contains hidden or 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
(ns csv | |
(import com.csvreader.CsvReader)) | |
(defn csv-seq | |
"Return a lazy sequence of records (vectors) from CSV file" | |
[filename] | |
(let [csv (CsvReader. filename) | |
read-record (fn [] | |
(when (.readRecord csv) | |
(into [] (.getValues csv))))] |
This file contains hidden or 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
'''Example on how to copy data from one database to the other''' | |
import sqlite3 | |
SCHEMA_SQL = "CREATE TABLE people (name TEXT, id INT)" | |
INSERT_SQL = "INSERT INTO people VALUES (?, ?)" | |
GET_SQL = "SELECT * FROM people" | |
COUNT = 100 | |
def setup_dbs(): | |
"Setup source and destination databases, create schema and populate source" |
This file contains hidden or 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> | |
#include <avro.h> | |
#include <stdlib.h> | |
int | |
main(int argc, char *argv[]) { | |
if (argc != 2) { | |
fprintf(stderr, "usage: reader FILENAME\n"); | |
exit(1); | |
} |
This file contains hidden or 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 python | |
# Print exchange rate | |
import yql | |
QUERY = 'SELECT * FROM yahoo.finance.xchange WHERE pair in ("%s%s")' | |
ENV = "store://datatables.org/alltableswithkeys" | |
def main(argv=None): | |
import sys |
This file contains hidden or 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
name: Daffy Duck | |
age: 80 | |
frenemies: ["Bugs Bunny", "Taz"] |
This file contains hidden or 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
# Find the greatest product of five consecutive digits in the 1000-digit number. | |
from operator import mul | |
n = ''' | |
73167176531330624919225119674426574742355349194934 | |
96983520312774506326239578318016984801869478851843 | |
85861560789112949495459501737958331952853208805511 | |
12540698747158523863050715693290963295227443043557 | |
66896648950445244523161731856403098711121722383113 |
This file contains hidden or 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 sqlite3 | |
UPDATE_SQL = ''' | |
UPDATE phonebook | |
SET phone = ? | |
WHERE name = ? | |
''' | |
INSERT_SQL = ''' | |
INSERT INTO phonebook |