Skip to content

Instantly share code, notes, and snippets.

View excavador's full-sized avatar

Oleg Tsarev excavador

View GitHub Profile
COMMAND = """#!/bin/bash
set -x
ls -al
docker load --input {server_source} | awk '{{print $3}}' > {server_result}
docker load --input {client_source} | awk '{{print $3}}' > {client_result}
"""
def _clickhouse_export_impl(ctx):
server_source = ctx.attr.server.files.to_list()[0]
client_source = ctx.attr.client.files.to_list()[0]
import os
import sys
import queue
import threading
import re
import requests
import logging
import colorlog
import hashlib
load("//bzl:fmt.bzl", "fmt")
fmt(name="fmt")
@excavador
excavador / dummy constants columns for FOREIGN KEY
Last active August 11, 2017 18:57
Annoying PostgreSQL limitations
TODO
[jenkins@ci-slave-1:Ireland oleg]$ grep -A 1 -B 1 error_log /home/jenkins/backend-ci/bin/nginx.conf
pid /home/jenkins/backend-ci/bin/nginx.pid;
error_log /dev/stderr error;
--
access_log /dev/stderr combined_plus;
error_log /dev/stderr error;
[jenkins@ci-slave-1:Ireland oleg]$ /sbin/nginx -c /home/jenkins/backend-ci/bin/nginx.conf
nginx: [alert] could not open error log file: open() "/var/log/nginx/error.log" failed (13: Permission denied)
$(FMT).state: bin/xargs-if-changed
rm -f $@
touch $@
$(FMT): bin/xargs-if-changed bin/gofmt $(FMT).state $(SIGN__GO__SOURCE) $(SIGN__GO__TEST) $(SIGN__GO__GENERATED)
$(info [fmt])
make/02.files-go-source.sh | XARGS_STATE=$(FMT).state XARGS_WRAP_OUTPUT=0 bin/xargs-if-changed bin/gofmt -l -s -w
make/02.files-go-test.sh | XARGS_STATE=$(FMT).state XARGS_WRAP_OUTPUT=0 bin/xargs-if-changed bin/gofmt -l -s -w
touch $@
fmt: $(FMT)
$(VET).state:
@touch $@
$(VET): bin/xargs-if-changed bin/vet $(VET).state $(SIGN__GO__SOURCE) $(SIGN__GO__TEST) $(SIGN__GO__GENERATED)
$(info [vet])
@(make/02.files-go-source.sh; make/02.files-go-test.sh) | XARGS_STATE=$(VET).state XARGS_WRAP_OUTPUT=0 bin/xargs-if-changed bin/vet
@touch $@
vet: $(VET)
➜ make/02.files-go-source.sh | XARGS_STATE=bin/make/fmt XARGS_WRAP_OUTPUT=0 bin/xargs-if-changed bin/gofmt -l -s -w
/Users/oleg/pp/backend/src/cmd/make/xargs-if-changed/main.go
➜ bin/xargs-if-changed --help
Usage: xargs-if-changed <tool with arguments>
tool
1. reads file paths from stdin
2. reads content of every file and calculate MD5
3. checks MD5 for this file in <XARGS_STATE>
4. if file was changed executes "<tool with arguments> <file path>"
5. if execution was successfull writes actual MD5 for <file path> to <XARGS_STATE>
ifeq ($(STAGE),initial)
.PHONY: everything
everything:
$(MAKE) STAGE=bootstrap bootstrap $(MAKECMDFLAGS)
$(MAKE) STAGE=execute bootstrap $(MAKECMDFLAGS)
$(MAKE) STAGE=execute $(MAKECMDGOALS) $(MAKECMDFLAGS)
$(MAKECMDGOALS): everything
@excavador
excavador / README.md
Last active November 6, 2022 21:48
automatically add alias ip address to loopback

Motivation

You often have several docker containers and applications which work together in the locel development environment. You need the following communications:

  • docker container to localhost
  • localhost to docker container
  • docker container to docker container

You have a way to connect localhost-to-docker using -p (port-mapping) docker option. For instance, you can start PostgreSQL container using -p 0.0.0.0:5432:5432 and then connect like to normal PostgreSQL