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 / 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: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
function timespan(start, end) {
if (typeof end === "undefined") {
end = start;
start = Date.now();
}
if (start !== null && typeof start === "object" && start.getTime) {
start = start.getTime();
}
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:
@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,
<!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 / latex.md
Created August 1, 2022 18:09
LaTex

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