Skip to content

Instantly share code, notes, and snippets.

@jpf
jpf / statelatch.py
Created March 1, 2014 21:35
A class with a method that can only be assigned a specific number of times
class StateLatch(object):
def __init__(self, changes_until_latched=2):
self._state = None
self.latch_count = changes_until_latched
@property
def state(self):
return self._state
@state.setter
@jpf
jpf / gist:9479205
Created March 11, 2014 03:52
keybase.md
### Keybase proof
I hereby claim:
* I am jpf on github.
* I am jfranusic (https://keybase.io/jfranusic) on keybase.
* I have a public key whose fingerprint is 535A 06B0 6A4A CE7C D80C CEA2 60C5 039A 605A A1DA
To claim this, I am signing this object:
@jpf
jpf / defaults-watcher.py
Created April 18, 2014 17:53
Monitors and displays changes made to system preferences on Mac OS X
import time
import subprocess
import re
import collections
class NSPlistParser():
'''Thanks to @rndmcnlly for writing this!'''
def __init__(self):
# these will all get interpreted as raw literal values in the parser
@jpf
jpf / fib.s
Last active August 29, 2015 14:00
This is a program written in AUTOCODER for the IBM 1401. It prints the first 10 numbers in the Fibonacci sequence.
A DCW @001@ * VARIABLE "A"
B DCW @001@ * VARIABLE "B"
C DCW @000@ * VARIABLE "C"
COUNT DCW @000@ * VARIABLE "COUNT"
START MCS A,201+3 * MOVE A VARIABLE TO PRINT BUFFER
W * PRINT
LOOP BCE DONE,COUNT-1,1 * WHILE COUNT < 10
MCS B,201+3 * MOVE B VARIABLE TO PRINT BUFFER
W * PRINT
A @1@,COUNT * COUNT++
# * * * * * command to be executed
# - - - - -
# | | | | |
# | | | | +- - - - day of week (0 - 6) (Sunday=0)
# | | | +- - - - - month (1 - 12)
# | | +- - - - - - day of month (1 - 31)
# | +- - - - - - - hour (0 - 23)
# +- - - - - - - - minute (0 - 59)
@jpf
jpf / okta_openvpn.py
Created April 30, 2015 20:19
Okta OpenVPN, using pyca/cryptography instead of M2Crypto
#!/usr/bin/env python2
# vim: set noexpandtab:ts=4
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
# Contributors: gdestuynder@mozilla.com
import ConfigParser
import base64
@jpf
jpf / okta-words.txt
Created June 29, 2015 18:39
cat /usr/share/dict/words | egrep -i '^octa' | sed 's/cta/kta/g'
oktachloride
oktachord
oktachordal
oktachronous
Oktacnemus
oktacolic
oktactinal
oktactine
Oktactiniae
oktactinian
@jpf
jpf / welcome.py
Created August 20, 2015 01:58
The code I used for my welcome message at the sfpython "Project Night at Okta" event
import os
import time
import okta
# Get your very own Okta organization at: http://developer.okta.com
client = okta.AuthClient("https://example.okta.com",
"your-api-token")
#rsyslog SERVER
# Activate kernel logging
$ModLoad imklog
# Activate TCP logging
$ModLoad imtcp
# Activate UDP logging
$ModLoad imudp
# Activate unix socket logging (used by syslog(3) system calls)
$ModLoad imuxsock
# Activate the 'ommail' module, used to forward messages via SMTP
# How to override DNS on Mac OS X 10.5
sudo dscl localhost -create /Local/Default/Hosts/site.dom IPAddress 127.0.0.1