Skip to content

Instantly share code, notes, and snippets.

View krichardsson's full-sized avatar

Kristoffer Richardsson krichardsson

  • Bitcraze AB
  • Malmö Sweden
View GitHub Profile

Keybase proof

I hereby claim:

  • I am krichardsson on github.
  • I am krichardsson (https://keybase.io/krichardsson) on keybase.
  • I have a public key whose fingerprint is 4535 9909 0180 64B7 1D84 B93D A9C9 475D B071 7717

To claim this, I am signing this object:

@krichardsson
krichardsson / number.coffee
Last active August 29, 2015 14:16
Dashing number widget that changes color based on the direction of the arrow
class Dashing.Number extends Dashing.Widget
@accessor 'current', Dashing.AnimatedValue
@accessor 'difference', ->
if @get('last')
last = parseFloat(@get('last'))
current = parseFloat(@get('current'))
if last != 0
diff = Math.abs(Math.round((current - last) / last * 100))
"#{diff}%"
@krichardsson
krichardsson / gist:4311eac592a3569fa08a
Created July 10, 2015 12:04
Docker 1.7 osx workaround
boot2docker ssh sudo /etc/init.d/docker restart
One way to enable a docker container to use docker, is to pass the socket for the docker daemon to the container. To make it work you need to:
1. use a container that has the docker cli installed. A dockerfile for that
FROM debian
RUN apt-get update && apt-get install wget -y
RUN wget https://get.docker.io/builds/Linux/x86_64/docker-latest -O /bin/docker
RUN chmod +x /bin/docker
2. mount the docker daemon socket when the container is started docker
@krichardsson
krichardsson / gist:41e125a267624d589613
Last active September 25, 2015 01:30
Populate mysql docker container from sql file
# Create a mysql container
docker run --name myDb -e MYSQL_DATABASE=db-name -e MYSQL_ROOT_PASSWORD=topsecret -p 3306:3306 -d mysql
# Populate it
docker run --rm -it --link myDb:mysql -v ${PWD}:/dump mysql sh -c 'exec mysql -h"$MYSQL_PORT_3306_TCP_ADDR" -P"$MYSQL_PORT_3306_TCP_PORT" -uroot -p"$MYSQL_ENV_MYSQL_ROOT_PASSWORD" --database="$MYSQL_ENV_MYSQL_DATABASE" < /dump/my-dump.sql'
@krichardsson
krichardsson / Readme.md
Created November 23, 2015 14:14
Dashing octoprint integration

Simple octoprint integration for dashing

The status and remaining time is pulled in from octoprint by the client. An image is taken from a webcam and added as background for the widget.

Add to your dashboard

<li data-sizex="1" data-sizey="1">
  <div data-id="octoprint" data-view="Octoprint" data-title="3D printer"></div>
</li>
@krichardsson
krichardsson / pomodoro.coffee
Last active November 24, 2016 00:20
Dashing pomodoro widget
class Dashing.Pomodoro extends Dashing.Widget
ready: ->
setInterval(@startCountdown, 500)
startCountdown: =>
current_timestamp = Math.round(new Date().getTime()/1000)
end = parseInt($(@node).find("#pomodoro-end-time").html())
end_timestamp = Math.round(end / 1000)
seconds_until_end = end_timestamp - current_timestamp
@krichardsson
krichardsson / gist:5d21dcb57715c8322ccdb4c191f7d75d
Created October 17, 2018 17:55
Prototype Position High Level Commander
# -*- coding: utf-8 -*-
#
# || ____ _ __
# +------+ / __ )(_) /_______________ _____ ___
# | 0xBC | / __ / / __/ ___/ ___/ __ `/_ / / _ \
# +------+ / /_/ / / /_/ /__/ / / /_/ / / /_/ __/
# || || /_____/_/\__/\___/_/ \__,_/ /___/\___/
#
# Copyright (C) 2018 Bitcraze AB
#
@krichardsson
krichardsson / lpsTdoa3Tag.c
Last active May 25, 2021 09:46
TDoA3 Hybrid Mode, example implementation
/*
* || ____ _ __
* +------+ / __ )(_) /_______________ _____ ___
* | 0xBC | / __ / / __/ ___/ ___/ __ `/_ / / _ \
* +------+ / /_/ / / /_/ /__/ / / /_/ / / /_/ __/
* || || /_____/_/\__/\___/_/ \__,_/ /___/\___/
*
* Crazyflie firmware.
*
* Copyright 2018-2021, Bitcraze AB