Skip to content

Instantly share code, notes, and snippets.

View gekitz's full-sized avatar
🌴
On vacation

Georg Kitz gekitz

🌴
On vacation
View GitHub Profile
@gekitz
gekitz / gist:1582190
Created January 9, 2012 09:34
Memory Warning Fake
-(void) performFakeMemoryWarning {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
SEL memoryWarningSel = @selector(_performMemoryWarning);
if ([[UIApplication sharedApplication] respondsToSelector:memoryWarningSel]) {
[[UIApplication sharedApplication] performSelector:memoryWarningSel];
NSLog(@"Memory Warning!!");
}
[pool release];
}
@gekitz
gekitz / gist:2624119
Created May 6, 2012 20:04
Section Header Button
- (id)initWithFrame:(CGRect)frame {
    if ((self = [super initWithFrame:frame])) {
                UIImage *image = [[SMImageCacher instance] imageWithName:@"sectionHeader"];
                self.textPadding = UIEdgeInsetsMake(0, 10, 0, 90);
                self.font = [UIFont boldSystemFontOfSize:17];
                self.textColor = [UIColor whiteColor];
                self.backgroundColor = [UIColor colorWithPatternImage:image];
                self.shadowOffset = CGSizeMake(0, 1);
                self.shadowColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
                self.userInteractionEnabled = YES;
Making right turns on red signals after stopping (and ensuring the path is clear of pedestrians and oncoming traffic) is allowed in most states, unless there is a specific restriction posted at the intersection or the traffic lights show a red arrow in place of the standard red light. Some areas will allow you to make a left turn on red going from a one-way street onto another one-way street. (Note: There is no "Right on Red" in New York City.)
@gekitz
gekitz / UIImage-Addition.m
Created September 11, 2012 11:46
Sample Method Swizzle
+ (void)initialize
{
NSError *error = nil;
[[self class] jr_swizzleClassMethod:@selector(imageNamed:) withClassMethod:@selector(gk_imageNamed:) error:&error];
}
+ (UIImage *)gk_imageNamed:(NSString *)str
{
UIImage *image = [UIImage gk_imageNamed:str];
if (!image && [str rangeOfString:@".jpg"].location == NSNotFound) {
ladidas test
@gekitz
gekitz / perfect.txt
Created September 11, 2012 12:50
The perfect gist
this is the perfect gist
@gekitz
gekitz / generate_tags.rb
Created September 22, 2012 19:39
This gist shows a possibility to generate tag sites out of your post's tags
module Jekyll
class TagPage < Page
def initialize(site, base, dir, tag)
@site = site
@base = base
@dir = dir
@name = 'index.html'
self.process(@name)
---
layout: default
---
<h2 class="tag">{{ page.title }}</h2>
{% for post in site.tags[page.tag] %}
<div class="tag_entry">
<h3>
<a class="content_head" href="{{ post.url }}">{{ post.title }}</a>
</h3>
<div>
@gekitz
gekitz / gist:6145781
Created August 3, 2013 08:57
Auto Layout Question
What I want to have is the following layout
-5-[label with flexible width]->=5-[uiimageview with fix width]-5-
the problem is the >= 5 in the middle is always treated as a 5 instead of a flexible width which should be bigger than 5.
My visual constraint looks like this:
@"|-(5)-[_usernameLabel]-(>=5)-[_userImageView(34)]-5-|"
Anyone any ideas how to achive the layout I want?
@gekitz
gekitz / sample.m
Last active December 21, 2015 10:19
const char *attributes = "T@\"DeliveryPlatform\",&,D,N";
const char *ret;
char buffer[1 + strlen(attributes)];
strcpy(buffer, attributes);
char *state = buffer, *attribute;
while ((attribute = strsep(&state, ",")) != NULL) {
if (attribute[0] == 'T') {
ret = (const char *)[[NSData dataWithBytes:(attribute + 3) length:strlen(attribute) - 4] bytes];
}
}