Skip to content

Instantly share code, notes, and snippets.

@adomokos
adomokos / fizzbuzz.clj
Last active January 1, 2016 11:48
Solving the "FizzBuzz" kata (http://codingdojo.org/cgi-bin/wiki.pl?KataFizzBuzz) in Clojure
(ns fizzbuzz.core
(:gen-class))
(defn- format-output [output current]
(cond
(= 0 (mod current 15)) (str output "FizzBuzz\n")
(= 0 (mod current 3)) (str output "Fizz\n")
(= 0 (mod current 5)) (str output "Buzz\n")
:else (str output current "\n")))
@adomokos
adomokos / vim_katas_02.md
Last active December 18, 2015 09:59
vim katas

The Yank Register

  1. Start at the first character of the first line collection = getCollection(); process(somethingInTheWay, target);
  2. Yank the word "collection" with - yiw
  3. Move to the beginning of the word "somethingInTheWay" with - jww
  4. Delete the word "somethingInTheWay" with - diw
  5. Paste from the Yank Register with - "0P
  6. Look at the Yank Register with - :reg "0
@adomokos
adomokos / vim_katas_01.md
Last active December 18, 2015 05:48
vim katas

Selection

  1. type in the word: "errors for job profile"
  2. move to the first 'p'
  3. select the entire content within the quotes: vi"
  4. select just from the cursor to the quotes: vt"
  5. delete just from the cursor location to the quote: dt"
  6. delete everything within the quotes: di"

Creating, using marks

  1. open a file with a few hundred lines of code
@adomokos
adomokos / loads_position_types.rb
Created February 21, 2013 22:59
DRY-ing up service logic with mixins. Since these services are very similar in behavior I used a "template" method that uses only one dynamic data: the entity type they are fetching.
module Services
class LoadsPositionTypes
extend ::Services::LookupDataFetchable
def self.entity_class
PositionType
end
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
@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 / 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 / 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 / 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 / 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?