Skip to content

Instantly share code, notes, and snippets.

View mcabreradev's full-sized avatar
🎯
Focusing

Miguelángel Cabrera mcabreradev

🎯
Focusing
View GitHub Profile
@mcabreradev
mcabreradev / cloudSettings
Last active August 19, 2020 22:34
Visual Studio Code Settings Sync Gist
{"lastUpload":"2020-06-25T21:31:00.119Z","extensionVersion":"v3.4.3"}
@mcabreradev
mcabreradev / fruits.js
Last active September 22, 2017 07:48
Demo Promesas
const fruits = ['apple', 'peach', 'lime', 'watermelon']; // Array de frutas
function getFruit(fruit) {
return new Promise((resolve, reject) => { // Se crea la promesa con los 2 parámetros
// Se busca en el array si existe la fruta
if (fruits.find(item => item === fruit)) {
resolve(`${fruit} was found!`); // Se resuelve la promesa
} else {
reject(Error('no fruit was found!')); // Se rechaza la promesa
let items = [
{name:"A", value:2},
{name:"B", value:3},
{name:"A", value:4},
];
let result = [];
items.map((item, index) => {
const _$ = $;
setInterval(function(){
_$("#mm_cc > div > header > div.profile-header__vote.js-profile-header-buttons > div.profile-header__vote-item.profile-header__vote-item--yes.js-tutorial-first-yes > div > span").click()
}, 2000);
///////
setInterval(function(){
// Initialize an empty array of length n. Use Array.prototype.reduce() to add values into the array, using the sum of the last two values, except for the first two.
const fibonacci = n =>
[...Array(n)].reduce(
(acc, val, i) => acc.concat(i > 1 ? acc[i - 1] + acc[i - 2] : i),
[]
)
@mcabreradev
mcabreradev / actions.js
Created October 20, 2018 03:18
React Redux cheatsheet
import { FETCH_DATA } from './types';
export const fetchRestaurants = () => async (dispatch, getState) => {
try {
const response = await axios.get("/service");
const data = response.data.data;
dispatch({
type: FETCH_DATA,
@mcabreradev
mcabreradev / tmux-cheatsheet.markdown
Created December 11, 2018 20:39 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@mcabreradev
mcabreradev / common functions.js
Created March 28, 2019 00:00
common functions
/*
isAnagram
Checks if a string is an anagram of another string (case-insensitive, ignores spaces, punctuation and special characters).
*/
const isAnagram = (str1, str2) => {
const normalize = str =>
str
.toLowerCase()
.replace(/[^a-z0-9]/gi, '')
<div id="header"></div>
<div class="section">
<div class="article">
<div class="figure">
<img>
<div class="figcaption"></div>
</div>
</div>
</div>
<div id="footer"></div>
<header></header>
<section>
<article>
<figure>
<img>
<figcaption></figcaption>
</figure>
</article>
</section>
<footer></footer>