Articles

 123456  Next page

News 6 years Ago
 
Published by packi on in Technology

Since the beginning of this year (that’s 2012, in the case I’m not writing any articles for a year, again) I’ve been working with Python. It took some time getting used to the indentation but since then I’m really enjoying it. One reason is that it allows you to do complex things extremely simple.
I had to write a pool for some objects that needed to be thread-safe. Thats what I came up with:

class Pool(object):
    def __init__(self, items):
        self.queue = Queue(len(items))
        for item in items:
            self.queue.put(item)

    @contextmanager
    def item(self):
        item = self.queue.get()
        try:
            yield item
        finally:
            self.queue.put(item)

Usage:

p = Pool([SomeObject()])
…

with item = p.item():
    item…

The item gets returned right after it has been used, without any knowledge about the pool.
 

 
News 7 years Ago
 
Published by packi on in Technology

…you might want to check if you’re calling pthread_detach somewhere along the lifetime on that thread. If you don’t detach the thread the internal pthread structures will keep being allocated and leaked until you hit PTHREAD_THREADS_MAX threads.
At this point pthread_create will fail on each call.

 
News 8 years Ago
 
Published by packi on in digitalSTROM
  • Tag support for devices added, including support in JS and the SetBuilder.
  • Worked on socket support and learned much about boost::asio in the progress. TcpSocket is functional (at least the parts covered by tests) but still missing the server parts.
  • Got used to using gitorious.
  • Released 0.7.6, a bugfix release which should enable non-git users to communicate with their demo-sets again.
  • Had to answer (and still have to reply to) some support mails, a clear sign that people are starting to use the code.
 
Published by packi on in Others

If you ever need to get a bank clearing number from a IBAN string, this page will help you complete your quest ;-)

 
Published by packi on in digitalSTROM

This week was rather short with me having a day off, but that’s what we’ve accomplished last week in digitalSTROM Server (dSS) development:

  • Some Documentation added (yeah it’s still a bit thin for my taste too…)
  • Wiki cleaned up
  • Released 0.7.5
  • Rewritten meterings polling-loop to be event-based
  • Set-up & moved to gitorious.digitalstrom.org
  • Updated the developer page
  • Closed some resolved issues that weren’t closed in a long time
 
Published by packi on in digitalSTROM

At the digitalSTROM.org Developer Day (last Friday) we’ve officially opened up our git repository, allowing everyone to access the software. It might be of little use at the moment as the hardware is still not available (for sale anyway) but since we’ve got a simulation built into the dSS you can actually develop cool stuff without having access to the hardware.

As it’s not yet officially linked anywhere, here a short link collection to get you started:

  • Redmine for bug-tracking and wiki
  • Update: Git repository: git://gitorious.digitalstrom.org/dss/dss-mainline.git
  • Mailinglists

If you’re not familiar with git you can download our latest release (0.7.5) here.

 
Published by packi on in Technology

Today I had to code something up that checks if a socket got closed on the other end, without touching the data if it’s still up and running. I came up with the following lines:

  bool isSocketAlive(const int _socketHandle) {
    uint8_t tmp;
    bool result = true;
    int res = recv(_socketHandle, &tmp, 1,  MSG_PEEK | MSG_DONTWAIT);
    if(res == -1) {
      if((errno != EAGAIN) && (errno != EINTR) && (errno != EWOULDBLOCK)) {
        log("lost connection", lsInfo);
        result = false;
      }
    } else if(res == 0) {
      // if we were still connected, recv would return -1 with an errno listed above or 1
      log("lost connection", lsInfo);
      result = false;
    }
    return result;
  } // isSocketAlive
 
Published by packi on in Quotes

“Show me a man who cannot be bothered to do the little things, and I will show you a man who cannot be trusted to do the big ones.”
– Lawrence Bell, Founder Bell Helicopter

 
Published by packi on in Packi.ch

Today, I moved over to a new server at Hetzner. So this is a delayed test of the new setup as well as a test if I’m still able to post something.

 
News 9 years Ago
 
Published by packi on in Quotes

“L’histoire est une suite de mensonges sur lesquels on est d’accord.”
– Napoleon Bonaparte

 
Published by packi on in Quotes

“Talking about music is like dancing about architecture.”
– Laurie Anderson
 

 
Published by packi on in Technology

Cool page that pictures the state of the SVG support in today’s and tomorrows browsers: http://www.codedread.com/svg-support.php.

IE is lagging way behind while the nightly-builds of WebKit and Opera are moving on to near complete support. Firefox lacks most of the animation features but I was surprised that 3.0 already supports features like filters.

 
Published by packi on in Technology

If you’re ever running out of diskspace on your gentoo system, be sure to remove old kernel sources. I just removed > 20 and freed about 10 gigabyte.

 
Published by packi on in Quotes

“If a cluttered desk is a sign of a cluttered mind, then what are we to think of an empty desk?”

– Albert Einstein

Shamelessy copied from an article on timesonline.co.uk: Messy? I’m an artist!

 
Published by packi on in Technology

Last night I was tinkering with the source-code of kdelibs to make the thumbnail generation optional/configurable. No point in having truecrypt if your documents get thumbnailed and stored directly in your home. It ruins your deniable encryption[1] if your desktop tracks every move you make. Except if your desktop cleans up after it has run.
But then you’ve got the problem of files still lying around in unallocated inodes on your hard-drive.

One solution to this problem is to create a file containing all zeroes or just random data, fill your partition up till the brink and delete the file. This will overwrite everything you wanted to hide from the eyes from your room-mates, your geek-girlfriend or your oppressive government. And as recent studies have shown[2] [3] it’s perfectly secure to overwrite the data just once.
The problem is, it takes forever to write gigabites of zeroes to our hard drives.

This morning I’ve had this idea:

  • All inodes that get deallocated have to be stored in the free inodes table to be reused (nothing new here).
  • If an inode gets deleted put it in tthe table but flag it as “dirty” (as in still containing data).
  • If your filesystem needs to allocate inode it should prefer the dirty ones.
  • On shutdown (or periodically) go through your “dirty” inodes and fill them with zeroes.
  • Life life in happiness and peace.

The performance impact should be minimal as you don’t need to zero out the inodes that you’re reusing[4].


[4] Well that’s no entirely true, an inode that’s not used up fully may still contain compromising data. But this might be fixed by zeroing the last block of a continous inode-allocation (e.g. if the request is for 10 inodes, just zero out the last one).

 123456  Next page