Skip to content

Instantly share code, notes, and snippets.

View ajmontag's full-sized avatar

Andrew Montag ajmontag

View GitHub Profile
@ajmontag
ajmontag / gpio.c
Created November 4, 2012 19:24
A C program that listens for button presses on a Beaglebone GPIO pin and reports the press duration.
/**
* Title: gpio.c
*
* Author: Andrew Montag
* ajmontag@gmail.com
* sites.google.com/site/andrewmontag
*
* Licence: Boost Software Licence - Verison 1.0
* http://www.boost.org/users/license.html
*
@ajmontag
ajmontag / progname.c
Created November 4, 2012 21:18
A simple C program to compare different ways of getting your program's name in unix.
/**
* A simple program to compare different ways of getting your program's name.
*/
#include <stdio.h>
#include <stdlib.h>
extern char* __progname;
extern char* program_invocation_name;
extern char* program_invocation_short_name;
@ajmontag
ajmontag / Finddbus-cxx.cmake
Created November 9, 2012 05:24
Find dbus-cxx
# - try to find the dbus-cxx library
#
# Finddbus-cxx.cmake
#
# Cache Variables: (probably not for direct use in CMakeLists.txt)
# DBUS-CXX_ROOT_DIR
# DBUS-CXX_LIBRARY
# DBUS-CXX_INCLUDE_DIR
#
# Non-cache variables you might use in your CMakeLists.txt:
@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:
@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 / 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 / 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 / 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 / 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 / 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) {}