Skip to content

Instantly share code, notes, and snippets.

@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++
@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 / 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 / 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 / CFBundleVersion.py
Created December 2, 2013 23:16
Given a list of Mac OS X Applications, print out their names and version numbers.
import os
import plistlib
import argparse
class CFBundle:
def __init__(self, path, kind='path'):
self.name = False
self.version = False
@jpf
jpf / hangup-and-text.xml
Last active December 21, 2015 08:09
TwiML that will answer a call, read a message saying to text instead, and also send a text message.
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Say>Hello. I don't answer voice calls, please text me instead.</Say>
<Pause length="2"/>
<Hangup/>
<Sms>Trying to get ahold of me? Reply to this text!</Sms>
</Response>
@jpf
jpf / filegenerator.py
Created June 20, 2013 09:03
I'm using this code to stream a file from Flask as that file is being written.
from Queue import Queue
from time import sleep
import threading
class FileGenerator(object):
def __init__(self):
self.q = Queue()
def read_generator(self):
mkdir archiveteam
cd archiveteam/
sudo apt-get update
sudo apt-get install libssl0.9.8 libssl-dev lua5.1 liblua5.1-0-dev
sudo apt-get install build-essential git-core
git clone http://github.com/ArchiveTeam/posterous-grab.git
cd posterous-grab
git clone http://github.com/ArchiveTeam/seesaw-kit
cd seesaw-kit
sudo apt-get install python-pip
$ curl -vv https://jf.posterous.com/
* About to connect() to jf.posterous.com port 443 (#0)
* Trying 184.106.20.99... Connection timed out
* couldn't connect to host
* Closing connection #0
curl: (7) couldn't connect to host
@jpf
jpf / app.py
Created January 11, 2013 21:55
A slightly more complete Python/Flask to send a URL in an SMS.
import os
from twilio.rest import TwilioRestClient
from flask import Flask, request, render_template
app = Flask(__name__)
# TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN environment variables must be set
client = TwilioRestClient()
@app.route("/", methods=['POST', 'GET'])
def index():