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
View keybase.md

Keybase proof

I hereby claim:

  • I am adomokos on github.
  • I am adomokos (https://keybase.io/adomokos) on keybase.
  • I have a public key ASA8JcfM-KoBRcr5g7J-bADE-azTB3JtbjP0B6yn84UXygo

To claim this, I am signing this object:

@adomokos
adomokos / RomanNumeralsSpec.hs
Created Apr 26, 2017
The Roman Numerals kata in Haskell
View RomanNumeralsSpec.hs
import Test.Hspec
import Test.QuickCheck
import Control.Exception (evaluate)
import qualified Data.Map as Map
import Data.List
mapping :: Map.Map Int String
mapping = Map.fromList [
(1, "I"),
(4, "IV"),
@adomokos
adomokos / type_vs_data_constructors.md
Created Apr 5, 2017
Type vs Data Constructors in Haskell
View type_vs_data_constructors.md

Type vs Data Constructors

In a data declaration, a type constructor is the thing on the left hand side of the equals sign. The data constructor(s) are the things on the right hand side of the equals sign. You use type constructors where a type is expected, and you use data constructors where a value is expected.

Data constructors

To make things simple, we can start with an example of a type that represents a colour.

data Colour = Red | Green | Blue
View string_calculator_test.go
package string_calculator
import (
"github.com/stretchr/testify/assert"
"strconv"
"strings"
"testing"
)
func Convert(params ...string) int {
@adomokos
adomokos / string_calculator.hs
Created Jul 14, 2016
String Calculator in Haskell
View string_calculator.hs
module StringCalculator where
import Test.Hspec
import Test.QuickCheck
import Control.Exception (evaluate)
import Data.List.Split (splitOn)
calculator' :: String -> Char -> Integer
calculator' x c = sum $ coerceString x c
@adomokos
adomokos / Makefile
Last active Jun 23, 2017
Makefile template
View Makefile
DBUSER=db_user
DBPASSWD=db_password
DBNAME=some_db
THIS_FILE := $(lastword $(MAKEFILE_LIST))
.DEFAULT_GOAL := help
build-db: ## Builds the DB
dropdb --if-exists --username $(DBUSER) $(DBNAME)
View change_maker.clj
(ns change-maker.core-test
(:require [clojure.test :refer :all]))
(def ^:dynamic *denominations* [25 10 5 1])
(defn best-match [value]
(first (filter #(<= % value) *denominations*)))
(defn calculate-change [value product]
(let [reducer (best-match value)]
@adomokos
adomokos / core_test.clj
Created May 15, 2015
Solving the Roman Numeral Kata in Clojure
View core_test.clj
(ns roman-numerals.core-test
(:require [clojure.test :refer :all]))
(def mapping {
0 ""
1 "I"
4 "IV"
5 "V"
9 "IX"
10 "X"
@adomokos
adomokos / string_calculator_spec.rb
Last active Aug 29, 2015
String Calculator Kata in Ruby - using enumerable methods
View string_calculator_spec.rb
# Solving the String Calculator Kata
# http://osherove.com/tdd-kata-1/
class StringCalculator
def self.add(numbers)
return 0 if numbers.empty?
numbers.split(",").map(&:to_i).reduce(:+)
#splitted_array = numbers.split(",")
@adomokos
adomokos / group_by_spec.rb
Created Mar 5, 2014
Recognizing Ruby's group_by in the imperative code
View group_by_spec.rb
class Location
attr_reader :city, :user
def initialize(city, user)
@city = city
@user = user
end
end
class User
attr_reader :name
You can’t perform that action at this time.