Christopher Smith cbsmith

View Copy.java
1 2 3 4 5 6 7 8 9
public class Copy {
public static void main(String[] args) throws Throwable {
int next;
while ((next = System.in.read()) != -1) {
System.out.write(next);
}
System.out.flush();
}
}
View tad_test.cpp
1 2 3 4 5 6 7 8 9 10
// -*- compile-command: "clang++ -ggdb -std=c++11 -stdlib=libc++ -Wall -Werror tad_test.cpp -o tad_test" -*-
 
#include <iostream>
 
using namespace std;
 
template <typename T, typename U>
struct Foo {
T v;
U w;
View sql_join.py
1 2 3 4 5 6 7 8 9 10
#!/usr/bin/env python
 
import sqlite3
 
from_location_group = {
'OBD1': 'Online',
'OBD2': 'Online',
'CB07': 'Retail',
'CB08': 'Retail',
'CB09': 'Retail',
View better_random.py
1 2 3 4 5 6 7 8 9 10
import random
import itertools
 
def sample(population, k):
"How random.sample should really be defined."
 
if callable(getattr(population, '__len__', None)) and callable(getattr(population, '__getitem__', None)):
return random.sample(population, min(k, len(population)))
 
p = iter(population)
View endian.cpp
1 2 3 4 5 6 7 8 9 10
// -*- compile-command: "g++ -O3 -march=native -std=c++11 -Wall -Werror endian.cpp -o endian" -*-
#include <fstream>
#include <ostream>
#include <istream>
#include <cstdint>
#include <algorithm>
#include <cassert>
#include <string>
#include <vector>
#include <limits>
View test.cpp
1 2 3 4 5 6 7 8 9 10
// -*- compile-command: "clang++ -Weverything -Wno-c++98-compat -ggdb -o test -std=c++11 -stdlib=libc++ test.cpp" -*-
 
#include <iostream>
#include <type_traits>
 
template <typename T, typename U, bool boolable = std::is_convertible<T,bool>::value, bool assignable = std::is_assignable<T, U>::value >
struct or_assign_helper;
 
template <typename T, typename U>
struct or_assign_helper<T, U, true, true> {
View test.cpp
1 2 3 4 5 6 7 8 9 10
// -*- compile-command: "clang++ -ggdb -o test -std=c++11 -stdlib=libc++ test.cpp" -*-
 
#include <iostream>
 
float add(float x, float y) {
return x+y;
}
 
auto add_fourty_two = +[](float x) { return add(x, 42); };
auto add_pie_and_fourty_two = +[]() { return add_fourty_two(3.1415926); };
View two_stars_98.cpp
1 2 3 4 5 6 7 8 9
// -*- compile-command: "clang++ -ggdb -o two_stars_98 -std=c++98 -stdlib=libc++ two_stars_98.cpp" -*-
#include <algorithm>
#include <iostream>
 
using namespace std;
 
bool points_to_two(int* x) {
return *x == 2;
}
View two_stars.cpp
1 2 3 4 5 6 7 8 9 10
// -*- compile-command: "clang++ -ggdb -o two_stars -std=c++0x -stdlib=libc++ two_stars.cpp" -*-
#include <algorithm>
#include <iostream>
 
using namespace std; //laziness
 
int main(int argc, char** argv) {
int a = 1;
int b = 2;
int c = 3;
View random_selection.cpp
1 2 3 4 5 6 7 8 9 10
// -*- compile-command: "clang++ -ggdb -o random_selection -std=c++0x -stdlib=libc++ random_selection.cpp" -*-
//Reference implementation for doing random number selection from a container.
//Kept for posterity and because I made a surprising number of subtle mistakes on my first attempt.
#include <random>
#include <iterator>
 
template <typename RandomGenerator = std::default_random_engine>
struct random_selector
{
//On most platforms, you probably want to use std::random_device("/dev/urandom")()
Something went wrong with that request. Please try again.