Skip to content

Instantly share code, notes, and snippets.

👨‍💻

Ryan Castellucci ryancdotorg

View GitHub Profile
View lz77c.js
// a toy lz77 compressor that outputs printable ascii, by @ryancdotorg
var compress = function(I) {
var p = 0, // position in input
o = "", // compressed output string
D, D_MAX = 479, // distance
L, L_MAX = 19, // length
match; // best match for current position
// encode a (distance,length) tuple
@ryancdotorg
ryancdotorg / exim.py
Created Dec 23, 2018
Twisted protocol for Exim's `readsocket` function
View exim.py
#!/usr/bin/env python
from zope.interface import implementer
from twisted.internet.interfaces import IHalfCloseableProtocol
from twisted.internet.protocol import Protocol
@implementer(IHalfCloseableProtocol)
class EximSocketProtocol(Protocol):
# buffer received data
def dataReceived(self, data):
@ryancdotorg
ryancdotorg / bitfi_to_brainflayer.py
Last active Sep 15, 2018
Python script to output Bitfi key material compatible with `brainflayer -x -t priv`.
View bitfi_to_brainflayer.py
#!/usr/bin/env python
# This script accepts salt,passphrases pairs on STDIN seperated by a tab.
# Specify the coin symbol and indexes to generate via command line args.
#
# Appears to work fine with Bitcoin, Litecoin and Ethereum, probably works
# with many other coins as well.
#
# Don't participate in Bitfi's pay-to-play Bounty - it's a sham.
View brotlipng.sh
#!/bin/sh
# brotlipng.sh by @ryancdotorg
pngcrush -q -force -m 1 -l 0 "$1" ".$1.tmp" && \
brotli -fj ".$1.tmp" -o "$1.br"
@ryancdotorg
ryancdotorg / bitfi.py
Created Jul 25, 2018
incomplete attempt to implement bitfi's key derivation algorithm
View bitfi.py
#!/usr/bin/env python
import sys
import hmac
import hashlib
import binascii
import scrypt
import pycoin
from pybitcointools import *
@ryancdotorg
ryancdotorg / export-earn.com-earnings.js
Last active Mar 19, 2018
earnings report for earn.com task completion
View export-earn.com-earnings.js
// paste to console on https://earn.com/history/ after scrolling down until no more entries appear
hist=[];
document.querySelectorAll(".tasks-results-card-content").forEach(function(e){
var yearStr = " "+(new Date()).getFullYear();
var dateStr = e.getElementsByClassName("task-results-response-status")[0]
.getElementsByTagName("div")[6].innerText.split(',')[0];
dateStr += dateStr.indexOf(yearStr) > -1 ? "" : yearStr;
hist.push(
e.getElementsByClassName("head-stat")[0]
View bloom_chk_hash160.nasm
CPU X64
%macro check_bit 0 ; check whether bit rax
; of the bloom filter is set
mov rdx, rax ; copy hash
shr rax, byte 3 ; byte to check in rax
movzx rax, byte [rdi+rax] ; load byte to check from memory
and rdx, byte 7 ; mask off bit to check
bt rax, rdx ; bit test against bloom filter
jnc bloom_miss ; jump to return a 'miss' if bit isn't set
@ryancdotorg
ryancdotorg / rotate_dkim.py
Last active Jul 1, 2018
Experimental DKIM rotate/revoke/repudiate script for Exim+Route53. I take no responsibility for its use.
View rotate_dkim.py
#!/usr/bin/env python
import os
import grp
import sys
import stat
import time
import hmac
import boto3
import tempfile
View clean-dnsmasq-ipset.py
#!/usr/bin/env python
import re
import os
import sys
import glob
import signal
import socket
import subprocess
View place_frames.py
#!/usr/bin/env python
from PIL import Image
INFILE = 'place.csv' # expects ts (seconds), x, y, hex color (without #) sorted by timestamp
OUTDIR = 'place_frames' # a directory, expected to exist
def hex2rgb(h):
return (int(h[0:2], 16), int(h[2:4], 16), int(h[4:6], 16))
You can’t perform that action at this time.