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:4656584
Last active December 11, 2015 20:38
hacky pdf.js release notes gen
#! /usr/bin/env python
"""\
%prog [options] <last pull request number>
Helper script to generate release notes from github pull request titles.
"""
import json
import urllib2
@brendandahl
brendandahl / gist:6242756
Created August 15, 2013 17:25
Grep uncompressed PDF contents using pdftk.
find . -name "*.pdf" -exec sh -c "pdftk {} output - uncompress | grep -l 'searchString' --quiet && echo {}" \;
@brendandahl
brendandahl / gist:6383523
Created August 29, 2013 21:16
Create windows popup to attach debugger.
::MessageBox( NULL, L"Attach debugger now", L"ATTACH", MB_OK );
@brendandahl
brendandahl / uplift.sh
Last active December 22, 2015 00:58
Create mozilla-<beta/aurora> uplift patch for pdf.js.
#!/bin/sh
set -e
if [ "$#" -ne 4 ]; then
echo "Usage: $0 1_NAME 2_MESSAGE 3_BASELINE 4_CHERRY-PICK" >&2
echo "Example: $0 annot-ap-beta \"Bug 890259 - Use text widget annotation appearance stream if it is available.\" 4e83123 feafb39" >&2
echo "Run in your mozilla-<branch> directory." >&2
exit 1
fi
read -p "Did you 1) pop all hg patches, 2) update mozilla-<version>, 3) make sure pdf.js is clean?[y\n] " -n 1
@brendandahl
brendandahl / gist:7258065
Created October 31, 2013 22:11
Place to expose things in extensions for debugging.
Cc["@mozilla.org/appshell/appShellService;1"].getService(Ci.nsIAppShellService).hiddenDOMWindow
@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;