It happens from time to time that I’d like to backup files to a USB drive.  Being old school, I like to use batch files to achieve this.  Now provided your PC runs a reasonably new version of Windows where robocopy is included by default, this little backup script works reasonably well.

Simply copy this file to the USB drive, and double click it when you’d like to backup your critical files.  Of course, as always you need to adjust the individual parameters in the script to suit your own flavor.

 

@echo off
:: == find the current path of the USB drive
set ME=%~d0%~p0

:: == what would I like to backup
set SOURCE=%USERPROFILE%
:: == where am I backing it up to
set TARGET=%ME%backup
 
echo SOURCE = %SOURCE%
echo TARGET = %TARGET%

:: == Write the date and time.  This is useful to know when the backup was last taken
time /t > %ME%lastbackup.txt
date /t >> %ME%lastbackup.txt

:: == by design, I'm disabling the wait and retry... I'd rather have the backup finish with most of the files, than get stuck on one file.
robocopy "%SOURCE%" "%TARGET%" /mir /w:0 /r:0

I’ve been back in South Africa now for 2 weeks (with one more week to go).  As always, the initial days are filled with nostalgia, as I see my family again.  Thoughts enter my mind on how I can now afford a property in South Africa, paying it with Australian dollars, but then reality sets in.

The country is in much better shape than it was 10 years ago, but you just look around, and then the reality becomes clear.  People are not happy.  There’s a level of depression and “fighting for your place” that exists.  Traffic in Johannesburg is horrible.  The homes (town houses) are tiny.  Why would I ever want to retire here?  The only logical reason would be the strong AUD against the ZAR, but with money aside, there is really no other reason.

There is still a lot of poverty in this country.  There are numerous beggars on the streets (standing in the middle of the road), sometimes, sun-roasted parents with their children.  As heartbreaking as it may seem, giving money is not a solution.  There is no clear indication if the current presidency has any inclination to correct the current levels of corruption, or even improve the current levels of poverty.

The ZAR is much weaker than before.  It is a bit disturbing to see shampoo being sold for R90.  When I convert to AUD, it is not that bad.  As a foreigner visiting, the ZAR is ok.  For the locals earning ZAR, it may be a different story.

For now, people are still driving new cars, and for the most part the country does appear to be surviving.  Let’s see what the rest of the week will bring.

As it happens from time to time, you may need to look up some data from within an Excel file.  In this case, I have a 2 dimensional data set, and I need to pick a value from it.  In this example, I’m interested in the value of 22 for Women in Asia.

excel1

 

Now you can be clever and say : Oh, that’s easy!  Just enter =Sheet1!C3 and you’re all set.  Great… I got 22, but if I decide to add another column, or add a few rows, that falls down.

To overcome this I’ve developed this simple little formula.

=INDIRECT(ADDRESS(MATCH(“Women“,Sheet1!A:A,0),MATCH(“Asia“,Sheet1!1:1,0),1,1,”Sheet1“))

You can work through the statement, and it’s really simple and elegant in it’s use.

  • The first MATCH command looks for the location of the word Women in column A from the sheet Sheet1.
  • The second MATCH command looks for the location of the word Asia in row 1 from the sheet Sheet1.
  • The ADDRESS command then builds the reference to the cell for Sheet1.
  • The INDIRECT command then retrieves the result from that address.

When copying this in your own spreadsheet, you will need to :-

  1. Adjust the word “Sheet1″ to the sheet name where your data is stored.
  2. Adjust A:A to the column where the left hand titles are stored.
  3. Adjust 1:1 to the row where the top titles are stored.
  4. Adjust the words Asia & Women to the terms you’re referencing in either cell.

Since Linux made it’s appearance on the IT scene many years ago, the battle has been raging between the Windows and the Linux fanboys.  And I will admit that I am a Linux fanboy (sorry Ray!!)

I like Linux, I really do.  As a development platform (yeah, I’m the geek that codes in vi) doing development in Perl for web-based application with mySQL, Linux is great.  I love the power you get from the command-line where you can pipe anything to anything.  It is simply a level of computing freedom that you can not explain to a Windows user.

But now something has happened..  There are some applications that just do not work on Linux.  OpenOffice is goodish, but it is no Microsoft Office.  I use Excel everyday at work, and I love it, but sadly calc just does not have the same grunt.  The ribbon menu from Office also does not transfer to OpenOffice, so transferring between Microsoft Office and OpenOffice is painful.

I think my next big gripe is mounting disks.  When you use Ubuntu Desktop, a lot of the stuff just kind-of works.  Cool, but Ubuntu Desktop is bloated.  Canonical loaded every piece of software imaginable onto that one little CD, making it slow and clunky.  I don’t want all that junk, I load what I need, so I install Ubuntu Server (bare bones), and install icewm on top for some of my gui apps, like Google Chrome, vlc and so on.  But when I want to mount a drive letter to a server, I need to enter the password again.  So I do miss some basic kerberos authentication from the Linux command line back to my Windows boxes.  (Maybe there’s a fancy way to setup the /etc/fstab file with a samba file credentials file, but that defeats the point!  It should use my current login !)

And then there’s bitlocker… A great encryption mechanism for Windows, but sadly, not so portable to Linux.  Yes I know there are fuse drivers, but lets face it — it doesn’t work.  I can read bitlocker file systems, but I can’t write to them.

So sadly I find my self putting my Windows drive into my laptop more often than my Linux drive, and it is only a matter of days before I won’t be putting the Linux disk back in anymore.  I will still use Linux for my hosting platform, but as a personal desktop operating system, maybe not so much.

I wanted an easy way to get my chatbot to interact with the world through text-to-speech.  There are a number of built-in TTS options on many operating systems.  I searched around, and I mashed some code together and created a speech JavaScript library that can be called easily within any web application.

See the library in action here.

I was quite interested by the recent cloud photo leakage scandal.  What was not so unsurprising was the total lack of understanding in what really happened.  In various outlets, many are asking why someone would take private photos of themselves.  Others are saying you shouldn’t trust the cloud.  While I do empathise with Miss Lawrence and the others who had their privacy invaded, I do believe there is a general misunderstanding of what really went wrong. Continue reading

#!/usr/bin/perl
 
use strict;
use WWW::Mechanize;
use HTTP::Cookies;
use JSON;
 
my $URL = "http://localhost/chatbot/rivescript.pl";		# == the URL of the RiveScript chat bot
my $MSG = $ARGV[0];						# == the message to pass to the bot
 
# == setup the json interface
my $json = JSON->new->utf8->pretty;
 
# == setup the web interface, with a permanent cookie jar
my $mech = WWW::Mechanize->new( 
     cookie_jar => HTTP::Cookies->new( file => "cookies.txt" , autosave => 1) 
     );
 
# == post a message to the bot
$mech->post($URL,{ message => $MSG });
 
# == decode the json output
my $vars = $json->decode($mech->content);
 
# == display the reply
print $vars->{reply} . "\n";

Within chatbots I believe there should be a core set of knowledge files, call it an operating system, for lack of a better term.  I call it BotOS, which essentially is common knowledge a bot needs to survive.  What I mean by that, is that some things a bot should just know, regardless of it’s personality or purpose.

These are (but not limited to) :

  • A list of substitutions (if I say “what’s”, you know I meant “what is”)
  • A list of person substitutions (if I say “I am” you say “you are”)
  • A list of common spelling mistakes (If I say “becuas”, you know I meant “because”)
  • A list of common redirections (if I say “Where is your house”, you know I meant “Where do you live”)
  • A list of arrays (grouping pork, beef and lamb as meat)

To promote cross collaboration, I’ve decided to host the data file on Google Docs.  Every night, a dump is taken from the file, and converted into an equivalent A.I. text file.  Currently only RiveScript is fully supported, and partial support for AIML.

Update – The Google Docs idea is not working.  I’ll work on something like a Wiki interface.  For now, I’ll maintain the data files.

The resulting files could (in theory) be placed into the same directory as your bot, and start to enhance it’s understanding with the built-in redirection, and also help with the common spelling issues.  However as we’re just starting out, there’s still some work to be done for the BotOS to become a real game changer.

If you would like to contribute, email me with the data you’d like to add in, and I’ll be more than happy to paste it in.  If you’d like to be an active participant, I’ll be more than happy to share the document with you, provided you’ll abide by playing nice, and work towards the spirit of collaborating and improving chatbots overall.

And of course, if you have your own bot language that I have not covered yet, or you find a mistake in some of the code, let me know.  I’d be more than happy to adjust the code to cater for that requirement.

Data files

These files are updated from time to time.  All (except personality.rs) can be dropped in place of your existing bot, and it should enhance the bot’s ability to respond.

  • Substituions, spelling, array and reductions – begin.rs
  • A core set of chatbot rules – core.rs
  • A personality variable file to support the core rules – personality.rs
  • Some factual knowledge (still early days) – knowledge.rs

Some legal stuff

By contributing your content, you are allowing others to benefit from your work.  BotOS may be used in any bot application, be it a hobby or commercial, free or paid.  It doesn’t matter.  You just can not sell a clone of BotOS as your own.
Creative Commons License
This work is licensed under a Creative Commons Attribution 4.0 International License.

#!/usr/bin/perl
use strict;
use Win32::OLE;
 
my $v = Win32::OLE->new('SAPI.SpVoice');
$v->Speak('Hello world');
$v->Waituntildone(-1);