Skip to content

Instantly share code, notes, and snippets.

Avatar
⌨️

Victor victornpb

⌨️
View GitHub Profile
View gist:18862258e8b3fe84737a4537f900d394

LG 4K UHD 27MU58P-B.AWZ

Display Calibration

  • [Picture]
    • Picture Mode: Custom
    • Picture Adjust >
      • Super Resolution: Off (Use Low for 1080p)
      • Sharpness: 50
      • Black Level: Low
      • HDMI ULTRA HD Deep Color: Off
View fromNow.js
/**
* 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;
@victornpb
victornpb / clone_all.sh
Last active Mar 31, 2021
Clone All repositories from User or Organization
View clone_all.sh
#!/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"
View Backup Arduino firmware.md

Set these variables

Arduino Uno:

export BOARD=atmega328p
export PORT=/dev/tty.usbmodem14201
export BAUD=115200
export PROGRAMMER=arduino
export AVR_DIR=/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin
@victornpb
victornpb / start_server.command
Last active Mar 16, 2021
Bash script to start Minecraft server and keep it running if it crashes
View start_server.command
#!/bin/bash
# Config
WINDOW_TITLE="Minecraft Server"
ONLINE_AUTH=true
RAM_INITIAL=512M
RAM_MAX=4G
RESTART_DELAY=10
################################################################################
@victornpb
victornpb / frozen-task.js
Last active Feb 26, 2020
Bookmarklet to make frozen tasks more effortless
View frozen-task.js
(() => {
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 => {
@victornpb
victornpb / remove-outline-focus-ring.js
Last active Feb 6, 2020
Remove the focus outline ring when using mouse but keep it for keyboard users for a11y
View remove-outline-focus-ring.js
/**
* 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; }";
@victornpb
victornpb / zip.js
Created Dec 18, 2019
Zip file on nodeJS using subprocess
View zip.js
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);
@victornpb
victornpb / parseQueryString.js
Created Oct 16, 2019
Simple query string parser
View parseQueryString.js
/*
Example:
parseQueryString('?foo=hi&bar=World%20Hello')
{
foo: "hi",
bar: "Hello World"
}
*/
/**
@victornpb
victornpb / ajax.js
Created Oct 16, 2019
Minimal ajax library
View ajax.js
/**
* Minimal Ajax library
* @param {object} options Options
* @param {string} options.url Url
* @param {string} [options.method='GET'] Method GET|POST|PUT|DELTE
* @param {string} [options.data] Body of the request
* @param {string} [options.contentType='application/x-www-form-urlencoded'] Set the content type of the body
* @param {number} [options.timeout] Timout in milliseconds
* @param {boolean} [options.withCredentials=false] withCredentials
* @return {Promise} Returns a promise