Go to Date WordPress Widget

This is the widget code to have a Go to Date widget in WordPress. It requires the correct permalink structure, but it is easy to paste into a text widget and it works nicely.

<script type="text/javascript">

function gotodate() {
  var baseurl = "http://example.com/index.php/"
  
  var y = document.getElementById("year").value;
  var m = document.getElementById("month").value;
  var d = document.getElementById("day").value;
  //debug alert(y + m + d);
  
  var newloc = baseurl + y + "/" + m + "/" + d
  window.location = newloc
}



<form>
  <table>
    <tr>
      <td>Year:</td>
      <td>Month:</td>
      <td>Day:</td>
      <td> </td>
    </tr>
    <tr>
      <td><input type="text" id="year" size="4" maxlength="4" /></td>
      <td><input type="text" id="month" size="2" maxlength="2" /></td>
      <td><input type="text" id="day" size="2" maxlength="2" /></td>
      <td><input type="button" value="Go" onclick="javascript:gotodate();" /></td>
    </tr>
</table>
</form>

Backdrop in Python

#!/usr/bin/python

import os, sys, random, imghdr

# This is a little program I call via cron to change my desktop every
# few minutes.  With no arguments it goes to my directory of backdrop
# images and picks a valid image at random.  If I specify a path and a
# file the program will put it up as the display.

# I don't want to fill up my inbox with emails from cron telling me that
# X isn't running, so I check first.
xisrunning = os.popen("pidof /usr/bin/X11/X").read()

def changebackdrop():
    # The below command works for transparent Eterm or Urxvt terminals,
    # populating their backgrounds with the image they occlude.  xli or
    # xsetroot can be called, but they don't work as desired for
    # transparent terminals.
    command = "/usr/bin/Esetroot"
    # If I was logging into X remotely, this would change.
    commandargs = " -display :0.0 "

    # This is where my backdrops live
    picdir = "/home/willyyam/misc/bmps/"

    if sys.argv[1:]:
        doit = command + commandargs + sys.argv[1]
        os.popen(doit, 'r')
    else:
        files = os.listdir(picdir)
        os.chdir(picdir)
        pics = []
        for file in files:
            # This is a test for valid images - it includes rgb files,
            # which are not supported by my image software, but the
            # error thrown is not terrible - it knows what it can and
            # cannot run.
            if imghdr.what(file):
                pics.append(file)

        randpic = random.choice(pics)
        doit = command + commandargs + picdir + randpic
        os.popen(doit, 'r')

if xisrunning:
    changebackdrop()
else:
    exit

# Copyright 2005 William Witteman

Randomized Backdrops 2.0

#!/usr/bin/perl -w

# This little program sets my background image
# randomly in blackbox (and now openbox).
# It's called when I startx.

$isxrunning = `ps -C startx | grep "startx"`;

if ($isxrunning =~ "startx") {
    changebackdrop();
} else {
    exit;
}

sub changebackdrop {
    if (!defined $ARGV[0]) {
        $backdrop_directory = "/home/willyyam/misc/bmps/";
        # Set this to your backdrop files directory.

        opendir(BD, "$backdrop_directory") or die;
        # Normally we'd report errors, but since we will be
        # running this via script and discarding the STDOUT
        # that it generates, that would be a waste of time.

        @backdrops = readdir(BD);
        # Grab the contents of the backdrop directory.

        @spordkcab = reverse(@backdrops);
        pop(@spordkcab);
        pop(@spordkcab);
        # The first two entries readdir() finds are
        # . and  ..  We don't want to hand these
        # entries to bsetbg, so I reverse the array
        # and do away with them.  There is a smooth,
        # tidy way to do this.  I don't care :-)

        $randpic = $spordkcab[ rand @spordkcab];
        $randpic = $backdrop_directory . $randpic;
        `/usr/bin/Esetroot -display :0.0 $randpic`;
        #`/usr/bin/X11/xli -display :0.0 -onroot $randpic > /dev/null &`;

        exit;
    } else {
        # If backdrop is called with an argument, use the argument
        # as the backdrop.
        `/usr/bin/Esetroot -display :0.0 $ARGV[0]`;
        #`/usr/bin/X11/xli -display :0.0 -onroot $ARGV[0] > /dev/null &`;
        exit;
    }
}

# William O'Higgins yam@nerd.cx