Skip to content

Instantly share code, notes, and snippets.

View yeonsh's full-sized avatar

Seunghoon Yeon yeonsh

View GitHub Profile
@yeonsh
yeonsh / Capture OpenGL ES View as an Image
Created January 30, 2011 21:27
Capture OpenGL ES View as an Image
- (UIImage*)snapshot:(UIView*)eaglview
{
// Get the size of the backing CAEAGLLayer
GLint backingWidth, backingHeight;
glBindRenderbufferOES(GL_RENDERBUFFER_OES, _colorRenderbuffer);
glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &backingWidth);
glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &backingHeight);
NSInteger x = 0, y = 0, width = backingWidth, height = backingHeight;
NSInteger dataLength = width * height * 4;
-(BOOL) setupFetchedResultsControllerForEntity:(NSString *)argEntityName withSortKey:(NSString *)argSortKey
{
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem;
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
// Configure the request's entity, and optionally its predicate.
NSEntityDescription *entityDescription = [NSEntityDescription entityForName:argEntityName inManagedObjectContext:self.managedObjectContext];
[fetchRequest setEntity:entityDescription];
@yeonsh
yeonsh / searchButtonPressed.m
Created April 5, 2011 13:38
searchButtonPressed
-(void) searchButtonPressed
{
[self.searchDisplayController setActive:YES animated:YES];
[self.searchDisplayController.searchBar becomeFirstResponder];
}
@yeonsh
yeonsh / clearNSURLConnectionCache
Created April 10, 2011 11:29
NSURLConnection의 Cache 삭제
-(void) clearNSURLConnectionCache
{
NSURLCache *sharedCache = [[NSURLCache alloc] initWithMemoryCapacity:0 diskCapacity:0 diskPath:nil];
[NSURLCache setSharedURLCache:sharedCache];
[sharedCache release];
}
@yeonsh
yeonsh / gist:962129
Created May 9, 2011 06:09
Change UINavigationBar Button Color
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]];
}
}
@yeonsh
yeonsh / listdir.py
Created January 25, 2013 04:48
List directories only under given directory
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)
@yeonsh
yeonsh / gist:5791444
Last active December 18, 2015 13:39
Find file path of system font on OS X
...
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;
@yeonsh
yeonsh / gist:6833951
Created October 4, 2013 22:32
OS X Mavericks GM Seed로 업데이트한 후
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
sudo pip install virtualenv-clone --upgrade
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/')