Skip to content

Instantly share code, notes, and snippets.

View tomas-stefano's full-sized avatar

Tomas D'Stefano tomas-stefano

  • Ministry of Justice
  • London
View GitHub Profile
@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 / 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 / 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 / Capybara.md
Last active May 2, 2024 05:16
Capybara cheatsheet

Capybara Actions

# Anchor
click_link 'Save'

# Button
click_button 'awesome'

# Both above
@tomas-stefano
tomas-stefano / .gitconfig
Created August 13, 2013 18:55
A short git config.
[color]
branch = auto
diff = auto
status = auto
[color "branch"]
current = yellow reverse
local = yellow
remote = green
[color "diff"]
meta = yellow bold
@tomas-stefano
tomas-stefano / open_source.markdown
Created July 29, 2013 02:31
Open Source Sprint 1
@tomas-stefano
tomas-stefano / Gemfile
Created July 22, 2013 02:19
jRuby + Puma
source 'https://rubygems.org'
gem 'rack'
gem 'puma'
@tomas-stefano
tomas-stefano / Gruntfile.js
Last active December 15, 2015 08:28
Simple Handlebars Compiler in command line.
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
handlebars: {
all: {
src: ["app/assets/javascripts/templates"],
dest: "app/assets/javascripts/templates/all.js"
}
}
});
@tomas-stefano
tomas-stefano / api_settings.rb
Created March 18, 2013 13:42
Cross Origin Resource Sharing Rack middleware.
# This class should parse a yaml configuration file.
#
require 'ostruct'
class APISettings
def self.cross_origin_resource_sharing
OpenStruct.new(allow: ['http://127.0.0.1:8080', 'http://localhost:8080'])
end
end
@tomas-stefano
tomas-stefano / npm + handlebars.sh
Created January 13, 2013 01:26
Play handlebars in node
$ npm install handlebars
$ node
> var Handlebars = require('handlebars');
> var template = Handlebars.compile("Hi, {{name}}");
> console.log(template({name: "Bob"}));
Hi, Bob