Skip to content

Instantly share code, notes, and snippets.

View priore's full-sized avatar

Prioregroup.com priore

View GitHub Profile
@genedelisa
genedelisa / gist:f9d350f0ac90cc079f3d
Created June 30, 2014 23:24
Create a calendar event with alarm
var store:EKEventStore = EKEventStore()
store.requestAccessToEntityType(EKEntityTypeEvent,
completion:{(granted:Bool, error:NSError?) -> Void in
if let e = error {
println("Error \(e.localizedDescription)")
}
if granted {
// http://stackoverflow.com/questions/17535918/aes-gets-different-results-in-ios-and-java
- (NSData *)AES256EncryptWithKey:(NSString *)key {
// 'key' should be 32 bytes for AES256, will be null-padded otherwise
char keyPtr[kCCKeySizeAES256+1]; // room for terminator (unused)
bzero(keyPtr, sizeof(keyPtr)); // fill with zeroes (for padding)
// fetch key data
[key getCString:keyPtr maxLength:sizeof(keyPtr) encoding:NSUTF8StringEncoding];
@0liver
0liver / GoogleAnalyticsApi.cs
Last active February 12, 2025 17:32
C# wrapper around the Google Analytics Measurement Protocol API
/* based on the docs at: https://developers.google.com/analytics/devguides/collection/protocol/v1/devguide */
/*
* LICENSE: MIT
* AUTOHR: [email protected]
*/
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
@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)
@priore
priore / gist:3128993
Created July 17, 2012 11:50
Copy object with property values
// Created by Danilo Priore on 02/04/12.
// Copyright (c) 2011 Prioregroup.com. All rights reserved.
//
// Copy object with property values
//
- (id)copy {
id copied = [[[self class] alloc] init];
unsigned int count = 0;
objc_property_t *properties = class_copyPropertyList([self class], &count);
@priore
priore / gist:3128985
Created July 17, 2012 11:49
How to enable automatic observer notification
//
// How to enable automatic observer notification
//
// Created by Danilo Priore on 03/04/12.
// Copyright (c) 2012 Prioregroup.com. All rights reserved.
//
- (id)init {
if (self = [super init]) {
[self addObserverNotifications];
}
@romainbriche
romainbriche / TBXML+NSDictionary.h
Created February 27, 2012 09:07
Parse XML to NSDictionary using TBXML
#import "TBXML.h"
@interface TBXML (TBXML_NSDictionary)
+ (NSDictionary*)dictionaryWithXMLNode:(TBXMLElement*)element;
+ (NSDictionary*)dictionaryWithXMLData:(NSData*)data;
@end
@joshbirk
joshbirk / samplerest.js
Created February 3, 2012 19:57
Sample of using passport w/ mult strategies
var fs = require("fs")
var ssl_options = {
key: fs.readFileSync('privatekey.pem'),
cert: fs.readFileSync('certificate.pem')
};
var port = process.env.PORT || 3000;
var express = require('express');
var ejs = require('ejs');
var passport = require('passport')
@terhechte
terhechte / slow_kvo_dictionary_example2.m
Created December 7, 2011 20:34
Example 1 of slow and fast NSDictionary access
// Created by Benedikt Terhechte on 07.12.11.
// Appventure.me
//
#import <Foundation/Foundation.h>
#define AKeyPathDictionary(dictionary, A) [dictionary objectForKey:@A]
#define BKeyPathDictionary(dictionary, A, B) [AKeyPathDictionary(dictionary, A) objectForKey:@B]
#define CKeyPathDictionary(dictionary, A, B, C) [BKeyPathDictionary(dictionary, A, B) objectForKey:@C]
#define DKeyPathDictionary(dictionary, A, B, C, D) [CKeyPathDictionary(dictionary, A, B, C) objectForKey:@D]