Chris Jean

Linux, WordPress, programming, anime, and other stuff
  • Home
  • Linux
  • Development
  • Random Ramblings

Use PHP Pear with Ubuntu

November 2nd, 2009

PEAR is PHP’s equivalent of Perl’s CPAN. It offers hundreds of ready-to-use code modules that can make projects go much more quickly than having to hand code everything. However, it never seems like PEAR is easy to get running.

Installing the Needed Software

In Ubuntu, installing the following packages will quickly get you started with PEAR: php5-cli, php5-dev, and php-pear.

Make sure that you read the next section about problems with using PEAR to install PEAR packages if you are running 9.10, Karmic Kaola.

Here’s an example of how to quickly install those packages from the terminal.

[chris@rommie ~]$ sudo apt-get install php5-cli php5-dev php-pear
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
autoconf autoconf2.13 automake automake1.4 autotools-dev libltdl-dev libssl-dev libtool m4 php5-common shtool zlib1g-dev
Suggested packages:
autobook autoconf-archive gnu-standards autoconf-doc gettext libtool-doc automaken gfortran fortran95-compiler gcj php5-suhosin
The following NEW packages will be installed:
autoconf autoconf2.13 automake automake1.4 autotools-dev libltdl-dev libssl-dev libtool m4 php-pear php5-cli php5-common php5-dev shtool zlib1g-dev
0 upgraded, 15 newly installed, 0 to remove and 5 not upgraded.
Need to get 0B/8,690kB of archives.
After this operation, 27.7MB of additional disk space will be used.
Do you want to continue [Y/n]? y
Selecting previously deselected package m4.
(Reading database ... 127272 files and directories currently installed.)
Unpacking m4 (from .../archives/m4_1.4.13-2_i386.deb) ...
...

With these packages, you are ready to roll with PHP and PEAR in Ubuntu.

Problem with Ubuntu 9.10 Karmic Kaola

A great thing about PEAR is that you can quickly install packages with a simple command. For example, “sudo pear install PHP_Parser-0.2.1″ will install the PHP_Parser package. However, this doesn’t work properly in Ubuntu 9.10, Karmic Kaola.

Output of the standard PEAR install command can be seen below:

[chris@rommie ~]$ sudo pear install PHP_Parser-0.2.1
downloading PHP_Parser-0.2.1.tgz ...
Starting to download PHP_Parser-0.2.1.tgz (70,782 bytes)
.................done: 70,782 bytes

While this doesn’t look wrong, it has actually failed. Rather than installing the package, it has simply downloaded the archive, encountered an unchecked error, and crashed. A successful installation has a message saying that the installation is successful.

This problem can be easily fixed by giving the install command the “-Z” option. For example:

[chris@rommie ~]$ sudo pear install -Z PHP_Parser-0.2.1
downloading PHP_Parser-0.2.1.tar ...
Starting to download PHP_Parser-0.2.1.tar (Unknown size)
.............................................................................done: 533,504 bytes
install ok: channel://pear.php.net/PHP_Parser-0.2.1

Notice the “install ok: …” portion of the message. That’s what you should see at the end of a successful installation.

For more details on this bug, please check out Bug #451314 on the Ubuntu bug tracker.

Categories Linux, Tips 'n Tricks
Comments (0)

Fix Volume not Working in Ubuntu 9.10 Karmic Kaola

November 2nd, 2009

I just encountered an odd issue with Ubuntu 9.10, Karmic Kaola. I had music playing in the background, I adjusted the volume, and I noticed that there wasn’t any change in the volume level. Even maxing out the volume and muting it had no effect.

After wondering if the problem was that I went insane, I looked in Sound Preferences (right-click the volume icon and select Sound Preferences) and found that “RV635 Audio device [Radeon HD 3600 Series] Digital Stereo (HDMI)” was selected under the device output. This means that Ubuntu was trying to send audio over my HDMI connection rather than through my headphone jacks.

This wasn’t a problem last night, so it might be due to the fact that my external monitor at the office runs over the HDMI connection, so it automatically switched to the HDMI audio output. In one way, this is nice, in another way, it will frustrate me to no end if it does this every time I’m at the office. If I’m right that it automatically switched upon detecting an active HDMI connection, then wouldn’t it be better to make it easier to provide a notification on where to switch the audio output rather than just switching it and causing confusion?

HDMI selected in sound output in Ubuntu Karmic Kaola

Switching the option to “Internal Audio Analog Stereo” instantly fixed the problem.

Oddly enough, when I manually selected the HDMI output again, it muted the analog output. So, it seems that it may not be a complete switchover or possibly just a bug. I’ll continue to see how the situation plays out and make a Ubuntu bug report if necessary.

Categories Linux, Tips 'n Tricks
Comments (0)

A Rough Launch for Ubuntu One on Ubuntu 9.10 – Karmic Kaola

October 31st, 2009

Ubuntu 9.10, Karmic Kaola, launched earlier this week. One of the key new features in this release is Ubuntu One. Unfortunately, from what I’ve seen, this new feature/product launch has been anything but smooth.

Ubuntu One is one of the new ways that Canonical, the creators of Ubuntu, is trying to generate some revenue based on their distro. Ubuntu One is a hosted file storage solution that allows users to keep a folder and all of its content synced between multiple computers. All users get 2GB of storage for free with the option of increasing the store to 50GB for $10/month.

Since this new offering has many Ubuntu users very excited, I thought I’d give it a try as soon as I installed the new release. However, I was instantly met with a very big message telling me that something was wrong.

Read More→

Categories Linux, Random Ramblings
Comments (2)

Fix WHM/cPanel cPHulk Brute Force Protection Lock Out Via SSH

October 15th, 2009

One of my company’s servers is hosted with Liquid Web. Yesterday one of my co-workers tries to log into WHM and sees the following message:

Brute Force Protection

This account is currently locked out because a brute force attempt was detected. Please wait 10 minutes and try again. Attempting to login again will only increase this delay. If you frequently experience this problem, we recommend having your username changed to something less generic.

He tries to log in a bit later and receives the message again. He contacts Liquid Web’s Heroic Support, and the support person “helpfully” recommend a server reboot to fix the problem. My co-worker asked for another solution, and support said that it was the only way.

My co-worker tells me about the situation, and I tell him that the support guy is an idiot. It takes all of about ten seconds to quickly find a solution to the problem on google. I then tell my co-worker that I’ll fix the problem, so he “thanks” the support guy and closes the chat.

I logged into the box via SSH and had the problem fixed in a couple of minutes.

Read More→

Categories Tips 'n Tricks
Comments (14)

Fix width:auto Floated Elements in IE 6

September 30th, 2009

It is popular to use ul and li elements float them and set them to width:auto in CSS in order to create a horizontal list of self-sizing boxes. These can easily be used to create horizontal navigation or a listing of tabs, and it works very well. However, there is one caveat; given the right mix of CSS this solution doesn’t work properly in IE 6.

To create this scenario, we can simply use something like the following:

<style type="text/css">
    ul {
        height: 30px;
        overflow: hidden;
    }
    ul li {
        float: left;
        width: auto;
    }
    ul li a {
        display: block;
        height: 30px;
    }
</style>
<ul>
    <li><a href="#">Link 1</a></li>
    <li><a href="#">Link 2</a></li>
</ul>

This will show the problem in IE 6 nicely. The problem is that IE 6 interprets this mix of CSS and decides that each li element should actually expand out to 100% width.

I’ll explain how to fix this issue and provide and example page so you can easily play around with the HTML and CSS yourself.

Read More→

Categories Development, Tips 'n Tricks
Comments (6)

Completed the One Outs Anime Series

September 28th, 2009

I finished watching the One Outs anime series today. I’m neither a sports fan nor a sports anime fan, yet One Outs really won me over.

One Outs is a sports genre anime about a pitcher named Tokuchi Toua. He was found and recruited to the Saikyou Saitama Lycaons by Japanese batting legend Kojima Hiromichi and is not your standard pitcher. Discovered during a game of One Outs, a betting game that pits a pitcher against a batter in a battle of wits, Tokuchi mixes his gambling proficiency, his ability to intimidate and read other players, and his strategic expertise to bring the Lycaons out of their long slump.

My personal interest in this show is how Tokuchi is extremely-creative in how he manipulates everything and everyone to his advantage. This starts when he gets his team’s owner to agree to a contract where Tokuchi is paid 5 million Yen for every player he gets out while he pays a penalty of 50 million Yen for every player that he allows to gain a run. The owner believes that the contract will result in Tokuchi paying him millions of Yen each game, but he is quickly frustrated when Tokuchi sends him a bill of 110 million Yen after the first game he pitches in.

There are currently 25 episodes, which is just half of the story at best. From the series’ Wiki page, I found One Outs was originally a manga running in Business Jump from 1998 through 2006, so there should be plenty of material for many seasons of the show. However, at this time, I have yet to find any confirmation of additional seasons. I’d really like to see them run this series at least one additional season as the story really deserves it.

The music is really bland in this series. Also, the animation isn’t anything special. Neither of these are reasons to watch the show. This show is all about the characters and story, both of which are top-notch.

While I don’t think that this show is for everyone, if you are an anime fan that likes stories involving strategy and tactics, then I highly recommend One Outs.

Categories Anime
Comments (1)

Vertically Centering HTML Content via CSS

September 27th, 2009

Today I  have yet another entry on HTML and CSS. Today it is how to vertically center content in HTML using CSS.

You’d think that there would be a standard definition of how to vertically center any content by now, but there isn’t. There are a variety of methods out there that do this. I frequently see people using the line-height CSS property to vertically center content. While this appears to work, it isn’t very flexible, only works properly if there is only one line of text, and doesn’t work in all situations.

I found Yuhu’s Definitive Solution with Unknown Height which looks great, works properly with all major browsers, doesn’t have the limitations I’ve seen in other solutions, and is quite simple to implement. Basically all you have to do is have three divs wrapped around the content you wish to vertically center and use specific styling for those divs.

The following code is what does the magic. Replace the comment with the content to be vertically centered, change the height to match the vertical height of the container, and you’re set.

<div style="display:table; height:400px; #position:relative;">
    <div style="#position:absolute; #top:50%; display:table-cell;
vertical-align:middle;">
        <div style="#position:relative; #top:-50%">
            <!-- content to be centered -->
        </div>
    </div>
</div>

I built a quick example document that shows how I applied the rules via a style block in the head to keep the HTML clean.

As with my taming HTML lists fix, I tested this successfully on the following browsers:

  • OS X
    • Firefox 3.5
    • Safari 4
  • Ubuntu (Linux)
    • Firefox 3.5
    • Google Chrome 4
    • Konqueror 4.2
    • Midori 0.1.2
    • Opera 10
  • Windows
    • Firefox 3.5
    • Google Chrome 4
    • Internet Explorer 6, 7, and 8
    • Safari 4

Thank you Yuhu for the great solution.

Categories Development, Tips 'n Tricks
Comments (0)

man Pages for C Development in Ubuntu

September 26th, 2009

I recently tutored a friend in C coding. Since I hadn’t worked with C in at least 8 years, I really needed to have some references to rely on for syntax and other specifics. Fortunately, there are some easy man pages that can be installed in Ubuntu that offer helpful information that I was able to use to help refresh my memory.

These man pages are easily installed by installing the manpages-dev package. You can install this package via Synaptic or directly on the command line. I like the command line method personally, so I ran sudo apt-get install manpages-dev from the command line to quickly install the package.

After installing the package, I’m able to access man pages for functions such as printf, opendir, and putc. For each function, it shows the valid syntax as well as what library is required to make use of the function.

The information isn’t limited to functions as you can also access information on the libraries, such as stdio or string.

To access any of this information, simply run man [function or library name] such as man stdio.

This package isn’t limited to C functions/libraries. It is a general use Linux development suite of man pages. For a full list of what is installed, check out the file list.

Categories Development, Linux, Tips 'n Tricks
Comments (0)

Pushing a Webpage Footer to the Bottom of an HTML Page with CSS

September 25th, 2009

Anyone that works with HTML and CSS will tell you that positioning things exactly where you want them to be is often times difficult. If you want to position something somewhere vertically, it becomes even worse.

I just finished working on a theme where I needed to force the footer of the layout to the very bottom of the page. While logically putting the footer after all the other content is easy, making it sit at the very bottom of the page even when the content doesn’t take up enough space to push it down there is quite difficult.

After struggling with getting this right for a couple of hours, I finally found a site that has done all the hard work for me. CSS Sticky Footer is the site that saved my sanity.

CSS Sticky Footer provides a solution that sticks the footer to the bottom of the page in a cross-browser compliant manner. The site reports, and I can confirm, that it works with Internet Explorer 6 through Internet Explorer 8,  Firefox, Google Chrome, Safari, Opera, and Konqueror.

Since the implementation could change, I recommend that you visit the site to get details; however, just in case something happens to the site, I’m going to add the solution here as well.

Read More→

Categories Development, Tips 'n Tricks
Comments (0)

Taming HTML Lists Across All Browsers

September 24th, 2009

It seems that every browser rendering engine has a completely different way of rendering lists. I recently had the frustrating job of getting them all to play nicely together.

The CSS I ended up using is quite simple and works across all the browsers I tested (list at the bottom).

This is the magic bit of CSS:

ul, ol {
    list-style-position: outside;
    margin: 0 0 0 15px;
    padding: 0;
}
ol {
    margin-left: 20px;
    *margin-left: 24px; /* targeted IE 6, 7 fix */
}
li {
    margin: 0;
    padding: 0;
}

This CSS forces all the browsers to play by the same rules. The end results are nice and clean.

The left margins are necessary to get all the browsers to not clip part of the bullet/number; however, you can change this left margin on ul/ol elements contained within the primary ul/ol if you need to adjust the indentation of each sub-list.

Each browser that I tested rendered the same thing, albeit with slightly different bullets or padding in front of the number.

The following are the browsers I tested:

  • OS X

    • Firefox 3.5
    • Safari 4
  • Ubuntu (Linux)

    • Firefox 3.5
    • Google Chrome 4
    • Konqueror 4.2
    • Midori 0.1.2
    • Opera 10
  • Windows

    • Firefox 3.5
    • Google Chrome 4
    • Internet Explorer 6, 7, and 8
    • Safari 4
Categories Development, Tips 'n Tricks
Comments (2)
« Previous Page
Next Page »
Chris Jean
Copyright © 2012 All Rights Reserved
iThemes Builder by iThemes
Powered by WordPress