Grouping filter for AngularJS

  April 6, 2014

I wanted to create a bootstrap layout with multiple rows and columns through AngularJS. In order to do that, every six items or so a new row would have to be created, containing the next six list items.

This of course requires slicing the list into groups of six and iterating over those groups at the row level. My idea was then to implement a grouping filter, that could be used as follows:

<div class="row" ng-repeat="group in items | inSlicesOf:6">
  <div class="col-xs-6 col-md-2" ng-repeat="item in group">
    ...
  </div>
</div>

After some not-quite-working experimentation and a (to me) somewhat obscure error
Error: 10 $digest() iterations reached. Aborting!
I stumbled upon a snippet, that does exactly what I need:

myModule.filter('inSlicesOf', function($rootScope) {
  return function(items, count) { 
    if (!count) {
      count = 1;
    }
 
    if (!angular.isArray(items) && !angular.isString(items)) {
      return items;
    }
 
    var array = _.groupBy(items, function(val, index) {
      return Math.floor(index / count);
    });
 
    if (angular.equals($rootScope.arrayinSliceOf, array)) {
      return $rootScope.arrayinSliceOf;
    } else {
      $rootScope.arrayinSliceOf = array;
    }
 
    return array;
  };
});

(Note that this requires Underscore.js)

Highly available Samba on Ubuntu 8.04

  October 3, 2009

This is something I worked on over the last few days. I was confronted with a particular network infrastructure, where a central Samba fileserver stores all important business data. Of course there is a working backup strategy, however – that server being a single point of failure – the situation wasn’t quite optimal. Usual failure recovery times where as long as 2 days over which the critical data was only partly available. Thus the idea was born to move Samba onto a high availability setup. It’s implemented as a two-node cluster using Ubuntu 8.04 Server Edition, DRBD and Hearbeat.

In this article I will guide you through all the necessary steps to implement such sytem.

Read More

Fedora LiveCD without CD drive

  February 12, 2009

Yesterday I wanted to give the new Fedora 11 alpha a spin. Unfortunately it seems that Virtualbox doesn’t like Fedora – the system would always run unusably slow.
I started looking for a way to run the LiveCD without actually using a CD. Ubuntu has some good documentation on that, but I could not find anything similar for Fedora. So I had to figure it out myself and after a little tinkering I present to you the simple instructions on how to boot Fedora LiveCD’s from hard disk.

  1. Download the LiveCD
  2. Mount the CD Image and copy its contents to an unused partition (this *should* work with a in-use partition actually… but don’t blame me for lost data) like so:
    $ mkdir /tmp/fedora-cd
    $ mount -o loop F11-Alpha-i686-Live.iso /tmp/fedora-cd  # as root
    $ mkdir /tmp/installer
    $ mount /dev/sda4 /tmp/installer  # as root
  3. Now you have to edit your boot loader configuration. For grub this will typically be done in a file called /boot/grub/menu.lst or something like that. Add the following lines:
    # adjust these settings for the device you're actually using
    title Fedora 11 Alpha LiveCD
    root (hd0,3)
    kernel /isolinux/vmlinuz0 root=/dev/sda4 rootfstype=auto ro liveimg quiet rhgb
    initrd /isolinux/initrd0.img

Now you can boot into the LiveCD from the according Grub menu entry.

On the Theme Hospital project

  May 13, 2008

There’s a new comment on one of the theme hospital posts.

Just wondering. Is this project still going on? Hospital could do with an open source (enhanced) version.

I know some people are busy on it at http://www.rounddonut.co.uk/ but this project is going very very slow.

F

Now here is my answer:

Unfortunaltely I haven’t had much time for this lately. But indeed, there was some progress just a week ago – I made a few additions and cleanup-work in the wiki and also worked a bit on the viewer-program. When there was some good progress about a year ago, I initially expected other interested people would build upon my findigs. This has not been the case yet. Well…. I think there will be more stuff going on, but it may take some time – at least for the reverse engineering, as I kinda ditched the open-source-clone thing for now.

The latest THViewer brings improvements in file-handling and a completely Java based RNC decompressor. If you’re interested in the sourcecode, you can get it from GitHub:

git clone https://github.com/alexandergitter/THViewer.git

Seam Carving

  November 25, 2007

Intro and Overview

If you have already seen the video on content aware image resizing at seamcarving.com then you probably know what seam carving is. If not, I recommend you to do so.

Seam carving is a method to resize an image that takes the images content into account – and can therefore produce really great results. This is my attempt to provide the reader with an easy to understand explanation of how seam carving works.

Read More

Mensaessen auf Knopfdruck

  November 8, 2007

Mein aktuelles kleines Miniprojekt (ich wollte mal was mit Ruby und GTK+ machen) ist fertig geworden. Ein Programm was den tagesaktuellen Mensaplan anzeigt, und auch das tagesweise Vor- und Zurückblättern erlaubt.

Kleiner Screenshot:

Sehr einfaches Script, vor allem dank Glade und Hpricot.

Litter, Shadow, Heads and Sound

  July 30, 2007

I’d say this looks quite Theme Hospital’ish doesn’t it?

The few things that were done since the last post:

  • figured out how shadows and litter is represented in a savegame
  • I worked out how the animation layers are stored; this is why the people have heads and different clothes on the new screenshot
  • soundfiles; yeah right! I messed with the sound files format and I now know how this works… well at least to a large extent

And as always I also updated the wiki and implemented the new stuff in my TH Viewer. Get the latest version here.

Outlook

With the last bits waiting to be uncovered comes the time to think about the next steps.

Finish the savegame format

The next coupe of days/weeks are still mainly for finishing up the reverse engineering and getting the wiki in the right shape. Savegames are crucial in getting a feeling for “how Theme Hospital does stuff” without having to go through many painful debugging sessions. So that is something I’d like to get done.

Finish other reverse engineering

Not too much left and not really that importent – unless of course we want a clone that is fully compatible with the original game.

Toolchain evaluation

I will probably stick with java for a programming language, however I’m still not quite sure what graphics/media libraries to use. SDL may be a good choice but I also consider choosing a LWJGL based engine.

Spread the word

I already received an email from Ted Tycoon recently, who expressed his interest in the project. I would also like to see what other people have to say and if there are more players and developers interested.

Savegame rendering

  July 25, 2007

The last days I did some work on the savegame format. It’s far from complete, but I thought it would be nice to share some progress. Click on the image to the right.

As you can see there are still some things to do – but I guess that it’s all not that complicated. Note that this is not a playable game – it is just a rendered image, using the information from a savegame.

I also updated the wiki with the new information.

Looks like Theme Hospital

  June 23, 2007

I have made some good progress on the reverse engineering of theme hospital’s data formats since the last time I wrote about it. My “Theme Hospital Viewer” is now able to render animations and maps.

Still, there are some unknown pieces to the whole specification. But my guess would be that we are now at about 75% done and nearly all files classified by their format. By now it should be already possible to begin a theme hospital clone – if not even complete it.

So without further ado, I present to you:

The Sourcecode of THViewer is included in the archive. I’ve also included a Win32 Binary and the sourcecode of dernc. Please read the readme.

A word of warning: the source code of THViewer is quite a hack and the whole thing is more like a proof of concept / test-tool. It is by no means “user friendly”.

Was ich so gemacht habe

  April 3, 2007

Die letzten Wochen habe ich mich hautpsächlich mit dem Programmieren einer etwas aufwändigeren Java Applikation beschäftigt. Zunächst sollte es nur darum gehen, eine Exceltabelle mit vorgegebenem Format ein ein anderes vorgegebenes Format zu konvertieren.

Mit der Zeit stellte sich jedoch heraus, dass hier gewisse Faktoren eine Rolle spielen, die mir das Ganze nicht so einfach machen würden.

Kleiner Überblick

Gegeben war eine Beispielexceltabelle, die dem Format der anderen verwendeten Exceltabellen entsprach. Desweiteren hatte ich ein etwa zwanzigseitiges Dokument, in dem das Zielformat spezifiziert war.

Das Problem mit Exceltabellen: Prinzipiell sind sie nicht strukturiert. Es gibt für die Zeilen und Spalten kein festgelegtes Format, und ein Benutzer kann Daten in eine Zelle schreiben, die – bezogen auf das Zieldateiformat – nicht viel Sinn machen. Aufgrund der Tatsache, dass es keine eindeutige Abbildung von Quell- auf Zieldaten gibt, musste eine grafische Benutzeroberfläche her. Der Anwender soll die Möglichekeit bekommen, die konvertierten Daten nachträglich nocheinmal zu bearbeiten und, wo nötig, zu korrigieren.

Read More

Contact

Alexander Gitter
contact at agitter de