Skip to content

Instantly share code, notes, and snippets.

Attila Domokos adomokos

Block or report user

Report or block adomokos

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
adomokos / keyword_like_function_test.clj
Created Jan 6, 2014
An example to create keyword-like arguments for a Clojure function
View keyword_like_function_test.clj
(ns keyword-like-function-test
(:require [clojure.test :refer :all]))
(defn find-values
[& {:keys [p1 p2] :or {p1 [0 0] p2 [1 1]}}]
[p1 p2])
(deftest keyword-arguments-test
(testing "when both of the arguments were passed"
(is (= [4 15] (first (find-values :p1 [4 15] :p2 [3 21]))))
View fizzbuzz.clj
(ns fizzbuzz.core
(defn- format-output [output current]
(= 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")))

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


  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 / loads_position_types.rb
Created Feb 21, 2013
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.
View loads_position_types.rb
module Services
class LoadsPositionTypes
extend ::Services::LookupDataFetchable
def self.entity_class
adomokos / bubble_sort.rb
Created Jan 24, 2013
Bubble Sorting in Ruby
View bubble_sort.rb
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
adomokos / something_steps.rb
Created May 25, 2012
Would this make you angry?
View something_steps.rb
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
adomokos / vehicle_or_car.html
Created Apr 12, 2012
Follow up comment on my blog post "Refactoring Workflows to Chain of Actions"
View vehicle_or_car.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<html xmlns="" xml:lang="en" lang="en">
Created using /
Source can be edited via /anakul/8/edit
adomokos /
Created Jan 22, 2012
Set up sample project with mocha
function create_dir {
if [ ! -d $1 ];
mkdir $1
echo "create the src directory..."
adomokos /
Created Jan 21, 2012
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) ->
You can’t perform that action at this time.