Pare down your read-it-later list by going old school

Do you follow too many subjects across the Interwebs? How about subscribe to a firehose like Hacker News (the RSS feed spouts 83.3 items per day)? If you answered yes to either of those questions, then you probably have an extensive collection of things you want to “read later”.

If you take a look at my Google Reader trends above, you can see that I read a lot of RSS items daily. I rarely click “Mark all as read”, so that ~163 items/day statistic is quite accurate. However, I often only have time to browse the titles and star the items that I promise myself I’ll read later. You guessed it: my number of starred items is insane (131 just from the last 30 days) and I have no hope of ever reading them all.

In the end, there’s many more items that I think I’ll read later than I actually do. So starring items ends up being a waste of my time (I tell myself reading this much tech news isn’t a waste of time, though!).

To combat this, I’ve added a layer of work between myself and my read-it-later list. Now, instead of starring an interesting item (just an easy tap on the “S” key), I make myself copy and paste the link into a text file. This extra work, although slight, causes me to think twice and keeps me from saving items that I know will be sitting at the bottom of my read-it-later collection for months. So save yourself some time (or even guilt!) and protect your read-it-later stash with this little trick.

Making a simple query to a MySQL database via PHP

To make a query to a MySQL database using PHP, you will first create the PHP script. I’m assuming that you have created your database and have the connection information.

/*declare your connection information*/
$host = 'yourHost';
$databaseUser = 'yourUser';
$databasePassword = 'yourPassword';
$databaseName = 'yourDatabase';

/*Connect to the host and select the database*/
mysql_connect($host,$databaseUser,$databasePassword);
@mysql_select_db($databaseName) or die( "Unable to select database");

/*create a query. here we will select all entries from the posts table*/
$query = "SELECT * FROM `posts`";

/*execute the query and assign the result to a variable*/
$result =  mysql_query($query);

/*grab the number of rows returned by the query*/
$rowCount=mysql_numrows($result);

/*close the connection*/
mysql_close();

/*the following while loop goes through all the rows of the result 
and outputs the 'title' of each entry of the posts table*/

echo "<html>";
$i=0;
while ($i < $rowCount) {

    $title=mysql_result($result, $i, "title");

    echo "$title <br>";
	
    $i++;
}
echo "</html>";

Then you can take this script and create a webpage where the title to each entry will be outputted in HTML.

Receive an alert when a terminal command completes

It’s pretty common to issue commands in a Linux terminal that take a little while to complete. Instead of sitting and waiting for the program or process to complete, you can issue the alert command so you know when it completes.

For example, if you issue the command sleep 5; alert, your terminal will run the sleep program for 5 seconds and then you will receive a pop up alert on your desktop. This lets you know that the process has finished. Here it is in action:

This is great for long-running dd commands or installation of new programs that take a while. As an aside, I did have to install libnotify-bin for this to work properly.

Wake Ubuntu with USB mouse or keyboard

I tend to suspend my Ubuntu machine quite a bit. A three second wakeup is a lot faster than a 30 second boot and I can keep my windows open while the machine is asleep without using much more power than a fully shut down computer.

Instead of having to reach for a power button on my computer’s case, I have set up Ubuntu to come out of suspend mode when I press any key on my keyboard.

After some research, I found I could issue this command:

sudo sh -c 'echo "USBE" > /proc/acpi/wakeup'

I have seen some people use USB0 instead of USB0, but since it was not listed under wakeup devices by acpi, I used USBE. You can judge for yourself as to which you should use.

There you have it. Your machine should wake up when you press a key, given your keyboard is USB.

Loading images from a directory with PHP

This is how you can use PHP to display all of the images in a directory (folder) where the PHP page lives.

<?php
$files = glob("*.jpg");
$fileCount = count($files);
for ($i = ($fileCount-1); $i >= 0; $i--) {
  echo '<img src="' . $files[$i] . '"><br />';
}
?>


Note: this will only display images with the extension .jpg. You will have to modify it to display other image types (png, gif, etc.).