Skip to content

Instantly share code, notes, and snippets.

View weslleyaraujo's full-sized avatar
💤

Weslley Araujo weslleyaraujo

💤
View GitHub Profile
var users = [
'yellow',
'green',
'pink',
'blue'
];
var sepa = [];
for (var i in users) {
@weslleyaraujo
weslleyaraujo / iffy.js
Last active February 18, 2016 11:56
add behavior on input's based on values
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define(['jquery'], factory);
} else if (typeof exports === 'object') {
module.exports = factory(require('jquery'));
} else {
root.Iffy = factory(root.$);
}
const crashReporter = store => next => action => {
try {
return next(action)
} catch (err) {
console.error('Caught an exception!', err)
// capture error somehow here: action, store.getState()
throw err;
}
}
git log --first-parent --pretty=format:'%s' \
| grep -v '^update changelog' \
| perl -p -e 's/^((v?[0-9]+\.?)+)$/\n## \1\n/g' \
| perl -p -e 's/^([^#\s].*)$/* \1/g'

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
import color from ‘color’; // a simple color helper library
import styled from ‘styled-components’;
const lighten = from => color(from).lighten(0.333).hexString();
const activeCSS = props => `
 background-color: ${lighten(props.color)} !important;
`;
export const Pad = styled.div`
 /* some styles here … */
${(props) => props.active ? activeCSS(props) : ‘’}
{
 pads: [
{
id: ‘green’,
component: ‘GreenPad’,
active: false
},
// More pads here
 ],
 game: {
import React, { Component } from 'react';
import audios from '../audios';
import { connect } from 'react-redux';
export class Player extends Component {
componentDidUpdate() {
const { active } = this.props;
const player = this.refs[active];
if (!player) {
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:
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’ } }