Shells that support process substitution such as bash
and zsh
allow to run shell script on gist as follows.
# With curl:
bash <(curl -sL ${GIST_URL}) args...
# With wget:
--- | |
-- Function to retrieve console output | |
-- | |
function os.capture(cmd, raw) | |
local handle = assert(io.popen(cmd, 'r')) | |
local output = assert(handle:read('*a')) | |
handle:close() | |
if raw then |
export default function (babel) { | |
const { types: t } = babel; | |
const infiniteLoopDetector = babel.parse(` | |
function __infiniteLoopDetector() { | |
loopdetector.count += 1; | |
if(loopdetector.count > 10000) { | |
throw new Error("Infinte loop detected.") |
ANSI escape sequences can be printed to a shell to as instructions. The below is a list of codes I have used often in my CLI programs and I find myself looking up over and over again.
A great article about it can be found here.
SELECT ?subClass ?subClassLabel ?desc WHERE { | |
?subClass wdt:P279* wd:Q5. # Here we are getting all subClasses of Human and its subclasses | |
OPTIONAL { | |
?subClass rdfs:label ?desc. | |
FILTER((LANG(?desc)) = "en") | |
} | |
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } | |
} |
@ECHO OFF & :: ANSI-COLOR :: Authored by Ryan Beesley :: https://github.com/rbeesley | |
GOTO :DEFINE_MACROS | |
%=- Entry point after macro definitions -=% | |
:MAIN | |
SETLOCAL ENABLEDELAYEDEXPANSION | |
CALL :PARSE_ARGS %1 %2 %3 %4 %5 %6 %7 %8 %9 | |
:: Error when parsing | |
IF ERRORLEVEL 1 %@exit% %ERRORLEVEL% | |
:: Parsing success |
// git.io url: https://tinyurl.com/SurfingKeys-settings or https://git.io/JfXjB | |
// inspired by https://github.com/Foldex/surfingkeys-config/blob/master/config.js | |
// remove conflict with browser's history, download pannel toggle | |
// unmap('<Ctrl-j>'); | |
// iunmap('<Ctrl-j>'); | |
// vunmap('<Ctrl-j>'); | |
// unmap('<Ctrl-h>'); | |
// iunmap('<Ctrl-h>'); | |
// vunmap('<Ctrl-h>'); |
let bigArray = [["a", "b", "c"], | |
[1, 2, 3], | |
[true, true, false], | |
[":)", ":P", ":X"], | |
[true, false, false], | |
[1, 2, 3], | |
["foo", "zorb", "blarg"], | |
["a", "b", "c"]]; | |
let uniqueArray = Array.from(new Set(bigArray.map(JSON.stringify)), JSON.parse); |
/** | |
* Simulate a key event. | |
* @param {Number} keyCode The keyCode of the key to simulate | |
* @param {String} type (optional) The type of event : down, up or press. The default is down | |
* @param {Object} modifiers (optional) An object which contains modifiers keys { ctrlKey: true, altKey: false, ...} | |
*/ | |
function simulateKey (keyCode, type, modifiers) { | |
var evtName = (typeof(type) === "string") ? "key" + type : "keydown"; | |
var modifier = (typeof(modifiers) === "object") ? modifier : {}; |