Skip to content

Instantly share code, notes, and snippets.

Avatar

Zev Eisenberg ZevEisenberg

View GitHub Profile
@ZevEisenberg
ZevEisenberg / fixXcode.sh
Last active Dec 14, 2015
Function to fix Xcode’s code snippets library by replacing it with the one from the ZevEisenberg/ios-convenience git repo
View fixXcode.sh
function fixXcode
{
pushd > /dev/null
cd
xcodepath=`xcode-select --print-path`/..
destination=$xcodepath/Frameworks/IDEKit.framework/Versions/A/Resources/SystemCodeSnippets.codesnippets
shouldRelaunchXcode=false
if [[ `osascript -e 'tell app "System Events" to count processes whose name is "Xcode"'` == 1 ]]; then
@ZevEisenberg
ZevEisenberg / glastcommit.sh
Last active Dec 24, 2015
Copies full log of the last git commit to the clipboard (and displays it, too)
View glastcommit.sh
# this is useful for lots of git-related functions
alias returnIfNotGitRepo='if isGitRepo; then; ; else echo "No repositories here."; return 1; fi'
function glastcommit
{
returnIfNotGitRepo
git show --name-only
git show --name-only | pbcopy
}
@ZevEisenberg
ZevEisenberg / fixTerminal.sh
Created Jan 20, 2014
Function to set Control-Tab and Control-Shift-Tab for Select Next Tab and Select Previous Tab in Terminal.app
View fixTerminal.sh
#!/bin/sh
# First, a function to safely add custom menu item entries to com.apple.universalaccess.plist,
# since duplicate entries in com.apple.custommenu.apps causes a crash when you open
# System Preferences and go to Keyboard -> Shortcusts
function addCustomMenuEntryIfNeeded
{
if [[ $# == 0 || $# > 1 ]]; then
echo "usage: addCustomMenuEntryIfNeeded com.company.appname"
return 1
@ZevEisenberg
ZevEisenberg / moveAssetImages.sh
Created Feb 25, 2014
Shell script to move a folder of correctly-named image files into their respective .xcassets subfolders
View moveAssetImages.sh
#!/bin/sh
function moveAssetImages
{
usage="usage: moveAssetImages /path/to/folderOfImages /path/to/Images.xcassets"
sourceDir=$1
assetsDir=$2
if [ $# != 2 ]; then
@ZevEisenberg
ZevEisenberg / gist:9808986
Created Mar 27, 2014
Function to take a screenshot on the currently-connected Android device and drop it on your Mac’s Desktop.
View gist:9808986
function androidScreenshot
{
# only do this if there is a device connected
adb shell exit 2>/dev/null
if [[ $? == 0 ]]; then
# Example filename: ~/Desktop/Android Screen 2013-09-11 12.32.16 PM.png
# perl line ending hacks from http://blog.shvetsov.com/2013/02/grab-android-screenshot-to-computer-via.html
dateString=`date +"%Y-%m-%d at %I.%M.%S %p"`
fileName="Android Screen $dateString.png"
adb shell screencap -p | perl -pe 's/\x0D\x0A/\x0A/g' > ~/Desktop/$fileName
@ZevEisenberg
ZevEisenberg / AndroidScreenRecording.sh
Last active Oct 14, 2015
Functions to take a screen video recording or screenshot on the currently-connected Android device and drop it on your Mac’s Desktop.
View AndroidScreenRecording.sh
function androidScreenshot
{
# only do this if there is a device connected
adb shell exit 2>/dev/null
if [[ $? == 0 ]]; then
# Example filename: ~/Desktop/Android Screen 2013-09-11 12.32.16 PM.png
# perl line ending hacks from http://blog.shvetsov.com/2013/02/grab-android-screenshot-to-computer-via.html
dateString=`date +"%Y-%m-%d at %I.%M.%S %p"`
fileName="Android Screen $dateString.png"
adb shell screencap -p | perl -pe 's/\x0D\x0A/\x0A/g' > ~/Desktop/$fileName
@ZevEisenberg
ZevEisenberg / gist:8442a144040a7298a85a
Created Apr 29, 2014
Braindead stupid method to return a string representing bitmask values in a UIFontDescriptorSymbolicTraits
View gist:8442a144040a7298a85a
- (NSString *)stringForTraits:(UIFontDescriptorSymbolicTraits)traits
{
NSMutableString *string = [@"traits:" mutableCopy];
if ( traits & UIFontDescriptorTraitItalic ) { [string appendString:@", UIFontDescriptorTraitItalic"];}
if ( traits & UIFontDescriptorTraitBold ) { [string appendString:@", UIFontDescriptorTraitBold"];}
if ( traits & UIFontDescriptorTraitExpanded ) { [string appendString:@", UIFontDescriptorTraitExpanded"];}
if ( traits & UIFontDescriptorTraitCondensed ) { [string appendString:@", UIFontDescriptorTraitCondensed"];}
if ( traits & UIFontDescriptorTraitMonoSpace ) { [string appendString:@", UIFontDescriptorTraitMonoSpace"];}
if ( traits & UIFontDescriptorTraitVertical ) { [string appendString:@", UIFontDescriptorTraitVertical"];}
@ZevEisenberg
ZevEisenberg / resetAllSimulators.sh
Last active Aug 11, 2020
Reset all iOS simulators with this one weird trick
View resetAllSimulators.sh
osascript -e 'tell application "iOS Simulator" to quit'
osascript -e 'tell application "Simulator" to quit'
xcrun simctl erase all
View Solarized Light.crtheme
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BackgroundColor</key>
<string>#fdf6e4</string>
<key>CharColor</key>
<string>#6c71c4</string>
<key>ClassColor</key>
<string>#29a198</string>
@ZevEisenberg
ZevEisenberg / keyboardShortcuts.sh
Last active Jan 2, 2020
Keyboard Shortcut Shell Script Magic
View keyboardShortcuts.sh
function addCustomMenuEntryIfNeeded
{
if [[ $# == 0 || $# > 1 ]]; then
echo "usage: addCustomMenuEntryIfNeeded com.company.appname"
return 1
else
local contents=`defaults read com.apple.universalaccess "com.apple.custommenu.apps"`
local grepResults=`echo $contents | grep $1`
if [[ -z $grepResults ]]; then
# does not contain app
You can’t perform that action at this time.