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
// sample of using POCO's ThreadPool | |
#include "Poco/Runnable.h" | |
#include "Poco/ThreadPool.h" | |
#include <iostream> | |
using namespace std; | |
class Worker:public Poco::Runnable{ | |
public: |
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
#!/bin/sh | |
# This script will install a Git pre-push hook that prevents force pushing the master branch. | |
# Install in current Git repo: | |
# curl -fL https://gist.githubusercontent.com/stefansundin/d465f1e331fc5c632088/raw/install-pre-push.sh | sh | |
# Uninstall: | |
# rm .git/hooks/pre-push | |
# in each repository that you've added this to. | |
GITROOT=`git rev-parse --show-toplevel 2> /dev/null` |
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
#define UIViewParentController(__view) ({ \ | |
UIResponder *__responder = __view; \ | |
while ([__responder isKindOfClass:[UIView class]]) \ | |
__responder = [__responder nextResponder]; \ | |
(UIViewController *)__responder; \ | |
}) |
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
# Format for Radiotunnes channels | |
# Standard quality | |
# http://pub[1 -10].radiotunes.com:80/radiotunes_[channel name] | |
# example | |
http://pub6.radiotunes.com:80/radiotunes_tophits | |
# Low quality | |
# http://pub[1 -10].radiotunes.com:80/radiotunes_[channel name]_aac |
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
#define NSLog(FORMAT, ...) fprintf( stderr, "%s\n", [[NSString stringWithFormat:FORMAT, ##__VA_ARGS__] UTF8String]); |
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
static void printIvarsList(Class classType) { | |
printf("\n"); | |
do { | |
unsigned int count = 0; | |
Ivar* ivars = class_copyIvarList(classType, &count); | |
for(unsigned int i = 0; i < count; ++i) { | |
printf("%s::%s %s\n", [classType description].UTF8String, ivar_getName(ivars[i]), ivar_getTypeEncoding(ivars[i])); | |
} | |
free(ivars); |
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)initialize { | |
Class metaClass = objc_getMetaClass(class_getName(self)); | |
SEL selector = @selector(description); | |
IMP implementation = imp_implementationWithBlock(^NSString *(){ | |
return @">>>added"; | |
}); | |
Method method = class_getClassMethod(metaClass, selector); |
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
CGPoint points[num]; | |
CGContextRef ctx = [[NSGraphicsContext currentContext] graphicsPort]; | |
CGMutablePathRef path = CGPathCreateMutable(); | |
CGPathAddLines(path, NULL, points, num); | |
if (closePath) CGPathCloseSubpath(path); | |
CGContextAddPath(ctx,path); | |
CGContextStrokePath(ctx); |
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
NSString *frameworksPath = @"/System/Library/Frameworks"; | |
NSBundle *bundle = [NSBundle bundleWithPath:[frameworksPath stringByAppendingPathComponent:@"AVKit.framework"]]; | |
void* handle = dlopen(bundle.executablePath.UTF8String, RTLD_NOW); | |
dlclose(handle); | |
Class class = NSClassFromString(@"AVPlayerView"); | |
id instance = [[class alloc] init]; | |
NSLog(@"%@ %@", class, instance); |
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
-- Using lua_replace(L, LUA_GLOBALSINDEX); | |
-- to change the globals for a thread. | |
#include "lua.h" | |
#include "lauxlib.h" | |
#include "lualib.h" | |
static int report (lua_State *L, int status) { | |
const char *msg; | |
if (status) { |