Skip to content

Instantly share code, notes, and snippets.

View fervisa's full-sized avatar

Fernando Villalobos fervisa

  • Oaxaca, México
View GitHub Profile
function countCSSRules() {
var results = '',
log = '';
if (!document.styleSheets) {
return;
}
for (var i = 0; i < document.styleSheets.length; i++) {
countSheet(document.styleSheets[i]);
}
function countSheet(sheet) {
@fervisa
fervisa / String#truncate
Created July 2, 2013 22:31
Javascript truncate method for strings. Replaces the end of string with ellipsis (...)
String.prototype.truncate =
function(n){
return this.substr(0, n-1)+(this.length > n ? '&hellip;' : '');
};
@fervisa
fervisa / String#truncate
Created July 2, 2013 22:33
CoffeeScript truncate method for strings. Replaces the end of string with ellipsis (...)
String::truncate = (n) ->
@substr(0, n - 1) + ((if @length > n then "&hellip;" else ""))
require 'rubygems'
require 'rubygems/package'
require 'zlib'
require 'fileutils'
module Util
module Tar
# Creates a tar file in memory recursively
# from the given path.
#
@fervisa
fervisa / hash_rocket => semicolon
Created September 1, 2013 17:42
Vim command to convert hash_rocket sintax to semicolon
%s/:\(\w*\) =>/\1:/gc
@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.\+'
@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 / gist:9539639
Created March 13, 2014 23:59
Script de Vim para convertir hashrocket (=>) a colon (:) Ruby
%s/:\(\w*\) =>/\1:/gc
@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 / 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