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
@kitze
kitze / conditionalwrap.js
Created October 25, 2017 16:54
one-line React component for conditionally wrapping children
import React from 'react';
const ConditionalWrap = ({condition, wrap, children}) => condition ? wrap(children) : children;
const Header = ({shouldLinkToHome}) => (
<div>
<ConditionalWrap
condition={shouldLinkToHome}
wrap={children => <a href="/">{children}</a>}
>
@ddresselhaus
ddresselhaus / .vimrc
Last active January 21, 2021 18:05
run Elixir tests in a separate tmux pane
" when triggering this command, vim will grab your path and line location and pass it along
map <Leader>el :call RemoteSendCommand(TestLineCommand(expand("%:p"), line(".")))<CR>
" because I'm mostly writing Elixir and making heavy use of the REPL while writing my tests,
" I made a specific command to user with Mix, the Elixir task utility
" But I'm sure you could get this to work with vim-test or something like that
function! TestLineCommand(path, line_number)
let cmd = join(["mix test --only", " line:", a:line_number, " ", a:path], "")
return cmd
endfunction
@erikras
erikras / SearchBox.js
Last active September 23, 2020 03:03
A search box that replaces a query parameter in the url
import React, { Component, PropTypes } from 'react'
import { withRouter } from 'react-router'
import queryString from 'query-string'
@withRouter
export default class SearchBox extends Component {
static propTypes = {
router: PropTypes.object.isRequired
}
@iammerrick
iammerrick / ConnectNavigation.js
Last active May 30, 2023 20:06
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)
}), {
@slorber
slorber / toastSaga.js
Created April 13, 2016 15:56
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 = [];
@yang-wei
yang-wei / destructuring.md
Last active February 20, 2024 04:40
Elm Destructuring (or Pattern Matching) cheatsheet

Should be work with 0.18

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"))
@cgcardona
cgcardona / gist:79fa3a6dcd329c60c290
Last active August 29, 2015 14:23
The Atom.io packages that I use.
  • atom-fuzzy-grep
  • atom-jshint
  • color-picker
  • git-plus
  • highlight-selected
  • minimap
  • minimap-autohide
  • minimap-bookmarks
  • minimap-find-and-replace
  • minimap-git-diff
@kugaevsky
kugaevsky / revert.sh
Last active July 4, 2018 09:06
Reverting back to node 0.10.36 on Mac OS X with Homebrew
$ cd /usr/local
$ git checkout b64d9b9c431642a7dd8d85c8de5a530f2c79d924 Library/Formula/node.rb
$ brew unlink node
$ brew install node
$ npm install -g npm@latest
@Davidebyzero
Davidebyzero / gist:9221685
Last active August 23, 2023 07:14
Best known Regex Golf solutions (SPOILERS) - Classic level set - (SPOILERS)
  1. Plain Strings (207): foo
  2. Anchors (208): k$
  3. Ranges (202): ^[a-f]*$
  4. Backrefs (201): (...).*\1
  5. Abba (169): ^(.(?!(ll|ss|mm|rr|tt|ff|cc|bb)))*$|^n|ef
  6. A man, a plan (177): ^(.)[^p].*\1$
  7. Prime (286): ^(?!(..+)\1+$)
  8. Four (199): (.)(.\1){3}
  9. Order (198): ^[^o].....?$
  10. Triples (507): (^39|^44)|(^([0369]|([147][0369]*[258])|(([258]|[147][0369]*[147])([0369]*|[258][0369]*[147])([147]|[258][0369]*[258])))*$)