RSSAmplifier

Blog

Metallapan on Metallapan AB

Recent content in Metallapan on Metallapan AB

metallapan.seRSS feed ↗54 posts

Latest posts

AI agents belong in prison


Last Friday, Opus, which I had allowed `terraform plan` permissions
to help troubleshoot some integration, suddenly asked to do `terraform apply`
even though the plan showed that a production database would get deleted
and recreated (😱), even if I had explicitly instructed
it to help me investigate only, and change nothing. Because it at least
asked, catastrophe was…

Giving Your AI a Memory: Building a Local Knowledge Base with pgvector and MCP


I use Claude Code for most of my development work these days, especially investigations and
quick-and-dirty spikes. For the most part, it's a huge help – until you realise it has no
idea what you talked about yesterday, and Claude.ai does not know what I did in Claude Code.
Every session starts from zero, or by throwing lots of reference material at it, filling the context. 
…

Cleaning sensitive data from test (PG) databases

As someone who both does a fair bit of data engineering jobs for clients with sensitive (and
sometimes really sensitive) data, creating life-like data sets to test, reproduce bugs etc
can be challenging as compliance often dictates that data cannot be accessed for any other
purpose than the primary business case – so no loading to staging databases that can be
reached by testers,…

Creating a one-file Windows service in Python with pywin32 and PyInstaller

I recently set up a brand new Windows service implemented in Python, and although the experience was definitely easier than when I did it last (2006?) there were still a few snags I hit on the way. 
 First, most (all?) of the service examples I found seem to have been copy-pasted from the same source for ten years, and have some strange incantations that does not seem to (no longer) do…

New homepage, new URL for Bitsynchub

I give up. 
 I’ve used home-grown, half-baked, and ‘standard’ static homepage/blog generators, but in the end, I don’t have the time to spend on updating packages in third party solutions, and I don’t have the time – and no longer really the interest – to maintain a platform of my own. 
 So, today I give up and move to WordPress.com, so I can hopefully just have my homepage stable and when…

Provisioning Elasticsearch and Kibana with Terraform

Fair warning up front: this is not a Terraform, AWS, or Elasticsearch tutorial. You’ll need to know a bit or read the docs to apply the examples. 
 When I wanted to add the AWS version of ELK (Elasticsearch, Logstash, Kibana) which is Elasticsearch, Cloudwatch and Kibana, I hit a road block that Terraform did not support provisioning the actual streaming of logs from Cloudwatch to…

What I wish recruiters would do

I spend a lot of time dealing with recruiters – responding to queries, and accepting or rejecting endless amount of LinkedIn contact requests. I mostly agree to those requests, unless it’s obviously a spam account, since you never know what a new contact will give, but a quick review says that way less than 1% of the recruiters who contact me will actually end up signing a new contract. This means…

Another kind of nomad?

I used to enjoy a lot of the writing about digital nomadry, but the more I’ve started living the life I’m aiming for, the more what I read seems to describe an adolescent “workation” while depleting your saving rather than a sustainable career and lifestyle. In the interest of banging my own drum giving a different perspective to a life of travel, I’d like to share our journey so far.

BitSyncHub Open Sourced

A while back, I opened (as in ‘made available’) BitSyncHub , a tool to automatically synchronize Bitbucket repositories to Github. At the time I saw no real reason to open source it – it was a quick hack to solve my own problems, and I felt that anyone else could just reproduce it if they wanted to. 
 Since then, a whole lot of open source projects, including a few big names, has started using…

Slides and videos from Stockholm Automation Nights #1

I was honored to be given the oppurtunity to speak at the first instance of Stockholm Automation Nights last week, and hope to be able to attend many more. I think it was a good mix of talks – my talk was more to the DIY side of automation, Andrey talked about Jenkins delivery flows, and Håkan Rönngren had more of a process and way-of-working focus in his talk on test automation.

PyCon Sweden – get your ticket while it’s hot!

This year’s PyCon Sweden, held on the 12-13th of May at Hilton Slussen in Stockholm, looks to be a spectacular follow-up to last years success. 
 I’m immensely happy that we got two great keynotes – Kate Heddleston and Ian Ozsvald are both amazing speakers – and I’m delighted that we got even more proposals for talks than last year, even though it did increase the amount of work to select the…

PyCon Sweden Call For Proposals – Less Than a Week Left

Since PyCon Sweden was a success last year, we’re doing it again this year, only slightly bigger, hopefully even better! We’ll move in to a prime venue at Hilton Slussen on the waterfront in central Stockholm, and keep aiming for the fantastic Swedish spring weather we had last year, with the conference running on the 12-13th of May. 
 We are accepting proposals until the 16th of February – go…

Call for Proposals: PyCon Sweden 2014!

That’s right, PyCon Sweden 2014 will take place in Stockholm on May 20-21, and you should be there! 
 Even better, you should propose a talk on anything related to Python, and/or see if your company would not like to sponsor the event – this is a chance to reach 250 developers over two days you don’t want to miss. 
 This event will be the first national Python conference in Sweden – a…

Basic Python course in Karlskona

I will be giving a course in basic Python in Karlskrona on March 27. 
 This is a course for those who already know programming, and would like to learn Python from the ground up, or for the developer who has done some work in Python but wants a broader knowledge and foundation. 
 During the course we will work with a strong focus on practical knowledge and learning by doing, so that…

Embedding Jython in Java Applications

I just had an article on Jython embedding appear over at Smartbear .

I accidentally the server

Some of you may have noticed that BitSyncHub (and my company homepage ) went down for almost three days this week. 
 Now, I’m proud of my skills building highly available, fault-tolerant, state-of-the art and bleeding edge systems, deployed on OS, vendor and geographically redundant infrastructure, that never goes down. Sometimes a failover may take a short while, or parts of a system may get…

BitSynchHub now supports git, gitapi released, new hgapi version

Since I got several requests for BitSyncHub to support BitBucket Git repository synching to GitHub, I went ahead and added the functionality. The service will dedtect the appropriate repository type, and push specified branches – although the source branch will be ignored for now, so a branch speficiation of ‘foo:bar’ will simply push ‘bar’. 
 To make this happen, I finally had to bring gitapi…

Synchronize Bitbucket to Github automatically

Introducing BitSyncHub # Since I’m an automation nut, when I found Travis CI , I was understandably excited – automatic running of my testcases for hgapi from the repository as opposed to a pre-push hook (as I have had it set up since the beginning of time) would avoid the oh-so embarrassing mistakes of forgetting to add a new file to the repository and having a non-working version in the repo. I…

See you in Florence this summer?

I’ll be in Florence for EuroPython 2013 and do (more or less) a follow-up to the training session I held last year – a very hands-on venture into Python lanugage and standard library features that will allow you to implement your bad ideas in awesome hacks and good ideas with beautiful magic. This is how fun we had last year! 
 






 
 
 
 
 
…

Batteries included: Download, unzip and parse in 13 lines

The other day I needed to download some zip files, unpack them, parse the CSV files in them, and return the data as dicts. I did the very same thing a couple of years ago, and although the source is lost, I recall having a Python (2.4?) script of about two screens to do the download – so a hundred lines. When re-implementing the solution now that I know Python and the standard library better, I…

WGS-84 distance calculations at the speed of C

When we started with fleet management at Visual Units, one thing was really hard to get right – distance calculations. There was no end of information available, but most-to-all of it was on a level of mathematics far beyond a poor developer who feels that anything beyond discrete mathematics and basic geometry and statistics really should be somebody else’s problem. The implementations that could…

pyRest part 5: You can actually use this

( part 1 , part 2 , part 3 , part 4 ) 
 I’m almost done with the parts to make this project PyPI ready – it can now work on your application as long as you implement the actual code to route calls to the right part of your API – this works: 
 Listing 1. 
 python -m pyrest.launcher –server pyrest.integration.cherry 
–api=pyrest.examples.hg 
 Configuration can also be…

pyRest part 4: Separating the parts

( part 1 , part 2 , part 3 ) 
 I’ve now split the code into separate parts – pyrest.py now only has generic functionality for hooking and routing, along with a bunch of helpers to create responses with HTTP response types. In fact, it’s only 35 lines of code, and that’s the entire ‘core’ of pyRest so far. 
 The CherryPy integration has moved to the pyrest.integration package as cherry.py –…

pyRest part 3: Routing and responsibilities

In part 2 , I hooked up the API to CherryPy in a very crude fashion, and this time we’ll look at how we can add handlers for resources in a less clumsy way. I decided to keep handlers on one ‘level’ only – that is, /sketch/parrot and /sketch will both be handled by the /sketch handler. This is because I find that the same sub-resource often is present in several places (what about /props/parrot ?)…

pyRest part 2: Hooking the API

In part 1 , a very unexciting base CherryPy implementation was all we had, but now it’s time to hook up something real! Instead of creating a mock API to work against as example code, I’ve decided to use hgapi to access the pyrest repo itself as example implementation – very meta! 
 I’ve decided to hook the API in before I refactor the code to separate the web framework from pyRest, since I…

Simple REST-ful (-ish) exposure of Python APIs

After having written code to expose APIs through RESTful web services a couple of times, I’ve decided to do it once more, only this time I won’t get paid, I won’t have deadlines, I’ll write it so I’ll never have to write it again, and I’ll make it available as open source. 
 Problem is, I’m a lazy, lazy person, and have not been able to muster the energy to actually get writing, which leads me…

Sending non-valid names as arguments

I got a feature request on hgapi the other day, pointing out that it was not possible to filter the Mercurial log using the API, since there is no dedicated way to do it and the fallback method – sending keyword arguments that will be passed to the command line – does not work. The signature of the method in question is 
 def hg_log (self, identifier = None , limit = None ,
 template =…

See me on an island!

I’ve really neglected to update the blog lately, but that’s at least in part because I’ve been busy doing preparations for talks – so you could see me instead of read my blog! I’ll be speaking both at PyCon UK and PyCon Ireland , so if you’re going to either come chat with me! And, you know, maybe see my talks… 
 Also, I do have a proper blog post with actual content a-brewing, and I promise…

You should send a presentation proposal to PyCon

Next year, in March, I will be at PyCon. It will be the third time I attend PyCon – ever since I attended my first, not going has not really been an option. 
 There are lots of good things about PyCon – meeting interesting people, seeing San Francisco, beating off recruiters with a stick, hanging out in the hotel bar and chill in the evenings – but the best part is that the talks are so many,…

Using the AST to hack constants into Python

During EuroPython 2012, after my training and talks, I really needed to do some coding, so I started hacking on a ‘practical’ application of the AST – making (some) constants faster than local variables, instead of slower by inlining them on import. 
 To do this, I use a custom importer on meta_path to intercept the import, and find any assignments look like constants – that is, any…

EuroPython impressions

I had a blast at Europython – I made new friends, went to a couple of talks that gave me some ideas for the future, and my own talks seemed to go down well. 
 All in all, the EP2012 organization was great, the food was way beyond ‘normal’ conference fare, and the venue was good – although finding a place to sit down during lunch was hard. 
 I would have liked some kind of feedback…

You deserve practice

I enjoyed The Clean Coder by Uncle Bob , and would recommend it to any serious developer. I agree with almost everything in it, but there is one jarring exception – I disagree strongly with his view that because it’s your own responsibility to practice, you should not do it on paid time. 
 Under the headline “Practice Ethics” , he states: /”Professional programmers practice on their own time.…

Version 1.2.0 of hgapi released

hgapi is a pure-Python API for Mercurial, which uses the command-line interface for maximum compatibility. It is tested for Python 2.7 and 3.2. 
 Version 1.2.0 fixes a few bugs, and allows iterating over a repository as well as using slices ( i.e. repo[0:’tip’]) to get a set of changesets. API documentation is also slightly improved. 
 Special thanks to Nick Jennings and Adam Gomaa who…

Protocol specifications written in Python

This is a writeup of a talk I did recently at Software Passion Summit in Gothenburg, Sweden. 
 Writing a specification in a full-blown programming language like Python has upsides and downsides. On the downside, Python is not designed as a declarative language, so any attempt to make it declarative (apart from just listing native data types) will require some kind of customization and/or…

PyCon 2012 – the other stuff

I have tried to do a full writeup of my PyCon experience this year, and failed miserably, so this is what I’ll do: This post will focus only on the conference experience – lessons learned, sessions attended, and projects discovered will have their own posts; this is the other stuff. 
 So what about the conference as a whole? It was, just like Atlanta last year, an overwhelmingly positive…

[rant] Dare to show your code

My name is Fredrik, and sometimes I write code I’m not that proud of. 
 A friend of mine started on a Python project recently, and when I asked him to put it up on Bitbucket his response was an immediate and not-quite-mock “But then people will see my code!”. I believe this fear of showing one’s code is common, and I believe that it is a problem. Not so much for open source, or anything like…

Python Closures and Decorators (Pt. 2)

In Python Closures and Decorators (Pt. 1) , we looked at sending functions as arguments to other functions, at nesting functinons, and finally we wrapped a function in another function. We’ll begin this part by giving an example implementation on the exercise I gave in part 1: 
 >>> def print_call (fn):
 ... def fn_wrap ( * args, ** kwargs):
 ... print( 'Calling %s with arguments: \n\t…

Python Closures and Decorators (Pt. 1)

Since I, in retrospect, made the wrong choice when cutting down a Python course to four hours and messed up the decorator exercise, I promised the attendees that I’d make a post about closures and decorators and explain it better – this is my attempt to do so. 
 Functions are objects, too. In fact, in Python they are First Class Objects – that is, they can be handled like any other object with…

Blaag using Genshi, greedy bloggers adding ads, and demographics. Also ranting.

(There will be very little techical content here; if that’s what you are looking for, move along) 
 So, I updated Blaag to use Genshi for templating (still in it’s own branch), which was a pretty pleasant experience; I cleared out some of the worst code from blaag.py and ended up with a single html template instead of a host of snippets. 
 I also added a left column to the template (should…

Python API to git: gitapi

Train rides can be good – if not creativity, then at least boredom-induced productivity. I had planned to make a hgapi fork that worked against git instead of Mercurial, and during the ride back from holding a Python workshop in Malmö (a three-hour trip back to Karlskrona; I still have another hour to go…), I finally did. gitapi is born, and even though its in it’s infancy, it supports a large…

Why Python is important for you

I believe that Python is important for software development. While there are more powerful languages (e.g. Lisp), faster languages (e.g. C), more used languages (e.g. Java), and weirder languages (e.g. Haskell), Python gets a lot of different things right , and right in a combination that no other language I know of has done so far. 
 It recognises that you’ll spend a lot more time reading…

Using Python to get rid of .doc

I’ll be appearing att Software Passion to speak about using Python for protocol specifications, instead of using an external document to write the specification, and then try to implement it from there (or, perhaps more common, implementing it and then trying to keep the document up-to-date). 
 A while ago at Visual Units , the situation was this: There was a protocol to transfer data over TCP…

Mercurial in Python 3: promoting hgapi

When I took a look at the python.org Py3k poll , I saw that Mercurial was on the top list of things people wanted ported (though far behind the likes of Django). Now, I don’t know why others want to tie into Mercurial from code, but if a little performance overhead from using the CLI isn’t critical – such as when writing hooks , or just integrating version control in some tool or another, you…

What’s the point of properties in Python?

A few days ago I was asked by a collegaue what the point of properties in Python is. After all, writing properties is as much text as writing getters and setters, and they don’t really add any functionality except from not having to write ‘()’ on access. 
 On the surface, this argument holds as we can see by comparing a simple class implemented with getters and setters, and with properties.

hgapi 1.1.0

As a belated christmas gift, I just released hgapi version 1.1.0. New since 1.0.1 is support for hg status, merge and revert. This means that I right now have no firm plans for the future, as the tool does what I need it to do. If you have other requirements, add them to the issue tracker.

Jenkins

Recently, I wanted to migrate some lightweight services from a virtual host to an account at Webfaction , since running a wiki/issue tracker ( Trac ) and CI server ( Jenkins ) for a couple of low-volume projects really shouldn’t take a whole machine of it’s own. Or should it? 
 This is when I realized that Jenkins is heavyweight in a world of cloud and shared hosts. I already kinda knew, since…

Problem exist between chair and keyboard

It was pointed out to me that an entry was missing. My initial reaction was “No, its not!”, but then had to confess that yes, an entry that had been posted was missing. This was because I’ve developed (and written) for blaag on several computers, and I’d accidently made a closed head tip and lost an update. Maybe I need to add some functionality to make sure that existing posts do not disappear.

Autohook updated

When I linked to autohook the other day, I was not prepared that somebody would actually try it, and tell me that it did not work. 
 So, eating my own dogfood I set up the released version of autohook , to run Blaag generation, and realized that it did, indeed, not work. This is fixed now in version 1.1.0, which also does away with using if __name__: ..." and instead uses setuptools magic to…

Tools for better Python

Tools I use every day to write better Python, to make it more fun, or just easier: 
 A good editor 
 I prefer Emacs , you might like something else, but trust me on this – it’ll be a humongous project that forces you to use a full IDE. If you stay clear of large web frameworks, you might never need it. I started out using PyDev since I was used to Eclipse, but now I just don’t think its…

On useless testing

All testing is not valuable. There. I said it. 
 If you take a look at the source of Blaag, you might notice a certain lack of tests. No unit test, no tests at all in fact. Does this mean I do not believe in unit tests, TDD and testing in general? No! If you take a look at hgapi , for example, I wrote almost all code using TDD since that was the only way to know I got it right.