Skip to content

Instantly share code, notes, and snippets.

View ptone's full-sized avatar

Preston Holmes ptone

View GitHub Profile
@ptone
ptone / idle.sh
Created July 8, 2019 16:10 — forked from ikbear/idle.sh
Docker image entrypoint idle script
#!/bin/bash
echo "This is a idle script (infinite loop) to keep container running."
echo "Please replace this script."
cleanup ()
{
kill -s SIGTERM $!
exit 0
}
@ptone
ptone / exmaple.go
Last active June 17, 2019 23:43 — forked from wlhee/exmaple.go
Generate Open ID Token Connect with Google Service Account Key
package main
import (
"context"
"flag"
"fmt"
"io/ioutil"
"log"
"net/http"
@ptone
ptone / gist:4271278
Created December 12, 2012 20:27
Problem trying to run notebook with extra static paths
(notebook)element:nbcast$ ipython notebook --NotebookApp.extra_static_paths="['./profile_nbcast/static/']"
Traceback (most recent call last):
File "/Users/preston/Projects/Python/virtualenvs/notebook/bin/ipython", line 9, in <module>
load_entry_point('ipython==0.14.dev', 'console_scripts', 'ipython')()
File "/Users/preston/UNIX/src/ipython/IPython/frontend/terminal/ipapp.py", line 388, in launch_new_instance
app.initialize()
File "<string>", line 2, in initialize
File "/Users/preston/UNIX/src/ipython/IPython/config/application.py", line 84, in catch_config_error
return method(app, *args, **kwargs)
File "/Users/preston/UNIX/src/ipython/IPython/frontend/terminal/ipapp.py", line 313, in initialize
# Create pubsub topics for cron regular tasks
gcloud pubsub topics create cron-minute
gcloud pubsub topics create cron-hour
gcloud pubsub topics create cron-day
# Create minute, hour, daily heartbeat events
gcloud alpha scheduler jobs create pubsub minute-task --topic cron-minute --schedule="* * * * *" --message-body="OK"
gcloud alpha scheduler jobs create pubsub hour-task --topic cron-hour --schedule="0 * * * *" --message-body="OK"
gcloud alpha scheduler jobs create pubsub day-task --topic cron-day --schedule="0 2 * * *" --message-body="OK"
@ptone
ptone / aead.py
Created December 27, 2018 19:13
chachapoly interop sanity check
from cryptography.hazmat.primitives.ciphers.aead import ChaCha20Poly1305
data = b"secret"
data = bytes([0x01,0x01,0x01,0x01,0x01,0x01])
aad = b"1111111111111111"
aad = bytes([0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01])
nonce = b"111111111111" # os.urandom(12)
nonce = bytes([0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01])
test_key = ChaCha20Poly1305.generate_key()
key = bytes([0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18,
@ptone
ptone / gist:1246480
Created September 27, 2011 22:47
potential layout

ArchiveIndexView

Properties (with optional accessor):

allow_empty = True (django.views.generic.list.MultipleObjectMixin)

@ptone
ptone / hue-lutron.go
Created January 6, 2017 17:49
Mirroring Hue lights by watching Lutron integration local-hub
package main
import (
"log"
"github.com/heatxsink/go-hue/groups"
"github.com/heatxsink/go-hue/lights"
"github.com/heatxsink/go-hue/portal"
lutronlib "github.com/ptone/go-lutron"
)
@ptone
ptone / opentracing-zipkin.md
Created December 23, 2016 01:41 — forked from codefromthecrypt/opentracing-zipkin.md
My ramble on OpenTracing (with a side of Zipkin)

I've had many people ask me questions about OpenTracing, often in relation to OpenZipkin. I've seen assertions about how it is vendor neutral and is the lock-in cure. This post is not a sanctioned, polished or otherwise muted view, rather what I personally think about what it is and is not, and what it helps and does not help with. Scroll to the very end if this is too long. Feel free to add a comment if I made any factual mistakes or you just want to add a comment.

So, what is OpenTracing?

OpenTracing is documentation and library interfaces for distributed tracing instrumentation. To be "OpenTracing" requires bundling its interfaces in your work, so that others can use it to time distributed operations with the same library.

So, who is it for?

OpenTracing interfaces are targeted to authors of instrumentation libraries, and those who want to collaborate with traces created by them. Ex something started a trace somewhere and I add a notable event to that trace. Structure logging was recently added to O

@ptone
ptone / gist:6437039
Last active December 22, 2015 07:19
Pycon 2014 talk proposal. I'm open to any and all feedback. Would you be interested in this talk? Are you more interested in the generalizations, or the specifics? What do you think would make this talk more interesting to an even broader pycon audience?

Blending art, technology, and light. Designing Birdfish, an expressive Python Library for interactive and real time LED installations

Category

Other

Python Level

Intermediate

@ptone
ptone / index.html
Created June 27, 2013 15:33
recording keypresses with browser & websockets uses: https://github.com/aaugustin/websockets
<html>
<head>
<title>key press test</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
</head>
<body>
<h1>Press keys...</h1>
WebSocket status : <span id="message"></span>
<script>
var ws = new WebSocket('ws://127.0.0.1:8866/');