Skip to content

Instantly share code, notes, and snippets.

View olieidel's full-sized avatar

Oliver Eidel olieidel

View GitHub Profile
@olieidel
olieidel / sgp30_bme680.py
Created January 17, 2021 19:48
Ancient python code which I coded ages ago to analyse air quality with the BME680 and SGP30 sensors. Has some nifty calibration stuff in there which I couldn't find anywhere else, at least not in this combination. It was part of a django app, that's why it imports the "models". That's also how it persists data.
import math
import time
import threading
import adafruit_sgp30
import bme680
import board
import busio
from piaq.monitor.models import SensorReading, SensorSettings
# coding: utf-8
# A combined poller / calibrator when reading data from the BME680 and
# SGP30 sensors with a raspberry pi.
import csv
import datetime
import os
import time
@olieidel
olieidel / db.clj
Last active October 3, 2018 21:10
Read and Write H2 DB's TimestampWithTimeZone from Clojure by converting them to instances of java.time.Instant. Requires Java 8.
(ns yourns.db
(:require [clojure.java.jdbc :as jdbc]
;; note the java-time library from
;; https://github.com/dm3/clojure.java-time
java-time)
(:import org.h2.util.DateTimeUtils))
(defn- h2-timestamp-with-timezone->instant
"Convert a h2 `TimestampWithTimeZone` to a `java.time.Instant`."
@olieidel
olieidel / project.clj
Created September 3, 2018 08:52
ClojureScript webpack dependencies
(def foreign-libs
[{:file "src/js/foreign-libs.js"
:provides ["cljsjs.react"
"cljsjs.react.dom"
"cljsjs.three"
"intercom.io"
"material-ui"]
;; see https://clojurescript.org/news/2017-07-30-global-exports
:global-exports '{cljsjs.react React
cljsjs.react.dom ReactDOM
@olieidel
olieidel / delete_recursive.clj
Last active June 4, 2023 16:12
Delete Directories recursively with Clojure in only 4 lines of code.
(ns yourproject.yourns
(:require [clojure.java.io :as io]))
(defn delete-directory-recursive
"Recursively delete a directory."
[^java.io.File file]
;; when `file` is a directory, list its entries and call this
;; function with each entry. can't `recur` here as it's not a tail
;; position, sadly. could cause a stack overflow for many entries?
;; thanks to @nikolavojicic for the idea to use `run!` instead of
@olieidel
olieidel / constants.cljc
Created January 30, 2018 13:03
ClojureScript: read out leiningen project version
(ns your-project.constants
#?(:cljs (:require-macros [your-project.constants :refer [get-app-version]])))
#?(:clj
(do
(def app-version
(System/getProperty "your-project.version"))
(defmacro get-app-version []
app-version))
:cljs
# trying to create an auth request with the microsoft cognitive
# services translator api.
# as seen here: http://docs.microsofttranslator.com/oauth-token.html
# endpoint in question (POST): https://api.cognitive.microsoft.com/sts/v1.0/issueToken
url = "https://api.cognitive.microsoft.com/sts/v1.0/issueToken"
HTTPoison.post! url, "" # empty POST request, no headers
# yields:
# iex> ** (HTTPoison.Error) :closed
@olieidel
olieidel / richhickey.md
Created November 29, 2015 17:09 — forked from prakhar1989/richhickey.md
richhickey.md

Rich Hickey on becoming a better developer

Rich Hickey • 3 years ago

Sorry, I have to disagree with the entire premise here.

A wide variety of experiences might lead to well-roundedness, but not to greatness, nor even goodness. By constantly switching from one thing to another you are always reaching above your comfort zone, yes, but doing so by resetting your skill and knowledge level to zero.

Mastery comes from a combination of at least several of the following:

@olieidel
olieidel / addsqlite.sh
Last active August 29, 2015 14:21 — forked from botris/addsqlite.sh
cordova plugin add https://github.com/brodysoft/Cordova-SQLitePlugin.git