Skip to content

Instantly share code, notes, and snippets.

View vadv's full-sized avatar
🏠
Working from home

vadv vadv

🏠
Working from home
  • OZON
  • Moscow
View GitHub Profile
diff --git a/.gitignore b/.gitignore
index 94d2001..2078a91 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
/target
.idea
/examples
+/vendor
diff --git a/Cargo.lock b/Cargo.lock
package main
import (
"flag"
"fmt"
"net"
"os"
"strconv"
"strings"
"time"
@vadv
vadv / fsm.md
Created January 29, 2020 07:44

Finite state machine in PostgreSQL

This document will not disclose the topic why you need fsm.

But if you implement fsm, then you need to do it as nearly as possible in the data.

This document will explain how you can implement it with PostgreSQL and gives developers maximum freedom.

Schema

package main
import (
"encoding/json"
"flag"
"fmt"
"log"
"os"
"os/signal"
"syscall"
@vadv
vadv / Golang.md
Last active August 29, 2019 15:45

This article is about how to plan connections to PostgreSQL in Golang applications.

Recommended libraries

The standard PostgreSQL library is de-facto: lib/pq

Also, the quite popular library is: pgx

I do not impose the use of any libraries, and I make a description of how to use the specified.

begin;
drop table if exists audit_data;
create table audit_data ( id bigserial unique not null, payment_id text, payload text );
insert into audit_data (payment_id, payload)
select md5(i::text),
       repeat(md5(i::text), 10)
from generate_series(1, 1000*1000) s(i);
commit;
@vadv
vadv / 01_schema.sql
Last active January 29, 2020 08:58
/* list of order */
create table "order" (
id text primary key,
created_at timestamp with time zone default current_timestamp,
processed_at timestamp with time zone,
processed_state text
);
/* processed transition on order.id */
create table order_events (
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import re
import requests
import sys
from Crypto.Cipher import AES
package crypto
import (
"bytes"
"crypto/aes"
"fmt"
"io"
)
// читаем из io.Reader размером size и записываем в io.Writer дешифрованный поток ключом key
require "chef/handler"
require "etc"
require "date"
class TelegramHandler < Chef::Handler
BOT_API_KEY = 'BOTAPI:KEY'
CHAT_ID = -id
PROXY_ADDR = 'http://chef/telegram/'