domingo, 29 de marzo de 2009

vim and rst, a confortable way to do presentations

I've been hunting for a good app to write slides without much success:

I've tried from powerpoint-esque approaches, to text presentations with tpp . I haven't found a single good one, but well...

  • Powerpoint/OO slides failed. GUI. Big Files. I don't like to work visually with those kind of programs.
  • tpp and magicpoint failed. Too naive, or too dificult to configurate.
  • Latex-beamer was good enough. Bad thing is I have to insall latex, where usually I don't have installed. Very professional look. That's a big++.
Having tried nearly all typical programs (I don't use Mac , so keynote is not an option), I decided to go into a DIY mood finding more 'housemade' apps.


  • plain HTML templates. Probably, when I have some time, I'll do a perl script to embed text into chained html's with a common structure. I think it's the best option available (oh duh, isn't it sad?).
  • text2tags | markdown | rst . For the moment, I'll go with rst, using a vim plugin to generate the final html or s5 slides. It's easy, it's vim, it's lightweight, it's html, it's portable.... I just would like it was more clear and easy to modify...


What I've choosen is vim vst plugin . A plugin to generate html, s5 or latex from a simple syntax based on ReST.

It works quite well for writting short to medium sized texts, without having to think about presentation.

Give it a try and see.

Some css here http://www.rst2a.com/gallery/html/

Addendum: EPIC FAIL for presentations. Depending on the resolution, text doesn't fit the screen. If you limit to 10 code lines, you probably get no problems, but... For plain html it's quite good and straight to write.

miércoles, 25 de marzo de 2009

Fully vim style linux - Part 1

That's the start of a group of threads related to converting your linux experience to the most vim-ish way.

My aim is to get every application I use behave as vimish as possible.

That means:
  • Understand hjkl
  • Being able to find using '/'
  • Maps or at least some kind of extensibility
  • If we can't go vim, let's go screen, or even emacs ( keyboard >> mouse )
My use cases are the typical ones for any programmer and internet surfer:
  • Editing text
  • Browsing
  • Reading pdf's and chm's
  • Playing music (local mp3 or streaming)
  • Chat (IRC, msn)

Editing text with vim

First things first. If you want vim shortcuts everywhere, you should first learn vim deeply. That means getting used to hjkl, mappings, trying plugins and so.

There are some plugins that are a must, if you ask me. For example:

  • snippetsEmu or snipMate
  • parenquote
  • surround
  • pastie
  • FuzzyFinder or 0scan
there's plenty of info about vim in the net, so I'm not going to rewrite what's been already written. Only two little tips for your .vimrc

:nnoremap ,vimrc :new ~/.vimrc
:nnoremap jk <esc>
A 'quick' shortcut to edit your vimrc when you think: "Oh, that map is darn cool, I must have it in my vimrc". Just press ',vimrc' and you have your vim config file ready to edit.
The second one is pretty obvious, but it's one of the coolest tricks I've seen. No more pressing escape to go to the normal mode.

Browsing
If you're short on resources, use opera. Calmar has a pretty nice opera config file for vim keybindings in his page
For those using firefox, you MUST use vimperator. It's the reason why I switched from opera to firefox. With vimperator, your firefox will be really close to vim. You can use the common navigation shortcuts (hjkl, gg, G, c-o, c-i ,c-d, c-u, c-b, c-f), and it allows some cool way of navigate the web. For example:

  • gu : 'go up' . loads the url you're on from the start till last '/'. That means, travelling one directory up if you're browsing an ftp. http://www.foo.com/bar/lala/baz.html -> gu -> http://www.foo.com/bar/lala/
  • gU: 'go (really) Up' . Loads the main page on the server. From the begining of the url till the first '/' .
  • [[ and ]] are for traveling through document hierearchies. Hey ! that's my patch! . If you're browsing a document written with latex2html, or there's a link with the text 'prev','previous','<' or '<<' ,or their obvious counterparts, [[ and ]] will load the page pointed by them.
  • f. It activates the 'quick hints' mode. Typing substrings of text links, or the number assigned to a given link, it vimperator will load the given page when the typed string points to only one. F does the same but opens it in a new tab.

Vimperator is very customizable, with a plugins system and a vimperatorrc file that's read when you run vimperator. Tips:

:noremap ,vimrc :!gvim ~/.vimperatorrc
:noremap <Left> gT
:noremap <Right> gt
Pretty obvious, right?

type :h in vimperator to see a quick tutorial and the docs.

Cya

miércoles, 18 de marzo de 2009

Parrot 1.0 is out

The parrot virtual machine is out. At least, 1.0 version. It's not production ready yet, but it's intended to be used by language developers to start adding their languages to parrot.

Sofar I've tried only a few codes, but it already does amazing things with great simplicity.

Parrot site:
http://www.parrot.org

miércoles, 11 de marzo de 2009

installing SGML addon for Io and using it to get latest xkcd image

Io can be a PITA to install. SGML addon is an example of it.

things to try:
- install libsgml (from http://www.hick.org/code/skape/libsgml/ )
- cd /usr/local/lib
ln -s sgml sgml-1.1.4

- cp sgml/include/Variant.h sgml/Variant.h

- cd steved..../addons/SGML/
ln -s sgml sgml-1.1.4

It doesn't work unless you run io from /usr/local/lib
^ This is only a draft, tomorrow I'll clean it... sure.....
------

Ok, say you already have SGML installed along with your Io instalation.

Today's toy problem is HTML parsing. I thought I'd do something web related (like my last squeaky google fight) . Well, This is the result. a Tiny script to get latest xkcd png and put it as a wallpaper using feh. The code has too many hardcoded things, but, you know... it's only a demo, right?
#!/usr/local/bin/io_static
# updates wallpaper with latest xkcd image
#
# kidd
#

XKCD := Object clone do (
      url := "http://www.xkcd.com"
      fetch := method(
         html := URL with(url) fetch asString asHTML
         urlImage := html elementsWithNameAndClass("div", "s") at(2) elementsWithName("h3") at(1) allText split(": ") at(1)
         File with("/tmp/sc.png") setContents(URL with(urlImage) fetch)
         return ("/tmp/sc.png")
     )
)

SGML
xkcd := XKCD clone
System system("feh --bg-scale " .. xkcd fetch .." ")

Let's hope next Io post will use some of Io's cool features, not just 'standard' code

Seeya!

domingo, 8 de marzo de 2009

Squeak + Soup + Regex engine = google fight!

About a year ago, I wrote a kind of google fight in perl. At first it was to automatize a process I was doing more and more:

When I don't know how a word is spelled, I tend to look the options at google, and depending on the number of results, I choose. The perl program has been included as an example of WWW::Mechanize at a course in La Laguna University which makes me really happy :) .

Now, I wanted to try it in squeak, as it seems a good toy problem: it includes some web scraping , some string comparisons with regex involved, and, of course connecting to inet and little logic control.

Well, to run the following example, you'll have to get squeak Soup (a port of python beautiful soup) , including it as a new monticello http repo (http://www.squeaksource.com/Soup ) and install the latest version of soup. In my pharo image, it complains about using startsWith (deprecated) instead of beginsWith . you can just ignore those warnings or fix them (that's what I did).

Then install regex engine from SqueakMap Package Loader . I had to use the beta version, because the latest crashed, but I may have done an error installing it, so don't take anything about comparisons beta vs stable for granted.

After that, we're ready to run the next code in a workspace:

mySearcher := [:wordToSearch| |tmpText re m |
soup := Soup fromUrl: ('http://www.google.co.uk/search?q=', wordToSearch , '') .
results := soup findAllTags:
[:e | e name = 'div'
and: [(e attributeAt: 'id') = 'ssb']].

tmpText := ((results at:1) findChildTag: [:e | e name = 'p']) text.

re := 'about ([\d,.]+)' asRe.
m := re search: tmpText.
((m matches at:1) copyWithoutAll: ',' ) asNumber.
].

googleFight := [ :x :y |
( (mySearcher value: x) > ( mySearcher value: y ) )
ifTrue: [x]
ifFalse: [y]
].


googleFight value: 'hello' value: 'helo'
Need any further explanation? post a comment

--- EDIT ---
I contacted to Zulq Alam (Soup Author) and he updated the beginsWith vs startsWith thing, and provided some alternative snippets to take full profit of Soup. As it's related to #doesNotUnderstand selector which I plan on writting a post, I'll leave it for now.
Thanks Zulq :)

domingo, 1 de marzo de 2009

Vector linux 6.0 in my Acer Aspire One

I recently bought an AAO, that came with linpus (a very visual distro without much features, but I suppose nice for people that doesn't expect much from their AAO).

Last week, when I got a bootable usb to repartition my AAO hd I installed arch in one partition and from arch, I could install vectorlinux from arch partition doing a hosted install. I'm going to explain how to do a hosted install. Very easy:

First you should have a working linux (with 2.6.x kernel, forget DSL) and a free unmounted partition. Vl installer will be able to recognize unmounted partitions.

- Get an vl iso (wget http://vectorlinux.osuosl.org/veclinux-6.0/iso-release/VL6.0-STD-Gold.iso will do)

- When its done, mount it in a temporary directory somewhere

mount -o loop VL6.0-STD-Gold.iso tmpdir
- Copy vinstall-iso file to anywhere outside the tmpdir

cp tmpdir/install/vinstall-iso .

- unmount tmpdir

umount tmpdir
- as root, execute vinstall-iso with vl iso as a parameter

./vinstall-iso VL6.0-STD-Gold.iso
- Install starts normally (text installer)
1) choose the correct screen resolution (for 8.9" screens)
2) lilo didn't see archlinux, so I decided not installing lilo, and just modify archlinux's grub menu.lst file

After installing vl normally, you can reboot, and start using vl.

Warning:

Wifi led is software controlled, and won't tell you if wifi is on/off. vl can use wireless out of the box. If it does not work, push the wifi switch until it works (you won't need more than 2 tries)

Some more comments on http://forum.vectorlinux.com/index.php?topic=7330.0

Have fun with a fully working vector linux installed on your aspire one.

Wireless -> ok
Webcam -> ok
Sound -> ok