Skip to content

Instantly share code, notes, and snippets.

View dirvine's full-sized avatar

David Irvine dirvine

View GitHub Profile
@dirvine
dirvine / urls.txt
Created September 11, 2020 10:32 — forked from jgamblin/urls.txt
Top 1000 Domains
google.com
youtube.com
facebook.com
baidu.com
yahoo.com
amazon.com
wikipedia.org
google.co.in
twitter.com
qq.com
@dirvine
dirvine / i3 config
Last active November 28, 2018 15:25
# This file has been auto-generated by i3-config-wizard(1).
# It will not be overwritten, so edit it as you like.
#
# Should you change your keyboard layout some time, delete
# this file and re-run i3-config-wizard(1).
#
# i3 config file (v4)
#
# Please see https://i3wm.org/docs/userguide.html for a complete reference!
@dirvine
dirvine / dummy.cc
Created June 18, 2012 14:22
boost process test
#include <boost/program_options.hpp>
#include <thread>
#include <chrono>
#include <iostream>
namespace po = boost::program_options;
int main(int ac, char* av[]) {
po::options_description desc("Allowed options");
desc.add_options()

Keybase proof

I hereby claim:

  • I am dirvine on github.
  • I am dirvine (https://keybase.io/dirvine) on keybase.
  • I have a public key ASA2eTly6DqSDQl54W0_CvfbASdSiA_xvXcQsl_jnPrQFwo

To claim this, I am signing this object:

@dirvine
dirvine / rust-python-cffi.md
Created September 1, 2016 23:25 — forked from seanjensengrey/rust-python-cffi.md
Calling Rust from Python/PyPy using CFFI (C Foreign Function Interface)

This is a small demo of how to create a library in Rust and call it from Python (both CPython and PyPy) using the CFFI instead of ctypes.

Based on http://harkablog.com/calling-rust-from-c-and-python.html (dead) which used ctypes

CFFI is nice because:

  • Reads C declarations (parses headers)
  • Works in both CPython and PyPy (included with PyPy)
  • Lower call overhead than ctypes
@dirvine
dirvine / myclass.h
Last active December 19, 2015 07:49
FullyOrdered c++11 class (assume that will work in msvc as well as gcc clang)
#ifndef MY_CLASS_H
#define MY_CLASS_H
#include <tuple>
#include <utility>
template <typename T, typename U>
struct MyClass {
T first;
U second;
@dirvine
dirvine / turing.cc
Created February 9, 2013 22:38
turing machine, not sure where this is from I am not the origin author.
/*
* =====================================================================================
*
* Filename: turing.cc
*
* Description:
*
* Version: 1.0
* Created: 30/07/12 19:16:46
* Revision: none
@dirvine
dirvine / max_template.cc
Created February 9, 2013 22:15
template form of max as test
/*
* =====================================================================================
*
* Filename: max_template.cc
*
* Description: simple template example
*
* Version: 1.0
* Created: 25/07/12 19:56:01
* Revision: none
@dirvine
dirvine / check_concept.cc
Created January 24, 2013 08:49
Concept checker
// sfinae test for has ThisFunc() method
template <typename T>
class has_this_func {
typedef char one[1];
typedef char two[2];
template <typename U> static one test(decltype(&U::ThisFunc()); // could also be *U::Routing() for pointer to ThisFunc
// the above gets masked out as sfinae will choose two
template <typename U) static two test(...);
public:
static bool const value = sizeof(test<T>(0)) == sizeof(one);
@dirvine
dirvine / endian.cc
Created January 10, 2013 01:01
Endian calculation (unrestricted union)
union Endian {
char c;
int i;
Endian(void) : i(1) { };
bool big(void) { return !!c; };
} endian;
cerr << (endian.big() ? "big" : "little");