Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / 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 / no_actions_goes_to_the_park_spec.coffee
Created January 21, 2012 22:11
Blog Post - Refactoring Workflows to Chain of Actions
should = require 'should'
House = {
leave: (dude) ->
'leaves the house'
closeTheDoor: (dude) ->
'closes the door'
}
Car = {
jumpIn: (dude) ->
@adomokos
adomokos / mocha_sample_project_install.sh
Created January 22, 2012 21:35
Set up sample project with mocha
#!/bin/bash
function create_dir {
if [ ! -d $1 ];
then
mkdir $1
fi
}
echo "create the src directory..."
@adomokos
adomokos / vehicle_or_car.html
Created April 12, 2012 13:58
Follow up comment on my blog post "Refactoring Workflows to Chain of Actions"
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!--
Created using /
Source can be edited via /anakul/8/edit
-->
<head>
@adomokos
adomokos / something_steps.rb
Created May 25, 2012 17:59
Would this make you angry?
When /^I am on the Billing\/Shipping address page$/ do
# setting the order_id to 1 in the session
class Spree::BaseController < ApplicationController
prepend_before_filter :stub_order_id_in_session
def stub_order_id_in_session
session[:order_id] = 1
end
end
@adomokos
adomokos / bubble_sort.rb
Created January 24, 2013 18:21
Bubble Sorting in Ruby
module Enumerable
def bubble_sortit
reached_end = true
(1..self.length-1).each do |e|
if self[e] < self[e-1]
self[e-1], self[e] = self[e], self[e-1]
reached_end = false
end
end