This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
p "Oh I see, a Gist is a bit like a Pastie." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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>" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The below Sinatra code works with URLs like: | |
/c/blahblah | |
and | |
/c/http://blah.com/something.php | |
or | |
/c/google.com |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
require 'rubygems' | |
require 'mysql' | |
require 'sqlite3' | |
def with_mysql | |
db_object = Mysql.init() | |
db_object.real_connect('localhost','things','1234','things') | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h1>Feeds Checker</h1> | |
<% | |
require 'hpricot' | |
require 'open-uri' | |
f1 = open("http://www.commerce.wa.gov.au/feeds/feed1.xml") | |
feed = Hpricot.XML(f1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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 () { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
desc "Deploy to Heroku" | |
task :deploy_heroku do | |
app = 'myappname' | |
temp_path = "/tmp/heroku-deploys/#{app}" | |
deploy_path = "~/heroku-deploys/#{app}" | |
system "mkdir -p #{temp_path}" | |
system "rm -rf #{temp_path}/*" | |
system "tar -C . -cf - . | tar -C #{temp_path}/ -xpf -" | |
system "cd #{temp_path} && find . -regex '.*git.*' -exec rm -rf {} \\;" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# sweet bro. | |
%w(rubygems sinatra haml sass dm-core dm-timestamps).each {|gem| require gem} | |
DataMapper.setup(:default, ENV['DATABASE_URL'] || "sqlite3://#{Dir.pwd}/dev.db") | |
DataMapper.auto_upgrade! | |
get '/' do | |
haml :index | |
end |
OlderNewer