Posted by hank, Fri Feb 23 01:41:00 UTC 2007
I changed all my typo:code tags to filter:code today:
Article.find(:all).each {|a|a.body.gsub!('typo:code', 'filter:code');a.save};
Posted by hank, Fri Feb 23 01:41:00 UTC 2007
I changed all my typo:code tags to filter:code today:
Article.find(:all).each {|a|a.body.gsub!('typo:code', 'filter:code');a.save};
Posted by hank, Wed Feb 21 23:13:00 UTC 2007
I had some difficulty along the way, and I have some fixes for those of you who are having trouble converting. I found that Mephisto is actually very friendly to the ./script/console hacker. Also, though it took a while to actually get a response, I ended up getting direct help from technoweenie in #mephisto@irc.freenode.net, which was a big help. So, here’s the situation:
My current host is Site5. I have gems set up in my home directory, and I have rails 1.2.2 installed as a gem. I tried using it, but just ended up freezing edge rails because I ran into some trouble. I created a db, subdomain, and .htaccess entry for the site. Then, I actually checked it out:
svn co http://svn.techno-weenie.net/projects/mephisto/trunk mephisto
Then, I created config/database.yml. Here’s a template you can use:
development:
adapter: mysql
database: mephisto
username: meph
password: <new-pw>
host: localhost
production:
adapter: mysql
database: mephisto
username: meph
password: <new-pw>
host: localhost
typo:
adapter: mysql
database: typo
username: typo
password: <typo-pass>
host: localhost
Next, I installed tzinfo as a gem to my home directory, and froze it in the project root:
gem install tzinfo
cd mephisto
rake gems:freeze GEM=tzinfo
Finally, it’s time to fill the database with stuff:
rake db:bootstrap
Now that that’s done, for CGI and FastCGI to work, we need a .htaccess file in public:
AddHandler fastcgi-script .fcgi
AddHandler cgi-script .cgi
Options +FollowSymLinks +ExecCGI
RewriteEngine On
RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ dispatch.cgi [QSA,L]
ErrorDocument 500 "<h2>Application error</h2>Rails application failed to start properly"
Notice I left it as dispatch.cgi. It’s up to you, but while I was still converting I left it like this since it didn’t want to run with FastCGI.
Let’s make sure log and public can be read and, if need be, written to:
chmod -R 755 public log
And finally, the moment we’ve all be waiting for:
script/runner "Mephisto.convert_from :typo" -e production
This connects to the Typo database and runs a converter script in Mephisto’s vendor/plugins/ directory. It takes all the attributes Typo articles and users and comments had and converts them to Mephisto form. Rockin’.
I did this with Typo trunk v1246 with migration level 55. If you are at a similar Typo state, then you may definitely want to continue reading as the next steps I took will be necessary for you as well.
First of all, I saw that my Markdown with SmartyPants formatting was not being interpreted at all! This was, of course, easy to fix because Mephisto is awesome:
./script/console
# Don't do this unless you ALWAYS used Markdown with SmartyPants
# Refer to vendor/plugins/filtered_column if you use Textile or straight up Markdown
# It's just a different a.filter= line below.
Article.find(:all).each {|a|a.filter='smartypants_filter';a.save};1
What this does is find all the Mephisto articles and set their filter to Markdown with SmartyPants. The 1 on the end just prevents it from spewing every article to the console.
Now here’s where I ran into some trouble. Typo has changed its Tag storage technique at least twice, and the way my tags happened to be stored is as follows:
articles
- id
articles_tags
- article_id
- tag_id
tags
- id
- name
Someone else had posted a small loop to cure another type of Typo tagging scheme, where there was just one tag grouping string per article. I ran that. Don’t do that.
I noticed that each one of my articles only had one tag, which made me a sad monkey. To remedy this, I wrote a small loop to find all the tags of a Typo article and set them up for the same article in Mephisto. Now, since the id’s on articles and tags are not kept constant in the conversion scripts, this was a bit tricky. Luckily, I never have duplicate permalinks (I guess that means I’m creative…).
First, you have to enable the Typo converter in the console. I did this by adding these 2 lines to the bottom of vendor/plugins/mephisto_converters/init.rb:
require "converters/base"
require "converters/typo"
Then, it’s simply a case of the following:
./script/console
# Remove All Mephisto Taggings as to not make dupes
Tagging.find(:all).each{|t|t.destroy}
# Loop through every Typo article
# Find the associated Mephisto article
# Loop through all the Typo Tags
# Append each tag to the Mephisto tag array
Typo::Article.find(:all).each do |ta|
a = Article.find_by_permalink(ta.permalink)
ta.tags(true).collect{|b|b.name}.each do |tag|
a.tags(true) << Tag.find_by_name(tag)
end
end
Don’t forget to remove the requires you put into init.rb above. Once you do that, you should have a nicely running Typo -> Mephisto conversion. Congratulations!
Posted by hardwarehank, Sun Feb 18 23:19:52 UTC 2007
So, it turns out that when I changed my theme to a ‘harvest gold’ background, I got a lot of flak about it:
20:43:29 <+plaidrules> hardwarehank: wow dude, your blog css is hideous
It led me to embrace the night with this new emoesque theme. I hope you like it. I’m going to have to start looking the part in real life, as well as posting pictures of myself with swoopy to the left-like hair dyed black, and some awesome eyeshadow of doom. Something like this should do:

Oh ya. Thats gonna be me. You just wait.
Oh, and the offending color for all the see:
Also, this awesome theme is called Wibbish, and you can get it like this for all I care:
svn co https://modzer0.cs.uaf.edu/repos/hank/code/rails/typo/wibbish
Time to go put on makeup.
Posted by hardwarehank, Mon Feb 05 09:29:00 UTC 2007
I realized that spam bots are stupid, and spammers are generally not the best programmers, so a while back I made a system to fight the intolerable spam plaguing us. I noted today that Robby on Rails was having this same problem, and I figured I might as well share what has worked for me.
First, I added this line to my views/articles/_comment_box.rhtml:
# <td><p><label for="comment_body">Your message</label></p></td> # <td valign="top" colspan="2"> # <%= text_area "comment", "body" %> # </td> # </tr> <tr> <td> <p> <% spammer_array = [["two","9","twelve","2"][rand(4)],["1","15","4","eight"][rand(4)]] %> <% question = "What's #{spammer_array[0]} times #{spammer_array[1]} ? (numerical)" %> <label for="spammers_suck"><%= question %></label> </p> </td> <td> <%= text_field_tag "spammers_suck" %><%= hidden_field_tag "spammers_question", question %></td> </tr> # <tr> # <td colspan="2" id="frm-btns">
So far, it’s simply a new table row with some junk in it. But, the interesting thing is that every time the page is created and cached, it contains a new random equation for the user to guess. This is then sent along with the request to post a comment (not the preview, mind you) to the comment action.
# Again: Commented parts are unchanged from Typo codebase # def comment # unless @request.xhr? || this_blog.sp_allow_non_ajax_comments # render_error("non-ajax commenting is disabled") # return # end #AntiSpam b = params[:spammers_question].split(" ") c = [[2, 9, 12, 2], [1, 15, 4, 8]] d = [["two","9","twelve","2"], ["1","15","4","eight"]] num_one = 0 num_two = 0 c[0].each_with_index{|t,i| if(b[1].index(d[0][i])); num_one = t; end} c[1].each_with_index{|t,i| if(b[3].index(d[1][i])); num_two = t; end} if not params[:spammers_suck].to_i == num_one * num_two render_text "You're either a spammer, or you can't do math." # elsif request.post? # begin # @article = this_blog.published_articles.find(params[:id]) # ...
This very simple hack has caused a complete cease of comment spam on my blog. I also globally disabled trackbacks (which took a manual database query in the end), and so far the only spam-like comment I’ve gotten was a hate comment ;). So, the moral of the story is that you don’t have to put up with spam in Typo, and you don’t have to use Askimet or some other external service to fight it. Just some simple math is all it takes to pwn the noob-bots.
Posted by hardwarehank, Sat Jan 27 20:09:25 UTC 2007
I made a sweet sidebar today that I’ve been wanting to make for a long time. I usually forget to head over to XKCD, so I wanted a way to have the newest images staring me in the face all the time. Now, thanks to the magic of RSS, they’re right in front of me. They are lightboxed, so I have the newest comics and their captions available to me without even leaving my own site. How homey. To get the sidebar (works in Typo svn rev. 1246, which is my crusty old checkout), do this wherever your plugins are kept:
svn co http://modzer0.cs.uaf.edu/repos/hank/code/ruby/typo/xkcd_sidebar/
Horray! A sidebar is born.
Posted by hardwarehank, Sun Jan 21 13:59:09 UTC 2007
So, I am currently hosting this blog on Site5’s $5 Deal. I paid $120 for 2 years of hosting with 55GB HD Space and 5TB/month transfer allowance. So far, I am very happy with it, and I’m going to share some gory details with you.
The deal on the site looked to good to be true, and I thought it might be. So far, I haven’t noticed any deviances or misconceptions at all though.
Here’s what it looks like when you log into the Backstage application. This lets you manage your billing, domains, and contact info, and acts as a gateway into your site management systems. Very Nice!
Then, you can go to each site just by clicking its name. Each site has its own SiteAdmin interface which gives you pretty amazing abilities.
You can manage MySQL databases with phpMyAdmin, see all the Ruby and Perl libraries they have installed, mess around with FTP junk, automatically create about 30 applications, manage files, and lots lots more.
Also, there’s a little tool called FlashBack that I get to beta test for them. It auto-saves the state of your directory so if you delete files or whatnot you can restore them easily. Pretty awesome.
Shell access is enabled by default, so you don’t have to mess around with support on that one. I transferred my domain name to them, and they have a flat rate of $8.88/year for domain name registration. That’s fine with me. Also, if you need SSL, even if you can generate your own certificate like I can (CACert), it still costs $15 to install it on the server. Personally, I don’t want to pay for it, so I’m SSL-less right now. Oh well, I don’t need it anyway.
All in all, these guys blow away Dreamhost, which I had for the past year. Dreamhost cost me twice as much, and their server had very slow network performance for me. The fastest I ever saw was 100K/sec, and usually it was around 40K/sec. Unacceptable. Also, as far as I can tell with ps, this shared host is not as overloaded with people as Dreamhost’s. Dreamhost’s MySQL setup is lame (you have to create a ton of subdomains for no apparent reason), whereas Site5 you always use localhost, speeding installations along. I managed to transfer my entire old SVN checkout of Typo over here, and the only trouble I had was trying to remember to cross my T’s and dot my I’s on the FastCGI/Apache environment. It’s too bad I can’t just run mongrel instances and do Apache forwarding like I used to, but as long as it runs, whatever.
Site5 has done a wonderful job so far, and I don’t see it going downhill soon. They make a wonderful Rails host, and I’m proud to be a customer.
Posted by hardwarehank, Sat Jan 20 01:35:51 UTC 2007
Well, I made the transition to Site5 Hosting today. They have an amazing deal - $5/month for 2 years gets you 5 TB/month transfer and 55 GB HD Space. It’s a very Rails-Friendly environment, too! I got Typo up and running today which was transfered from the college webserver it’s been on for a year. They give you shell access, unlimited databases…it’s insane. And I also transferred my domain there - $8.88/year is a little expensive, but that’s OK. They have tons of support for Ruby including tons of popular gems, and their admin interface is very slick.
Anyway, so this is my first post on Site5. I wanted to show off my Google Adsense sidebar, which I made to generate revenue to pay the server bills.
You can get it from my usual subversion repository:
svn co https://modzer0.cs.uaf.edu/repos/hank/code/google_ads_sidebar
It’s very simple to use (at least in my very old checkout of Typo). First, dump it in the typo/vendor/plugins directory. Then, go find it. Then jam in your key from the code they gave you. It should look something like this: pub-1275878260955547. Finally, save, and go stare in awe at the results. You might have to restart Typo’s webserver or clear its cache first.
Posted by hardwarehank, Fri Jan 05 00:03:37 UTC 2007
So, I made it so the Timeline project and javascript libs can now use my custom Typo RSS feed to make pretty timelines. Just did some very simple (but troublesome to debug) modifications of the Timeline and Typo codebases. Trouble was for a while that this…
<?xml ..... ?>
…is apparently not parsable in the Timeline libs. And it throws some unclosed parenthetical exception. That took me a long time to figure out. Lame. Anyway, you can see the result of the integration between blog events and life events here.
Gotta start trading stocks in 30 minutes, then eventually go to bed. I’m such a night-owl.
Posted by hardwarehank, Sun Nov 05 05:45:11 UTC 2006
I added some functionality to myflog today. Now it prints a RubyURL for you if you set the following in your .flogrc file:
rubyurl: true
Read the earlier posts to know what I’m talking about.