Skip to content

Instantly share code, notes, and snippets.

View logston's full-sized avatar
🥑
Hmm, I wonder...

Paul Logston logston

🥑
Hmm, I wonder...
View GitHub Profile
@logston
logston / keybase.md
Created October 22, 2014 03:46
keybase.md

Keybase proof

I hereby claim:

  • I am logston on github.
  • I am logston (https://keybase.io/logston) on keybase.
  • I have a public key whose fingerprint is 7B4D DD18 4387 9904 3D51 C67B 535E 985C 4B2A B0E1

To claim this, I am signing this object:

@logston
logston / get_links.py
Created May 23, 2015 20:43
Python Office Hours 2015-05-23
#!/bin/sh
#
# /etc/init.d/kibana4 -- startup script for kibana4
# bsmith@the408.com 2015-02-20; used elasticsearch init script as template
# https://github.com/akabdog/scripts/edit/master/kibana4_init
#
### BEGIN INIT INFO
# Provides: kibana4
# Required-Start: $network $remote_fs $named
# Required-Stop: $network $remote_fs $named
@logston
logston / multi1.py
Last active March 26, 2016 17:34
Does multiprocessing copy modules or does it share state with the other processes?
"""
Does multiprocessing copy modules or does it share state
with the other processes. I'm almost 100% sure it copies
the state, but why not try an experiment to find out.
"""
import multiprocessing
import sys
def get_sys_module_ids(conn):
@logston
logston / multi2.py
Last active March 26, 2016 17:38
Wait, really? Can you share state between processes?
"""
Can you share state between processes my updating sys.modules?
"""
import multiprocessing
import sys
import time
def change_state():
print('Before change', id(sys.modules))
I didn't expect the decorated version to execute as fast as it did. Only twice the duration as the "normal" version!
@logston
logston / ping_to_influx.ino
Created April 10, 2016 20:04
My Arduino Sketch for recording ping times to influx db
#include <SPI.h>
#include <Ethernet.h>
#include <ICMPPing.h>
/*
* CONSTANTS
*/
// ICMPPing CONSTANTNS
byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED}; // max address for ethernet shield
@logston
logston / patch_migration_executor.py
Last active May 5, 2016 17:57
A patch for Django 1.8.12's migration executor.
def patch_migration_executor():
from django.db.migrations import executor
from django.db.migrations.state import ProjectState
class InvalidMigrationPlan(ValueError):
pass
class PatchedMigrationExecutor(executor.MigrationExecutor):
"""
End-to-end migration execution - loads migrations, and runs them
import glob
import json
import os
import sys
DATA_DIR = 'data'
subdirname = sys.argv[1]
pattern = '{}/{}/**/*.json'.format(DATA_DIR, subdirname)
@logston
logston / loops_in_threads_in_processes.py
Last active July 21, 2016 01:21
A process pool that spins up thread pools that spins up asyncio loops.
"""
A process pool that spins up thread pools that spins up asyncio loops.
"""
import asyncio
from concurrent.futures import ProcessPoolExecutor, ThreadPoolExecutor, wait
import random
PROCESS_WORKERS = 2
THREAD_WORKERS = 2