This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#http://gist.github.com/raw/269432/e258ffe91e309b7e472d76f9aa98fdddda64cea4/letter.rb | |
class Numeric | |
def to_letters | |
letras = "" | |
number = self*1.0 | |
# Separo los decimales de los enteros | |
str_split = number.to_s.split(".") | |
entero = str_split[0] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Customer < ActiveRecord::Base | |
attr_accessible :name, :customer_code | |
has_many :payments | |
has_many :orders | |
def place_order(line_items = []) | |
self.orders.create.fill_with_products(line_items) | |
end | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PostsController < InheritedResources::Base | |
belongs_to :blog, :optional => true | |
before_filter :admin_or_owner_only, :only => [:create,:new,:update,:edit,:destroy] | |
after_filter :register_post_visit, :only =>[:show,:index] | |
before_filter :register_brain_buster, :only => [:show] | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Dependencias previas | |
sudo apt-get install libc6 libpcre3 libpcre3-dev libpcrecpp0 libssl0.9.8 libssl-dev zlib1g zlib1g-dev lsb-base | |
#Instalamos Passenger | |
sudo gem install passenger | |
sudo passenger-install-apache-module | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
print "Hola" | |
puts "Hola" | |
x = "Hola" | |
puts x | |
x = "Hola" | |
print x | |
x = "Hola" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Analyze | |
def load_visits(filename="Visitas26") | |
filename << ".txt" | |
visits = File.read(filename) | |
visits = visits.split("\r") | |
visits = visits[1..-1] | |
array = visits.map do |visit| | |
url, visits, timestamp = visit.split("\t") | |
post_id = url.split("/").last |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
files = File.read("gems.txt") | |
files.each do |line| | |
line = line.chop!.split(" (") | |
#puts "Gema: #{line[0]} Version: #{line[1].chop!}" | |
puts "Instalando gema: #{line[0]}" | |
line[1].chop!.split(", ").reverse.each do |version| | |
puts "Instalando version #{version}" | |
puts "sudo gem install #{line[0]} -v=#{version} --no-ri --no-rdoc" | |
result = `sudo gem install #{line[0]} -v=#{version} --no-ri --no-rdoc` | |
puts result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Location /> | |
# Insert filter | |
SetOutputFilter DEFLATE | |
# Netscape 4.x nos da algunos problemas | |
BrowserMatch ^Mozilla/4 gzip-only-text/html | |
# Netscape 4.06-4.08 tambien | |
BrowserMatch ^Mozilla/4\.0[678] no-gzip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ActionController::Base.asset_host = Proc.new { |source| | |
if source.starts_with?('/images') | |
"http://images.semanaeconomica.com" | |
else | |
"http://scripts.semanaeconomica.com" | |
end | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/ruby | |
require 'redgreen' | |
require 'autotest/timestamp' | |
module Autotest::GnomeNotify | |
def self.notify title, msg, img | |
system "notify-send '#{title}' '#{msg}' -i #{img} -t 3000" | |
end | |
Autotest.add_hook :ran_command do |at| |