Skip to content

Instantly share code, notes, and snippets.

@sickel
sickel / jessie.sh
Last active March 9, 2017 03:38 — forked from subaddiction/jessie.sh
debian 8 live build
#!/bin/bash
# WARNING: to use "--binary-images hdd", see this bug: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=773833
# WARNING: to get persistence encryption working, apply this fix: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=767195
# Italian locale & keyboard, default boot with luks encrypted persistence
# lb config --distribution jessie --debian-installer live --binary-images iso-hybrid --archive-areas "main contrib non-free" --bootappend-live "boot=live persistence persistence-encryption=luks locales=it_IT.UTF-8 keyboard-layouts=it username=utente hostname=D8"
# lb config --distribution jessie --debian-installer live --binary-images iso-hybrid --archive-areas "main contrib non-free" --bootappend-live "boot=live persistence persistence-encryption=luks keyboard-layouts=it username=user hostname=D8"
# Default locale & norwegian keyboard, pxe boot
@sickel
sickel / ROIextract.py
Last active September 19, 2017 09:35
a python script to extract ROI data from a CSV-file exported from radassist as specified in Momorc
#!/usr/bin/python
from __future__ import print_function 
import csv
import sys
#First and last channel for each ROI. Edit as needed:
rois={'Tc99m': [37, 52],
'Ba133': [107,139],
'I131': [113,121],
@sickel
sickel / EPG.R
Last active September 28, 2017 21:07
library(ncdf4)
library(chron)
library(lattice)
library(RColorBrewer)
epspath="C:\\Users\\mortens\\Desktop\\EPS"
scenario=4
ncpath=paste(epspath,"\\",scenario,sep="")
setwd(ncpath)
@sickel
sickel / NuclearTests.csv
Last active January 24, 2018 12:35
A csv file with the number of atmospheric and underground nuclear tests by country and year
Year USatm USudg UUSRatm USSRUdg UKatm UKudg FRatm FRudg PRCatm PRCudg IndiaAtm IndiaUdg PakistanAtm PakistanUdg NKatm NKudg Otheratm Otherudg atm udg all
1945 3 3 0 3
1946 2 2 0 2
1947 0 0 0
1948 3 3 0 3
1949 1 1 0 1
1950 0 0 0
1951 15 1 2 17 1 18
1952 10 1 11 0 11
1953 11 5 2 18 0 18
@sickel
sickel / NuclearTests.R
Last active January 24, 2018 13:46
An R script to make a plot of the number of nuclear tests per country and year
if(!exists("lang")){lang="EN"}
directory="https://gist.githubusercontent.com/sickel/8accd0d2ca32c9f7624e10f4837095f5/raw/f70630c17010bc33407caa3d08dc8d6283bc7f23/"
# or download https://gist.githubusercontent.com/sickel/8accd0d2ca32c9f7624e10f4837095f5/raw/f70630c17010bc33407caa3d08dc8d6283bc7f23/NuclearTests.csv
# and set the directory to where the file is stored.
# Data source: http://www.ldeo.columbia.edu/~richards/my_papers/WW_nuclear_tests_IASPEI_HB.pdf and https://en.wikipedia.org/wiki/List_of_nuclear_weapons_tests_of_North_Korea
# In theory, it should be possible to source this file directly into R from the "Raw" url, for some reason this fails,
# so copy the script and past it into an editor.
@sickel
sickel / README.md
Created May 20, 2019 18:58 — forked from mill1000/README.md
Headless A2DP Audio Streaming on Raspbian Stretch

About

This gist will show how to setup Raspbian Stretch as a headless Bluetooth A2DP audio sink. This will allow your phone, laptop or other Bluetooth device to play audio wirelessly through a Rasperry Pi.

Motivation

A quick search will turn up a plethora of tutorials on setting up A2DP on the Raspberry Pi. However, I felt this gist was necessary because this solution is:

  • Automatic & Headless - Once setup, the system is entirely automatic. No user iteration is required to pair, connect or start playback. Therefore the Raspberry Pi can be run headless.
  • Simple - This solution has few dependencies, readily available packages and minimal configuration.
  • Up to date - As of December 2017. Written for Raspbian Stretch & Bluez 5.43

Prerequisites

@sickel
sickel / deamontest.py
Last active June 4, 2019 19:35
A python deamon that spins of an extra thread and acts on signals
# Concept of daemon that spins of an extra thread and can be controlled by signals
#
# I have rewritten the script slightly after I did this log. So some output has changed a bit,
# the signals are still the same
#
# This has to be run with python3
#
# Developed and tested on debian 9.9 - all modules installed with apt
#
# morten@latlon:/home/disk0/m/GardenController$ sudo tail -f /var/log/messages &
@sickel
sickel / waterfallapplet.java
Created October 30, 2019 07:03
Waterfall - java Keep it here, use some ideas for qgis plugin
import java.io.*;
import java.net.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import javax.swing.*;
/*
(c) Morten Sickel 2010 - 2011
@sickel
sickel / readuluru.py
Created October 30, 2019 13:07
File to import csv-file into postgres
#!/usr/bin/python3
# This script can read a csv-file exported from radassist and insert data into a postgis table to be used by the qgisSpectre plugin
#
# schema.sql creates a appropriate table in a postgis enabled postgresql database
#
# Copyright Morten Sickel, 2019
import sys
import psycopg2
@sickel
sickel / dataleser.py
Last active November 17, 2019 17:30
For å lese krysstabeller
#!/usr/bin/python3
from openpyxl import load_workbook
import sys
filenames=[]
for i in range(1,len(sys.argv)):
print(sys.argv[i])
filenames.append(sys.argv[i])