The Mimic Pendant Lamp

This is a prototype for a dining table pendant lamp. A camera monitors what’s underneath the lamp and tries to mimic the colors it sees with the LED:s on the top of the lamp. This creates a somewhat matching ambient light in the room. It is made from oak wood and it uses a Python script on a Raspberry PI Zero W for the image analysis. The drawback is that the boot time is close to 20 seconds....

May 13, 2020 · Peter Krantz

Visualizing Statistics in Minecraft

Data about public sector spending is often hard to understand and compare. Statistics about government is often presented in tables. In this hack I have used open data from Eurostat (the EU statistics agency) about government expenditure for a set of countries and rendered sets of boxes in a Minecraft world. This makes it possible to explore the data by walking (flying) around the world. Boxes for expenditure data is ordered as General public services, Defence, Public order and safety, Economic affairs, Environment protection, Housing and community amenities, Health, Recreation culture and religion, Education, Social protection....

August 5, 2012 · Peter Krantz

Rails vs Grails vs Django models

Coming back to Rails after being away from some time in Django land I discovered a huge difference in how Rails, Grails and Django treats your models. In Django and Grails you can look at a model class and see all the properties it has: [python] class Organization(models.Model): name = models.CharField(max_length=255) url = models.URLField(verify_exists=False) orgtype = models.ForeignKey(OrgType) [/python] The same model class in Rails typically looks like this: [ruby] class Organization < ActiveRecord::Base belongs_to :OrgType end [/ruby]...

June 24, 2009 · Peter Krantz

Integrating Yahoo Search in a Django site in 5 easy steps

I have been experimenting with various search options for the eutveckling.se site for a while. Google Custom Search is nice and very fast, but the number of ads appearing in the search result page makes it difficult for users to separate result items from ads. (Update: I am sticking with Google Custom Search until I figure out how to get Yahoo search to present proper excerpts). I am a fast reader which comes with the tradeoff of missing important information sometimes....

December 18, 2008 · Peter Krantz

Improving Django performance with better caching

The Django cache middleware is great, but has one drawback. If you are caching views (which can give a nice performance boost) Django will only use the path segment of the URL to create a cache key. If you are an avid reader of RFC 3986 you may remember that a URI consists of multiple components; path and query being of special interest here. The problem is documented in ticket 4992 (Update: it is now in Django)....

November 2, 2008 · Peter Krantz

Stuff I learned over the weekend

1. Finding stuff in lists of dicts in Python If you have a list of dicts in Python like this: [python]items = [{“id”:1, “name”: “Rasmus”}, {“id”: 2, “name”: “Rick”}][/python] …and want to check if there are any dict items with an id of a specific value (e.g. 2) I first came up with this: [python]2 in map(lambda x: x[‘id’], items)[/python] The downside is that it will loop all items which may be inefficient for larger lists....

October 27, 2008 · Peter Krantz

Come celebrate Niklas Lindström's birthday

You may ask yourself “who is that?” or “wtf?!” but the fact is that in the near future he will have a much greater impact on your life than you may think. Here is why you should head over to his blog and post a random comment about Yak shaving and, if possible, create a link containing the words “Yak shaving” pointing to his blog. With a little bit of effort and luck Google will pick it up and Niklas will be the number one result for people from inner Mongolia....

February 12, 2008 · Peter Krantz

Software architects as management deadwood

Two interesting quotes from Dietrich Kappe: So no, we don’t hire architects. We hire developers. In a small team, there is no room for management deadwood. I agree completely. My view is that the title “Software architect” is a misnomer for what most architects in the software industry do, or at least what they should be doing. It is part of the weird trend that career advancement means getting away from actual programming for some reason....

February 2, 2008 · Peter Krantz

Hackety Hack - The Foundation for a Revolution

Why the lucky stiff is a well known name among most Ruby developers. Many have read his Ruby programming tutorials and seen his spectacular performances (or whatever they are) at RailsConf and elsewhere. Personally, I owe him a lot for Hpricot, the liberal HTML parser (at my previous government agency Verva we used it to run the quarterly test of all public websites in Sweden). Hpricot is also the default parser for the Ruby Accessibility Analysis Kit....

July 9, 2007 · Peter Krantz

First impressions of Mercurial (as an alternative to subversion)

So, I was in the mall the other day where I bumped into Marcus Ahnve. He mentioned that he had been using Mercurial instead of Subversion for his latest project. Just before I met Marcus I had been coding on a rails project housed in subversion. I was sitting in a cafe without internet access which means that it wasn’t possible to commit changes to subversion. As my son was asleep time was scarce and I wanted to get as much done as possible....

May 4, 2007 · Peter Krantz