Skip to content

Instantly share code, notes, and snippets.

View cjameshuff's full-sized avatar

Christopher James Huff cjameshuff

View GitHub Profile
#include <iostream>
#include <cstdlib>
#include <cfloat>
#include <cmath>
#include "simpletest.h"
#include "allocator.h"
static Foo * foo = nullptr;
static Mutex fooLock;
Foo * GetFoo()
{
if(!foo)
{
fooLock.Lock();
class Fault: public TerrainFn {
protected:
const float4 center;
const float4 plane;
const float4 displacement;
const float amplitude;
public:
Fault(fn_handle _input, float4 c, float4 p, float amp):
TerrainFn{std::move(_input)},
auto tfn = fn_handle{new TerrainFn};
thickness = 10.0f;
layerIdx = 1;
tfn = fn_handle{new PlaneLayer(std::move(tfn), layerIdx++, elev, 100.0f)};
tfn = fn_handle{new Turbulate(std::move(tfn), turbScl, turbAmp)};
elev += thickness;
layerIdx = igneous;
struct VolumeVal {
uint16_t type;
float field;
};
using fieldfn_t = std::function<float(const vec3 &)>;
using volfn_t = std::function<VolumeVal(const vec3 &)>;
// Result is a function giving one of three possible results:
// the result of fnb (preexisting layers)
uint8_t duckWheel1 = {
0x1F, // #####
0x1F, // #####
0x15, // #_#_#
0x0E, // _###_
0x1B, // ##_##
0x15, // #_#_#
0x1B, // ##_##
0x0E // _###_
};
@cjameshuff
cjameshuff / gist:5903469
Created July 1, 2013 18:47
Pseudo-Smalltalk/named parameters syntax in Ruby
class Thing
def do_something(params)
puts "#{params[:a]}, #{params[:b]}, #{params[:c]}"
end # do_something()
end # class Thing
myThing = Thing.new
myThing.do_something(a: 3.14159, b: 2.71828, c: 1.618033)
#!/usr/bin/env ruby
# ./totext.rb FILENAME
require "rexml/document"
puts "Converting #{ARGV[0]}"
fin = File.new(ARGV[0])
doc = REXML::Document.new(fin)
template<typename cb_t>
void add_handler(const cb_t & cb) {
auto existing = globalEventHandlers[event];
globalEventHandlers[event] = (existing)? []() -> bool {
if(cb())
return true;
return existing();
} : cb;
}
#include <iostream>
#include <cstdlib>
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Box.H>
#include <FL/Fl_Button.H>
#include <FL/Fl_Text_Display.H>
#include <FL/Fl_Multiline_Input.H>