Skip to content

Instantly share code, notes, and snippets.

View 4e1e0603's full-sized avatar
🎯
I may be slow to respond.

David Landa 4e1e0603

🎯
I may be slow to respond.
  • Prague, Czech Republic
View GitHub Profile
/*
------------------------------------------------------------------------------
Popis:
Úkolem bylo ukázat, jak vytáhnout různá ověření na atributy osoby mimo samotnou
třídu osoba. Osoba zná svůj věk, ale neví jestli je plnoletá či smí na horskou dráhu.
Takové omezení přichází až z vnějšku a je závislé na kontextu, např. plnoletost je
jinak definována v USA než v EU.
1) Bude mít rozšíření které ověří, jestli osoba smí pít alkohol (min. 18 let).
@4e1e0603
4e1e0603 / FluentSpecificationExample.java
Last active November 29, 2016 15:26
Example of simple parametrized specification pattern implementation
/*
Specification Pattern
Simple use case: We have a person class with a birthdate attribute and we want to know if he is an adult.
The straigtforward approach is create the custom parametrized specification.
*/
import java.time.Period;
import java.time.LocalDate;
public class FluentSpecificationExample {
@4e1e0603
4e1e0603 / current_python_path.py
Created December 9, 2016 19:26
Prints the current Python Path -- oneliner
python -c "import sys; print('\n'.join(sys.path))"
@4e1e0603
4e1e0603 / oracle_conn_demo.clj
Created December 21, 2016 14:47
Clojure Oracle Database connection
(ns app.core
(:require
[clojure.java.jdbc :as jdbc]))
(def oracle-db-spec
{:classname "oracle.jdbc.Driver"
:subprotocol "oracle:thin"
:subname "//@host:port/name"
:user "USER"
:password "PASS"})
@4e1e0603
4e1e0603 / release.sh
Created March 8, 2017 15:40 — forked from bclinkinbeard/release.sh
Bash script to automate the Git Flow tag/release process
#!/bin/bash
# current Git branch
branch=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,')
# v1.0.0, v1.5.2, etc.
versionLabel=v$1
# establish branch and tag name variables
devBranch=develop
@4e1e0603
4e1e0603 / value_object.cpp
Last active April 25, 2017 19:31
Simple value object example in C++
/*
Ukázka jak implementovat jednoduchý *value object*.
*/
#include <string>
#include <stdexcept>
#include <iostream>
template<typename T>
@4e1e0603
4e1e0603 / ngram.py
Last active February 11, 2020 08:49
Compute N-Gram
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Jednoduchá realizace n-gramu.
"""
def ngrams(words, n):
return zip(*[words[i:] for i in range(n)])
@4e1e0603
4e1e0603 / HammingDistanceAlgorithm.py
Last active February 11, 2020 08:50
Compute Hamming Distance
# -*- coding: utf-8 -*-
"""
Hamming distance between two sequences.
Hamingova vzdálenost je metrika; splňuje předpoklady:
Předpoklad:
a) H(x, y) >= 0 a H(x, y) = 0 právě když x = y;
b) H(x, y) = H(y, x) komutace
@4e1e0603
4e1e0603 / generate_uuids.py
Created December 17, 2017 16:04
Generate UUIDs
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
Script for generating unique IDs for persons.
The script accepts command line arguments stating how many IDs should be generated,
if the number of IDs is not defined or it is not a number, the script will generate
default number of IDs (which is set to 10000).
"""
@4e1e0603
4e1e0603 / Makefile
Created December 29, 2017 13:16 — forked from maxtruxa/Makefile
Generic makefile for C/C++ with automatic dependency generation, support for deep source file hierarchies and custom intermediate directories.
# output binary
BIN := test
# source files
SRCS := \
test.cpp
# files included in the tarball generated by 'make dist' (e.g. add LICENSE file)
DISTFILES := $(BIN)