Skip to content

Instantly share code, notes, and snippets.

View OndrejValenta's full-sized avatar

Ondrej Valenta OndrejValenta

View GitHub Profile

Serilog configuration for easy console/file/debug logging in Console apps

Using Microsoft Logging extensions

Serilog.Debugging.SelfLog.Enable(msg => Debug.WriteLine(msg));
Serilog.Debugging.SelfLog.Enable(Console.Error);

loggerConfig = new LoggerConfiguration()
  .MinimumLevel.Verbose();

Simple reordering of items in database table

The problem

Ability to reorder item based on users drag and drop of items in UI. Items can be drag and drop in as a single object or with This is not the most efficient way how to do this but it's working just fine.

-- Drop functions and data table if they already exists
drop function save_todo_float(_user_id int, _what text, _todo_id int);
drop function move_todo_float(_user_id int, _ids int[], _target_id int, _position text);
drop table todos_float;
@OndrejValenta
OndrejValenta / install-elixir-on-centos8.sh
Created June 20, 2020 01:03
Install Elixir on Centos 8
# DEPENDS ON install-erlang-on-centos8.sh
# Install Elixir
cd /opt
git clone https://github.com/elixir-lang/elixir.git
cd elixir
make clean test
export PATH="$PATH:/opt/elixir/bin"

Install Zsh and Oh-my-zsh on CentOS 8

Based on this article

chsh is not available on some Centos8 so there is a dnf install to add the package that contains it

ALL INSTALLATIONS ASSUME YES WHEN PROMPTED, that's what -y does

This script can be copy paste to ssh as is. No hands installation. :-)

@OndrejValenta
OndrejValenta / install-erlang-on-centos8.sh
Last active June 19, 2020 23:45
Install Erlang on Centos8
# Install Epel repository
yum install epel-release -y
# Install necessary libraries for Erlang compilation
yum install gcc gcc-c++ glibc-devel make ncurses-devel openssl-devel autoconf java-1.8.0-openjdk-devel git wget wxBase3 libGL libGLU unixODBC wxGTK3 wxGTK3-gl -y
# Download Erlang package (update to proper package version)
wget https://packages.erlang-solutions.com/erlang/rpm/centos/8/x86_64/esl-erlang_23.0.2-1~centos~8_amd64.rpm
# Install Erlang
@OndrejValenta
OndrejValenta / hetzner-centos8-first-steps.sh
Last active July 19, 2020 22:24
Hetzner Centos 8 - first steps
# Update everything automatically
yum update -y
# Install nano and other useful stuff because you are not a masochist
yum install epel-release -y;
yum install nano -y;
yum install mc -y;
yum install htop -y;
# Install and start firewalld

Install Nginx and PHP on CentOS 7

Based on this article

Install Nginx

sudo yum install epel-release -y
sudo yum install nginx -y

sudo systemctl start nginx

Install Zsh and Oh-my-zsh on CentOS 7

Based on this article

ALL INSTALLATIONS ASSUME YES WHEN PROMPTED, that's what -y does

This script can be copy paste to ssh as is. No hands installation. :-)

yum install zsh -y

This installation is based on Postgres Apt repository

  • Installation steps for Postgres are defined here
  • Installation steps for PostGIS are defined here

Add keys to Apt

sudo apt install curl ca-certificates gnupg
sudo curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'