Skip to content

Instantly share code, notes, and snippets.

@ml-eds
ml-eds / postgres_ssl_configuration.md
Created November 14, 2022 13:14
How to activate SSL (self-signed certs) for PostgreSQL

SSL for Postgres connections

In the following we will create a self-signed certificate (without self-signed Root CA certificate, to keep things simple)

postgresql.conf

In /var/lib/postgresql/data:

nano postgresql.conf
@ml-eds
ml-eds / git_diff.sh
Created April 26, 2022 12:07
git diff - export all changed files between two commits into tar archive
# export all changed files from commit b58b5f9 to commit HEAD into tar archive
git diff-tree -r --no-commit-id --name-only --diff-filter=ACMRT b58b5f9^..HEAD | tar -czf file.tgz -T -
@ml-eds
ml-eds / .zshrc
Created April 22, 2022 09:55
Unix timestamp to date bash / zsh
# Convert Unix timestamp to date in zsh/bash
#
# Add to .zshrc or .bash_profile
#
# Example usage: ts2date 1650621128
# Example output: 2022-04-22 11:52:08
timestamp2date() {
date -r "$1" '+%Y-%m-%d %H:%M:%S'
}
@ml-eds
ml-eds / replace.sh
Last active August 26, 2020 06:48
Shell script to replace strings in files based on two file-based lists
#!/bin/bash
# given list_search.txt with content, e.g.
# <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.0" />
# <PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="3.1.0" />
# given list_replace.txt with content, e.g.
# <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.5" />
# <PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="3.1.5" />
@ml-eds
ml-eds / addcert.sh
Last active November 7, 2019 11:06
Ubuntu: Add missing CA certificate
# good reference: https://wiki.ubuntuusers.de/CA/
# download missing cert DigiCertHighAssuranceEVRootCA.crt
wget --no-check-certificate https://dl.cacerts.digicert.com/DigiCertHighAssuranceEVRootCA.crt
# convert to pem format
openssl x509 -inform DER -outform PEM -in DigiCertHighAssuranceEVRootCA.crt -out DigiCertHighAssuranceEVRootCA.pem.crt
# copy to /usr/local/share/ca-certificates
cp DigiCertHighAssuranceEVRootCA.pem.crt /usr/local/share/ca-certificates/
@ml-eds
ml-eds / postman_set_env.js
Last active October 24, 2019 06:58
Postman: Write response values back to environment vars
// Place the following in the "Tests" tab of a request
// Check HTTP status code
tests['Status 200'] = responseCode.code === 200;
// We need valid JSON
var validJSON = false;
var resData = {};
try {
resData = JSON.parse(responseBody);
@ml-eds
ml-eds / git_precommit_hook_tslint.md
Last active August 28, 2019 09:28
Node + Typescript: How to configure git pre-commit hook with TSLint

TSLint pre-commit hook

Important!

Must be configured on top level directory of a project when having a multi-package project (e.g. frontend + backend).

Install

npm install --save-dev husky lint-staged
@ml-eds
ml-eds / shell_command.sh
Last active July 16, 2019 09:58
Shell: Find files modified after a certain time
find . -type f -newermt '7/14/2019 16:00:00'
@ml-eds
ml-eds / Program.cs
Last active July 26, 2019 14:08
Password hashing (ASPNetCore)
using System;
using Microsoft.AspNetCore.Identity;
using Microsoft.Extensions.Options;
namespace ConsoleApp
{
class Program
{
static void Main(string[] args)
{
@ml-eds
ml-eds / vagrant_ssh.md
Last active July 26, 2019 14:10
SSH connect to Vagrant VM without "vagrant ssh"

get current ssh config of vagrant vm

vagrant ssh-config

Host default
  HostName 127.0.0.1
  User ubuntu
  Port 2222
  UserKnownHostsFile /dev/null

StrictHostKeyChecking no