Skip to content

Instantly share code, notes, and snippets.

@suuuch
suuuch / pg_dump_store.sh
Last active August 21, 2021 07:21
[PostgreSQL Manager] Database Backup #PostgreSQL #Backup #Restore
#1. Backup and Restore Single Database
#Backup: single database in PostgreSQL. Replace your actual database name with mydb.
pg_dump -U postgres -d mydb > mydb.pgsql
#Restore: single database backup in PostgreSQL.
psql -U postgres -d mydb < mydb.pgsql
#2. Backup and Restore All Databases
#Backup: all databases in PostgreSQL using pg_dumpall utility.
@HauptJ
HauptJ / openresty.service
Created June 21, 2018 18:02
OpenResty Systemd service file
# Stop dance for OpenResty
# A modification of the Nginx systemd script
# Source: https://www.digitalocean.com/community/tutorials/how-to-use-the-openresty-web-framework-for-nginx-on-ubuntu-16-04
# =======================
#
# ExecStop sends SIGSTOP (graceful stop) to the Nginx process.
# If, after 5s (--retry QUIT/5) OpenResty is still running, systemd takes control
# and sends SIGTERM (fast shutdown) to the main process.
# After another 5s (TimeoutStopSec=5), and if OpenResty is alive, systemd sends
# SIGKILL to all the remaining processes in the process group (KillMode=mixed).
@silkeh
silkeh / grace.go
Created June 4, 2018 07:27
Golang graceful restart with TCP connections
package main
import (
"encoding/json"
"flag"
"io/ioutil"
"log"
"net"
"os"
"os/signal"
@chrisguitarguy
chrisguitarguy / nginx.conf
Created February 22, 2018 16:22
How to proxy requests from nginx to an upstream backend. Could be use for Python or JavaScript (express) apps.
http {
# other stuff here
# The upstream backend server this can be named whatever you desire
# See http://nginx.org/en/docs/http/ngx_http_upstream_module.html
upstream backend {
# this is the actual hostname + port of the backend server
server backend:8080;
# how many keep alive connections to allow, only set this if you're going
# to specify the `Connection` header in the proxy below, nginx sets the
@NikolayS
NikolayS / becnh_m5.2xlarge.out
Last active November 17, 2021 21:52
pgbench: simple INSERTs, UPDATEs with and without triggers
# m5.2xlarge 32.0 GiB 8 vCPUs
# s=100, n=10
*** Only SELECTs, -T 30 -j4 -c12
transaction type: <builtin: select only>
scaling factor: 100
query mode: prepared
number of clients: 12
number of threads: 4
duration: 30 s
<?php
$db_username = ''; //username
$db_password = ''; //password
//path to database file
$database_path = $_SERVER["DOCUMENT_ROOT"] . "\access\accessdatabase.accdb";
//check file exist before we proceed
if (!file_exists($database_path)) {
die("Access database file not found !");
}
@ruanbekker
ruanbekker / docker-nfs-volumes.md
Created December 10, 2017 10:43
NFS Volumes with Docker Swarm

Create NFS Volumes:

Creating the NFS Volume:

$ docker volume create --driver local \
  --opt type=nfs \
  --opt o=addr=192.168.1.115,uid=1000,gid=1000,rw \
  --opt device=:/mnt/volumes/mysql-test \
  mysql-test-1
@fsalehpour
fsalehpour / watermark.bash
Last active April 25, 2024 17:46
Script to add a scrolling watermark and scaling a video in one go using `ffmpeg`
#!/bin/bash
dir=$(pwd)
(cd $1
mkdir -p output
for i in *
do
output="output/$(echo $i | sed 's/\..*$/\.mp4/')"
@mediaupstream
mediaupstream / make_certs.sh
Last active December 4, 2024 17:30
extract ca-certs, key, and crt from a pfx file
#!/bin/bash
#
# Usage:
# ./make_certs.sh test.example.com
#
# The required input to make_certs.sh is the path to your pfx file without the .pfx prefix
#
# test.example.com.key
# test.example.com.crt (includes ca-certs)
@voluntas
voluntas / openssl_speed_aes_gcm_chacha20_poly1305.md
Last active November 10, 2024 05:00
$ openssl speed -evp aes-gcm | chacha20-poly1305 の結果を集めるスレ

$ openssl speed -evp aes-128-gcm | chacha20-poly1305 の結果を集めるスレ

AES-CBC が早いけど、AES-GCM/AES-CTR が遅かったり、Ryzen が爆速だったり、 ChaCha20-Poly1305 が ARM で早かったりするという噂の真相が知りたいです。コメントに適当にべたべた結果を貼ってください。

ちなみに Apple M2 おかしいくらい早いです。

CPU 情報はできれば詳細なのがほしいです。

OpenSSL のバージョンは 3.1 系の最新版でお願いします。