Skip to content

Instantly share code, notes, and snippets.

View tsnobip's full-sized avatar

Paul Tsnobiladzé tsnobip

View GitHub Profile
@tsnobip
tsnobip / gen_unique_name.sql
Created February 16, 2024 14:37
Postgres unique name generator
-- idea and dictionaries taken from https://github.com/andreasonny83/unique-names-generator
create type word_kind as enum('animal', 'color', 'adjective');
-- insert animals
create table animal_words(
word text primary key
);
@tsnobip
tsnobip / main.py
Created September 15, 2023 10:59
Software architecture - draft
import networkx as nx
import scipy
import inspect
from abc import ABC
class OutOfMemoryException(Exception):
pass
class OutOfCpuResourcesException(Exception):
pass
@tsnobip
tsnobip / NodePostgres.res
Created March 1, 2023 09:16
Node-PG Rescript bindings
open Belt
let {then, thenResolve, catch, resolve, reject} = module(Promise)
module PgResult = {
module FieldInfo = {
type t = private {
name: string,
dataTypeId: string,
}
@tsnobip
tsnobip / dune.log
Created July 8, 2022 13:05
Dune Logs - Missing dependency file after upgrading lang dune above 2.9
dune build --verbose
Shared cache: disabled
Workspace root: /Users/paul/code/stork
Auto-detected concurrency: 8
Running[0]: /Users/paul/.opam/default/bin/ocamlc.opt -config > /var/folders/2k/9dsd6lhj3g5gj0zvj6s75g8w0000gn/T/dune_da6911_output
Dune context:
{ name = "default"
; kind = "default"
; profile = Dev
; merlin = true
@tsnobip
tsnobip / citation.md
Created April 26, 2022 08:12
Quotations

Dieu se rit des hommes qui déplorent les effets dont ils chérissent les causes

Jacques-Bénigne Bossuet

@tsnobip
tsnobip / rename_column_if_exists.sql
Last active May 10, 2021 11:17
Postgres: Rename column if exists
CREATE OR REPLACE FUNCTION column_exists(
pschema TEXT,
ptable TEXT,
pcolumn TEXT)
RETURNS BOOLEAN AS $BODY$
-- does the requested table.column exist in schema?
SELECT EXISTS
( SELECT NULL
FROM information_schema.columns
WHERE table_name=ptable
@tsnobip
tsnobip / I18n.res
Last active January 6, 2021 14:12
a small example of i18n with Rescript-react using only built-in components.
let intToString = Js.Int.toString
type localeCode = En_US
let localeCodeToString = x =>
switch x {
| En_US => "en-US"
}
let localeCodeFromString = x =>
@tsnobip
tsnobip / bulk_insert_ndjson.py
Created December 14, 2018 12:49
Python script to bulk insert an ndjson file to an ElasticSearch cluster
from elasticsearch import Elasticsearch
from elasticsearch.helpers import bulk
es_host = "MY_ES_URL:PORT"
user = "MY_USERNAME"
secret = "MY_PASSWORD"
file_path = "/PATH/TO/FILE.ndjson"
index = "INDEX_NAME"
doc_type = "_doc"