Skip to content

Instantly share code, notes, and snippets.

Kristopher Johnson kristopherjohnson

View GitHub Profile
@kristopherjohnson
kristopherjohnson / make-ios-app-icon.sh
Last active Apr 22, 2019
Script for generating iOS app icons in all necessary sizes
View make-ios-app-icon.sh
#!/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 Sep 8, 2018
Simple Swift logging functions
View log.swift
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 Aug 12, 2018
Delete all tweets that are listed in a tweets.csv archive that are over 90 days old
View delete_archived_tweets.py
#!/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 Aug 5, 2018
Delete all tweets older than 90 days
View deletetweets.py
#!/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 Sep 19, 2017
AWK script that gets certificate expiration info from PEM-format certificate data
View cert_expire.awk
#!/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 Mar 2, 2018
Unblock all blocked Twitter accounts
View unblock_all.py
#!/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 Jul 30, 2017
Bash script that downloads the source to Donald Knuth's "TeX: The Program" and builds a PDF
View maketexprogram.sh
#!/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 Jun 15, 2018
Python 3 program to convert Roman numerals to integer values
View rn.py
#!/usr/bin/env python3
import sys
letterValues = {
'M': 1000,
'D': 500,
'C': 100,
'L': 50,
'X': 10,
@kristopherjohnson
kristopherjohnson / Makefile
Last active Oct 11, 2018
C program to convert Roman numerals to integer values
View Makefile
rn: rn.c
test: rn
./rn I IV V VI IX X XI XIV XIX XCIX CI MCMLXVII MD MDC MCD MM
.PHONY: test
@kristopherjohnson
kristopherjohnson / IfElse.swift
Last active Apr 19, 2019
Implement "If", "Else", and "ElseIf" in Swift
View IfElse.swift
// Implementation of If, ElseIf, and Else in Swift.
//
// Supports uses such as these:
//
// If (condition) { doAction() }
//
// If (condition) { doAction() }
// .Else { doOtherAction() }
//
// If (condition) { doAction() }
You can’t perform that action at this time.