Skip to content

Instantly share code, notes, and snippets.

View molind's full-sized avatar

Evgen Bodunov molind

View GitHub Profile
@molind
molind / start_realm_sync.md
Last active October 7, 2024 12:48
Self-hosted realm sync

Recently, MongoDB announced that they are discontinuing support for Atlas Sync, and developers will be looking for alternatives. I thought it would be a good idea to write an article on how we host the Realm server ourselves.

In the realm-core repository, the source code for the synchronization server is located. We will need to add some wrappers and launch the server. Launching is trivial. Build realm-core from here: https://github.com/molind/realm-core/tree/auth_check (There are minimal changes to allow authorization with our tokens. You can check the diff). Then, in your server.cpp, write approximately the following:

#include <stdio.h>
#include <unistd.h>

#include <realm/sync/noinst/server/server.hpp>
@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 [email protected] 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)