Skip to content

Instantly share code, notes, and snippets.

@frowing
frowing / ListFonts.m
Last active August 29, 2015 14:25
List All Fonts on iOS
NSArray *familyNames = [[NSArray alloc] initWithArray:[UIFont familyNames]];
NSArray *fontNames;
NSInteger familyIndex, fontIndex;
for (familyIndex = 0; familyIndex < [familyNames count]; ++ familyIndex) {
NSLog(@"Family name: %@", [familyNames objectAtIndex:familyIndex]);
fontNames = [[NSArray alloc] initWithArray:[UIFont fontNamesForFamilyName:
[familyNames objectAtIndex:familyIndex]]];
for (fontIndex = 0; fontIndex < [fontNames count]; ++ fontIndex) {
NSLog(@" Font name: %@", [fontNames objectAtIndex:fontIndex]);
}
@frowing
frowing / gist:8575251
Last active January 12, 2017 10:58
Remove Caches and Preferences directory on the latest used Simulator app so it gets rebooted to its initial state.
#!/bin/bash
simulatorDirectory="$HOME/Library/Developer/CoreSimulator/Devices"
latestSimulator=$(ls -Ft "$simulatorDirectory"| grep / | head -1)
applicationsDirectory="$simulatorDirectory""/""$latestSimulator/Applications/"
latestApp=$(ls -t "$applicationsDirectory" | head -1)
appDirectory="$applicationsDirectory""/""$latestApp"
libraryDirectory="$appDirectory/Library"
prefDir="$libraryDirectory/Preferences"
cachesDirectory="$libraryDirectory/Caches"
@frowing
frowing / gist:8565112
Created January 22, 2014 19:02
Open in finder last app executed in the iOS Simulator
simulatorDirectory="$HOME/Library/Application Support/iPhone Simulator"
latestSimulator=$(ls -t "$simulatorDirectory" | head -1)
applicationsDirectory="$simulatorDirectory""/""$latestSimulator/Applications/"
latestApp=$(ls -t "$applicationsDirectory" | head -1)
appDirectory="$applicationsDirectory""/""$latestApp"
open "$appDirectory"
@frowing
frowing / gist:8562420
Created January 22, 2014 16:54
Converts HEX to RGB
#!/bin/sh
# hextorgb.sh
hexinput=`echo $1 | tr '[:lower:]' '[:upper:]'` #uppercaseing
a=`echo $hexinput | cut -c-2`
b=`echo $hexinput | cut -c3-4`
c=`echo $hexinput | cut -c5-6`
r=`echo "ibase=16; $a" | bc`
g=`echo "ibase=16; $b" | bc`
b=`echo "ibase=16; $c" | bc`
@frowing
frowing / hack.sh
Created December 6, 2012 06:45 — forked from amrox/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/3999124/hack.sh | sh
#