This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Redirect output to stderr. | |
exec 1>&2 | |
# enable user input | |
exec < /dev/tty | |
debugregexp='debugger' | |
# CHECK | |
if test $(git diff --cached | grep $debugregexp | wc -l) != 0 | |
then |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Fish function that kill the process listening on a specific port | |
# Usage: kill-port <port> | |
function kill-port | |
lsof -n -i:$argv | grep LISTEN | awk '{ print $2 }' | uniq | xargs kill -9 | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Split & stack an array into chunks | |
// Ex: arrayChunk([1, 2, 3, 4, 5, 6, 8], 3) => [[1, 2, 3], [4, 5, 6], [7, 8]] | |
function arrayChunk (arr = [], len = 2, stackRest = false) { | |
const chunks = []; | |
const n = arr.length; | |
let i = 0; | |
while (i < n) { | |
const chunk = arr.slice(i, i += len); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(() => { | |
let results; | |
let currentWindow; | |
let customizedWindow = {}; | |
let iframe = document.createElement('iframe'); | |
iframe.style.display = 'none'; | |
document.body.appendChild(iframe); | |
currentWindow = Object.getOwnPropertyNames(window); | |
results = currentWindow.filter(function (prop) { | |
return !iframe.contentWindow.hasOwnProperty(prop); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.slog = function (...args) { | |
if (!window.logsStack) { | |
window.logsStack = []; | |
window.printLogsStack = function () { | |
for (const logItem of window.logsStack) { | |
const [msg, lineDetails] = logItem; | |
console.log(msg); | |
console.log(lineDetails); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Usage: | |
// commit ('SET', { prop: `path.to['my'].prop[1]`, value: 42 }); | |
// or commit ('SET', [`path.to['my'].prop[1]`, 42]); | |
export default { | |
SET_PROP(state, payload) { | |
let prop, value; | |
if (Array.isArray(payload)) { | |
[prop, value] = payload; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Script that shows the total price of an Airbnb listing divided by the number of persons | |
// Inject it in any Airbnb search page (https://airbnb.com/s/*) | |
!function() { | |
function runner() { | |
const persons = +new URL(window.location.href).searchParams.get('adults'); | |
if (!persons) { | |
return; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Check if there's any Google foobar challenge invite in the page comments | |
// https://www.geeksforgeeks.org/google-foo-bar-challenge/ | |
(() => { | |
function getAllComments() { | |
const $root = document.documentElement; | |
const comments = []; | |
const iterator = document.createNodeIterator($root, NodeFilter.SHOW_COMMENT, () => NodeFilter.FILTER_ACCEPT, false); | |
let node; | |
while (node = iterator.nextNode()) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@mixin cursor-emoji($emoji) { | |
cursor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='40' height='48' viewport='0 0 100 100' style='fill:black;font-size:24px;'><text y='50%'>"+$emoji+'</text></svg>') | |
16 0, | |
auto; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Find all properties & methods of an object, up to the root prototype | |
function findAllProps(obj, props = []) { | |
if (!obj) { | |
return props; | |
} | |
return findAllProps(Object.getPrototypeOf(obj), [ | |
...props, | |
Object.getOwnPropertyNames(obj), | |
]); | |
} |
OlderNewer