Skip to content

Instantly share code, notes, and snippets.

Zev Eisenberg ZevEisenberg

Block or report user

Report or block ZevEisenberg

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@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 / 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"];}
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 / gist:d29476094201e4076c03
Last active Aug 29, 2015
Localized Hours Range String
View gist:d29476094201e4076c03
NSDateComponents *comps = [[NSDateComponents alloc] init];
comps.year = 2015;
comps.month = 5;
comps.day = 12;
comps.hour = 21;
NSDate *startDate = [[NSCalendar currentCalendar] dateFromComponents:comps];
comps.day = 13;
comps.hour = 0;
@ZevEisenberg
ZevEisenberg / Ad Blocker Comparisons.md
Last active Aug 29, 2015
Unscientific Ad Blocker Comparisons
View Ad Blocker Comparisons.md

Safari tests run on a Mac mini late 2012, 2.6 GHz Core i7, 16 GB RAM. Didn't bother to reboot or disable these other extensions, so the test is less than scientific:

  • Fireballed
  • ExifExt
  • TinEye
  • Instapaper
  • Smile
  • 1Password (beta)

If you visit any of these URLs, there is a text field where you can paste any other of these URLs to see a comparison report

@ZevEisenberg
ZevEisenberg / gist:d95cde83055f6c707050
Created Jul 10, 2015
Function to open the GitHub page of the current repo
View gist:d95cde83055f6c707050
function gh
{
local remoteURL=`git remote -v | grep fetch | awk -F ' ' '{print $2}'`
if [[ ! -z $remoteURL ]]; then
local isGitHubURL=`echo $remoteURL | grep -i github\.com`
if [[ ! -z $isGitHubURL ]]; then
local regex=".*github\.com[:/](.*)/(.*)\.git"
if [[ $remoteURL =~ $regex ]]; then
local owner=$match[1]
local repoName=$match[2]
@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 / PrintAllCharacters.swift
Last active Oct 31, 2015
A script that prints all the Unicode characters. I would have uploaded the output as well, but it’s 50 MB and GitHub can’t handle my scale.
View PrintAllCharacters.swift
import Foundation
func describeCharsInRange(range: Range<Int>) -> String {
return range.map {
let swiftCharacter = Character(UnicodeScalar($0))
let string = String(swiftCharacter)
let hexString = NSString(format: "0x%.6X", $0) as String
// Optional in theory, but in this case it always returns a value
let name = string.stringByApplyingTransform(NSStringTransformToUnicodeName, reverse: false)!
@ZevEisenberg
ZevEisenberg / traits.m
Created Dec 14, 2015
Version of a UIFont with different symbolic traits
View traits.m
static UIFont *versionOfFontWithSymbolicTraits(UIFont *font, UIFontDescriptorSymbolicTraits symbolicTraits)
{
UIFontDescriptor *descriptor = font.fontDescriptor;
UIFontDescriptor *descriptorToUse = [descriptor fontDescriptorWithSymbolicTraits:symbolicTraits];
UIFont *newFont = [UIFont fontWithDescriptor:descriptorToUse size:font.pointSize];
return newFont;
}
You can’t perform that action at this time.