Author Archives: Gen2ly

About Gen2ly

<3's linux

WordPress Tips 2

Wordpress Tips 2Continuing from yesterdays tips I have a few tips that can help bloggers begin.

Purty Colors

Syntax Highlighting in Blogposts with Vim

Post Ownership

Being blog-rolled is when a post the owner has written appears to belong to someone else because it has been reprinted. I use the creative commons attribution license here so my content is free distributable as long as there is reference to the original work but I have discovered that search engines can misinterpret the original owner of the post. Google has a fail-safe that can tell ownership of a post by that post linking to itself. I have created a script that can makes this simple:


# vm2html-segment
# Create HTML formatted text suitable for displaying syntax highlighting
# in a blog post, or possibly some forums.


#vim -f +"syn on" +"let html_no_pre = 1" +'let html_use_encoding = "utf8"' +"let use_xhtml = 1" +"let html_number_lines = 0" +"so \$VIMRUNTIME/syntax/2html.vim" +"wq" +"q" $FILENAME

vim -f  +"syntax on" \
        +"colorscheme simple256" \
        +"let html_no_pre = 1" \
        +"let html_number_lines = 0" \
        +"TOhtml" \
        +"x" \
        +"q" $FILENAME

# Just need the colored syntax, deleting the HTML page information.
sed -i '1,/body bgcolor=/d' $FILENAME.html

# Adding preformatting first <pre> tag
sed -i '1 i <pre>' $FILENAME.html

# Line breaks no longer need to be defined with preformatted text.
sed -i 's|<br>||g' $FILENAME.html

# Remove the closing HTML tags.
sed -i 's~</body[^>]*>~~g' $FILENAME.html
sed -i 's~</html[^>]*>~~g' $FILENAME.html

# Add the closing preformatting tag
sed -i '$ a </pre>' $FILENAME.html

Type “wordpress-link title of post” and paste in blog. This creates an invisible link and will not be seen.

Style Sheet

Commercial wordpress users will need to pay a few dollars to be able to create a custom style sheet. Some style sheet attributes can be added though within the html tags. For instance, I like padding around images:

<img src="" style="margin:0 10px 5px 0;" align="left" alt="Links Saturday" /     >

WordPress RSS Feeds

A final note on WordPress RSS feeds. WordPress RSS feeds do the odd behavior of subsituting the username for the title of the feed. Changing to an ATOM feed can fix this but if you’re stuck with a news aggregator site that refuses feed changes the title can be changed by defining the name (alt tag) of the last image of the post:

<img src="" style="border-width:0;" align="left" alt="Wordpress Tips 2" />

Hope this makes blogging better! :)


WordPress Tips

Wordpress TipsTyping this blog for the last six months has been a tremendous honor to me. It is something I have learned to love and loved to do. First, I want to thank the tremendous folk as WordPress that made this happen. From the very first few times I used wordpress, I knew that it was top notch software and I humbly thank all of them for letting me be a part of it. Thank you. I wish many good wishes and fortune for a folk who envisioned software that provides beautiful collboration and ease of use.

WordPress 2.5 was released a couple weeks ago and carries on the good work. I’d like to provide a few tips I’ve learned over this time to all wordpress users and blogging in general.

RSS Feeds

WordPress by default only shows summary feeds. This is all good if wanting to get people to come to the website and comment but if just wanting to get the word out consider a full feed. In the Dashboard go to Settings > Reading to choose.

Linking to Other Articles

It took me forever to figure this out but there is a right way to link internal posts. I kept linking to previous articles and having tracebacks put in comments. Tracebacks are used so the owner of the blog knows who is linking to the article. A good idea but tracebacks from within the blog are unecessary. To prevent this use the relative link “<a href="/2008/04/04/random-thoughts/">Random Thoughts</a>”

Code to HTML Entities

HTML code doesn’t like key characters like < and &. Web browsers interpret such characters as HTML code and won’t print them. Therefore there’s a special syntax for writing the entities like < and & they will need to be encoded as &lt; and &amp;. Theres a good number of characters that require conversion. I found this script for perl on cspan that can encode to html but I don’t know a lick of perl so I prefer to encode with a website encoder.

WordPress Themes

No theme is perfect and even the best wordpress themes have minor bugs. For instance, the Ocean Mist theme I used prior wouldn’t give a proper return after emoticons. So after each I had to break <br>. Well the Ocean theme was fixed and I ended up editing a number of my posts. Generally it’s best to format correctly and either wait for the theme to be fixed or better yet tell the author about the bug. Many authors update their themes as necessary. The authors name can usually be found at the bottom of the page.

I’ll have a couple more tips tomorrow.

Upcoming Games – OpenLieroX

I like to try new games, I generally don’t write about them though. I often shuffle through free gamer and game tome on the weekends to see what budding developers are doing. Some of them are pretty cool but few are worth talking about as they are all usually early in development. I was pulled in my OpenLieroX though.

I wasn’t a Windows user for many years so I never heard of it. Liero is an real time, excessive carnaged, Worms-clone. Though I have tried Worms before (and really liked it) I didn’t know what to expect. So a good clone would be something I’d like to see in Linux. Clones in general are something that I’ve learned to avoid. Good games are alot more than ideas and usually only pretentious developers feel they replicate the time and detail of a commercial success.

I’ve been real fortunately lately with games. I’m still playing OpenTyrian which rocks, and Wesnoth is alot of fun so I really didn’t need anything else, but I got the bug, or should I say… worm.

To be technical, OpenLieroX is a clone of Liero Extreme the most popular of Liero clones. So OpenLieroX is a clone of the of a clone of a clone, ok, I got it… :) This sounded discouraging but OpenLieroX is actually a polished game with some nice features.

The plot of Liero is simple: destruction. Moving the worm about and firing various weapons is all Liero is basically about, but it’s Fun! Gameplay is smooth, there’s lots and lots of weapons, sound effects are all good too. Also there are a good number of mods to keep it interesting. Network play looks like it be a kick in the pants, and the CPU AI is about average. Maybe the screenshots will show it best.

The menu:

Local Play:

On a 747:

Now they’re trapped, think I’ll nuke ’em.

Upcoming Games - OpenLieroX

The developer has been working on this steady for quite a bit now and I like his efforts. Good too see good games come into Linux. OpenLieroX is an unexpected surprise and well worth the try.

The Three Amigos – Tar, bz2, and gunzip

Lucky Day: Wherever there is injustice, you will find us.
Ned Nederlander: Wherever there is suffering, we’ll be there.
Dusty Bottoms: Wherever liberty is threatened, you will find…
Lucky Day, Ned Nederlander, Dusty Bottoms: The Three Amigos!

Dusty Bottoms: Do you have anything here besides Mexican food?

Tar, bz2, and gunzipBeginning with Linux meant getting to know the obscure file.tar.gz I had sometimes seen trespassing in Windows. To begin with, this extra dot threw me off – what does that mean? And what about these extensions that weren’t always the same, similar but different – .tgz, tar.bz2, tb2. Well here is what tar is and his amigos gunzip and bunzip2.

Tar is a file format and a program. Tar is short for tape archive, whence once tape media was used to backup data. Tar is a program to create a file that is a container of other files. Tar follows the Unix Philosophy “do one thing and do it well” paradigm and is ONLY a container of files. Tar files are not compressed (though they are typically compressed afterword to save space which are typically termed tarballs). Most tar compressions are either done with the gzip or the bzip2 programs. Why not compress a bunch of files with just gzip or bzip2 then? Because gzip and bzip2 follow the Unix Philosophy as well and can only compress one file. The tar program only has the ability to concatenate files, gzip and bzip2 have the ability to compress single files.Tar, bz2, and gunzip

Tar though does have built-in ability to work in conjunction with gzip and bzip2 compression (bzip2 is becoming a more popular format because it provides provides higher compression).

To tar and compress with gzip:

tar -cvpzf filename.tar.gz fileorfolder

To tar and compress with bzip2:

tar -cvpjf filename.tar.bz2 fileorfolder
  • -c is for create, v verbose, p preserve permissions, z gunzip, j is bunzip2, f is write to file
  • these arguments cannot generally be switched, the order is important.
  • tar.gz is the typical Unix format. For MSDOS compatibility sometimes .tgz or .bz2 will be seen.
  • any number of files can be specified file1 file3…

To see the list of files in a tar container:

tar -tzf filename.tar.gz
tar -tjf filename.tar.bz2

And to decompress:

tar -xvf file.tar.tgz
tar -xvf file.tar.bz2

I have experience with the new simplified way (-xvf) not always working and had to use the expanded form for bunzip2’s:

tar xvjpf file.bz2

Because I’m not good at remembering arguments I created a basic script called trex:

# trex - tar files and folders


if [[ -z $LOCATION ]]; then
    echo "tarer <compressed-name>.tgz </location/to/start>"
    echo "  - use absolute location if planning restores."

tar -czpvf "$NAME".tgz "$LOCATION"


Linux Design – Calibrate the Display

Many people who have worked in the professional graphics department in either Mac or Windows have learned that a calibrated display is a valuble tool in creative design. Macs have a manual display calibrator built into OS X that is pretty darn good. It allows the users to adjust color balance in varying gray scale levels. To a trained eye this can nearly be as good a hardware calibration. ICC profiles can as well be created for printers, scanners… Creating an ICC profile will give very very accurate colors to be able to produce and reproduce across different monitors and medium.

Linux isn’t a powerhouse for desktop publishing. Alot of people still use older versions of Photoshop instead of GIMP (I suspect that’s it’s more for the plug-ins that anything else). And calibration in Linux is still in its infancy. So what can be done in Linux?

Keep in mind readers that I haven’t worked in desktop publishing in quite a while but this is what I found out I can do in Linux.


Lprof is a graphical (qt) application to create ICC profiles for camera, scanners and monitors.

I installed Lprof and I have Gnome so I thought that alot of qt applications may get pulled in but Portage only had to pull in one qt library so it wasn’t so bad.

With Lprof can set a generic color space, a white point(D65 – daylight, is the standard for most desktop LCD’s and monitors), and also a gamma. Lprof will need a screen 1024×768 to adjust the gamma, this can be got around for small displays by making the desktop scroll in the xorg.conf:

        SubSection "Display"
                Depth           16
                Modes           "800x600" "640x480"
                Virtual         1024 768

A more specific color space (RGB values) can be defined, but Lprof has no way manually test it.


Xcalib is an utility for setting an ICC profile to a monitor.

xcalib ibook.icc


Argyll is a command line tool and driver to be used with professional hardware calibratrors. (spectrophotometer, colorimeter). I have yet to try it though I would very much like to one day.

Other Alternatives

Lprof and xcalib didn’t work for me. Either Lprof didn’t write a profile that xcalib understood, or xcalib wasn’t able to properly communicate to the video card. I suspect the later, as on xcalibs site it is noted that xcalib has trouble setting a couple variables on older ATI cards.

All is not lost though as the gamma setting can be set to make up some color differences in the monitor.

Most distro’s already have xgamma installed so begin testing xgamma by:

xgamma -gamma .95

Xservers default is 1.0. Use a gamma chart to correctly set the gamma.

Most charts are configured to be set to 2.2, the basic standard now days. Macs still use 1.8 which can make things screwy even when I used Mac OS I had a 2.2 gamma set up.

Xgamma can adjust color gammas too -rgamma -ggamma but there is alot easier way to do that


Monica, my honey my sweetie. Monica is a graphic front end to xgamma:

Linux Design - How to Calibrate the Display

Careful with Monica she can be sensitive – the color boxs are tad off. I find it easier to detect color skew with the gray scale bar on top. Thank ya honey, you can go now. ;)

Wrapping Up

Monitors and LCD’s do change over time. It’s not uncommon in desktop publishing house to see people calibrate their displays every couple of weeks. But now that gamma has been discovered a good way to set it is to put it in the Monitor section of /etc/X11/xorg.conf:

Section "Monitor"
    Identifier  "Color LCD"
    Option      "DPMS"
    HorizSync   28-84
    VertRefresh 43-60
    Gamma       0.78 0.92 0.95 #RGB

Lprof Bug

Once I had created a profile, Lprof refused to write to file. Probably a missing dependency but easy enough to fix:

touch ~/Desktop/ibook.icc

Then on the select file button (…), I selected ibook.icc and then was able to “Create Profile”.

Notes and Resources

Command Line – Converting SVG’s

Command Line - Converting SVG'sDoh!

A couple days ago I mentioned that I’d be writing about converting svg’s from the command line… yesterday. This porous gooey noodle at times steers adrift however and the pen forgot about the partchment. Thankfully though I awoke today and the replacement that at times gets loaned to me recalled.


Previously, I had used Gimp to convert .svg‘s to .png‘s, but I found that a line to Inkscape from the command line can do it nice and quick:

inkscape noggin.svg --export-png=noggin.png -w96 -h86

Inkscape also can do pdf’s, and eps’s. Some examples can be found on website Inkscape

Forgiven hopefully Iam.

Command Line – Resizing Images GIMPless

Fairly often I’ll find a desktop that I like on the Internet and download it. Usually the process is that it’s not the correct size for my desktop and I’ll open up Gimp and resize it. This can be a bit of a time taker if there is only one image. Imagemagick can do the job from the command line possibly faster.

For example, last night, I snatched a wallpaper from IamFreeman. Its a good wallpaper with rough texture, nice and simple. Now to resize it to the desktop size I use imagemagick’s mogrify or convert program. Mogrify tranforms the image meaning making mistakes = bad, convert will write a new image. I use mogrify here, if using convert specify the new filename at the end of the line.

If I just wanted the top left part of the image, I could just crop it.

mogrify Clean_is_simple_by_iAmFreeman.jpg -crop 800x600+0+0

The 0+0 specifies the top-left portion of the image. But I don’t want to just crop the top left, I want the whole image scaled down.

Since the proportions aren’t equal between my screens aspect ratio 4:3 (800×600) and the desktop I choose is 5:4 (1280×1024), I’d need to crop part of the image before I resize. The image dimensions can be listed with the identify command:

identify Clean_is_simple_by_iAmFreeman.jpg 
Clean_is_simple_by_iAmFreeman.jpg JPEG 1280x1024 1280x1024+0+0 DirectClass 8-bit 729.758kb 0.700u 0:02

To discover if height or width needs to be cropped, find the difference of the aspects:

echo "scale=5;(1280/1024)/(800/600)" | bc

This tells me proportionally the 5:4 picture is taller. If the value is less that one then the height needs to be cropped, greater than one and the width needs to be cropped. In this instance, the height needs to be cropped 93.75%. If the width needs to be cropped:

echo "scale=5;(1280/800)/(800/600)" | bc
echo "scale=5;(100/1.2)" | bc

To use mogrify to crop, tell the x and y in percentages:

mogrify Clean_is_simple_by_iAmFreeman.jpg -crop 100%x93.75%+0+0

Purists will say that, this isn’t’ good. That god will walk upon the earth and smite thee. Yes, and he’d be right to. Here:

mogrify Clean_is_simple_by_iAmFreeman.jpg -crop 100%x93.75%+0+32

I specified in the previous command 0+0 (the crop value from the top left) hence the bottom portion was cut off in the previous command. Since the image is being reduced to 960 pixels height and since – (1024 – 960)/2 will give us the proper offset. The image is now centered. (+) values will crop x and y from the top left, (-) values will crop x and y from the bottom right.

    +        -
+  |           |
   |           |
   |           |
-  |___________|

OMG, what a pain!

Anyways, its easy to resize now:

mogrify -resize 800 Clean_is_simple_by_iAmFreeman.jpg

I only specified the width here as specifying height would be redundant. If the image needs to be stretched or compressed use an ! after the value (800×500!).

All in One Command

Put the steps in order and this can be done in one command.

mogrify Clean_is_simple_by_iAmFreeman.jpg -crop 100%x93.75%+0+32 -resize 800


I’ll talk about converting SVGs tomorrow and how I take screenshots.