Skip to content

Instantly share code, notes, and snippets.

View mikeando's full-sized avatar

Mike Anderson mikeando

  • DownUnder GeoSolutions
  • Perth
View GitHub Profile
#ifndef ma_concurrent_queue_h
#define ma_concurrent_queue_h
// Based on code from http://www.justsoftwaresolutions.co.uk/threading/implementing-a-thread-safe-queue-using-condition-variables.html
// Original version by Anthony Williams
// Modifications by Michael Anderson
#include "boost/thread.hpp"
#include <deque>
@mikeando
mikeando / include_grapher.py
Created September 24, 2010 04:24
Source code include visualiser for c++
#!/usr/bin/python
import sys
import os.path
import re
# Use this like this:
# cppfind . -l autogen | grep -v test | python include_grapher.py | neato -otest3.pdf -Tpdf -Goverlap=scale -Gstart=rand
# you can replace neato with dot or any of the other graphvis commands
# What the example does is finds all files using autogen in them anywhere, and graphs who includes what (directly)
@mikeando
mikeando / prepare-commit-msg.py
Created May 18, 2011 04:15
Simple git prepare-commit-msg
import sys
import subprocess
import re
# A normal commit will just have two arguments, this filename and the filename
# of the commit message we want to change. Any other kind of commit we'll be
# cowardly about and just leave as is.
if len(sys.argv)!=2 :
sys.exit(0)
@mikeando
mikeando / fast_sin.cpp
Created May 24, 2011 10:03
fast sine approximations
#include <math.h>
#include <stdio.h>
// P Found using maxima
//
// y(x) := 4 * x * (%pi-x) / (%pi^2) ;
// z(x) := (1-p)*y(x) + p * y(x)^2;
// e(x) := z(x) - sin(x);
// solve( diff( integrate( e(x)^2, x, 0, %pi/2 ), p ) = 0, p ),numer;
//
@mikeando
mikeando / fiddle.css
Created June 2, 2011 03:14
Javascript data bindings using closures
We couldn’t find that file to show.
@mikeando
mikeando / fiddle.css
Created June 2, 2011 03:51
Javascript data bindings via closures
We couldn’t find that file to show.
@mikeando
mikeando / build_html.bash
Created June 2, 2011 12:06
Another batch of javascript MVC prototyping
echo "<html><head><script src=\"jquery-1.6.1.js\"></script><script>" > data_binding2.html
cat fiddle.js >> data_binding2.html
echo >> data_binding2.html
echo "</script></head>" >> data_binding2.html
echo "<body>" >> data_binding2.html
cat fiddle.html >> data_binding2.html
echo >> data_binding2.html
echo "</body></html>" >> data_binding2.html
@mikeando
mikeando / Makefile
Created June 24, 2011 02:36
Example for failing compile on system symbol usage
all: should_work.x should_fail.x
should_fail.x : should_fail.o fncheck.o
gcc should_fail.o fncheck.o -Xlinker -dead_strip -o should_fail.x
should_work.x : should_work.o fncheck.o
gcc should_work.o fncheck.o -Xlinker -dead_strip -o should_work.x
should_fail.o : should_fail.c
gcc -c should_fail.c
@mikeando
mikeando / Demo.c
Last active March 20, 2024 10:47
Example of using C++ from C.
#include "HMyClass.h"
#include <stdio.h>
void my_eh( const char * error_message, void * unused)
{
printf("my_eh: %s\n", error_message);
}
int main()
{
@mikeando
mikeando / README.md
Last active December 18, 2019 08:34
Output buffer as binary, similar to xxd in java

Simple XXD Style output from a ByteBuffer.

Refactored here without testing, so probably no-longer compiles - but should be a good starting point should I need it again.