March 2008 Archives

Really funny name of post, isn't it? It should mean something to people who understand Croatian: it's virtual computer. This fun toy begin it's existence as Orao emulator. In the process, I wrote 6502 and Z80 emulator (actually only perl xs bindings for existing cpu emulators) and implemented Orao, Galaksija and Galeb using it.

Various machines are in different stage of usability. Orao emulation is working (without tape support), Galaksija is too slow to be useful (also doesn't have tape) and Galeb doesn't have keyboard or tape support.

I would be very grateful for hardware information about those machines if you can spare some time writing them. I'm somewhat hope that source code of this emulators might serve as historic reference how this machines where constructed.

Lately, I have also found mess project, but soon after that I also noticed that I need about six times as much to implement changes in it. C is just not my language, so actually only hope for preservation of those computers is good documentation (which is something mess community is striving also).

On the other hand, currently CPU emulation library is not license compatible with GPL so I won't probably push this to CPAN any time soon but I would love to find another implementation (PowerPC anyone?) and basically create thin layer of perl code which can express different architectures.

Having written all that now it's time to show you how to compile dam thing!

svn co svn://svn.rot13.org/VRac/
cd VRac
perl Makefile.PL
make
make orao

And you will have working Orao emulator in a second. You can also try make galaksija or make galeb.


This post was originally written on 2007-09-05 when I wanted to announce this project after playing with it over the summer. Since I never finished emulation of Galaksija or Galeb, I left it in draft mode for too long. Now that first Croatian Perl Workshop is coming along I will talk about this project, so it's just fair to announce it, so you can have preview about what my lecture will be.

Danas sam na Razmjeni vještina održao maratonsko četverosatno predavanje koje je nadam se bilo donekle korisno. Nažalost, nismo stigli ući u detalje onoliko koliko bih želio, ali ako ništa drugo ponovo sam koristio pgrestraier (koji se nekako indeksira previše sporo, morati ću pogledati zašto) i još jedan zgodan projektić koji sam napisao prošle godine za studente u Zadru pg-getfeed koji je zapravo mala perl stored procedura kojim možete raditi SQL upite na RSS feedovima.

Initially created in 2006 this handy tool is best described with original commit message:

IRC bot which replace human memory

Here is a quick run-down through available features:

  • web archive with search
  • irc commands: last, grep/search, stat, poll/count
  • tags// in normal irc messages (tagcloud, filter by tag, export as RSS feed)
  • announce /me messages to Twitter (yes, lame, but that was a year ago)
  • tags are available as html links for embedding (in wikis)
  • RSS feed from messages with tags (also nice for embedding)
  • irssi log import (useful for recovery in case of failure of machine or service :-)
  • announce new messages from RSS feeds (nice for wiki changes, blog entries or commits)

It has grown quite a bit from initial vision to recall last messages on the web (and it does go through some hoops to produce nice web archive). Adding of tags allowed easy recall of interesting topics but in a way now it provides an central hub for different content connected to irc.

It's written in perl using POE and it's probably not best example of POE usage. It is also somewhat PostgreSQL specific but works well for our small comunity at #razmjenavjestina irc channel. Since I have seen some interest in it this blog post might serve as announce of it's existence.

I will probably add some documentation to it's wiki page and add real muti-channel support (most of code is in there, but web archive needs filtering by channel). If you are interested to /invite it to your channel, drop me a note.

I had a particular problem at work: we have upstream subversion repository which we access over ssh tunnel (using svn protocol) which contains two branches in which we are interested and various other stuff we don't care about (and don't want to mirror).

On other hand, we also wanted to have local copy of all changes (preserving history) and local commit messages and SVN::Web interface.

In original idea, I also wanted to keep revision numbers as-is (so I can just checkout our local version and be done), but this wasn't possible. One solution that we examined is to use Pushmi and make local copy, but we didn't want all the other changes.

Other idea was to use svndumpfilter to sync only two branches we are interested in (it will create dummy commits for revision which are outside our branches), but since branches are result of copy from parts of the tree we don't want to sync, it didn't work either.

Did I mentioned that our svn repository can access upstream only through carefully crafted ssh tunnels? Mess, right?

So, in the end, solution was hybrid:

  • make local copy of two upstream branches using svk (loosing original order of commits, even if we are commiting into same svk mirror copy at our side)
  • install post-commit hook in upstream repository which will call (over https) svk sync at our side (I would probably use SMTP to trigger that, but our machine with svn repository doesn't accept outside e-mail)
  • install local post-commit hook to send e-mail notifications

Rest of this post are instructions on how to do this. Since I learned a thing of two doing this, I hope it might be also useful for others.

First create svn-pull.sh shell script which will run under user which has ssh keys to login to upstream firewall (1.2.3.4 in this example) and setup tunnels to upstream svn server (10.1.1.1):

#!/bin/sh
ssh -L 13690:10.1.1.1:3690 1.2.3.4 sleep 2 &
pid=$!
SVKROOT=/home/user/.svk svk sync -a
kill $pid

Now setup mirrors of branches we care about:

svk mirror svn://127.0.0.1:13690/project/carnet-foo /project/foo
svk mirror svn://127.0.0.1:13690/project/carnet-bar /project/bar

This is all nice, but we need to trigger it from www-user which is done with following in /etc/sudoers:

www-data ALL=(user) NOPASSWD:/home/user/svn-pull.sh

and add simple cgi script which will trigger sync operation:

#!/bin/sh
echo -e "Content-type: text/plain\n\r\n\r"
sudo -u user /home/user/svn-pull.sh

I used ScriptAlias in apache to make it visible at https://svn-ours.example.com/upstream-svn-update. No need on obsucate URL, since it's behind SSL for added points. IP address limit might also be a good idea:

  <Location /upstream-svn-update>                   
        Order allow,deny
        Allow from 1.2.3.4
  </Location>

Now install post-commit hook in upstream repository. We care only for files which have /carnet in path since branches which we are interested have that prefix:

svn log -v -r $REV file://$REPOS | grep ' /carnet' 2>/dev/null \
    && wget -q -O /dev/null https://svn-ours.example.com/upstream-svn-update

You will notice that there are no locking or any other tweaks, since all tools have those capabilities anyway, so we are really just using RPC via cgi over https in fact.

Nice and easy, once you know how to do it! It seems like a few bits of configuration all over the place, but I hope that it employs KISS - keep it simple and stupid at it's best.

Update: OK, now we have local repository (with different revisions), but svn switch --relocate doesn't work because those repositories are not same (makes sense, eh?)

Following steps are quick explanation now to copy .svn directories from new repository:

cd /srv/carnet-foo
# update repository to last upstream version
svn update
# delete old .svn directories
find . -name ".svn" -exec rm -Rf {} \;
# checkout new repository
cd /srv
svn co svn://svn-ours.example.com/carnet-foo carnet-foo.new
# copy new .svn files to old repository
cd carnet-foo.new
find . -wholename "*/.svn/*" | cpio -pvd ../carnet-foo/
# cleanup
cd /srv
rm -Rf carnet-foo.new
# following shouldn't return any differences
cd carnet-foo
svn diff

Nekako pomalo nezapaženo je prošlo vrlo zanimljivo predavanje Nicholasa Negropontea u Zagrebu. O organizaciji konferencije ne treba trošiti riječi, ali želio bih djelomično prokomentirati neke nedoumice o OLPC ideji.

Za početak zaboravite na laptop. Da, znam teško je. Ili je lijep ili ružan. Ili spor. Zaboravite na laptop. Dobro?

Ideja je promijeniti način školovanja. Negroponte očigledno to želi naročito napraviti u zemljama "trećeg svijeta" (što je, prisjetimo se malo bila i Hrvatska nekada u doba Jugoslavije) zbog toga što tamo većinom vlada još Viktorijansko poučavanje 19. stoljeća koje šibom utjeruje znanje.


Svi citati su moji sjećanja na sadržaj predavanja, a ne nikakav prijevod materijala (koji su bili snimljeni, pa se možemo nadati da ćemo ih moći nekada i pogledati).

...učenicima se do četvrtog razreda izgubi ta žar u očima koju imaju kada prvi pita dođu u školu...

To je kreativistički način podučavanja (ili poticanje istraživanja) koji se onda može vidjeti i u drugim aktivnostima koje nemaju veze sa računalima. Čuli smo primjer da djeca koja nauče programirati (program nikada ne proradi od prve!) dobiju novu vještinu debuggiranja koju onda koriste i u testovima ispravnog pisanja riječi. Njih zanima zašto su pogriješili te dvije riječi i nije im dovoljno što su sve ostale točne.

Slijedeća priča pokušava opisati situaciju na drugi način:

Postojao je narod koji nije imao pismo. U jednom trenutku vođe naroda odlučile su da treba uvesti pismo, pa su uvele po jednu olovku i svaku školu.

Kako to nije urodilo plodom, odlučili su u svaku školu staviti po jedan razred koji je imao po jednu olovku na svakom stolu.

Naravno, svi znamo da je bolji način dati svakom učeniku olovku.

Dakle, sve rasprave da li je OLPC ili Asus EEE PC bolji, jednostavno promašuju cijeli cilj. Nije čak ni stvar u tome da je OLPC dva puta jeftiniji ($200 * 5 = 1000 kn) od Asusa nego jednostavno u tome da je jeftin laptop jedini način da svaki učenik dobije svoju olovku.

OLPC laptop je zapravo samo jako zanimljiva implementacija te ideje.

Zamislite sat u školi upoznavanja sa znakovima, ulicama i prostorom oko sebe:

Djeco, nacrtajte ulice oko škole i znakove koje ste vidjeli na njima (prisjetimo se, OLPC ima podršku za grupno crtanje). Nakon što su nacrtali ulice i napisali imena, može se spomenuti da je standardna orijentacija karata prema sjeveru i zašto crtamo baš tako, a onda, s obzirom da je lijep i sunčan dan, djeca mogu krenuti u obilazak škole i koristeći više OLPC-a istovremeno (zgodnim programom koji smo vidjeli koji može mjeriti udaljenosti između dva uređaja) upisati na svoje mape točne udaljenosti.

Mapa onda sama može korigirati odnose (prisjetimo se, svi OLPC-ovi su povezani tako da se mapa sama obnavlja svima) i na kraju imaju neku ideju o tome kako prostor možemo zapravo prikazati kao skicu (npr. tramvajske pruge) a različito kao mapu sa stvarnim omjerima.

Usput, naravno možemo pogledati i horizontalnu i vertikalnu signalizaciju (zebre, semafori), i npr. snimiti filmić.

Možda nisam siguran u program kojeg predmeta bi ovakav zanimljiv zadatak spadao, ali mislim da mu nedostaje samo "pametna mapa" koja bi mogla biti jednostavna aplikacija na OLPC-u. Da li čujem glasove zainteresiranih pythonaša? :-)

About this Archive

This page is an archive of entries from March 2008 listed from newest to oldest.

February 2008 is the previous archive.

April 2008 is the next archive.

Find recent content on the main index or look in the archives to find all content.

Pages

  • pics
OpenID accepted here Learn more about OpenID
Powered by Movable Type 5.04