Skip to content

Instantly share code, notes, and snippets.

View brendandahl's full-sized avatar

Brendan Dahl brendandahl

  • Google
  • San Francisco, CA
View GitHub Profile
@brendandahl
brendandahl / gist:9061968
Last active August 29, 2015 13:56
Windows Like MessageBox for OSX
#include <CoreFoundation/CoreFoundation.h>
#define IDOK 1
#define IDCANCEL 2
int MessageBox( char* header, char* message, unsigned long message_type )
{
//convert the strings from char* to CFStringRef
CFStringRef header_ref = CFStringCreateWithCString( NULL, header, strlen(header) );
CFStringRef message_ref = CFStringCreateWithCString( NULL, message, strlen(message) );
@brendandahl
brendandahl / gist:9104435
Created February 20, 2014 00:20
Disable B2G Remote Debugging Prompt

adb shell

stop b2g

cd /data/b2g/mozilla/*.default/

echo 'user_pref("devtools.debugger.prompt-connection", false);' >> prefs.js

start b2g

@brendandahl
brendandahl / gist:10312526
Created April 9, 2014 20:40
PDF.js Release Plan
  1. Update moz central
  2. Move BETA_VERSION to STABLE_VERSION in make.js
  3. Use version number from moz central for BETA_VERSION
  4. Create a PR with above changes
  5. git checkout <BETA_VERSION>
  6. Run node make dist to generate the zip
  7. Create github release 2. add release notes 2. attach zip generated from above
  8. mark as pre-release
/**
* Searches the functions defined in the `fns` param and replaces any arguments
* that have the name 'callback' or 'cb' with a wrapped callback that will
* record how long it took for the callback to be invoked and how many times
* it was called. To view the information recorded call window.timeDump`name`();
*
*
* @param {string} name Unique name for the stats.
* @param {Object} fns All the functions that will have callbacks wrapped.
* @return {Object} An object with the same keys as the `fns` object, but with
@brendandahl
brendandahl / gist:b0439a7178991b3790a4
Last active August 29, 2015 14:21
Dump J2ME.js Context Frames
var frames = $.ctx.frames;
var out = "";
for (var i = 0; i < frames.length; i++) {
if (frames[i].methodInfo) {
out += frames[i].methodInfo.implKey + "\n";
} else {
out += "marker\n";
}
}
out;
@brendandahl
brendandahl / print_to_browser_console.cpp
Created September 18, 2015 16:35
Print to the browser console, works in fennec and desktop.
#include "nsIConsoleService.h"
void someFunction() {
uint32_t loadType = 25;
nsCOMPtr<nsIConsoleService> consoleService = do_GetService(NS_CONSOLESERVICE_CONTRACTID);
if (consoleService) {
nsAutoCString message(nsPrintfCString("!!!!!!!!!!!!!!!!!!! LOAD TYPE %X", loadType));
consoleService->LogStringMessage(NS_ConvertUTF8toUTF16(message).get());
}
@brendandahl
brendandahl / gist:f0f952e27dc66bb61391
Created September 18, 2015 16:45
nsDocShellLoadTypes
LOAD_NORMAL: 1
LOAD_NORMAL_REPLACE: 800001
LOAD_NORMAL_EXTERNAL: 10000001
LOAD_HISTORY: 4
LOAD_NORMAL_BYPASS_CACHE: 1000001
LOAD_NORMAL_BYPASS_PROXY: 2000001
LOAD_NORMAL_BYPASS_PROXY_AND_CACHE: 3000001
LOAD_NORMAL_ALLOW_MIXED_CONTENT: 21000001
LOAD_RELOAD_NORMAL: 2
LOAD_RELOAD_BYPASS_CACHE: 1000002
@brendandahl
brendandahl / gist:1953439
Created March 1, 2012 21:43 — forked from jviereck/gist:1944694
About Printing On The Web

Version: 29-Feb-2012
Author: Julian Viereck <jviereck (dot) dev (at) googlemail (dot) com>

About Printing On The Web

tl;dr: Printing on the web is very limited. There is CSS3 Paged Media "Last Call" spec, that improves things, but has not been adopted by browsers yet. How about creating a new "WebPrintAPI" that does not use the DOM but is more like a simple canvas API? Would such a simple API be helpful for your printing needs on the web, or is it just suitable for very special use cases like PDF.JS?

About this document

This document is intended to sum up the current state of printing using the open web platform. It should serve as a foundation for discussion on how to get proper printing support added to the PDF.JS project (adding printing support is tracked here).

@brendandahl
brendandahl / f1040.otf.base64
Created March 6, 2012 23:44
Failing CID Font
data:font/opentype;base64,T1RUTwAJAIAAAwAQQ0ZGIGMPZ3YAAACcAAACVk9TLzJD0CsGAAAC9AAAAGBjbWFw4ObhHQAAA1QAAABCaGVhZKsnT1UAAAOYAAAANmhoZWEC/wHkAAAD0AAAACRobXR4AAAAAAAAA/QAAAAQbWF4cAAEUAAAAAQEAAAABm5hbWXnhlCzAAAEDAAAAoJwb3N0AAMAAAAABpAAAAAgAQAEAgABAQEjTU1YUURRK1VuaXZlcnNhbFN0ZC1OZXdzd2l0aENvbW1QaQABAQE3+B0B+BcEhPt3+nH5kAUdAAACKA8dAAABnRH4HgwV+Bv4HIsMHu8MIh0AAAIvDCQdAAACUQwlAAUCAAEABgAOAP8BDAEnQWRvYmVJZGVudGl0eUNvcHlyaWdodCAxOTg4LCAxOTk1LCAyMDAyICwgMjAwM0Fkb2JlIFN5c3RlbXMgSW5jb3Jwb3JhdGVkLiBBbGwgUmlnaHRzIFJlc2VydmVkLiBVbml2ZXJzYWwgaXMgYSB0cmFkZW1hcmsgb2YgSGVpZGVsYmVyZ2VyIERydWNrbWFzY2hpbmVuIEFHLCBleGNsdXNpdmVseSBsaWNlbnNlZCB0aHJvdWdoIExpbm90eXBlIExpYnJhcnkgR21iSCwgYW5kIG1heSBiZSByZWdpc3RlcmVkIGluIGNlcnRhaW4ganVyaXNkaWN0aW9ucy4vRlNUeXBlIDQgZGVmVW5pdmVyc2FsU3RkLU5ld3N3aXRoQ29tbVBpAAAABAEBTlFqhPiIi7347L0Bi734JL0DiwT4iPlQ/IgG9477xRX7PveTBffoBvsg+8AV9z73kwX8kgf8Bl4V9z73k/c++5MF/Ab4vxX3PvuT+z77kwUO96wO+nz7cvpkAZf6ZAP6cPeeFf5k+HwF/mQHDvp8+2j6ZAGX+mQD+nD7aBX8fPpk/Hz+ZAUOAAABAGEAYwABAQEQHQAAAA4dAAACQxL4Hwwmi4v5iYsG+3eLB7sKuw
@brendandahl
brendandahl / gist:2038213
Created March 14, 2012 17:53
pdf.js stats format
[
{
"browser": "firefox",
"page": 1,
"pdf": "tracemonkey-eq",
"round": 0,
"stats": [
{
"end": 1331675927704,
"name": "Page Request",