Skip to content

Instantly share code, notes, and snippets.

View nchevobbe's full-sized avatar

Nicolas Chevobbe nchevobbe

View GitHub Profile
@nchevobbe
nchevobbe / .hgrc
Last active April 4, 2023 08:46
hg log graph with links to Bugzilla and Phabricator
[alias]
wip = log --graph --rev=wip --template=wip
[revsetalias]
wip = (parents(not public()) or not public() or . or (head() and branch(default))) and (not obsolete() or orphan()^) and not closed() and not (fxheads() - date(-90))
ignored_changesets = desc("ignore-this-changeset") or extdata(get_ignored_changesets)
[templates]
wip = '{
label(
@nchevobbe
nchevobbe / not_wordle_just_my_firefox_tabs.js
Created February 4, 2022 15:13
Not Wordle Just My Firefox Tabs
// Evaluate the following in Firefox Browser Console
copy("Not Wordle, just my #firefox tabs:\n" +
gBrowser.tabs
.map(tab => tab.pinned ? `🟪` : tab.getAttribute("pending") ? `🟨` : `🟩` )
.reduce((acc, curr) => {
if (acc.at(-1).length == 10) {
acc.push("");
}
acc[acc.length - 1] += curr;
return acc;
@nchevobbe
nchevobbe / prompt_hg.sh
Created June 30, 2020 15:53
get repo information in prompt fast
prompt_hg() {
local HG_ROOT
find_hg_root() {
local dir="$( pwd )"
while test $dir != "/"; do
if test -f $dir'/.hg/dirstate'; then
HG_ROOT=$dir"/.hg"
return 0
fi
@nchevobbe
nchevobbe / fake-typing-in-console-from-browser-console.js
Last active March 28, 2019 09:05
Fake typing in the console and executing commands, from the browser console
// With the console open, in the browser console:
async function getOpenedConsoleReference() {
var {devtools} = Cu.import("resource://devtools/shared/Loader.jsm", {});
var target = await devtools.TargetFactory.forTab(gBrowser.selectedTab);
var {gDevTools} = devtools.require("devtools/client/framework/devtools");
var toolbox = gDevTools.getToolbox(target);
return toolbox.getCurrentPanel();
}
@nchevobbe
nchevobbe / get-console-state-from-browser-console.js
Last active August 28, 2019 14:27
Get console state from hud
// With the console open, in the browser console:
async function getOpenedConsoleReference() {
var loader = Cu.import("resource://devtools/shared/Loader.jsm", {});
var {gDevTools} = loader.require("devtools/client/framework/devtools");
var target = await gDevTools.getTargetForTab(gBrowser.selectedTab);
var toolbox = gDevTools.getToolbox(target);
return toolbox.getCurrentPanel();
}
@nchevobbe
nchevobbe / gist:431fed66e0f20a991b048316f27b4855
Created December 12, 2017 22:02
Push to another person PR
git push git@github.com:user/repo local_branch_name:remote_branch_name
var index = 0;
var nodes = document.querySelectorAll(".tree-node");
function scrollNext() {
index = index + 40;
nodes[index].scrollIntoView();
if (index < nodes.length - 1) {
requestAnimationFrame(scrollNext);
}
}
scrollNext();
@nchevobbe
nchevobbe / screenshot.js
Last active September 4, 2018 13:22
Log a data URL containing a screenshot of the window
let canvas = window.document.createElementNS("http://www.w3.org/1999/xhtml", "html:canvas");
let context = canvas.getContext("2d");
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
context.drawWindow(window, 0, 0, canvas.width, canvas.height, "white");
console.log(`
📸 📸 📸 📸
${canvas.toDataURL()}
@nchevobbe
nchevobbe / array_fill.js
Created January 27, 2017 08:21
Array.fill
let [a, b] = (new Array(2)).fill(Symbol());
console.log(a === b); // -> true
@nchevobbe
nchevobbe / create-dom-element.js
Last active August 22, 2021 12:03
Utility function to create DOM element
/**
* Utility function to create DOM element with populated attributes and content
*
* Usage :
*
* // simple element
* let input = createDomElement("input", {
* type: "search",
* placeholder: "Enter what pleases you"
* });