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
@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 / 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 / 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 / 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 / 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 / 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 {
/*
------------------------------------------------------------------------------
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 / rust-patterns-builder.rs
Last active November 19, 2016 17:57
Rust Builder Pattern Example
// Rust Builder Pattern Example
struct Foo {
x: i32,
y: i32,
z: i32
}
struct FooBuilder {
x: i32,
@4e1e0603
4e1e0603 / DatabaseConnectionDemo.java
Last active November 21, 2016 20:56
Simple JDBC Java examples
/*
This example shows how to connect to PostgreSQL database server using the `DriverManager` class.
It is recommended to use `DataSource` class instead because of connection pooling.
compile: javac DatabaseConnectionDemo.java
execute: java -cp .;lib\postgresql-X.X.XXXX.jar DatabaseConnectionDemo
*/
//package io.uetoyo.gists;
@4e1e0603
4e1e0603 / create-scala-project.bat
Last active November 16, 2016 14:28
Create the basic Scala/SBT project with Windows batch script.
@echo off
:: Create the basic SBT project structure.
:: Does not overwrite existing project folder.
:: Use the command `rd /s /q {folder-name}` for removing existing folder.
:: version 0.1
:: author: David Landa
:: license: http://creativecommons.org/licenses/by-sa/2.5/