Skip to content

Instantly share code, notes, and snippets.

View and3rson's full-sized avatar
♥️
Time You Enjoy Wasting Is Not Wasted Time.

Andrew Dunai and3rson

♥️
Time You Enjoy Wasting Is Not Wasted Time.
View GitHub Profile
@kissgyorgy
kissgyorgy / listen.py
Created September 4, 2020 16:37
How to use PostgreSQL's LISTEN/NOTIFY as a simple message queue with psycopg2 and asyncio
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;")
@Yepoleb
Yepoleb / ytmusic.py
Last active November 4, 2023 05:19
Youtube Music downloader with automatic ID3 tagging. Uses mutagen and requests.
#!/usr/bin/env python3
# License: GPLv3
import re
import json
import shutil
import subprocess
import sys
import urllib.parse
import yaml
from collections import OrderedDict
class quoted(str):
pass
def quoted_presenter(dumper, data):
return dumper.represent_scalar('tag:yaml.org,2002:str', data, style='"')
yaml.add_representer(quoted, quoted_presenter)
@IAmSuyogJadhav
IAmSuyogJadhav / Transparent drawings in OpenCV.py
Created July 10, 2018 09:41
Add transparency to rectangles, circles, polgons, text or any shape drawn in OpenCV.
import cv2
image = cv2.imread('test.jpg')
overlay = image.copy()
x, y, w, h = 10, 10, 10, 10 # Rectangle parameters
cv2.rectangle(overlay, (x, y), (x+w, y+h), (0, 200, 0), -1) # A filled rectangle
alpha = 0.4 # Transparency factor.
@cbmeeks
cbmeeks / sid.txt
Last active June 2, 2024 16:29
SID File Format
===========================
SID FILE FORMAT DESCRIPTION
===========================
AUTHORS:
Michael Schwendt (PSID v1 and v2)
Simon White (PSID v2NG, RSID)
Dag Lem (PSID v2NG)
Wilfred Bos (PSID v3, RSID v3, PSID v4, RSID v4)
@harrisont
harrisont / example.py
Created February 25, 2017 22:03
Python asyncio exception, cancellation, and KeyboardInterrupt handling
import asyncio
import logging
import time
async def do_work(i):
print('start', i)
# Work
time.sleep(1)
@17twenty
17twenty / xForwardTest.go
Created January 18, 2017 04:45
Extracting X-Forwarded-For from connections in Golang
package main
import (
"fmt"
"log"
"net/http"
"strings"
)
func main() {
@blaisep
blaisep / jenkins-pipeline-git-cred.md
Created October 20, 2016 23:33
Insert git credentials into Jenkins Pipeline Script projects

Suppose you want to inject a credential into a Pipeline script. The cloudbees note does not include Pipeline script examples. https://support.cloudbees.com/hc/en-us/articles/203802500-Injecting-Secrets-into-Jenkins-Build-Jobs

The Jenkins Pipeline Docs' description of the git pushmethod doesn't have an example using injected credentials. (https://jenkins.io/doc/pipeline/examples/#push-git-repo)

The Snippet generator is helpful, but not not if you try to follow the instructions at: https://wiki.jenkins-ci.org/display/JENKINS/Credentials+Binding+Plugin

@chrisjarman
chrisjarman / substitute.sh
Created September 29, 2016 20:03
Bash script to substitute environment variables for placeholders, in-place.
#/usr/bin/env bash
TEMP=`mktemp`
envsubst < $1 > $TEMP
mv $TEMP $1
@zillion45
zillion45 / sftp.py
Last active June 4, 2023 15:28
paramiko sftp example
import getpass
import sys
import paramiko
LOCAL= ''
REMOTE = ''
def copy_file(host, port, username, password, src, dest):
client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())