Skip to content

Instantly share code, notes, and snippets.

View pedrouid's full-sized avatar
🛠️
Building @WalletConnect

Pedro Gomes pedrouid

🛠️
Building @WalletConnect
View GitHub Profile
@pedrouid
pedrouid / flattenArray.js
Created June 22, 2017 00:27
Flatten Arbitrarily Nested Arrays Method (Javascript)
View flattenArray.js
// Using recursion this method will concatenate the values of nested arrays into a single array
function flatten(arr) {
var holder = [];
for(var i = 0; i < arr.length; i++) {
if(Array.isArray(arr[i])) {
holder = holder.concat(flatten(arr[i]));
} else {
holder.push(arr[i]);
}
}
View init.coffee
# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to log to the console when each text editor is saved.
#
# atom.workspace.observeTextEditors (editor) ->
# editor.onDidSave ->
@pedrouid
pedrouid / .vimrc
Created August 26, 2017 11:45
VIM config
View .vimrc
syntax on
set number
set tabstop=2
set autoindent
set smarttab
@pedrouid
pedrouid / timeago.js
Last active September 17, 2017 02:15
Get Time Ago String
View timeago.js
// Just run this file with node and give it a valid Javascript Date string or timestamp
// It will return the string with time ago it nomenclature given the timedifference
//
// @param {String} date [REQUIRED]
// @param {Boolean} short
// @param {string} current
//
// Author: Pedro Gomes | Github @gomesphoto | Twitter @gomesphoto
const nodeQuery = Number(process.argv[2])
@pedrouid
pedrouid / changePlaybackRate.js
Last active November 29, 2017 22:25
Tiny script to change currently playing HTML video speed
View changePlaybackRate.js
// Copy & Paste to the browser's console and call function to adjust playbackRate for currenly playing videos
// Common playback rates are 0.25 / 0.5 / 0.75 / 1.0 / 1.25 / 1.5 / 1.75 / 2.0
// Maximum value recommended is 4.0 (browser / hardward dependent)
// @param {Number} [rate = 1.0]
function changePlaybackRate(rate) {
var videos = document.getElementsByTagName('video');
var currentlyPlaying = [];
var playbackRate = Number(rate) || 1.0;
for (var i = 0; i < videos.length; i++) {
@pedrouid
pedrouid / devops-cheatsheet.md
Last active March 12, 2021 14:27
Digital Ocean DevOps Cheatsheet (Ubuntu 16.04)
View devops-cheatsheet.md

Digital Ocean DevOps Cheatsheet (Ubuntu 16.04)

How to Deploy a Node.js App with SSL

Create an SSH key

We will need this for our server configuration

  1. Open console
@pedrouid
pedrouid / instructions.txt
Last active March 21, 2018 23:49
Setting up NTFS 3G on Mac OS Sierra
View instructions.txt
// Install Homebrew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
// Check if Homebrew Cask extension is installed
brew cask
(if not installed ===> brew install caskroom/cask/brew-cask)
@pedrouid
pedrouid / eslint-config-setup.md
Last active December 14, 2018 15:56
Basic Eslint Config for React, React-Native and Node
View eslint-config-setup.md

ESLINT-CONFIG-REACT-APP (react.js)

  1. Install All Dev Dependencies
yarn add -D babel-eslint eslint eslint-config-react-app eslint-plugin-flowtype eslint-plugin-import eslint-plugin-jsx-a11y eslint-plugin-react

# OR

npm install --save-dev babel-eslint eslint eslint-config-react-app eslint-plugin-flowtype eslint-plugin-import eslint-plugin-jsx-a11y eslint-plugin-react
@pedrouid
pedrouid / crawlObject.js
Created November 6, 2017 18:05
Crawl a nested object to find data
View crawlObject.js
// Crawl nested object and find data that matches your __CONDITION__
const crawlObject = (evalObj, prevObj, prevKey) => {
if (typeof evalObj === "object") {
Object.keys(evalObj).map((key) => crawlObject(evalObj[key], evalObj, key));
} else {
if (__CONDITION__) {
// DO SOMETHING
console.log(prevObj[prevKey])
}
@pedrouid
pedrouid / randomDomainNameGenerator.js
Last active July 21, 2023 13:41
Random Domain Name Generator
View randomDomainNameGenerator.js
// @desc Creates a list of domains with custom TLDs using a pattern string with fixed length with option for keywords
// @param {String} pattern
// @param {Array|String} tlds
// @returns {Array} domainList
//
//
// Pattern string is defined by:
// - keywords lowercase
// - any letter uppercase A
// - consonants uppercase C