Skip to Content

Typespeed Hall of Fame - I passed 500!

 

 

I also finally managed to upload a picture to this site in a standard way. I've hooked up FCKEditor with ImageAssist and all the other Image Modules. I don't know which ones are working, and I'm afraid I don't have the time to care right now. Exams, y'know.

 

Any of you using Typespeed? What are your highest scores?

tablefmt: an attempt at a text filter.

While I was just generally looking through vim-related links at digg and the like, I came across a site with a number of text-related tools that can be used as text filters in vim (and elsewhere, of course). A filter is a program which takes lines of text, performs some operation and returns more lines of text, which are substituted in place of the original text. One of these which I could find a really good use for, was a filter which converted misaligned table data into an aligned table. However, the link for this program was broken, and I never found it anywhere.

Because of this, and the fact that I had nothing better to do, I wrote one myself.

Enter tablefmt, a simple text filter which does exactly what I said in the last paragraph. It's written in python, and till date supports a few features such as input delimiters and output delimiters. More is planned, though.

Here is an example of tablefmt in action :

(sykora@localhost)-(21:53:49)-(tablefmt:master)-
(%:!1136)- cat > tablefmt_test.txt
January 50 100 1000
March 20 10 300
July 100 20 5000
November 3000 200 10000
(sykora@localhost)-(21:55:07)-(tablefmt:master)-
(%:!1137)- python tablefmt.py < tablefmt_test.txt 
 January   50 100  1000
   March   20  10   300
    July  100  20  5000
November 3000 200 10000
(sykora@localhost)-(21:55:25)-(tablefmt:master)-
(%:!1138)-

The code is available on my github site, namely http://github.com/sykora/tablefmt/, but only the .py file is required.

Try it out, and tell me if you like it :)

Who said linux wasn't funny?

Posted in

This doesn't look funny at first sight, not the least when you read it in a black and white terminal as one usually reads manpages. But once it sinks in, damn is it good!

GROPE(1)                                                              GROPE(1)
 
 
 
NAME
       grope, egrope, fgrope - massage a file for a while
 
SYNOPSIS
       grope [option] ...  expression [file] ...
       egrope [option] ...  [expression] [file] ...
       fgrope [option] ...  [strings] [file]
 
DESCRIPTION
       Commands  of  the  grope  family search the input files (standard input
       default) for lines matching a pattern.  Some of the lines matching this
       pattern  will be sent to standard output.  Others will not.  Grope pat-
       terns are limited expressions in the style of mumps(1); it uses a  com-
       pact  nondeterministic  n-depth multidimensional negative feedback ora-
       cle/bag-automata algorithm  with  mudflaps,  foam  dice,  and  dimples.
       Egrope  works  only  in  Europe.  Fgrope uses FM to locate strings.  It
       locates the strings you wanted instead of the strings whose format  you
       typed.  The following options are recognized.

Move over Ratpoison, enter StumpWM

I've been an avid ratpoison user about 3-4 years, ever since I made the transition from full-blown eye-candly to painful minimalism. Ratpoison fit my needs perfectly, providing cheap, simple window management with non-overlapping windows and no frills. And damn was it fast.

There are, however, a number of drawbacks of ratpoison, where things are just too hard, much harder than they need to be. For example, one of my common gripes has been the ability (or lack thereof) to use the same key to run an application if it isn't running, or raise it if it is. After hours of work, I gave up with that goal, and tried to get at least a combination of 2 keys, one to open, and one to raise. The open, of course, is trivial. I found raising unbelievably hard. Why? There just is no provision to do the kind of testing necessary inside ratpoison itself. The common idiom in these cases, is to run an external script, and have it call the ratpoison binary in command mode, like this :

$> ratpoison -c "..."
	     -c "..."

and so on. This becomes really hard if you're trying to do something complicated. I later found out that there was a python module that you could import directly, but it only made the mechanics of the situation simpler, it didn't improve what you could do.

Enter StumpWM

StumpWM is the successor to ratpoison. It has the same goals of keyboard driven window management, but with one huge addition : It's written in Lisp. Now if you've had the same bad experiences with things as Scheme like I have, then you might not think this is such a good idea. But it probably is. That's because you can now customize the wm in a high level language, and not restrictive scripting language like what ratpoison offered. So now you can write your own functions in lisp which use functions provided by stumpwm, and do whatever you like with them. Moreover, you can interact with the running lisp process, meaning you can load code right into the running wm. I'm not an Emacs fan either, but I can see why they like that way of doing things.

eg, Here's the code I've been looking for, all this time :

(define-stumpwm-command "opera" ()
	(run-or-raise "opera" '(:class "Opera")))

That code will run opera if it isn't running, or raise it if it is. The command can be bound to a key, and used as required.

My second example, is one my largest time-sinks in ratpoison : How do you get 2 escape/prefix keys?

This is in direct relation to using the Super L/R keys (both of them) as your escape keys. In ratpoison, there was no way, you'd have to mess around with xmodmap to bind them to the same keysym, and go from there. I never got it working satisfactorily.

In stumpwm, it's all of 2 lines of code, as you'd expect it to be.

(define-key *top-map* (kbd "Super_L") *root-map*)
(define-key *top-map* (kbd "Super_R") *root-map*)

This code basically says that both the keys in the top level keymap are bound to the same thing, namely entering the prefix-map or root-map.

Now I'm by no means a Lisp ninja, but this isn't exactly hard.

My gripes with StumpWM? Only one so far. Stump lacks Ratpoison's undo/redo functionality, which was my saviour when I accidentally "only'd" a window. But this is on the dev's TODO list, so hopefully it won't be long before it's there.

Obviously there's a lot I haven't rambled on about, like the modeline, and rule-based window placement. Give me a break, I only started yesterday.

Mail on the Command Line - Part 1 - The basics: msmtp, getmail and mutt.

I never thought gmail's web interface was bad, and always wondered why people used a mail client to download mail to their computer, then read it there. After some digging around, I found the following few reasons :

  • Google isn't the only mail provider, others exist, and their interfaces were/are lousy.
  • Using a web interface requires an internet connection at the time, whereas downloading the mail doesn't, allowing for offline access. This doesn't matter much if you've got 24/7 internet like most people I know, but not all of us are that lucky.
  • You get to use your own editor. My slam dunk. Use vim to write mail.
  • Lot more configuration options, to suit your need, and there's no need to wait for page loads each time.

There are probably a lot more, but these are what struck me. Note that I'm talking about POP and not IMAP, but I'll get to that later.

So once I'd decided that I wanted to access my mail from my own computer as opposed to using a web-interface, I looked around for what I needed. I already had a decent idea, but there were a lot of alternatives. As far as I know, the bare minimum you need is the following :

  • A tool to get your mail from a server.
  • A tool which sends mail from your account, through your outgoing server<./li>
  • A tool to read your mail.
  • And the glue to put this together.

First off, to test the water, I installed thunderbird and tried to recognize my mailbox. Now I have issues with my network connection and ports not being open, but that shouldn't be a problem for most people. Once I got that working, I scrapped it. Too much mouse, too slow. I needed something on the command line.

I settled on the following programs to build my mail system :

  • getmail
  • msmtp
  • mutt

What getmail does should be fairly obvious. msmtp is a sendmail compatible smtp client to...send mail. Mutt is _the_ command line mail user agent. The choice of getmail and msmtp are almost arbitrary, I chose what most tutorials use. I haven't had too many problems with them, and they're easier to configure than others I (don't) know.

So now, let's get to it.

Git, and Github

Posted in

I first tried using a code management programming when I was playing with the drupal codebase. They used cvs, and after great difficulty, I got that to work (my fault, not theirs). It was a nice feeling, being able to "checkout" the HEAD branch, and look at what was actually happening. I didn't however, learn how to use cvs at that time, since I was more into the actual code, than how it was being stored. What I did notice was that I would never be able to write back to the main code repository, ie I would never be able to commit. Anything I wanted to contribute had to be done through the patch submission process.

Quit some time later, I read an article on git. It's relatively new, only 2 years old. It was started by Linus Torvalds, for managing the source code for the linux kernel. After hearing more and more about git, I thought I should check it out.

git is surprisingly easy to use. I would never have dreamed of trying to set up my own cvs/svn repo with as much ease as I have done with git. Inserting an existing project into a git repo is as easy as :

$> git init
$> git add .
$> git commit

The following quote from the linux-mips wiki sums things up pretty well :

We will hereby start scouring the net for people who say git is hard to understand and use, and just kill them. They clearly are just polluting the gene pool.
-- Linus

I also saw this Google tech-talk of Linus Torvalds talking about git and why it's better. It's an awesome watch for anyone interested.

Git follows a distributed design philosophy, where each person can play with their own code, and whenever someone else thinks there's something worth looking at, they can pull from them. This eliminates the need to have a central repository of code, as well as a group of elite users with commit access to the repo.

Did I mention that git is fast?

Just as I was ridinng this wave, QwertyM told me about GitHub, a service that provides hosting for code, and allows (or rather is focussed around) user access of code through git. After some fumbling around with ssh keys, I set up my account with GitHub. You can find it at http://github.com/sykora/, where I've also uploaded the code for my limits project.

Because git doesn't mess around with a centralized repository, it's easy to use even for small, personal projects, and I definitely recommend it for anyone who's managing code.

Note: As far as I know, git support in windows is still transitional. If that's what you need, check out Mercurial.

RSS feeds - keeping my own end.

Posted in

l've finally added feedburner integration for the site. I suppose it's something I should've done when I started off, but I thought drupal's inbuilt aggregation would be enough. I still have no idea, I just saw everyone else using it.

Click on the Feed Tab in the primary links up the top to subscribe.

Limits - A simple programmer's aide.

There have been a number of times (especially when doing such pathological calculations as in Project Euler) that I have needed (in C/C++) the exact minimum and maximum values of any datatype. Of course, these details are available in limits.h/climits, but I was too lazy to open that up each time.

Limits is a simple program which outputs these values. That's all it does. For example, here it is in action :

(sykora@localhost)(0 job[s])(Saturday, August 30, 2008 : 14:22:10)-
(%:1075:~)- limits
                Data Type     Size                   Minimum                   Maximum
                     char        1                      -128                       127
                    short        2                    -32768                     32767
                      int        4               -2147483648                2147483647
                 long int        4               -2147483648                2147483647
            long long int        8      -9223372036854775808       9223372036854775807
           unsigned short        2                         0                     65535
             unsigned int        4                         0                4294967295
        unsigned long int        4                         0                4294967295
   unsigned long long int        8                         0      18446744073709551615
                    float        4               1.17549e-38               3.40282e+38
                   double        8              2.22507e-308              1.79769e+308
              long double       12              3.3621e-4932             1.18973e+4932

The code is available here. Just untar, make and make local/global. This is the first time I'm actually going to the extent of publishing the code, so please bear with the slapdashness :).

Limits is written in C++, with a formatting front-end in Python. I had originally written it for 3.0, but that'll have to wait till its release in October.

Command Line typing tools

No, I'm not done with the typing thing yet :)

Over the course of learning colemak, and taking a better look at my typing, I went in search of relevant programs, which happen to be either tutors or games.

I looked at Ktouch, but it looked a bit bland to me. Then I found tuxtype, but left it just as fast -- any typing tutor with fullscreen graphics and a penguin isn't for me.

Finally, I wondered why I hadn't tried out any command-line alternatives. There was no reason, and I searched the vast expense of debian's package repositories. 2 programs caught my eye.

g(nu)typist is a command line (ncurses-based) typing tutor. It's really simple to use, and has a large number of lessons, mainly for qwerty, but it has one main dvorak lesson as well. Although a Colemak lesson is not included with the program, one is available from the colemak website. Gtypist is simple -- some would say too simple; it has no advanced statistics or anything, just speed and error indicators -- but it's just right for me.

Typespeed is a simple game based on another simple game ztspeed, from the dos heyday. The premise is simple : Type words as they fly across the screen. Miss 10 and you're out. Typespeed will grade you based on your speed, accuracy, etc, and keep a high-scores list. You can also go head-to-head against a friend over the network, but I haven't tried it out yet. The thing that got me here was that it had... unix commands as one of the word sets. I haven't seen any other program which didn't assume that the only thing I typed in was English, so that's something new right there. Typespeed also has C# keywords, French, and other languages as well.

And so the command line comes to the rescue again. I'm amazed why I didn't think of it before, especially since the only thing one does on the command line is _type_. ;)

Colemak et al, one week later.

Posted in

It's been one week since I started using colemak as my primary keyboard layout. Progress has been fairly good, and although I'm not typing anywhere near as fast as I used to, it does feel more comfortable.

The worst part about all of this is the changing of the keybindings. Only now do I realize how qwerty-centric vim is :(.
I'm working on some new bindings for vim, and I'll put them up when I'm done. Yes, I know that at least one set exists already, but I'm going to write them up myself.

This week I also started adding some eye-candy to ratpoison. This comes in the form of dmenu and dzen2, and would be instant hits for me if they didn't break gvim's line-handling.

I also installed archlinux, but didn't get further than network configuration. Damn ntlm.

Syndicate content