Skip to content

Instantly share code, notes, and snippets.

jmarceli / .vimrc
Created Mar 30, 2019
Updated .vimrc configuration for ReactJS development
View .vimrc
set runtimepath^=~/.vim runtimepath+=~/.vim/after
let &packpath = &runtimepath
source ~/.vimrc
""" tagbar
""" tern_for_vim
""" vim-obsession
""" ctrlp.vim
jmarceli / .vimrc
Created Mar 29, 2019
Flow suggestions
View .vimrc
nnoremap <leader>fa :execute ":! yarn --silent flow type-at-pos --quiet %" line(".") col(".") "\| grep '^type' \| yarn --silent prettier --stdin-filepath test.js"<cr>
View docker-compose.yml
version: '2'
image: grafana/grafana:5.0.0 # or probably any other version
container_name: grafana
restart: always
- VIRTUAL_HOST=YOUR.DOMAIN.TEST # adjust to match your domain name
View .vimrc
" RELOAD WITHOUT closing vim
" :so ~/.vimrc
set nocompatible
" Specify a directory for plugins
" - For Neovim: ~/.local/share/nvim/plugged
jmarceli / Capfile
Last active Dec 9, 2015 Rails Capistrano deploy (based on CucumisSativus/Capfile), '>' used instead of '/' in file path
View Capfile
# Load DSL and set up stages
require 'capistrano/setup'
# Include default deployment tasks
require 'capistrano/deploy'
# Include tasks from other gems included in your Gemfile
require 'capistrano/rvm'
require 'capistrano/bundler'
require 'capistrano/rails/assets'
View gist:91bc44a4ff8c0d10eb11

zo - open folding
za - toggle folding
zc - close folding

zf - create manual folding from selection

View React random

How to redirect from route if sth. (e.g. not logged in)

function createRoutes() {
  function requireLogin(store) {
    return (nextState, replaceState) => {
      const { users: { user }} = store.getState();
      if (_.isEmpty(user)) { // or any other authentication condition
 replaceState({ nextPathname: nextState.location.pathname }, '/');
jmarceli /
Last active Oct 31, 2019
React errors explained


You will get one of these:

Uncaught (in promise) TypeError: Cannot read property 'toUpperCase' of undefined(…)

ReactCompositeComponent.js:870 Uncaught TypeError: Cannot read property 'displayName' of undefined

if you try to:

jmarceli / gist:651301ea895e48774896
Created Mar 31, 2015
client_side_validations with select2 and Ajax
View gist:651301ea895e48774896

Possible complete Select2 integration

Full live (client side) validation, "developed" to use with simple_form and foundation markup (should work in other cases too).

Create separate .coffee file e.g. with following code:

# Add select2 support
ClientSideValidations.selectors.validate_inputs += ', select[data-select2-validate]'
ClientSideValidations.selectors.inputs += ', .select2-container'
View gist:818f44f98557a46049e7
#! /usr/bin/env ruby
# Modified from :
# NOTE: This opens with a link to the mvim protocol for compatibility with RailsPanel
# goes to /usr/local/bin/cvim
require 'uri'
require 'cgi'
full_path = ARGV[0]