Skip to content

Instantly share code, notes, and snippets.

View mrsimo's full-sized avatar
💃
./do run hello

Albert Llop mrsimo

💃
./do run hello
View GitHub Profile
def get_images
require 'action_controller'
require 'action_controller/test_process.rb'
require 'mime/types' # gem install mime-types
@log = Array.new
@posts = WpaPost.find :all
@results = Array.new
# hacer un bucle recorriendo lo que sea que tiene las posibles imagenes.
require 'rubygems'
require 'spider' # sudo gem install spider
Spider.start_at('http://localhost/') do |s|
# Limit the pages to just this domain.
s.add_url_check do |a_url|
a_url =~ %r{^http://localhost.*}
end
# Handle 404s.
root@ip-10-224-81-194:/etc/chef# chef-client
/usr/lib/ruby/1.8/net/http.rb:2097:in `error!': 400 "Bad Request" (Net::HTTPServerException)
from /usr/lib/ruby/gems/1.8/gems/chef-0.6.2/lib/chef/rest.rb:227:in `run_request'
from /usr/lib/ruby/gems/1.8/gems/chef-0.6.2/lib/chef/rest.rb:90:in `post_rest'
from /usr/lib/ruby/gems/1.8/gems/chef-0.6.2/lib/chef/client.rb:205:in `authenticate'
from /usr/lib/ruby/gems/1.8/gems/chef-0.6.2/lib/chef/client.rb:70:in `run'
from /usr/lib/ruby/gems/1.8/gems/chef-0.6.2/bin/chef-client:125
from /usr/lib/ruby/gems/1.8/gems/chef-0.6.2/bin/chef-client:119:in `loop'
from /usr/lib/ruby/gems/1.8/gems/chef-0.6.2/bin/chef-client:119
from /usr/bin/chef-client:19:in `load'
We couldn’t find that file to show.
def create
@roseta = Roseta.new(params[:roseta])
if @roseta.save
flash[:notice] = 'Roseta creada.'
lastros = Roseta.find(:first,:order=>"id desc")
redirect_to :action => 'edit', :id => lastros.id
else
@errors = 'd'
render :action => 'new'
end
result = false or true # => true
result # => false
result = false || true # => true
result # => true
Status: 500 Internal Server Error
uninitialized constant MysqlCompat::MysqlRes
line = " Transferencia al C.Cost 9100000012 -594,00 15/03/10 traspas fundacio A.Mass\363"
regexp = /^(.+)\s+([-|\d|\.|,]+)\s+(\d+\/\d+\/\d+)\s+(.+)*$/
line.match(regexp) # => 1min at 100% cpu usage
# How to make this more legible?
# n and m are any natural number
n=1; m=12
(n..m).map{ |i| ["%02d"%i,i] }
#=> [["01", 1], ["02", 2], ["03", 3], ["04", 4], ["05", 5], ["06", 6], ["07", 7], ["08", 8], ["09", 9], ["10", 10], ["11", 11], ["12", 12]]
commit 2400f944f6b5d850c33158ae27f501e9ec8c1aba
Author: Albert Llop <mrsimo@gmail.com>
Date: Thu Aug 26 16:07:46 2010 +0200
First steps into the Package module
Allows the installation of packages from a url. For example:
require 'geoffrey'
Geoffrey.package do