Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am pgriess on github.
  • I am pgriess (https://keybase.io/pgriess) on keybase.
  • I have a public key ASBcs2YU4XH8ij0TCnDmI2hrOVzK4servJktXguDxmLwzAo

To claim this, I am signing this object:

@pgriess
pgriess / index.js
Last active July 8, 2019 18:27
AcceptContentNegotiation
'use strict';
const {
ValueTuple,
awsPerformEncodingNegotiation,
awsPerformTypeNegotiation } = require('http_content_negotiation');
const SERVER_ENCODINGS = [
new ValueTuple('br', new Map([['q', 1]])),
new ValueTuple('gzip', new Map([['q', 0.9]])),
@pgriess
pgriess / origin-request.js
Last active September 14, 2018 18:50
Content negotiation with AWS Lambda@Edge
/*
MIT License
Copyright (c) 2018 Peter Griess
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
def aws4_signature_parts(...):
...
def aws_route53(aws_key, aws_key_secret, path, data=None):
url = 'https://route53.amazonaws.com/2013-04-01/{}'.format(path)
_, _, headers = aws4_signature_parts(
aws_key,
aws_key_secret,
'GET' if data is None else 'POST',
url,
@pgriess
pgriess / aws-route53-zones.sh
Last active February 20, 2017 17:45
Use aws4sign.py to list AWS Route53 zones
# AWS keys
export AWS_ACCESS_KEY_ID=...
export AWS_SECRET_ACCESS_KEY=...
# Inputs to the signature algorithm; must be immutable
#
# The $now parameter in particular is interesting. The AWS signature algorithm
# includes the current time, which we pass to aws4sign.py using the -t option.
now=$(date '+%s')
url=https://route53.amazonaws.com/2013-04-01/hostedzone
@pgriess
pgriess / gist:7046324
Created October 18, 2013 18:54
Patch to get gtest-1.6.0 building against Mac OS X / libc++.
diff -ur gtest-1.6.0-PRISTINE/fused-src/gtest/gtest.h gtest-1.6.0/fused-src/gtest/gtest.h
--- gtest-1.6.0-PRISTINE/fused-src/gtest/gtest.h 2011-04-15 14:54:57.000000000 -0500
+++ gtest-1.6.0/fused-src/gtest/gtest.h 2013-10-18 13:50:34.000000000 -0500
@@ -544,7 +544,7 @@
// defining __GNUC__ and friends, but cannot compile GCC's tuple
// implementation. MSVC 2008 (9.0) provides TR1 tuple in a 323 MB
// Feature Pack download, which we cannot assume the user has.
-# if (defined(__GNUC__) && !defined(__CUDACC__) && (GTEST_GCC_VER_ >= 40000)) \
+# if (defined(__GNUC__) && !defined(__CUDACC__) && !defined(_LIBCPP_VERSION) && (GTEST_GCC_VER_ >= 40000)) \
|| _MSC_VER >= 1600
@pgriess
pgriess / gist:7045204
Last active December 25, 2015 21:49
Patch to get double_conversion building a library.
diff -ur double-conversion-PRISTINE/SConstruct double-conversion/SConstruct
--- double-conversion-PRISTINE/SConstruct 2012-06-10 13:25:57.000000000 -0500
+++ double-conversion/SConstruct 2013-10-18 13:25:36.000000000 -0500
@@ -1,14 +1,28 @@
+import os
+import os.path
+
double_conversion_sources = ['src/' + x for x in SConscript('src/SConscript')]
double_conversion_test_sources = ['test/cctest/' + x for x in SConscript('test/cctest/SConscript')]
-test = double_conversion_sources + double_conversion_test_sources
@pgriess
pgriess / gist:7045080
Created October 18, 2013 17:36
Patch for boost-1_54_0 to build with clang++ on Xcode.
diff -ur boost_1_54_0-PRISTINE/tools/build/v2/user-config.jam boost_1_54_0/tools/build/v2/user-config.jam
--- boost_1_54_0-PRISTINE/tools/build/v2/user-config.jam 2011-01-25 12:06:12.000000000 -0600
+++ boost_1_54_0/tools/build/v2/user-config.jam 2013-10-18 10:57:15.000000000 -0500
@@ -90,3 +90,10 @@
# Configure specific Python version.
# using python : 3.1 : /usr/bin/python3 : /usr/include/python3.1 : /usr/lib ;
+#
+
+# ---------------------
@pgriess
pgriess / gist:7044785
Last active December 25, 2015 21:48
Patch for glog-0.3.3 to build against libc++.
diff -ur glog-0.3.3-PRISTINE/src/glog/stl_logging.h.in glog-0.3.3/src/glog/stl_logging.h.in
--- glog-0.3.3-PRISTINE/src/glog/stl_logging.h.in 2013-01-09 07:57:36.000000000 -0600
+++ glog-0.3.3/src/glog/stl_logging.h.in 2013-10-18 12:15:28.000000000 -0500
@@ -53,7 +53,9 @@
#ifdef __GNUC__
# include <ext/hash_set>
# include <ext/hash_map>
-# include <ext/slist>
+#ifdef __GLIBCXX__
+# include <ext/slist>
@pgriess
pgriess / demo.py
Created December 19, 2011 01:12
Script to stream audio from Rdio
#!/bin/env python
#
# Demo tool to generate the rtmpdump(1) command for streaming a song from Rdio.
import httplib
from optparse import OptionParser
from os.path import basename
from pprint import pprint
from pyamf.remoting.client import RemotingService
from rdioapi import Rdio