Skip to content

Instantly share code, notes, and snippets.

View kristopherjohnson's full-sized avatar
💭
Huh?

Kristopher Johnson kristopherjohnson

💭
Huh?
View GitHub Profile
@kristopherjohnson
kristopherjohnson / Unfollow_Quiet_Accounts.ipynb
Created September 7, 2019 19:13
Python script to unfollow Twitter accounts that have not tweeted in the last 400 days
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kristopherjohnson
kristopherjohnson / lunar.rs
Last active August 15, 2020 19:23
Translation of classic Lunar Lander game from FOCAL to Rust
//! Translation of
//! <http://www.cs.brandeis.edu/~storer/LunarLander/LunarLander/LunarLanderListing.jpg>
//! by Jim Storer from FOCAL to Rust.
use std::error::Error;
use std::io;
use std::io::prelude::*;
use std::marker::{Send, Sync};
use std::process;
use std::str::FromStr;
@kristopherjohnson
kristopherjohnson / make-ios-app-icon.sh
Last active February 3, 2020 15:09
Script for generating iOS app icons in all necessary sizes
#!/bin/bash
#
# Given a source image, create icons in all sizes needed for an iOS app icon.
# See <https://developer.apple.com/library/ios/qa/qa1686/_index.html> for details.
#
# First (required) argument is path to source file.
#
# Second (optional) argument is the prefix to be used for the output files.
# If not specified, defaults to "Icon-".
#
@kristopherjohnson
kristopherjohnson / log.swift
Last active September 8, 2018 21:24
Simple Swift logging functions
import Foundation
extension String {
/// Return last path component.
public var lastPathComponent: String {
return (self as NSString).lastPathComponent
}
}
/// Write a message to the system log.
@kristopherjohnson
kristopherjohnson / delete_archived_tweets.py
Last active August 12, 2018 01:46
Delete all tweets that are listed in a tweets.csv archive that are over 90 days old
#!/usr/bin/env python
"""Deletes all tweets in your 'tweets.csv' archive older than 90 days.
You can obtain your 'tweets.csv' archive by going to
<https://twitter.com/settings/account>, requesting your archive,
downloading it, and then extracting the 'tweets.csv' file.
"""
from __future__ import print_function
@kristopherjohnson
kristopherjohnson / deletetweets.py
Last active February 9, 2022 14:13
Delete all tweets older than 90 days
#!/usr/bin/env python
"""Deletes all tweets older than 90 days.
"""
from __future__ import print_function
# Dependencies: pip install twitter python-dateutil
import twitter
import dateutil.parser
@kristopherjohnson
kristopherjohnson / cert_expire.awk
Last active May 13, 2022 23:44
AWK script that gets certificate expiration info from PEM-format certificate data
#!/usr/bin/env awk -f
# Processes PEM output to print certificate expiration information.
#
# Example: Print expiration dates for all certificates on macOS
#
# security find-certificate -a -p | awk -f cert_expire.awk
#
# Example: Print expiration dates for all "iPhone Developer" certificates on macOS
#
@kristopherjohnson
kristopherjohnson / unblock_all.py
Last active May 4, 2023 13:03
Unblock all blocked Twitter accounts
#!/usr/bin/env python3
# Dependency: pip3 install twitter
import twitter
# Go to http://apps.twitter.com/, create an app, and fill in these values:
consumer_key = 'www'
consumer_secret = 'xxx'
access_token = 'yyy'
access_token_secret = 'zzz'
@kristopherjohnson
kristopherjohnson / maketexprogram.sh
Created July 30, 2017 14:13
Bash script that downloads the source to Donald Knuth's "TeX: The Program" and builds a PDF
#!/bin/bash
# This script downloads the source to Donald Knuth's "TeX: The Program"
# and builds a PDF.
#
# Requires curl and a TeX distribution.
curl http://tug.org/texlive/devsrc/Build/source/texk/web2c/tex.web -o tex.web
weave tex.web
tex tex.tex
@kristopherjohnson
kristopherjohnson / rn.py
Last active May 13, 2022 23:45
Python 3 program to convert Roman numerals to integer values
#!/usr/bin/env python3
import sys
letterValues = {
'M': 1000,
'D': 500,
'C': 100,
'L': 50,
'X': 10,