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
cbsmith / keybase.md
Created Dec 27, 2015
Proving who I am to the world...
View keybase.md

Keybase proof

I hereby claim:

  • I am cbsmith on github.
  • I am cbsmith (https://keybase.io/cbsmith) on keybase.
  • I have a public key ASAP-aANv7TdH9M92MiL7AmjcQmFCR4m9bNymFF-1y6LIgo

To claim this, I am signing this object:

@cbsmith
cbsmith / awscli_functions.sh
Created Dec 15, 2015
A handy collection of bash functions to make the aws cli a bit more usable
View awscli_functions.sh
# Usage: . awscli_functions.sh
# Suggested: add to ~/.bashrc
# This code lazily uses your default profile && region.
# It wouldn't take much to add some logic for using ${PROFILE} and/or ${REGION} as some kind of override.
# Lots more functions would be helpful, but I've been playing with ec2 & vpcs a lot lately, so...
clusters()
{
local __resultvar=$1
local __clusters=$(aws ecs list-clusters | jq -r '.clusterArns[]')
@cbsmith
cbsmith / cloud-config.yml
Last active Sep 26, 2016 — forked from skippy/cloud-config.yml
modifying fleet metadata (from aws meta-data service) before fleet.service start; this is a proof of concept (but it works!)
View cloud-config.yml
#cloud-config
---
coreos:
units:
- name: update-fleet-metadata.service
command: start
content: |-
[Unit]
Description=Update Fleet metadata tag
Before=fleet.service
@cbsmith
cbsmith / gist:1493e6686c8d1be74310
Created Mar 6, 2015
Clinton Article from AP Feed
View gist:1493e6686c8d1be74310
<ns0:entry xmlns:ns0="http://www.w3.org/2005/Atom" xmlns:ns1="http://ap.org/schemas/03/2005/apcm" xmlns:ns2="http://ap.org/schemas/03/2005/apnm">
<ns0:id>urn:publicid:ap.org:f655319a9d09472495e3d7cc400da16a</ns0:id>
<ns0:title>US-DEM-2016-Clinton</ns0:title>
<ns0:updated>2015-03-05T22:05:43.580Z</ns0:updated>
<ns0:published>2015-03-05T22:05:36Z</ns0:published>
<ns0:author>
<ns0:name>AP</ns0:name>
</ns0:author>
<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">
View gevent.monkey_patch_all.py
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:
patch_os()
if time:
patch_time()
if thread:
patch_thread(Event=Event)
View gist:3cef86101cba1b61c7cb
{
"detail_output": {
"content.article-lease": {
"lease_type": 2,
"node_identifier": {
"node_name": "content.article-lease"
},
"timestamp": 1422677331539
},
"content.article.shingles-lease": {
@cbsmith
cbsmith / format_strings.py
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.
View format_strings.py
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
@cbsmith
cbsmith / idempotent_path_add.sh
Last active Oct 16, 2017
An example on how to do idempotent PATH manipulation.
View idempotent_path_add.sh
#!/usr/local/bin/bash
#How to manipulate the path in an intelligent fashion with bash. Note: this doesn't work with Bourne shell.
function idempotent_path_add {
DIR="$1"
PREPEND=$2
if [[ ! "$PATH" =~ (^|:)"$DIR"(:|$) ]]
then
if [ $PREPEND ]
then
@cbsmith
cbsmith / Copy.java
Created Mar 25, 2014
A simply gist demonstrating how to copy from stdin to stdout in Java, in response to discussion of: https://news.ycombinator.com/item?id=7463671
View Copy.java
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();
}
}
@cbsmith
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;
You can’t perform that action at this time.