Skip to content

Instantly share code, notes, and snippets.

View nobitagit's full-sized avatar
🕸️
The less I know the better

Aurelio nobitagit

🕸️
The less I know the better
View GitHub Profile
@nobitagit
nobitagit / reverse-recursive-tree.js
Last active November 14, 2023 13:16
Build a reverse recursive tree in JavaScript
/**
* from this..
**/
const list = [
{id: 0 , parent: null},
{id: 1 , parent: 0},
{id: 2 , parent: 1},
{id: 3 , parent: 1},
{id: 4 , parent: 2},
{id: 5 , parent: 1},
@nobitagit
nobitagit / iterm2.md
Last active August 24, 2023 12:16
iterm2 cheatsheet

This gist has been moved to its own Github repo, so it's easier to contribute with additions and corrections. Please open a PR there if you see any mistake, I don't track comments on here as there's no notification system for gists AFAIK. Thanks.

Tabs and Windows

Function Shortcut
Previous Tab + Left Arrow
Next Tab + Right Arrow
Go to Tab + Number
@nobitagit
nobitagit / vs-code-keys.mdown
Last active April 29, 2021 07:10
VS Code shortcuts

💥 - you should never forget this one

See all open files CTRL + p

Show command palette CMD + p

Show suggestions (intellisense style) CTRL + SPACE either on a new line or by highlighting a word

@nobitagit
nobitagit / customeEvents.js
Created November 19, 2014 08:36
Creating an event in javascript and firing it programmatically
// creating an event and firing it programmatically
document.addEventListener('change', function(e) {
console.log(e.someProp);
});
var event1 = document.createEvent('HTMLEvents');
event1.initEvent('change',true,false);
event1.someProp = 'yourPropHere';
inputEl.dispatchEvent(event1);
@nobitagit
nobitagit / reborn.sh
Last active January 16, 2019 14:40
Just in case i need to resurrect my laptop.
echo "Starting"
echo "Getting Homebrew"
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
# Show dotfiles by default
defaults write com.apple.finder AppleShowAllFiles -bool true
killall Finder
# get Vundle
@nobitagit
nobitagit / index.MD
Created September 11, 2018 13:02
videos to watch
@nobitagit
nobitagit / .babelrc
Created March 23, 2017 22:17 — forked from c9s/.babelrc
webpack + babel + typescript + es6 - total solutions!
{
"presets": ["es2015"],
"plugins": ["transform-runtime"]
}
@nobitagit
nobitagit / launch.json
Last active July 29, 2018 18:56
VSCode ES2017 ingle file debug
{
 "name": "Single JS file",
 "type": "node",
 "request": "launch",
 "program": "${file}",
 "stopOnEntry": false,
 "args": [],
 "cwd": "${workspaceRoot}",
 "preLaunchTask": null,
 "runtimeExecutable": null,
@nobitagit
nobitagit / numlen.js
Last active June 6, 2018 21:20
Pipe implementation in js
const len = num => {
const isNum = !isNaN(parseFloat(num)) && isFinite(num);
if (!isNum) {
return new Error('not a number');
}
const str = num.toString().replace('.', '');
return str.length;
}
function translateError(msg) {
var newErr = new Error(msg); // placed here to get correct stack
return e => {
newErr.originalError = e;
throw newErr;
}
}
async function asyncTask() {
const user = await UserModel.findById(1).catch(translateError('No user found'))