Skip to content

Instantly share code, notes, and snippets.

View elpsk's full-sized avatar
:octocat:
I may be slow to respond.

alberto elpsk

:octocat:
I may be slow to respond.
View GitHub Profile
@elpsk
elpsk / APLogger.h
Last active August 29, 2015 14:20
APLogger - Write console log to disk
//
// APLogger.h
// Copyright (c) 2015 Alberto Pasca. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface APLogger : NSObject
void APLog ( NSString* format, ... );
@elpsk
elpsk / Execution-Time.m
Created June 22, 2015 10:26
DEBUG Execution Time
NSDate *_start;
- (void) start
{
_start = [NSDate date];
}
- (void) stopMethod:(NSString*)pMethod line:(int)pLine
{
@elpsk
elpsk / UIDynamics-CCMotionManager.m
Created May 20, 2015 15:16
UIDynamics and CCMotionManager
//
// ViewController.m
// DynamicMotion
//
// Created by Alberto Pasca on 20/05/15.
// Copyright (c) 2015 Alberto Pasca. All rights reserved.
//
#import "ViewController.h"
#import <CoreMotion/CoreMotion.h>
@elpsk
elpsk / archiveIPA.sh
Created December 17, 2015 11:16
Auto Archive IPA files
#!/bin/sh
xcodebuild -scheme AppName clean archive -archivePath /Users/pasky/Desktop/AppName
xcodebuild -exportArchive -exportFormat ipa -archivePath "/Users/pasky/Desktop/AppName.xcarchive" -exportPath "/Users/pasky/Desktop/AppName.ipa" -exportProvisioningProfile "XC Ad Hoc: com.AppName.iphone.app"
rm -rf "/Users/pasky/Desktop/AppName.xcarchive"
mv "/Users/pasky/Desktop/AppName.ipa" "/Volumes/DATA/Dropbox/Public/AppName.ipa"
echo "done."
//
// CoreTextLabel.h
// Frost
//
// Created by David Kasper on 10/1/12.
//
#import <UIKit/UIKit.h>
#import <CoreText/CoreText.h>
@elpsk
elpsk / foreach label
Created October 22, 2013 13:20
foreach label
@interface APViewController ()
{
NSMutableArray *_Labels;
}
- ( void ) forEachLabel: ( void (^)( UILabel * label ) ) block;
@end
@elpsk
elpsk / APPassThroughUIView
Created December 4, 2013 13:19
Pass through view
@interface APPassThroughUIView : UIView
@end
@implementation APPassThroughUIView
- (BOOL) pointInside:(CGPoint)point withEvent:(UIEvent *)event
{
for (UIView *v in self.subviews)
{
- (NSDictionary*) loadJson
{
NSString *fPath = [[NSBundle mainBundle] pathForResource:@"jtest" ofType:@"json"];
NSData *data = [NSData dataWithContentsOfFile:fPath];
return
[ NSJSONSerialization JSONObjectWithData: data
options: NSJSONReadingMutableContainers
error: nil ];
}
int N(int n, int k) {
if (n == 0) return k == 0 ? 1 : 0;
return (N(n-1, k-1) + N(n-1, k)*(n-1-k)) + N(n-1, k+1)*(k+1) % 2810;
}
int num[] = {N(3,6)+105,N(8,5)-2,102,N(8,5)-1,64,97+N(3,6),
108,98,101,N(8,5)+2,116,N(8,5)-1,N(8,5),
97,115,99,97,(N(8,6)*2)-10,105,N(8,5)+4};
for ( auto n : num )
printf ( "%c", n );
@elpsk
elpsk / contentTypeForImageData
Last active September 1, 2016 11:03
Get contentTypeForImageData from image byte header
- (NSString *)contentTypeForImageData:(NSData *)data {
uint8_t c;
[data getBytes:&c length:1];
switch (c) {
case 0xFF:
return @"jpeg";
case 0x89:
return @"png";
case 0x47: