Skip to content

Instantly share code, notes, and snippets.

@edamov
edamov / index.php
Created October 18, 2016 15:52
PHP token-based (JWT) push notifications to APNS via HTTP/2
<?php
require_once 'vendor/autoload.php';
use Jose\Factory\JWKFactory;
use Jose\Factory\JWSFactory;
$key_file = 'key.p8';
$secret = null; // If the key is encrypted, the secret must be set in this variable
$private_key = JWKFactory::createFromKeyFile($key_file, $secret, [
func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [AnyObject]? {
var deleteAction = UITableViewRowAction(style: .Normal, title: " ") { [weak self] action, indexPath -> Void in
self?.deleteItemAtIndexPath(indexPath)
}
let cellBounds = tableView.cellForRowAtIndexPath(indexPath)!.bounds
UIGraphicsBeginImageContextWithOptions(cellBounds.size, true, UIScreen.mainScreen().scale)
var image = UIImage(named: "icon-delete-bin-white")
let yPos = floor((cellBounds.height / 2) - (image!.size.height / 2))
@hardez
hardez / gist:985ce910f82f151b01e2
Created January 4, 2015 15:53
NSURLConnectionDelegate
func connection(connection: NSURLConnection, canAuthenticateAgainstProtectionSpace protectionSpace: NSURLProtectionSpace?) -> Bool
{
return protectionSpace?.authenticationMethod == NSURLAuthenticationMethodServerTrust
}
func connection(connection: NSURLConnection, didReceiveAuthenticationChallenge challenge: NSURLAuthenticationChallenge?)
{
if challenge?.protectionSpace.authenticationMethod == NSURLAuthenticationMethodServerTrust
{
if challenge?.protectionSpace.host == "www.myhost.com"