Skip to content

Instantly share code, notes, and snippets.

Pietro Rea pietrorea

Block or report user

Report or block pietrorea

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:c52c6b9a11785cee71a6aae34c8488d8
Verifying my Blockstack ID is secured with the address 13XP5d1aPsUQZHt55f3WyYMCHvaWQjgDKu
pietrorea / gist:2deb1dab39a6d0f896ce91d35273083b
Last active Apr 13, 2017
atmssg - sweetpea - human graphic
View gist:2deb1dab39a6d0f896ce91d35273083b
"message": {
"attachment": {
"type": "template",
"payload": {
"template_type": "generic",
"elements": [
"title": "Having trouble launching your app?",
"image_url": "",
View poll.swift
func poll() {
let backgroundQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)
let source = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, backgroundQueue)
let interval: UInt64 = UInt64(10) * NSEC_PER_SEC
let leeway: UInt64 = UInt64(0.1) * NSEC_PER_SEC
dispatch_source_set_timer(source, DISPATCH_TIME_NOW, interval, leeway)
dispatch_source_set_event_handler(source) { () -> Void in
self.pollDidFinish(source: source)
pietrorea / UIViewController+Containment.swift
Created Nov 12, 2015
View UIViewController+Containment.swift
import UIKit
extension UIViewController {
func addChildVC(viewController: UIViewController) {
pietrorea /
Created Oct 26, 2015 — forked from quellish/
Xcode CI script variables



pietrorea / gist:8309d74336bd82c127ae
Created Dec 7, 2014
Cast Swift closure as Objective-C block (needed for JavaScriptCore)
View gist:8309d74336bd82c127ae
var block : @objc_block (NSString!) -> Void = {
[unowned self] (string : NSString!) -> Void in
let jsText = "\(string)\n"
self.outputTextView.setText(jsText, concatenate: true)
context.setObject(unsafeBitCast(block, AnyObject.self),
forKeyedSubscript: "print")
pietrorea / gist:9887ce31f1d09c87114b
Last active Aug 29, 2015
Weak reference to self within a Swift block
View gist:9887ce31f1d09c87114b
let dataTask = urlSession.dataTaskWithURL(url!, completionHandler: { [unowned self] (data: NSData!, response: NSURLResponse!, error: NSError!) -> Void in
//add code here
View gist:49a5b9f8a6440afdbc1a
NSString *html = @"<bold>Wow!</bold> Now <em>iOS</em> can create <h3>NSAttributedString</h3> from HTMLs!";
NSDictionary *options = @{NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType};
NSAttributedString *attrString = [[NSAttributedString alloc] initWithData:[html dataUsingEncoding:NSUTF8StringEncoding] options:options documentAttributes:nil error:nil];
pietrorea / gist:fbd09d5496bd018f6354
Created Aug 31, 2014
debugLog preprocessor macro
View gist:fbd09d5496bd018f6354
//Add to Project-Prefix.pch
#ifdef DEBUG
#define debugLog(...) NSLog(__VA_ARGS__)
#define debugLog(...) // Nothing
pietrorea / gist:089e308b4e9b46ded3ae
Last active Aug 29, 2015
Auto Layout ambiguous constraints debugging tool
View gist:089e308b4e9b46ded3ae
//In UIViewController subclass
@interface UIWindow (AutoLayoutDebug)
+ (UIWindow *)keyWindow;
- (NSString *)_autolayoutTrace;
- (void)didRotateFromInterfaceOrientation: (UIInterfaceOrientation)fromInterfaceOrientation
[super didRotateFromInterfaceOrientation:fromInterfaceOrientation];
You can’t perform that action at this time.