Apr 112012
 

Here are the things you need to know about using any new font for Rubymine:

  1. It needs to be Unicode
  2. It needs to go into the $JDK_HOME/jre/lib/fonts directory

That is absolutely it. The last thing is the Monaco font, which I have attached for your downloading pleasure. It turns out DejaVu Sans Mono just isn’t as nice — however nice it may be — and Inconsolata XL doesn’t quite do it for me either.

Jan 062012
 

Ruby has a neat feature called at_exit which takes a block and then executes the contents of this block when the program ends. There are a couple of VERY important details:

  1. It takes a block and converts it into a Proc object at the time of parsing. This means that the data has to be available in the binding, or you’ll run into errors. Example: instance variables need to be set before you can use them in that block. Better idea: don’t use instance variables in there at all.
  2. You can ‘chain’ at_exit calls, and they will be resolved in a First In, Last Out (FILO) order.

Once you know this, using at_exit and writing tests for it becomes a little easier:

class Piddler
   def initialize
     create_pid_file
   end

   private

   def create_pid_file
     pid_file = "/tmp/piddler/my_pid" #Simplified for example purposes
     File.new(pid_file, 'w')
     at_exit { FileUtils.rm_f pid_file }
   end
end

What you’ll notice is that the at_exit block is defined RIGHT AFTER I create what I will need to resolve/undo/finish – not separately, right inside the method.

 

def test_clears_pid_file_when_it_exits
   at_exit { assert_equal 0, Dir['/tmp/piddler/*].size}
   Piddler.new
end

The advantage of that is that I know exactly when it gets defined. For this example, it gets defined at the end of the ‘initialize > create_pid_file’ call. This means that any at_exit blocks defined BEFORE that will be resolved AFTER.

 

May 102011
 

I just moved into a new apartment where the AT&T reception is, well, atrocious. Still, I like AT&T, so I’m dragging my feet to switch to Verizon (or something else).

Today, I spoke in live chat to some AT&T employee. I believe the name was Monica Garnett but I could be wrong — and it probably doesn’t matter. My issue was that I didn’t seem to have a mailbox for my phone number. She says my data plan is unsupported for smart phones.

… Wait, what? I’ve been using this data plan for over a year with this phone. Maybe I never got voicemail, but who cares! It WORKED. I had unlimited text and unlimited data. Now, yes, I know, this plan had been removed and AT&T wasn’t offering it anymore, but I am an existing customer, I get the perk of keeping that, right?

… No. I was told I could switch to their 200Mb/month or 2Gb/month plan, which I did, but what I wasn’t told is that THESE PLANS DO NOT INCLUDE MESSAGING.

Now, I want to fix this. I got screwed by a company, big whoop, whatever, I’ll just limit myself a little. THE WEBSITE DOES NOT GIVE ME REASONABLE OPTIONS. I can get unlimited text, or unlimited text with any mobile-to-mobile calling, or 1000 texts.

I could pay $15 for 200 megs and $10 for 1000 texts, and then I’d have $25 — which is, $5 less than unlimited data and unlimited texts. Huh. NO.

I could pay $25 for 2Gb and $10 for 1000 texts, or $20 for unlimited texts. So .. $35 or $45? NO.

Seriously? So I have to pay MORE now to have LESS than I used to have? Well, goodbye, AT&T. Guess who’s going to go say hi to another phone service provider tomorrow?

Feb 052011
 

Scrivener is a wonderful OSX app for writing basically anything you want (novels, plays, theses, etc). There’s a beta out for Windows. As it turns out, they’re actually developing it using the Qt toolkit.

The Windows Beta runs on WINE, if you do a bit of work. I am getting all my information from a Lifehacker tip, just rewriting it and adding some more information for those who don’t know enough.

  • Install WINE — version 1.3.5 or higher.
  • Download winetricks
    $ wget http://winetricks.org/winetricks
  • I also recommend installing the ‘cabextract’ tool, as indicated in the previous link.
  • run winetricks and install the following runtime libraries:
    $ sh winetricks vcrun2008 vcrun6 quartz dotnet20
  • I did not need to do this, but the link also recommends downloading qsvg.dll and qtsvg.dll and copying them to your ~/.wine/drive_c/windows/system32 directory. I’m not actually sure where to find these, and installing Scrivener created a qsvg4.dll file.
  • Finally, install and run the Beta.

Let me know if you run into any issues following these instructions.

May 112010
 

If you happen to use Gentoo on a Notebook, you may already know this. If not..

At the time of this writing, If you have a Poulsbo video card (another craptastic Intel invention) do _not_ upgrade to xorg-server 1.7. Stay on 1.6.5-r1 or whatever you have. If you upgrade, xorg will just refuse to work for you, and downgrading is kind of a pain.

If you have upgraded already, then here’s what to do:

http://bugs.gentoo.org/show_bug.cgi?id=290679#c4

After doing this, you’ll need to also mask >xorg-server-1.6.5-r1, then re-install the old xorg-server, and finally re-emerge everything you have installed from the category x11-drivers.

Have fun!

Mar 312010
 

Hooks are a fascinating bit of Ruby magic. They are methods you can define with actions to run when something happens. You can put triggers in your code.

This blog post explains them very well; and for more information, get “Metaprogramming Ruby”, which is a great book – not only about the callbacks, but about a host of information.

Mar 122010
 

I will readily admit that I don’t know all that much about Github or Git for that matter. I use them, they’re handy, and that’s where it stops. I read about a git feature called “smart HTTP”, which would allow to communicate both ways with git (push and pull) with HTTP or HTTPS. So, I asked Github about it – it would be nice for them to have this feature, because I currently can’t push to Github from work. Here’s how the exchange went.
(this first message is from memory, as I used the web interface, so I don’t have a copy of it)
Me:
Hi, I just read about this: http://progit.org/2010/03/04/smart-http.html and I would like to know when Github plans on implementing this, because it would be very useful.
_______
From: Tekkub (Support staff)
Subject: [Contact] Upgrading git to support smart HTTP ?

You do know that Scott (the guy who wrote Pro Git) works for us, right? We’re well
aware of smart http…
_______
I tried to make light of the condescending tone and sent the following reply:
Me:
Nope.. Had no idea.
So when will it be implemented? ;)
_______
From: Tekkub (Support staff)
Subject: [Contact] Upgrading git to support smart HTTP ?

It will be implemented when it is…
_______

That’s when I just gave up. I don’t know if whoever handles the messages is paid or not, but I’m pretty sure Github pays its employees by now. I’m using a free account, so they wouldn’t lose anything by me leaving them, and they do provide a great service.
Am I just being picky when I expect the support staff to be polite? I say this as someone who has worked as support staff for over three years: no. The support staff SHOULD, nay, MUST be polite. I don’t care how flat your company hierarchy is, I don’t care how young or forward-thinking the company is, and I especially don’t care if your target audience is Asperger’s syndrome-suffering programmers who laugh at Star Trek jokes and read slash fiction. You’re the support, you’re polite. Especially over a medium like text, where you can’t easily place a slap on the shoulder, a grin and a wink.

This has left a bad taste in my mouth.

Mar 012010
 

There are a few gotchas:
1) If you have a SSD drive, you need to modprobe pata_sch to see it.
2) when using GRUB, install it on whatever drive the hard drive is, even if it’s /dev/sdc — and let your FSTAB use /dev/sda. Chances are that /dev/sda is your liveUSB.
3) In the kernel, in the I2C options, don’t let it pick automatically – instead, select the algorithm options in the menu that appears (I don’t know it off-hand, will edit this post later to add the important information). This will allow you to install the kernel driver for the poulsbo card (kmod-psb, I believe).

For the rest, so far, it seems that the howto on the Gentoo wiki is good. I installed e17 very painlessly.

Wireless was a bit trickier.
I needed to use gentoo-sources-2.6.33, which at the time of this writing was masked as ~x86. A big advantage though is that it has support for the Atom processor (and the proper driver for the broadcom card!).
Enable the “B43″ driver in the kernel.
Then, follow the instructions given here:

git clone http://git.bu3sch.de/git/b43-tools.git
cd b43-tools/fwcutter
make
cd ..

Use version 4.174.64.19 of Broadcom’s proprietary driver. (The tarball is mislabeled as “4.178.10.4″, but it is actually 4.174.64.19.)
Download and extract the firmware from this driver tarball (Gentoo’s installation directory for this is /lib/firmware):

export FIRMWARE_INSTALL_DIR=”/lib/firmware”
wget http://downloads.openwrt.org/sources/broadcom-wl-4.178.10.4.tar.bz2
tar xjf broadcom-wl-4.178.10.4.tar.bz2
cd broadcom-wl-4.178.10.4/linux
sudo ../../fwcutter/b43-fwcutter -w “$FIRMWARE_INSTALL_DIR” wl_apsta.o

At the time of this writing, although the b43-firmware is available and promises to give us what we need, the b43-fwcutter tool is only at version 12, and not 13, so it can’t be used. This is why we need to use git to download the latest version and correctly build the firmware by hand.

Jan 152010
 

~~~~ ListBrowser README ~~~~

I was working on a parser for a very specific tree structure, and was frustrated that there wasn’t a simple way to parse it in irb. “What??”, I thought. “I have to use my brain?! God forbid!”. So I set to using my brain a little more to create this tool. It’s not much, but maybe it’ll make someone’s life a little easier.

Install: (set up gemcutter)
gem install ListBrowser

It can be used in irb, and really should be used there – when you call it on a tree structure, you’ll get a menu with a list of choices on how you want to go through whatever structure you gave it.

In my particular, special case, I would do something like this:

require ‘sgf_parser’ # For my tree structure require ‘list_browser’ # For this.

tree = SgfParser::Tree.new :filename => “kogo.sgf”

ListBrowser.new tree.root, ‘parent’, ‘children’, ‘properties’

# And follow the menu!

In my particular case, I would not need to enter those strings, as they
just happen to be the names I chose for my tree structure, but they should
serve as a good enough example!