Skip to content

Instantly share code, notes, and snippets.

View hrafnkelle's full-sized avatar

Hrafnkell Eiríksson hrafnkelle

View GitHub Profile
@hrafnkelle
hrafnkelle / getQuakes.js
Created March 16, 2021 16:37
Retreive and print quake date and size from the Icelandic Met office
// run with node:
// node getQuakes.js 3.5
// to get all quakes over M3.5
async function getQuakesFromMetoffice(minimumQuakeSize) {
const axios = require('axios');
let pageHtml = await axios.get('https://vedur.is/skjalftar-og-eldgos/jardskjalftar/reykjanesskagi/#view=table');
lines = pageHtml.data.split('\r\n');
let VI = {quakeInfo: undefined};
live_loop :first do
play :c3
sleep 0.25
end
live_loop :second do
play :e3
sync :first
end
@hrafnkelle
hrafnkelle / EventBus.py
Created December 14, 2017 22:01
Minimal event bus?
import asyncio
from collections import namedtuple
Event = namedtuple('Event',['source','data'])
observers = {}
def register(source, callback):
observers.setdefault(source,[]).append(callback)
@hrafnkelle
hrafnkelle / .gitignore
Last active December 7, 2017 13:22
Experiment with asyncio reading of w1 sensor and aiohttp interface
.vscode
Include
Lib
Scripts
tcl
@hrafnkelle
hrafnkelle / app.R
Created February 8, 2015 20:23
Demonstate how lubridate fails to parse a date that depends on locale on shinyapps.io which only has the C locale
library(shiny)
library(lubridate)
dateStr1="2015/02/08"
dateStr2="2015 Feb 8"
# Uncomment to make it work on windows if not on english locale
# Perhaps each shinyapps.io app should have a locale configuration?
# Sys.setlocale("LC_TIME","English")
@hrafnkelle
hrafnkelle / camserv.py
Created December 1, 2014 12:05
HTTP server for Raspberry Pi Camera
import time
import http.server
import picamera
import datetime as dt
import shutil
from fractions import Fraction
HOST_NAME = 'raspiplus.lan'
PORT_NUMBER = 9000
@hrafnkelle
hrafnkelle / gist:5142295
Created March 12, 2013 11:46
Running this with the busted testing framework makes the busted runner hang with 100% cpu load
local M = {
a=function(self,msg)
self:b(msg)
end,
b=function(self,msg)
print(msg)
end
}
describe("Description", function()
@hrafnkelle
hrafnkelle / find_if_test.cpp
Created May 8, 2012 22:14
This is an attempt to learn how to use both find_if and C++ lambda functions to find an element in a collection using an anonymous predictate
// This can be compiled with a recent g++ (version > 4.5 I belive) by issuing
// $ g++ -std=c++0x -o foo find_if_test.cpp
#include<iostream>
#include<vector>
#include<algorithm>
struct Record
{
int a;