Skip to content

Instantly share code, notes, and snippets.

View baseplate-admin's full-sized avatar

baseplate-admin

  • GlitchGalore
  • Middle of Nowhere
View GitHub Profile
@J-Priebe
J-Priebe / jwt_middleware.py
Last active January 17, 2024 15:31
Cookie-based JWT Middleware for Django Channels
from django.contrib.auth.models import AnonymousUser
from django.db import close_old_connections
from django.conf import settings
from channels.sessions import CookieMiddleware
from channels.db import database_sync_to_async
from rest_framework_simplejwt.authentication import JWTAuthentication
import logging
logger = logging.getLogger(__name__)
@wzjoriv
wzjoriv / clustering.py
Last active August 11, 2024 20:47
Nearest Neighbor, K Nearest Neighbor and K Means (NN, KNN, KMeans) implemented only using PyTorch
import torch as th
"""
Author: Josue N Rivera (github.com/wzjoriv)
Date: 7/3/2021
Description: Snippet of various clustering implementations only using PyTorch
Full project repository: https://github.com/wzjoriv/Lign (A graph deep learning framework that works alongside PyTorch)
"""
def random_sample(tensor, k):
@meicookies
meicookies / weeaboo.lol
Created June 21, 2021 20:47
Wibu Stress Generator written in LOLCODE
HAI 1.2
OBTW
CODED BY ./MEICOOKIES
TLDR
O HAI IM WEEB
HOW IZ I SEX YR WAIFU AN YR CUM
CUM, WTF?
OMG "1"
@Guhan-SenSam
Guhan-SenSam / 1info.md
Last active August 7, 2024 23:25
Methods to Optimizing Kivy Performance

Many people state that kivy is slow. While this may be true it is mostly due to that python is slow to run on android devices.Thus it is in the programmer's hands to properly optimize their code so as to create a performant application.

Most of the lag on android devices runing kivy apps arise due to widget creation. Widget creation remains the slowest step in a kivy app. Here are some of the methods that I follow to optimize my apps and ensure I can hit 60fps even on old devices

Optimization Methods:

@JulienPradet
JulienPradet / Component.svelte
Last active July 22, 2024 07:04
How to use `use` directive to trap focus in Svelte
<script>
import {trapFocus} from "./trapFocus";
</script>
<div use:trapFocus>
<button>Hi!</button>
<button>Second button</button>
</div>
@advaith1
advaith1 / top bots.md
Last active September 22, 2024 15:43
The top Discord bots ranked by server count
Rank Bot Approximate Server Count Library
1 MEE6 21,500,000 Custom Python
2 Rythm 🪦 15,200,000 JDA
3 Groovy 🪦 10,300,000 JDA, Discord4J
4 carl-bot 🅱️ 10,300,000 Pycord
5 ProBot
@tomchristie
tomchristie / proxy.py
Created January 15, 2020 13:06
An ASGI proxy service.
import httpx
from starlette.requests import Request
from starlette.responses import StreamingResponse
class Proxy:
def __init__(self, hostname):
self.hostname = hostname
self.client = httpx.AsyncClient()
@tenuki
tenuki / multi_uvicorn.py
Last active February 24, 2024 01:18
How to run multiple uvicorn server apps in the same process (thanks @a-d-j-i )
##
## How to run multiple uvicorn server apps in the same process
##
import asyncio
from uvicorn import Server, Config
class MyServer(Server):
async def run(self, sockets=None):
self.config.setup_event_loop()
return await self.serve(sockets=sockets)
@eltonvs
eltonvs / arch_installation.md
Last active August 23, 2024 21:16
Arch Linux step to step installation guide

Arch Linux Installation Guide

This guide will show step-by-step how to Install Arch Linux on UEFI mode.

Table of Contents

  • Bootable Flash Drive
  • BIOS
  • Pre installation
    • Set Keyboard Layout
    • Check boot mode
  • Update System Clock
@ilfuriano
ilfuriano / backup_db.sh
Created September 13, 2017 18:07
Backup Postgres DB to Google Drive
#!/bin/bash
now=`date +%Y%m%d-%H%M%S`
day_ago=7
db_name="DB_NAME"
base_path="BASE_PATH"
dump_fpath="$base_path/backup_db-$now.sql.gz"
sudo -u postgres pg_dump $db_name | gzip -9 > $dump_fpath