Skip to content

Instantly share code, notes, and snippets.

View bind-disney's full-sized avatar
💭
I have a bad feeling about this

Artem Filatov bind-disney

💭
I have a bad feeling about this
  • St. Petersburg, Russia
View GitHub Profile
@bind-disney
bind-disney / postgres-user-registration.sql
Last active October 23, 2022 22:56
PostgreSQL user registration example with UDFs and custom data types
DROP SCHEMA IF EXISTS membership CASCADE;
CREATE SCHEMA membership;
SET SEARCH_PATH TO membership;
CREATE EXTENSION IF NOT EXISTS pgcrypto WITH SCHEMA membership;
CREATE SEQUENCE id_sequence; -- AS bigint
@bind-disney
bind-disney / Makefile
Created June 18, 2020 00:31
Two-way merge sort example in C++
CC=g++
CFLAGS=-c -Wall
LDFLAGS=
SOURCES=main.cpp input.cpp sort.cpp
OBJECTS=$(SOURCES:.cpp=.o)
EXECUTABLE=mergesort
all: $(SOURCES) $(EXECUTABLE)
$(EXECUTABLE): $(OBJECTS)
@bind-disney
bind-disney / docker-compose.yml
Last active May 5, 2020 16:59
docker-compose for default spring boot app
version: "3.7"
services:
app:
image: gradle:jdk11
container_name: app
working_dir: /app
user: gradle
command:
- sleep
@bind-disney
bind-disney / build.gradle.kts
Created November 28, 2019 06:17
Запуск Liquibase-задач из командной строки
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
id("org.springframework.boot") version "2.2.0.RELEASE"
id("io.spring.dependency-management") version "1.0.8.RELEASE"
id("org.liquibase.gradle") version "2.0.1"
kotlin("jvm") version "1.3.50"
kotlin("plugin.spring") version "1.3.50"
kotlin("plugin.jpa") version "1.3.50"
}
@bind-disney
bind-disney / Model.kt
Created November 22, 2019 09:19
Поддержка нативных ENUM-ов PostgerSQL в Spring Data JPA
package com.example.project.entity
import org.hibernate.annotations.Type
import org.hibernate.annotations.TypeDef
import com.example.project.enumeration.PostgreSQLEnumType
import com.example.project.enumeration.ModelStatus
import javax.persistence.Column
import javax.persistence.Entity
import javax.persistence.EnumType
import javax.persistence.Enumerated
@bind-disney
bind-disney / clear-docker-logs.sh
Last active February 18, 2019 16:50
Clear Docker logs
# Mac
#
# Usage: clear_docker_logs <CONTAINER_NAME> | <CONTAINER_ID>
clear_docker_logs() {
docker_log_file=$(docker inspect --format='{{.LogPath}}' $1)
clear_command="truncate -S 0 $docker_log_file"
screen -d -m -S dockerlogdelete ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/tty
screen -S dockerlogdelete -p 0 -X stuff $"$clear_command"
screen -S dockerlogdelete -p 0 -X stuff $'\n'
"""
You should add Flow as a dependency to your Mix project configuration:
mix.exs:
defp deps do
[
...,
{:flow, "~> 0.14.2"},
...
require 'dry-validation'
ThreeDigits = /^\d{3}$/
FourDigits = /^\d{4}$/
schema = Dry::Validation.Schema do
required(:field_1).filled(:str?)
required(:field_2).filled(:str?)
rule(field_2_depends_on_field_1: [:field_1, :field_2]) do |field_1, field_2|