Skip to content

Instantly share code, notes, and snippets.

Christopher Smith cbsmith

  • Ticketmaster
Block or report user

Report or block cbsmith

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
cbsmith /
Last active Aug 29, 2015
An attempt to help this reddit poster use databases more effectively:
#!/usr/bin/env python
import sqlite3
from_location_group = {
'OBD1': 'Online',
'OBD2': 'Online',
'CB07': 'Retail',
'CB08': 'Retail',
'CB09': 'Retail',
cbsmith / tad_test.cpp
Created Mar 1, 2014
Some examples of template argument deduction
View tad_test.cpp
// -*- 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;
cbsmith /
Created Mar 25, 2014
A simply gist demonstrating how to copy from stdin to stdout in Java, in response to discussion of:
public class Copy {
public static void main(String[] args) throws Throwable {
int next;
while ((next = != -1) {
cbsmith /
Last active Aug 29, 2015
An example of how one could wrap pyodbc's wildcard prepared statements with Python's format string to have keyword based prepared statements.
from string import Formatter
import sys
def keywords_to_questionmarks(format_string, *args, **kwargs):
'''Convert a format string keyword formatted query to a ? wildcarded prepared statement
that is pyodbc compatible, along with the args tuple to pass to it.
* format_string: Python format compatible representation of a query
* args: positional args for the format string
* kwargs: keyword args for the format string
View gist:3cef86101cba1b61c7cb
"detail_output": {
"content.article-lease": {
"lease_type": 2,
"node_identifier": {
"node_name": "content.article-lease"
"timestamp": 1422677331539
"content.article.shingles-lease": {
def patch_all(socket=True, dns=True, time=True, select=True, thread=True, os=True, ssl=True, httplib=False,
subprocess=False, sys=False, aggressive=True, Event=False):
"""Do all of the default monkey patching (calls every other function in this module."""
# order is important
if os:
if time:
if thread:
cbsmith / gist:1493e6686c8d1be74310
Created Mar 6, 2015
Clinton Article from AP Feed
View gist:1493e6686c8d1be74310
<ns0:entry xmlns:ns0="" xmlns:ns1="" xmlns:ns2="">
<ns0:rights>Copyright 2015 The Associated Press. All rights reserved. This material may not be published, broadcast, rewritten or redistributed.</ns0:rights>
<ns0:content type="text/xml">
cbsmith /
Created Apr 29, 2012
Instant CentOS Minion on Joyent
# Setups up a new CentOS machine on Joyent running a Salt minion talking to your salt master. From there, you can do the rest of your setup work from the Salt Master.
# Requires Joyent Command Line SDK be installed as well as Node's jsontool (npm install jsontool)
# If you don't provide a Joyent ID, the code assumes the master is labeled with metadata "salt-role=master" or with "role=salt-master"
# Tweak these variables should have done anything creative with your salt setup
cbsmith / dont_terminate.cpp
Created Aug 8, 2012
The problem with std::uncaught_exception illustrated
View dont_terminate.cpp
// -*- compile-command: "clang++ -ggdb -o dont_terminate -std=c++0x -stdlib=libc++ dont_terminate.cpp" -*-
// Demonstration of the problem that can happen with using std::uncaught_exception() to determine
// whether it is safe to throw from within a destructor
// Problem identified, as always, by GOTW:
#include <stdexcept>
#include <iostream>
#include <cassert>
using namespace std;
cbsmith / brace_initializer.cpp
Created Nov 27, 2012
Demonstration of brace initialization as well as variadic templates.
View brace_initializer.cpp
// -*- compile-command: "clang++ -ggdb -o brace_initializer -std=c++0x -stdlib=libc++ brace_initializer.cpp" -*-
#include <string>
#include <ostream>
#include <memory>
#include <iostream>
#include <sstream>
#include <new>
class Foo {
You can’t perform that action at this time.