Skip to content

Instantly share code, notes, and snippets.

View gist:818f44f98557a46049e7
#! /usr/bin/env ruby
# Modified from : http://www.tkalin.com/blog_posts/using-console-vim-as-vim-protocol-handler-in-ubuntu
# 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]
@jmarceli
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. client_side_select2.js.coffee with following code:

# Add select2 support
ClientSideValidations.selectors.validate_inputs += ', select[data-select2-validate]'
ClientSideValidations.selectors.inputs += ', .select2-container'
View React random thoughts.md

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 }, '/');
View gist:91bc44a4ff8c0d10eb11

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

zf - create manual folding from selection

@jmarceli
jmarceli / Capfile
Last active Dec 9, 2015
mydevil.net 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 .vimrc
" RELOAD WITHOUT closing vim
" :so ~/.vimrc
"
set nocompatible
"""""""""""""""""""
" PLUGINS
"""""""""""""""""""
" Specify a directory for plugins
" - For Neovim: ~/.local/share/nvim/plugged
@jmarceli
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>
@jmarceli
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
"""
""" EXPERIMENTAL
""" tagbar
""" tern_for_vim
""" vim-obsession
""" ctrlp.vim
"""
@jmarceli
jmarceli / README.md
Last active Oct 31, 2019
React errors explained
View README.md

1

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:

View docker-compose.yml
version: '2'
services:
grafana:
image: grafana/grafana:5.0.0 # or probably any other version
container_name: grafana
restart: always
environment:
- VIRTUAL_HOST=YOUR.DOMAIN.TEST # adjust to match your domain name
- VIRTUAL_PROTO=https