Skip to content

Instantly share code, notes, and snippets.

View vsalbaba's full-sized avatar

Vojtech Salbaba vsalbaba

  • Red Hat
  • Czech Republic
View GitHub Profile
@vsalbaba
vsalbaba / gist:1050924
Created June 28, 2011 11:14
Generovani hesla z mysql
def generate_mysql_hash(password)
# pouze pokud bezime na MySQL
if ActiveRecord::Base.connection.adapter_name == "MySQL" then
# prohnat sql cistici funkci proti sql_injection
parameters = ActiveRecord::Base.send :sanitize_sql_array, ["password('%s')", password]
ActiveRecord::Base.connection.execute("select #{parameters}").fetch_row.first
else
password
end
end
@vsalbaba
vsalbaba / cares.xml
Created July 6, 2011 19:34
cares.xml
<cares type="array">
<care>
<name>asdfasdfafds</name>
<original-id type="integer" nil="true"/>
<created-at type="datetime">2011-07-05T17:28:57Z</created-at>
<updated-at type="datetime">2011-07-05T17:30:18Z</updated-at>
<id type="integer">1</id>
<short-name>adsfasdf</short-name>
<description nil="true"/>
<rates-string>
line = "<p>aaa bbb ccc <abbr title=\"AUTHOR:5\">toto je autor</abbr> ddd eee fff <abbr title=\"WORK:10\">toto je jeho dilo</abbr></p>"
regexp = /<abbr title=\"(.*?):(.*?)\">(.*?)<\/abbr>/
line.scan(regexp)
# => [["AUTHOR", "5", "toto je autor"], ["WORK", "10", "toto je jeho dilo"]]