PostgreSQL: DB Error: constraint violation.

When inserting a row into a PostgreSQL database table, PHP’s PEAR DB class was giving me the following error:
DB Error: constraint violation
After some research I found out that when we moved the tables to a new database server, the SEQUENCE values were not updated, causing this problem. Sequences are the equivalent of MySQL’s auto-increment and are used to generate a unique identity value for newly inserted rows.

Because our table already had plenty of rows in it and the sequence value was not in sync, the insert would fail because the ID generated for it by the sequence already existed in the database. This is an easy fix, all you have to do is update the sequence value to be back in sync with your data. Simply run the following command in psql to bring everything back into sync:
select setval('your_table_id_seq', (SELECT max(id) FROM your_table) + 1);
Of course you will want to substitute your own sequence, table, and field values into this command. Once you’ve done this everything will be back in sync and you’ll be able to insert new rows into your DB once again.

Red Hat Fedora Linux: Add an additional IP to your network card.

Adding an additional IP or IPs to your network card in Linux is easy. Here’s how I did it in my Fedora Core 4 installation:
cd /etc/sysconfig/network-scripts/
cp ifcfg-eth0 ifcfg-eth0:0

Now you will need to open your newly created ifcfg-eth0:0 file in your favorite editor and modify it to fit your needs. The two lines you MUST change are the following, the rest are optional:
DEVICE=eth0:0
IPADDR=192.x.x.x

Of course you will want to fill in the IPADDR value to fit your needs.

Now, to make the changes take effect, you will need to bring your new IP up by issuing the following command:
./ifup eth0:0
Or if you want you can just restart the entire network:
/etc/rc.d/init.d/network reload
There you go! Run ifconfig and you should see your new IP assigned to eth0:0. It should look something like this:
eth0:0 Link encap:Ethernet HWaddr 00:D0:B7:B7:XX:XX
inet addr:192.168.1.XX Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

You can add even more IPs by repeating this process and incrementing the value of eth0:0, for example you can add eth0:1, eth0:2, etc.

Retrospect Express HD for Maxtor OneTouch: “Can’t save setup…”

I was receiving the following error after completing the setup for Retrospect Express HD with my Maxtor OneTouch External Hard Drive:
Can't save setup, check the selected drive to make sure there is enough free space.
I had plenty of space on the drive, so I knew this couldn’t be accurate. After some research I found out that my config file was corrupt and it was an easy fix: Remove or rename the RestorePoint.rbc file in the Retrospect Restore Points folder on your external drive. Open up Retrospect Express HD and it will re-create a new config file, as well as re-create all your restore points. This can take a very long time (hours) but once it’s done you’ll be back up and running like new.

(Source: http://forums.dantz.com/)

phpList: processing with cron & bash script: “Command not found.”

If you are trying to process your phpList queue using a crontab, you will have to set up the phplist script provided in the bin directory to work with your system. It looks like this:
#!/bin/bash# script to run PHPlist from commandline. You may need to edit this to make it work
# with your shell environment. The following should work for Bash# in commandline mode, access is restricted to users who are listed in the config file
# check README.commandline for more info# identify the config file for your installation
CONFIG=/home/website/public_html/lists/config/config.php
export CONFIG# alternatively you can use -c on the commandline# run the PHPlist index file with all parameters passed to this script
/usr/bin/php /home/website/public_html/lists/admin/index.php $*

Of course you will want to modify all the paths to fit your phpList install. Most importantly, however, is to not forget to modify the FIRST line if need be. Otherwise, if your bash interpreter exists elsewhere, when your try to execute your script you will get the following error:
/path/to/phplist: Command not found.
For the majority of the installations out there, /bin/bash should be fine, however on some systems you may need to edit this to point to where your bash interpreter is installed. In my case, I had to change it to /usr/local/bin/bash.

To future-proof my changes, I also symlinked to where my bash existed:
ln -s /usr/local/bin/bash /bin/bash
That way I will not have to re-edit new versions of the phplist script in future phpList upgrades.

Windows & NTFS: Cannot rename file, or: Working with files containing double periods (..) in filename.

I had downloaded a folder from a friend’s FTP server titled “Orchestrated & Conducted by..” the other day. When attempting to browse inside the folder using Windows Explorer I was given the following error:
D:\Orchestrated & Conducted by.. refers to a location that is unavailable. It could be on a hard drive on this computer, or on a network. Check to make sure that the disk is properly inserted, or that you are connected to the Internet or your network, and then try again. If it still cannot be located, the information might have been moved to a different location.
Great. Unable to access a folder on my hard drive! I’m assuming it’s because of the “..” characters in the directory name. It is of course in Windows’ best interest for security reasons to not deal with any mischievous files trying to read the directory above it.

So I tried a few other things to access the folder. First I tried renaming the folder. Windows explorer lets me Right Click > Rename and even lets me type in a new name. However, when I press Enter to rename the file, I get the following:
Cannot rename file: Cannot read from the source file or disk.
Great. So I brush off my dusty old DOS skills and open up a command shell, navigate to the dir containing the bastard, and try it old school style:
D:\> rmdir "Orchestrated & Conducted By.."
The system cannot find the file specified.

Great. Now lets get medieval on this folder’s ass!
D:\> dir /x
Volume in drive D is Data
Volume Serial Number is BC1A-DBC4
Directory of D:\
 
01/03/2006 04:35 PM <dir> ORCHAS~1 Orchastrated & Conducted By..
0 File(s) 0 bytes
1 Dir(s) 35,736,907,776 bytes free
 
D:\> rmdir ORCHAS~1
D:\>

SUCCESS!

So, if you ever have an unruly folder, the way to deal with it is to use 8.3 notation when handling your files. To see what a file or folder’s 8.3 notation is, simply type dir /x at the command prompt.

The funny thing is that I used to have 8.3 notation disabled for performance reasons but had recently re-enabled it because of a software incompatibility with Mozilla Firefox. I have no idea how I would have gotten rid of this loco folder if I hadn’t of re-enabled 8.3 notation.

Logitech diNovo Wireless Desktop Review

Logitech diNovo Wireless DesktopThe population explosion of gadgets and their connectors on my desktop had finally pushed me to make the jump to a wireless desktop. I was looking for a few things: simple keyboard/mouse combo, minimal bells & whistles, nice look & feel, and something that just works. Since I don’t need an espresso machine or back-massager built into my wireless desktop, I was pleased to find the sexy Logitech diNovo Media Desktop: Sleek, stylish, simple, and of course, wireless… without all the fluff!

I did my research and read plenty of positive and negative reviews, but most of them seemed to revolve around problems with Logitech’s software and driver package for the diNovo’s media center controller capabilities. I wasn’t looking for any of that, so I decided to gamble and invest in the admittedly expensive ($158.89 from NewEgg.com) diNovo.

Below you will find my completely non-official, non-technical, stream-of-consciousness review of the diNovo.

I was up and running in no time. Simply plug in the USB-Bluetooth dongle, power up, and everything was instantly recognized and installed by Windows XP. A quick 4-hour charge of the mouse on the handy cradle and everything was good to go. Keep in mind, I simply did not care for any of the extra bells, whistles, buttons, and features that the diNovo offered, I was only interested in the keyboard and mouse operation. So if you want all that extra crap, you will have to install all the Logitech software and drivers which, apparently, cause people all sorts of problems. Just know that the keyboard and mouse themselves work great as plug-and-play devices in XP, and don’t require ANY third party software installation to operate right out of the box.

The mouse is a bit heavier than my old Microsoft optical, which concerned me at first, but now I don’t even notice it. The extra weight even actually helps a bit with super-fine mouse navigations, as it gives more physical feedback to your hands than a flimsy lighter mouse. The buttons click and the wheels scroll, which is all I needed, so this laser mouse gets an A grade from me.

I have had absolutely ZERO major problems. Granted, I never installed any of the Logitech drivers, as I only need a simple keyboard and mouse combo. If you want all the bells and whistles, I imagine you’d run into some potential problems, but if you want just a simple keyboard and mouse like myself, this is a great investment. In the month I’ve been heavily using the diNovo, I’ve only had one issue with Bluetooth where my keyboard lost connectivity. I had to pop out the batteries and re-insert them for my keyboard to become responsive. Sometimes when returning to my desktop after being idle, it takes a split second for they keyboard and mouse to kick on and become responsive, but it’s hardly even noticeable. Once the Bluetooth reconnects, everything is back to normal. It’s a worthy trade-off in my opinion: trade a little instant gratification for extended battery life.

I do have a few minor gripes, but they can probably be attributed more to my personal idiosyncrasies than anything else. I don’t like the fact that the keypad is separated from the keyboard. I’m assuming they did this so that you can use it as a remote-control for your media center, but I’m not using any of that junk. It is quite annoying that when I move my keyboard around the keypad doesn’t come with it. This also leads to another gripe. I like my keyboard slanted towards me, so I open up the little legs on the bottom to elevate the top a bit. Of course the separate keypad doesn’t have any legs, so it sits flat while my keyboard sits slanted. It’s fairly annoying that a product that supposedly spent so much effort in the style arena didn’t think this through, because now my otherwise elegant media desktop looks like a stupid non-matching set of pieces. This could have easily been solved by either giving the keypad its own legs, or making it possible to attach it to the main keyboard. Ahhhh well, nothing’s perfect I guess.

PROS:

  • Wireless!! Duh.
  • Mouse is re-chargeable and has never let me down even after extended (10+ hour) usage. Simply pop the mouse on its charging cradle before you go to bed and you’ll always have a full charge at your disposal the next day.
  • Mouse has an LED indicating battery charge. There are 3 bars and I’ve never seen it go below two bars, even after a full day’s use.
  • Laser mouse is more accurate that old-style opticals.
  • Mouse “heft” makes it feel like an actual tool rather than a cheapo piece of plastic. The extra weight helps with pointer-detail stuff.
  • Look and feel is top notch. No bulbous buttons or monstrous extrusions where they need not be. Minimalist stylings look great!
  • Laptop-style keys: Although it is a full-sized keyboard layout, the keys themselves are the thinner and softer laptop style. Quieter and easier to type on. More my style.
  • Built in calculator in the keypad is a plus. I’ve found myself using it more than XP’s calculator.

CONS:

  • Keypad is separate from keyboard (personal preference). They should have at least made it attachable so that you have an option.
  • Keypad doesn’t have its own feet to slant it towards you a bit. So if you slant your keyboard you end up with an un-even layout.
  • Keypad screen is not backlit. It’s difficult to see unless you’re in bright light or you’re 2 inches from the screen. Of course a backlit screen would suck the battery to death, so I don’t mind too much.
  • Slight half-second delay when waking from idle battery-saving mode. Not a big deal.

Now my only hope is that this baby lasts long enough for it to be worth what I paid. The last Logitech keyboard I bought crapped out after about 3-months. Lets hope that the diNovo can redeem the Logitech name in the eyes of this beholder.

phpList/Sendmail/Linux: X-Authentication-Warning

As a follow-up to my post on getting rid of the X-Authentication-Warning error when using phpList on FreeBSD, here’s how to do the same in Linux.

Open up /etc/mail/trusted-users in your favorite editor, and add both the user that your Apache is running under, as well as any usernames which are processing phpList queues and bounces via crontab. For example, your trusted-users file should look like this:
httpd
yourusername

Save & Exit. Restart sendmail with the following command:
/etc/init.d/sendmail restart
Now when you send mail with phpList, the headers won’t contain X-Authentication-Warnings.

One security drawback that you should be aware of: Any user on your system can now use PHP to send email with “forged” headers. You basically just gave everyone on your system “Trusted User” status to Sendmail, so be sure that you trust your users before actually doing this!

See how to do this on FreeBSD