Skip to content

Instantly share code, notes, and snippets.

View tomas-stefano's full-sized avatar

Tomas D'Stefano tomas-stefano

  • Ministry of Justice, Department for Education
  • London
View GitHub Profile
@tomas-stefano
tomas-stefano / solr.rb
Created February 28, 2014 19:48
Solr Abstraction
module Morpheus
module Adapters
module Solr
class Relation
include ActiveModel::Model
attr_accessor :connection, :relation_class, :where
delegate :present?, :blank?, :empty?, to: :to_a
delegate :each, :map, :collect, :select, :find, :last, :first, to: :to_a
delegate :total, :facet_fields, to: :response
@tomas-stefano
tomas-stefano / unit_test_spec.rb
Created March 24, 2014 21:43
Unit Test spec simple example
require 'active_support/dependencies'
%w(app/business app/enumerations app/marketplace).each do |path|
ActiveSupport::Dependencies.autoload_paths.push(path) unless ActiveSupport::Dependencies.autoload_paths.include?(path)
end
@tomas-stefano
tomas-stefano / inheritance_from_scratch_example.js
Last active August 29, 2015 14:00
Inheritance Javascript from scratch with super call
var Bar, Foo,
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) {
for (var key in parent) {
if (__hasProp.call(parent, key)) child[key] = parent[key];
}
function ctor() {
this.constructor = child;
}
ctor.prototype = parent.prototype;
@tomas-stefano
tomas-stefano / developers.rb
Created August 11, 2014 14:24
Rubyconf T-shirt code
class Rubyconf
event year: 2014, role: :rubyist
end
@tomas-stefano
tomas-stefano / Gemfile
Last active August 29, 2015 14:16
Codebar student Capybara selenium browser starts
source 'http://rubygems.org'
gem 'rspec'
gem 'capybara'
gem 'selenium-webdriver'
gem 'site_prism'
@tomas-stefano
tomas-stefano / Graph Benchmark result
Created February 20, 2010 15:28
Benchmark Ruby Graphs
user system total real
gruff 0.880000 0.040000 0.920000 (0.849686)
scruffy 2.470000 1.910000 4.380000 (3.361562)
@tomas-stefano
tomas-stefano / German_Spec.rb
Created April 1, 2010 01:36
Just a example of german spec in the Rspec Framework
beschreibe Menschen do
vorher(:von_jeder) do
@menschen = Meschen.new(:name =>"Guilherme",:familienname => "Silveira",:alter => 21)
@meggie = Meschen.new(:name =>"Meggie",:familienname => "Simpson",:alter => 6)
@homer = Meschen.new(:name =>"Homer",:familienname => "Simpson",:alter => 35,
:kinder => [@meggie])
end
es "muss den vollständigen Namen zurück" do
# Just a simple example
describe Person do
before(:each) do
@person = Person.new(:name => "Guilherme", :last_name => "Silveira", :age => 21, :children => [])
@meggie = Person.new(:name => "Meggie", :last_name => "Simpson", :age => 6)
@homer = Person.new(:name =>"Homer",:last_name => "Simpson",:age => 35,
:children => [@meggie])
end
ENV["RAILS_ENV"] ||= 'test'
require 'rubygems'
require 'spork'
require File.expand_path(File.join(File.dirname(__FILE__),'..','config','environment'))
require File.expand_path(File.dirname(__FILE__) + "/blueprints")
require 'spec/autorun'
require 'spec/rails'
require 'authlogic/test_case'
@tomas-stefano
tomas-stefano / Fake_DSL_Code.rb
Created April 30, 2010 01:36
Just a Fake DSL Code
# Rake Syntax for RDoc
#
Rake::RDocTask.new do |rdoc|
rdoc.rdoc_dir = "doc"
rdoc.title = "My Gem"
rdoc.options << '--line-numbers' << '--inline-source' << '-A cattr_accessor=object'
rdoc.options << '--charset' << 'utf-8'
rdoc.template = ENV['template'] ? "#{ENV['template']}.rb" : '../doc/template/horo'
rdoc.rdoc_files.include("README", "CHANGELOG")
rdoc.rdoc_files.include("lib/**/*.rb")