Skip to content

Instantly share code, notes, and snippets.

View molind's full-sized avatar

Evgen Bodunov molind

View GitHub Profile
@molind
molind / why.sql
Created February 10, 2024 11:44
Magic in nested branches
CREATE TABLE test_data (
housenumber text
);
INSERT INTO test_data VALUES
('123;456'),
('789;'),
(';'),
('abc;def'),
('');
@molind
molind / docker-compose.yml
Last active December 26, 2023 14:09
immich + traefik = ❤️
version: "3.8"
# Updated from immich v1.91.4
# Before you start it, replace immich.domain.com to your domain and your@email.com to your email.
#
# Traefik web-admin is available on server at port 8080.
# To connect it, forward 8080 port to your machine `ssh -L 8080:127.0.0.1:8080 user@server`, then open http://localhost:8080
name: immich
BookmarkIcon(color: .blue, icon: .icon_star), // 0
BookmarkIcon(color: .green, icon: .icon_bank), // 1
BookmarkIcon(color: .gray, icon: .icon_car_service), // 2
BookmarkIcon(color: .turquoise, icon: .icon_theater), // 3
BookmarkIcon(color: .green, icon: .icon_education), // 4
BookmarkIcon(color: .turquoise, icon: .icon_cinema), // 5
BookmarkIcon(color: .blue, newColor: .orange, icon: .icon_restaurant), // 6
BookmarkIcon(color: .red, icon: .icon_health), // 7
BookmarkIcon(color: .green, icon: .icon_police_station), // 8
BookmarkIcon(color: .green, icon: .icon_residence), // 9
@molind
molind / db.go
Last active February 12, 2024 20:19
Disable migration in gorm.io
package db
import (
"fmt"
"userspace_back/db/model"
"gorm.io/driver/postgres"
"gorm.io/gorm"
"gorm.io/gorm/schema"
@molind
molind / report_cpu_multi_threads.txt
Created January 14, 2022 20:12
sysbench 60s on Apple macbook air M1
WARNING: --num-threads is deprecated, use --threads instead
sysbench 1.0.20 (using system LuaJIT 2.1.0-beta3)
Running the test with following options:
Number of threads: 8
Initializing random number generator from current time
Prime numbers limit: 10000
@molind
molind / parsel.sql
Created July 30, 2021 09:34
Parallel select and Parallel query
-- since it uses dblink it should be enabled in the database.
-- CREATE EXTENSION dblink;
-- And you'll may need to grant permissions to use it to your user.
-- GRANT EXECUTE ON FUNCTION dblink_connect_u(text) TO user;
-- GRANT EXECUTE ON FUNCTION dblink_connect_u(text, text) TO user;
-- Usage example:
-- select g_parsel('insert into osm_polygon_extra select osm_id, st_pointonsurface( st_collect( geom ) ) from osm_polygons group by osm_id;', 'osm_polygons', 12);
@molind
molind / default.mapcss
Created June 1, 2020 16:21
Default MapCSS used by GuruMaps
* {
details-text:eval(tag('name'));
details-description:eval(tag('description'));
}
line {
width:3pt;
color:#0062CC;
linejoin:round;
linecap:round;
}
@molind
molind / SortedDictionary.swift
Last active September 7, 2020 11:36
SortedDictionary used to sort contents before JSON serialization
// We have a parent just to pass face control in JSONSerialization
@objc class SortedDictionary: NSDictionary {
let _values: NSMutableArray = []
let _keys: NSMutableOrderedSet = []
override var count: Int {
return _keys.count
}
override func keyEnumerator() -> NSEnumerator {
@molind
molind / parsel.sql
Created November 28, 2018 18:10
Parallel select function for PostgreSQL.
--
-- Befor using it you should enable dblink extension in database and allow user to run dblink_connect_u
-- You may need to change 'dbname=osm' to your db connection options in line 34.
-- CREATE EXTENSION dblink;
-- GRANT EXECUTE ON FUNCTION dblink_connect_u(text) TO user;
-- GRANT EXECUTE ON FUNCTION dblink_connect_u(text, text) TO user;
--
DROP FUNCTION IF EXISTS public.g_parsel(query text, table_to_chunk text, num_chunks integer);
CREATE OR REPLACE FUNCTION public.g_parsel(query text, table_to_chunk text, num_chunks integer default 2)
@molind
molind / postgresql_norm.conf
Created November 17, 2018 16:45
Postgresql config
include 'postgresql_orig.conf'
# Generated by PGConfig 2.0 beta
## http://pgconfig.org
# Memory Configuration
shared_buffers = 6GB
effective_cache_size = 18GB
work_mem = 819MB
maintenance_work_mem = 2GB