Skip to content

Instantly share code, notes, and snippets.

View stalkerg's full-sized avatar
🎯
Focusing

Yury Zhuravlev stalkerg

🎯
Focusing
View GitHub Profile
@stalkerg
stalkerg / s3.py
Created January 12, 2015 13:09
Async Tornado S3 uploader with AWS4 sign
import hashlib
import hmac
import mimetypes
import binascii
from calendar import timegm
from datetime import datetime
import time
from email.utils import formatdate
from urllib.parse import quote, urlparse
@stalkerg
stalkerg / gist:86a2197cf4707b2f1130
Created February 2, 2015 08:35
boycottsystemd.org
THE RUNDOWN
1. systemd flies in the face of the Unix philosophy: "do one thing and do it well," representing a complex collection of dozens of binaries1. Its responsibilities grossly exceed that of an init system, as it goes on to handle power management, device management, mount points, cron, disk encryption, socket API/inetd, syslog and other things.
2. systemd's journal files (handled by journald) are stored in a complicated binary format2, and must be queried using journalctl. This makes journal logs potentially corruptable. Oh, an embedded HTTP server is loaded to read them. QR codes are served, as well.
3. systemd's team is noticeably chauvinistic and anti-Unix, due to their open disregard for non-Linux software and subsequent systemd incompatibility with all non-Linux systems. Since systemd is very tightly welded with the Linux kernel API, this also makes different systemd versions incompatible with different kernel versions. This is an isolationist policy that essentially binds the Linux ecosystem i
@stalkerg
stalkerg / FuncAcceptArgtypes.cmake
Created September 2, 2015 17:13
CMake analog for ac_func_accept_argtypes.m4
include(CheckIncludeFiles)
include(CheckCSourceCompiles)
check_include_files(sys/types.h HAVE_SYS_TYPES_H)
check_include_files(sys/socket.h HAVE_SYS_SOCKET_H)
if(HAVE_SYS_TYPES_H)
set(INCLUDE_SYS_TYPES_H "#include <sys/types.h>")
endif(HAVE_SYS_TYPES_H)
@stalkerg
stalkerg / ptrack_backup_todo.md
Last active May 31, 2016 17:05
Truly Incremental backup for Postgres

Description

First, I will talk about the current state of affairs. We have a several approaches:

  1. Scan all db files and compare page LSN (barman, pg_rman). If you have big db it is not your choice.

  2. Scan archive WAL files (current pg_arman). If you have high load it is not oyur choice too. (Big databases rarely living without high load.)

  3. Pages are tracked using bitmap during runtime, so the needed ones can be easily dumped. (Oracle and my ptrack (patches for postgres and pg_arman)) It's really your choice.

import tornado.ioloop
import tornado.web
import json
class MainHandler(tornado.web.RequestHandler):
def get(self, type_r=None):
format_answer = self.get_argument("format", "json")
# bla bla request to postgres
if format_answer == "sql":
self.write(my_sql_answer)
@stalkerg
stalkerg / ptrack_v2.patch
Created May 31, 2016 16:53
ptrack patch for Postgres 9.5 stable
diff --git a/src/backend/access/heap/Makefile b/src/backend/access/heap/Makefile
index b83d496..788c55c 100644
--- a/src/backend/access/heap/Makefile
+++ b/src/backend/access/heap/Makefile
@@ -12,6 +12,6 @@ subdir = src/backend/access/heap
top_builddir = ../../../..
include $(top_builddir)/src/Makefile.global
-OBJS = heapam.o hio.o pruneheap.o rewriteheap.o syncscan.o tuptoaster.o visibilitymap.o
+OBJS = heapam.o hio.o pruneheap.o rewriteheap.o syncscan.o tuptoaster.o visibilitymap.o ptrack.o
@stalkerg
stalkerg / ptrack_95_v3.patch
Created September 1, 2016 10:29
ptrack patch v3 for Postgres 9.5 stable
diff --git a/src/backend/access/heap/Makefile b/src/backend/access/heap/Makefile
index b83d496..788c55c 100644
--- a/src/backend/access/heap/Makefile
+++ b/src/backend/access/heap/Makefile
@@ -12,6 +12,6 @@ subdir = src/backend/access/heap
top_builddir = ../../../..
include $(top_builddir)/src/Makefile.global
-OBJS = heapam.o hio.o pruneheap.o rewriteheap.o syncscan.o tuptoaster.o visibilitymap.o
+OBJS = heapam.o hio.o pruneheap.o rewriteheap.o syncscan.o tuptoaster.o visibilitymap.o ptrack.o
@stalkerg
stalkerg / ptrack_100_v7.patch
Last active November 17, 2016 11:46
ptrack patch v7 for Postgres 10
--- src/backend/access/heap/Makefile
+++ src/backend/access/heap/Makefile
@@ -12,6 +12,6 @@ subdir = src/backend/access/heap
top_builddir = ../../../..
include $(top_builddir)/src/Makefile.global
-OBJS = heapam.o hio.o pruneheap.o rewriteheap.o syncscan.o tuptoaster.o visibilitymap.o
+OBJS = heapam.o hio.o pruneheap.o rewriteheap.o syncscan.o tuptoaster.o visibilitymap.o ptrack.o
include $(top_srcdir)/src/backend/common.mk
@stalkerg
stalkerg / cmake_10_v2.patch
Last active October 9, 2017 23:22
cmake_10_v2
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000000..795f34db48
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,1429 @@
+cmake_minimum_required(VERSION 2.8.4)
+
+project(Postgres C)
+
@stalkerg
stalkerg / Clipboard.html
Last active January 20, 2022 08:52
Svelte component for copy to clipboard.
<script>
import { tick } from 'svelte';
let valueCopy = null;
export let value = null;
let areaDom;
async function copy() {
valueCopy = value;
await tick();