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 / slimer.js
Created February 18, 2017 02:00
Snapshot a page with slimer.js
var webpage = require('webpage').create();
webpage
.open('http://localhost:8000')
.then(function() {
// store a screenshot of the page
webpage.viewportSize = { width:650, height:320 };
webpage.render('/home/bdahl/projects/gecko/page.png',
{ onlyViewport:true });
slimer.exit();
});
@brendandahl
brendandahl / linking_error_debug.md
Last active January 5, 2017 20:04
Debugging a Linking Error
  1. Is library referenced in the link command?

  2. Does the library have the method?

nm <library path> | grep -i <method name> | grep -v " U "

Note: if the symbol type is lowercase 't', then the symbol is not exported!

  1. Are both libraries/executables compiled with or without RTTI?
change base_path and my_symbol
for lib in $(find base_path -name \*.a) ; do echo $lib ; nm $lib | grep -i my_symbol | grep -v " U " ; done
@brendandahl
brendandahl / cinnabar-to-gecko-dev.md
Last active August 10, 2016 18:58
Find gecko-dev sha from cinnabar sha by date

Replace ../gecko with path to your cinnabar gecko repo and da9da17db2c68140ad873d2701c3c05162ca8443 with your cinnabar sha

[positron]$ git log gecko/master --format="%h %ci" --max-count=1000 | grep "$(git -C ../gecko show -s --format=%ci da9da17db2c68140ad873d2701c3c05162ca8443)"
@brendandahl
brendandahl / Main.cpp
Last active July 8, 2016 23:09
Attempt at adding an observer before XRE_main runs
// in main.cpp
#include "nsIObserver.h"
#include "nsIObserverService.h"
#include "nsServiceManagerUtils.h"
class nsBlahObserver final : public nsIObserver
{
public:
@brendandahl
brendandahl / positron_electron_notes.md
Created July 6, 2016 21:51
Notes from Integrating SpiderNode into Positron

First spider monkey context creation:

thread #1: tid = 0x7007eb, 0x0000000109aa8386 XUL`JSContext::init(this=0x0000000117fea000, maxBytes=33554432, maxNurseryBytes=16777216) + 22 at jscntxt.cpp:93, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
    frame #0: 0x0000000109aa8386 XUL`JSContext::init(this=0x0000000117fea000, maxBytes=33554432, maxNurseryBytes=16777216) + 22 at jscntxt.cpp:93
    frame #1: 0x0000000109aa8409 XUL`js::NewContext(maxBytes=33554432, maxNurseryBytes=16777216, parentRuntime=0x0000000000000000) + 73 at jscntxt.cpp:106
    frame #2: 0x00000001099fa9a8 XUL`JS_NewRuntime(maxbytes=33554432, maxNurseryBytes=16777216, parentRuntime=0x0000000000000000) + 200 at jsapi.cpp:457
  * frame #3: 0x00000001026eed79 XUL`mozilla::CycleCollectedJSRuntime::Initialize(this=0x0000000100763000, aParentRuntime=0x0000000000000000, aMaxBytes=33554432, aMaxNurseryBytes=16777216) + 185 at CycleCollectedJSRuntime.cpp:510
    frame #4: 0x0000000103b80093 XUL`XPCJSRuntime::Initialize(this=0x000000
script topsrcdir = "/Users/bdahl/projects/gecko"
command alias gk command source -s true "/Users/bdahl/projects/gecko/.lldbinit"
@brendandahl
brendandahl / print_on_android.cpp
Created February 17, 2016 19:16
Print to logcat on android.
#include <android/log.h>
__android_log_print(ANDROID_LOG_INFO, "ZZZ", "!!!!!!!!!!!!!!!!!!! HERE 1\n");
nsAutoCString url;
aPresContext->Document()->GetDocumentURI()->GetSpec(url);
printf("nsMediaQueryResultCacheKey::Matches [url = %s]\n", url.get());
nsAutoString autoString;
// mName is the atom
(*(entry->mFeature->mName))->ToString(autoString);
printf("nsMediaQueryResultCacheKey::Matches %s\n", NS_ConvertUTF16toUTF8(autoString).get());