I hereby claim:
- I am ocean on github.
- I am ocean (https://keybase.io/ocean) on keybase.
- I have a public key whose fingerprint is FD45 4D63 9596 4B4E 7B4A D156 1C15 4316 3B37 2385
To claim this, I am signing this object:
# custom regex pattern for our URIs, allowing | |
# ampersands in the URL and ^s in the query string. | |
URI_EXTRA %{URIPROTO}://(?:%{USER}(?::[^@]*)?@)?(?:%{URIHOST})?(?:(?:/[A-Za-z0-9$.+!*'(){},~:;=&@#%_\-]*)+(?:\?[A-Za-z0-9$.+!*'|(){},~@#%&\^/=:;_?\-\[\]]*)?)? |
I hereby claim:
To claim this, I am signing this object:
p "Oh I see, a Gist is a bit like a Pastie." |
I got the idea, and most of this code, from this post at The Killswitch Collective: | |
http://www.killswitchcollective.com/articles/45_legacy_data_migration_with_activerecord | |
I'm sure that other bits of the code aren't going to work either, like the "if" statement | |
in the "publish" boolean field, I suppose there will be another way to make that work. |
#results.each do |row| | |
results.each_hash do |row| | |
# 'collect' enables handling of NULL/nil values | |
row = row.collect { |v| v.nil? ? "" : v } | |
#fname = row[0] + ".html" | |
fname = row["ID"] + ".html" | |
open(fname, 'w') do |f| | |
f.puts "<strong>Defendant</strong><br>" | |
#f.puts row[1] + "</p>" |
def html_entity_escape(string) | |
fixed = string.to_s.gsub(/&/, "&").gsub(/½/, "½").gsub(/¼/, "¼").gsub(/¾/, "¾").gsub(/“/, "“").gsub(/”/, "”").gsub(/’/, "’").gsub(/‘/, "‘") | |
#fixed = string.to_s.gsub(/38/, "&").gsub(/189/, "½").gsub(/188/, "¼").gsub(/190/, "¾").gsub(/8220/, "“").gsub(/8221/, "”").gsub(/8217/, "’").gsub(/8216/, "‘") | |
return fixed | |
end | |
blahblah = "only 3 breaks of ½ hour, worked for 16 ¼ hours, had a break of 8 ¼ hours" | |
puts html_entity_escape(blahblah) |
The below Sinatra code works with URLs like: | |
/c/blahblah | |
and | |
/c/http://blah.com/something.php | |
or | |
/c/google.com |
#!/usr/bin/ruby | |
require 'rubygems' | |
require 'mysql' | |
require 'sqlite3' | |
def with_mysql | |
db_object = Mysql.init() | |
db_object.real_connect('localhost','things','1234','things') | |
<h1>Feeds Checker</h1> | |
<% | |
require 'hpricot' | |
require 'open-uri' | |
f1 = open("http://www.commerce.wa.gov.au/feeds/feed1.xml") | |
feed = Hpricot.XML(f1) |
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>g.RaphaelJS Graph Testing</title> | |
<script src='raphael-min.js'></script> | |
<script src='g.raphael-min.js'></script> | |
<script src='g.line-min.js'></script> | |
<script type='text/javascript'> | |
//<![CDATA[ | |
window.onload = function () { |