Skip to content

Instantly share code, notes, and snippets.

@felix-schwarz
felix-schwarz / openssl-build.sh
Last active March 19, 2024 03:16 — 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).
#!/bin/bash
# This script downloads and builds the iOS, tvOS and Mac openSSL libraries with Bitcode enabled
# Credits:
# https://github.com/st3fan/ios-openssl
# https://github.com/x2on/OpenSSL-for-iPhone/blob/master/build-libssl.sh
# https://gist.github.com/foozmeat/5154962
# Peter Steinberger, PSPDFKit GmbH, @steipete.
# Felix Schwarz, IOSPIRIT GmbH, @felix_schwarz.
@0xced
0xced / MoviePlayerControllerDoneButton.h
Created December 17, 2014 09:54
Access the "Done" button of a MPMoviePlayerController
#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);
@msealand
msealand / CGVectorUtilities.swift
Last active September 4, 2019 17:37
Operator overloads to do scalar vector math on CGPoint, CGSize, CGVector.
import CoreGraphics
protocol VectorType {
typealias Element
var xElement: Element { get }
var yElement: Element { get }
class func buildFrom(#x: Element, y: Element) -> Self
@niun
niun / find-raspberry.sh
Last active September 16, 2022 12:06
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 192.168.0.0/24 | awk '/^Nmap/{ip=$NF}/B8:27:EB/{print ip}'
@rupey
rupey / gist:f1429adab0877506c9fb
Created August 10, 2014 01:34
iTunes Store API rating count retriever snippet
#pragma mark - iTunes Store API
#define ITUNES_APP_ID @"870393074"
- (void)updateReviewCount
{
NSString *countryCode = [[[NSLocale currentLocale] objectForKey: NSLocaleCountryCode] lowercaseString];
NSString *url = [NSString stringWithFormat:@"https://itunes.apple.com/%@/lookup?id=%@", countryCode, ITUNES_APP_ID];
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
@steipete
steipete / PSPDFUIKitMainThreadGuard.m
Last active March 10, 2024 19:23
This is a guard that tracks down UIKit access on threads other than main. This snippet is taken from the commercial iOS PDF framework http://pspdfkit.com, 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…
// Taken from the commercial iOS PDF framework http://pspdfkit.com.
// Copyright (c) 2014 Peter Steinberger, PSPDFKit GmbH. All rights reserved.
// Licensed under MIT (http://opensource.org/licenses/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 (https://openradar.appspot.com/27192338) if you would like to see this in UIKit.
#import <objc/runtime.h>
#import <objc/message.h>
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
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 = git@github.com:joyent/node.git

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:

@henry0312
henry0312 / mingw.sh
Created November 27, 2011 06:19
Build MinGW Cross Compiler on Mac OS X Lion
#!/bin/sh
# 初期設定
WORK=$HOME/Builds/GCC
PREFIX=$HOME/mingw
export PATH="$HOME/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin"
# ソースコードのダウンロード
if [ ! -d $WORK/src ] ; then
mkdir src
@omz
omz / gist:1102091
Created July 24, 2011 01:40
Creating arbitrarily-colored icons from a black-with-alpha master image (iOS)
// Usage example:
// input image: http://f.cl.ly/items/3v0S3w2B3N0p3e0I082d/Image%202011.07.22%2011:29:25%20PM.png
//
// UIImage *buttonImage = [UIImage ipMaskedImageNamed:@"UIButtonBarAction.png" color:[UIColor redColor]];
// .h
@interface UIImage (IPImageUtils)
+ (UIImage *)ipMaskedImageNamed:(NSString *)name color:(UIColor *)color;
@end