Skip to content

Instantly share code, notes, and snippets.

View jfro's full-sized avatar
🎉
Being rusty

Jeremy Knope jfro

🎉
Being rusty
View GitHub Profile

Keybase proof

I hereby claim:

  • I am jfro on github.
  • I am jfro (https://keybase.io/jfro) on keybase.
  • I have a public key whose fingerprint is B06C DA0C 453E A3E4 2749 0172 4D1E 4EC0 6B9D A115

To claim this, I am signing this object:

@jfro
jfro / Vagrantfile
Created May 15, 2015 21:19
Raspberry Pi cross-compiling Vagrant VM
# -*- mode: ruby -*-
# vi: set ft=ruby fdl=99:
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "ubuntu/trusty64"
# Create a forwarded port mapping which allows access to a specific port
@jfro
jfro / clean-old-sims.rb
Last active October 28, 2015 14:05
Deletes old simulators that have unavailable runtimes
#!/usr/bin/ruby
require 'fileutils'
require 'optparse'
options = {:verbose => false}
OptionParser.new do |opts|
opts.banner = "Usage: clean-old-sims.rb [options]\nLists old devices, deletes if -d is specified"
opts.on("-d", "--delete", "Delete old simulator devices") do |d|
@jfro
jfro / re-create-sims.rb
Created March 9, 2015 20:47
re-creates simulators stuck in "Creating" state from Xcode 6.2 update
#!/bin/env ruby
deviceTypes = {
"iPhone 4s" => "com.apple.CoreSimulator.SimDeviceType.iPhone-4s",
"iPhone 5" => "com.apple.CoreSimulator.SimDeviceType.iPhone-5",
"iPhone 5s" => "com.apple.CoreSimulator.SimDeviceType.iPhone-5s",
"iPhone 6 Plus" => "com.apple.CoreSimulator.SimDeviceType.iPhone-6-Plus",
"iPhone 6" => "com.apple.CoreSimulator.SimDeviceType.iPhone-6",
"iPad 2" => "com.apple.CoreSimulator.SimDeviceType.iPad-2",
"iPad Retina" => "com.apple.CoreSimulator.SimDeviceType.iPad-Retina",
@jfro
jfro / sim-nuke-from-orbit.rb
Last active August 29, 2015 14:16
Erase all simulators
#!/bin/env ruby
xcodes = Dir.glob("/Applications/Xcode*.app")
puts xcodes
xcodes.each do |xcode|
simctl = "#{xcode}/Contents/Developer/usr/bin/xcrun simctl"
puts "#{simctl} list"
out = %x{#{simctl} list}
out.lines.each do |line|
match = /(\s+)(.*)\s\(([\d\w]{8}-[\w\d]{4}-[\w\d]{4}-[\w\d]{4}-[\w\d]{12})\)/.match(line)
if match
@jfro
jfro / clean-sims.rb
Created November 3, 2014 21:41
Quick script to remove stale simulator device folders unused by Xcode, lists invalid devices if run without flags
#!/usr/bin/ruby
require 'fileutils'
require 'optparse'
xcodePath = %x{xcode-select -print-path}
puts "Checking simulator devices against Xcode: #{xcodePath}"
options = {}
OptionParser.new do |opts|
@jfro
jfro / schedule_service_downtime.sh
Created March 28, 2013 15:21
Fixed version of a nagios scheduled service downtime script. Handles parsing of config better, allowing spaces.
#! /bin/bash
#
# Write commands into the Nagios command file to schedule service
# downtime.
#
# Author: Kelly Cobean, Jr. <[email protected]>
#
# Based on a similar script by Sam Tilders <[email protected]>
#
# Requires:
@jfro
jfro / update-redmine.sh
Last active December 14, 2015 06:09
Untested upgrade script for Redmine, hopefully can streamline upgrading an install.
#!/bin/sh
VERSION=2.2.3
URL=http://files.rubyforge.vm.bytemark.co.uk/redmine/redmine-$VERSION.tar.gz
SITES_DIR=/home/sites
SITE=example.com
cd $SITE_DIR
curl -O $URL
@jfro
jfro / screw-utf-16.sh
Last active December 13, 2015 23:28
Converts all argument files to UTF-8 if they aren't already. Could be more flexible in future
#!/bin/sh
for sourceFile in $@
do
fromEncoding=`file --mime-encoding $sourceFile | awk '{print $2}'`
encodingCheck=${fromEncoding:0:6}
if [ $encodingCheck == "utf-16" ]; then
echo "Converting from $fromEncoding to utf-8"
tempFile="$sourceFile-temp"
# ZSH Theme - Preview: http://dl.dropbox.com/u/1552408/Screenshots/2010-04-08-oh-my-zsh.png
if [ $UID -eq 0 ]; then NCOLOR="red"; else NCOLOR="green"; fi
local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
crop_pwd() {
((MAXMID=$COLUMNS / 2)) # truncate to this value
mypath="%~"
echo -n "%$MAXMID<...<$mypath"
}