Skip to content

Instantly share code, notes, and snippets.

@ajmontag
ajmontag / scd30-read.py
Created May 24, 2020
Read from SCD30 Sensor on Raspberry PI
View scd30-read.py
#!/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
View DS18B20.py
# 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
View Egyptian Braces
# find things like this {
# other stuff
# }
\w+.*\{\s*$
@ajmontag
ajmontag / except.cpp
Created Jun 26, 2013
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.
View except.cpp
// 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
Scrapes random wikipedia pages for the last page edit time.
View wiki.pl
#!/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 Dec 14, 2015
POST to Google App Engine Blobstore from CURL easy interface
View postBlob.cpp
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 Nov 13, 2012
A Handy makefile for simple C/C++ applicaitons
View makefile
# 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 Nov 9, 2012
Find SigC++ package in cmake
View FindSigC++.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 Nov 9, 2012
Utilities for finding cmake packages
View LibFindMacros.cmake
# 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 Nov 9, 2012
Find dbus cmake module
View Finddbus.cmake
# - 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:
You can’t perform that action at this time.