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
//
// 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 );
//
// 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;
}