Skip to content

Instantly share code, notes, and snippets.

View guillermo's full-sized avatar
😍
Processing request ...

Guillermo Álvarez guillermo

😍
Processing request ...
View GitHub Profile
@guillermo
guillermo / hash_to_array_with_order.rb
Created October 10, 2010 15:26
hash to array with order
class HashToArrayWithOrder
class MaxDepth < Exception ; end
def self.new(data,max_level = 5)
raise MaxDepth if max_level==0
if data.is_a? Hash
data = data.sort{|a,b| a.class == b.class ? a.to_s <=> b.to_s : a.class.to_s <=> b.class.to_s}
end
return data unless data.is_a? Array
@guillermo
guillermo / application_controller.rb
Created October 19, 2010 16:22
application controller arround filter to log
around_filter do |controller, action|
@start_time = Time.now
set_trace_func proc { |event, file, line, id, binding, classname|
if (@file != file && @line != line)
@file, @line = file, line
if (%w(call c-call).include? event)
file = @file[(Rails.root.to_s.size+1)..-1]
if @file[0...(Rails.root.to_s.size)] == Rails.root.to_s && !(file =~ /vendor\/plugins\/newrelic_rpm/)
@logger ||= Logger.new(File.join(Rails.root,'tmp/trace'))
args = []
module RequireLoggedUser
protected
def require_logged_user!
before_filter do
return true if current_user.present?
# if the method hasn't returned, there is no user logged in!
# flash a warning and redirect the user to the log in page
flash[:warning] = "You must log in before proceeding!"
redirect_to new_user_session_path and return
end
[root@es01 ~]# hdparm -Tt /dev/sda1
/dev/sda1:
Timing cached reads: 10004 MB in 2.00 seconds = 5012.25 MB/sec
Timing buffered disk reads: 14 MB in 3.38 seconds = 4.14 MB/sec
[root@es01 ~]# dd if=/dev/urandom of=/tmp/urandom count=100000
100000+0 records in
100000+0 records out
51200000 bytes (51 MB) copied, 14.4699 seconds, 3.5 MB/s
@guillermo
guillermo / debug.coffee
Created June 21, 2011 14:50
CoffeSnippets
debug = () ->
s = ""
for arg in arguments
unless typeof(arg) == "string"
arg = JSON.stringify arg
s += "#{arg} :"
window.console.debug s
@guillermo
guillermo / download_song.rb
Created August 3, 2011 20:04
Little script to download and convet music
#!/usr/bin/env ruby
=begin
README
======
Download any youtube video, in the original format ogg without
loosing quality, and also convert a mp3 from the ogg.
You have to decide if the mp3 quality is enough for you. Or you
can adjust the parameters of the conversion if you need the mp3
@guillermo
guillermo / Rakefile
Created September 15, 2011 20:48
Use module inside Rakefile
module Utils
extend self
def install
puts "Installing"
end
end
desc "We are going to install... LA LA LA"
# Option 1
# The clean one, you can move the class to other file
module Utils
extend self
def install
puts "Installing"
end
end
@guillermo
guillermo / peliculas.csv
Created November 14, 2011 12:30
Peliculas
We can make this file beautiful and searchable if this error is corrected: It looks like row 3 should actually have 1 column, instead of 2. in line 2.
¡Mamma Mia! http://www.megavideo.com/?v=39G6ZIBW DVD Español
1997: Rescate en Nueva York http://www.megaupload.com/?d=1IQVR204 DVD-RIP Español
2001 una odisea en el espacio http://www.megaupload.com/?d=RJEPWE9Z 1,4Gb DVD-RIP
30 minutes or less 1 http://freakshare.com/files/36kax38u/los.changosos.part1.gz 271 MB DD
30 minutes or less 2 http://freakshare.com/files/9dfsg4zz/los.changosos.part2.gz 271 MB DD
300.avi http://www.fileserve.com/file/NfBQcz7 698.04 MB DD
Across The Universe DVDRip http://depositfiles.com/files/giklyvrqq 469.59 MB DD Dual
Amélie http://www.fileserve.com/file/mqVEMe3/ 700 MB DD
American Beauty http://www.megaupload.com/?d=W99XXY96 701 MB DD
Asterix en los Juegos Olímpicos (2008) http://www.megavideo.com/?v=JSNXVYH6 362.20 MB Streaming
@guillermo
guillermo / twitter_backup.rb
Created December 10, 2011 12:05 — forked from mort/twitter_backup.rb
Tweaking mort's fork of the Tweaking Guillermo's original script to add support for accounts with a huge amount of tweets ;), to use the new twitter api.
#!/usr/bin/env ruby
=begin
DESCRIPTION
This little program will save all tweets from a user timelime to files
~/.twitter_backup/tweets/tweet_id.yaml # Full yaml tweet
~/.twitter_backup/tweets/tweet_id.txt # Only tweet text
You can search your tweets with: