20091124

Archive backup periodicly

I'm not into typing much about such simple subjects, but i just had to share this old batch code. Turns out there is no quick and neat solution available for moving your daily backups to separate folders. So in short and without further adieu;

Backups are important. All Staes IT web servers submit backups on a regular basis to secure offsite locations. These should run automated and reliable, without much human intervention.

Problem
These backup server receives backups via FTP each day. I don't want the next day's backup to overwrite the current ones, so have to archive them in a daily manner. It also looks nice when browsing the backups folder. Keeps everything nice and organized.

I should run a script every morning to archive those nightly backups to do the job for me.

Solution
This scripts puts all files a folder named "bu_YYYYMMDD_auto". Run this daily when the ftp backups are finished.

Since i've realized this script over 7 years ago people keep asking me how to do such a thing with batch files. So i figured i should just put it on the internet for all to see. Sorry for the delay, i only recently started this blog thing.

Back then i created two batch files to suit my needs at the time. One named "bu_shift.bat" checks if files exist with the correct extention, then creates a folder using the date, and moves all files in here. It outputs the results to the console. The other file named "bu_shift_keeplog.bat" just calls the above and puts the results in a daily logfile. Files are listed below.

It assumes the incomming files are at ./bu_ftp_up/*.gz and you could easily change that yourself.

Also keep in mind better solutions exist. This one will work out of the box and simply does its job - thats the only reason i present it here.

bu_shift.bat
@echo off

REM Run this file as a cronjob, some time after the FTP has delivered a backup.
REM All folders are appended with _auto to easily distinguish them from manual backups.

echo.
echo ****************************************************
echo * Start backup shift:
echo.
if not exist ".\bu_ftp_up\*.gz" GOTO NoFiles


for /F "tokens=2-4 delims=/- " %%A in ('date/T') do set var=%%C%%B%%A

echo * Creating folder bu_%var%_auto:
md "bu_%var%_auto"
echo.
echo * Moving files to folder:
move ".\bu_ftp_up\*.*" ".\bu_%var%_auto\"
echo.
GOTO End


:NoFiles
echo * Stopped: found no files in "bu_ftp_up".
echo.


:End
echo * End of batch
echo ****************************************************
echo.
Above neatly outputs results in the console.
When running this as a cronjob use below file to log this to aptly named files.

bu_shift_keeplog.bat
@echo off
for /F "tokens=2-4 delims=/- " %%A in ('date/T') do set logd=%%C%%B

set logfile=bu_shift_log_%logd%.txt

echo. >> %logfile%
echo bu_shift_keeplog.bat op %date%, om %time% >> %logfile%
.\bu_shift.bat >> %logfile%
echo. >> %logfile%
In Windows you can add this file as a cronjob via "Task Scheduler". This code has been in use for over five years on various Windows Server 2003 and 2008 environments, and continues to serve a purpose. Happy sharing!

PS - boy this Blogger editor is worth shit. Awfull code markup.

20091121

Human origin; robots!

I love science fiction, and one thing has stumbled me. Actually the lack of something. Not on one occasion have i seen what i´m about to elaborate on. And i´ll explain why i believe it is likely.

The closest i've ever seen this being used, is in Battlestar Galactica:
[SPOILER ALERT]
If you plan to watch Battlestar Galactica (BSG) stop reading now. What i aim at here is the vicous circle. The aliens are made by humans. These aliens retaliate and eradicate civilization, realize humans have something they don´t, emulate this, and in effect become the `new´ humans. Vicious circle ensues, the end. Oh and the story was interplanitary. This too relates to my point.

Now combine this with the Borg from Star Trek or the Replicators from Stargate:
  • The borg wants to gain perfection, and one way they do this is by assimilating everything there is to know. This often means destroying civilizations and using slaves for their greater good.
  • The replicators intended to defend their creator and in extent themselves, mostly by means of violence.

Both fictional species show similar behavior, but the Borg looks human, and the Replicators look like LEGO bricks.

My point
If you take all this, you get an entity (say some civilization, like humanity) that generates an entity (say some robots) in the quest for perfection. If this evolves enough, it wil most likely end up in a loop. Artifical humans basicly. Knowledge and evidence about this eventually gets lost (it might be still out there, don't get me wrong)

How we humans fit in
Be warned: i talk in generics, as there are a lot of variables here. Most of them don´t even matter in this context. We could stand on either side of the subject on this case. Actually, i beleive both.

In more detail
Now for some reason, assume some civilization gets to the point they figure out how to automate something. O wait, we've done that. The end result is a robot. In line of how we got so far, we (as humans) want to perfect this even more.

Assume we end up with or as (for all intents and purposes the same here) a artificial entity (or call it civilization). They will continue this trend, and seed out to the universe in the meanwhile. Some won't survive a catastrophe and crash on some meteor or planet. Dead.

Don´t get me wrong, i am fond of Darwin.
But one of the things we've seen so far is that nature has rather advanced designs. If you aren't inspired try to understand how every cell in your body has a copymachine and protein assembly line. Enough youtube video's on that subject. Also don´t forget that some cellular automation appears irreducible complex, meaning it we don´t have a model yet for how it may have evolved. There exist a ton of papers on this broad subject, but the video do a better job on explaining this.

I believe that a artificial entity ends up with what we call now bacteria, viruses and evolution all tied up with attaining the goals of said entity. Forget empathy, if it has to kill 90% of a population it will. It is a machine, it just does its job. Empathy is just some layer we humans made up in our brain chemistry to aid even better survival. All in line with the goals the machine is based on, and the rules of life itself ofcourse.

Full Circle
Imagine bacteria from the artificial entity got stranded on earth. Resume their goal. Eventually you end up with a smart entity, they make artificial perfection, this artificial perfection ends up much like we know nature today, and it is full circle.

There's much more to speculate with on this subject, but i'd rather leave you with the thought at hand. That and there´s the stuff that might put people off, its weird enough in this short form.

This train of thought should have a name. I suggest we call it Circolution, Loopolution, or something i've yet to come up with. Don't beleive evolution fits the subject at all, so suggestions are welcome.

What if? nothing... Consensus would be nice though.
If this was obvious concept long before you read this article, let me know. This will not lend itself for philosophy without diverging from the issue, nor bar talk. I feel rather alone on this subject.

Nature stems from robots?
It all seems so logical. Pun intended.

20091116

Last.FM app for Android

It really bugs me that the Last.FM app for Android is not available in the Netherlands. They should know better. There is a fix however:

So just download the apk file (fm.last.android.1.3.0.apk) at:
http://www.csmarshal.com/android/

Via:
http://www.last.fm/group/Last.fm+Android/shoutbox

Out.

20091104

Visual Studio and Resource.resx missing

To be more specific i had trouble building the Sample and Library Sources in C# from Forest Moon Productions. It concerns an API that i wanted to try out.

Errors
When opening the ArmSample project in Visual Studio 2008 Pro i was met with the following errors:
Warning 1 The custom tool 'ResXFileCodeGenerator' failed while processing the file 'Properties\Resources.resx'.
When then building in an attempt to run it anyhow it trows two errors:

Error 1 Metadata file 'C:\Documents and Settings\Staes\Desktop\InternetFiles\ForrestMoonProductions\AX12 sample and library sources in C#\AX12ArmSources\Projects\Joystick\Joystick\bin\Debug\Joystick.dll' could not be found AX12ArmSample
Error 2 Resource file "Properties\Resources.resx" cannot be found. Joystick
Warning 3 The custom tool 'ResXFileCodeGenerator' failed while processing the file 'Properties\Resources.resx'.
These files are not in the archive i downloaded. I reckoned the files got repacked and some are missing now or i use a unsuited IDE version, or i might have some misconfiguration on the Windows XP computer bursting anyway with all the installations of DirectX, DotNetFramework, runtimes, drivers, and whatnot.

Solution
Most google searches led me to irrelevant sites, and some suggested altering the .csproj files with Notepad. When i did that just more errors popped up, pulled out anything i got (even Bing.com) and was willing to  giveup, figured that a reboot might help and decided to emailed the author weither he saw the problem before.

Minutes later i tried this obvious and simple solution: removing the /Resource.resx files from the project. To be more specific those in AX12ArmSample and JoyStick sub projects. All other errors dissapeared.

Priming myself
Turns out i overlooked those files in the projectbrowser, and went searching for some deep rooted cause that didn´t exist. Its been to long since using Visual Studio, in the old days easy stuff like this didn't cost me 2 cups of caffeine to figure out. I wish i never stopped using it and should have used an easyer project to play catchup with on the IDE. (I'm trying to graph AX12 actuator outputs)

Its late. Time for a nap i guess. Oh crap .. damn caffeine!
Perhaps i´ll watch Primer again. On Android! Use the download link at Google Video while it lasts.

UPDATE 20091108:
I mailed Scott Ferguson about the missing files in his library, he fixed the download;
I added the missing files Resources.resx and Resources.Designer.cs to the Projects\Joystick\Joystick\Properties\ path in the AX12ArmSources.zip file:
http://www.forestmoon.com/Software/AX12ArmSample/AX12ArmSources.zip
Thanks for reporting the issue! Do let me know if you encounter further problems.

20091103

Daisy, Daisy

You either love or hate the movie 2001: A Space Odyssey. I recon that lovers love the `Daisy´ song by HAL, and haters couldn´t stand the low pace of the movie. Despite all differences, most might agree its more art than movie.

Even i can´t stand its low pace and am unable to watch it for more than 20 minutes. Ok to be fair; except that one time that i had to stay up at midnight, nothing else was on TV, saw it for the first time, and missed the first half hour. Good times, anyone feels like a philosopher at these hours. Either way i enjoyed watching it in 20 minute chunks whenever i felt like it.

Inspired by IBM
today i saw this article floating past (reffering to this Youtube video) where you hear a computervoice sing a song. All this IBM did in 1961. Some 6 years later it inspired its use in Stanley Kubricks' movie, and it is only now that i recognize how excelent it suits the movie plot.
"Daisy Daisy .. Give me your answer do .. I'm half crazy, all for the love of you .. "
HAL actually is communicating a message. It wants them to answer a question, and remarks that he is overprotecting (half crazy by love!) Dave. I feel stupid by only finding out now, seems i haven´t watched it thoroughly enough. Point is the computer-sung song is an excellent addition to the plot of 2001: A Space Odyssey in multiple ways.

FYI the description companying above video:
"Daisy Bell" was composed by Harry Dacre in 1892. In 1961, the IBM 7094 became the first computer to sing, singing the song Daisy Bell. Vocals were programmed by John Kelly and Carol Lockbaum and the accompaniment was programmed by Max Mathews. This performance was the inspiration for a similar scene in 2001: A Space Odyssey.
I should watch 2001 and 2010 again, and come to speak of it: Primer (2004) is a good science fiction movie. Its plot is mind boggling and intriguing. Avoid any spoilers (asides from the synopsis) if you plan to watch and enjoy it .