Skip to content

Instantly share code, notes, and snippets.

View mikeando's full-sized avatar

Mike Anderson mikeando

  • DownUnder GeoSolutions
  • Perth
View GitHub Profile
@mikeando
mikeando / thiserror_backtrace.rs
Created May 12, 2020 23:51
Example of backtrace usage in thiserror
#![feature(backtrace)]
extern crate thiserror;
use thiserror::Error;
use std::backtrace::Backtrace;
#[derive(Error, Debug)]
pub enum DataStoreError {
//#[error("data store disconnected")]
@mikeando
mikeando / demo.py
Last active November 15, 2019 07:57
Devito comm mismatch
import numpy as np
from dugwave.devitowrap import Function, TimeFunction, Grid, Eq, Operator, configuration, Constant, SpaceDimension, SubDimension, solve
from sympy import Symbol
from mpi4py import MPI
bc_thickness = 4
nx=10
ny=10
dx=0.1
@mikeando
mikeando / mpi_heat_test.py
Created November 8, 2019 07:24
Example bad devito MPI operator
import numpy as np
import cloudpickle
from mpi4py import MPI
from devito import Function, TimeFunction, Grid, Eq, Operator, configuration
configuration["mpi"] = True
configuration["openmp"] = True
pub struct CircularQueue<T> {
queue: Vec<Option<T>>,
head: usize,
tail: usize,
max_capacity: usize,
count: usize,
}
impl<T> CircularQueue<T> {
pub fn new(size: usize) -> CircularQueue<T> {
#include <cerrno>
#include <iostream>
#include <typeinfo>
//Here's a simple function that does exactly what we might expect
void testx( int * errnox ) {
std::cout<<"in testx type of errno = "<<typeid(errnox).name() <<std::endl;
if(errnox) {
*errnox = 7;
std::cout<<"errnox is "<<errnox<<std::endl;
@mikeando
mikeando / README.md
Last active February 4, 2023 01:02
Fraction approximation in C++
@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.

@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 / 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 / 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