Skip to content

Instantly share code, notes, and snippets.

View nicpro85's full-sized avatar

Nicolas Manzini nicpro85

  • Lausanne, Switzerland
View GitHub Profile
@edwardmp
edwardmp / gist:df8517aa9f1752e73353
Created May 22, 2015 16:06
Using NSURLSession with SSL public key pinning
/*
1. Adhere to the NSURLSessionDelegate delegate
2. Initialize NSURLSession and specify self as delegate (e.g. [NSURLSession sessionWithConfiguration:defaultConfigObject delegate:self delegateQueue: [NSOperationQueue mainQueue]];)
3. Add the method below to your class
4. Change the certificate resource name
*/
- (void)URLSession:(NSURLSession *)session didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition, NSURLCredential *))completionHandler
{
SecTrustRef serverTrust = challenge.protectionSpace.serverTrust;
@nicpro85
nicpro85 / UIPlaceholderTextView.h
Created October 27, 2014 11:25
UIPlaceholderTextView
//
// UIPlaceholderTextView.h
//
// Created by Nicolas Manzini on 27.10.14.
// Free under MIT
//
#import <UIKit/UIKit.h>
@interface UIPlaceholderTextView : UITextView
@turret-io
turret-io / aes_enc_dec.php
Last active July 27, 2024 02:51
AES encryption/decryption in PHP
<?php
// DEFINE our cipher
define('AES_256_CBC', 'aes-256-cbc');
// Generate a 256-bit encryption key
// This should be stored somewhere instead of recreating it each time
$encryption_key = openssl_random_pseudo_bytes(32);
// Generate an initialization vector
// This *MUST* be available for decryption as well
@nicpro85
nicpro85 / UIButton+IndexPath.h
Created September 10, 2013 18:24
UIButton+IndexPath
#import <UIKit/UIKit.h>
@interface UIButton (IndexPath)
@property (strong, nonatomic) NSIndexPath * indexPath;
@end
/* [UIColor colorWithHex:0xFF0000]; */
#import <UIKit/UIKit.h>
@interface UIColor (Hex)
+(UIColor*) colorWithHex:(int)hex;
@end
@jirutka
jirutka / rules-both.iptables
Created September 18, 2012 12:42
Basic iptables template for ordinary servers (both IPv4 and IPv6)
###############################################################################
# The MIT License
#
# Copyright 2012-2014 Jakub Jirutka <[email protected]>.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
@sekati
sekati / xcode-build-bump.sh
Created July 24, 2012 20:44
Xcode Auto-increment Build & Version Numbers
# xcode-build-bump.sh
# @desc Auto-increment the build number every time the project is run.
# @usage
# 1. Select: your Target in Xcode
# 2. Select: Build Phases Tab
# 3. Select: Add Build Phase -> Add Run Script
# 4. Paste code below in to new "Run Script" section
# 5. Drag the "Run Script" below "Link Binaries With Libraries"
# 6. Insure that your starting build number is set to a whole integer and not a float (e.g. 1, not 1.0)
// UIColor+hex.h
@interface UIColor (Hex)
+ (UIColor *) colorWithHex:(uint)rgbValue;
@end
// UIColor+hex.m
#import "UIColor+Hex.h"