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 Cell < ActiveRecord::Base | |
composed_of :extent, :class_name => "Vector", :mapping => %w(extent_x extent_y extent_z), :constructor => Proc.new { |x,y,z| Vector.elements([x, y, z]) } | |
def as_json(options={}) | |
{:name => self.name, :id => self.id, :extent => [self.extent_x, self.extent_y, self.extent_z]} | |
end | |
end |
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
// very basic embedded Ruby interpreter for C++ programs | |
// thrown together by Jeff Trull <[email protected]> based on googling and asking questions on #ruby-lang | |
#include <ruby.h> | |
// access to C variables | |
static VALUE getter(VALUE ns, VALUE var) { | |
return Qfalse; | |
} | |
VALUE setter(VALUE ns, VALUE var, VALUE val) { |
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
// testcase for nice error messages in lexer-based parser | |
#define BOOST_SPIRIT_USE_PHOENIX_V3 | |
#include <iostream> | |
#include <sstream> | |
#include <boost/spirit/include/phoenix.hpp> | |
#include <boost/spirit/include/lex_lexertl.hpp> | |
#include <boost/spirit/include/lex_lexertl_position_token.hpp> | |
#include <boost/spirit/include/qi.hpp> | |
#include <boost/spirit/include/support_istream_iterator.hpp> |
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
// Example of running Ruby in a separate thread | |
// 2012-01-08 by Jeff Trull <[email protected]> | |
#include <iostream> | |
#include <queue> | |
#include <string> | |
#include <set> | |
#include <boost/thread.hpp> | |
#include <boost/thread/mutex.hpp> |
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 <sstream> | |
#include <iostream> | |
#include <boost/spirit/include/lex_lexertl.hpp> | |
#include <boost/spirit/include/lex_lexertl_position_token.hpp> | |
#include <boost/spirit/include/support_istream_iterator.hpp> | |
// if this gets defined, my parse passes and all input is consumed | |
// #define BOOST_SPIRIT_DEBUG | |
// if it is not defined, my parse passes but not all input is consumed |
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
// Attempt at making a Boost grammar that successfully parses Jason Shankel's predicate logic language | |
// #define BOOST_SPIRIT_DEBUG | |
#include <boost/spirit/include/qi.hpp> | |
#include <boost/variant/recursive_variant.hpp> | |
#include <boost/fusion/include/adapt_struct.hpp> | |
#include <boost/spirit/include/phoenix.hpp> | |
#include <boost/optional.hpp> | |
// start with the AST |
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
// Test of odeint using intersignal coupling | |
// Jeff Trull <[email protected]> 2012-05-16 | |
#include <vector> | |
using namespace std; | |
#include <boost/numeric/odeint.hpp> | |
using namespace boost::numeric; | |
typedef vector<double> state_type; |
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
.title NGSpice coupling simulation circuit for comparison with odeint | |
* by Jeff Trull <[email protected]> 2012-05-25 | |
*** passive subcircuit module representing the driver impedances, traces, and receiver loads | |
*** (leaves input voltages to caller) | |
.subckt coupling_testcase aggdrv vicdrv aggrcv vicrcv gnd | |
+ raggdrv=100 ragg1=1k cagg1=100f ragg2=1k cagg2=100f caggl=20f | |
+ rvicdrv=100 rvic1=1k cvic1=100f rvic2=1k cvic2=100f cvicl=20f | |
+ ccoup=100f |
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 <memory> | |
#include <boost/thread.hpp> | |
#include <thread> | |
#include <map> | |
#include <vector> | |
typedef std::map<std::size_t, boost::thread> ThreadContainer; | |
// this one produces the same error: | |
// typedef std::vector<std::pair<std::size_t, boost::thread> > ThreadContainer; |
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
// experiments for varying class member function behavior with | |
// class template args, member template args, and member function overloads | |
// Jeff Trull 2012-08-23 | |
#include <string> | |
#include <iostream> | |
template<typename T> | |
struct Foo { |
OlderNewer