By epb on July 18, 2010
I really don’t have a shorter description for this. I was working on a personal project the other day and realized that this might be a nifty function. Basically, you know all those snippets to make cropped thumbnails (squares and the like), and how most of them either center or crop to the top of an image. I wanted a new function that would crop to most any size I desired and any position on the image I desired without the need to change any code, only parameters. And thus img_resize_crop was born.
Continue reading “Resize and Crop to a specific width x height with a crop suggestion point.”
Posted in php | Tagged gd, images, php |
By epb on June 23, 2010
I have a sizable collection of music, so sizable in fact that I can’t store the full collection on any portal media. Since I only use Windows to play video games, I use Rhythmbox to manage my music and found myself in need of a way to sync to a USB thumbdrive. Now, the issue with this is that, by default, Rhythmbox doesn’t treat just any USB mass-storage device as an audio player, so I stumbled upon a post titled “Rhythmbox and USB mass storage sync” dealing with a similar problem.
All you need to do is create a file called “.is_audio_player” and add some content to it that’s something like this:
audio_folders=music/
folder_depth=1
…and then scan removable media. (Should be in the file menu) One caveat you should be aware of is that I’m not sure if Rhythmbox will do any audio file conversion for you during the sync to your device. But for moving a play list from one computer to another, this is plenty fine for me.
Posted in linux | Tagged linux, mp3, music |
By epb on May 31, 2010
An odd quest perhaps: but adding album art to an MP3 (in ID3 tags) is readily doable with the KTaglib extension for PHP. Once you have it, you can use a script like this to add artwork to an MP3:
$mp3 = new KTaglib_MPEG_File('2.mp3');
$idv2 = $mp3->getID3v2Tag(true);
$album = new KTaglib_ID3v2_AttachedPictureFrame();
$album->setType(KTaglib_ID3v2_AttachedPictureFrame::FrontCover);
$album->setPicture('testalbum.jpg');
$album->setMimeType('image/jpeg');
$idv2->addFrame($album);
$mp3->save();
Assuming no exceptions are thrown, this should allow you to set an image of your choosing as a FrontCover image (of course replacing my example values with your own real values), consult the KTaglib documentation for more details and check “Predefined Constants” for the other image types.
Posted in php | Tagged metadata, mp3, php |
By epb on May 21, 2010
This week I was working on a computer that was having problems with it’s hard drive. I could get it to start once, and then it would fail to start up again. As you can imagine, the drive had some bad sectors, but the people I was fixing this for could not afford another $60 expense to replace the drive. So I had to try to find a way to fix the computer without replacing the drive.
And that’s when I learned this: Before you throw out a drive with bad sectors, try to run the manufacturers test and repair utilities on the hard drive. Western Digital has its Digital Lifeguard software and I’m sure Seagate has a similar tool. If you can attempt a repair with it, try the repair option. If the repair fails, then you will likely need to get a new hard drive unfortunately. Hopefully this will help you wring another couple of months out of your drive. (Who knows, it may work for years after you do so.)
Posted in Problems | Tagged computer problems, hard drive |
By epb on May 6, 2010
I made a pretty normal trip to jlist (an online shop selling all manner of things Japanese) and for some reason thought: I bet I could change this store layout with Greasemonkey! With a couple of hours of fiddling, I had managed to create a script that took their HTML and mangled it to my bidding. That makes me sound kinda evil doesn’t it? At any rate, you can do some pretty impressive stuff to a page with just JavaScript. So you can poke it and whatnot fairly easily, I’m providing both in this zip file: jlist condensing greasemonkey scripts
By default, when browsing by category, everything in is shown vertically with text and pictures. I wanted to browse without scrolling so much, so at first I made this a greasemonkey userscript called “jlist-condense.user.js” and here’s the result with that one:

JList with the first condensing script
So, I decided to continue playing around with the script and then made a “super-condensed” version that uses even less space. It would break on things that don’t have pictures at the moment btw, but most everything on jlist does have a picture. Further, I was just me messing around with Greasemonkey script shenanigans. All it is is product image with a reflection (because I can) that you can mouse over for the title and click to view the full product descriptions.

Super-Condensed jlist greasemonkey script
Posted in Uncategorized |
By epb on March 12, 2010
You can do quite a bit of unorthodox stuff with PHP. If you head over to epbsoft.com, you’ll find several flash coloring sheets I made with PHP, not Flash. (Sort of anyway.) I make them by first creating specially formatted SVG (Scalable Vector Graphics) files and feeding them to a PHP script that writes ActionScript files that are then compiled by MotionTwin ActionScript compiler. As far as capabilities, it’s not all that capable. I have to jump through a couple of hoops to make an SVG that my ActionScript generator can actually parse properly, but when it works, I like the results.
svg-to-coloring.php.zip <– The source code is available if you want to take a look at how it works.
Posted in linux, php | Tagged actionscript, flash, php |
By epb on March 3, 2010
I might take a look at installing MongoDB on my server. I like the idea of a document-driven, NoSQL database, especially after working with relational SQL databases for years, and MongoDB looks interesting. You can read more about it in Developing scalable PHP Applications using Mongo DB. What caught my interest is how flexible using it appears to be from the linked article. Plus, using something other than a SQL database could be a nice change of pace. I HATE adding fields to a SQL database table, and it looks nearly painless in these examples.
Another thing that seemed as though it were worth looking into is it’s apparently designed with storing whole files in mind. I’ve stored files in MySQL databases before, but MySQL really isn’t designed with that in mind, but at the same time, if I’m going to be making a lot of small binary files, I don’t like them cluttering up my directories.
Posted in linux, php | Tagged php, rambling |
By epb on January 17, 2010
Let’s say you have a VHD file you’d like to access while in Linux without attaching it to a Virtual Machine. There are many reasons you might like to do this, but it’s not immediately obvious how to do so with Linux.
There are two ways I know of:
You can use vmware-mount provided by VMWare Server. I don’t actually like this method because VMWare Server is huge and I don’t use VMWare. However, if you do, take a gander at this: http://www.vmware.com/support/reference/linux/loopback_linux.html
The method I ultimately went with was vdfuse since I use VirtualBox. It allows you to mount any disk image supported by VirtualBox. Basically, if you follow the instructions at that the vdfuse forum link I just provided, you can mount the VHD to a mount point in your filesystem. Now, this alone doesn’t yet give you access to your files yet. It provides the partitions as standard files (and a file for the entire disk as well). The partitions are named Partition1, Partition2, etc. You can then mount the partition you want as a loopback device.
Posted in linux | Tagged fuse, linux, mounting, vhd |
By epb on January 8, 2010
Typing this from Deepest Sender (while listening to a remixes of Septette for the Dead Princess) It’s kinda nice and exactly what I was looking for – An extension for Firefox that allows you to post directly to your blog. (Of course you need XML RPC turned on to do so.) I note that it can’t upload or resize photos for you, but that would kinda be feature bloat anyway, wouldn’t it? Ack, it seems to lack the ability to easily make headings and such as well, but you can add them with raw HTML in the source editting tab though.
For a quick one-off post like this, it seems as though it might be a useful tool to have at your disposal.
What’s better yet is that it allows you to save your post so you can come back to it later. (Might want to make sure you give it an XML file extension and don’t accidentally load the Kanji Dictionary XML file either. It really doesn’t like that. Oops.)
Looking for more Firefox blogging extensions? I found them at speckboy design magazine.
Posted in Wordpress |
By epb on January 2, 2010
I noticed a couple of searches for ‘running danbooru’ in my search phrases for this site, so I decided to post a little bit more about that. I assume someone searching for this was actually searching for help with installing danbooru. Admittedly, I had some difficulty with it. For one thing, I’d never used psql in my life.
Here’s the INSTALL file that’s packaged with the source code so you know what you’re getting yourself into before you even fetch the source tree from Subversion.
Continue reading “Installing Danbooru”
Posted in Uncategorized |