This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
uint8_t duckWheel1 = { | |
0x1F, // ##### | |
0x1F, // ##### | |
0x15, // #_#_# | |
0x0E, // _###_ | |
0x1B, // ##_## | |
0x15, // #_#_# | |
0x1B, // ##_## | |
0x0E // _###_ | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# ./totext.rb FILENAME | |
require "rexml/document" | |
puts "Converting #{ARGV[0]}" | |
fin = File.new(ARGV[0]) | |
doc = REXML::Document.new(fin) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static void GenericCallback(Fl_Widget * widget, void * data) { | |
auto cb = static_cast<std::function<void(Fl_Widget *)> *>(data); | |
(*cb)(widget); | |
} | |
template<typename cb_t> | |
void cb(Fl_Widget * widget, const cb_t & cb) { | |
auto wrapped = new std::function<void(Fl_Widget *)>; | |
*wrapped = cb; | |
widget->callback(GenericCallback, wrapped); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdlib> | |
#include <iostream> | |
#include "boost/format.hpp" | |
using boost::format; | |
namespace iter { | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template<typename T> | |
std::tuple<double, double, double, double> stat_test(int ntrials, const T & fn) | |
{ | |
double m = 0, m2 = 0, s = 0, mn = DBL_MAX, mx = -DBL_MAX; | |
int n = 0; | |
for(int j = 0; j < ntrials; ++j) | |
{ | |
double x = fn(); | |
mn = std::min(mn, x); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static inline fstring operator%(const fstring & lhs, float4 rhs) { | |
std::string fs = lhs.next_fmt("f"); | |
fs = (fstring("(%s, %s, %s, %s)")% fs % fs % fs % fs).str(); | |
return lhs.append((fstring(fs)% rhs.x % rhs.y % rhs.z % rhs.w).str()); | |
} |