Skip to content

Instantly share code, notes, and snippets.

View objarni's full-sized avatar

Olof Bjarnason objarni

View GitHub Profile
@objarni
objarni / buz.py
Last active August 29, 2015 14:06
A code sketch of a nice simple asynchronous messaging library I'd like to call "Buz" - standing for lots of chatter - buzz, and it's a MessageBus architecturally. And it's a TLA that's nice to say ;)
from buz import Buz, Inbox
buz = Buz()
# Sending a message asynchronously is ridiculously simple
def long_computation(self):
# looong slow algorithm (possibly involving polling I/O ports!)
buz.publish(SomeMessage(..))
# Remember the hell we go through to do things in parallell
@objarni
objarni / domain event class in Python
Last active March 13, 2021 11:26
Simplistic Domain Events Python
# coding: utf-8
import unittest
# Unit tests for kata 'domevent'
''' Synchronous domain events in pure Python.
#- triggering an event
#- registering a callback
#- triggering an event with 1 handler
#- triggering an event with 2 handlers
@objarni
objarni / minddump_bookmarklet.js
Created August 11, 2014 15:23
Mind dump bookmarklet
javascript:{var txt = prompt('Minddumpa vad?'); alert(txt); }
@objarni
objarni / install_hangout.bash
Created July 7, 2014 18:48
Install Google Hangoug plugin
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
sudo sh -c 'echo "deb http://dl.google.com/linux/talkplugin/deb/ stable main" >> /etc/apt/sources.list.d/google.list'
sudo apt-get update
sudo apt-get install google-talkplugin
@objarni
objarni / gist:8c9755f2a5671b9de930
Last active August 29, 2015 14:01
Zoo DDD tests
# Rule 1. Carnivors and herbivors cannot live together.
# For example, moving a lion to an enclosement with a zebra is not good, since the zebra will be eaten.
zoo = Zoo()
zoo.add_fenced_enclosure('Fenced area 1')
zoo.add_fenced_enclosure('Fenced area 2')
zoo.add_carnivore('lion', 'Fenced area 1')
zoo.add_herbivore('zebra', 'Fenced area 2')
assertThrows(zoo.move_animal('lion', 'Fenced area 2'))
# Rule 2: Herbivors can live side-by-side.
@objarni
objarni / homepage.html
Last active August 29, 2015 14:00
Poor mans browser start page
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
<head>
<title>Start page</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<style type="text/css">
@objarni
objarni / CheapDigiSign.html
Last active December 3, 2015 18:22
Poor mans digital sign
<html>
<head>
<title>Poor mans digital sign</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<script>
var urls = [
'http://www.bloggar.se',
'http://www.knuff.se',
@objarni
objarni / setup_objarni_lubuntu_env.sh
Created January 4, 2014 19:42
Setup my own comfy' Lubuntu development environment.
sudo apt-get update
sudo apt-get upgrade -y
sudo apt-get install adobe-flashplugin
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 4E9CFF4E
sudo sh -c 'echo "deb http://repository.spotify.com stable non-free" >> /etc/apt/sources.list'
sudo apt-get update && sudo apt-get install spotify-client-qt -y --force-yes
@objarni
objarni / install_spotify
Created December 31, 2013 16:20
A bash script to install spotify on ubuntu based linux.
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 4E9CFF4E
sudo sh -c 'echo "deb http://repository.spotify.com stable non-free" >> /etc/apt/sources.list'
sudo apt-get update && sudo apt-get install spotify-client-qt
@objarni
objarni / many_ffs.py
Created November 1, 2013 23:38
Hack to run multiple selenium browser at the same time
import multiprocessing
import time
from browserdriver import BrowserDriver
def readfile(fname):
with open(fname) as f:
content = f.read()
#print("Read value " + content + " from file " + fname)
return content