Skip to content

Instantly share code, notes, and snippets.

View mythagel's full-sized avatar

Nicholas Gill mythagel

  • Melbourne, Victoria, Australia
View GitHub Profile
// (c) 2020 Nicholas Gill GPLv3
#include <cstdio>
#include <cstdint>
#include <cstring>
template <typename CharT, unsigned N>
class KMPStream
{
public:
bool begin(const CharT* search, size_t size)
#include <cstdint>
#include <cstdio>
#include <stdexcept>
#include <vector>
// C compatible external api
extern "C" {
// Input / Output value types
enum {
@mythagel
mythagel / spiral_morph.cpp
Created September 1, 2016 01:49
Spiral morph toolpath
#include <cmath>
#include <vector>
#include <iostream>
struct point_2
{
double x;
double y;
point_2 operator-(const point_2& p) const {
@mythagel
mythagel / tailstock_die_holder.scad
Created May 17, 2016 09:27
tailstock die holder
module thread_die() {
cylinder(h=6, r=20/2);
}
$fn=32;
difference () {
cylinder(h=12, r=24/2);
translate([0,0,(12-6)+0.1]) thread_die();
translate([0,0,-0.5]) cylinder(h=12+1, r=12/2);
translate([5,0,12/2 + 6/2]) rotate([0,90,0]) cylinder(h=11, r=4/2);
/*
* main.cpp
*
* Created on: 22/03/2012
* Author: mythagel
*/
#include <cstdio>
#include <cstdlib>
#include <sys/types.h>
#include <sys/stat.h>
/*
g++ -std=c++11 boost_units.cpp -o boost_units
*/
#include <iostream>
#include <boost/units/systems/si/prefixes.hpp>
#include <boost/units/systems/si/length.hpp>
#include <boost/units/systems/si/io.hpp>
#include <boost/units/systems/si/velocity.hpp>
@mythagel
mythagel / gist:5219207
Created March 22, 2013 05:40
bittest.cpp
#include <iostream>
#include <cstdint>
#include <cstring>
int main()
{
uint64_t hi;
uint64_t lo;
if(hi & 0x8000000000000000ULL)
@mythagel
mythagel / cmake.l
Created March 1, 2013 05:38
Extracted CMake lexer
%{
#include <stdio.h>
#include <errno.h>
int file_num;
int file_num_max;
char **files;
extern int errno;
%}
%pointer
@mythagel
mythagel / CMake.abnf
Last active December 14, 2015 01:59
CMake ABNF grammar
; CMake list file grammar
newline = CR / LF / CRLF
whitespace = SP / HTAB / newline
comment = "#" *CHAR newline
wspc = whitespace / comment
identifier = ( ALPHA / "_" ) 1*( ALPHA / DIGIT / "_" )
escape-char = "\\" ( "\\" / DQUOTE / SP / "#" / "(" / ")" / "$" / "@" / "^" / ";" / "t" / "n" / "r" / "0" )
@mythagel
mythagel / v8_wrap_class.cpp
Last active October 15, 2023 17:45
Complete example of binding a C++ class with Google V8.
/*
* v8_wrap_class.cpp
*
* Created on: 14/01/2013
* Author: nicholas
* License: public domain
*/
/* CMakeLists.txt
project(v8_wrap_class)