Skip to content

Instantly share code, notes, and snippets.

Pietro Rea pietrorea

View GitHub Profile
View UIImage+Extension.m
#import "UIImage+Extension.h"
@implementation UIImage (Extension)
- (UIImage *)imageWithColor:(UIColor *)color
{
UIGraphicsBeginImageContextWithOptions(self.size, NO, self.scale);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextTranslateCTM(context, 0, self.size.height);
CGContextScaleCTM(context, 1.0, -1.0);
View gist:c52c6b9a11785cee71a6aae34c8488d8
Verifying my Blockstack ID is secured with the address 13XP5d1aPsUQZHt55f3WyYMCHvaWQjgDKu https://explorer.blockstack.org/address/13XP5d1aPsUQZHt55f3WyYMCHvaWQjgDKu
@pietrorea
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": "https://static1.squarespace.com/static/5636e291e4b0b347abc855f0/56b0b6538a65e22f4e82c849/58bf4aab9de4bbc4171985ac/1489069853859/Fotolia_120413491_Subscription_Monthly_M.jpg?format=750w",
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
pietrorea / UIViewController+Containment.swift
Created Nov 12, 2015
UIViewController+Containment.swift
View UIViewController+Containment.swift
import UIKit
extension UIViewController {
func addChildVC(viewController: UIViewController) {
addChildViewController(viewController)
view.addSubview(viewController.view)
viewController.didMoveToParentViewController(self)
}
}
@pietrorea
pietrorea / xcci.md
Created Oct 26, 2015 — forked from quellish/xcci.md
Xcode CI script variables
View xcci.md

Variable

Type

@pietrorea
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
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
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__)
#else
#define debugLog(...) // Nothing
#endif
You can’t perform that action at this time.