Skip to content

Instantly share code, notes, and snippets.

@devdave
devdave / reloader.py
Created June 4, 2019 15:21
Slimmed down twisted compatible reloader
"""
A flask like reloader function for use with txweb
In user script it must follow the pattern
def main():
my main func that starts twisted
if __name__ == "__main__":
@devdave
devdave / background.js
Created October 16, 2018 20:34 — forked from akirattii/background.js
Message passing of Chrome Extension example
/*****************************************************************
* onMessage from the extension or tab (a content script)
*****************************************************************/
chrome.runtime.onMessage.addListener(
function(request, sender, sendResponse) {
if (request.cmd == "any command") {
sendResponse({ result: "any response from background" });
} else {
sendResponse({ result: "error", message: `Invalid 'cmd'` });
}
@devdave
devdave / notes.txt
Created September 18, 2018 19:01
Virtualenvwrapper-win post project hook to make a komodo project file.
Dislaimer
#########
I've been using Komodo IDE since the mid-90's but I AM NOT AN ACTIVE STATE EMPLOYEE. This is on your ownware with a I don't care license.
No warranty of the code is offered, read the code, and only install it if you understand what it does.
Semi-rant
#########
Pre-retirement, it was my in-house rule that all projects used virtualenv. It made it easier to `pip freeze > requirements.txt`
dependancies. Last thing I ever wanted to experience was having a "Oh my god everything is broken" call and spend an hour reverse
@devdave
devdave / namap.py
Created September 14, 2018 22:33
N America cartopy blank using Natural earth for fill in
"""
Features
--------
A demonstration of some of the built-in Natural Earth features found
in cartopy.
modified from caropy examples/features.py
"""
__tags__ = ['Lines and polygons']
@devdave
devdave / run.js
Created April 9, 2018 22:50 — forked from ChuckJHardy/run.js
Express Server for ZeroMQ, Socket.io and Angular.js
'use strict';
var express = require('express'),
app = express(),
http = require('http'),
server = http.createServer(app),
path = require('path'),
io = require('socket.io').listen(server),
fs = require('fs'),
zmq = require('zmq'),
@devdave
devdave / client.py
Created December 24, 2012 23:53
Setup a PUB/SUB 0MQ client/server over ssh.
"""
Bridge test client:
So this one's going to be a doozy.
Connect to target via SSH and then connect to target:localhost:8283(DAVE) and listen
for the time messages.
"""
@devdave
devdave / test3.rb
Created July 23, 2012 22:21
Working SA auth for Google analytics
require 'pry'
require 'rubygems'
require 'google/api_client'
passPhrase = "notasecret"
keyFile = "YOUR KEY HERE-privatekey.p12"
cID = "YOUR ID HERE.apps.googleusercontent.com"
scope = 'https://www.googleapis.com/auth/analytics.readonly'
profileID = "YOUR PROFILE ID"
email = 'YOUR_SA_ACCOUNT_EMAIL_HERE@developer.gserviceaccount.com'
@devdave
devdave / annotated_abuse.py
Last active November 6, 2017 16:27
Messing around with annotations in python3
"""
Command line output
=================================
Test with both arguments supplied
Handling call
Parameter name: always_int
Parameter name: always_str
Original position arguments: ('123',)
Original keyword arguments: {'always_str': 345}
@devdave
devdave / knownpaths.py
Created April 5, 2016 13:54 — forked from mkropat/knownpaths.py
Python wrapper around the SHGetKnownFolderPath Windows Shell function
import ctypes, sys
from ctypes import windll, wintypes
from uuid import UUID
class GUID(ctypes.Structure): # [1]
_fields_ = [
("Data1", wintypes.DWORD),
("Data2", wintypes.WORD),
("Data3", wintypes.WORD),
("Data4", wintypes.BYTE * 8)
#!/usr/bin/env python
"""
Recipe for creating and updating security groups programmatically.
"""
import collections
import boto