Skip to content

Instantly share code, notes, and snippets.

@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

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 / 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/"/>
@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 / ssh_vim_bash_SETUP.md
Last active November 20, 2020 01:27
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. Check groups for new user: # groups <new-username>
  4. Edit sshd_config settings: # vim /etc/ssh/sshd_config
  5. Under "Authentication", change PermitRootLogin from yes to no: "PermitRootLogin no"
  6. (Optional) Change "MaxAuthTries" to a lower value to limit login attempts for any user: "MaxAuthTries 4"
  7. Save the changes: :wq (save and exit vim)
  8. Restart the ssh daemon: # systemctl restart sshd
@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 / 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 / .vimrc
Last active September 15, 2022 14:40
Vim configuration
set wrap
set number
set colorcolumn=80
syntax on
set tabstop=4
set softtabstop=4
set shiftwidth=4
set expandtab
let g:go_highlight_trailing_whitespace_error=0
@84adam
84adam / btc-mc-EMA-plot.py
Last active October 12, 2022 17:22
Plot BTC Market Cap Weekly EMAs
import datetime as dt
import requests
import io
import pandas as pd
import matplotlib.pyplot as plt
from matplotlib.pyplot import figure
from matplotlib import ticker
from matplotlib.ticker import (MultipleLocator, FormatStrFormatter, AutoMinorLocator)
%matplotlib inline
@84adam
84adam / noroot-ssh.txt
Created September 16, 2019 12:07
Create new sudo user; disable root login via SSH
# create a new non-root user
adduser <new-username>
# follow prompts
# give sudo permissions to the new user
usermod -aG sudo <new-username>
# check groups for new user
groups <new-username>