Skip to content

Instantly share code, notes, and snippets.

View smlbiobot's full-sized avatar

SML (See-ming Lee) smlbiobot

View GitHub Profile
@jstayco
jstayco / README.md
Last active September 12, 2023 19:29
Setup script for Kohya SS on macOS

MacOS (Apple Silicon)

In the terminal, run

git clone https://github.com/bmaltais/kohya_ss.git
cd kohya_ss
# Patch these files into top level/root project folder
# Then run the next command
bash ./macos.sh
@pinheaded
pinheaded / cog_ext.py
Last active June 11, 2024 19:54
a basic cog + extension example for discord.py v2
from discord import app_commands
from discord.ext import commands
# all cogs inherit from this base class
class ExampleCog(commands.Cog):
def __init__(self, bot):
self.bot = bot # adding a bot attribute for easier access
# adding a command to the cog
@commands.command(name="ping")
@ashleysommer
ashleysommer / proxy.py
Created September 30, 2021 06:18
A simple reverse-proxy server in Sanic using HTTPX streaming responses
#!/bin/python3
#
"""Example Sanic Reverse Proxy"""
from urllib.parse import urlsplit, urlunsplit
from sanic import Sanic, Request
from sanic.response import stream, HTTPResponse
import httpx
env = {"hostname-from": "localhost", "port-from": 8000, "port-to": 8080}
@ahopkins
ahopkins / # Server Sent Events.md
Last active May 30, 2024 15:03
Server Sent Events

Server Sent Events

@karlcow
karlcow / error.md
Created February 10, 2021 13:50
lxml.etree.XMLSyntaxError: Char 0x0 out of allowed range

With lxml 4.5.0

❯ python
Python 3.9.1 (default, Feb  5 2021, 17:04:50) 
[Clang 12.0.0 (clang-1200.0.32.29)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from lxml import etree
>>> from io import StringIO
>>> etree.parse(StringIO('<h2>👺</h2>'))
@lukaskleinschmidt
lukaskleinschmidt / app.scss
Last active September 11, 2023 14:50
Utility class generator like tailwindcss but in pure Sass.
@use 'sass:map';
@use 'variants' as * with (
$breakpoints: (
'small': 640px,
'medium': 768px,
'large': 1024px,
'wide': 1280px,
)
);
@raveenb
raveenb / ssh_into_android.md
Last active July 5, 2024 05:48
SSH into Android

Connecting to an Android device over SSH

Initial Setup

Install Android App Termux from APKPure or AppStore. If the app exists, just delete and re-install it to get the latest version, The APK can be downloaded from https://apkpure.com/termux/com.termux/ Install the APK using by running

adb install ~/Downloads/Termux_v0.73_apkpure.com.apk
# -*- coding: utf-8 -*-
import re
from redbot.core import checks, Config
import discord
from redbot.core import commands
from redbot.core.data_manager import bundled_data_path
import asyncio
import datetime
from .userprofile import UserProfile
from PIL import Image, ImageDraw, ImageFont
@drbh
drbh / checkIsBrave.js
Created January 30, 2019 20:19
Reliably detect Brave Browser with native JS
// helper to find Brave in User Agent string
function isBraveAgent(userAgentResponse) {
var isBraveIndex = ~userAgentResponse.indexOf('Brave')
if (isBraveIndex < 0) {
return true
}
return false
}
// Function from Javarome
@amitripshtos
amitripshtos / elasticsearch-py-async-bulk.py
Created October 28, 2018 14:13
Asyncio bulk helper methods for elasticsearch-py-async (python 3.6+) , use it like a regular helper, with AsyncElasticsearch
from __future__ import unicode_literals
import logging
from operator import methodcaller
import asyncio
from elasticsearch.exceptions import TransportError
from elasticsearch.helpers import BulkIndexError, expand_action, _chunk_actions
from elasticsearch.compat import map