Skip to content

Instantly share code, notes, and snippets.

View darkfall's full-sized avatar

Robert Bu darkfall

View GitHub Profile
@darkfall
darkfall / gist:13001c901edf0dc9fb85
Last active January 24, 2021 10:03
get objc subclasses via private runtime info
#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
#else
typedef uint64_t mask_t;
#define FAST_DATA_MASK 0xfffffffcUL
@darkfall
darkfall / gist:11047818
Created April 18, 2014 14:46
Get component test
#include <vector>
#include <set>
struct TypeDescriptor {
TypeDescriptor* parent;
const char* name;
typedef std::set<TypeDescriptor*> ChildList;
ChildList children;
@darkfall
darkfall / gist:6074996
Created July 24, 2013 21:59
Some libCef3 and CefGlue notes
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
darkfall / libcef notes
Created December 30, 2012 15:53
Reading notes of libcef & chromium
Cef1:
CefBrowser::CreateBrowser ->
CreateBrowserHelper ->
PostTask to UI Thread ->
CefBrowser::CreateBrowserSync
CefBrowser::CreateBrowserSync(window_info, client_handler, url, settings) [browser_impl.cc]
-> new CefBrowserImpl(window_info, settings, opener{NativeView = null}, client_handler)
-> BrowserWebViewDelegate(this)
@darkfall
darkfall / gist:3929023
Created October 22, 2012 00:04
ukn static run code/call func
#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
darkfall / gist:2760319
Created May 21, 2012 02:33
Cocos2dx PopScene with Transition
template<typename T>
void CCDirector::popSceneWithTransition(float t) {
CCAssert(m_pRunningScene != NULL, "running scene should not null");
m_pobScenesStack->removeLastObject();
unsigned int c = m_pobScenesStack->count();
if (c == 0) {
end();
}
@darkfall
darkfall / gist:1656050
Created January 22, 2012 07:15
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
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;