Skip to content

Instantly share code, notes, and snippets.

View tkcranny's full-sized avatar

Thomas Cranny tkcranny

  • Brisbane, Australia
View GitHub Profile
@tkcranny
tkcranny / desktop.py
Created June 6, 2013 11:21
Simple script to retreive the highest rated (1080p) image from reddit.com/r/wallpapers and apply it as the windows desktop image.
import urllib2, ctypes
import os, re
from time import sleep
__author__ = "Thomas Cranny"
__version__ = "1.0"
def CheckConnection(checks=5*60, delay=1):
for i in range(checks):
try:
echo -e "\e[36m================================================================================"
echo -e "\e[35mWarnings:\e[33m"
gcc -Wall -ansi -pedantic thebox.c -o thebox
echo -e "\e[35mCompilation Complete\e[33m"
echo -e "\e[36m================================================================================\e[0m"
@tkcranny
tkcranny / Open in iTerm.workflow
Last active August 29, 2019 05:09
macOS Sierra Automater service to open iTerm2 from a finder window
-- Adapted from these sources:
-- http://peterdowns.com/posts/open-iterm-finder-service.html
-- https://gist.github.com/cowboy/905546
-- https://gist.github.com/ttimasdf/7bb02ed419db4b472b534e1a57008a3b
--
-- Modified to work with files as well, cd-ing to their container folder
on run {input, parameters}
tell application "Finder"
set my_file to first item of input
set is_folder to (do shell script "file -b " & quoted form of (POSIX path of my_file))
@tkcranny
tkcranny / check_output_concurrent.py
Last active November 27, 2017 06:03
Simple script to run a shell command multiple times very quickly and concurrently, and report on the failure rate.
#!/usr/bin/env python
"""
Simple script to run a shell command repeatedly using concurrent
subprocesses. Shows a pretty progress bar, and prints a percentage of
times the command failed.
Took a ~20 minute sequence of `npm run test` to under 2 minutes.
"""