Skip to content

Instantly share code, notes, and snippets.

Avatar

John B Nelson jbn

View GitHub Profile
View lolps5.py
import subprocess
import requests
from pyquery import PyQuery
import time
def send_to_pushover():
requests.post("https://api.pushover.net/1/messages.json", data={
"token": "XXX",
"user": "XXX",
@jbn
jbn / avi_rotate.py
Created Jul 7, 2021
How I rotate my AVI
View avi_rotate.py
import tweepy
import json
import time
import datetime
from calendar import monthrange
from PIL import Image, ImageEnhance
import pathlib
import pylunar
View weird_tweets.py
TWEETS = [
"F3B383064F9A76AD777D08A4C3CBF4CD:DF4E827DCBA71AEA510F4B2BB5F62796:FDA3BA94D91870DA38783787178F6B565C391D441E82D1318571D0B1C17DC9B305C1B47EE8C69BF8F244027F53B1317DD53D8E27A923B3FE411411142754B846C53300483C5AA46A90D6F33F8F4BDF65F98D10C059A6A36D7F3C9A49472C768BAD275A094128D00860C5FD",
"6A9537BA898C70D3DB6BB5D984B6423104B5691111067413F6C3E9C6A3AB90678ADA2445592C41CA4802990621F47E21431125AE1E34B3A4C394CBD1AC4F1ACCC8FE04059C6586EF2425710619112CABF775C3C7CAE44DB8B6467228D845990295307A5539B3F8B50C735F4D4B2AEED59E73A5142F26578AA768FBBEF51B63BBF8AA824C2F87ED4C17E56C85",
"27F2322110C16594C3369792230F845F10E26231F76C201F164667C3CAD73FFA72AD710704BD3C3E65E91BDDF8888C8A7964F25510C29A598D21734BD1FD6FD5DB3D15F06E580A0C2839A81954BBDB3C690C9AB146792C02D3D976ECF57C1F37AB900A535F177E5A9CCAC190B2424BBF13B1F3D7F04C74DA593D43F058DF77DF4ACDC7F2A6FFC5847931AA74",
"FEA4845903FF9AFDF42A0C8CB25C0409A031EDC4BA3C05BC47298898CB5BECF2C02D0BAE7554",
"3CDB109B0AD9E30F845A0E07EE78FC83:ACC4B7820D28BF600134E74D00
@jbn
jbn / shifted_geom.py
Last active Oct 4, 2020
A shifted geometric distribution with p=0.75 via bit twiddling
View shifted_geom.py
# Came across the `randomLevel` function in
#
# https://github.com/automerge/automerge/blob/main/backend/skip_list.js
#
# which implements a geometric distribution with bit twiddling.
#
# Below is a pedagogical implementation.
import random
from collections import Counter
@jbn
jbn / Dockerfile
Created Sep 25, 2020
An attempt to build akash from scratch and set up a validator
View Dockerfile
FROM golang:1.14.9-stretch
# See: https://docs.akash.network/validator-guides/gentxo
RUN cd $GOPATH/src && mkdir -p github.com/ovrclk && \
cd github.com/ovrclk && \
git clone https://github.com/ovrclk/akash.git && \
cd akash && \
MAINNET=true git checkout v0.8.1 && \
make deps-install && \
make install
@jbn
jbn / python_help_evolution.txt
Created Jul 13, 2020
Diff of python --help over time
View python_help_evolution.txt
Python 2.7.10
usage: python [option] ... [-c cmd | -m mod | file | -] [arg] ...
Options and arguments (and corresponding environment variables):
-B : don't write .py[co] files on import; also PYTHONDONTWRITEBYTECODE=x
-c cmd : program passed in as string (terminates option list)
-d : debug output from parser; also PYTHONDEBUG=x
-E : ignore PYTHON* environment variables (such as PYTHONPATH)
-h : print this help message and exit (also --help)
View archive.py
import json
import pathlib
import tweepy
import pickle
from collections import defaultdict
import pandas as pd
from dateutil.parser import parse as parse_time
def load_api():
View corruption.py
import numpy as np
n, syn, ack = 240, "SYN", "ACK"
k = n//4
idx = sorted(zip(np.random.randint(0, n, k), np.random.choice([syn, ack], k)))
corruption = []
for i in range(n):
while idx and idx[0][0] <= i:
View maxims_shitpost.py
import tweepy # pip install tweepy
import json
import time
from missing_builtins import chunker # pip install missingbuiltins
with open("twitter_creds.json") as fp: # Yours with the fields below
creds = json.load(fp)
auth = tweepy.OAuthHandler(creds['appKey'], creds['appSecret'])
auth.set_access_token(creds['userToken'], creds['userSecret'])
api = tweepy.API(auth)
View watch_virus.sh
sudo apt-get install jq # See: https://stedolan.github.io/jq/download/
take Virus # or, mkdir Virus && cd Virus
python -m venv env
source env/bin/activate
pip jmespath twarc # https://github.com/DocNow/twarc
twarc configure # https://github.com/DocNow/twarc#quickstart
twarc filter "#TraceableMemeticVirus" | tee -a virus.jsonl | jq '. | {id: .id, who: .user.screen_name, what: .text}'