Skip to content

Instantly share code, notes, and snippets.

Avatar
:shipit:
Ship it!

Ricardo Shiota Yasuda shadowmaru

:shipit:
Ship it!
View GitHub Profile
View gist:340696
class UserPasswordCryptMD5
def self.encrypt(*tokens)
Digest::MD5.hexdigest(*tokens)
end
def self.matches?(crypted_password, *tokens)
encrypt(*tokens) == crypted_password
end
end
View gist:340694
acts_as_authentic do |c|
c.transition_from_crypto_providers = [UserPasswordCryptSHA, UserPasswordCryptMD5]
end
View gist:309131
location /atendimento.php {
rewrite /atendimento.php http://www.smartfit.com.br/atendimento permanent;
}
location /franquias.php {
rewrite /franquias.php http://www.smartfit.com.br/franchises/new permanent;
}
location /unidades.php {
rewrite /unidades.php http://www.smartfit.com.br/unidades permanent;
View gist:309129
Redirect /atendimento.php http://www.smartfit.com.br/atendimento
Redirect /unidades.php http://www.smartfit.com.br/unidades
Redirect /franquias.php http://www.smartfit.com.br/franchises/new
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/a-smartfit.php$
RewriteCond %{QUERY_STRING} ^idUnidade=1$
RewriteRule ^.*$ http://www.smartfit.com.br/unidades/brasilia? [L,R=301]
RewriteCond %{REQUEST_URI} ^/a-smartfit.php$
RewriteCond %{QUERY_STRING} ^idUnidade=2$
View create_nfo.rb
#!/usr/local/bin/ruby
videos = Dir.glob("Glee*.avi")
videos.each do |file|
file_parts = file.split(".")
file_parts.pop
filename = file_parts.join(".")
nfo = File.new("#{filename}.nfo", "w+")
nfo.puts("<musicvideo>
View gist:187837
>> extend Hirb::Console
=> main
>> view Page.find_by_name('About Us'), :class => :parent_child_tree, :type => :directory
About Us
|-- Contact
|-- Our History
|-- Mission
|-- Privacy Policy
`-- Terms of Use
View gist:187835
>> Post.all :limit => 5
+----+---------------+---------------+---------------+---------------+---------+---------------+---------------+-----------+---------------+
| id | name | body | published_at | permalink | user_id | created_at | updated_at | published | comments_c... |
+----+---------------+---------------+---------------+---------------+---------+---------------+---------------+-----------+---------------+
| 74 | Manipuland... | Uma das d?... | 2009-06-09... | manipuland... | 1 | 2009-06-09... | 2009-08-11... | true | 3 |
| 73 | Limpando o... | !/system/a... | 2009-04-22... | limpando-o... | 1 | 2009-04-22... | 2009-08-11... | true | 0 |
| 72 | Why's (poi... | <img src="... | 2009-04-09... | why-s-poig... | 1 | 2009-04-09... | 2009-08-11... | true | 0 |
| 70 | Evento: Ru... | No dia 4 d... | 2009-03-10... | evento-rub... | 1 | 2009-03-10... | 2009-08-10... | true | 1 |
| 68 | Dica r
View gist:187834
if ENV['RAILS_ENV']
require 'rubygems'
require 'hirb'
Hirb.enable
end
View gist:187833
$ script/console
Loading development environment (Rails 2.3.4)
>> require 'hirb'
=> []
>> Hirb.enable
=> nil
View local-backup.rb
DIRECTORIES = %w(Users/username)
TO = '/path/for/backup'
OPTIONS = { :rsync => '--progress -varRu', :remote => false }
rsync DIRECTORIES, nil, TO, OPTIONS