Skip to content

Instantly share code, notes, and snippets.

Avatar

Weslley Araujo weslleyaraujo

View GitHub Profile
@weslleyaraujo
weslleyaraujo / simple-fuzzy.js
Created Aug 8, 2020
simple fuzzy search regex
View simple-fuzzy.js
new RegExp(".*" + "string".split("").join(".*") + ".*")
@weslleyaraujo
weslleyaraujo / index.html
Last active Jan 14, 2020
React w/TypeScript
View index.html
<div id="app"></div>
@weslleyaraujo
weslleyaraujo / Build_Vim7.4_CentOS7.txt
Created Oct 10, 2017 — forked from junxie6/Build_Vim7.4_CentOS7.txt
Compile the latest Vim 7.4 on CentOS 7
View Build_Vim7.4_CentOS7.txt
Compile the latest Vim 7.4 on CentOS 7
# yum install gcc make ncurses ncurses-devel
# yum install ruby ruby-devel lua lua-devel luajit \
luajit-devel ctags git python python-devel \
python3 python3-devel tcl-devel \
perl perl-devel perl-ExtUtils-ParseXS \
perl-ExtUtils-XSpp perl-ExtUtils-CBuilder \
perl-ExtUtils-Embed
@weslleyaraujo
weslleyaraujo / destructuring.js
Created Oct 14, 2015 — forked from mikaelbr/destructuring.js
Several demos and usages for ES6 destructuring.
View destructuring.js
// === Arrays
var [a, b] = [1, 2];
console.log(a, b);
//=> 1 2
// Use from functions, only select from pattern
var foo = () => {
return [1, 2, 3];
View score.js
import styled from ‘styled-components’;
const Score = styled.div`
 /* some styles here … */
 font-size: ${props => props.length <= 2 ? 62 : 45}px;
`;
View match-example.js
const { guessed, all } = getState().match;
console.log(all, guessed) // ['red'] ['red']
if (guessed[0] === all[0]) {
// keep going from here, guesses are correct
return;
}
// player didnt guessed properly, do something about it
View dispatching.js
import sleep from 'utils/sleep';
const SONG_DELAY_TIME = 400;
export const sing = payload => async (dispatch, getState) => {
dispatch(startSong());
const { match } = getState();
for (let i = 0; i <= match.all.length - 1; i++) {
const id = match.all[i];
dispatch(lightenPad({ id }));
await sleep(SONG_DELAY_TIME); // sleep time during note play
View sleep.js
export default function sleep(ms = 0) {
 return new Promise(r => setTimeout(r, ms));
}
View game-actions.js
const start = createAction(START_GAME);
const next = createAction(NEXT_LEVEL);
const startGame = payload => start({ next: getRandomId() });
const nextLevel = payload => next({ next: getRandomId() });
startGame(); // { type: ‘START_GAME’, payload: { next: ‘red’ } }
startGame(); // { type: ‘START_GAME’, payload: { next: ‘blue’ } }
startGame(); // { type: ‘START_GAME’, payload: { next: ‘yellow’ } }
View actions.js
const lightenPad = createAction(LIGHTEN_PAD);
const lightenOffPad = createAction(LIGHTEN_OFF_PAD);
lightenPad({ id: 'green' }); // { type: 'LIGHTEN_PAD', payload: { id: 'green' } };
lightenOffPad(); // { type: 'LIGHTEN_OFF_PAD', payload: {} };
function pads(state, action) {
const { type, payload } = action;
switch(type) {
case LIGHTEN_PAD:
You can’t perform that action at this time.