Skip to content

Instantly share code, notes, and snippets.

@sgtlaggy
sgtlaggy / YOURDOMAIN
Created March 9, 2023 18:04
nginx include example
# /etc/nginx/sites-available/YOURDOMAIN
server {
server_name your.domain;
location / {
proxy_pass http://localhost:PORT/;
include /etc/nginx/custom/proxy.conf;
}
include /etc/nginx/custom/ssl-YOURDOMAIN.conf;
@sgtlaggy
sgtlaggy / 1_shared_cursor.py
Last active February 21, 2024 14:15
The perils of shared database connections and cursors
import asyncio
import asqlite
async def shared_cursor():
"""
Expected result:
Each `fetchone` should return a row with a `user_id` matching the passed value.
from typing import Annotated, Any
from discord import Interaction, app_commands
from discord.app_commands import Choice
from discord.ext import commands
import discord
class CategoryTransformer(app_commands.Transformer):
@sgtlaggy
sgtlaggy / help_view.py
Last active March 25, 2022 19:25
A discord.py 2.0 help command implemented using select menus for selecting cogs or commands.
from __future__ import annotations
"""
Copyright 2021 sgtlaggy
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
?tag list 103714384802480128
@sgtlaggy
sgtlaggy / base.html
Last active August 6, 2017 00:00
I wrote DRPG a while back, it was on Github for a bit, then I took it down when I built it into my flask project, which I'm no longer hosting.
<!DOCTYPE html>
<html>
<head>
<title>{% block title %}{% endblock %}</title>
<link type="text/css" rel="stylesheet" href="/style.css">
{% block head %}{% endblock %}
</head>
<body>
<div id="container">
<div id="main1">
import urllib.request
import random
import json
try:
from tkinter import Tk, messagebox
except ImportError:
tk = False
else:
tk = True