NOTE: This is a question I found on StackOverflow which I’ve archived here, because the answer is so effing phenomenal.
If you are not into long explanations, see [Paolo Bergantino’s answer][2].
| import { PrismaClient } from '@prisma/client'; | |
| import type { User } from '@prisma/client'; | |
| import { createPool, sql } from 'slonik'; | |
| export const buildBaseConnectionURL = (config) => { | |
| return ( | |
| 'postgresql://' + | |
| config.DB_USER + | |
| ':' + | |
| config.DB_PASS + |
| #include <fcntl.h> | |
| #include <unistd.h> | |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <sys/stat.h> | |
| int main(void) | |
| { | |
| // Using POSIX open/read functions | |
| // If using Windows, you probably want to use fopen/fread (or native Windows API) |
| import asyncio | |
| import psycopg2 | |
| # dbname should be the same for the notifying process | |
| conn = psycopg2.connect(host="localhost", dbname="example", user="example", password="example") | |
| conn.set_isolation_level(psycopg2.extensions.ISOLATION_LEVEL_AUTOCOMMIT) | |
| cursor = conn.cursor() | |
| cursor.execute(f"LISTEN match_updates;") |
| # Install OpenSSL from source on Mac OS X | |
| # prepare workspace | |
| mkdir -p ~/code/build-from-src/ && cd $_ | |
| # download source code | |
| curl -LO https://www.openssl.org/source/openssl-1.1.1d.tar.gz | |
| # expand tar | |
| tar -xzvf openssl-1.1.1d.tar.gz |
| #!/usr/bin/env bash | |
| # To fix the " gpg: WARNING: unsafe permissions on homedir '/home/path/to/user/.gnupg' " error | |
| # Make sure that the .gnupg directory and its contents is accessibile by your user. | |
| chown -R $(whoami) ~/.gnupg/ | |
| # Also correct the permissions and access rights on the directory | |
| chmod 600 ~/.gnupg/* | |
| chmod 700 ~/.gnupg |
NOTE: This is a question I found on StackOverflow which I’ve archived here, because the answer is so effing phenomenal.
If you are not into long explanations, see [Paolo Bergantino’s answer][2].
| mkcd() { mkdir -p "$@" && cd "$@"; } |
| require 'rubygems' | |
| require 'yaml' | |
| # A demonstration of YAML anchors, references and handling of nested values | |
| # For more info, see: | |
| # http://atechie.net/2009/07/merging-hashes-in-yaml-conf-files/ | |
| stooges = YAML::load( File.read('stooges.yml') ) | |
| # => { | |
| # "default" => { |
| import java.security.InvalidKeyException; | |
| import java.security.NoSuchAlgorithmException; | |
| import java.security.SignatureException; | |
| import java.util.Formatter; | |
| import javax.crypto.Mac; | |
| import javax.crypto.spec.SecretKeySpec; | |
| /** |