Programmers Who Already Program Good and Want To Ruby Good Too

Sorry for the horrible Zoolander reference. But I couldn’t resist.

As you can tell from the article title, I’m going to start a mini class on how to program in Ruby on this blog. It’s more directed to people who are already familiar with most programming concepts, so if you are learning Ruby without much programming experience, I highly suggest Ruby the Hard Way or Programming Ruby (aka the Pickaxe Book). This project will also lean towards modern Rails development, and it’s necessary skills.

Overall I think it will end with Sinatra and ActiveRecord, but I’m not sure. I really want to very slowly add in the Rails stack where all of a sudden you’re working in Rails without realizing. Such as using Sprokets manually, then setting up autoload to app/assets. I’m going to need to take a look at how to hack that up with minimal code. Anyway, off to the first steps: installing Ruby!

Note that at the top section of the each part, I’ll be writing up some trivia. Feel free to skip this, but it does have a lot of history in them, which is both interesting and significantly relevant.

Printing Raw EPL on the LP2844 from a Mac or Linux

This is mostly a list for my own purposes, but I got a Eltron/Zebra LP2844 to print raw files generated on my Mac to send over USB.

First, you need to find the device URI:

Add the printer to CUPS, accept, and enable it:

(cupsaccept is for Mac, “accept” works on all other flavors of UNIX.)

Try a test:

UPDATE:

If you are just on Mac, you can actually add it through the System Preferences. Add the EPL printer via Print & Scan, click the plus to add the printer, click on the printer, and search and select EPL2 as the driver.

To print raw EPL commands, first find the command line name of the printer. List all printers via this command:

If Zebra_LP2844 was the printer you just added, then use this command to print:

Textile and the Starmen.Net Forums

As some of you might know, I — almost religiously — push Textile onto everybody on the Starmen.Net forums. I really like it since it makes a lot of organizational posts easy to do with all the block-level elements. Allowing inline styles is awesome too. Except that I highly parse the styles for certain elements now. Sarsie found all kinds of wonderful XSS attacks with CSS Expressions and IE6. I keep telling the story about a security problem with font colors.

Anyway, a lot of people have problems with the newlines and how they work. I’ve tried all kinds of things, but none of them work well really. Since I used RedCloth 3, the Ruby parser for Textile, there wasn’t a nice answer. Going without it is impossible, since there’s a legitimate reason to have single breaks. Enabling the official hard breaks on RedCloth 3 caused havoc on quotes and spoiler matocode tags. I eventually settled on an ugly hack.

In comes RedCloth 4. It fixes the line break issue, it’s a C-based extension for extra speed. And it doesn’t have disablers, it’s all or nothing. I have to disable images on the forum because it’s possible to display tasteless images. Not to mention the occasional Goatse hotlink protection. Stuff I really don’t want to be shown on a forum that has members of 12 or less.

However, We offer regular users the ability to post images in certain forums, like the Fan Forum, to show off their artwork. Administrators and moderators like images for various real needs, as well as special permissions allow certain users to post images for various needs. (ie. the runner of the currently running Mafia game.) So the feature disabler had to be easily disabled/enabled.

After a brief email in their mailing list, I manned up and added it myself. Unfortunately, I didn’t know Ragel, or Ruby C Extensions for that matter. It was a long and tough battle, but I defeated the final boss!

RedCloth.new("!image.jpg!",[:disable_inline=>:image]).to_html
#=>"!image.jpg!"

Hopefully — With the feature disabler that I needed — this fixes a lot of problems that have been plaguing the Textile implementation on the forum.

The next step is to port the crappy MatoCode (my implementation of BBCode) to the fancy Ragel system. Things like the [quote] and [spoiler] tags need to have their insides parsed separately from the outside.

What I had to do to resize my Boot Camp Partition:

I heard iPartition was great, so I went to try it. Here’s what I did:

  • Needed a DVD, so I looked forever to find one.
  • Remembered that blank DVDs where in my car, went and got one.
  • Burned the iPartition boot DVD.
  • It didn’t work.
  • Burned it again.
  • Didn’t work.
  • I realized it might not have drivers for my new iMac, so I tried copying my /System/Library/Extentions over to the DVD, burned another one.
  • It didn’t work either.
  • I realized I could use my iBook instead while my iMac was in target disc mode.
  • Except my iBook would let me put in the DVD I burned. There appeared to be something jamming it. (WTF?)
  • So I tried a credit card to unblock it, no dice.
  • I had to open up my iBook, but I needed a smallish Allen wrench to open it. I looked everywhere.
  • I realized that it too, was in my car, so I went to go get it.
  • I took my iBook apart.
  • I took the Combo Drive apart. The disc let me put it in, no clue why. I guess it wanted some fresh air inside?
  • Put the iBook half-way back together, except I forgot to connect the Combo Drive up again.
  • Took it apart, hooked up the Combo Drive, and then put the iBook back together again.
  • Booted the iBook with the iPartition boot disc. (It worked fine.)
All-in-all iPartition is a pretty nice program to resize your Boot Camp partition. Getting to the program was a total pain in the ass.