Skip to content

Instantly share code, notes, and snippets.

View bbasata's full-sized avatar

Baraa Basata bbasata

View GitHub Profile
@bbasata
bbasata / jasmine-let.js
Created October 28, 2011 19:53
First draft: wondering if anyone else would love to see a RSpec-like lazy-initializing let() function introduced into @jasminebdd
function lazy(fn) {
return _.once(fn);
}
describe('Expired Item View', function() {
var item, view, rendered;
beforeEach(function() {
item = lazy(function() { return {}; });
view = lazy(function() { return new APP.Views.ExpiredItem({ item: item() }); });
@bbasata
bbasata / bowling_game_spec.rb
Created November 5, 2011 01:49
How DRY & expressive can we get by making the subject a "let"-defined helper?
describe BowlingGame, '#score' do
subject { score }
let(:game) { BowlingGame.new }
let(:score) do
rolls.flatten.each { |roll| game.roll(roll) }
game.score
end
context "when there are no spares or strikes" do
context "all gutter balls" do
@bbasata
bbasata / StackTest.java
Created November 5, 2011 02:02
An example of BDD-influenced use of JUnit
import org.junit.Test;
import java.util.EmptyStackException;
import java.util.Stack;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
public class StackTest {
Stack<String> stack = new Stack<String>();
@bbasata
bbasata / factorial_spec.rb
Created November 5, 2011 02:04
A simple example of RSpec
class Integer
def factorial
raise if self < 0
self > 0 ? (1..self).reduce(&:*) : 1
end
end
describe Integer, '#factorial' do
context "for values larger than 1" do
example { 2.factorial.should == 2*1 }
@bbasata
bbasata / bowling_game_spec.rb
Created December 20, 2011 05:40
A bowling game
module Enumerable
def sum(identity=0)
inject(identity) { |sum,each| sum + each }
end
end
class BowlingGame
class Frame
def initialize
@rolls = []
@bbasata
bbasata / gist:3548170
Created August 31, 2012 02:34
"Where is your domain model?" : A Talk

Where is your domain model?

A domain model is much more than the “M” in MVC. As Martin Fowler writes, “Learning how to design and use a Domain Model is a significant exercise--one that has led to many articles on the ‘paradigm shift’ of objects use.”

Let’s talk about evolving a domain model in sustainable ways that allow a codebase to organically grow in a way that supports agility and adaptability. Highlights include:

  • What is a domain model? What are the alternatives?
  • What is sustainable software development?
  • Ubiquitous language, and thinking twice about naming something a Manager, Service, or DAO
@bbasata
bbasata / gist:7558982
Created November 20, 2013 07:12
Hello again
Hello again
@bbasata
bbasata / gist:7559018
Created November 20, 2013 07:17
Another CoreOS gist
Another CoreOS gist
@bbasata
bbasata / gist:5c5ec40650371e62e970
Last active August 29, 2015 14:19
twitter-pairing with @magnusstahre
SUBMODULE=lib/ansible/modules/core
SUBMODULE_COMMIT=4d9ce9cf2cdee14b1c417e92059d4ef83dbcc457
for superproject_tag in $(git tag); do
git ls-tree -r $superproject_tag | grep $SUBMODULE | awk '{ print $3 }' | while read submodule_commit_in_superproject_tag; do
(cd $SUBMODULE && git rev-list $submodule_commit_in_superproject_tag | grep $SUBMODULE_COMMIT >/dev/null && echo "Found submodule commit in superproject tag $superproject_tag")
done
done
@bbasata
bbasata / gist:8e5c6d7943908bb7bc20
Created October 18, 2015 17:35
Ignite talk proposal for devopsdays detroit
[Ignite] Three ways to automate application deployment to Amazon Web Services
Comparing and contrasting full-stack automated app deployment using:
* Ansible, a task-centric tool with uses from configuration management to cloud provisioning
* Terraform, an model-/graph-centric tool for cloud provisioning
* Convox, a Heroku-like open source Platform-as-a-Service offering that can be deployed into your Amazon Web Services account