Skip to content

Instantly share code, notes, and snippets.

View benben's full-sized avatar
🤔
Are we still online?

Benjamin Knofe benben

🤔
Are we still online?
View GitHub Profile
if (option == "Object1")
{
Object1 obj = new Object1();
}
else if (option == "Object2")
{
Object2 obj = new Object2();
}
else if (option == "AnotherObject")
{
@benben
benben / factory.cpp
Created June 28, 2011 16:53 — forked from pyrtsa/factory.cpp
Object factory using Boost.Phoenix, Boost.Function and Boost.SmartPtr libraries
#include <boost/foreach.hpp>
#include <boost/function.hpp>
#include <boost/spirit/include/phoenix.hpp>
#include <boost/shared_ptr.hpp>
#include <iostream>
#include <map>
#include <string>
#include <vector>
struct Parent { virtual std::string hello() const = 0; };
@benben
benben / factory.cpp
Created June 30, 2011 13:46 — forked from pyrtsa/factory.cpp
Object factory using Boost.Phoenix, Boost.Function and Boost.SmartPtr libraries
#include <boost/foreach.hpp>
#include <boost/function.hpp>
#include <boost/spirit/include/phoenix.hpp>
#include <boost/variant.hpp>
#include <iostream>
#include <map>
#include <string>
#include <vector>
struct Object1 { std::string hello() const { return "Hi, Object1"; } };
@benben
benben / main.cpp
Created July 4, 2011 12:18
factory with parameters
#include <boost/foreach.hpp>
#include <boost/function.hpp>
#include <boost/spirit/include/phoenix.hpp>
#include <boost/shared_ptr.hpp>
#include <iostream>
#include <map>
#include <string>
#include <vector>
struct Parent { virtual std::string hello() const = 0; };
#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;
class Object
{
public:
@benben
benben / test.cpp
Created July 11, 2011 09:49
boost::spirit::qi::rule
//works
//output of v with values as expected
bool r = phrase_parse(
first,
last,
double_ % ',',
space,
v
);
template <typename T>
class TextInput
{
public:
TextInput(float* _x, float* _y, string _name, T* _value, bool* _bProcessed, bool* _bIsNodeActive);
...
}
typedef boost::shared_ptr<ds::TextInput<float> > TextInputPtr;
@benben
benben / get.rb
Created September 20, 2011 20:29
#!/usr/bin/env ruby
# encoding: UTF-8
require 'rubygems'
require 'rest_client'
API_KEY = '...'
response = RestClient.get 'http://apileipzig.de/api/v1/district/streets', :params => {:api_key => API_KEY, :limit => 10}
@benben
benben / wordpress.rb
Created September 26, 2011 23:56
pimped octopress wordpress migrator script
require 'rubygems'
require 'sequel'
require 'fileutils'
require 'yaml'
require 'active_support/inflector'
# pimped by http://github.com/benben
# original script from here: https://github.com/mojombo/jekyll/blob/master/lib/jekyll/migrators/wordpress.rb
# some parts stolen from here: http://vitobotta.com/how-to-migrate-from-wordpress-to-jekyll/#importing-from-wordpress
layout title date comments categories
post
test
2011-10-21 15:06
true

test post with äüß