Skip to content

Instantly share code, notes, and snippets.

View fmessina's full-sized avatar

Ferdinando fmessina

View GitHub Profile
@leviathan
leviathan / Load UIView with nib
Created January 7, 2011 14:53
Loading a custom UIView class with a custom nib file.
QPickOneView* myView = nil;
NSArray* nibViews = [[NSBundle mainBundle] loadNibNamed:@"QPickOneView" owner:self options:nil];
for (id currentObject in nibViews) {
if ([currentObject isKindOfClass:[QPickOneView class]]) {
myView = (QPickOneView *) currentObject;
break;
}
}
@artero
artero / launch_sublime_from_terminal.markdown
Last active May 15, 2024 03:38 — forked from olivierlacan/launch_sublime_from_terminal.markdown
Launch Sublime Text 2 from the Mac OS X Terminal

Launch Sublime Text 2 from the Mac OS X Terminal

Sublime Text 2 ships with a CLI called subl (why not "sublime", go figure). This utility is hidden in the following folder (assuming you installed Sublime in /Applications like normal folk. If this following line opens Sublime Text for you, then bingo, you're ready.

open /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl

You can find more (official) details about subl here: http://www.sublimetext.com/docs/2/osx_command_line.html

Installation

anonymous
anonymous / gist:2767637
Created May 22, 2012 08:39
Wiggling Animation
CABasicAnimation* animation = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
[animation setToValue:[NSNumber numberWithFloat:-M_PI/128]];
[animation setFromValue:[NSNumber numberWithDouble:M_PI/128]];
[animation setDuration:0.09];
[animation setRepeatCount:NSUIntegerMax];
[animation setAutoreverses:YES];
@afrael
afrael / gist:2777859
Created May 23, 2012 21:13
Merging to WAV files in iOS
NSURL *originalFileName = [NSURL alloc];
NSURL *RecordingPath =[NSURL fileURLWithPath:[appDelegate.RecordingPath stringByAppendingPathComponent:
[NSString stringWithFormat:@"RecordingFile.wav"]]];
NSLog(@"LocalRecoding Path :%@",RecordingPath);
originalFileName=RecordingPath;
NSURL *temporaryFileName = [NSURL alloc];
@dhoerl
dhoerl / AppDelegate(category).m
Created July 26, 2012 23:19
Keychain Wrapper for dictionary (NSData) not a single NSString
static NSString *kcIdentifier = @"MyApp";
@implementation LTAppDelegate (KeyChain)
- (void)keychainInit
{
self.keychainDict = [NSMutableDictionary dictionaryWithCapacity:7];
KeychainItemWrapper *item = [[KeychainItemWrapper alloc] initWithIdentifier:kcIdentifier accessGroup:nil];
[self.keychainDict setObject:@"" forKey:kcEmailAddress];
@sent-hil
sent-hil / pictures.markdown
Created August 24, 2012 02:18
River (getriver.com): Keep a programming journal.

One of my favorite past times is to look at the notebooks of famous scientists. Da Vinci's notebook is well known, but there plenty others. Worshipping Da Vinci like no other, I bought a Think/Create/Record journal, used it mostly to keep jot down random thoughts and take notes. This was great in the beginning, but the conformity of lines drove me nuts. Only moleskines made blank notebooks, so I had to buy one.

At the same time I started a freelance project. The project itself is irrelevant, but suffice to say it was very complex and spanned several months. It seemed like a perfect opportunity to use the moleskine. Looking back, all my entries fell under few categories:

  • Todo
  • Question
  • Thought
  • Bug
  • Feature
@snikch
snikch / gist:3661188
Created September 6, 2012 23:16
Find the current top view controller for your iOS application
- (UIViewController *)topViewController{
return [self topViewController:[UIApplication sharedApplication].keyWindow.rootViewController];
}
- (UIViewController *)topViewController:(UIViewController *)rootViewController
{
if (rootViewController.presentedViewController == nil) {
return rootViewController;
}
@akshay1188
akshay1188 / whatsapp-image-compression
Last active June 10, 2023 16:42
Whatsapp like image compression
- (UIImage *)compressImage:(UIImage *)image{
float actualHeight = image.size.height;
float actualWidth = image.size.width;
float maxHeight = 600.0;
float maxWidth = 800.0;
float imgRatio = actualWidth/actualHeight;
float maxRatio = maxWidth/maxHeight;
float compressionQuality = 0.5;//50 percent compression
if (actualHeight > maxHeight || actualWidth > maxWidth) {
@steipete
steipete / UIKitLegacyDetector.m
Last active March 12, 2024 13:57
A simple way to detect at runtime if we're running in UIKit legacy mode or the new "flat" variant. Written for our PDF iOS SDK (http://pspdfkit.com), where the precompiled binary needs to detect at runtime in what variant it's running. Want more stuff like that? Follow me on Twitter: http://twitter.com/steipete
// Taken from http://PSPDFKit.com. This snippet is under public domain.
#define UIKitVersionNumber_iOS_7_0 0xB57
BOOL PSPDFIsUIKitFlatMode(void) {
static BOOL isUIKitFlatMode = NO;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
// We get the modern UIKit if system is running >= iOS 7 and we were linked with >= SDK 7.
if (kCFCoreFoundationVersionNumber >= kCFCoreFoundationVersionNumber_iOS_7_0) {
isUIKitFlatMode = (NSVersionOfLinkTimeLibrary("UIKit") >> 16) >= UIKitVersionNumber_iOS_7_0;
}
@staltz
staltz / introrx.md
Last active June 25, 2024 15:13
The introduction to Reactive Programming you've been missing