Archive for the 'software' Category

Virtual Workspaces

Thursday, November 20th, 2008

I was going through my Google Reader recently and I saw this post about workspaces and started thinking. Didn’t I do a post like that before? I mean, I probably had to, right? Out of all the topics out there, I’m pretty sure I had to mention this at one time or another. Besides, I have a vague recollection of writhing about it.

It turns out I was right. I did write about it last year. Thank you Google! You are by best friend, and nowadays that I actually figured out the site map thing (and by that I mean I found a plugin that will generate them for me) and I’m all indexed up you often work better than the shitty Wordpress search. You know what I’m talking about no? If you don’t look for the search box on top of the side bar. That defaults to the internal Wordpress search, but I might actually switch it over to the googles one of these days.

Anyways, I digress. Digressing is probably one of the things I do well. It is also one of the reasons why my posts are longer than they need to be most of the time. The other is my tendency to use seven sentences where one would be enough. Being concise is a skill that I have never mastered. I am always amazed when people take my 15 minutes of rambling and abstract it into a 5 words or less. I’m like - wow! Yes, that’s exactly what I meant. Of course being a long winded writer has some benefits - for example I never had to worry about meeting length requirements on school papers. My friends were doing all these tricks with changing the font size, changing the face to the widest one available. I’d just write the damn essay, notice it is 3 pages to long, then cut some stuff out, rewrite bits to be shorter and I was done. And that was when I was speaking strictly on topic. Not like I’m doing now.

Anyway, I re-read my earlier post and decided that - what the hell - let’s talk about this again!

How do you organize your virtual workspaces on your machine? Do you organize your windows based across worskpaces based on some sort of order, or randomly assign them to the virtual desktops on a first come first served basis. I’m surprisingly organized when it comes to my worskspaces. Surprisingly, because you wouldn’t be able to tell that if you had seen my actual desk where everything is arranged using a stack methodology. ANd I mean that literally - I stack things on top of each other until they fall off which is what I call a natural stack distribution.

My virtual workspaces however are nearly arranged like this:

workspaces.png

It pretty much goes like this:

  1. Email - first workspace is always for work/school email. My personal email lives on the second desktop because it is web based, but my work and school emails live inside Kmail and always are located on the workspace number one.
  2. Web - second desktop is for firefox, and assorted windows that I use for web browsing, downloading shit from the web and etc..
  3. Code - third desktop always holds my IDE. More often than not it is Komodo Edit which I like because it has limited vim bindings. Sometimes it is Eclipse though.
  4. Virtual Machines - my windows XP instance lives here. I use it to run shitty Windows only software like Monarch, Office 2007 and some other proprietary apps that my company supports.
  5. Stuff - this is the workspace where I open all the random windows that don’t fit anywhere else - like Dolphin for file browsing, random shell windows, random Vim windows, and sometimes Gimp when I need to edit some images (which is almost never)
  6. Remote - last worskpace is reserved for remote desktop sessions for the servers that I maintain. Usually they are rdp sessions, but I sometimes I have a VNC window there (for remote support stuff)

How about you? How do you organize your desktops?

Oh, a word about windows - I have yet to find a virtual desktop manager for that OS which would work the way these things work in Linux. The MS Powertoy is slow and buggy in my experience. I found the popular VirtuaWin to be ass backwards and counter intuitive when it comes to moving window across the desktops. The Sysinternals Tool is nice but so bare-bones that it doesn’t even have the functionality to move windows between desktops. Virtual Dimension was possibly the only tool that I knew off that would actually show you what is on which desktop (the way KDE pager does) but it did not integrate into the task bar, and it has not been updated in over 3 years. So meh… I’m not using workspaces on my Windows box. Then again I hardly do any coding on Windows anymore and for entertainment I usually either run Firefox or fullscreen video games so I don’t really need the virtual worskpace functionality for that.

Any suggestions for a working windows virtual desktop manager though?

Vim Cheatsheet

Monday, October 27th, 2008

Today’s post is not really a post. It is an attempt to create a workable Vim cheat-sheet. I know that there hundreds vi/vim chat-sheets online, some better than other but naturally none of them is complete and includes all the commands that I care about.

By far the most popular sheet is probably this one which actually hangs over my desk. It is a very good one and I use it all the time to remind myself certain key-strokes. Still, it is not very comprehensive since you just can’t physically fit all the useful key-strokes in that format. I decided to organize mine into sections rather typographical groupings. The result is below.

Please note that I skipped the obvious stuff like ‘hjkl’ and some of the advanced stuff like marking, folding, and register operations. That’s because I don’t really use these commands that often, and furthermore a lot of Vi emulators (like the one in Komodo Edit) do not support them.

Your mission, should you choose to accept it is to add your favorite commands and/or indispensable shortcuts which I have omitted. And yes, I omitted a lot here. There are just to many things to list - this is why I’m relying on you guys!

Movements

w - next word
W - next white space delimited word
b - previous word
B - previous space delimited word
e - end of word
E - end of white space delimited word
0 or ^ - to the physical beginning of the line
$ - to the physical end of the line (ie. the newline char)
g0 - to the beginning of the virtual screen line
gm - to the middle of virtual screen line
g$ - to the end of the virtual screen line
gk - up screen line
gj - down screen line
fchar - till the next occurrence of character ‘char’ (inclusive)
Fchar - till the previous occurrence of character ‘char’ (inclusive)
tchar - till the previous occurrence of character ‘char’ (exclusive)
Tchar - till the previous occurrence of character ‘char’ (exclusive)
G - end of file
gg - start of file
gd - go to the definition (first occurrence of the word under cursor)
{} - begging/end of paragraph
() - begging/end of sentence
[{ ]} - beginning/end of a code block
[[ ]] - beginning/end of a method
[* ]* - beginning/end of a comment block
% - find next open block char ({[ and jump to it’s matching close char
‘. - go to the line with the latest change
* - search to the next occurrence of the word under cursor
# - search to previous occurrence of the word under cursor
/pattern - search to next occurrence of “pattern”
?pattern - search to previous occurrence of “pattern”
n - repeat last search (*,#,/,?) forward
N - repeat last search (*,#,/,?) backward

In the examples below I indicate a movement specified above as mov

Entering Insertion Mode

i - insert at the cursor
I - insert at the beginning of the line
gI - insert in column 1 of the line
a - append after the cursor
A - append at the end of the line
o - open a blank line below cursor
O - open a blank line above cursor
r - replace character under cursor and exit insert mode
R - insert at the cursor in overstrike mode
cmov - delete (change) movement and enter insert mode
cc - replace entire line
C - delete (change) line and enter insert mode
s - delete character under cursor and enter insert mode
S - delete line under cursor and enter insert mode

Deleting

x - delete char under cursor
X - delete char before cursor
dmov - delete range of movement m
dd - delete current line (text moves up)
D - delete to the end of line
J - join the line below to the current
gJ - append the line below to the end of current line

Block Modifiers

When dealing with blocks of text delimited by parentheses (), brackets [], braces {} or <> you can apply the command to either the contents of the block or the whole thing by following it with:

iblk - inner block (everything inside braces, parenthesis etc..)
ablk - all (whole parenthesized block)

Where ‘blk’ is ), ], } or >

Copy/Paste

yy - copy current line
ymov - copy movement m
p - paste after cursor
P - paste before cursor

Visual Mode
v - enter visual mode highlighting 1 char at a time
V - enter visual mode highlighting 1 line at a time
Ctrl+V - enter visual block mode
aw - highlight word
as - highlight sentence
ap - highlight paragraph
ab - highlight a parenthesized block
aB - highlight a {} blocks
ib - highlight contents of a parenthesized block
iB - highlight contents of a {} block

Special

< > - indent left/right
. - repeat last command
u - undo last command
U - undo all changes on the current line
Ctrl+R - redo last undo
Ctrl+O - jump outwards (up-back) to the previous cursor position
Ctrl+I - jump inwards (down-forward) to the previous cursor position

Completion

Ctrl+X - enter completion mode
Ctrl+N - auto complete word in insert and completion mode
Ctrl+P - auto complete word in insert and completion mode
Ctrl+L - auto complete whole line in completion mode
Ctrl+K - dictionary completion in completion mode
Ctrl+F - filename completion in completion mode

Useful Tricks

g~mov - toggle uppercase/lowercase on the range of ‘mov’
gumov - lowercase the range of ‘mov’
guu - lowercase the current line
gUmov - uppercase the range of ‘mov’
gUU - upercase the whole line
g?mov - rot13 on the range of ‘mov’

Regexp Replace

:ranges/foo/bar/arg - replace foo with bar in ‘range’ with

Values of ‘range’:

% - whole file
number - that particular line
none - apply to current line only

Values of ‘arg’:

none - apply to first occurrence
g - global (all occurrences)
i - ignore case
I - don’t ignore case
c - confirm each substitution
p - print the last line containing substitution
e - ignore errors

Macros

qchar - start recording macro storing it in register ‘char’
q - end recording
@char - replay the macro stored in ‘char’

That’s all I have for now. I will update this page with any useful suggestions. If we have enough perhaps I will take this, re-format it nicely and generate some sort of nice looking single sheet PDF that you could hang in your cube or above your fireplace or whatnot.

Vim LaTex

Monday, October 20th, 2008

I noticed that in the past I produced several posts about combining LaTex and Emacs. While I do like Emacs and respect it’s formidable power I do not consider myself an Emacs user. Most of my day-to-day work is done in Vim which brings different kind of editing power to the table. Emacs is a lisp based framework for building text editing applications - fully programmable, easily customizable and almost endlessly extensible. The power of Emacs comes from what it can do. Vim’s power stems from what it does - and that is providing very powerful and yet simple modal text editing environment. I wanted to say intuitive, but yeah - that would be a lie. Vim is powerful because it allows you to accomplish just about anything in 3-4 keystrokes by chaining and combining simple commands.

Using Vim makes editing text much simpler and easier. It removes a lot of key-presses and movements. Let me give you an example - in a typical coding session you may want to copy the current line, and paste it below. Assuming your cursor is in the middle of the line how would you go about accomplishing it? Typically you would do:

  1. Hit Home to skip to the beginning of the line
  2. Hold shift and hit End to highlight the line
  3. Press Ctrl+C to copy the line
  4. Hit End again to put the cursor at the end of the line
  5. Hit Enter to insert a new line
  6. Press Ctrl+V to paste the line

How do you do it in Vim?

  1. Press the following keys in a sequence: yyp

That’s it. You want to paste the line 3 times? Do yy3p. This is the power you get when you use Vim. Of course die-hard emacs fanboys will remind me that one could always use Emacs’ VIP mode which emulates vi’s modal editing features. And they would be absolutely right. As I said, Emacs is a framework for building editors rather than an editor. So when you launch it in VIP mode you are really using Vi with the lisp powerhouse underneath it.

In theory you could combine the neat features of AUCTex on Emacs and the power the VIP mode gives you to get the best of both worlds. But if you don’t need these features - if you are a Vim purist or if you just need a simple modal text editor I have a nice alternative for you. It’s called VimLaTex.

vim-latex.gif

While it does not have the nice rendering features of AUCTex, VimLaTex is a must-have if you are planning to use Vim to edit LaTex files. The package itself is tiny - you just drop few hundred KB into your .vim directory and add few lines to your .vimrc.

The suite will add bunch of useful menus to your toolbar:

croppercapture100.jpg

These menus are your standard IDE like features - for example options for inserting packages, or snippets of code for special environments and etc.. A lot of the entries come with predefined key-bindings which make your life much easier. For example:

  1. To compile your file do: \ll
  2. To view compiled file do: \lv

You can set the preferred format for both options above by invoking :TTarget. It works like a charm both on Windows and Linux when I tried it.

VimLaTex also uses an interesting concept of placeholders. Whenever you use it to generate snippet of code, it will put funny looking character sequences inside of it. They may look silly until you realize how useful they are. For example let’s say you want to insert a figure:

\begin{figure}[h]
    \centerline{\psfig{figure=«eps file»}}
    \caption{«caption text»}
    \label{fig:«label»}
\end{figure}«»

The placeholders are there to make your life easier. When you press Ctrl+J vim will jump to the first «» delimited sequence and select it. This way you can just type over it. Press Ctrl+J again (while still in insert mode) and you will jump to the next one. How awesome is that?

If you are a Vim lover who also happens to use LaTex or a LaTex user who loves Vim definitely check this one out.

WYSIWYG is a Lie

Thursday, October 16th, 2008

Yes boys and girls, it’s that time of the month again when I rant about the evils of WYSIWYG. Let me tell you a little story. In the beginning there was text. That’s all we had really. We used white space, underscores and bunch of the table drawing ASCII characters for all our formating needs. And we were doing just fine. Plain text was limited though, and people wanted to do typesetting on their computers. You know, like take bunch of text and mark it up so that when printed it looks all nice - like a professionally bound book or a magazine. So we invented markup.

Markup can be done in many ways, but it always boils down to this: there are special formating commands or characters inserted into your text document which convey the formating/typesetting information to the printing software. Next logical step was of course to invent Print Preview functionality where you would try to simulate how a printed document would look on the computer screen to avoid killing many trees. The rest is history - a perfect example that pandering to the lowest common denominator under the guise of improving usability may lead you to an evolutionary dead end.

According to my rough estimates, 60% of people are fucking idiots, and the remaining 40% are fucking morons. Yes, that means you are in one of these groups and so am I. Pick one or the other - they are both equally bad. Our only redeeming quality is that every once in a while even a total idiot or a complete moron can come up with a good idea. Once this happens the rest of us idiots and morons conspires to fuck it up as quickly and throughly as possible. Fortunately good ideas can often fend for themselves, survive the assault of stupidity and persevere. Word processing unfortunately failed this test and got fucked up.

First issue with markup languages was that you need to learn them. As you can imagine, stupid people don’t like to learn so we invented special editors with funky toolbars so that they don’t have to remember the markup code for bold, but just press a button. This made the fancy typesetting applications accessible to even more stupid people, who immediately started complaining about how hard and counter intuitive they were. For example switching between editing view and print preview was cumbersome. The markup commands embedded in text were confusing, and etc… So we all boarded the simpleton train of idiocy we allowed the stupids to type in a print-preview like environment hiding the actual markup. This was how WYSIWIG was born. It was hailed (and still is) as a revolution in the way we processed electronic documents - a grand new invention, and a usability improvement like no other. But in reality it was an ugly kludge designed so that Ms. Dumberbuttons in accounting could type up her reports without stopping every keystroke to consult a cheat sheet taped to her desk (cause before we taped it she kept losing it every day). Funny thing is that all that work was for nothing, because at the end of the day Ms. Dumberbuttons still needed a cheat sheet to tell her that she needs to press the bolded B on the toolbar to make the text bold, and called the IT department every time she accidentally minimized her editor window (which was 4-5 times a day).

Some of the better WYSIWYG word processors such as Corell Word Perfect retained some vestigial mode which would actually show you all the markup commands and characters in your document. This was great because terminally stupid people like Ms. Dumberbuttons could just use her WYSIWYG interface without really learning how it worked, while the rest of us could still sort of know what the hell was actually going on in our documents.

markup.jpg
the right way to do WYSIWYG

Guess what happened to Word Perfect though? It was superseded by a much dumber and kludge-worthy application from Microsoft which removed never included the above feature from their product. Why? Who knows. Perhaps having such a tool would make it easier for their open source competition to reverse-engineer the proprietary, binary file format. Or perhaps they did not deem it worthy of inclusion, seeing how only like 7 people in the world admitted to using it. Either way, the de-facto standard for word processing these days is a funny little application that creates text files, applies quite an intense amount of markup to them, then hides all that markup making you guess what is going to happen next time you press the backspace key. Will you delete some important markup tag or not?

WYSIWYG is it’s own worse enemy because what you see is really not what you get. The invisible markup is what makes all the difference. You can’t really use MS Word to the full extent of it’s functionality without understanding how page breaks, section breaks and column breaks work.You need to understand that your document is full of meta-information that describes font faces, sizes, spacing and etc. You need to understand the crucial difference between inserting a paragraph break (Enter) or a line break (Shift+Enter) and how it impacts formating, and layout. Word seems deceptively easy to use, but it is a truly a difficult application to master because all the important things are hidden or obscured. Not to mention the fact that Word’s Print Layout mode is not really WYSIWYG - to really see how your document will look like you still need to use Print Preview feature.

When users hear WYSIWYG they expect the application to work like a modal typewriter. When they press enter they expect to see the cursor skip to the next line. They don’t expect that behind the scenes word will insert a paragraph break into their document, then write out some invisible markup that indicates the start of a new paragraph and then check what formating this paragraph is supposed to inherit based on current document layout and write it out as well. So there is a huge discrepancy between what people expect WYSIWYG to do and what it really does.

I’m not the only person who sees it. Terminally Incoherent regular Ian Clifton noticed this too:

In general, users want to get the work done as soon as possible, which means doing whatever they already know or whatever makes the most sense to them. They rarely look through menu choices to try to figure out how to do something such as how to format a paragraph. They don’t pay any attention to anything that they don’t need to pay attention to (e.g., the ruler). They commonly feel as though they are “fighting” the computer to get it to do what they want. The thought that there are alternative programs almost never occurs.

Overall, I’d say the biggest difference between an “average” user and someone who is truly technically literate is that the former never considers how his/her actions will be interpreted by the computer (assuming the computer should think in the same way as s/he does); the latter acts based on how the computer will interpret the action. Essentially, it’s the difference between talking to someone and talking at someone.

That is precisely the point. Average MS Word user is FIGHTING the application to get their work done. They have to wrestle this monster and beat it into submission. It is an uphill battle between a user who just wants to type shit up, and an evil, malevolent computer which throws obstacles in his way. The only way to properly use the application is to understand the way it handles the markup and try to anticipate what it will do based on that knowledge.

In effect, every user of a WYSIWYG processor has to acquire intuitive knowledge of their editors internal markup language and it’s quirks without actually ever seeing it displayed on the screen. The ease of use is an illusion that fades away as soon as you need to create a document that is more complex than a one page memo or a thank you letter.

I blame the WYSIWYG paradigm for this. Going from text processing to typesetting to word processing was an idiotic thing to do and we are paying for it every day. Well, you are paying for it. I’m happily typesetting most of my work in LaTex so I don’t have to deal with word processor bullshit. But I digress, people are paying for it every day. I’m not saying everyone should switch to LaTex. LaTex is for smart people who are not afraid to learn a new markup language in order to increase their productivity and generally improve their quality of life. For example Ms. Dumberbuttons from Accounting would probably never learn it, because she is allergic to knowledge (and also dumb as a brick). You my friend may never learn it because you are a lazy bum, and you don’t give a fuck. Everyone has their own reasons and deficiencies so I’m not going to push the issue. All I’m saying is, put a button on your Word Processing application which will expose the markup to me the same way Corell Word Perfect did. Make it nice, self explanatory and user friendly. Have tool-tips explaining each of the tags when user hovers over them. I’m looking at you OpenOffice.org? Why is that not part of your Word Processing application? Because MS Word doesn’t have it? Well, if MS Word jumped off a bridge would you do it too?

Fuck, never mind - it was a rhetorical question. The only reason you probably don’t have a Ribbon interface yet is because it would require rewriting the whole UI from scratch and no one wants to do that. Yet… So yeah, I know full well you would jump off that bridge. But you don’t have to. Blindly aping everything that Microsoft does is not always a good thing. If we had a markup exposing feature in MS Office alternatives our lives would be much easier.

Instead of sitting and scratching their heads, users could just switch to the markup view and go - “Ah! That’s where my problem is. I’m missing a column break here!. And by users I mean power-users. You know, guys like you who don’t want to learn LaTex even though I keep telling you it will make you better, more awesome and will totally increase the size of your… Resume. What? What did you thing I was going to say? Ms. Dumberbuttons will still be two-finger typing her reports and calling the helpdesk every day to walk her through the ardors process of saving the document in the right folder on the network share. That can’t be helped.

Do we really want to dumb down our software to the point where even Ms. Dumberbuttons can use them? Isn’t there a point where we should just say, fuck this! If you can’t figure out how to my application perhaps you are just too dumb to use it? Do we really need to scrape every single bit of functionality and power out of an application before it is deemed “idiot proof” enough to be released?

Do you know why crybabies out there constantly whine that Linux is not ready for the desktop? That’s because most people involved with open source project have some intuitive grasp of what I said above. They know that you have to draw a line at some point and refuse to dumb the application down any further. Pandering to Ms. Dumberbuttons needs is very time consuming, difficult process. Especially since months of research and development staff result in only mildly smaller amount of confusion on her part and no visible increase in productivity. The smart thing to do is to cut your losses and hope that Ms. Dumberbuttons boss will come to his senses and move her into a position which does not require computer skills.

What we are doing right now is counter productive. By investing so much into WYSIWYG we created an interface which is actually deceptively difficult to master and use properly. I really don’t see why Ms. Dumberbuttons couldn’t have a cheat sheet with markup commands on her desk instead of a cheat sheet which tells her which buttons and menu items to click on. Perhaps it would not be so bad. Perhaps it would actually be easier for her to learn bunch of textual formating directives than to navigate the menus and tool bars and dealing with the quirks caused by invisible characters in her text. But alas, that won’t happen. We are stuck with WYSIWYG. Hell, there is a WYSIWYG editor in my Wordpress for Christ’s sake. For what? For the 4 or 5 HTML tags actually allowed? It is like a joke. Fortunately there is a way for me to switch back into regular HTML editor and use that. And this is all I’m really asking for. You can have a WYSIWYG editor, but give me a way to actually use the markup language that it uses internally. This way both power users and idiot users will be happy.

Using Dropbox without Gnome

Wednesday, October 15th, 2008
dropbox.gif

If you haven’t heard about Dropbox you have probably been living under a rock for the last month or two. It is the latest and the greatest file syncing project out there. I usually describe it to people as a cross between rsync and web 2.0 application. Only more intuitive. The concept is simple - Dropbox gives you a free 2GB of space on their server. You install their client, add a computer to your account and designate a folder on your drive. Anything in that folder will be automatically synced up with Dropbox’s server almost in real time. Trust me it is fast!

That’s not all though. If you add more than one computer to your account, Dropbox will automatically sync the files from all of them. So the latest change you do on your desktop will be seamlessly pushed out to your laptop, and your work computer. You don’t really have to do anything - you just save files into your dropbox folder and they get updated everywhere. And if you are away from your machines, you can access your files via their web interface. It’s great.

Naturally, you should be concerned with privacy issues but that’s what encryption is for. I wouldn’t put any sensitive data in that special folder without encrypting it first. But that’s besides the point. The service just works, and has clients for Windows, Apple and Linux. Well, almost.

Here is my problem with the service - the Linux client is heavily dependent on Gnome and Nautilus. This sucks for me, because I’m a die-hard KDE user who runs Kubuntu. I checked what it would take for me to install Nautilus and ended up with over 200 packages that needed to be downloaded. Nope! I’m not doing that. I decided to pass on the Gnome client and wait for a KDE or at least a command line version. There is a project to develop KDE client on Launchpad but it seems to be in very early stages of development. It might actually be abandoned or simply parked for future use. I have been checking it almost daily for like a week now, and I have yet to see any activity there.

So while my windows boxes have been seemlesly syncing school related files (ppt slides, handouts, etc..) my Kubuntu laptop was cut off from the fun. I had a client running in the Virtual Windows XP that I have on that machine but it’s not the same. It was annoying. Today my problem was solved by Mr. Deepak who wins 1 Internet for his solution which turned out to be astonishingly simple:

  1. Download the generic linux binaries
  2. Un-tar them and put the .dropbox-dist folder in your home diretory
  3. Run ~/.dropbox-dist/dropboxd to initiate the graphical configuration dialog, and add your computer to the account
  4. Finally do: ln -s ~/.dropbox.dist/dropboxd ~/.kde/Autostart/dropboxd to always run dropboxd daemon at login

No Gnome needed. You don’t get fancy little sync icons on your files, and you don’t get a taskbar doodad that will let you know whether or not the syncing up finished but the daemon works. Files are getting uploaded to the dropbox server without any issues or interruptions behind the scenes. I can’t believe I didn’t think of ever trying that. It was so simple!

Some Dolphin/Konqueror integration would be nice of course but I don’t mind dealing with background process magic for now. As long as my files are getting synced in the mysterious dropbox way I’m happy. Thanks Deepak!