Skip to content

Instantly share code, notes, and snippets.

View fervisa's full-sized avatar

Fernando Villalobos fervisa

  • Oaxaca, México
View GitHub Profile
@fervisa
fervisa / vim_short.md
Last active January 14, 2017 19:05 — forked from apux/1_vim_short.md
mkdir -p ~/.vim/autoload ~/.vim/bundle; \
curl -Sso ~/.vim/autoload/pathogen.vim \
    https://raw.github.com/tpope/vim-pathogen/master/autoload/pathogen.vim
set nocompatible
execute pathogen#infect()
syntax on
@fervisa
fervisa / sanitize.rb
Created May 22, 2014 22:50
Ejemplo de transformer
gray_title = lambda do |env|
node = env[:node]
return if !node.elem? or !['p'].member? node.name or !['#D9D9D9', '#E0E0E0'].member? node.styles['background']
node.name = 'h1'
node['class'] = 'gray-title'
node.delete 'style'
node.parent.replace node
return {:node_whitelist => [node]}
end
@fervisa
fervisa / sanitize.rb
Created May 22, 2014 00:20
Cleaning converted docx -> html file
require 'rubygems'
require 'sanitize'
require 'nokogiri-styles'
no_whitespaces = lambda {|env|
node = env[:node]
return unless node.elem?
unless node.children.any?{|c| !c.text? || c.content.strip.length > 0 }
node.unlink
@fervisa
fervisa / queries-no-ajax.rb
Last active August 29, 2015 14:01
SQL from users/index
# All users (count)
# ======================
SELECT COUNT(DISTINCT "users"."id") FROM "users" LEFT OUTER JOIN "ole_core"."logins" ON "ole_core"."logins"."id" = "users"."login_id" LEFT OUTER JOIN "ole_core"."taggings" ON "ole_core"."taggings"."taggable_id" = "ole_core"."logins"."id" AND ole_core.taggings.context = ('udfs') AND "ole_core"."taggings"."taggable_type" = 'OleCore::Login' LEFT OUTER JOIN "ole_core"."tags" ON "ole_core"."tags"."id" = "ole_core"."taggings"."tag_id" WHERE (logins.account_id = 5359 and (logins.id = 59251 or logins.role >= 6) and users.status != 'Retired' and users.deleted_at is null)
# current subscription x5
# ======================
SELECT "ole_core"."subscriptions".* FROM "ole_core"."subscriptions" WHERE "ole_core"."subscriptions"."deleted_at" IS NULL AND "ole_core"."subscriptions"."account_id" = 5359 LIMIT
# subscription plan
# ======================
@fervisa
fervisa / queries_2.rb
Created May 14, 2014 18:07
SQL from users/index
# All users (count)
# ======================
SELECT COUNT(DISTINCT "users"."id") FROM "users" LEFT OUTER JOIN "ole_core"."logins" ON "ole_core"."logins"."id" = "users"."login_id" LEFT OUTER JOIN "ole_core"."taggings" ON "ole_core"."taggings"."taggable_id" = "ole_core"."logins"."id" AND ole_core.taggings.context = ('udfs') AND "ole_core"."taggings"."taggable_type" = 'OleCore::Login' LEFT OUTER JOIN "ole_core"."tags" ON "ole_core"."tags"."id" = "ole_core"."taggings"."tag_id" WHERE (logins.account_id = 5359 and (logins.id = 59251 or logins.role >= 6) and users.status != 'Retired' and users.deleted_at is null)
# Filtered users (count)
# ======================
SELECT COUNT(DISTINCT "users"."id") FROM "users" LEFT OUTER JOIN "ole_core"."logins" ON "ole_core"."logins"."id" = "users"."login_id" LEFT OUTER JOIN "ole_core"."taggings" ON "ole_core"."taggings"."taggable_id" = "ole_core"."logins"."id" AND ole_core.taggings.context = ('udfs') AND "ole_core"."taggings"."taggable_type" = 'OleCore::Login' LEFT OUTER JOIN "ol
@fervisa
fervisa / queries_1.rb
Created May 14, 2014 16:36
SQL from users/index
# All users (count)
# ======================
SELECT COUNT(DISTINCT "users"."id") FROM "users" LEFT OUTER JOIN "ole_core"."logins" ON "ole_core"."logins"."id" = "users"."login_id" LEFT OUTER JOIN "ole_core"."taggings" ON "ole_core"."taggings"."taggable_id" = "ole_core"."logins"."id" AND ole_core.taggings.context = ('udfs') AND "ole_core"."taggings"."taggable_type" = 'OleCore::Login' LEFT OUTER JOIN "ole_core"."tags" ON "ole_core"."tags"."id" = "ole_core"."taggings"."tag_id" WHERE (logins.account_id = 5359 and (logins.id = 59251 or logins.role >= 6) and users.status != 'Retired' and users.deleted_at is null)
# Filtered users
# ======================
SELECT DISTINCT "users".id, logins.first_name, logins.last_name, logins.id AS alias_0 FROM "users" LEFT OUTER JOIN "ole_core"."logins" ON "ole_core"."logins"."id" = "users"."login_id" LEFT OUTER JOIN "ole_core"."taggings" ON "ole_core"."taggings"."taggable_id" = "ole_core"."logins"."id" AND ole_core.taggings.context = ('udfs') AND "ole_core"."taggings"."taggable_ty
@fervisa
fervisa / queries.rb
Created May 14, 2014 00:31
SQL from users/index
# All users (count)
# ======================
SELECT COUNT(DISTINCT "users"."id") FROM "users" LEFT OUTER JOIN "ole_core"."logins" ON "ole_core"."logins"."id" = "users"."login_id" LEFT OUTER JOIN "ole_core"."taggings" ON "ole_core"."taggings"."taggable_id" = "ole_core"."logins"."id" AND ole_core.taggings.context = ('udfs') AND "ole_core"."taggings"."taggable_type" = 'OleCore::Login' LEFT OUTER JOIN "ole_core"."tags" ON "ole_core"."tags"."id" = "ole_core"."taggings"."tag_id" WHERE (logins.account_id = 5359 and (logins.id = 59251 or logins.role >= 6) and users.status != 'Retired' and users.deleted_at is null)
# Filtered users
# ======================
SELECT DISTINCT "users".id, logins.first_name, logins.last_name, logins.id AS alias_0 FROM "users" LEFT OUTER JOIN "ole_core"."logins" ON "ole_core"."logins"."id" = "users"."login_id" LEFT OUTER JOIN "ole_core"."taggings" ON "ole_core"."taggings"."taggable_id" = "ole_core"."logins"."id" AND ole_core.taggings.context = ('udfs') AND "ole_core"."taggings"."taggable_ty
@fervisa
fervisa / gist:9539639
Created March 13, 2014 23:59
Script de Vim para convertir hashrocket (=>) a colon (:) Ruby
%s/:\(\w*\) =>/\1:/gc
@fervisa
fervisa / save_screenshot
Created November 8, 2013 23:17
Save a screenshot in png file within a cabypara step definition
Capybara.save_screenshot 'tmp/my_screen.png'
@fervisa
fervisa / match 80 char
Created October 15, 2013 15:33
Resaltado en vim al exceder los 80 caracteres por línea
match ErrorMsg '\%>80v.\+'