Skip to content

Instantly share code, notes, and snippets.

@adomokos
adomokos / jasmine-node-email.txt
Created January 10, 2012 14:17
jasmine-node pull-requests or fork
Misko,
I submitted a fairly large pull request to jasmine-node a couple of weeks ago (https://github.com/mhevery/jasmine-node/pull/105). I wanted to fix the way the verbose version of the TerminalReporter works, since it couldn't parse out nested describe statements from jasmine results. I separated out a TerminalVerboseReporter that creates a nice, colored report in the terminal.
I am very excited about this project. I'd like to add further tests around other parts of the app and I am considering adding acceptance tests as well.
Unfortunately, I don't see any activity around jasmine-node since December 14th.
Would you mind if I forked the project, released it under a new npm and merge the two back together when you're able to work on it again?
@adomokos
adomokos / observer_example.js
Created January 2, 2012 22:22
Observer in JavaScript
var observer = {
addSubscriber: function(callback) {
this.subscribers[this.subscribers.length] = callback;
},
removeSubscriber: function(callback) {
for (var i = 0; i < this.subscribers.length; i++) {
if (this.subscribers[i] === callback) {
delete (this.subscribers[i]);
}
@adomokos
adomokos / inheritance.js
Created December 22, 2011 04:44
A couple of ways to create JS objects
// From the book - Javascript: The Good Parts.
// Differential Inheritance
var myMammal = {
name: 'Herb the Mammal',
getName: function() {
return this.name;
},
says: function() {
return this.saying || '';
@adomokos
adomokos / stubbing_with_arguments_spec.rb
Created December 13, 2011 20:06
Stubbing with arguments - examples used in my "(More) Specific Stubbing with RSpec" blog post
class GivesCreditToPreferredCustomers
LOOK_BACK_PERIOD = 3
def self.for_large_orders(sales_amount, added_credit)
# the has_large_purchases scope now takes two arguments
preferred_customers = Customer.has_large_purchases(sales_amount, LOOK_BACK_PERIOD)
preferred_customers.each do |customer|
customer.add_credit added_credit
end
end
end
@adomokos
adomokos / .gitconfig
Created December 2, 2011 21:09
Wiring up p4merge
...
[merge]
summary = true
tool = p4
[mergetool "p4"]
cmd = /Applications/p4merge.app/Contents/Resources/launchp4merge "$PWD/$BASE" "$PWD/$LOCAL" "$PWD/$REMOTE" "$PWD/$MERGED"
keepBackup = false
trustExitCode = false
[mergetool]
keepBackup = false
@adomokos
adomokos / ScoreBoard.coffee
Created November 19, 2011 18:16
The TicTacToe game's ScoreBoard class is taking shape
class App.ScoreBoard
permutations =
[['A_1', 'B_1', 'C_1'],
['A_2', 'B_2', 'C_2'],
['A_3', 'B_3', 'C_3'],
['A_1', 'A_2', 'A_3'],
['B_1', 'B_2', 'B_3'],
['C_1', 'C_2', 'C_3'],
@adomokos
adomokos / sort_with_other.rb
Created October 5, 2011 19:40
A special kind of sorting algorithm, where "Other" has to be the last item when sorted
require 'ostruct'
module SortWithOther
def <=>(other)
if self.send(sort_field).downcase == "Other".downcase
1
elsif other.send(sort_field).downcase == "Other".downcase
-1
else
self.send(sort_field) <=> other.send(sort_field)
@adomokos
adomokos / string_calculator_spec.coffee
Created October 2, 2011 12:37
Hackibou (09/01/2011) CoffeeScript file - working on the String Calculator kata
class StringCalculator
calculate: (input) ->
@validateArgument(input)
result = 0
result += parseInt(splitValue) for splitValue in @splitValues(input)
result
validateArgument: (input) ->
@adomokos
adomokos / get_out_of_my_controller_spec.rb
Created September 7, 2011 19:38
The supporting code for my blog entry: "Get out of my Controller! And from Active Record, too!"
module ActiveRecord; class Base; end; end
# The AR Models Rails give you
class User < ActiveRecord::Base
# These fields are defined dynamically by ActiveRecord
attr_accessor :id, :full_name
end
class Discussion < ActiveRecord::Base
# These fields are defined dynamically by ActiveRecord
@adomokos
adomokos / visitor_pattern_example.rb
Created May 24, 2011 17:28
The Visitor Pattern implementation in Ruby from the Wikipedia example
class CarElement
def accept(visitor)
raise NotImpelementedError.new
end
end
module Visitable
def accept(visitor)
visitor.visit(self)
end