Skip to content

Instantly share code, notes, and snippets.

View ZevEisenberg's full-sized avatar

Zev Eisenberg ZevEisenberg

View GitHub Profile
2015-01-26 18:02:31.223 Invaluable iOS[29323:1139622] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '{objective 0x7ff55b678f30: <251:-343, 250:915> + <250:5.96046e-08>*0x7ff55d81f580.marker{id: 7363} + <250:-2.98023e-08>*0x7ff55db73220.marker{id: 7364} + <250:2>*0x7ff55fa3e030.marker{id: 9313} + <250:2>*0x7ff55fd01060.negError{id: 9018} + <250:-2>*0x7ff55fd01060.posErrorMarker{id: 9017} + <250:-2>*0x7ff55fd018b0.marker{id: 9032}}: internal error. Setting empty vector for variable INVTriColumnPriceView:0x7ff55fe35160.minX{id: 8877}.'
*** First throw call stack:
(
0 CoreFoundation 0x00000001085ddf35 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010546cbb7 objc_exception_throw + 45
2 CoreFoundation 0x00000001085dde6d +[NSException raise:format:] + 205
3 Foundation 0x00000001060cf45e -[NSISObjectiveLinearExpression setPriorityVector:forKnownAbsentVariable:] + 76
@ZevEisenberg
ZevEisenberg / gist:d29476094201e4076c03
Last active August 29, 2015 14:21
Localized Hours Range String
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 August 29, 2015 14:23
Unscientific Ad Blocker Comparisons

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 July 10, 2015 20:03
Function to open the GitHub page of the current repo
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 / iOS 9 system font properties.json
Created August 13, 2015 22:26
Result of calling CTFontCopyFeatures on the system font in iOS 9 beta 5
[
{
"CTFeatureTypeIdentifier" : 0,
"CTFeatureTypeName" : "All Typographic Features",
"CTFeatureTypeNameID" : -100,
"CTFeatureTypeSelectors" : [
{
"CTFeatureSelectorDefault" : true,
"CTFeatureSelectorName" : "On",
"CTFeatureSelectorNameID" : -101,
@ZevEisenberg
ZevEisenberg / PrintAllCharacters.swift
Last active October 31, 2015 02:33
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.
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 December 14, 2015 18:02
Version of a UIFont with different symbolic traits
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;
}
@ZevEisenberg
ZevEisenberg / map float range.swift
Last active July 13, 2020 20:31
Mapping floating point numbers between two ranges in Swift
import QuartzCore
extension CGFloat {
func map(from from: ClosedInterval<CGFloat>, to: ClosedInterval<CGFloat>) -> CGFloat {
let result = ((self - from.start) / (from.end - from.start)) * (to.end - to.start) + to.start
return result
}
}
extension Double {
@ZevEisenberg
ZevEisenberg / LICENSE
Last active February 19, 2022 02:04
Smoothly deselect table and collection view cells on dismissal, including interactive dismiss and interactively-partially-dismiss-then-cancel-then-dismiss-again
The MIT License (MIT)
Copyright (c) 2016 Zev Eisenberg
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
@ZevEisenberg
ZevEisenberg / NS Prefix Finder.txt
Created March 30, 2017 15:25
Regex for finding NS prefixes in code migrated to Swift 3
[^(CONDITIO)]NS[^(Error)|^(Coder)|^(Managed)|^(Attributed)|^(LayoutConstraint)|^(Predicate)|^(FetchRequest)|^(Null)|^(KeyValue)]