Skip to content

Instantly share code, notes, and snippets.

omz / gist:1102091
Created Jul 24, 2011
Creating arbitrarily-colored icons from a black-with-alpha master image (iOS)
View gist:1102091
// Usage example:
// input image:
// UIImage *buttonImage = [UIImage ipMaskedImageNamed:@"UIButtonBarAction.png" color:[UIColor redColor]];
// .h
@interface UIImage (IPImageUtils)
+ (UIImage *)ipMaskedImageNamed:(NSString *)name color:(UIColor *)color;
henry0312 /
Created Nov 27, 2011
Build MinGW Cross Compiler on Mac OS X Lion
# 初期設定
export PATH="$HOME/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin"
# ソースコードのダウンロード
if [ ! -d $WORK/src ] ; then
mkdir src
piscisaureus /
Created Aug 13, 2012
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url =

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:


Playstation 2 (Dual Shock) controller protocol notes

There are many sources for information on the basics of the Playstation controller protocol. There is frustratingly little, however, in the way of comprehensive documentation for the controller's full command set.

This document is a rather loose collection of reverse-engineering notes, documenting a larger subset of the PS2 and Dual Shock

steipete / PSPDFUIKitMainThreadGuard.m
Last active Dec 24, 2022
This is a guard that tracks down UIKit access on threads other than main. This snippet is taken from the commercial iOS PDF framework, but relicensed under MIT. Works because a lot of calls internally call setNeedsDisplay or setNeedsLayout. Won't catch everything, but it's very lightweight and usually does the job.You might n…
View PSPDFUIKitMainThreadGuard.m
// Taken from the commercial iOS PDF framework
// Copyright (c) 2014 Peter Steinberger, PSPDFKit GmbH. All rights reserved.
// Licensed under MIT (
// You should only use this in debug builds. It doesn't use private API, but I wouldn't ship it.
// PLEASE DUPE rdar://27192338 ( if you would like to see this in UIKit.
#import <objc/runtime.h>
#import <objc/message.h>
rupey / gist:f1429adab0877506c9fb
Created Aug 10, 2014
iTunes Store API rating count retriever snippet
View gist:f1429adab0877506c9fb
#pragma mark - iTunes Store API
#define ITUNES_APP_ID @"870393074"
- (void)updateReviewCount
NSString *countryCode = [[[NSLocale currentLocale] objectForKey: NSLocaleCountryCode] lowercaseString];
NSString *url = [NSString stringWithFormat:@"", countryCode, ITUNES_APP_ID];
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
niun /
Last active Sep 16, 2022
Find Raspberry Pi in network (looking for MAC address vendor prefix of Raspberry Pi Foundation using nmap, awk for ipv4 / ping6, ip, grep for ipv6 neighbour discovery)
sudo nmap -sP | awk '/^Nmap/{ip=$NF}/B8:27:EB/{print ip}'
msealand / CGVectorUtilities.swift
Last active Sep 4, 2019
Operator overloads to do scalar vector math on CGPoint, CGSize, CGVector.
View CGVectorUtilities.swift
import CoreGraphics
protocol VectorType {
typealias Element
var xElement: Element { get }
var yElement: Element { get }
class func buildFrom(#x: Element, y: Element) -> Self
0xced / MoviePlayerControllerDoneButton.h
Created Dec 17, 2014
Access the "Done" button of a MPMoviePlayerController
View MoviePlayerControllerDoneButton.h
#import <MediaPlayer/MediaPlayer.h>
* Example usage:
* UIButton *doneButton = MoviePlayerControllerDoneButton(moviePlayerViewController.moviePlayer);
* [doneButton setTitle:@"✖" forState:UIControlStateNormal];
* doneButton.titleLabel.font = [UIFont systemFontOfSize:30];
extern UIButton * MoviePlayerControllerDoneButton(MPMoviePlayerController *moviePlayerController);
felix-schwarz /
Last active Feb 21, 2022 — forked from steipete/openssl-build.h
Updated script that builds OpenSSL for OS X, iOS and tvOS. Bitcode enabled for iOS, tvOS. Updated to build for tvOS, use the latest SDKs, skip installing man pages (to save time), download the OpenSSL source over HTTPS, patch OpenSSL for tvOS to not use fork(). Currently requires Xcode7.1b or later (for the tvOS SDK).
# This script downloads and builds the iOS, tvOS and Mac openSSL libraries with Bitcode enabled
# Credits:
# Peter Steinberger, PSPDFKit GmbH, @steipete.
# Felix Schwarz, IOSPIRIT GmbH, @felix_schwarz.