transparent block Click here to login or logout The Photo Gallery All about me


You never know till you try to reach them how accessible men are; but you must approach each man by the right door.
Henry Ward Beecher, preacher and writer (1813-1887)

How I drastically increased battery life on my Dell XPS M1530

Posted in Delusions,Home Improvement,Injustice,Personal by Riskable on the February 26th, 2009

I ordered my Dell XPS M1530 with the “extended”, 9-cell battery in the hopes that I could run on battery power for at least three hours.  After using my laptop for a few days I realized that I had got my wish:  It ran for about 4 hours with the screen dimmed to ~75%, the ondemand CPU governor enabled, and running a 3D-accelerated (Compiz) desktop.  This was with Ubuntu 7.10 (Gutsy Gibbon) and KDE 3.

Recently (well, months ago =) after migrating to KDE 4.1 in Ubuntu 8.10 I’ve had to plug my laptop in after about 2 hours.  Even if I dimmed the screen significantly and shut down non-essential services it still wouldn’t last very long.  More importantly, as time progressed I knew the problem would just get worse so I decided to investigate.  This investigation turned up some surprising tweaks that save a lot of power…

(more…)

How to avoid cron hell

Posted in Personal by Riskable on the February 24th, 2009

Cron is not a particularly intelligent utility.  It will run a command whenever it is set to run–regardless of whether or not the last invocation of said command completed.  So if you have a command that puts a high load on your system and it’s time for cron to execute that same command again you’re going to be in a heap of trouble.

The solution to this problem is as old as cron itself but for some reason it seems to have gone missing in the minds of the general cron-using public.  Here it is:

* * * * * [ -n "`ps -ef | grep -v grep | grep myprocess`" ] && <execute myprocess>

That will only execute “myprocess” if it isn’t already running.  Here’s another way:

* * * * * [ ! -f /tmp/myprocess ] && touch /tmp/myprocess && <execute myprocess> && rm -f /tmp/myprocess.pid

Of course, it would be even better if ‘myprocess’ actually wrote a PID file itself so you wouldn’t have to manage it from within cron.  If ‘myprocess’ is a shell script here’s how you do that:

#!/bin/bash
[ ! -f /tmp/myprocess.pid ] && echo $$ > /tmp/myprocess.pid
<your code goes here>
rm -f /tmp/myprocess.pid

Of course, if your script is going that far you might as well go all the way:

#!/bin/bash
if [ -f /tmp/myprocess.pid ]; then
    echo "Not running since /tmp/myprocess.pid exists"
    exit 1
fi
echo $$ > /tmp/myprocess.pid
<your code goes here>
rm -f /tmp/myprocess.pid

How to use SSL with the Python MySQLdb module

Posted in Personal by Riskable on the February 12th, 2009

It took me forever to figure this out because I could find ZERO examples after like 20 minutes of googling and at least 10 minutes of reading the docs (I’m sorry but, “see the MySQL documentation for more details” is *FAR* too ambiguous).  Anyway, so no one has to go through what I did here’s a real example of how to use SSL with the MySQLdb Python module:

#!/usr/bin/env python

ssl_settings = {'ca': '/etc/mysql/mysql_ca.pem',
    'cert': '/etc/mysql/mysql_cert.pem',
    'key': '/etc/mysql/mysql_key.pem'
}

db=MySQLdb.connect(host="mysqlserver",
    user="myuser",
    passwd="mypassword",
    db="mydatabase",
    ssl=ssl_settings
)

server_status = db.stat() # This was another thing that was non-obvious (to me anyway)
print server_status

# Perform a standard query
c = db.cursor()
c.execute("SELECT * from some_table")
row = c.fetchone()
print row

For reference, I was only able to get the SSL connection to work if I supplied at a minimum the ‘cert’ and ‘key’ parameters.  The ‘ca’ parameter isn’t necessary but it adds an extra layer of security (at trivial cost) so you might as well use it.

The really annoying thing about SSL in the MySQLdb module is that it doesn’t report whether or not it is actually using SSL (you could set ‘ssl=”blah”‘ and it would still continue on its merry way).  If you get the ssl settings parameter wrong it will still try to connect without using SSL–sending your queries in plaintext over the network.  To prevent this from happening I highly recommend you add the REQUIRE SSL parameter to the MySQL user you’re going to be using for connections…

mysql> GRANT ALL PRIVILEGES ON mydatabase.* to username@somehost
	      -> IDENTIFIED BY "secretpass" REQUIRE SSL;

Here’s a list of all the available keywords you can use in the ssl connection parameters (taken from here):

key – the path name to the key file.
cert – the path name to the certificate file.
ca – the path name to the certificate authority file.
capath – the path name to a directory that contains trusted SSL CA certificates in pem format.
cipher – a list of allowable ciphers to use for SSL encryption

These are a few of my favorite things… About Linux desktops

Posted in Personal by Riskable on the October 15th, 2008

Hardware detection

I love how fast the hardware detection is.  In Windows when you plug in some new piece of hardware you have to wait for that “ba-doop” sound (and the driver to load).  It can take an especially annoying length of time when booting up with new hardware attached (especially a mouse).  In Linux hardware detection is nearly instantaneous.

I just plugged in a new mouse and it was recognized and working properly before I could even put my hand on it.  Also, no annoying sound.

Desktop customization

I love how I can customize everything.  If I don’t like the boot screen graphic I can change it.  If I don’t like my login screen, desktop, window decoration, or even what happens when I move the mouse over a window, I can change it in almost any way imaginable.  I can make it look and operate like Windows or a Mac or I could make it completely unique; *my* desktop.

Not only can anything and everything be customized but most of these changes don’t even require administrative privileges.  Linux puts a lot of power in the hands of users without sacrificing security.

Available software

I love how I have easy access to tens of thousands of applications for free.  Most poeple don’t know this but there’s far, far more software for Linux than there is for any other platform.  If you combined all the available software for Windows and Macs it wouldn’t even come close to what’s available for Linux.  Best of all, you don’t have to pay a cent.  Just about all of it is completely free.

Solutions are just a Google away

I have a saying, “To find a solution with Linux you merely search the Internet. To find a solution with Windows you have to search your IT budget.”  If I want to do something new with my Linux desktop all I have to do is perform a quick search and I’ll likely find a swath of easy-to-follow HOWTO articles.  In Windows when you search the Internet for solutions, nine times out of ten the only way to do what you want is to pay for some proprietary software package.

If the (Windows) product you just purchased doesn’t do everything you want you’ll likely have to purchase more software to fill the gap.  In Linux, because of the nature of open source software, adding new functionality is usually just a matter of mashing up your existing free software with some new free software.

Linux distributions are the perfect example of “mashing up” disparate free software packages to create a system that has comprehensive functionality.  Best of all, there’s hundreds of them to choose from for all sorts of generalized or specialized purposes.  You can try a few and pick the one that best meets your needs and desires.

Tip: Regular expression to match any IP address in FoxyProxy

Posted in Delusions,Ideas,Personal by Riskable on the September 17th, 2008

I’m posting this because I know someone out there will find it useful (or at the very least, a time saver).

What is FoxyProxy?

FoxyProxy is a great add-on to Firefox that lets you define multiple rule-based proxy servers.  It lets you do things like define a rule that loads all URLs through a certain proxy server except those that match a given pattern.  Rules can be wildcards (*whatever.com*) or regular expressions (https?://.*.whatever.com.*).

The problem (need an IP address regex)

I had a problem with FoxyProxy where IP addresses (e.g. 127.0.0.1, 10.0.0.1, etc) were being loaded through my work’s proxy server when they shouldn’t be using a proxy at all.  This is because I had a proxy setup with a “Match all URLs” rule along with a blacklist rule for local URLs (*.myworkintranet.com*).  What I needed was a blacklist rule that would tell FoxyProxy to load all IP addresses directly.  Specifically, I needed a regular expression that would match any IP address.

The solution (regular expression matching any IP address)

https?://[1-9][0-9]?[0-9]?.[0-9][0-9]?[0-9]?.[0-9][0-9]?[0-9]?.[0-9][0-9]?[0-9]?.*

There you have it.  I know this will also match invalid IP addresses (e.g. 999.999.999.999) but it shouldn’t matter since there’s no number-only top-level domains (i.e. .999 as opposed to say, .com).

Also, in case you were wondering FoxyProxy uses the Javascript regular expression format.

Other regular expressions you might find useful

Same thing but for FTP URLs:

ftp://[1-9][0-9]?[0-9]?.[0-9][0-9]?[0-9]?.[0-9][0-9]?[0-9]?.[0-9][0-9]?[0-9]?.*

Match reserved (non-Internet) IP addresses (i.e. 127.X.X.X, 10.X.X.X, 192.168.X.X, and 172.16-31.X.X):

https?://(127|10|172|192)\.(1[6-9]|2[0-9]|3[01])\.[0-9][0-9]?[0-9]?\.[0-9][0-9]?[0-9]?.*

The Myth of “Business as Usual”

Posted in Uncategorized by Riskable on the June 30th, 2008

There’s this idea floating around in people’s minds regarding oil that I feel compelled to dispel:  That if we just drill more oil, build more renewable/nuclear power plants, and sell more energy efficient vehicles we’ll be able to go back to Business as Usual (BAU).  It is a myth.  We’ve reached Peak Oil.  All that stuff, if done 10-30 years ago could have made a difference but now it is too late.

As a nation (the USA for foreign readers) we need to stop looking for scapegoats and place the blame where it belongs: US.  Speculators are not the cause of high oil prices.  The oil companies/countries are not consipiring to make our lives miserable (Hint: You don’t intentionally destroy your biggest customer).  The Man is not trying to keep you down.  It’s not THEM it’s US.

WE did not prepare for Peak Oil.  WE ignored the warning signs.  WE did not want to change our lifestyles.  WE did not want to hear about all that “tree hugger BS”.  WE thought the market would save us.  WE thought (think?) the government could fix everything.  WE only paid attention to people/media that only told us what we wanted to hear.  WE ignored the gas mileage sticker when WE bought our horribly gas-inefficient vehicles.  WE blame everyone else while WE stare at the price on the pump instead of the gallons.

Still want someone to blame other than yourself?  If you must, take your pick:  The guy driving that giant SUV, the people who made that giant SUV, or the government that didn’t bother to regulate the efficiency of that giant SUV.  How about the airline industry?  How about the everything-shipped-from-far-far-away consumer marketplace (where were your shoes made?  Where were those Apples grown?)?

An economy based on the consumption of fixed resources will consume itself…  and WE have one hell of an appetite for irreplaceable fossil energy.

My IT Best Practices

Posted in Uncategorized by Riskable on the June 24th, 2008

We’ve all heard the term, “Best Practices” but what they entail tends to vary from person to person.  Especially in the realm of Information Technology (IT).  I’ve been involved in IT for a while now and I’ve decided to share a few of my own, “Best Practices”:

  1. Non-technical people should never be allowed to make technical decisions.
  2. Never buy anything from a vendor that doesn’t offer their product documentation for free to the public.
  3. Before you solicit bids or start looking for an off-the-shelf solution always ask your existing IT staff what it would cost in time and resources to DIY.
  4. The only ‘investment’ you can make in Information Technology is hiring or training technical workers. All else is just expense.
  5. Big IT mistake: Taking market market research into consideration when making IT decisions.
    Bigger IT mistake: Making decisions and then using market research to justify them.
    Market research is nothing more than documented hearsay.
  6. To solve problems with proprietary software you have to spend time and money.  To solve problems with free software you only have to spend time.
  7. Making things easier for management is usually the opposite of making things easier for workers.  Management would do well to remember this when they want improved productivity.
  8. If you use a trouble ticket system as a blame thrower you will get burned.
  9. Having someone to blame is not an effective IT strategy.
  10. Migration is always an option.
  11. Just because something works doesn’t mean it is the best solution.
  12. Quality of implementation is always more important than quality of software.

I will add more as time goes on.

CNN Bullshit: “Some other experts” think the job market is strong? Oh really!?

Posted in Uncategorized by Riskable on the April 4th, 2008

I was reading an article on CNN.com saying that in March we lost 80,000 jobs (according to the Labor Department) when I came across the following text right in the middle of the story:

But some other experts said that while job losses are climbing, the job market is still relatively strong by historic standards, although even they expressed concerns about growing weakness.

Note that this was placed directly after the following:

“The job market is a lagging indicator,” said Arpitha Bykere, economic analyst at RGE Monitor.com. “We can expect the picture to get gloomier. We won’t see a positive picture any time soon, even if the economy recovers.”

Notice how CNN actually quoted someone? As in, a real person—with a name attached. Then they followed it up with “some other experts”. Otherwise known in mass media circles as bullshit.

You know CNN, “some other experts” think you’ve sunk to a whole new low of propaganda. Even if your intentions are good (trying to prevent market panic perhaps?) your methods are unacceptable and inappropriate. If there’s cause for panic there’s no reason not to tell it like it is! Yelling “fire!” in a movie theatre can save lives!

Note: I’ve saved the page text in case CNN decides to do some stealth post-publish editing.

The American Delusion – Diminishing supply will reduce demand

Posted in Uncategorized by Riskable on the March 15th, 2008

If you ask someone filling up their gas tank, “At what point will you stop going to the gas station to fill up?” they will respond in a confused manner, “What do you mean? No matter how much you cut back you still have to get gas sooner or later.”  Yet most Americans believe that as oil supplies diminish the price of gas will reach a point where demand will decrease.  Which among us will be the first to make the sacrifice of not commuting to work?  Which trucking and shipping companies will stop delivering as much and as fast as they can?  Which oil-fired power plants will shut down to save money?

The truth is that every oil-saving measure you can think of can only conserve so much oil.  No matter what the price, people and businesses will pay it as long as they can make more money out of it than they put in.  That is capitalism!  So what happens then when the supply of oil isn’t enough to meet demand?  When there’s not enough gas at the station for all the customers?  Rationing won’t help much if supplies will decrease forevermore.

This scenario is going on right now as I type this.  The available supply of oil has been down 13-20 million barrels of oil for the past several weeks compared with this time last year.  We’re quickly approaching the point where “how much we’ve got” is less than “how much we expect” or even “how much we need”.  Even as our economy enters a recession and gas prices go up the demand for oil has not decreased an equivalent amount.

No one knows for sure how long we can sustain our current lifestyles while oil supplies diminish.  I fear that the answer is, “not very long at all.”

Is today the beginning of the permanent oil crisis?

Posted in Uncategorized by Riskable on the March 5th, 2008

Oil hit $104/barrel today. This comes right after OPEC met to talk their usual talk about how much oil they want to pump out of the ground. OPEC is not going to increase production and they claim it is because “supplies are sufficient”. They’re blaming “speculators” for driving up the cost.

What a load of crap

I’m going to call their bluff: OPEC isn’t producing more oil because they can’t. World oil production has peaked. Don’t just take my word for it, have a look at the US oil inventories. We’re presently humming along at a 14-day supply of oil (don’t believe the “Days of Supply” graph on the EIA website—do the math yourself: 14 days!).

Last week we were down 20.5 million barrels/day from this time last year. This week we’re down “only” 18.5 million barrels/day… HOWEVER, we just had a major refinery go up in flames so you’d expect oil inventories to be UP and gas inventories to go DOWN. Essentially, that refinery fire is making the oil inventories look better than they would be otherwise.

Even President Bush (long time oil industry apologist) had this to say (from the NYT article):

As a sign of growing impatience with oil producers, President Bush said on Tuesday that it would be a “mistake” for OPEC not to increase supplies. As the oil group was meeting in Vienna, the president repeated his assault on Wednesday, saying it was “obvious” that demand was stripping supplies, and pushing up prices.

This could very well be the day that historians determine as the start of peak oil economic collapse.

Page 1 of 2112345...Last »