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 / objc-pan-direction
Last active August 29, 2015 14:04
PAN direction
BOOL dragUp = [pan velocityInView:<#UIView#>].y < 0;
@elpsk
elpsk / OSX detect runtime mouse position and click
Last active August 29, 2015 14:06
Returns a list of mouse coordinate for moving and/or clicking
//
// APAppDelegate.m
// TestMouse
//
// Created by alberto pasca on 04/09/14.
// Copyright (c) 2014 albertopasca.it. All rights reserved.
//
#import "APAppDelegate.h"
@elpsk
elpsk / OSX - keystroke listener and windows activate
Created September 3, 2014 22:40
MAC OSX - Keystroke listener
// listen for keystrokes
[NSEvent addGlobalMonitorForEventsMatchingMask:NSKeyDownMask handler:^(NSEvent *event)
{
NSLog(@"%lui -- %@", (unsigned long)[event modifierFlags], event.characters );
//
// if flag and char do something, like bring to front the application
// 256 is ESC, in my case.
//
@elpsk
elpsk / gist:574df60002b6ee4877ad
Created September 5, 2014 08:08
Xcode - lipo fat static library device/simulator
lipo -create libPhone.a libSimulator.a -output libUniversal.a
@elpsk
elpsk / PHP Singleton
Created September 6, 2014 22:00
PHP Singleton class, simple usage
<?php
class MyClass
{
private static $instance = null;
private function __construct() { }
public static function getInstance()
{
if(self::$instance == null)
{
@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 / 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 / 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 / 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."
@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: