Skip to content

Instantly share code, notes, and snippets.

View thcipriani's full-sized avatar

Tyler Cipriani thcipriani

View GitHub Profile
@thcipriani
thcipriani / DeterministicTuringMachine.py
Created February 15, 2017 05:57
This is a Turing machine based on the example in _Understanding Computation_ by Tom Stuart ported to python.
"""
Deterministic Turing Machine
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This is a turing machine written in python. This code closely follows code from
chapter 5 of the book _Understanding Computation_ by Tom Stuart.
This is basically a Finite State Machine with a tape.
"""
@thcipriani
thcipriani / focal_length_stats.awk
Last active February 11, 2017 19:02
Quick(ish) awk script to find some stats about the focal length of pictures I've taken.
#!/usr/bin/awk -f
BEGIN {
FL_SUM = 0
FL_CUR = 0
FL_TOTAL = 0
}
{
getFocalLength($0)
@thcipriani
thcipriani / Dockerfile.1
Last active March 27, 2017 09:59
Why Dockerfiles are weird.
FROM debian:latest
MAINTAINER Tyler Cipriani <tyler@tylercipriani.com>
RUN apt-get update
RUN apt-get install -y vim-nox
RUN apt-get install -y zip
RUN apt-get install -y zathura
@thcipriani
thcipriani / streaming.php
Created February 2, 2017 16:18
CGI script that will stream files from my ~/Music directory
#!/usr/bin/env php
<?php
/*
* This is a terrible way to build a streaming server as a cgi script! It
* takes a song from a query string, checks for its existence in the
* music directory. If it exists: it plays it! Whee!
*/
define('MUSIC_PATH', '/home/thcipriani/Music/');
define('FFMPEG', '/usr/bin/ffmpeg');
#!/usr/bin/env bash
# Meant to be run in a git directory
# This gets the first 12 bytes of a .git/index file which according to the spec (https://github.com/git/git/blob/master/Documentation/technical/index-format.txt) are:
# - 4 byte signature
# - 4 byte version
# - 32-bit (4 byte) number of entries, i.e. number of files
#
# This will pass the final 32-bits off to python to unpack a NBO Long to show the number of entries
head -c 12 .git/index | tail -c 4 | ~/tmp/unsigned_long_stdin.py
@thcipriani
thcipriani / whacky-git.sh
Created December 20, 2016 16:14
A shell session that demonstrates git smudge filter triggering. The smudge filter will not be run if there is no difference between `stat(2)` output and the cached stat in git's index.
vagrant@scap-target:$ stat big1.bin
File: ‘big1.bin’
Size: 74 Blocks: 8 IO Block: 4096 regular file
Device: 58h/88d Inode: 28913 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 1000/ vagrant) Gid: ( 1000/ vagrant)
Access: 2016-12-20 16:06:36.823036152 +0000
Modify: 2016-12-20 16:06:36.771036152 +0000
Change: 2016-12-20 16:06:36.771036152 +0000
Birth: -
vagrant@scap-target:$ git ls-files --stage --debug big1.bin
@thcipriani
thcipriani / progress.sh
Last active December 22, 2021 23:40
A simple(ish) progress bar in bash
#!/usr/bin/env bash
# Fancy progress bar, in bash!
TOTAL=100
DELAY=0.1
PROGRESS=
get_progress() {
@thcipriani
thcipriani / podcasts.opml
Last active September 29, 2016 22:25
Podcasts from my squeezebox player
<?xml version="1.0" encoding="utf-8" ?>
<opml version="1.1">
<head title="Podcasts">
<expansionState></expansionState>
</head>
<body>
<outline URL="http://feeds.99percentinvisible.org/99percentinvisible" text="99% Invisible" type="link" />
<outline URL="http://www.npr.org/rss/podcast.php?id=381444908" text="Fresh Air" type="link" />
<outline URL="http://radioproject.libsyn.com/rss" text="Making Contact" type="link" />
<outline URL="http://feeds.wnyc.org/radiolab" text="Radiolab" type="link" />
@thcipriani
thcipriani / git-photo
Last active August 29, 2016 00:18
Add exif info about git-annex managed photos in git-notes under the namespace "pictures"
#!/usr/bin/env bash
set -eu
COMMAND=''
usage() {
cat<<HELP
usage: git photo <add|show|rm> <file>
HELP
@thcipriani
thcipriani / beta-scap-targets
Last active April 21, 2016 18:28
Shell script using dsh that updates the version of scap in beta cluster. This script assumes that you have dsh installed, and that it has a `beta-scap-targets` group
deployment-jobrunner01.deployment-prep.eqiad.wmflabs
deployment-mediawiki01.deployment-prep.eqiad.wmflabs
deployment-mediawiki02.deployment-prep.eqiad.wmflabs
deployment-mediawiki03.deployment-prep.eqiad.wmflabs
deployment-tmh01.deployment-prep.eqiad.wmflabs
deployment-tin.deployment-prep.eqiad.wmflabs
mira.deployment-prep.eqiad.wmflabs