Skip to content

Instantly share code, notes, and snippets.

View ZevEisenberg's full-sized avatar

Zev Eisenberg ZevEisenberg

View GitHub Profile

The following line omitted the text in bold:

button.enabled = [string length] > 0;

As a result, the string's length, a value of type NSUInteger, or unsigned long on 64-bit, was stuffed into a BOOL, which is actually a typedef for signed char. Comparisons of this frankenbool against NO yield the right result, but only for values below 255. Anything above might truncate and yield an erroneous NO. Comparing against YES, meanwhile, only returns the right result for the value 1. By setting the button's enabled state to an unsigned integer, the code was effectively disabling the button for all strings shorter or longer than one character.

#!/usr/bin/python
#
# Usage:
#
# $ ./conception.py 1969-12-25
# searching for most recent event before 1969-04-03
# <li><a href="/wiki/April_1" title="April 1">April 1</a>
# &#226;&#8364;&#8220; The <a href="/wiki/Hawker_Siddeley_Harrier" title="Hawker Siddeley Harrier">Hawker Siddeley Harrier</a> enters
# service with the <a href="/wiki/Royal_Air_Force" title="Royal Air Force">Royal Air Force</a>.</li>
#
@AliSoftware
AliSoftware / GHDiff-HidePods.js
Last active February 13, 2017 11:40
Hide Pods/* related files in a GitHub diff page
// When you are in the diff page of a GitHub PR
// And want to hide all the Pods/* files in that diff page, use this:
// Paste that in your Web Inspector's console
var nodes = document.evaluate("//div[@class='file-header' and starts-with(@data-path,'Pods/')]", document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null );
for(i=0; i<nodes.snapshotLength; ++i) {
nodes.snapshotItem(i).parentNode.hidden = true
}
// Or even better, create a bookmark with this code for easy quick access:
@jacob414
jacob414 / blocks.m
Created May 24, 2012 19:39
With blocks and varargs Objective C might not be as bad after all
#include <stdarg.h>
#import <Foundation/Foundation.h>
@interface Cls : NSObject {}
-(int) takes_block: (int)limit withBlock:(int (^)(int first, ...))block;
@end
@implementation Cls
-(int) takes_block: (int)limit withBlock:(int (^)(int first, ...))block {
@woolsweater
woolsweater / .lldbinit
Last active September 12, 2018 01:59
Break on unsatisfiable constraints and send to wtfautolayout
command script import ~/.lldbscripts/break_unsatisfiable.py
@raven
raven / Breakpoints_v2.xcbkptlist
Last active August 30, 2019 00:53
Symbolic breakpoint for dynamically linking libReveal against UIApplicationMain
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
type = "2"
version = "2.0">
<Breakpoints>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.SymbolicBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
@neonichu
neonichu / update_xcode_plugins
Last active September 18, 2019 14:09
Update DVTPlugInCompatibilityUUIDs for installed plugins from Xcode 5.1 beta to final
#!/bin/sh
#ID='A16FF353-8441-459E-A50C-B071F53F51B7' # Xcode 6.2
ID='992275C1-432A-4CF7-B659-D84ED6D42D3F' # Xcode 6.3
PLIST_BUDDY=/usr/libexec/PlistBuddy
function add_compatibility() {
"$PLIST_BUDDY" -c "Add DVTPlugInCompatibilityUUIDs:10 string $2" \
"$1/Contents/Info.plist"
@bomberstudios
bomberstudios / sketch-diff-in-git.md
Last active November 8, 2019 17:58
How to diff your .sketch files in Git

Using sketchtool to diff your .sketch files using text

Requirements

You need to have SketchTool installed somewhere in your path.

Setup

Add this in your ~/.gitconfig file (for some reason, it won't work in a local .gitconfig file):

@ttscoff
ttscoff / itunesicon.rb
Last active January 13, 2022 10:07
Retrieve a 512 x 512px icon for an iOS app
#!/usr/bin/ruby
# encoding: utf-8
#
# Updated 2017-10-25:
# - Defaults to large size (512)
# - If ImageMagick is installed:
# - rounds the corners (copped from @bradjasper, https://github.com/bradjasper/Download-iTunes-Icon/blob/master/itunesicon.rb)
# - replace original with rounded version, converting to png if necessary
#
# Retrieve an iOS app icon at the highest available resolution
@stuartjmoore
stuartjmoore / WPHangingQuoteViewController.m
Last active June 15, 2022 07:29
Hanging quotes on iOS 7.Basically, we set the UITextView's left inset to the negative width of a double quote, then undo that per line fragment if the line doesn't start with a double quote.And the opposite for an exclusion path lines.
- (void)loadOrResizeOrSometing {
/*
* After creating the text view or resizing the font, set the quoteWidth and contentInset.
*/
WPTextContainer *textContainer = (WPTextContainer*)paragraphView.textContainer;
textContainer.spaceWidth = [self widthForCharacter:@" "];
textContainer.charWidths = @{
@(8220) : @([self widthForCharacter:@"“"]),
@(8216) : @([self widthForCharacter:@"‘"]),
@('"') : @([self widthForCharacter:@"\""]),