Skip to content

Instantly share code, notes, and snippets.

View rocapp's full-sized avatar
😶‍🌫️

Robbie Capps rocapp

😶‍🌫️
View GitHub Profile
@rocapp
rocapp / list-fftabs.py
Created November 5, 2024 22:22 — forked from tmonjalo/list-fftabs.py
List all Firefox tabs with title and URL
#! /usr/bin/env python3
"""
List all Firefox tabs with title and URL
Supported input: json or jsonlz4 recovery files
Default output: title (URL)
Output format can be specified as argument
"""
@rocapp
rocapp / dd_parallel.sh
Created October 25, 2024 00:10
low-level IO using `dd` in parallel.
#!/usr/bin/env /bin/bash
##
# dd_parallel.sh
# Low-level IO to disks using 'dd' in parallel.
# ref: https://unix.stackexchange.com/a/160526/217521
##
usage() {
echo "Usage: $0 -i <input_file> -o <output_file> -b <block_size:512000B> -c <count:1000> -s <status:progress>"

How to Install PostgreSQL Using cloud-init

cloud-init allows customising and configuring deployed server instances on most popular cloud service providers easily without requiring the use of other related tools like Ansible. Since cloud-init is such a reliable tool, this brief write-up will document the exact steps and procedures to install and setup PostgreSQL on a Debian 12 (Bookworm) server instance.

Get the Key ID From the Public Key

wget -qO- https://www.postgresql.org/media/keys/ACCC4CF8.asc \
  | gpg --with-fingerprint --with-colons \
  | awk -F: '/^fpr/ { print $10 }'
@rocapp
rocapp / bigchalice.py
Created August 24, 2023 16:22 — forked from RogerWebb/bigchalice.py
Deploy AWS Chalice Project via Docker and Serverless Application Model
import boto3, json, os, shutil, subprocess
from argparse import ArgumentParser
"""
Big Chalice Deployer deployes Chalice Apps using the "chalice package ..." command and
modifies the resulting sam.json template to make use of the Docker deployment process
instead of the default, s3 based, process. Additionally, the ability to delete the
resulting SAM App is available via the CLI.
Usage:
@rocapp
rocapp / get-e2-info
Created April 11, 2023 01:18
Tiny CLI for IDrive E2
#!/usr/bin/env python
import requests
import json
import argparse
import configparser
from pathlib import Path
class AWSConfig:
def __init__(self):
def get_best(file):
words = list()
with open(file, 'r') as f:
bf = json.load(f)
sbf = sorted(bf.items(), key=itemgetter(1), reverse=True)
sbf = [bb[0] for bb in sbf]
return sbf[0:int(len(sbf)/2.0)] # chooses the top half
import numpy as np
from tweepy import API, OAuthHandler
import json
auth = OAuthHandler(consumer_key, consumer_secret) # Connect to twitter via oAuth
auth.set_access_token(access_token, access_token_secret)
api = API(auth)
def get_haikus(api):
def haiku(sdict):
sdict = dict([(sk, sv) for sk, sv in sdict.items() if len(sk) >= 3])
first_5 = choose_words(sdict, 5, 0)
seven = choose_words(sdict, 7, 1)
sec_5 = choose_words(sdict, 5, 2)
first_line = ' '.join(first_5)
second_line = ' '.join(seven)
third_line = ' '.join(sec_5)
hai = ', '.join([first_line, second_line, third_line])
with open('haiku.txt', 'a+') as h:
import numpy as np
from nltk.tokenize import word_tokenize
from nltk import pos_tag
def pick_syl(target):
si = 0
choices = list()
while si != target:
if target-si != 1:
cr = np.random.randint(1, target-si)
from nltk.corpus import cmudict
d = cmudict.dict()
def nsyl(word):
return [len(list(y for y in x if y[-1].isdigit())) for x in d[word.lower()]]