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 / hash_rocket => semicolon
Created September 1, 2013 17:42
Vim command to convert hash_rocket sintax to semicolon
%s/:\(\w*\) =>/\1:/gc
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 / 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 "…" else ""))
@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 ? '…' : '');
};
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) {