Skip to content

Instantly share code, notes, and snippets.

@xyb
xyb / shell.py
Created September 30, 2024 04:29 — forked from ddahan/shell.py
FastAPI context-aware shell with model discovery and other auto-imports
# Requires Python 3.12+, IPython, rich
import datetime
import hashlib
import importlib
import inspect
import json
import logging
import os
import pkgutil
@xyb
xyb / middleware.py
Last active August 23, 2023 05:32 — forked from tclancy/middleware.py
Django middleware for Pympler (compatible with Django 2.0+)
# Derived from Piotr Maliński's example with a few modifications to use logging and :
# http://www.rkblog.rk.edu.pl/w/p/profiling-django-object-size-and-memory-usage-pympler/
import logging
import os
from django.conf import settings
from pympler import muppy
from pympler.asizeof import asizeof
from pympler.muppy import summary
@xyb
xyb / 00-install-facetime-camera.sh
Last active May 5, 2024 20:47 — forked from ukn/99-install-facetime-camera.sh
Install the kernal module required for the facetimehd camera to work on Linux
#!/bin/bash
set -e
export CONFIG_MODULE_SIG=n
export CONFIG_MODULE_SIG_ALL=n
# For current kernel
export KERNELRELEASE=$(cat /proc/version | awk '{print $3}')
temp_dir=$(mktemp -d)
echo "Installing FacetimeHD camera for $KERNELRELEASE"
@xyb
xyb / sqlite-kv-restful.py
Last active July 1, 2020 04:10 — forked from georgepsarakis/sqlite-kv-restful.py
Simple SQLite-backed key-value storage Rest API. Built with Flask & flask-restful.
#!/usr/bin/env python3
"""
Requirements:
pip install Flask==1.1.2 Flask-RESTful==0.3.8
"""
import os
import sqlite3
@xyb
xyb / cookiemonster.go
Last active February 3, 2019 15:41 — forked from rwifeng/cookiemonster.go
Simple script to extract (encrypted) cookies out of Chrome OS X cookie store. Usage: ./cookiemonster domain.com
package main
import (
"golang.org/x/crypto/pbkdf2"
"crypto/aes"
"crypto/cipher"
"crypto/sha1"
"database/sql"
"fmt"
"log"
#!/usr/bin/env python2
# Quick and dirty demonstration of CVE-2014-0160 by Jared Stafford (jspenguin@jspenguin.org)
# The author disclaims copyright to this source code.
import sys
import struct
import socket
import time
import select