Skip to content

Instantly share code, notes, and snippets.

View ViniciusFXavier's full-sized avatar
👨‍💻
Coding...

Vinícius Francisco Xavier ViniciusFXavier

👨‍💻
Coding...
View GitHub Profile
@ViniciusFXavier
ViniciusFXavier / viacep.js
Last active January 8, 2020 13:05
ViaCEP API service - NodeJS
const request = require('request');
const promisifiedRequest = function (options) {
return new Promise((resolve, reject) => {
request(options, (error, response, body) => {
if (response) {
return resolve(response);
}
if (error) {
return reject(error);
@ViniciusFXavier
ViniciusFXavier / nodejs-cheatsheet.js
Created February 24, 2020 01:55 — forked from LeCoupa/nodejs-cheatsheet.js
Complete Node.js CheatSheet --> UPDATED VERSION --> https://github.com/LeCoupa/awesome-cheatsheets
/* *******************************************************************************************
* THE UPDATED VERSION IS AVAILABLE AT
* https://github.com/LeCoupa/awesome-cheatsheets
* ******************************************************************************************* */
// 0. Synopsis.
// http://nodejs.org/api/synopsis.html
@ViniciusFXavier
ViniciusFXavier / problem.md
Created March 28, 2020 18:44
CodeWars - Kata - Tribonacci Sequence

Well met with Fibonacci bigger brother, AKA Tribonacci.

As the name may already reveal, it works basically like a Fibonacci, but summing the last 3 (instead of 2) numbers of the sequence to generate the next. And, worse part of it, regrettably I won't get to hear non-native Italian speakers trying to pronounce it :(

So, if we are to start our Tribonacci sequence with [1, 1, 1] as a starting input (AKA signature), we have this sequence:

[1, 1 ,1, 3, 5, 9, 17, 31, ...]

@ViniciusFXavier
ViniciusFXavier / problem.md
Created March 28, 2020 18:51
CodeWars - Kata - Stop gninnipS My sdroW!

Write a function that takes in a string of one or more words, and returns the same string, but with all five or more letter words reversed (Just like the name of this Kata). Strings passed in will consist of only letters and spaces. Spaces will be included only when more than one word is present.

Examples:

spinWords( "Hey fellow warriors" ) => returns "Hey wollef sroirraw"
spinWords( "This is a test") => returns "This is a test"
spinWords( "This is another test" )=> returns "This is rehtona test"

Adding npm Command Autocompletion to Your Shell

If you want to get a quick improvement to your npm productivity, you can add autocompletion for npm to your shell with just one command.

For bash, you can add npm autocompletion with: npm completion >> ~/.bashrc

For zsh, you can add npm autocompletion with: npm completion >> ~/.zshrc

And now you’ll have tab autocomplete for npm commands.

@ViniciusFXavier
ViniciusFXavier / ipAddressGenerator.js
Created June 3, 2020 19:36
IP Address Generator/Validator
function run() {
const listIp = []
for (let index = 0; index < 1000; index++) {
const ip = (Math.floor(Math.random() * 255) + 1)+"."+(Math.floor(Math.random() * 255))+"."+(Math.floor(Math.random() * 255))+"."+(Math.floor(Math.random() * 255));
listIp.push(ip);
}
console.log('listIp: ', JSON.stringify(listIp))
}
run()
@ViniciusFXavier
ViniciusFXavier / remove-demos.js
Last active June 17, 2020 16:36
Remove demos from STEAM account
(function () {
if (!location.href.startsWith('https://store.steampowered.com/account/licenses')) {
alert('Please run this on Steam\'s account licenses page.');
return;
}
let toDelete = [];
[...document.querySelectorAll('tr td:nth-child(2)')].forEach((element) => {
const match = element.innerHTML.match(/( Demo)\W+/gi);
@ViniciusFXavier
ViniciusFXavier / dblkeypress.js
Last active March 21, 2021 06:01
Double Keypress Detection
document.addEventListener('dblkeypress', function (event) {
console.log('event: ', event);
console.log('----Works----');
}, false);
var dblkeypressConfig = {
lastKeyCode: null,
lastFiredTime: null,
interval: 500, // 500(slow) or 350(medium) or 100(fast) or 50(impossible)
clear: function () {
@ViniciusFXavier
ViniciusFXavier / index.html
Last active March 21, 2021 19:19
Escape from Tarkov grid inventory on canvas
<script src="https://cdnjs.cloudflare.com/ajax/libs/konva/7.2.5/konva.min.js"></script>
<div id="container"></div>
<a href="https://jsfiddle.net/vfxloco/zvmt7rky/114/">Escape from tarkov grid inventory</a>
@ViniciusFXavier
ViniciusFXavier / example.js
Last active April 12, 2021 16:54
Detect on change
const object = {
foo: false,
a: {
b: [
{
c: false
}
]
}
};