Posts Categorized: linux

A Script A Day – Day 01/05

I had an idea for a programming self-challenge.  From Monday, Sept 1st to Friday, Sept 5th: I’ll write a new script each day.  The goal should be simple enough to solve in one day, but not so boring I’d feel dumb writing about making it.  I’ll likely be sticking to business logic type goals, as I don’t actually enjoy algorithmic challenges as much.  Now if a practical goal requires a decent algorithm, then so be it.

Continue reading

Script Encrypt

Have you ever wanted to encrypt a script so that it could only be run with the correct password?  Chances are… probably not.  However, in the off chance that you have, and your script is perfectly happy being piped through it’s interpreter (* See note below), then this script might work for you.  I make no guarantees or claims about how secure it might be, and it requires openssl to be installed to work. You can view the code or download it yourself at my BitBucket repo for Script Encrypt. Continue reading

ImageMagick: Rounded-corner PHP function

I’ve converted my rounded-corner bash script into a PHP function that’ll use the Image Magick command line tools to do the same. With some added functionality to handle automatically creating thumbnails and applying a background color to the source image itself. This also allows for the insertion of basic pre-processing and post-processing arguments to IM.

For more information and output examples see. the bash version.

To see an example of thumbnails generated with some pre-processing done:

First Preprocessor Test

This is a sample done with thumbnail pre-processing. That is processing done before the rounded corners are made.

With this sample, I switched colorspace to HSL and then set the hue and saturation to a constant before applying the glass-bubble rounded corners.

Known bug: sometimes the glass-bubble method will add a single pixel to the width, which is transparent. I believe passing -trim in the postprocessing option may trim that off for you, though I have not thoroughly tested it.

Also: I have no idea if this will work on a Windows server.

Continue reading

Rounded Corner Script

Script Download: rounded_corner.sh (v2)

Ever wanted a script that would round the corners of images for you?  Well, if you said yes, I wrote myself a bash script to do just that.  As of this post it can do the following: round of corners of images and it can also add a glass-bubble effect as described in the ImageMagick tutorials.  You can specify the border radius and a background color, which is handy if you are making JPEGs.  The script’s help screen is shown below, as well as a couple of samples.  Radius sizes are in pixels.

./rounded_corner.sh <inputfile> <outputfile> [options]
  -m   Method [plain or glass-bubble]
  -r   Corner Radius
  -b   Background Color
Method can be plain or glass-bubble at the moment. (default: plain)
Radius specifies the radius of the rounded corners. (default: 15)

Note: This should be able to function as filter command, so if you wanted
rounded thumbnails of a particular size you can:
convert <bigfile> -resize 200x200 png:- | ./rounded_corner.sh png:- smallrounded.png" 1>&2

CherryPad America

I got my CherryPad America toward the end of October.  It’s a low-end tablet, comparable to the ones you can now find at WalMart and KMart.  I bought mine primarily to function as an e-reader, and quickly found that it had impressive video codec support and could do more than I was expecting out of such a cheap device.  (When I bought it, it was one of the cheapest on the market.)

I was order number 58, so some things are probably different now.  I believe the factory language is now English instead of Chinese for instance.

Some initial thoughts:

  • Good codec support (Too bad the Android video player doesn’t support internal mkv subtitles.  You need third party software from the market for that.)
  • Root access!
  • Android Market is a pain to get (and keep) working.
  • Resistive Screen takes some getting used to
  • Speakers are less than impressive, but sounds pretty decent with headphones or externally attached speakers.
  • Fits in one hand, good for reading.
  • Gah, why is JavaScript not on by default?
  • I like the aluminum case.
  • Uses my iPod’s docking cable.
  • A little slow sometimes, depends on the task.

Getting the Android Marketplace to function well has been an uphill battle, and honestly, the biggest problem I’ve run into.  It will work for a bit and then stop working entirely.  Actually, hasn’t worked for a week for me now. *sigh* I think I’ll email and ask about that.

If you’re looking for a simple music-playing, video-playing tablet, that you can use for reading and browsing the Internet.  It’s perfectly capable of all that.  I even use it to order parts off NewEgg and such.  Once you get it set up to your liking and get used to the resistive screen, it’s nice, if a little slow.  Verdict is that I like it, but am hesitant to recommend buying it because of the issues I’ve had with the Android Market.

Rythmbox Sync to USB Device

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.