Skip to content

Instantly share code, notes, and snippets.

View rowanj's full-sized avatar
🐧
Seizing the machines of production

Rowan James rowanj

🐧
Seizing the machines of production
View GitHub Profile
@rowanj
rowanj / XVM.xc
Last active August 29, 2015 13:57
My XVM configuration
/**
* Config was created in XVM Editor v0.7417
* at Sat Mar 15 14:02:43 GMT+1100 2014
*/
{
"configVersion": "5.0.1",
"editorVersion": "0.74",
"definition": {
"author": "rvalue (based on QuickyBaby)",
"date": "15/03/2014",
@rowanj
rowanj / dct_weak.h
Created December 29, 2011 01:01 — forked from Abizern/dct_weak.h
ARC macros for weak references
#ifndef _DCT_WEAK_H
#define _DCT_WEAK_H
// Macros for portable support of notionally weak properties with ARC
// Forked from https://gist.github.com/1354106
// Updated by Rowan James
// Available at https://gist.github.com/1530868
// Defines:
// dct_weak to be used as a replacement for the 'weak' keyword:
// @property (dct_weak) NSObject* propertyName;
@rowanj
rowanj / gist:1688354
Created January 27, 2012 11:25
Regex to match any decimal number in source files
([+-])?(0|[1-9][0-9]*)(?:\.([0-9]+))?(?:[Ee]([+-])?(0|[1-9][0-9]*)(?:\.([0-9]+))?)?
#import <iostream>
struct Octree {
Octree() : index(created++){}
void print_index()
{
std::cout << "print_index() " << index << std::endl;
}
int index;
static int created;
// istreamLikeClass is
boost::iostreams::filtering_streambuf<boost::iostreams::input> in;
boost::iostreams::gzip_decompressor decompressor;
in.push(decompressor);
in.push(is);
stringstream ss (stringstream::in | stringstream::out);
@rowanj
rowanj / gist:3004098
Created June 27, 2012 13:35
Using multiple Boost pools with a class heirarchy
struct Base{virtual ~Base(){}; int x;};
struct Derived : public Base {int y;};
#import <boost/pool/object_pool.hpp>
namespace pools
{
boost::object_pool<Base> Base;
boost::object_pool<Derived> Derived;
}
@rowanj
rowanj / gist:3004102
Created June 27, 2012 13:36
Using a single Boost.Pool with a class heirarchy
struct Base{virtual ~Base(){}; int x;};
struct Derived : public Base {int y;};
#import <boost/pool/pool_alloc.hpp>
template <typename T>
T* construct()
{
T* result = reinterpret_cast<T*>(boost::pool_allocator<Base>::pool_allocator::allocate(sizeof (T)));
@rowanj
rowanj / gist:3023854
Created June 30, 2012 13:54
Default arguments aren't overloads
#include <iostream>
using namespace std;
// #include <some header>
void foo(int x, int y);
// but we always use y = 2 with foo
void foo(int x, int y = 2);
int main()
@rowanj
rowanj / SharedPtrEx.hpp
Created October 12, 2012 05:09
Shared pointer implementation that throws exceptions on NULL
//
// SharedPtrEx.hpp
// Phere Shared Ptr
//
// Created by Rowan James on 12/10/12.
// Copyright 2012 Rowan James. All rights reserved.
//
#ifndef PHERE_UTIL_SHARED_PTR_HPP
#define PHERE_UTIL_SHARED_PTR_HPP
@rowanj
rowanj / Tue 6 Nov 2209.note.html
Created November 6, 2012 12:08
Testing IE 8 specific notebook rendering
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1">
<title></title>
<meta name="notebook-annotation-version" content="2">
<style type="text/css">.page {
/* PAGE BACKGROUND */
background: white;