perl -lpe 's/([^a-z])$/$1a/ || substr($_, -1) =~ tr/a-z/b-za/'
Saturday, October 9, 2010
Perl one-liner, bumping a version string
Friday, October 1, 2010
Wednesday, February 24, 2010
Wordpress Fail
1) Create a new post
2) In the visual editor, start a line with a few spaces followed by some text
3) Click 'Preview', or click to the HTML tab then back to the Visual tab.
You'll notice your leading spaces have disappeared. Ok, fine, just convert them to  's in the HTML editor. Now, switch back to the visual editor. Ahh, leading spaces at last. Let's just switch back to the HTML editor for one last tweak. And... the leading spaces are gone again. Welp.
I found one attempt to fix this - unfortunately it's just a bandaid and only works inside shorttags for a specific wordpress plugin.
Tuesday, January 23, 2007
Embedding iTunes album art into MP3s
iTunes makes it really easy to download album art for an entire music library in one fell swoop (select-all, Advanced->Get Album Artwork). It's a little trickier to embed the artwork into the MP3s themselves (for use with other players like WinAmp). I found a perl script at Teridon's iTunes Scripts called itunes_insert_artwork that does a nice job.
While trying it out, I noticed that a lot of the jpegs from iTunes were ridiculously large. Some were over 800K, for a 600x600 image. Not quite sure why - resaving them even at 100% quality resulted in much smaller files. So, I tweaked the script to send the images through ImageMagick first. (At quality 85, those 800K images get down to 200K.)
You'll need to have ImageMagick and PerlMagick installed. If you plan on installing ImageMagick/PerlMagick for ActivePerl, note that, currently, you'll need the older 5.8.x version to get it to work.
Download the scriptSaturday, November 25, 2006
KeyFix4000: Improve your MS Natural Keyboard 4000
First, it is conspicuously missing a Windows key on the right side. Second, there is no way to remap the back and forward buttons to act as mouse buttons. After googling in futility for a solution, I decided to whip one up myself. (After all, this was nothing a little keyboard hooking couldn't solve.)
The result? KeyFix4000.
The mouse button mapping is pretty straight-forward - it just translates a click on the back/forward button to a click on the left/right mouse button.
The Windows key issue was a little tricky - how do you fix a key that doesn't exist? Well, the Apps key is pretty much where the Windows key should be, and I realized I could overload it. Now, when pressed by itself, it functions as the Apps key, and when pressed in combination with another key, it works as the Windows key. This dual usage works surprisingly well.
Download executable
C++ source code at GitHub
Sunday, November 12, 2006
Fun compiler bugs
void bar() {}
namespace foo
{
using ::bar;
}
using namespace foo;
// namespace {}
int main(int argc, char * argv[])
{
bar();
return 0;
}
In VC6, the preceding block of code produces
error C2668: 'bar' : ambiguous call to overloaded function
and the error goes away when you uncomment "namespace {}". Yikes.
Sunday, August 27, 2006
Fixing Google
For the rest of us, however, this was begging for a fix. My searching revealed a Chickenfoot script here that looked promising. Unfortunately, I found that Chickenfoot isn't quite ready for primetime. When I set the script to run on *.google.com/*, then went to mail.google.com, Chickenfoot caused Firefox to freeze and consume 99% CPU.
At that point I knew I knew it was time to break out good ol' Greasemonkey. A couple hours of hacking, and the problem was solved. The script is easily customizable, and by default also restores the Froogle and Books links. Let me know if you have any suggestions or feedback.
Update: Google changed a few things that broke the script. I should have an update this weekend that fixes it and makes it more resistant to being broken by minor changes.
Update 2.0: Made a few tweaks and got everything working again. As per David's request, the script also has two new functions. hideGoogleSearchLink moves a link off the main page and into the 'more »' popup. removeGoogleSearchLink gets rid of a link altogether. Enjoy...
