Skip to content

Instantly share code, notes, and snippets.


Zev Eisenberg ZevEisenberg

View GitHub Profile
ZevEisenberg /
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
function fixXcode
pushd > /dev/null
xcodepath=`xcode-select --print-path`/..
if [[ `osascript -e 'tell app "System Events" to count processes whose name is "Xcode"'` == 1 ]]; then
ZevEisenberg /
Last active Dec 24, 2015
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
git show --name-only
git show --name-only | pbcopy
ZevEisenberg /
Created Jan 20, 2014
Function to set Control-Tab and Control-Shift-Tab for Select Next Tab and Select Previous Tab in
# First, a function to safely add custom menu item entries to,
# since duplicate entries in causes a crash when you open
# System Preferences and go to Keyboard -> Shortcusts
function addCustomMenuEntryIfNeeded
if [[ $# == 0 || $# > 1 ]]; then
echo "usage: addCustomMenuEntryIfNeeded"
return 1
ZevEisenberg / NS Prefix Finder.txt
Created Mar 30, 2017
Regex for finding NS prefixes in code migrated to Swift 3
View NS Prefix Finder.txt
ZevEisenberg /
Created Jul 22, 2017
Functions to copy versions of Xcode, browsers, and macOS
function copySafariVersion
local safariVersion=$(defaults read /Applications/ CFBundleShortVersionString)
local safariBuild=$(defaults read /Applications/ CFBundleVersion)
local macOSVersion=$(sw_vers -productVersion)
local macOSBuild=$(sw_vers -buildVersion)
local fullString="Safari ${safariVersion} (${safariBuild}) on macOS ${macOSVersion} (${macOSBuild})"
echo "Copied \"$fullString\""
echo -n $fullString | pbcopy
ZevEisenberg / apple-dev.zsh
Created Jul 22, 2017
Utility functions for doing iOS and Mac development
View apple-dev.zsh
# cd to the folder containing an Xcode project dragged from an Xcode window's proxy icon. If no file is provided, cd to the folder containing the current Xcode project
function xc
if [[ `osascript -e 'tell app "System Events" to count processes whose name is "Xcode"'` == 1 ]]; then
if [[ $xcodeIsRunning == false ]]; then
echo "Xcode is not open. I don’t know what you want from me."
View SectionedArray.swift
struct SectionedArray<GroupKey, Item> where GroupKey: Comparable & Hashable {
struct Section {
let key: GroupKey
var items: [Item]
var sections: [Section]
var count: Int {
ZevEisenberg / guard.swift
Created Jul 31, 2018
Example Guard indentation
View guard.swift
let foo: Int? = nil
let bar: Int? = nil
let baz: Int? = nil
func x() {
let foo = foo,
let bar = bar,
let baz = baz
else { return }
ZevEisenberg / Dictionary+Utilities.swift
Created Nov 29, 2017
Convert a dictionary’s keys from NSAttributedStringKey to String
View Dictionary+Utilities.swift
extension Dictionary where Key == NSAttributedStringKey {
var withStringKeys: [String: Value] {
return reduce(into: [:], {
$0[$1.key.rawValue] = $1.value
You can’t perform that action at this time.