Albin Larsson: Blog

Culture, Climate, and Code

An Awesome List

9th February 2019

sceenshot of list contents

I created one of those “awesome lists” for K-samsök resources, I have personally found awesome lists useful when starting with something new our just needs to investigate useful components a hobby project. Therefor I decided that it might help someone else to have one list for all the best K-samsök projects and resources so that people might get started quicker with one of Europe’s largest Linked Open Data platforms for heritage data.

The list is on Github and licensed under CC0.

Grasping Concepts through Implementations

25th January 2019

I sometimes write code to learn things not at all related to code or technical concepts. It can be an implementation of a concept in math or even a Resting Metabolic Rate calculator. I used this technique quite a lot back when I was in school.

Below I’m providing an example I found while looking through old hard drives during the holidays. It’s Python implementation of the basics of complex numbers. The implementation itself is useless as these features are already built into the Python standard library itself but at the time things like this helped me grasp concepts quickly.

import math

'''
Implementation of Polar and Cartesian coordinates and conversion between them.

These features exists within the Python standard library, this was meant 
for educational purposes.
'''

class ComplexNumber:
    def __init__(self, real, imaginary, polar = False):
        if polar:
            distance = real
            angle = imaginary
            self.real = distance * math.cos(math.radians(angle))
            self.imaginary = distance * math.sin(math.radians(angle))
        else:
            self.real = real
            self.imaginary = imaginary

    @property
    def distance(self):
        return math.sqrt((self.real ** 2) + (self.imaginary ** 2))
        
    @property
    def angle(self):
        multiplier = 1
        if (self.real < 0):
            # Quadrant 2 or 3
            multiplier = 180
        elif (self.real >= 0 and self.imaginary < 0):
            # Quadrant 4
            multiplier = 360
            
        return math.degrees(math.atan(self.imaginary / self.real)) * multiplier

A Five Minute Hack

19th December 2018

Click the link or type runes.rocks into your web browser and you will be directed to a random article about a rune inscription or runestone.

I love small ideas and experiments. They are cheap they scale from a few hours to a few moths. An example I’m often refer to is Kyrksok.se a site we build a few years ago in less then two days.

However runes.rocks and the Swedish version runor.rocks sets a new record. It took me five minutes to buy the domain names and everything up thanks to existing tools.

I bought domain names and pointed the redirect URL to Magnus Manske’s Random article tool and waited for the name servers to update. Done.

Landerydsstenen CC-BY Bengt A Lundberg / Riksantikvarieämbetet Image of a rune stone

I Created Another On this Day API

26th September 2018

screenshot of documentation

There are multiple “On this Day” APIs built on top of Wikipedia but I created yet another one. This API can be used to retrieve birth, deaths, and events for any given day of the year.

The reason for building this was that I wanted something stable with support for things like Cross-Origin-Requests and SSL. The need wasn’t actually mine. A friend of mine sees the potential of “On this Day” information as a possible delighter in everyday contexts and I offered to help.

The data is (because it’s harvested from Wikipedia) licensed under Creative Commons Attribution-ShareAlike 3.0 Unported The API is actually just a collection of pre-generated static JSON files cached and exposed using Cloudflare. So feel free to query without limits.

API Sandbox and Documentation

Older PostsNewer Posts