Geekery

After receiving an update today to push my Chrome version to 5.0.322.2 dev, I noticed that I could no longer log in to the web site that I had open when the update was done. I happened to be developing a website when I received notification for the update so, like always, I just continued developing and let the new version of Chrome install in the background.

When it was finished, I closed all my browser windows, re-opened Chrome and navigated back to the site I had open that I was working on. Try as I might, I couldn’t seem to get my $_SESSION information working for PHP. This was first noticeable when I tried to log in and it didn’t appear to work correctly. I tried another web site and it worked fine. I tried another browser on my development site and that worked fine too. I decided to go ahead and use the session_id() function and noticed that I was getting a new session ID with every page load.

I finally did some digging around and realized Chrome wasn’t setting any cookies for the domain. I tried other websites and they all worked fine. For some reason, the site I had open when the browser upgraded just wasn’t creating cookies for me.

I checked my configuration settings. I cleared all my personal information. In the “Under the Hood” menu in the Google Chrome options, I set my cookies to “Accept All” and still, no luck. Cookies were working just fine everywhere else except for where I needed to do work.

Frustrated, I decided to click the “Reset to defaults” button and it worked!

So, if you’re having troubles getting Chrome to create cookies for just one domain, try resetting defaults in your “Under the Hood” menu and see if that works for you.

I hope this helps others experiencing this annoying problem.

If you liked this post, then please consider subscribing to my feed.

Life

While browsing around the Internet, I came upon a rather startling series of videos. These videos were the first, in quite a long time, where I had to stop part way through and take a break. They show the absolutely staggering poverty and conditions that exist within the country of Liberia.

BE WARNED that these videos are not for the faint of heart in any stretch of the imagination. However, if you are willing to experience what exists in our world, then these videos will challenge you. I bring you, The Vice Guide to Liberia.

Part I:

Part II:

Part III:

Part IV:

Part V:

Part VI:

Part VII:

Part VIII:

I don’t know if the other parts haven’t been published, or what, but right now, I could not find the links to part 7 and 8… but damn, this is some captivating reporting. The remaining episodes have been posted as they have been released.

If you liked this post, then please, consider subscribing to my feed.

Geekery

Working with the random() function in PostgreSQL can be a bit tricky if you’re trying to populate a table.

The random() function in PostgreSQL will return a number between 0 and 1 like so:

SELECT RANDOM();
      random       
-------------------
 0.115072432027698
(1 ROW)

If you’re trying to get a whole number from random(), you can use some multiplication and the round() function to let random() work for you. Say you wanted to get a random number from 0-100:

SELECT ROUND(RANDOM() * 100);
 round 
-------
    22
(1 ROW)

For the project I’m working on, we wanted to pre-populate some birthdays with random dates. I tried using a combination of the datetime functions with an interval and random() and couldn’t quite get there. Searching around on Google didn’t provide too many useful results so I turned to the wonderful folks in the #postgresql chat at irc.freednode.net. Using a combination of the above and the suggestions from the chat room, I was able to come up with a query that did what I wanted:

SELECT NOW() - '1 year'::INTERVAL * ROUND(RANDOM() * 100);
           ?COLUMN?           
------------------------------
 1987-01-20 11:10:34.26494-07
(1 ROW)

That means we could easily update our tables for people with random birthdays with a single update query:

UPDATE TABLE_NAME SET birthday = NOW() - '1 year'::INTERVAL * ROUND(RANDOM() * 100);

Hopefully you found this post useful. If you did, please consider subscribing to my feed.