Skip to content

Instantly share code, notes, and snippets.

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

Pedro Gomes pedrouid

🛠️
Building @WalletConnect Network
View GitHub Profile
@pedrouid
pedrouid / flattenArray.js
Created June 22, 2017 00:27
Flatten Arbitrarily Nested Arrays Method (Javascript)
// 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]);
}
}
@pedrouid
pedrouid / .vimrc
Created August 26, 2017 11:45
VIM config
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
// 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 / crawlObject.js
Created November 6, 2017 18:05
Crawl a nested object to find data
// 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 / changePlaybackRate.js
Last active November 29, 2017 22:25
Tiny script to change currently playing HTML video speed
// 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 / instructions.txt
Last active March 21, 2018 23:49
Setting up NTFS 3G on Mac OS Sierra
// 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 / windowResize.js
Created March 22, 2018 00:25
Window Responsiveness React High Order Component
import React, { Component } from 'react';
function windowResize(WrappedComponent) {
return class extends Component {
state = {
width: '',
height: ''
};
updateDimensions = () => {
const w = typeof window !== 'undefined' ? window : '';
@pedrouid
pedrouid / keybase.md
Created April 5, 2018 19:24
Keybase proof

Keybase proof

I hereby claim:

  • I am pedrouid on github.
  • I am pedrouid (https://keybase.io/pedrouid) on keybase.
  • I have a public key ASDDFwDqo6cL3R8995Y0mPgSp8ZPq2PnjfR_z-HpyPhoxgo

To claim this, I am signing this object:

@pedrouid
pedrouid / git-submodule.md
Created September 24, 2018 00:11
Git Submodules Cheatsheet

Add Submodule

git submodule add git@mygithost:project lib/project

Update Submodule

cd lib/project && git pull && cd ../.. && git commit -a -m 'update submodule'
# 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 ->