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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>My awesome app</title> | |
</head> | |
<body> | |
<h2>beta builds</h2> | |
<a href="itms-services://?action=download-manifest&url=http://dl.dropbox.com/u/1001/manifest.plist">Awesome App v 0.0.16</a></body> | |
<h2>alpha builds</h2> |
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
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>items</key> | |
<array> | |
<dict> | |
<key>assets</key> | |
<array> | |
<dict> |
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) loadHistory { | |
CGFloat oldOffsetReversed = self.collectionView.contentSize.height - self.collectionView.contentOffset.y; | |
NSUInteger pageSize = [self fetchNextPage]; //reloadData is called inside | |
[self.view layoutIfNeeded]; | |
CGFloat offset = self.collectionView.contentSize.height - oldOffsetReversed; | |
self.collectionView.contentOffset = CGPointMake(self.collectionView.contentOffset.x, offset); | |
} |
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
// MyBlockClass.h | |
@interface MyBlockClass : NSObject | |
- (id)initView:(UIScrollView *)scrollView withDataHandler:(void (^) (int pageNumber))handler; | |
@end | |
// MyBlockClass.m | |
@interface MyBlockClass () | |
@property (nonatomic, copy) void (^getDataOnPage)(int pageNumber); | |
@end |
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)loadView{ | |
// cannot set the height here because the data has not been loaded into the tableview yet | |
// so I just set it to zero | |
UITableView *tableView = [[UITableView alloc] initWithFrame:CGRectZero | |
style:UITableViewStylePlain]; | |
} | |
// set the custom height here | |
- (void)viewWillLayoutSubviews{ | |
self.tableView.frame = CGRectMake(0, 0, [self widthForView], [self heightForView]); |
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
// add this in viewDidLoad | |
// Configure Refresh Control | |
UIRefreshControl *refreshControl = [[UIRefreshControl alloc] init]; | |
[refreshControl addTarget:self action:@selector(refresh:) forControlEvents:UIControlEventValueChanged]; | |
[self.collectionView addSubview:refreshControl]; | |
// create an envent | |
#pragma mark Events | |
- (void) refresh:(id)sender { | |
[self loadData]; // create your own function to load the data, and at the end call [self.collecitonView reloadData] |
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
states = @{ | |
@"AL": @"Alabama", | |
@"AK": @"Alaska", | |
@"AZ": @"Arizona", | |
@"AR": @"Arkansas", | |
@"CA": @"California", | |
@"CO": @"Colorado", | |
@"CT": @"Connecticut", | |
@"DE": @"Delaware", | |
@"FL": @"Florida", |
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
// AppDelegate.h | |
@interface AppDelegate : UIResponder <UIApplicationDelegate, UITabBarControllerDelegate> | |
@property (strong, nonatomic) UIWindow *window; | |
@property (nonatomic, retain) UITabBarController *tabBarController; | |
@end | |
// AppDelegate.m | |
@implementation AppDelegate |
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
from django.core.files.temp import NamedTemporaryFile | |
from django.core.files.base import ContentFile | |
from django.core.files.storage import default_storage | |
# if you actually need the file | |
class MyMixin(object): | |
def pre_save(self, obj): | |
default_storage.save('/Users/2ndmouse/code/media/a.jpg', ContentFile(self.request.FILES['image'].read())) | |
# download online file and save it to image field |
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
# in view | |
>>> import datetime | |
>>> datetime.datetime.now() | |
datetime.datetime(2014, 3, 14, 20, 26, 33, 431064) | |
>>> a = datetime.datetime.now() | |
>>> from django.contrib.humanize.templatetags.humanize import naturalday, naturaltime | |
>>> naturalday(a) | |
u'today' | |
>>> naturalday(a) | |
u'today' |
NewerOlder