Skip to content

Instantly share code, notes, and snippets.


Robert Bu darkfall

View GitHub Profile
darkfall / gist:1656050
Created Jan 22, 2012
A simple class that converts a image to a icon in c# without losing image color data, unlike System.Drawing.Icon; ico with png data requires Windows Vista or above
View gist:1656050
class PngIconConverter
/* input image with width = height is suggested to get the best result */
/* png support in icon was introduced in Windows Vista */
public static bool Convert(System.IO.Stream input_stream, System.IO.Stream output_stream, int size, bool keep_aspect_ratio = false)
System.Drawing.Bitmap input_bit = (System.Drawing.Bitmap)System.Drawing.Bitmap.FromStream(input_stream);
if (input_bit != null)
int width, height;
darkfall / gist:2760319
Created May 21, 2012
Cocos2dx PopScene with Transition
View gist:2760319
template<typename T>
void CCDirector::popSceneWithTransition(float t) {
CCAssert(m_pRunningScene != NULL, "running scene should not null");
unsigned int c = m_pobScenesStack->count();
if (c == 0) {
darkfall / gist:6074996
Created Jul 24, 2013
Some libCef3 and CefGlue notes
View gist:6074996
CefClient -> Handlers
RequestHandler: can be used as QNetworkAccessManager
-> OnBeforeResourceLoad(.., .., request)
-> request.GetHeaderMap()
-> request.Url
ContextMenuHandler: handle context menu here
-> OnBeforeContextMenu(.., .., .., model)
-> model.AddItem(id, caption)
darkfall / libcef notes
Created Dec 30, 2012
Reading notes of libcef & chromium
View libcef notes
CefBrowser::CreateBrowser ->
CreateBrowserHelper ->
PostTask to UI Thread ->
CefBrowser::CreateBrowserSync(window_info, client_handler, url, settings) []
-> new CefBrowserImpl(window_info, settings, opener{NativeView = null}, client_handler)
-> BrowserWebViewDelegate(this)
darkfall / gist:3929023
Created Oct 22, 2012
ukn static run code/call func
View gist:3929023
#define UKN_STATIC_RUN_CODE_I(name, code) \
namespace { \
static struct name { \
name() { \
code; \
} \
} UKN_JOIN(g_, name); \
#define UKN_STATIC_RUN_CODE(code) \
darkfall / gist:13001c901edf0dc9fb85
Last active Aug 29, 2015
get objc subclasses via private runtime info
View gist:13001c901edf0dc9fb85
#include <objc/objc-runtime.h>
// from objc_runtime_new.h with some simplifications
#if __LP64__
typedef uint32_t mask_t;
#define FAST_DATA_MASK 0x00007ffffffffff8UL
typedef uint64_t mask_t;
#define FAST_DATA_MASK 0xfffffffcUL
darkfall / gist:11047818
Created Apr 18, 2014
Get component test
View gist:11047818
#include <vector>
#include <set>
struct TypeDescriptor {
TypeDescriptor* parent;
const char* name;
typedef std::set<TypeDescriptor*> ChildList;
ChildList children;
You can’t perform that action at this time.