Skip to content

Instantly share code, notes, and snippets.

@bcardiff
bcardiff / mini_test.cpp
Created March 18, 2013 01:38
mini test header framework for C++
#ifndef MINI_TEST
#define MINI_TEST
/*
Mini Test for C++
author: Brian J. Cardiff
1. Create simple test cases.
@bcardiff
bcardiff / scoped_cache.rb
Created March 7, 2013 16:07
Rails Scoped Cache allows seamless usage of cache island that can be deleted at once. Also default expiration could be achieved by cache options. Further reference: http://quickleft.com/blog/faking-regex-based-cache-keys-in-rails
class ScopedCache
attr_reader :name
def initialize(cache, name, options = nil)
@cache = cache
@name = name
@options = options
end
def read(key)
@bcardiff
bcardiff / svg.rb
Created January 11, 2013 17:17
SVG Generator spike with same RVG API from RMagick. (output svg xml only)
require 'rexml/document'
class SVG
def initialize(width, height)
@doc = REXML::Document.new
@doc << REXML::XMLDecl.new
@svg = @doc.add_element 'svg'
@svg.add_attribute 'xmlns', 'http://www.w3.org/2000/svg'
@svg.add_attribute 'width', width
@bcardiff
bcardiff / aed2_tests.h
Created November 28, 2012 19:07
tp3 test
#ifndef AED2_TESTS_
#define AED2_TESTS_
#include <iostream>
#include <sstream>
using namespace std;
string mt_bool_to_s(bool b) { return b ? "true" : "false"; }
#define MT_MAKE_ERROR(lhs, rhs, line) { ostringstream os;os << "error en linea " << (line) << endl;os << " se esperaba: " << (rhs) << endl;os << " se obtuvo: " << (lhs);throw os.str(); }
void mt_assert(bool lhs, bool rhs, int line) { if (lhs != rhs) { MT_MAKE_ERROR(mt_bool_to_s(lhs), mt_bool_to_s(rhs), line) } }
@bcardiff
bcardiff / tests.cpp
Created September 19, 2012 19:44
tp0 test
#include "anillo.h"
#include "aed2_tests.h"
template<typename T>
string to_s(const Anillo<T>* a) {
ostringstream os;
os << *a;
return os.str();
}