Skip to content

Instantly share code, notes, and snippets.

View ZevEisenberg's full-sized avatar

Zev Eisenberg ZevEisenberg

View GitHub Profile
@ZevEisenberg
ZevEisenberg / fixXcode.sh
Last active January 6, 2024 07:31
Function to fix Xcode’s code snippets library by replacing it with the one from the ZevEisenberg/ios-convenience git repo
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 December 24, 2015 12:59
Copies full log of the last git commit to the clipboard (and displays it, too)
# 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 January 20, 2014 16:56
Function to set Control-Tab and Control-Shift-Tab for Select Next Tab and Select Previous Tab in Terminal.app
#!/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 February 25, 2014 05:17
Shell script to move a folder of correctly-named image files into their respective .xcassets subfolders
#!/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 March 27, 2014 14:39
Function to take a screenshot on the currently-connected Android device and drop it on your Mac’s Desktop.
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 October 14, 2015 14:17
Functions to take a screen video recording or screenshot on the currently-connected Android device and drop it on your Mac’s Desktop.
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 April 29, 2014 20:12
Braindead stupid method to return a string representing bitmask values in a UIFontDescriptorSymbolicTraits
- (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 November 30, 2022 09:27
Reset all iOS simulators with this one weird trick
osascript -e 'tell application "iOS Simulator" to quit'
osascript -e 'tell application "Simulator" to quit'
xcrun simctl erase all
@ZevEisenberg
ZevEisenberg / Solarized Light.crtheme
Created October 14, 2014 18:13
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 January 2, 2020 12:22
Keyboard Shortcut Shell Script Magic
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