Skip to content

Instantly share code, notes, and snippets.

@kewisch
kewisch / TracedRequest.js
Created October 2, 2014 14:20
Monitor all http(s) network requests using the Mozilla Platform
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
var allRequests = [];
/**
* Add the following function as a request observer:
* Services.obs.addObserver(httpObserver, "http-on-examine-response", false);
*
var x11 = require('x11');
var PNG = require('png-js');
var bl = require('bl');
require('child_process').exec('locate png | grep 48').stdout.pipe(bl(function(err, files) {
var pngNames = files.toString().split('\n');
var pngIndex = 0;
x11.createClient(function(err, display) {
@lukewagner
lukewagner / ArrayBuffer.transfer
Created November 13, 2014 23:38
ArrayBuffer.transfer strawman
Proposal
--------
The proposal is to add a static ArrayBuffer.transfer(oldBuffer [, newByteLength]). This
method returns a new ArrayBuffer whose contents are taken from oldBuffer.[[ArrayBufferData]]
and then either truncated or zero-extended to be newByteLength. This operation leaves
oldBuffer in a detached state. If newByteLength is undefined, oldBuffer.byteLength is
used.
var buf1 = new ArrayBuffer(40);
@alex-spataru
alex-spataru / Opening files using system events in Qt
Last active August 29, 2015 14:14
Open files from system request on Mac [Qt]
#include <QEvent>
#include <QApplication>
// Create a subclass of QApplication so that we can customize what we
// do when the operating system sends us an event (such as opening a file)
class MyApp : public QApplication
{
Q_OBJECT
@abe33
abe33 / init.coffee
Last active May 1, 2018 21:44
Scrolling Atom editors without moving the cursor
atom.commands.add 'atom-text-editor',
'editor:scroll-down': ->
editor = atom.workspace.getActiveTextEditor()
editorElement = atom.views.getView(editor)
newScrollTop = editorElement.getScrollTop() + editorElement.getHeight()
editorElement.setScrollTop(newScrollTop)
'editor:scroll-up': ->
editor = atom.workspace.getActiveTextEditor()
editorElement = atom.views.getView(editor)
@Noitidart
Noitidart / _ff-addon-snippet-X11_XGetWindowProperty.js
Last active August 29, 2015 14:16
_ff-addon-snippet-X11_XGetWindowProperty - Shows how to use XGetWindowProperty, this is my skeleton for when I use it. [jsctypes] [x11] [unix]
Cu.import('resource://gre/modules/ctypes.jsm');
var nixtypesInit = function() {
// BASIC TYPES (ones that arent equal to something predefined by me)
this.ATOM = ctypes.unsigned_long;
this.BOOL = ctypes.int;
this.CHAR = ctypes.char;
this.GDKDRAWABLE = ctypes.StructType('GdkDrawable');
this.GDKWINDOW = ctypes.StructType('GdkWindow');
this.DATA = ctypes.voidptr_t;
@Yoric
Yoric / gist:c710b97dd55f98f8f0e3
Created April 20, 2015 09:52
Making a PromiseWorker that can shutdown
let myWorker = {
//
// Worker initialization
//
get worker() {
if (this._worker) {
return this._worker;
}
// Otherwise, initialize PromiseWorker.
// TODO
@Integralist
Integralist / flatten-array.js
Created May 20, 2015 08:35
Array flatten function written in ES6 syntax
const flattenTco = ([first, ...rest], accumulator) =>
(first === undefined)
? accumulator
: (Array.isArray(first))
? flattenTco([...first, ...rest])
: flattenTco(rest, accumulator.concat(first))
const flatten = (n) => flattenTco(n, []);
console.log(flatten([[1,[2,[[3]]]],4,[5,[[[6]]]]]))
@luckyrat
luckyrat / gist:7803415810fb4c09c975
Created May 22, 2015 11:08
importGlobalProperties test JSM
// JSM for working out which globalproperties can be imported in a specific Firefox version.
// https://developer.mozilla.org/en-US/docs/Components.utils.importGlobalProperties
// I'm not certain availability always equates to functionality but it probably does
// and in any case it's a way to narrow down the more involved test for functionality of each property
// Run from browser toolbox scratchpad like:
// Components.utils.import("resource://test-importGlobalProperties-addon/test.jsm");
Components.utils.import("resource://gre/modules/devtools/Console.jsm");