This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SystemSoundID soundID; | |
| id sndpath = [[NSBundle mainBundle] pathForResource:@"mySound" ofType:@"mp3" inDirectory:@"/"]; | |
| CFURLRef baseURL = (CFURLRef) [[NSURL alloc] initFileURLWithPath:sndpath]; | |
| AudioServicesCreateSystemSoundID (baseURL, &soundID); | |
| AudioServicesPlaySystemSound(soundID); | |
| [baseURL release]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| AudioServicesPlaySystemSound(kSystemSoundID_Vibrate); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| CABasicAnimation *myAnimation; | |
| myAnimation=[CABasicAnimation animationWithKeyPath:@"transform.translation.x"]; | |
| myAnimation.duration=1; | |
| myAnimation.repeatCount=2; | |
| myAnimation.autoreverses=YES; | |
| myAnimation.fromValue=[NSNumber numberWithFloat:0]; | |
| myAnimation.toValue=[NSNumber numberWithFloat:-50]; | |
| [view.layer addAnimation:myAnimation forKey:@"animateLayer"]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| NSArray *myImages = [NSArray arrayWithObjects: | |
| [UIImage imageNamed:@"1.png"], | |
| [UIImage imageNamed:@"2.png"], | |
| [UIImage imageNamed:@"3.jpg"], | |
| [UIImage imageNamed:@"4.gif"], nil]; | |
| UIImageView *myAnimatedView = [UIImageView alloc]; | |
| [myAnimatedView initWithFrame:[self bounds]]; | |
| myAnimatedView.animationImages = myImages; | |
| myAnimatedView.animationDuration = 0.25; // seconds |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| If you need to acquire your current location all the time, you need to have a delegate method to receive this information and parse this location to acquire latitude and longitude value. | |
| B sure to implement CLLocationManagerDelegate and create a property something like this in your .h file. | |
| CLLocationManager *location_mgr; | |
| And set properties. | |
| @property (nonatomic, retain) CLLocationManager *location_mgr; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -(void)acquireCurrentLocation | |
| { | |
| CLLocationManager *locationManager = [[CLLocationManager alloc] init]; | |
| [locationManager startUpdatingLocation]; | |
| CLLocation *location = locationManager.location; | |
| NSLog(@"Current Location: Latitude(%f), Longitude(%f)",location.coordinate.latitude, location.coordinate.longitude); | |
| [locationManager release]; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| NSData *inData = /* your decrypted font-file data */; | |
| CFErrorRef error; | |
| CGDataProviderRef provider = CGDataProviderCreateWithCFData((CFDataRef)inData); | |
| CGFontRef font = CGFontCreateWithDataProvider(provider); | |
| if (! CTFontManagerRegisterGraphicsFont(font, &error)) { | |
| CFStringRef errorDescription = CFErrorCopyDescription(error) | |
| NSLog(@"Failed to load font: %@", errorDescription); | |
| CFRelease(errorDescription); | |
| } | |
| CFRelease(font); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| ''' | |
| optparse_testing.py | |
| some recipes from http://www.alexonlinux.com/pythons-optparse-for-human-beings | |
| ''' | |
| import optparse | |
| parser = optparse.OptionParser() | |
| # basics |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ps -p $$ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| - (CGRect)computePositionForWidget:(UIView *)widgetView fromView:(UIScrollView *)scrollView | |
| { | |
| CGRect frame; | |
| float scale; | |
| scale = scrollView.zoomScale; | |
| // compute the widget size based on the zoom scale | |
| frame.size.width = widgetView.frame.size.width * scale; | |
| frame.size.height = widgetView.frame.size.height * scale; |