This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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;") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
type ternary struct { | |
conditionIsTrue bool | |
trueValue interface{} | |
} | |
func If(condition bool) *ternary { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Run gotest with the module name found in go.mod in the current directory | |
# gotest is: https://github.com/rakyll/gotest | |
gote () { | |
# run in a subshell, so errexit will exit the subshell, not the terminal shell | |
# https://unix.stackexchange.com/questions/207732/local-set-e-for-functions | |
( | |
set -eo pipefail | |
local options | |
local test_path | |
local module_name |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
listen 443 ssl http2; | |
server_name plex.example.com; | |
location / { | |
proxy_pass http://127.0.0.1:32400; | |
include proxy_params; | |
# This is for proxying websocket connections for the web interface | |
proxy_http_version 1.1; | |
proxy_set_header Upgrade $http_upgrade; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
import sqlite3 | |
from urllib.parse import unquote, parse_qs | |
PLEX_DB = '/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-in Support/Databases/com.plexapp.plugins.library.db' | |
conn = sqlite3.connect(PLEX_DB) | |
res = conn.execute('SELECT hints FROM media_items WHERE library_section_id = 1;') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import io | |
import os | |
import sys | |
import time | |
import wsgiref.util | |
import uwsgidecorators |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> import copy | |
>>> copy.deepcopy(257) is copy.deepcopy(257) | |
True | |
>>> a = copy.deepcopy(257) | |
>>> b = copy.deepcopy(257) | |
>>> a is b | |
False | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sqlite3 | |
from typing import namedtuple | |
class Environment(NamedTuple): | |
SLACK_CLIENT_ID: str | |
SLACK_CLIENT_SECRET: str | |
SECRET_KEY: str | |
conn = sqlite3.connect('config.db') | |
conn.row_factory = sqlite3.Row |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
certPem := result.Data["certificate"] | |
certString := certPem.(string) | |
certBytes := []byte(certString) | |
block, _ := pem.Decode(certBytes) | |
cert, err := x509.ParseCertificate(block.Bytes) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func (b *vaultBackend) Version() string { | |
r := b.client.NewRequest("GET", "/v1/sys/health") | |
resp, err := b.client.RawRequest(r) | |
if err != nil { | |
log.Fatal(err) | |
} | |
defer resp.Body.Close() | |
var result struct { | |
Version string | |
} |