Skip to content

Instantly share code, notes, and snippets.

@ajmontag
ajmontag / scd30-read.py
Created May 24, 2020 01:28
Read from SCD30 Sensor on Raspberry PI
#!/usr/bin/env python
# coding=utf-8
#
# Based on https://github.com/UnravelTEC/Raspi-Driver-SCD30
# Copyright © 2018 UnravelTEC
# Michael Maier <michael.maier+github@unraveltec.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# read temperature from DS18B20
# https://learn.adafruit.com/adafruits-raspberry-pi-lesson-11-ds18b20-temperature-sensing/hardware
# TODO command line args for time to run/num iterations
# TODO command line args for output file
# TODO run this on startup so I can run it with no network connection
import re
import datetime
import os
@ajmontag
ajmontag / Egyptian Braces
Created August 22, 2013 16:51
Useful regexes
# find things like this {
# other stuff
# }
\w+.*\{\s*$
@ajmontag
ajmontag / except.cpp
Created June 26, 2013 01:33
A sandbox for expirimenting with the throw() declaration. The moral of the story is that the throws() declaration doesn't provide any distinct advantage to programmers or users.
// A sandbox for expirimenting with the throw() declaration
// Author: Andrew Montag
#include <iostream>
#include <stdexcept>
class ClassA {
public:
ClassA(bool throwOnDestruct) : throwOnDestruct_(throwOnDestruct) {}
@ajmontag
ajmontag / wiki.pl
Created May 22, 2013 16:03
Scrapes random wikipedia pages for the last page edit time.
#!/usr/bin/perl
use strict;
use warnings;
use WWW::Curl::Easy;
use DateTime::Format::Strptime;
use IO::Handle qw( ); # For autoflush
STDOUT->autoflush(1);
@ajmontag
ajmontag / postBlob.cpp
Last active December 14, 2015 03:38
POST to Google App Engine Blobstore from CURL easy interface
void postBlob(const std::string& uploadurl, const std::string& blobstring) {
CURL *easyhandle;
CURLcode res;
easyhandle = curl_easy_init();
if (!easyhandle) {
throw std::runtime_error("Unable to init curl handle");
}
@ajmontag
ajmontag / makefile
Created November 13, 2012 07:17
A Handy makefile for simple C/C++ applicaitons
# Makefile for myProgram
FLAGS = -Wall -g
COMPILEONLY = $(CXX) $(FLAGS) -c $<
LINK = $(CXX) $(FLAGS) -o $@ $+
# All targets to be made
.PHONY: all
all: myProgram
@ajmontag
ajmontag / FindSigC++.cmake
Created November 9, 2012 05:30
Find SigC++ package in cmake
# Andrew Montag <ajmontag@gmail.com>
#
# Borrowed from:
# http://slfsmm.indefero.net/p/meteoio/source/tree/HEAD/tags/MeteoIO-1.0.0/tools/cmake
#
# - Try to find SigC++-2.0
# Once done, this will define
#
# SigC++_FOUND - system has SigC++
@ajmontag
ajmontag / LibFindMacros.cmake
Created November 9, 2012 05:28
Utilities for finding cmake packages
# Andrew Montag <ajmontag@gmail.com>
#
# Borrowed from:
# http://slfsmm.indefero.net/p/meteoio/source/tree/HEAD/tags/MeteoIO-1.0.0/tools/cmake
#
# Works the same as find_package, but forwards the "REQUIRED" and "QUIET" arguments
# used for the current package. For this to work, the first parameter must be the
# prefix of the current package, then the prefix of the new package etc, which are
# passed to find_package.
@ajmontag
ajmontag / Finddbus.cmake
Created November 9, 2012 05:25
Find dbus cmake module
# - try to find the dbus library
#
# Finddbus.cmake
#
# Cache Variables: (probably not for direct use in CMakeLists.txt)
# DBUS_ROOT_DIR
# DBUS_LIBRARY
# DBUS_INCLUDE_DIR
#
# Non-cache variables you might use in your CMakeLists.txt: