Skip to content

Instantly share code, notes, and snippets.

@dunkelstern
dunkelstern / README.md
Created May 8, 2023 17:58
Systemd Unit for running python application in virtualenv

Assumptions

  • Username is user
  • User is in group user
  • User's home is /home/user
  • Python application is in /home/user/pythonapp
  • Python script is named start.py
  • Virtual environment is /home/user/.virtualenvs/pythonapp created with python -m venv /home/user/.virtualenvs/pythonapp

You can add multiple Environment lines if you need more env-variables

@bugbrekr
bugbrekr / jumbled_word_solver.py
Last active July 23, 2024 15:00
Simple and inefficient word unjumbler!
import sys
import time
import webbrowser
WORDS_FILE = 'words_alpha.txt'
num_words = sum(1 for line in open(WORDS_FILE))
def permutation(lst):
if len(lst) == 0:
return []
if len(lst) == 1:
return [lst]
@OndraZizka
OndraZizka / switchHeadphones.sh
Last active May 29, 2024 13:43
Bluetooth headset - switch between quality sound + no mic (A2DP) and crappy sound and mic (HSP/HFP)
#!/bin/bash
#### Restart Bluetooth
if [ "$1" == "resetBT" ] ; then
sudo rfkill block bluetooth && sleep 0.1 && sudo rfkill unblock bluetooth;
exit;
fi;
#### Toggle listen/speak
if [ "$1" == "" -o "$1" == "toggle" ] ; then
@lopes
lopes / aes-cbc.py
Last active May 7, 2025 01:11
Simple Python example of AES in CBC mode. #python #cryptography #aes #cbc #poc
#!/usr/bin/env python3
#
# This is a simple script to encrypt a message using AES
# with CBC mode in Python 3.
# Before running it, you must install pycryptodome:
#
# $ python -m pip install PyCryptodome
#
# Author.: José Lopes
# Date...: 2019-06-14
@nejdetckenobi
nejdetckenobi / send_mail.py
Created January 3, 2016 11:17
sending mail via postfix, python.
# Source: http://masnun.com/2010/01/01/sending-mail-via-postfix-a-perfect-python-example.html
import smtplib
from email.MIMEMultipart import MIMEMultipart
from email.MIMEBase import MIMEBase
from email.MIMEText import MIMEText
from email.Utils import COMMASPACE, formatdate
from email import Encoders
import os