Malicious enjoyment derived from observing someone else’s misfortune
 

Tag Archives: rails

Fixing Mephisto Post Pinger Plugin

I wanted some places to get pinged when I posted. I used the mephisto_post_ping plugin, I simply changed the directory structure and class definition around: Directory Structure ./lib/article_ping_observer.rb ./lib/mephisto_plugins/post_ping.rb ./lib/config.rb ./README ./init.rb File Changes init.rb # $Id$ require ‘mephisto_plugins/post_ping’ ActiveRecord::Base.observers << :article_ping_observer plugin.rb module Mephisto module Plugins class PostPinger < Mephisto::Plugin author ‘Mark Guzman’ version ‘$Rev: 82 $’.gsub( "Rev: ", "" ) notes "Send Weblogs Pings when articles are published" homepage "http://hasno.info/2006/11/11/mephisto-plugins" class Schema < ActiveRecord::Migration def self.install end def [...]

How to make a Mephisto Plugin

So, I figured I might as well provide a quick tutorial on how to make Mephisto Plugins currently. Many of the old plugins are broken, so there needs to be a resurgence of plugin development. Here’s the basic structure of the Tag Cloud plugin: mephisto_tag_cloud – init.rb README – lib – mephisto_plugins – tag_cloud.rb As you can see, the structure is very simple. Here’s my code for init.rb Liquid::Template.register_filter(MephistoPlugins::TagCloud) That’s it! No require or anything! Next, I edited lib/mephisto_plugins/tag_cloud.rb: module [...]

Mephisto Tag Cloud Plugin

Because the French one disappeared off the face of the earth, I took it upon myself to make a tag cloud Liquid plugin. Here’s the scoop. I downloaded Rick’s MeasureMap Plugin and went to town converting it. Add this to your sidebar in your liquid template of choice: {% for tag in site.tags %} {{ tag | size_tag }} {% endfor %} And you should have some awesome tag_cloud action. You can specify an upper limit as well: {{ tag [...]

ZIP files in Rails

Today, I needed to make a KMZ file from my KML in Rails. This was easy thanks to RubyZIP: gem install rubyzip Now for the Rails action: # In your controller private def zip(data, filename) zipfile = “/tmp/rubyzip-#{rand 32768}” Zip::ZipOutputStream::open(zipfile) do |io| io.put_next_entry(filename) io.write data end zippy = File.open(zipfile).read File.delete(zipfile) zippy end This makes a temp file, adds to it zip-style, reads it to a string, and deletes it. It leaves nothing behind on the file system. Then all you [...]

MySQL Capitalization Issue

So, a problem with MySQL (in my opinion) is that it is not case sensitive by default for VARCHAR fields. That makes getting rid of crappy entries like ’ITALY’ a bother. I mean, sure, I could just post-process it with ruby (see titleize), but what’s the fun in that. select distinct BINARY(lead_country) from countries; Ah, finally recognizes that ITALY is not Italy. One is definitely uglier than the other one. Now for the change. update countries set lead_country = ‘Italy’ [...]

More Madness converting to Mephisto

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};

How I converted Typo to Mephisto

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 [...]

Switching SVN Locations

I moved some crap around in my repository the other day, and I felt the pain when I tried to update. Thankfully, the svn people have thought this thru already. svn sw https://modzer0.cs.uaf.edu/repos/hank/code/rails/stockmaster . At first this broke, so I had to do a temporary svn cp to resolve some missing crap. After that, it moved right over to the new location and I could update again. If I had changed servers and not paths, I could have done this: [...]

CheeseToast.Org is Live!

Now, you can see all the cheesy goodness at Cheesetoast.org. Have fun!

Everybody hates pumpkins

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 [...]