Archive

Author Archive

Minecraft

October 2nd, 2010 No comments

… is a pretty cool openworld, sandbox game. It is still in the alpha-phase, but it is very promising, and fun.
We definitely need to make a nerdy room server, to built stuff together.

Ars Technica on Minecraft
Official Website
The Dev Blog

Since I am not able to record a video, I’ve included a screenshot of my latest creation. It is 27×27 squares big (which equals about 27×27 meters) and is made of stone and glass.

Categories: fun, games, nerdcore Tags: , , , ,

Yet Another Starcraft 2 Review

August 3rd, 2010 1 comment

Hi there. For quite some time I have been a fan of Warcraft 3 The Frozen Throne, having played over a thousand games. I have been playing over 150 games of Starcraft 2 over the course of the beta and the days since the release. Here is my contrasting review to all the love the game gets. (e.g. the ars review)

At first: Don’t get me wrong. I like the core of the game very much. It’s balanced, it’s fast paced, it has an awesome soundtrack, it has awesome effects, awesome cut scenes and an ok story. And of course it “feels right”.

Once you are out of the actual playing, back in battle.net, or maybe you just logged in: The pain begins: Where the fuck is the battle.net chat? There is some kind of ICQ/MSN. But people not knowing others, playing the game (as I am), cannot chat with anyone since there are no public channels of some sort (as is the case in every other battle.net game).

More things that are wrong:

  • Only one tactical zerg unit – seriously, it’s only about massing. Forget being smart. Other races have more versatile units. Not Zerg. This my second biggest concern. It really comes down to macroing your queens well and putting as many units to fight as possible (and using the right counters goes without saying)
  • Achievements are just plain stupid. There exists more than 200. One for every single click you make. Maybe it’s just me, but I don’t like them. “Wohoo you killed 50 units in 15 seconds” or “Wow, you have 100 larva for producing units”. Things along those lines.
  • You cannot watch replays in less than “normal” speed. Inspection of fights is denied. Highly annoying for the careful analyzer. This was possible in the beta, and is possible in Warcraft 3. There is no reason to switch it off.
  • Zerg units do not make sounds when clicked, they are just silent. Terrans and Protoss are more fun.
  • (My english keyboard layout is wrongly detected as german – just a bug, will be resolved hopefully)
  • In order to watch replays by double-clicking the file, you first have to shut down the game, otherwise nothing will happen. If you then open the replay, you have to first log into battle.net using your password. Useless Annoyance.

My hypothesis is that the chat and tactical zerg unit(s) will follow in the next two releases.

To sum it up: The core game is awesome. But for some (perhaps hidden) reason the game has been split up and annoyance has been added. I really hope that the coming releases will change the picture in it’s favor. We’ll see.

You ask me whether you should buy it? I think you should. The campaign is fun. And online, a world of even more fun is waiting. Do not play Zerg, though! Stick with Terran and Protoss they’re more fun and have the cooler soundtrack.

As a side-note: League of Legends does some of the things important better than Starcraft 2. Try it out. It’s free as in beer and it’s awesome.

A little more Eclipse in Vim

June 13th, 2010 2 comments

I am currently coding Java using Eclipse and what I find particularly helpful is that Eclipse highlights all occurrences of the word under the cursor. So I decided that my favorite editor, vim, should do that too. After a lot of struggling and fiddling I finally understood and got it working.

Here is a quick snapshot what it will look like when we are finished:

snapshot

The following code also serves as a general example on how to use python for scripting vim.

So let’s get started:

First we define a new look for our highlighting. I use simple bold text for that purpose.
Using ctermfg=white and ctermbg=gray (e.g.) you can also adjust the background and foreground color.

 
highlight MyWordUnderCursorHighlight cterm=bold

The second step is to hook up to the proper input events.
Therefor we use the auto command on cursor moved in normal mode (CursorMoved)
and in insert mode (CursorMovedI). The star stands for “every filetype”.
We simply let it call our to-be-defined function for highlighting.

autocmd CursorMoved * call MyHighlightWordUnderCursor()
autocmd CursorMovedI * call MyHighlightWordUnderCursor()

The function for highlighting (explanation in-lined):

function! MyHighlightWordUnderCursor()
" tell vim to use python from now on
python < < endpython
import vim
 
# get the character under the cursor
row, col = vim.current.window.cursor
characterUnderCursor = ''
try:
    characterUnderCursor = vim.current.buffer[row-1][col]
except:
    pass
 
# remove last highlight
vim.command("match MyWordUnderCursorHighlight //")
 
# if the cursor is currently located on a real word, move on and
# highlight it. We don't want to highlight anything when the cursor is not
# on a word.
if characterUnderCursor.isalpha()  or characterUnderCursor.isdigit() or characterUnderCursor is '_':
 
    # expand cword (a keyword in vim) to get the word under the cursor
    wordUnderCursor = vim.eval("expand(\'<cword>\')")
    if wordUnderCursor is None :
        wordUnderCursor = ""
    else :
        wordUnderCursor = "\< " + wordUnderCursor + "\>"
 
    currentSearch = vim.eval("@/")
    if currentSearch != wordUnderCursor :
        # highlight it
        vim.command("match MyWordUnderCursorHighlight /" + wordUnderCursor + "/")
 
# has to be the word after < < in the first line. Ends the python interpreter
endpython
endfunction

all source again

That’s it. Have fun and may the force be with you.

PS: for some reason. wordpress screws up the formatting. Please use the above link for copy and paste

PS2: before pasting indented text into vim use “set paste” / “set nopaste”.

Update:
Here is the vimscript only version: (click)
Thanks bart!

Update 2:

  • words can now also consist of numbers and underscores
  • do not highlight the wordUnderCursor if it is the currently searched term

Categories: software Tags: , , , ,

Howto configure the TrackPoint of the Thinkpad Keyboard

January 13th, 2010 2 comments

To enable scrolling using your TrackPoint read the excellent thinkwiki tutorial.

But in order to get the the new ThinkPad Keyboard (the one without the laptop – just the keyboard) TrackPoint running, use “Lite-On Technology Corp. ThinkPad USB Keyboard with TrackPoint” instead of “TPPS/2 IBM TrackPoint” as a device identifier.

If this still does not work, query xinput using $ xinput list, and search for something that sounds like your device. Use this string for your configuration instead of the thinkwiki suggestion.

logapp (colors output from stderr red, lets everything else pass)

December 16th, 2009 2 comments

What it does: See heading.

$ sudo aptitude install logapp

bashrc:
export LOGAPP_OPTIONS="$LOGAPP_OPTIONS \
--logfile= \
--stdout_clip=-1 \
--stderr_clip=-1"

alias logapp='logapp $LOGAPP_OPTIONS'

alias make='logapp make'

Explanation: The alias for logapp itself is a little construction, which I use to modify a programs default parameters.
In this case it is needed to tell logapp to not clip any output and to not log anything to a file.

This is tool is pretty neat for make and will certainly proof useful from time to time.

Have fun

addendum:
Aside from the weird defaults, this program seems to mix up lines. stderr and stdout are not ordered correctly. What the hell?
Tool abandoned for now.

Categories: linux, software Tags:

Moar Links

September 20th, 2009 No comments
Categories: Uncategorized Tags:

Reading List on Software Management

July 16th, 2009 No comments

I recently came across the Fog Creek Reading List, which presents 75 books on software management. Additionally, Podcast#12 of Stackoverflow.com comments some of them.
Since I am always looking for interesting literature (mostly on processes of software development) and sometimes run out of ideas, I took the time to go through a good part of this list and add some books, taken from cross references.
It is a mix of management-, accounting-, psychology-, selling- and inspirational books plus stories about software companies/startups. If you are just doing a quick browse, I recommend the Fog Creek list – it has pictures.

Remarks:

  • means No information gathered
  • 0-5 ratings, (+ = 0.5 on amazon)
  • Pricing is from amazon.de
  • Please excuse the formatting 8[

download link

Categories: management, software Tags: , ,

DOS #2: Vim Tips

June 10th, 2009 2 comments

I have been using vim for development for over half a year now and want to share my setup and some commands I use on a daily base. To understand the article you need basic knowledge of how vim works.

Overview:

Name: Vim (Vi IMproved)
Version: 7.2
URL: http://www.vim.org/

How to set default options:

In the .vimrc file, default options can be set. This file is located in your home directory. e.g. ./home/user/.vimrc. There also is a global vimrc: /etc/vim/vimrc.

Default Option Set:

  • Abandon vi compatibility. Needed to get all the extras of vim.
    set nocompatible
  • Backspace is allowed to remove indentions, end of lines and starts.
    set backspace=indent,eol,start
  • Do not create backup files.
    set nobackup
  • Set the length of the history (accessed through arrow up and down, while typing a :-, /- or ?-command) to 400 entries.
    set history=400
  • Show the current cursor position in the status line.
    set ruler
  • Display incomplete commands in the status line.
    set showcmd
  • Display the current mode in the status line.
    set showmode
  • Visually jump to the matching opening bracket for a short time, when typing a closing bracket.
    set showmatch
  • Show intermediate search results, while typing a search term.
    set incsearch
  • Do not insert two spaces after a ‘.’, ‘?’ and ‘!’ with a join command.
    set nojoinspaces
  • Disallow all keys to move to the next line. See :help whichwrap for more information.
    set whichwrap=""
  • Use filetype-specific indention, if possible.
    filetype plugin indent on
  • Enable syntax highlighting. Vim is able to highlight more than 200 distinct filetypes.
    syntax enable
  • Highlight all search hits. Use :nohls to turn it off.
    set hlsearch
  • Indent intelligently, automatically – My favourite indention mode.
    set autoindent
  • Replace tabs with spaces.
    set expandtab
  • How many spaces is a tab?
    set tabstop=4
  • How many spaces is an indention.
    set shiftwidth=4
  • Show line numbers.
    set number
  • Always use the default color scheme.
    colorscheme default
  • Highlight trailing spaces and @todos.
                                                                                                                                         
    match Todo /\s\+$/                                                                                                                        
    match Todo /@todo/                                                                                                                        
    
  • Jump to end of the file, if opening a log file.
                                                                                                                                         
    :augroup somethinguseful                                                                                                                  
    :au BufReadPost *.log normal G                                                                                                            
    :augroup END                                                                                                                              
    

Copy’n’Paste:

                                          
set nocompatible                    " deactivated compatibility to vi
set backspace=indent,eol,start      " what is the backspace allowed to delete
set nobackup                        " do not keep a backup files, use versions instead
set history=400                     " keep 400 lines of command line history          
set ruler                           " show the cursor position all the time           
set showcmd                         " display incomplete commands                     
set showmode                        " show in which mode we are in the status line    
set showmatch                       " visually jumps the matching bracket when typing closing brackets
set incsearch                       " do incremental searching                                        
set nojoinspaces                    " do not insert a space, when joining lines                       
set whichwrap=""                    " do not jump to the next line when deleting                      
filetype plugin indent on           " if there is an indention plugin matching the filetype, use it   
syntax enable                       " syntax highlighting on                                          
set hlsearch                        " highlight all search hits                                       
set autoindent                      " indent intelligently automatically                              
set expandtab                       " expand tabs to spaces                                           
set tabstop=4                       " how many spaces make one tab                                    
set shiftwidth=4                    " how many spaces to indent, using < and >                        
set number                          " show line numbers                                               
colorscheme default                                                                                   

match Todo /\s\+$/                  " highlight trailing white spaces
match Todo /@todo/                  " highlight doxygen todos        

:augroup somethinguseful
:au BufReadPost *.log normal G " jump to the end of the file if it is a logfile
:augroup END                                                                   

Commands:

Since vim has a multitude of commands, having a cheat sheet is a must. Here is my favorite: Graphical Cheat Sheet.
Disclaimer: The following commands are likely to be more powerful than shown here.
This is only a narrow view on which commands and command combinations I use every day.

Legend

  • [] : optional argument
  • <> : mandatory argument
  • count : any number
  • movement : any movement command. e.g.: w,b,e,ge,arrows,^,$,…
  • {v} : being in visual mode
  • {i} : being in insertion mode

Movement

  • w, b : Move to the first character of the next/previous word.
  • e, ge : Move to the last character of the next/previous word.
  • /<find>/, ?<find>? : Search the term <find> forward/backward.
  • //, ?? : Repeat the last search.
  • *, # : Search the word under the cursor forward/backward.
  • n, N : Jump to the first letter of the next hit. I often use this in conjunction with the . command (The dot will be explained later on.)
  • :[no]hls : Switch off/on the highlight for the previous search. Use this when you are done with your search to not get distracted by the highlight.
  • % : Jump between matching starting and ending bracket.
  • ^ : Jump to the first non-blank character of this line.
  • [count]G : Jump to line [count]. Jump to the start of the file if [count] is omitted.
  • gg : Jump to the end of the file.

Editing

  • i,a : Switch to insertion mode before/after the current position.
  • I,A : Switch to insertion mode at the begin/end of the line.
  • [count]r<replacementcharacter> : Replace the [count] next characters with [count] <replacementcharacter>s starting at the current cursor position.
  • R : Switch to replacement mode.
  • c[count]<movement> : Delete the next [count] <movement>s and switch to insertion mode. I very often use cw.
  • cc : Change the whole line and preserve the indention.
  • d[count]<movement> : Delete the next [count] <movement>s. I very often use dw.
  • dd : Remove the current line.
  • J : Join the current line with next.
  • :0,$ s/<find>/<replace>/g : starting from line 0, ranging to the last line: Replace all appearances of <find> with <replace>.
  • . : Repeat the last insertion command. This is a very powerful tool, when you have to change something similarly in multiple places!

Formatting

  • [linecount]>>, [linecount]<< : Indent the next [linecount] lines, starting with the current.
  • {v} [indentcount]>, [indentcount]< : Indent the selected lines by [indentcount] indents.
  • {v} = : Automatically indent the selected lines according to the filetype’s rules.

Copy’n’Paste

Vim has an automatically changing clipboard. It changes on every deletion/change of anything. E.g.: d,x,c,s,…

  • y[count]<movement> : yank/copy the next [count] <movements>. I very often use y[count]w to copy whole words.
  • yy : Yank the current line.
  • p, P : Paste after/before the current position.
  • {i} Alt+p : Paste before the current position and leave insertion mode.

Tabbing

  • vim -p [files] : Open vim opening one tab for each file specified.
  • :tabnew [file] : Open a new tab, loading file [file].
  • :tabdo <command> : Execute command <command> in each tab separately.
  • :tabmove [count] : Move this tab to position [count] or to the last position if no [count] is specified.
  • Ctrl+Page Up, Ctrl+Page Down : Switch between tabs.

Visual Mode

  • v : Switch to visual mode.
  • V : Switch to visual mode, selecting whole lines.
  • Ctrl+v : Switch to visual mode, selecting whole blocks. For example to comment out a block in c++, you just need: Ctr+v (select some lines vertically) I // Esc Esc. This puts // in each of the selected lines at the current column.
  • gv : Restore the last selection.

Miscellaneous

  • u, Ctrl+r : Undo, Redo
  • Ctrl+p, Ctrl+n : Word completion searching forward/backward. This command also searches through included header files in c/c++.
  • :mks[!] <file> : Save the current session to file <file>.
  • vim -S <sessionfile> : Start vim using session <sessionfile>.
  • :set [no]paste : Switch on/off auto indention. Use this when pasting already indented text into vim.

This is probably too much to remember at once, so I suggest you have a look at this once in a while and try to apply one feature at a time. If you got used to it, move on to next.
Happy Coding!


Categories: DOS, software Tags: ,

Displaying Enum-Names instead of Values in Errors

June 4th, 2009 1 comment

The usual lazy developer likes to print out plain error messages, which contain pure numbers and don’t mean anything. The most prominent example is Windows itself, back in the old days.

Some time ago I was once again faced with the decision how to handle errors in our plug-able class design. While trying to find a good solution I remembered an old blog post – Qt is able to create a mapping from enum integer values to their respective names. So I fiddled around a bit and came up with a pretty neat solution, which requires virtually no extra code to gain a little more meaningful error messages than plain integer values.

Here is what I came up with:

You need to sub-class an error base class, insert your error enumeration, and tell Qt that you need the value-to-name mapping for this enum. All the extras come with the base class.
If you don’t like the rest of the class, you might just want to check out BaseError::identifierToName(). That’s where the magic is happening.

A usage example:

 // --- header file ---
 class HorseError : public BaseError
 {
     Q_OBJECT
     Q_ENUMS(x)
 public:
     enum x { DOES_NOT_WANT, IS_INJURED };
 };
 
 class Horse
 {
 public:
     HorseError error;
 
     void ride();
 };
 
 // --- source file ---
 void Horse::ride()
 {
     error.activate(HorseError::DOES_NOT_WANT, "cannot happen anyways");
 }
 
 // --- using ---
 
 Horse mybeautifulhorse;
 mybeautifulhorse.ride()
 
 // operator() returns a bool
 if (mybeautifulhorse.error()) {
    // operator QString makes the error readable
    qDebug() < < mybeautifulhorse.error;
 
    exit(1);
 }

The Header File – BaseError.hpp

#ifndef BASE_ERROR_HPP
#define BASE_ERROR_HPP
 
class BaseError : private QObject                                                                                                         
{                                                                                                                                         
    Q_OBJECT
public:
 
    BaseError();
    virtual ~BaseError();
 
    /** @returns whether the error is active */
    bool active() const;                       
    /** @returns the identifier (an enum) */   
    int identifier() const;                    
    /** @returns the name of the identifier enum e.g. "MyErrorClass::MyReturnValue" */
    QString name() const;                                                             
    /** @returns the description given by activate's second parameter */              
    const QString& description() const;                                               
 
    /** throw the error */
    void activate(int identifier, const QString& description = QString());
    /** clear the state / remove the error */                             
    void deactivate();                                                    
 
 
 
    /** alias for active() */
    bool operator()() const; 
 
    /** @returns 'name() "description()"' e.g.
     * 'MyErrorClass::MyReturnValue "something meaningful"'
     */                                                    
    operator QString() const;                              
 
signals:
 
    /** emitted when the error has been activated */
    void activated();                               
 
protected:
 
    /**
     * Default implementation generates a string using the
     * "DerivedErrorClassName::EnumeratorValueName"       
     *                                                    
     * @note                                              
     * reimplement this functions to apply an own         
     * identifier-to-error-name-mapping                   
     */                                                   
    virtual QString identifierToName(int identifier) const;
 
private:
 
    bool m_active;
    int m_identifier;
    QString m_description;
};
 
 
#endif

The Source File – BaseError.cpp

#include "BaseError.hpp"
#include <qmetaenum>
 
BaseError::BaseError() : QObject(), m_active(false)
{                                                  
}                                                  
 
 
BaseError::~BaseError()
{                      
}                      
 
 
bool BaseError::operator()() const
{                                 
    return m_active;              
}                                 
 
 
BaseError::operator QString() const
{                                  
    return QString("%1 \"%2\"").arg(name()).arg(description());
}                                                              
 
 
int BaseError::identifier() const
{                                
    return m_identifier;         
}                                
 
 
QString BaseError::name() const
{
    return identifierToName(m_identifier);
}
 
 
const QString& BaseError::description() const
{
    return m_description;
}
 
 
void BaseError::activate(int identifier, const QString& description)
{
    m_identifier = identifier;
    m_description = description;
    m_active = true;
 
    emit activated();
}
 
 
void BaseError::deactivate()
{
    m_active = false;
}
 
 
QString BaseError::identifierToName(int identifier) const
{
    QStringList ret;
 
    const QMetaObject* meta = metaObject();
 
    for (int i=0; i < meta->enumeratorCount(); ++i) {
 
        QMetaEnum enumerator = meta->enumerator(i);
 
        enumerator.key(identifier);
 
        ret < < QString("%1::%2").arg(enumerator.scope()).arg(enumerator.key(identifier));
    }
 
    return ret.join(", ");
}


Categories: c/c++, qt, software Tags: , , , , ,