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
@SuppressLint("NewApi") | |
@SuppressWarnings("unchecked") | |
public static void executeTaskInParallel(@SuppressWarnings("rawtypes") AsyncTask task, Bundle params) { | |
if (MyUtil.hasHoneycomb()) { | |
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, params); | |
} else { | |
task.execute(params); | |
} | |
} |
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
import android.content.Context; | |
import android.os.AsyncTask; | |
import android.os.Bundle; | |
/** | |
* Use this class when you provide logics for background execution. | |
* | |
* Implement your code in onAsyncTaskExecute(). | |
* | |
* If you have to reuse your code, define a dedicated task class using BDAsyncTaskSkeleton class. |
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
import time | |
import datetime | |
date_string = '2013-03-07' | |
date = datetime.datetime.strptime(date_string, '%Y-%m-%d') | |
time.mktime(date.timetuple()) | |
==> 1362582000.0 |
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
import os | |
import tldextract | |
from tld import get_tld | |
from tld.utils import update_tld_names | |
TEST_COUNT = 1000000 | |
start_time = os.times()[4] | |
for i in range(TEST_COUNT): | |
e = tldextract.extract('http://forums.news.cnn.com:8080/a/b/c/') |
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
sudo pip install virtualenv-clone --upgrade |
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
stevedore.extension Could not load 'user_scripts': virtualenv-clone | |
stevedore.extension virtualenv-clone | |
Traceback (most recent call last): | |
File "/usr/local/lib/python2.7/site-packages/stevedore/extension.py", line 89, in _load_plugins | |
invoke_kwds, | |
File "/usr/local/lib/python2.7/site-packages/stevedore/extension.py", line 101, in _load_one_plugin | |
plugin = ep.load() | |
File "/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/distribute-0.6.40-py2.7.egg/pkg_resources.py", line 2030, in load | |
if require: self.require(env, installer) | |
File "/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/distribute-0.6.40-py2.7.egg/pkg_resources.py", line 2043, in require |
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
... | |
NSLog(@"%@", [self getSystemFontPath:18]); | |
NSLog(@"%s", [self getSystemFontPathCString:18]); | |
... | |
- (const char *)getSystemFontPathCString:(CGFloat)argFontSize | |
{ | |
NSString *path = [self getSystemFontPath:argFontSize]; | |
const char *path_cstring = [path cStringUsingEncoding:[NSString defaultCStringEncoding]]; | |
return path_cstring; |
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
import os | |
dir = [] | |
def listDirectory(directory): | |
for f in os.listdir(directory): | |
path0 = os.path.join(directory, f) | |
if os.path.isdir(path0): | |
dir.append(path0) | |
listDirectory(path0) |
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
for (UIView *view in self.navigationController.navigationBar.subviews) { | |
NSLog(@"%@", [[view class] description]); | |
LOG_EXPR([[view class] description]); | |
if ([[[view class] description] isEqualToString:@"UINavigationButton"]) { | |
[(UINavigationButton *)view setTintColor:[UIColor brownColor]]; | |
} | |
} |
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) clearNSURLConnectionCache | |
{ | |
NSURLCache *sharedCache = [[NSURLCache alloc] initWithMemoryCapacity:0 diskCapacity:0 diskPath:nil]; | |
[NSURLCache setSharedURLCache:sharedCache]; | |
[sharedCache release]; | |
} |