Skip to content

Instantly share code, notes, and snippets.

View ZER0's full-sized avatar

Matteo Ferretti ZER0

  • Amsterdam, Netherlands
View GitHub Profile
@ZER0
ZER0 / latex.md
Created August 1, 2022 18:09
LaTex

$$\mathrm{e} = \sum_{n=0}^{\infty} \dfrac{1}{n!}$$

<!doctype html>
<html>
<div>
<button>click A</button>
<button>click B</button>
</div>
<output></output>
<script>
let buttons = document.querySelector("div");
let output = document.querySelector("output");
@ZER0
ZER0 / rulers.js
Created October 6, 2015 16:10
Example of highligther based on CanvasHighlighter
function RulersHighlighter2(highlighterEnv) {
CanvasHighlighter.call(this, highlighterEnv);
}
RulersHighlighter2.prototype = extend(CanvasHighlighter.prototype, {
typeName: "RulersHighlighter",
textStep: 100,
graduationStep: 5,
stepScale: 1,
JPM [info] Starting jpm test on addon-sdk
Creating XPI
JPM [info] XPI created at /var/folders/tx/91xwh51562l5_4xcqjst9bvw0000gn/T/@addon-sdk-0.1.18.xpi (1173ms)
Created XPI at /var/folders/tx/91xwh51562l5_4xcqjst9bvw0000gn/T/@addon-sdk-0.1.18.xpi
JPM [info] Creating a new profile
Shumway is registered
Running tests on Firefox 42.0a1/Gecko 42.0a1 (Build 20150805030208) ({ec8030f7-c20a-464f-9b0e-13a3a9e97384}) under darwin/x86_64.
console.error: addon-sdk:
JPM [error] Message: TypeError: FakeCu is not a constructor
Stack:
function timespan(start, end) {
if (typeof end === "undefined") {
end = start;
start = Date.now();
}
if (start !== null && typeof start === "object" && start.getTime) {
start = start.getTime();
}
@ZER0
ZER0 / gist:d49c9cd35ad4dd08389c
Last active August 29, 2015 14:19
highlight a word in a page
let word = "Mozilla";
// set the walker for non-empty text node
let walker = document.createTreeWalker(
document.body,
NodeFilter.SHOW_TEXT,
{ acceptNode: (node) => node.nodeValue.trim().length && NodeFilter.FILTER_ACCEPT }
);
// collecting the nodes
@ZER0
ZER0 / gist:10ef3b4b491c1dac3d70
Created August 7, 2014 16:25
ToggleButton with Global and Tab scope checked status
const { ToggleButton } = require('sdk/ui/button/toggle');
let globalToggle = ToggleButton({
id: 'my-global-toggle',
label: 'global function',
icon: './foo.png',
onChange: function() {
// delete the window state for the current window,
// automatically set when the user click on the button
this.state('window', null);
@ZER0
ZER0 / gist:10708822
Created April 15, 2014 06:59
Add-on SDK: take a screenshot of the active tab's content
const { window: { document } } = require('sdk/addon/window');
const { getTabContentWindow, getActiveTab } = require('sdk/tabs/utils');
const { getMostRecentBrowserWindow } = require('sdk/window/utils');
const canvas = document.createElementNS('http://www.w3.org/1999/xhtml', 'canvas');
document.documentElement.appendChild(canvas);
function captureActiveTab() {
let contentWindow = getTabContentWindow(getActiveTab(getMostRecentBrowserWindow()));
@ZER0
ZER0 / gist:10637946
Last active August 29, 2015 13:59
Add-on SDK: Reverse the tabs' order in the current window
const { ActionButton } = require("sdk/ui/button/action");
const { browserWindows } = require("sdk/windows");
let button = ActionButton({
id: "reverse-tabs",
label: "Reverse Tab Order",
icon: {
// The new APIs use "./" as shortcut for data folder, you don't need
// to require `self` for that purpose.
"16": "./16.png",
@ZER0
ZER0 / gist:10024431
Created April 7, 2014 17:19
Add-on SDK: to Certificate Viewer window
let { events: windowEvents } = require('sdk/window/events');
let { on } = require('sdk/event/core');
let { filter } = require('sdk/event/utils');
let ready = filter(windowEvents, ({type}) => type === 'DOMContentLoaded');
let certificateWindows = filter(ready, ({target}) =>
target.document.documentElement.mozMatchesSelector('dialog#certDetails'));
on(certificateWindows, 'data', ({target: window}) => {