Navigation Menu

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
//
// Fibonacci Algorithm
//
// Created by Alberto Pasca on 25/02/14.
// Copyright (c) 2014 albertopasca.it. All rights reserved.
//
#include <iostream>
#include <chrono>
# ----------------------------------------------------------------------
# WARNING - do not edit this template unless you know what you are doing
# ----------------------------------------------------------------------
# the parent cache
cache_peer %PARENTPROXY% parent %PARENTPORT% 7 no-query no-digest no-netdb-exchange default
strip_query_terms off
# disk and memory cache settings
- (UIColor *)averageColor
{
CGImageRef rawImageRef = [self CGImage];
CFDataRef data = CGDataProviderCopyData(CGImageGetDataProvider(rawImageRef));
const UInt8 *rawPixelData = CFDataGetBytePtr(data);
NSUInteger imageHeight = CGImageGetHeight(rawImageRef);
NSUInteger imageWidth = CGImageGetWidth(rawImageRef);
NSUInteger bytesPerRow = CGImageGetBytesPerRow(rawImageRef);
@interface UIImage (Blur)
- (UIImage *)imageWithGaussianBlur;
- (UIImage*) stackBlur:(NSUInteger)radius;
- (UIImage *) normalize;
+ (void) applyStackBlurToBuffer:(UInt8*)targetBuffer width:(const int)w height:(const int)h withRadius:(NSUInteger)inradius;
@end
- (NSMutableAttributedString*) subtitle:(NSString*)pString
{
NSMutableAttributedString *string = [[NSMutableAttributedString alloc] initWithString:pString];
NSRange selectedRange = NSMakeRange(0, 6); // 6 characters, starting at index 0
[string beginEditing];
[string addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"Helvetica-Bold" size:12.0] range:selectedRange];
[string endEditing];
return string;
}
@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)
{