Skip to content

Instantly share code, notes, and snippets.

View jeksys's full-sized avatar

Eugene Yagrushkin jeksys

View GitHub Profile
@jeksys
jeksys / gist:3136241
Created July 18, 2012 13:33
FizzBuzz
int main() {
for( int i=1; i<=100; i++)
{
if(i%3==0)
printf("Fizz");
if(i%5==0)
printf("Buzz");
if(i%3!=0 && i%5!=0)
printf("%d",i);
@jeksys
jeksys / gist:2956352
Created June 19, 2012 20:27
UISearchBar custom background
for (id img in searchBar.subviews) {
if ([img isKindOfClass:NSClassFromString(@"UISearchBarBackground")]) {
[img removeFromSuperview];
}
}
[searchBar setSearchFieldBackgroundImage:[UIImage imageNamed:@"UI_searchbar.png"] forState:UIControlStateNormal];
searchView.backgroundColor = [UIColor clearColor];
for (UIView *subview in [[searchBar.subviews objectAtIndex:0] subviews]) {
subview.alpha = 0.0;
subview.backgroundColor = [UIColor clearColor];
@jeksys
jeksys / gist:2936429
Created June 15, 2012 13:19
UIToolBar backgrund image
UIImage *tabBackground = [[UIImage imageNamed:@"tab_bg"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)];
[[UITabBar appearance] setBackgroundImage:tabBackground];
@jeksys
jeksys / gist:2936420
Created June 15, 2012 13:15
custom UINavigationBar
UIImage *backgroundImage = [UIImage imageNamed:@"UI_navbar.png"];
[[UINavigationBar appearance] setBackgroundImage:backgroundImage
forBarMetrics:UIBarMetricsDefault];
UIImage *backButton = [[UIImage imageNamed:@"UI_backbutton.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0,0,0,0)];
[[UIBarButtonItem appearance] setBackButtonBackgroundImage:backButton forState:UIControlStateNormal
barMetrics:UIBarMetricsDefault];
[[UIBarButtonItem appearance] setBackButtonBackgroundImage:backButton forState:UIControlStateHighlighted
barMetrics:UIBarMetricsDefault];
[[UINavigationBar appearance] setTitleTextAttributes:
[NSDictionary dictionaryWithObjectsAndKeys:
@jeksys
jeksys / gist:2394945
Created April 15, 2012 21:41
timer debug macros
OTHER_CFLAGS = -DDEBUG=1
#define MARK CMLog(@"%s", __PRETTY_FUNCTION__);
#define CMLog(format, ...) NSLog(@"%s:%@", __PRETTY_FUNCTION__,[NSString stringWithFormat:format, ## __VA_ARGS__]);
CMLog(@"My iPhone is an %@, v %@", [[UIDevice currentDevice] model], [[UIDevice currentDevice] systemVersion]);
#define START_TIMER NSTimeInterval start = [NSDate timeIntervalSinceReferenceDate];
#define END_TIMER(msg) NSTimeInterval stop = [NSDate timeIntervalSinceReferenceDate]; CMLog([NSString stringWithFormat:@"%@ Time = %f", msg, stop-start]);
#if DEBUG==1
@jeksys
jeksys / gist:2065546
Created March 17, 2012 21:41
NSDate.localDate
NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
[dateFormatter setLocale:[NSLocale currentLocale]];
[dateFormatter setTimeStyle:NSDateFormatterNoStyle];
[dateFormatter setDateStyle:NSDateFormatterShortStyle];
@jeksys
jeksys / gist:2065535
Created March 17, 2012 21:40
NSNumber.Currency
NSNumberFormatter *numberFormatter = [[[NSNumberFormatter alloc] init] autorelease];
[numberFormatter setNumberStyle: NSNumberFormatterCurrencyStyle];
@jeksys
jeksys / gist:1961023
Created March 2, 2012 20:21
Key Frame Animation
-(IBAction)buttonPress:(id)sender
{
NSString *keyPath = @"anchorPoint.x";
CAKeyframeAnimation *kfa = [CAKeyframeAnimation animationWithKeyPath:keyPath];
[kfa setValues:[NSArray arrayWithObjects:
[NSNumber numberWithFloat:-.05],
[NSNumber numberWithFloat:.1],
[NSNumber numberWithFloat:-.1],
[NSNumber numberWithFloat:.1],
[NSNumber numberWithFloat:-.05],
#import <UIKit/UIKit.h>
@interface UITableViewCellEnterText : UITableViewCell<UITextFieldDelegate>{
UITextField *textField;
}
@property (nonatomic, retain) NSMutableDictionary *Value;
@property (nonatomic, readonly) NSString *StringValue;
@property (nonatomic, retain) UITextField *textField;
@jeksys
jeksys / UIColor+myColors.m
Created February 18, 2012 23:17
myColors
@interface UIColor (myColors)
+ (UIColor *)questListTableViewColor;
+ (UIColor *)defaultBackground;
+ (UIColor *)defaultBackgroundColor;
@end
@implementation UIColor (myColors)
+ (UIColor *)questListTableViewColor
{