Skip to content

Instantly share code, notes, and snippets.

View cporter's full-sized avatar

Corey Porter cporter

  • Monrovia, Calif.
View GitHub Profile
import requests
import re
import sys
import os.path
import datetime
out = sys.argv[1]
def basename(x):
xs = x.split('/')
#include <Wire.h>
#include <Adafruit_VL53L0X.h>
#include <Joystick.h>
Joystick_ Joystick(JOYSTICK_DEFAULT_REPORT_ID,
JOYSTICK_TYPE_MULTI_AXIS, 4, 0,
false, false, false, false, false, false,
false, false, true, true, true);
const int TCAADDR = 0x70;

Keybase proof

I hereby claim:

  • I am cporter on github.
  • I am cp253 (https://keybase.io/cp253) on keybase.
  • I have a public key whose fingerprint is F1D9 4F8B 9FE8 CCCD 7F9A 8BF4 3DAE 18E9 CE8F 810E

To claim this, I am signing this object:

@cporter
cporter / map.cpp
Created May 12, 2014 00:16
Making a lookup table
// -*- compile-command: "clang++ -std=c++1y map.cpp -o map" -*-
#include <map>
#include <string>
#include <iostream>
class NoteLookup {
private:
std::map<std::string, double> lookup;
public:
@cporter
cporter / split.cpp
Last active August 29, 2015 14:01
Splitting a string
// -*- compile-command: "clang++ -std=c++1y split.cpp -o split" -*-
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <iterator>
#include <vector>
std::vector<std::string> split (const std::string& s) {
@cporter
cporter / rsvg-xml-huge
Created November 27, 2013 21:32
Make librsvg always allow possibly ill-formed documents.
diff --git a/rsvg-base.c b/rsvg-base.c
index 6210716..fe9a6cb 100644
--- a/rsvg-base.c
+++ b/rsvg-base.c
@@ -1111,6 +1111,7 @@ rsvg_handle_write_impl (RsvgHandle * handle, const guchar * buf, gsize count, GE
if (handle->priv->ctxt == NULL) {
handle->priv->ctxt = xmlCreatePushParserCtxt (&rsvgSAXHandlerStruct, handle, NULL, 0,
rsvg_handle_get_base_uri (handle));
+ handle->priv->ctxt->options |= XML_PARSE_HUGE;
@cporter
cporter / addr_to_ll.py
Created March 26, 2013 01:48
A simple script demonstrating the geopy API. You can install geopy via "sudo easy_install geopy". Expected input is one address per line on stdin. Output is, tab-delimited, LAT LON PLACE.
import geopy, sys
def main():
g = geopy.geocoders.GoogleV3()
for line in sys.stdin:
addr = line.strip()
try:
place, (lat, lon) = g.geocode(addr)
print '%f\t%f\t%s' % (lat, lon, place)
except:
@cporter
cporter / remove_if.cpp
Created November 26, 2012 06:46
remove_if and vector
// -*- compile-command: "clang++ -std=gnu++0x -stdlib=libc++ -o remove_if remove_if.cpp" -*-
#include <iostream>
#include <vector>
int main (int, char **) {
std::vector<int> ints = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
// won't remove
for (auto &x : ints) {
// The following doesn't change ints at all, even though it