Skip to content

Instantly share code, notes, and snippets.

View LeKovr's full-sized avatar

Aleksei Kovrizhkin LeKovr

View GitHub Profile
@LeKovr
LeKovr / dcape-install.sh
Created July 31, 2023 14:28
Install dcape v3
MY_HOST=demo.dcape.ru
[email protected]
git clone https://github.com/dopos/dcape.git
make install ACME=wild DNS=wild DCAPE_DOMAIN=${MY_HOST} \
TRAEFIK_ACME_EMAIL=${LE_ADMIN} PDNS_LISTEN=$(dig +short $MY_HOST):53
make echo-gitea-admin-pass
@LeKovr
LeKovr / config.Makefile
Last active June 20, 2023 21:54
.env.sample generation from app Makefile vars with notes prefixed by '#- ...' comment
# app custom Makefile
SHELL = /bin/sh
CFG = .env
# ------------------------------------------------------------------------------
# app custom config
# comments prefixed with '#- ' will be copied to $(CFG).sample
#- Postgresql container name (access via docker)
@LeKovr
LeKovr / pg-upgrade_v1.1.sh
Created April 21, 2023 08:02
Postgresql version upgrade script for dcape
#!/bin/sh
# Postgresql version upgrade script for dcape
# Uses tianon/postgres-upgrade docker image
# See also:
# * https://github.com/tianon/docker-postgres-upgrade
# * https://dopos.github.io/dcape/
# Restart after upgrade
# * dcape-app-pg-backup
<!--
MIT License
Source: https://gist.github.com/LeKovr/d6ee7d31c65a4b7e90d8d94295e4d535
Copyright (c) 2021 Aleksei Kovrizhkin (LeKovr)
Original version: https://github.com/pseudomuto/protoc-gen-doc/blob/v1.4.1/resources/markdown.tmpl
Copyright (c) 2017 David Muto (pseudomuto)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
@LeKovr
LeKovr / xml_unescape.sql
Created June 2, 2019 07:58
Unescape and pretty print xml in postgresql
create or replace function xml_pretty(xml)
returns xml as $$
-- requires xml2 pg extension
-- https://postgres.cz/wiki/PostgreSQL_SQL_Tricks#Pretty_xml_formating
select xslt_process($1::text,'
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:strip-space elements="*" />
<xsl:output method="xml" indent="yes" />
<xsl:template match="node() | @*">
<xsl:copy>
@LeKovr
LeKovr / func_from_json.sql
Created February 7, 2019 08:43
Создание postgresql функции с данными из json с помощью psql
/*
Пример создания функции postgresql средствами psql.
Функция возвращает строки по ключу без обращения к таблицам
Исходные данные размещены в файле json
*/
-- содержимое файла с данными, для логов
\! cat args.json
/*
{
@LeKovr
LeKovr / Makefile
Last active April 26, 2018 00:11
Bootstrapping vue.js project with docker
# Bootstrapping vue.js project with docker
# Requires: make, docker
# Copyright: Aleksei Kovrizhkin <[email protected]>
# License: MIT
#
# Place this file into empty dir and run
# make simple
# (be ready to answer questions about your new project)
#
# After complete you can run your sample project in development mode:
@LeKovr
LeKovr / concat-call.md
Created January 5, 2018 20:16
dbrpc sample function calls

Sample function calls

GET

$ curl -gs http://localhost:8081/rpc/concat?a_arg1=prefix&a_arg2=suffix

{
  "success": true,
  "result": [
    {
 "concat": "prefixsuffix"
@LeKovr
LeKovr / concat-def.md
Created January 5, 2018 20:13
dbrpc sample function docs

Sample function docs

Method

$ curl -gs http://localhost:8081/rpc/index?a_nsp=public

{
  "success": true,
  "result": [
    {
@LeKovr
LeKovr / concat.sql
Created January 5, 2018 16:13
dbrpc sample function
/*
concat - sample function for dbrpc demo
See https://github.com/LeKovr/dbrpc
*/
CREATE OR REPLACE FUNCTION concat(
a_arg1 TEXT
, a_arg2 TEXT DEFAULT ''
) RETURNS TEXT IMMUTABLE LANGUAGE 'plpgsql' AS
$_$
BEGIN