Skip to content

Instantly share code, notes, and snippets.

@84adam
84adam / pdf_text.py
Created January 2, 2020 17:43
Extract text from PDF files
from pdfminer.pdfinterp import PDFResourceManager, PDFPageInterpreter
from pdfminer.converter import TextConverter
from pdfminer.layout import LAParams
from pdfminer.pdfpage import PDFPage
from io import StringIO
import os
def convert_pdf_to_txt(path, pages=None):
if not pages:
pagenums = set()
@84adam
84adam / pdf_url_text.py
Created January 2, 2020 18:12
Extract text from a PDF given its URL
import requests
from pdfminer.pdfinterp import PDFResourceManager, PDFPageInterpreter
from pdfminer.converter import TextConverter
from pdfminer.layout import LAParams
from pdfminer.pdfpage import PDFPage
from io import StringIO, BytesIO
def convert_pdf_to_txt(url, pages=None):
if not pages:
pagenums = set()
@84adam
84adam / ssh_vim_bash_SETUP.md
Last active July 16, 2025 20:05
ssh_vim_bash_SETUP

no root ssh

  1. Create a new non-root user, follow the prompts: # adduser <new-username>
  2. Give sudo permissions to the new user: # usermod -aG sudo <new-username>
  3. Ensure that sudo is installed (which sudo ; if none, install it: apt install sudo)
  4. Check groups for new user: # groups <new-username>
  5. Edit sshd_config settings: # vim /etc/ssh/sshd_config
  6. Under "Authentication", change PermitRootLogin from yes to no: "PermitRootLogin no"
  7. (Optional) Change "MaxAuthTries" to a lower value to limit login attempts for any user: "MaxAuthTries 4"
  8. Save the changes: :wq (save and exit vim)
@84adam
84adam / convert_xyz_pub.py
Created March 15, 2021 18:00
Convert between bitcoin public key types: xpub/ypub/zpub
# convert_xyz_pub.py
# requirements: python3; base58 (`pip install base58`)
import base58
def convert_xyz_pub(in_key, out_key_type):
"""
Based on: https://gist.github.com/freenancial/d82fec076c13158fd34d1c4300b2b300
"""
xpub = b'\x04\x88\xb2\x1e' # mainnet P2PKH or P2SH
@84adam
84adam / AA-Bitcoin-RSS-Feeds.opml
Last active September 6, 2023 16:01
My collection of bitcoin-related RSS newsfeeds.
<?xml version="1.0" encoding="UTF-8"?>
<opml version="1.1">
<head>
<title>
Feeder
</title>
</head>
<body>
<outline title="Stacker+News" text="Stacker+News" type="rss" xmlUrl="https://stacker.news/rss"/>
<outline title="ππ‚πŸπŸ—πŸ–πŸ’" text="ππ‚πŸπŸ—πŸ–πŸ’" type="rss" xmlUrl="https://bc1984.com/rss/"/>

Keybase proof

I hereby claim:

  • I am 84adam on github.
  • I am bc1984adam (https://keybase.io/bc1984adam) on keybase.
  • I have a public key ASDrUT8jKjB08T4GWNscufRGcL8f3n_OwmDxfHfcK8LLRgo

To claim this, I am signing this object:

@84adam
84adam / python-systemd-daemon-example.md
Last active March 23, 2022 22:03
Python Systemd Daemon Example

Create a program in python

Example: x.py prints out increasingly large random numbers, once per second:

import math
from random import randint
from time import sleep

t = 0
import requests
import io
import pandas as pd
# SEE: https://fred.stlouisfed.org/series/T5YIFR/#0
url = """https://fred.stlouisfed.org/graph/fredgraph.csv?bgcolor=%23e1e9f0&chart_type=line&drp=0&fo=open%20sans&graph_bgcolor=%23ffffff&height=450&mode=fred&recession_bars=on&txtcolor=%23444444&ts=12&tts=12&width=1168&nt=0&thu=0&trc=0&show_legend=yes&show_axis_titles=yes&show_tooltip=yes&id=T5YIFR&scale=left&cosd=2003-01-02&line_color=%234572a7&link_values=false&line_style=solid&mark_type=none&mw=3&lw=2&ost=-99999&oet=99999&mma=0&fml=a&fq=Daily&fam=avg&fgst=lin&fgsnd=2020-02-01&line_index=1&transformation=lin&nd=2003-01-02
"""
s = requests.get(url).content
@84adam
84adam / pandas-one-in-two-out-apply.py
Created June 10, 2022 23:07
Apply a function to one column and assign the output to two pandas dataframe columns.
import pandas as pd
# MAKE UP SOME DATA
data = {'id': [1, 2, 3, 4, 5],
'First Name': ['Mary', 'Harry', 'Larry', 'Fairy', 'Dairy',],
'Birth Year': [1930,1940,1950,1960,1970],
'Favorite Color': ['Blue', 'Red', 'Green', 'Pink', 'Orange']}
# CREATE A DATAFRAME
df = pd.DataFrame.from_dict(data)
@84adam
84adam / neutrino-bitcoin-nodes.md
Last active April 12, 2023 23:18
Known Public Neutrino-Enabled Bitcoin Full Nodes
[Application Options]
feeurl=https://nodes.lightning.computer/fees/v1/btc-fee-estimates.json

[Bitcoin]
bitcoin.active=1
bitcoin.mainnet=1
bitcoin.node=neutrino

[neutrino]