Skip to content

Instantly share code, notes, and snippets.

@darkseed
darkseed / hubbub.py
Created February 26, 2010 16:15 — forked from Arachnid/hubbub.py
from google.appengine.api import urlfetch
from google.appengine.api import xmpp
from google.appengine.ext import db
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
from google.appengine.ext.webapp import xmpp_handlers
import base64
import feedparser
import logging
// Provides a device_scale class on iOS devices for scaling user
// interface elements relative to the current zoom factor.
//
// http://37signals.com/svn/posts/2407-device-scale-user-interface-elements-in-ios-mobile-safari
// Copyright (c) 2010 37signals.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
//
// NSString+FileTextEncodingAttribute.h
// Adapted from http://github.com/scrod/nv/blob/master/NSString_NV.m
//
#import <Foundation/Foundation.h>
#include <sys/xattr.h>
@interface NSString (FileTextEncodingAttribute)
*.pbxproj -crlf -diff -merge
@darkseed
darkseed / Iphone-idleTimer.m
Created January 10, 2011 02:32
Disable/Enable the iOS idle times to prevent screen dimming
// Disable
[[UIApplication sharedApplication] setIdleTimerDisabled:YES];
// Enable
[[UIApplication sharedApplication] setIdleTimerDisabled:NO];
@darkseed
darkseed / viewDidunload_freememory.m
Created January 10, 2011 02:36
ViewDidUnload and Low Memory Warnings
// Code taken from http://intelliobjects.com/ErnieSvehla/?p=123
-(void)viewDidUnload {
self.label1 = nil;
self.label2 = nil;
self.view1 = nil;
self.textView1 = nil;
self.view2 = nil;
[super viewDidUnload];
}
@darkseed
darkseed / Fadeout+default.m
Created January 14, 2011 17:22
Fadeout default.png
- (void)hideLoadingDefaultViewDidStop
{
    loadingDefaultView.hidden = YES;
}
 
- (void)viewDidAppear:(BOOL)animated
{
    if (!loadingDefaultView.hidden)
    {
        [UIView beginAnimations:@"Hide loading screen" context:nil];
NSFetchRequest *request = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"YourEntityName" inManagedObjectContext:managedObjectContext];
[request setEntity:entity];
// retrive the objects with a given value for a certain property
NSPredicate *predicate = [NSPredicate predicateWithFormat: @"property == %@", value];
[request setPredicate:predicate];
// Edit the sort key as appropriate.
NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"yourSortKey" ascending:YES];
NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:sortDescriptor, nil];
- (void) deleteAllObjects: (NSString *) entityDescription {
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName:entityDescription inManagedObjectContext:_managedObjectContext];
[fetchRequest setEntity:entity];
NSError *error;
NSArray *items = [_managedObjectContext executeFetchRequest:fetchRequest error:&error];
[fetchRequest release];
@implementation UINavigationBar(Background)
-(void)drawRect:(CGRect)rect{
UIImage *navBgImage = [UIImage imageNamed:@"nav_bg.jpg"];
[navBgImage drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
}
@end