Skip to content

Instantly share code, notes, and snippets.

View cjhanks's full-sized avatar
🔥

zeekoni cjhanks

🔥
View GitHub Profile
@cjhanks
cjhanks / t0.py
Created February 21, 2014 06:02
sre-tests
"""
http://www.careercup.com/question?id=5127611667709952
"""
RowSize = 5
Data = [['a', 'b', 'c', 'd', 'e'],
['f', 'g', 'h', 'i', 'j'],
['k', 'l', 'm', 'n', 'o'],
['p', 'q', 'r', 's', 't'],
['u', 'v', 'w', 'x', 'y'],
class Test(object):
def __init__(self):
self.val = None
def __eq__(self, rhs):
return self.val == None
t_0 = Test()
print(t_0 == None) # True
@cjhanks
cjhanks / image-diff
Created March 6, 2014 22:38
Image difference
#!/usr/bin/env python
import cv2
import math
import numpy
from argparse import ArgumentParser
def main():
ap = ArgumentParser('image difference tool')
ap.add_argument('--img1', required = True)
@cjhanks
cjhanks / safe.cc
Created March 13, 2014 20:23
safe-except_dog
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
class T {
public:
T(const string& value)
: value(value)
@cjhanks
cjhanks / mpu-copy.py
Last active August 29, 2015 13:57
mpu-copy
def safe_mp_copy(target_b, target_k, source_b, source_k):
"""
:target_b: boto.s3.Bucket
Destination bucket
:target_k: str
Destination object key
:source_b: boto.s3.Bucket
Source bucket
@cjhanks
cjhanks / evil.c
Last active August 29, 2015 13:57
Evil
bool
impl_query_pose_index(PoseIndexUncompressCtx* ctx, PoseIndexReq* req
, PoseIndexRes* res)
{
if (!unpack_block(ctx))
return false;
static void* dispatch[] = { &&above, &&below, &&exit };
enum State { AboveThreshold = 0, BelowThreshold = 1, Done = 2 };
@cjhanks
cjhanks / test.cpp
Created June 26, 2014 05:05
Variadic Serialization
#include <cassert>
#include <cstring>
#include <ctime>
#include <iostream>
#include <type_traits>
#include <tuple>
using namespace std;
@cjhanks
cjhanks / sample.py
Created June 26, 2014 18:43
ListByTag
import boto
def gather_hosts():
for reservation in boto.connect_ec2().get_all_instances(
filters = { 'tag:purpose' : 'ingestion' }):
for instance in reservation.instances:
print(instance.public_dns_name)
print(instance.private_ip_address)
@cjhanks
cjhanks / test.cpp
Last active August 29, 2015 14:03
Variadic Seriaization 2
#include "serial.hpp"
#include <iostream>
int
test(double a, int b) {
return a * b;
}
@cjhanks
cjhanks / HttpParse.cpp
Created July 16, 2014 16:02
Http Parser Code
#include "HttpParse.hpp"
#include <cstdint>
#include <vector>
namespace {
static constexpr size_t MaximumHeaderSize = 8 * 1024;
/// {@