Skip to content

Instantly share code, notes, and snippets.

View stenius's full-sized avatar

Paul Stenius stenius

View GitHub Profile
@stenius
stenius / gist:1013163
Created June 7, 2011 21:05
AJAX JQuery table editor
('table#bal_out tr').delegate('td','click', (function(){
cell = jQuery(this);
row = $(this).closest('tr');
oldValue = cell.html();
rowId = jQuery(row).attr('id');
headerId= cell.closest('table').find('th').eq(cell.index()).attr('id');
if (oldValue.indexOf('button') == -1)
@stenius
stenius / rfid.py
Created January 20, 2013 00:05
Basic loop for reading RFID tags. Filters out unwanted characters and ignores reads that happen back to back.
import serial
import datetime
ser = serial.Serial('/dev/ttyUSB0', 2400, timeout=1)
count = 0
read_time = datetime.datetime.now()
last_read = 'asdfasdf' #trash string so initial comparison fails
while True:
line = ser.readline()
if len(line) > 1:

Keybase proof

I hereby claim:

  • I am stenius on github.
  • I am griff (https://keybase.io/griff) on keybase.
  • I have a public key whose fingerprint is 5A4B 76AD E362 F047 2E18 A4EC 39D2 F995 B462 0197

To claim this, I am signing this object:

@stenius
stenius / outbound_open_ports.py
Created April 27, 2015 18:49
outbound port scan of common ports using portquiz.net
import requests
for x in [80, 443, 22, 21, 8080, 25, 4567, 1723, 53, 23, 3389, 110, 135, 143,
5000, 8081, 445, 139, 10000, 1863, 111, 1025, 81, 1026, 8000, 1027, 5060,
1028, 1029, 7676, 389, 1050, 113, 1024, 587, 30005, 20, 4444, 37, 27374,
5678, 56789, 1002, 18067, 30722, 554, 4664, 8594, 29860, 4]:
try:
r = requests.get('http://portquiz.net:%s' % x, timeout=5)
except requests.exceptions.Timeout:
continue
class Node:
def __init__(self, value, parent):
self.value = value
self.parent = parent
def ancestors(node):
# return all parent nodes including this node
ancestor_nodes = []
ancestor_nodes.append(node)
parent = node.parent
# check depth of keys
#
a = {
'key1': 1,
'key2': {
'key3': 1,
'key4': {
'key5': 4
}
}
@stenius
stenius / ses_lambda_forward.py
Last active February 22, 2021 18:34
AWS Lambda function for forwarding inbound emails from SES and sending outbound with SES
import json
import boto3
import os
from __future__ import print_function
from email.parser import Parser
os.environ['AWS_DEFAULT_REGION'] = 'us-east-1'
# this is the email address you want the inbound mail forwarded to
@stenius
stenius / mpd_client.py
Last active March 12, 2016 02:33
Hey Athena MPD Module
from athena.classes.module import Module
from athena.classes.task import ActiveTask
from athena.apis import api_lib
from mpd import MPDClient
client = MPDClient()
client.connect("192.168.0.150", 6600)
class PauseSongTask(ActiveTask):
def __init__(self):
@stenius
stenius / solr.sls
Created March 17, 2016 04:41
salt solr install state
debconf-utils:
pkg.installed
base:
pkgrepo.managed:
- humanname: Unoffical Java PPA
- name: deb http://ppa.launchpad.net/webupd8team/java/ubuntu precise main
- dist: precise
- file: /etc/apt/sources.list.d/java.list
- keyid: EEA14886
@stenius
stenius / client.sls
Last active April 11, 2016 20:57
Salt Stack state file for setting up a Consul agent that binds to a VPN tunnel
/etc/consul.d:
file.directory:
- user: root
- group: adm
- mode: 0755
/etc/consul.d/client:
file.directory:
- user: root
- group: adm