Category Archive : Linux

Raspberry Pi Light Project

import urllib.request
import datetime
import RPi.GPIO as GPIO
import time
from datetime import timezone

GPIO.setup(23, GPIO.OUT)

‘https://www.theDomain/theFolder/fileToRead.txt’, “localFile.txt”)

with open(‘localFile.txt’, ‘r’) as cf:
mostCurrent = cf.readline()

lastHit = datetime.datetime.strptime(
mostCurrent.rstrip().upper(), “%m-%d-%Y %H:%M:%S %Z”)

print(‘Last Hit:’)

current = # + datetime.timedelta(hours=-5)

print(‘Current Time:’)

elapsedTime = current – lastHit
timeDifference = divmod(elapsedTime.total_seconds(), 60)


(minElapse, secElapse) = timeDifference

if minElapse < 1:
   print(‘Relay On’)
   GPIO.output(23, GPIO.HIGH)
   print(‘Relay Off’)
   GPIO.output(23, GPIO.LOW)

   <title>Well Hello There</title>


        $file = "LocalFile.txt";
        $current = file_get_contents($file);
        $current = date('m-d-Y H:i:s e') . "\n" . $current;
        file_put_contents($file, $current);

    function getLines($file)
      $f = fopen($file, 'rb');
      $lines = 0;

      while (!feof($f)) {
        $lines += substr_count(fread($f, 8192), "\n");

      return $lines;
  <p>Hi there....</p>
  <p>You are visiter number <?php echo getLines($file) ?></p>

WordPress Hack Fix Steps

I had fun fixing a small pile of wordpress sites that had been hacked today. I could not find any useful how to guides on how to fix this, so I thought to post it here for the poor soul that also needs to fix this hack.

Site would show near the bottom of each page:

Not Found

The requested URL /spam/getlinks.php was not found on this server.

You can simply edit /wp-includes/general-template.php and comment out or remove the line in the function called get-footer that references file.

You should also remove or rename the file called in the js folder. ( /js/ )

You can find common hacks by using the command grep -r base64_decode in the main folder of your wordpress directory. It will show a list of encoded php code that could be used for injection during runtime. Be careful that you do not delete/remove good code that actually uses decoding.

Death by Hoarding

I read this article the other day and was completely disgusted.  I don’t know how anyone could live a life with that much stuff.  After I read it, I cleaned off my desk, and hoped I didn’t see any legs sticking out of some paperwork.

Apache Benchmark

I found this nice little utility to benchmark apache.  Here is my example:

ab -c 10 -n 100

It will run 100 tests on the domain, and return the results.

Replace Command

Here is a simple way to replace text in a file, or groups of files.

Add some text to a file:

aaron@myexample:~/test$ echo “Hello World”  > somefile.txt

View the contents of the file:

aaron@myexample:~/test$ cat somefile.txt

Hello World

Replace World => Dave

aaron@myexample:~/test$ replace World Dave < somefile.txt > someotherfile.txt

View the new file:

aaron@myexample:~/test$ cat someotherfile.txt
Hello Dave

You have to have mysql-server installed to get the command line tool.

Minimalist Web Server

As part of our quest to minimize our stuff, I’ve retired our web server, and will be saving just the good parts from it.  I obtained a old Dell laptop, and have loaded the Debian base install and am running my few web sites from it.

I think this will reduce my power bills a few bucks a month too.  If not at least it will be much quieter in the office.   I need to figure out a better backup solution, but I think I’ll be happy with the change.


Worst Mouse Ever

Here is a new mouse for Open-Office software, this has to be the worst idea ever.

Firefox Usage Still Climbing

Firefox usage world wide is now at 24.07%, and has now passed IE6, the worst browser ever.

Read more about it here.

Ubuntu Upgrade

Per Clark’s request, here are my thoughts on the new Ubuntu OS.

As always the new splash screen for boot up and shut down have been reworked, and look better than the previous version.  The default theme for Gnome is nice, with all new icons and images for shortcuts.  Menu is nearly unchanged, seems only the games menu has been altered, all the logical games are grouped in a sub menu.

Firefox is at version 3.5, which is nice, as Ubuntu/Debian are always so dang slow getting the most current version running on software.  New firefox has the ‘+’ feature for making new tabs, something I got used to with windows version and hated not having.

Ubuntu One is the new online file share/backup/storage.  You have to make an account with Ubuntu to get in, and it appears to be 2 gigs of room.  I had an account already, and didn’t know it, I must of had it from reporting a bug sometime in the past.  I moved some files over with both the web UI, and the built in folder for nautilus.  Both worked with no problems, and only took a few seconds for the file to transfer.  I am not a big fan of this kind of online storage, it is a really bad idea.   What if Ubuntu lost my junk?  And I know the files have little to no security, and get looked through all the time.  I host my own system, over SSL and feel much better about that.

Upgrade took ~2 hours, mostly all downloading from the overworked Ubuntu servers.  I read somewhere that there is a torrent type upgrade, and I wished I had explored that option for the upgrade.  I bet it is much quicker.

Only other change that interests me is the new Empathy IM client, that is replacing Pidgin.  I’ll have to upgrade the work computer before letting everyone know how good it is.

I have a raid 1 storage box at home, for file storage and sharing.  It has gone from the first version of Ubuntu all the way to 9.04.  I’ll have to upgrade it to 9.10 when I get a chance.  I think this will be the 9th OS upgrade, with no reinstall needed, something MS cannot do.  🙂

Email Hoax

Since I have a minor in CS,  work in computer technology, and am a nerd, I seem to get the dreaded chore of helping people with computers.  All part of the fun, is being the recipient of all those crappy emails from people.  To define crappy, I should explain that the majority of these are email hoaxes.  Emails about Walmart perfume, famous paintings and stupid email chains.

Before you forward another email to anyone, you really should check out these websites to see if they are hoaxes:

I’ve never let anyone email me too long before pointing out these hoax websites.  If they continue they get one last warning, then if there is another violation, they get the world famous “Don’t email me again” email.  It is always a good idea to let them know if they want to send pictures, or have original stuff that you’ll love to receive it.

The only thing worse than hoax emails, are the stupid political / abortion / immigration /  anti-Muslim / hatefilled / closeminded emails.  I cannot stand closed minded people, which means I’m closed minded about them, therefore I can’t stand myself.  Anyways, I educate myself with the facts for which way I vote, I don’t plan on having an abortion anytime soon, I don’t fear other races or their culture, I don’t hate any religion, and I have time to formulate my own opinion.  So no need to send me pre-processed opinion, the emails have little fact and usually only appeal to emotion.  It is too bad that people still spread these types of emails, as it does not help resolve any of the topics they discuss, usually they only anger people further, indoctronate the simple minded, and create more hatred about topics that need a solution better than angery people.

Simple Download Setup

Here is some simple steps to give you a feature to share files with others.  This example is for Debian setup, but can easily be ported over for other linux flavors.

Setup folder in your home directory:

mkdir /home/yourname/filedownloads

add index.php file to it:  ( from here )

$filepath = “/home/yourname/filedownloads/”;
$dir_handle = @opendir($path) or die(“Unable to open your  $filepath”);
while ($file = readdir($dir_handle))

if($file == “.” || $file == “..” || $file == “index.php” )
echo “<a href=\”$file\”>$file</a><br />”;

append to apache setup file at /etc/apache2/sites-available/default

#  public file download
<VirtualHost *:80>
DocumentRoot /home/yourname/filedownloads

Restart apache daemon

/etc/init.d/apache restart

Everything you put inside the folder /home/yourname/filedownloads will now show up as a link on the web under