Skip to content

Instantly share code, notes, and snippets.

// Object literal demo
var obj = {};
var key = Symbol('foo');
obj[key] = 'baz';
console.log(obj);
@nestoralonso
nestoralonso / random-commands.bash
Last active August 2, 2016 14:58
bash random commands
# make a folder selection using ls and pass it to echo to see command output before executing
ls -d muchos*dirs/ | xargs -I{} echo rm -rf {}
@nestoralonso
nestoralonso / ChatApp2.js
Created September 27, 2016 19:28
Repetaded avatar solved
////////////////////////////////////////////////////////////////////////////////
// Exercise:
//
// - Create a chat application using the utility methods we give you
//
// Need some ideas?
//
// - Cause the message list to automatically scroll as new
// messages come in
// - Highlight messages from you to make them easy to find
var webdriverio = require("webdriverio");
var options = {
desiredCapabilities: {
browserName: "chrome"
}
};
var client = webdriverio.remote(options);
@nestoralonso
nestoralonso / note.bash
Created October 2, 2017 21:48
Take notes on bash (add to .bashrc)
#Taken from https://dev.to/ricardomol/note-taking-from-the-command-line-156
note() {
if [ ! -z "$1" ]; then
echo $(date +"%Y%m%d-%H%M%S") $@ >> $HOME/notes/TempNotes.wiki
else
echo $(date +"%Y%m%d-%H%M%S") "$(cat)" >> $HOME/notes/TempNotes.wiki
fi
}
@nestoralonso
nestoralonso / simple_snippets.js
Created January 8, 2018 04:37
Useful snippets
// HOF to do an automatic catch over functions that return promises
const handleErrors = fn => (...args) => fn(...args).catch(err => console.error(`Ohh the horror ${err}`))
// A buggy sleep
const riskySleep = (ms) =>
new Promise((resolve, reject) => {
if (Math.random() < 0.7) { reject(ms) }
setTimeout(() => resolve(ms), ms)
});
@nestoralonso
nestoralonso / .tmux.conf
Created January 26, 2018 22:26
Minimal tmux conf
# remap prefix from 'C-b' to 'C-a'
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix
# Start window numbering at 1
set -g base-index 1
@nestoralonso
nestoralonso / getReactComponentInstance.js
Last active July 15, 2018 00:45
get react object from the DOM
getReactElement = (dom) => {
for (var key in dom) {
if (!key.startsWith("__reactInternalInstance$")) continue;
var compInternals = dom[key]._currentElement;
var compWrapper = compInternals._owner;
var comp = compWrapper._instance;
return comp;
}
@nestoralonso
nestoralonso / prepare-commit-msg.py
Created August 7, 2018 15:34
prepare the commit log message using the JIRA Ticket code
#!/usr/bin/env python3
#
# prepare the commit log message using the JIRA Ticket code.
#
# Given that the your branch is called something like bugfix/PROJETO-21012
# Then your commit message will look like
#
# [PROJETO-21012] Fixes the bug
#
@nestoralonso
nestoralonso / pattern-match.rs
Last active October 13, 2018 02:07
Rust Pattern matching Sample
#[derive(Debug)]
struct Action {
_type: String,
amount: u32
}
fn update_counter(state:u32, action: Action) -> u32 {
let Action {_type, amount} = action;
println!("{} {} {}", _type, amount, state);