Skip to content

Instantly share code, notes, and snippets.

View Pretz's full-sized avatar

Alex Pretzlav Pretz

View GitHub Profile
@dittos
dittos / trac-tickets-to-gh.py
Created July 29, 2010 07:53
Trac tickets to GitHub issues
import sys; reload(sys); sys.setdefaultencoding('utf-8')
import sqlite3
import urllib2
import urllib
import simplejson
login = 'your github id'
token = 'your github api key'
repo = 'username/reponame'
@ngs
ngs / Dictionary.js
Created July 26, 2012 07:53
Script to convert JSON to Objective-C literal
var Dictionary;
if (!Dictionary) {
Dictionary = {};
}
(function () {
'use strict';
function f(n) {
// Format integers to have at least two digits.
/**
* Several macros simplifying use of weak references to self inside blocks
* which goal is to reduce risk of retain cycles.
*
* Example:
* @code
@interface Example : NSObject{
int _i;
}
@mattt
mattt / uiappearance-selector.md
Last active March 19, 2024 12:52
A list of methods and properties conforming to `UIAppearance` as of iOS 12 Beta 3

Generate the list yourself:

$ cd /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS*.sdk/System/Library/Frameworks/UIKit.framework/Headers
$ grep UI_APPEARANCE_SELECTOR ./*     | \
  sed 's/NS_AVAILABLE_IOS(.*)//g'     | \
  sed 's/NS_DEPRECATED_IOS(.*)//g'    | \
  sed 's/API_AVAILABLE(.*)//g'        | \
  sed 's/API_UNAVAILABLE(.*)//g'      | \
 sed 's/UI_APPEARANCE_SELECTOR//g' | \
@axelarge
axelarge / gist:7386644
Created November 9, 2013 15:36
Objective-C NSComparisonResult for primitives macro
#define COMPARE(A, B) ({ \
__typeof__(A) __a = (A); \
__typeof__(B) __b = (B); \
__a < __b ? NSOrderedAscending : __a == __b ? NSOrderedSame : NSOrderedDescending; \
})
@keremk
keremk / Date.playground
Created June 24, 2014 06:56
Swift Date Helpers
// Playground - noun: a place where people can play
import UIKit
var str = "Hello, playground"
enum TimeIntervalUnit {
case Seconds, Minutes, Hours, Days, Months, Years
func dateComponents(interval: Int) -> NSDateComponents {
@cdzombak
cdzombak / tgmath.md
Last active July 14, 2016 18:01
fucking tgmath doesn't work with ObjC modules, and Apple has known about this for at least a year and doesn't care about fixing it
@andymatuschak
andymatuschak / MultiDirectionAdjudicatingScrollView.swift
Created January 26, 2015 19:31
Source for the Khan Academy app's unusual scrolling interactions
//
// MultiDirectionAdjudicatingScrollView.swift
// Khan Academy
//
// Created by Andy Matuschak on 12/16/14.
// Copyright (c) 2014 Khan Academy. All rights reserved.
//
import UIKit
import UIKit.UIGestureRecognizerSubclass
@jspahrsummers
jspahrsummers / GHRunLoopWatchdog.h
Created January 28, 2015 20:50
A class for logging excessive blocking on the main thread
/// Observes a run loop to detect any stalling or blocking that occurs.
///
/// This class is thread-safe.
@interface GHRunLoopWatchdog : NSObject
/// Initializes the receiver to watch the specified run loop, using a default
/// stalling threshold.
- (id)initWithRunLoop:(CFRunLoopRef)runLoop;
/// Initializes the receiver to detect when the specified run loop blocks for
@erica
erica / gist:0c445044e1bf97778263
Last active February 19, 2020 13:32
#swift-lang ReadMe

"JUST BECAUSE YOU'RE USING SWIFT DOESN'T MEAN YOUR QUESTION IS ABOUT SWIFT"

How To Get Answers

Ask your question and then be patient. Tell us what you want to happen, what is actually happening, and include any error messages you find:

  • Provide a scenario. "I am trying to do X, I do so by calling APIs W and Y, but Z happens instead. I see the following error messages:..."
  • Focus on the goal. Ask about what you're trying to achieve (the big story) rather than the specific technical detail that you believe is holding you back.
  • Don't solicit help. Don't say, "Does anyone here know about (for example) Protocol Extensions". Just ask your question.
  • Do your homework. Search the web before asking in-channel.
  • Be courteous Don't just paste Stack Overflow questions in-channel.
  • Remember the topic Refer questions about third party libraries to their developers.