Skip to content

Instantly share code, notes, and snippets.

@0xa
0xa / python.sh
Created October 28, 2019 01:42
get an usable python3 user environment for poetry on debian buster
# as root
apt install python3 python3-distutils python3-pkg-resources python3-venv
# rest as your project user
su - projectuser
# Create python shims (poetry needs "python" and "pip")
mkdir ~/.local/bin/ -p
ln -s /usr/bin/python3 $HOME/.local/bin/python
ln -s /usr/bin/pip $HOME/.local/bin/pip
echo 'export PATH="$HOME/.local/bin:$PATH"' > ~/.profile && source ~/.profile
@0xa
0xa / clean_cache.py
Created February 4, 2019 21:48
remove errors from nginx cache
#!/usr/bin/env python3
# apt install python3-tqdm
import os
import sys
from glob import iglob
from tqdm import tqdm
root = '/var/cache/nginx/octodon'
#!/bin/env python3
# uvccapture -d/dev/video0 -x2560 -y720 -osnap.jpg
# ./this.py snap.jpg
# -> output.jpg
from PIL import Image, ImageFilter
import numpy as np
import sys
@0xa
0xa / progressbar.rb
Last active October 4, 2018 13:56
mastodon tootctl media remove progressbar
# in lib/mastodon/media_cli.rb:43
# also gem install ruby-progressbar
# probably awful i dislike ruby lol
say("counting...")
count = MediaAttachment.where.not(remote_url: '').where.not(file_file_name: nil).where('created_at < ?', time_ago).count
say("removing #{count} files...")
bar = ProgressBar.create(:total => count, :length => 80, :format => "%a [%c/%C] |%B| %j%% %f")
MediaAttachment.where.not(remote_url: '').where.not(file_file_name: nil).where('created_at < ?', time_ago).reorder(nil).find_in_batches do |media_attachments|
media_attachments.each do |m|
@0xa
0xa / example.conf
Created October 3, 2018 19:47 — forked from Gargron/example.conf
Using an nginx proxy with cache in front of Wasabi to minimize egress costs
proxy_cache_path /tmp/cache levels=1:2 keys_zone=s3_cache:10m max_size=15g inactive=24h use_temp_path=off;
server {
listen 443 ssl;
server_name files.example.com;
keepalive_timeout 30;
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains";
location = / {
#!/bin/sh
total=$1
if [ -z "$total" ]; then
echo "usage:"
echo " $0 <total>"
echo "total:"
echo " echo 'select count(*) from statuses;' | su - postgres -c 'psql DBNAME'"
exit 1
fi
/*
Ok(
JsavFile {
version: 115,
tokens: [
"uv",
"landmark",
"state",
"globalentity_t",
"mapName",
<!DOCTYPE html>
<!-- saved from url=(0017)https://xomg.net/ -->
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>xomg</title>
<style type="text/css">
* { margin: 0; padding: 0; }
body { background: #000; text-align: center; }
p.noscript { color: white; font-size: 2em; }
</style>
@0xa
0xa / followings.py
Last active July 27, 2022 13:28
Mastodon followings management
#!/usr/bin/env python3
"""
A script that go through your followings and unfollows dead accounts.
It notices empty accounts, accounts that were deleted locally and remotely,
and also cleans up dead instances if allowed to.
It has a cache so you can run it once without --unfollow to preview its
actions, and a second time that will skip all verified active profiles.
With colors and a nice progress bar with item count, %, and ETA.
#!/usr/bin/env python3
"""
ROBCO Industries (TM) Password Recovery Tool
----
Next-generation hacking assistant for your RobCo Pip-Boy 3000.
"""
from collections import namedtuple