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
/** | |
* Human readable elapsed or remaining time (example: 3 minutes ago) | |
* @param {Date|Number|String} date A Date object, timestamp or string parsable with Date.parse() | |
* @return {string} Human readable elapsed or remaining time | |
* @author github.com/victornpb | |
*/ | |
function fromNow(date) { | |
const SECOND = 1000; | |
const MINUTE = 60 * SECOND; | |
const HOUR = 60 * MINUTE; |
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/bash | |
echo "-------------------------------" | |
echo " Clone all GitHub Repositories " | |
echo "-------------------------------" | |
#prompt for variables | |
printf "\nCreate a token here https://github.com/settings/tokens\nor leave it empty for public repositories\n\n" | |
read -s -p 'Personal Token (optional): ' GITHUB_TOKEN | |
printf "\n" |
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
function sortBy(arr, fields) { | |
if (typeof fields === 'string') fields = [fields]; | |
function compareFn(a, b) { | |
return fields | |
.map(field => { | |
let dir = 1; | |
if (field[0] === "-") { | |
dir = -1; | |
field = field.substring(1); | |
} |
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
#include <stdlib.h> | |
#include <stdio.h> | |
#include <time.h> | |
#define CARA 1 | |
#define COROA 2 | |
int pontosJogador; | |
int pontosComputador; |
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
/** | |
* Create a function that maps a value to a range | |
* @param {Number} inMin Input range minimun value | |
* @param {Number} inMax Input range maximun value | |
* @param {Number} outMin Output range minimun value | |
* @param {Number} outMax Output range maximun value | |
* @return {function} A function that converts a value | |
* | |
* @author Victor N. wwww.victorborges.com | |
* @see https://gist.github.com/victornpb/51b0c17241ea483dee2c3a20d0f710eb/ |
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
(() => { | |
if (window.MOD) return alert("Already running!"); | |
window.MOD = true; | |
const doc = document; | |
doc.querySelector("#toggle-side-nav").click(); | |
doc.querySelector("nav").style.position = "absolute"; | |
const delay = async t => new Promise(r => setTimeout(r, t)); | |
const wait4Elm = async selector => { |
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
(function() { | |
var html = `<div style="position: fixed; top: 50px; left: 50px; z-index: 99999999; background-color:black; color: white; padding: 5px;"> | |
<div style="display: flex;"> | |
READ: | |
<button class="readAsJsonBtn">as JSON</button> | |
<button class="readAsEnvBtn">as ENV</button> | |
WRITE: | |
<button class="writeFromJsonBtn">from JSON</button> | |
<button class="writeFromEnvBtn">from ENV</button> | |
<span style="flex-grow: 1;"></span> |
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
/** | |
* Hide the uggly focus outline ring on UI elements for users using mouse | |
* as input device, but enable it as soon as the keyboard is being used. | |
* This is important for keyboard and a11y purposes. | |
* @author https://gist.github.com/victornpb/0aa4aba6e15a2f156a53a7ba995a432e | |
*/ | |
(function () { | |
document.head.appendChild(document.createElement("style")).innerHTML = | |
"body.hide-focus-ring *:focus { outline: none !important; }"; |
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
/** Hide the address bar - vitim.us */ | |
function hideAddressBar(){ | |
setTimeout(function(){ | |
if(scrollY) return; | |
scrollTo(scrollX, 1); | |
setTimeout(function() | |
if(scrollY==1) | |
scrollTo(scrollX, 0); | |
}, 1); | |
}, 1); |
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
const path = require('path'); | |
const { spawn } = require('child_process'); | |
(async () => { | |
try { | |
await zip(path.resolve(__dirname, 'foo.js'), path.resolve(__dirname, 'bar.zip')); | |
console.log('OK'); | |
} catch (err) { | |
console.error('Failed to zip!', err); |