Skip to content

Instantly share code, notes, and snippets.

View albertodebortoli's full-sized avatar

Alberto De Bortoli albertodebortoli

View GitHub Profile
@albertodebortoli
albertodebortoli / gist:2863522
Created June 3, 2012 13:34
iOS Flip Animation within a view controller
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft fromView:self.view cache:YES];
[secondViewController viewWillAppear:YES];
[firstViewController viewWillDisappear:YES];
[firstViewController removeFromSuperview];
[self.view addSubview:tableView];
[firstViewController viewDidDisappear:YES];
[secondViewController viewDidAppear:YES];
@albertodebortoli
albertodebortoli / gist:2894402
Created June 8, 2012 08:09
clang ignore protocol method implementation warnings
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wobjc-protocol-method-implementation"
// do your override
#pragma clang diagnostic pop
@albertodebortoli
albertodebortoli / NSObject+PWObject.c
Created July 26, 2012 12:31 — forked from kylestew/NSObject+PWObject.c
Category - Perform Block After Delay
#import "NSObject+PWObject.h"
@implementation NSObject (PWObject)
- (void)performBlock:(void (^)(void))block afterDelay:(NSTimeInterval)delay {
int64_t delta = (int64_t)(1.0e9 * delay);
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, delta), dispatch_get_main_queue(), block);
}
@end
@albertodebortoli
albertodebortoli / 0.suffixtree.cs
Created July 30, 2012 08:51 — forked from axefrog/0.suffixtree.cs
C# Suffix tree implementation based on Ukkonen's algorithm
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
namespace SuffixTreeAlgorithm
{
public class SuffixTree
{
@albertodebortoli
albertodebortoli / gist:4100669
Created November 17, 2012 22:11
HelpEmotion
RESTful routes
GET /emergencies
POST /emergencies
GET /emergencies/:id
POST /emergencies/:id/offers
GET /emergencies
{
"emergencies": [
@albertodebortoli
albertodebortoli / apns.rb
Created November 30, 2012 11:49
Passbook Push Notification
# File: apns.rb
#
# Abstract: Pass Server reference implementation
#
# Version: <1.0>
#
# Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Inc. ("Apple")
# in consideration of your agreement to the following terms, and your use,
# installation, modification or redistribution of this Apple software
# constitutes acceptance of these terms. If you do not agree with these
@albertodebortoli
albertodebortoli / NSObject+RestKit
Created December 23, 2012 17:41
JSON serialization using RestKit
- (NSString *)JSONSerialization
{
RKObjectMappingProvider * provider = [RKObjectManager sharedManager].mappingProvider;
RKObjectMapping* mapping = [provider objectMappingForClass:[self class]];
RKObjectSerializer * serializer = [RKObjectSerializer serializerWithObject:self mapping:mapping];
NSError *error = nil;
NSString *retVal = [serializer serializedObjectForMIMEType:RKMIMETypeJSON error:&error];
# Note that a variable may require special treatment
#+ if it will be exported.
DARKGRAY='\e[1;30m'
INDACO='\e[1;36m'
WHITE='\e[1;37m'
PURPLE='\e[1;35m'
LIGHTRED='\e[1;31m'
GREEN='\e[32m'
YELLOW='\e[1;33m'
@albertodebortoli
albertodebortoli / gist:4968566
Created February 16, 2013 20:19
XOCL, common error messages in Objective-C
@interface AppDelegate : NSObject
- (void)causeUnrecognizedSelector;
@end
@implementation AppDelegate
- (void)startXOCL
{
@albertodebortoli
albertodebortoli / cloc-1.56.pl
Last active December 14, 2015 03:49
Just a personal copy of Al Danial's CLOC http://cloc.sourceforge.net/ (v1.56)
#!/usr/bin/env perl
# cloc -- Count Lines of Code {{{1
# Copyright (C) 2006-2011 Northrop Grumman Corporation
# Author: Al Danial <[email protected]>
# First release August 2006
#
# Includes code from:
# - SLOCCount v2.26
# http://www.dwheeler.com/sloccount/
# by David Wheeler.