Skip to content

Instantly share code, notes, and snippets.

View franciscoj's full-sized avatar
🎯
Focusing

Fran Casas franciscoj

🎯
Focusing
View GitHub Profile
@franciscoj
franciscoj / vim.diff
Created October 11, 2017 08:15
Better moving around on vim
-" Window move around
-nnoremap <silent><C-j> :wincmd j<CR>
-nnoremap <silent><C-k> :wincmd k<CR>
-nnoremap <silent><C-l> :wincmd l<CR>
-nnoremap <silent><C-h> :wincmd h<CR>
+" Move between windows
+nnoremap <silent><leader>j :wincmd j<CR>
+nnoremap <silent><leader>k :wincmd k<CR>
+nnoremap <silent><leader>l :wincmd l<CR>
+nnoremap <silent><leader>h :wincmd h<CR>
@franciscoj
franciscoj / vid2gif.sh
Created August 4, 2016 14:50
Transform a video into an animated gif.
#!/bin/sh
# Extracted from: http://blog.pkh.me/p/21-high-quality-gif-with-ffmpeg.html#usage
palette="/tmp/palette.png"
filters="fps=15,scale=640:-1:flags=lanczos"
ffmpeg -v warning -i $1 -vf "$filters,palettegen" -y $palette
ffmpeg -v warning -i $1 -i $palette -lavfi "$filters [x]; [x][1:v] paletteuse" -y $2
@franciscoj
franciscoj / ivar_vs_reader.md
Last active May 9, 2016 17:27
ivar vs reader

Ruby: ivar vs readers

Spoiler alert: Readers win.

  1. You don't rely on the instance state.
  2. You've better protection againt typos. @ivar might not exist and nothing will fail ivar will complain.
  3. They're easier to mock in specs in case you need to.
  4. They properly wrap the state so that refactors are easier
  5. they can be aliased
  6. they can be alias_method_chained
[Desktop Entry]
Name=Spacemacs
GenericName=Text Editor
Comment=Edit text
MimeType=text/english;text/plain;text/x-makefile;text/x-c++hdr;text/x-c++src;text/x-chdr;text/x-csrc;text/x-java;text/x-moc;text/x-pascal;text/x-tcl;text/x-tex;application/x-shellscript;text/x-c;text/x-c++;
Exec=emacsclient -c %F
Icon=~/.emacs.d/core/banners/img/spacemacs.png
Type=Application
Terminal=false
Categories=Development;TextEditor;
[Unit]
Description=Emacs daemon
[Service]
Type=forking
ExecStart=/usr/bin/emacs --daemon
ExecStop=/usr/bin/emacsclient --eval "(kill-emacs)"
Restart=always
[Install]
@franciscoj
franciscoj / reek-flycheck.el
Last active August 22, 2016 09:33
How to see reek analysis on emacs with flycheck.
;; To have reek to smell-check the ruby files
(flycheck-define-checker ruby-reek
"A Ruby smeel checker using reek
See URL `https://github.com/troessner/reek'."
:command ("reek" "--format=xml"
source-original)
:standard-input t
:error-parser flycheck-parse-checkstyle
:modes (enh-ruby-mode ruby-mode)
:next-checkers ((info . ruby-rubocop)))
@franciscoj
franciscoj / .dir-locals.el
Created January 8, 2016 10:01
Configure project to use local eslint (the one in your node-modules)
;; -*- mode: emacs-lisp; -*-
;; It will ask you whether those are safe values when opening a file on the project,
;; type `!` then to make take it as safe values :)
;; Take into account that it will add this as a safe value to your ~/.spacemacs
((nil . ((eval . (progn
(setq flycheck-javascript-eslint-executable
"/path/to/the/project/node_modules/.bin/eslint")
)))))
@franciscoj
franciscoj / pjson
Last active December 23, 2015 04:08
Pretty pring json from the command line
#!/bin/sh
# Put this file on your ~/bin, give it +x and then run it like:
# curl whatever.jon/it-gives.json | pjson
# It will print a pretty printed version of the josn file.
python -mjson.tool
@franciscoj
franciscoj / csv2csv.rb
Created July 24, 2013 08:59
Small ruby script to transform a CSV file into a VCF file.
# Requires fastercsv and vpim gems to be installed
require 'rubygems'
require 'fastercsv'
require 'vpim/vcard'
card = Vpim::DirectoryInfo.create([Vpim::DirectoryInfo::Field.create('VERSION', '2.1')], 'VCARD')
FasterCSV.foreach('contactos.csv') do |row|
first_name = row[1]
@franciscoj
franciscoj / simple_form.rb
Created November 2, 2011 16:57
Use twitter bootstrap with simple_form
# config/initializer/simple_form.rb
SimpleForm.setup do |config|
config.hint_class = "hint input"
config.error_class = 'error input'
config.wrapper_class = :clearfix
config.wrapper_error_class = :error
end