An experiment in colour
9/8/2009 - 18:07:56 - 2 comments - By D47
Well I decided to make some changes to my stylesheet for no good reason. I think it looks pretty good. I need a new title image though, I don't know.
 
Conky buses!
25/7/2009 - 00:23:24 - 0 comments - By D47
So to show off my new code tags I'm going to show you a script I wrote to get the upcoming bus times displayed right there on your desktop!

There are three bits of code required here, first there is the code to fetch the timetable data for the current day from your local bus service. You're unlucky if they don't provide the data in html form, although if the timetable doesn't change often you can simply create the timetable file yourself.

This is my code:
getbusses.sh:

#!/bin/bash
curl "http://jp.translink.com.au/TransLinkPublicTimetable.asp?RouteCode=301&TimetableKey=1849&Direction=inbound&TimetableVehicle=BTBus" 2>/dev/null | \
awk '/.*Doomben Station.*/{ getline; print; getline; print; getline; print; getline; print; getline; print; getline; print;}' | \
sed "s:.*<td class=\"TimetableDetails\">[ ^I]*\([0-9]*\:[0-9]*.*\)</td>.*:\1:p" -n \
    > ~/scripts/buses


That one is quite simple, it shouldn't be hard to make one up for your timetable provider.

The next piece of code is the workhorse. This one is executed every minute by conky.
nextbus.pl:

#!/usr/bin/perl
use DateTime;

my ($sec,$min,$hour,$day,$month,$yr,@rest) =   localtime(time);
my $line;
my $outputCount = 3;                        #Number of times to output (from current time)
my $previousLine;                        #Used to detect duplicates (this is commonplace practice at translink...)

open(BUSES, "<", "/home/d47/scripts/buses");

while ($line = <BUSES>) {
    if($line == $previousLine) {                #Detect duplicates
        next;
    }

    $previousLine = $line;

    if($outputCount == 0) {
        exit;
    }

    chop $line;

    my @checkTime = split(":", $line);

    my $cHour = @checkTime[0]+0;                #Hour

    if($cHour == 12) {
        $cHour = 0;
    }

    if(substr(@checkTime[1], 2, 2) eq "pm") {        #Adjust to 24Hr time
        $cHour += 12;
    }

    my $cMin = substr(@checkTime[1], 0, 2)+0;        #minute


    if($cHour < $hour) {
        next;
    }

    if($cHour == $hour && $cMin < $min) {
        next;
    }

    my $timeUntil = ($cHour - $hour) * 60 - ($min - $cMin);

    print $line, " (", $timeUntil, " mins)\n";

    $outputCount--;
}


As you can see it is rather strait forward, it cycles through each line on the "buses" file and determines if that bus is yet to come, if it is then it is printed. The program exits when $outputCount amount of buses are printed.

The third and last piece of code is the easiest. Its the code to put into your .conkyrc file, here is my whole file to show context.
~/.conkyrc:

use_xft yes
xftfont Bitstream Vera Sans Mono:style=Bold:size=8

update_interval 1
total_run_times 0
double_buffer yes
text_buffer_size 2048

own_window yes
own_window_type normal
own_window_transparent yes
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager

background yes

minimum_size 250 0
maximum_width 250

default_color cyan
draw_shades no

color0 cyan
color1 red
color2 white

border_margin 5
border_width 2

alignment top_right
gap_x 25
gap_y 35

no_buffers no
net_avg_samples 2

override_utf8_locale yes

no_buffers yes

TEXT
DATE ${hr 2}

${color0}${font StyleBats:size=16}4${font}   EST${color}${alignc 45}${color2}${font Arial Black:size=30}${time %H:%M}${font}${color}
${alignc}${time %A %d %Y}
${alignc}${time %s}

${color0}${font StyleBats:size=16}8${font}   UTC${color}${alignc 45}${color2}${font Arial Black:size=30}${utime %H:%M}${font}${color}
${alignc}${utime %A %d %Y}
${alignc}${utime %s}

SYSTEM ${hr 2}
${color0}${font StyleBats:size=16}A${font}${color}   CPU:      ${color1}${cpu cpu0}%${color} ${alignr}${color2}${cpubar cpu0 8,60}${color}
${color0}${font StyleBats:size=16}y${font}${color}   RAM:      ${color1}${memperc}% ${mem}${color} ${alignr}${color2}${membar 8,60}${color}
${color0}${font StyleBats:size=16}q${font}${color}   Uptime:   ${color1}${uptime}${color}

WEB USAGE ${hr 2}
${color0}${font StyleBats:size=16}x${font}${color}   P:        ${color1}${execi 60 awk '{print $1}' ~/scripts/currentusage} /  60GiB${color}     ${color2}${execibar 60 awk '{print ($1/63)*100}' ~/scripts/currentusage}
${color0}${font StyleBats:size=16}g${font}${color}   OP:       ${color1}${execi 60 awk '{print $2}' ~/scripts/currentusage} / 140GiB${color}     ${color2}${execibar 60 awk '{print ($2/143)*100}' ~/scripts/currentusage}${color}

BUSES ${hr 2}
${color0}${font StyleBats:size=16}B${font}${color}   Next buses into the city:
${color1}${execi 3600 ~/scripts/getbuses.sh}${execi 60 ~/scripts/nextbus\ 2.0.pl}${color}


And that's it! All I need to do now is become social and want to know when I can travel to the city to go clubbing! Oh goodie!
 
Nullam rewritten!
24/7/2009 - 22:17:35 - 2 comments - By D47
I have completely rewritten the code for nullam.net from the ground up. The site is now implemented using smarty templates, it is about a million times more efficient and comprehensible.

Its amazing what little oddities I found while reviewing the old code. Lets just say it's very evident that I am making progress in my programming proficiency.

If you come across any errors or any odd behaviour I want to know about it! Please send a brief email to d47@nullam.net or simply comment on this post.

As for functionality there is absolutely nothing new in the slightest! Enjoy it!

P.S, I love smarty templates.
 
Kill my family but don't take my anime!!!!
21/7/2009 - 21:34:42 - 2 comments - By D47
FFFUUUUUUUUUUUUUUUUUUUUUUUUUUU

It's happened again, my brand new 1tb hard-drive just died in a flurry of clicking and jerking. Why out of the four hard-drives I have does it have to be the one with all my anime on it! it was FULL of anime, 1tb of anime! One of the drives was completely empty but it had to be the full one. If someone I know dies I can shrug it off but taking my anime! I'm enraged!

Well from now on there is no question that I will be backing up everything I have. Every gigabyte I buy will be two, the cost of hard-drives to me is double what is labelled. From now my computer speaks in raid 1.

At least its under warranty =/
 
Take my mind
20/6/2009 - 19:46:19 - 8 comments - By D47
If I could give you my mind along with all its knowledge, memories and experience I would not hesitate to do so, in fact I really want to do this with you. I think that if you had my mind and your own, things would be so different and I wonder what kind of revelations you might have and what parts of my mind will be discarded as fallacy.

Would something I consider absolute fact be looked upon with doubt from the perspective of a combined mind. What kinds of conclusions would be drawn based on both sets of collective experiences seemingly occuring at once?
 

<<Older

By Dylan McGannon. Feel free to copy, use and modify anything you find here.

Valid HTML 4.01 Strict / Valid CSS!