Skip to content

Instantly share code, notes, and snippets.

import sys
import os
import urllib
import urllib2
from bs4 import BeautifulSoup
def report(count, block_size, total_size):
"""Report save progression."""
progress_size = int(count * block_size) / (1024 * 1024)
percent = int(count * block_size * 100 / total_size)
@ewangke
ewangke / BlockCheatsheet.m
Created September 28, 2013 09:44 — forked from twobitlabs/gist:4226365
Block cheat sheet for objective-c
// http://cocoawithlove.com/2009/10/ugly-side-of-blocks-explicit.html has a nice breakdown of the syntax--it helps to think of the ^ as similar to a pointer dereference symbol *
// block typedef:
typedef void(^Block)();
typedef void(^ConditionalBlock)(BOOL);
typedef NSString*(^BlockThatReturnsString)();
typedef NSString*(^ConditionalBlockThatReturnsString)(BOOL);
// block property with typedef:
@ewangke
ewangke / HD.txt
Created September 23, 2013 07:45 — forked from lexrus/HD.txt
WWDC 2013 Session Video download scripts
http://devstreaming.apple.com/videos/wwdc/2013/710xfx3xn8197k4i9s2rvyb/710/710-HD.mov?dl=1
http://devstreaming.apple.com/videos/wwdc/2013/202xdx2x47ezp1wein/202/202-HD.mov?dl=1
http://devstreaming.apple.com/videos/wwdc/2013/200xdx2x35e1pxiinm/200/200-HD.mov?dl=1
http://devstreaming.apple.com/videos/wwdc/2013/413xdx5x97itb5ek4yex3r7/413/413-HD.mov?dl=1
http://devstreaming.apple.com/videos/wwdc/2013/612xax4xx65z1ervy5np1qb/612/612-HD.mov?dl=1
http://devstreaming.apple.com/videos/wwdc/2013/221xex4xxohbllf4hblyngt/221/221-HD.mov?dl=1
http://devstreaming.apple.com/videos/wwdc/2013/220xbx4xipaxfd1tggxuoib/220/220-HD.mov?dl=1
http://devstreaming.apple.com/videos/wwdc/2013/711xcx4x8yuutk8sady6t9f/711/711-HD.mov?dl=1
http://devstreaming.apple.com/videos/wwdc/2013/404xbx2xvp1eaaqonr8zokm/404/404-HD.mov?dl=1
http://devstreaming.apple.com/videos/wwdc/2013/505xbx4xrgmhwby4oiwkrpp/505/505-HD.mov?dl=1
@ewangke
ewangke / UDIDMigration.m
Created June 27, 2013 13:39
UDID migration for unique identifier within a specific app
NSString *UUID = [[NSUserDefaults standardUserDefaults] objectForKey:kApplicationUUIDKey];
if (!UUID) {
CFUUIDRef uuid = CFUUIDCreate(NULL);
UUID = (__bridge_transfer NSString *)CFUUIDCreateString(NULL, uuid);
CFRelease(uuid);
[[NSUserDefaults standardUserDefaults] setObject:UUID forKey:kApplicationUUIDKey];
[[NSUserDefaults standardUserDefaults] synchronize];
}
@ewangke
ewangke / ChartboostSDK.podspec
Created April 18, 2013 09:04
Advanced CocoaPods - Local Dependency
Pod::Spec.new do |s|
s.name = 'ChartboostSDK'
s.version = '3.1.1'
s.license = 'Commercial'
s.summary = 'ChartboostSDK for showing ads and more apps pages, and tracking analytics and in-app purchase revenue.'
s.homepage = 'https://chartboost.com/'
s.author = { 'Chartboost' => 'https://chartboost.com/' }
s.source = { :git => '~/Desktop/ChartboostSDK' }
s.platform = :ios
s.source_files = '**/*.h'
@ewangke
ewangke / PlayHavenSDK.podspec
Last active December 16, 2015 09:09
Advanced CocoaPods - Local Dependency
Pod::Spec.new do |s|
s.name = 'PlayHavenSDK'
s.version = '1.12.1'
s.license = 'MIT'
s.summary = 'PlayHaven is a real-time mobile game marketing platform to help you take control of the business of your games.'
s.homepage = 'http://playhaven.com'
s.author = { 'Sam Stewart' => 'sam@playhaven.com' }
s.source = { :git => 'https://github.com/playhaven/sdk-ios.git', :tag => '1.12.1' }
s.description = "PlayHaven is a real-time mobile game marketing platform to help you take control of the business of your games. Acquire, retain, re-engage, and monetize your players with the help of PlayHaven's powerful marketing platform. Integrate once and embrace the flexibility of the web as you build, schedule, deploy, and analyze your in-game promotions and monetization in real-time through PlayHaven's easy-to-use, web-based dashboard. An API token and secret is required to use this SDK. These tokens uniquely identify your app to PlayHaven and prevent others from making requests to the API on you
@ewangke
ewangke / requirements.txt
Created July 28, 2012 10:12
bottle with pymongo and mongoengine on AppFog
bottle
pymongo
mongoengine