Skip to content

Instantly share code, notes, and snippets.

View flipjs's full-sized avatar
:octocat:
hjkl

Felipe Apostol flipjs

:octocat:
hjkl
View GitHub Profile

Keybase proof

I hereby claim:

  • I am flipjs on github.
  • I am flipjs (https://keybase.io/flipjs) on keybase.
  • I have a public key whose fingerprint is 8B91 5D62 53C1 CC43 83A0 3FFC E919 EE6A 0E35 4F95

To claim this, I am signing this object:

@flipjs
flipjs / destructuring.md
Created October 29, 2016 20:55 — forked from yang-wei/destructuring.md
Elm Destructuring (or Pattern Matching) cheatsheet

Destructuring(or pattern matching) is a way used to extract data from a data structure(tuple, list, record) that mirros the construction. Compare to other languages, Elm support much less destructuring but let's see what it got !

Tuple

myTuple = ("A", "B", "C")
myNestedTuple = ("A", "B", "C", ("X", "Y", "Z"))

let
  (a,b,c) = myTuple
@flipjs
flipjs / inject-store.js
Last active June 3, 2016 08:01
MobX - Injecting store to components
import React from 'react'
import { observer } from 'mobx-react'
import store from '../store'
function UserList (props) {
const {users} = props.store
return (
<ul>
{users.map(user => <li key={user.id}>{user.name}</li>)}
</ul>
@flipjs
flipjs / advisories-messages.js
Last active November 26, 2018 02:18
Redux Ducks
// Reducer Actions
import keyMirror from 'key-mirror'
export const MESSAGES = keyMirror({
GET_ALL_ADVISORIES_REQUESTED: null,
GET_ALL_ADVISORIES_RESOLVED: null,
GET_ALL_ADVISORIES_REJECTED: null
})
@flipjs
flipjs / str-join.js
Last active April 29, 2016 15:49
Join strings or array of strings
// Concatenates all the elements of a string array, using the specified separator between each element.
function strJoin (...args) {
const [delimiter, ...strings] = args
if (!delimiter || !strings.length) {
throw new Error('Invalid number of arguments.')
}
if (Array.isArray(...strings)) {
const [arr] = strings
if (!arr.length) {
@flipjs
flipjs / ConnectNavigation.js
Created April 24, 2016 15:59 — forked from iammerrick/ConnectNavigation.js
A higher order "smart" component that encapsulates all the logic for fetching and storing state. Especially smart because it accepts any "dumb" component, dumb components can be dropped on a page without knowing about their smart parents.
import React from 'react';
import { connect } from 'react-redux';
import { selectNavigation, selectState } from 'state/home/navigation/navigationSelectors';
import { getNavigation } from 'state/home/navigation/navigationActions';
const ConnectHomeNavigation = (Component) => {
return connect((state) => ({
navigation: selectNavigation(state),
state: selectState(state)
}), {
@flipjs
flipjs / toastSaga.js
Created April 15, 2016 14:30 — forked from slorber/toastSaga.js
How to wait for burgers (response to http://jlongster.com/Two-Weird-Tricks-with-Redux)
function* displayer() {
const MaxToasts = 3;
const ToastDisplayTime = 4000;
let pendingToasts = [];
let activeToasts = [];
@flipjs
flipjs / filter-data.js
Created January 25, 2016 23:56
filter-data
var data = [
{
id: 1,
name: 'felipe',
job: 'developer',
comment: 'hello world'
},
{
id: 2,
name: 'felipe',
@flipjs
flipjs / reduxtest.js
Created December 29, 2015 17:06
redux testing
import React from 'react'
import ReactDOM from 'react-dom'
import {createStore, combineReducers, applyMiddleware} from 'redux'
// we need the thunk to delay the evaluation in async functions
import thunk from 'redux-thunk'
// Action Creators
// synchronous
const setName = name => ({
@flipjs
flipjs / .vimrc
Created October 18, 2015 15:23 — forked from andyfowler/.vimrc
Swap iTerm2 cursors in vim insert mode when using tmux
" tmux will only forward escape sequences to the terminal if surrounded by a DCS sequence
" http://sourceforge.net/mailarchive/forum.php?thread_name=AANLkTinkbdoZ8eNR1X2UobLTeww1jFrvfJxTMfKSq-L%2B%40mail.gmail.com&forum_name=tmux-users
if exists('$TMUX')
let &t_SI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=1\x7\<Esc>\\"
let &t_EI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=0\x7\<Esc>\\"
else
let &t_SI = "\<Esc>]50;CursorShape=1\x7"
let &t_EI = "\<Esc>]50;CursorShape=0\x7"
endif