Selmys’ Weblog

Using Linux at Seneca College in Toronto

Archive for the ‘opensource’ Category

Postings of interest to the Open Source community.

Tackling the Android

Posted by selmys on September 20, 2011

This past summer I overcame the inertia of the couch and plowed my way into programming on Android. I wrote a little app, called “The Devil’s Dictionary”, which I published on the Android market last Friday. You can download the Android package and source code from my home server at lotuspond.ca or you can install it onto your Android phone or tablet directly from the Android market; just do a search for my name.

Google’s Android API is not difficult to learn if you already know some Java and there are lots of examples on their developer web site. I developed my app using Eclipse so that’s another hurdle you need to overcome but persistence will pay off if you work at it a little each day.

Last week I started the Android Programmers Klub (APK) for Seneca students and staff. We meet every Wednesday (fall 2011) starting at 5:10pm in room S2149. I also set up an email list, android@senecac.on.ca. Email me if you want your name added to the list or better still come to our next meeting on Wednesday.

Posted in opensource, Seneca | 5 Comments »

Remembrance Day

Posted by selmys on November 11, 2010

Today is Remembrance Day in Canada, a day to remember the sacrifices made by our citizens in current and past wars. Here at Seneca we’ll all be observing two minutes of silence at 11am. A very somber day indeed.

But this day is special in another sense and I don’t mean to be frivolous – it’s just that by nature I’m a curious fellow and often get sidetracked by sometimes very trivial ideas. Case in point, today is Remembrance Day but it’s also Seneca’s employee pay day. So why is this special? Well, it turns out that banks in Canada are closed on Remembrance Day so Seneca deposited our pay into our bank accounts yesterday – one day early. Ok, so big deal. Well for me it is a big deal because I couldn’t remember this happening in the past – and I’ve been here a long time. So I started thinking. When was the last time Remembrance Day fell on Seneca’s pay day? And when will it happen again?

It turns out that these questions can be answered with a simple BASH script. For example, to find out when this collision of dates happened in the past I wrote this script:

#!/bin/bash
echo Hit CTRL-C to quit
x=2
while :
do
 d=$(date -d"$x weeks ago")
 echo $d | grep "Thu Nov 11"
 ((x+=2))
done 

Now, when I ran this script, here’s what I got:

Hit CTRL-C to quit
Thu Nov 11 05:47:25 EST 1999
Thu Nov 11 05:47:27 EST 1976
Thu Nov 11 05:47:27 EST 1965
Thu Nov 11 05:47:28 EST 1954
Thu Nov 11 06:47:29 EWT 1943
Thu Nov 11 05:47:30 EST 1920
Thu Nov 11 05:47:31 EST 1909
Thu Nov 11 05:47:32 EST 1897
Thu Nov 11 05:47:32 LMT 1886
Thu Nov 11 05:47:33 LMT 1875
^C

So, it seems the last time our pay day fell on Remembrance Day was in 1999. Before that it happened in 1976.

Looking into the future, I ran this script:

#!/bin/bash
echo Hit CTRL-C to quit
x=2
while :
do
 d=$(date -d"$x week")
 echo $d | grep "Thu Nov 11"
 ((x+=2))
done

And the output I got was

Hit CTRL-C to quit
Thu Nov 11 06:24:00 EST 2021
Thu Nov 11 06:24:00 EST 2032
Thu Nov 11 06:24:02 EST 2055
Thu Nov 11 06:24:03 EST 2066
Thu Nov 11 06:24:03 EST 2077
Thu Nov 11 06:24:04 EST 2088
Thu Nov 11 06:24:05 EST 2100
Thu Nov 11 06:24:07 EST 2123
Thu Nov 11 06:24:07 EST 2134
^C

So the next time Remembrance Day will collide with Seneca’s pay day will be in the year 2021. Of course I’ll be retired by then … I hope.

Anyway, take some time today to reflect on the fact that the freedom we enjoy in Canada today is due in no small measure to the sacrifices of those who came before us, and when you go home tonight – practice your shell programming.

 

Posted in opensource | 1 Comment »

Tick Toc, Tick Toc

Posted by selmys on October 10, 2010

Ever try to solve a problem by looking at log file records with wrong time stamps? Ever submit a cron job only to find it crashed because it didn’t run when you expected it to?

If you’re like me, and you have, then it’s time to set up your own stratum-1 time server.

Here’s how.

Posted in opensource | Leave a Comment »

Anything C can do, BASH can do better!

Posted by selmys on April 13, 2010

Every now and then I like to take a peek at what our first year C programming students are up to. This semester I discovered that one of their assignments is to code a Sudoku puzzle. Obviously this was too tempting to resist, so here’s my solution written in BASH 4.

Posted in opensource | 8 Comments »

 
Follow

Get every new post delivered to your Inbox.