Skip to content

Instantly share code, notes, and snippets.

View jaimeiniesta's full-sized avatar

Jaime Iniesta jaimeiniesta

View GitHub Profile
# encoding: UTF-8
# Guess the charset encoding of a given input, by submitting it to vote to different guessers.
require 'rubygems'
require 'open-uri'
if RUBY_VERSION > "1.9"
# ruby encodings only work on 1.9
class Yukihiro
def guess_charset(str)
Bundler reports nearly 60 gems to be used by pagerankalert.com and its dependencies
-----> Gemfile detected, running Bundler version 1.0.0.rc.5
Unresolved dependencies detected; Installing...
Fetching source index for http://rubygems.org/
Fetching git://github.com/jaimeiniesta/metainspector.git
Fetching git://github.com/cavalle/steak.git
Installing rake (0.8.7)
Installing abstract (1.0.0)
Installing activesupport (3.0.0.rc)
class SitemapController < ApplicationController
def sitemap
@plants = Plant.find(:all)
respond_to do |format|
format.xml
end
end
require "net/http"
module GooglePageRank
M=0x100000000 # modulo for unsigned int 32bit(4byte)
def m1(a,b,c,d)
return (((a+(M-b)+(M-c))%M)^(d%M))%M # mix/power mod
end
feature "Articles", %q{
In order to manage articles
As an editor
I want to create, list, show, edit, update and destroy articles
} do
background do
Article.create(:title => 'First article', :body => 'My first article')
Article.create(:title => 'Second article', :body => 'My second article')
Article.create(:title => 'Third article', :body => 'My third article')
A small test to know if Rails 3 will double-escape already escaped strings, say, you've got your typical h(str), will str be escaped once by default and then escaped once again by h()? It does not look like this will happen (tried with rails 2.3.5 and the rails_xss plugin)
### .erb file
<% str = "A string that needs <strong>escaping</strong>" %>
<p>
Not escaped: <%= str %>
</p>
<p>
Escaped with h: <%= h str %>