Skip to content

Instantly share code, notes, and snippets.

View jakekara's full-sized avatar
💾

Jake jakekara

💾
View GitHub Profile
@jakekara
jakekara / glob.wl
Last active July 11, 2020 18:22
Find files with matching patterns using wolframscript
#!/usr/bin/env wolframscript
(* Recursively dump a list of files that match a given pattern *)
(* Very basic script to play with Wolfram outside of Notebooks *)
(* Jake Kara <jake@jakekara.com *)
(* Example usage: *)
(* ./glob.wl "*.txt" *)
If[
Length[$ScriptCommandLine] < 2,
@jakekara
jakekara / aria2c_input_tools.py
Created February 20, 2020 20:55
Generate input files for aria2c download manager
"""
Generate input files for aria2c.
For examples and documentation: https://aria2.github.io/manual/en/html/aria2c.html#input-file
"""
import re
class Aria2cInputEntry:
@jakekara
jakekara / kill_margins.py
Created September 5, 2019 13:19
Simple approach to crop the margins of an image
import numpy as np
import cv2
# use the crop_image() function at the bottom. The rest are pretty much helpers.
# works well enough with William Blake illuminated books that I didn't have to
# try anything more sophisticated
def read_image(path):
return cv2.cvtColor(cv2.imread(path), cv2.COLOR_RGB2BGR)
@jakekara
jakekara / blakescrape.py
Created September 4, 2019 20:40
Download images from blakearchive
# Download copies of illuminated texts from from Blake Archive
import json
import requests
from PIL import Image
from io import BytesIO
import os
from progress.bar import Bar
@jakekara
jakekara / lunch-time-checker.sh
Created June 20, 2019 15:23
tell me when it's lunch time
while [ 1 = 1 ]; do if [ $(date +"%H") = "12" ]; then say LUNCH TIME; break; else echo NOT LUNCH TIME; sleep 60; fi; done
@jakekara
jakekara / 40-pseudo-random-digits
Created June 20, 2019 13:14
One-liner Bash script that runs python -c to generate 40 (pseudo)random digits
#!/usr/bin/env bash
# print a pseudorandom string of 40 integers from command line
$(python -c "import random; print(''.join([str(random.randint(0,9)) for x in range(40)]))")
@jakekara
jakekara / nhblob.py
Created April 11, 2019 14:42
scrape all attachments from newhavenct.gov
import requests
import magic
import mimetypes
class Blob:
def __init__(self,
blob_id,
base_url="http://www.newhavenct.gov/civicax/filebank/blobdload.aspx?blobid="):
@jakekara
jakekara / netyet.sh
Last active June 11, 2020 14:07
bash script to check ever minute if a given site is online
#!/usr/bin/env sh
#
# netyet.sh - check a site every minute until it's back online
# jake@jakekara.com
#
# usage: netyet.sh google.com
#
# Read the site as the only command line arg
@jakekara
jakekara / sample usage
Created November 3, 2018 14:29
Search for products on searspartsdirect.com
bash-3.2$ python sears-parts.py "door handle"
WP8519336 Dryer door handle pad
8519373 Dryer door handle screw hole plug (graphite)
8519374 Dryer door handle screw hole plug (black)
@jakekara
jakekara / clean-mess.sh
Last active October 3, 2018 12:49
Convert a SQL text output to CSV, for when someone sends you SQL text output of a table instead of a CSV...
#!/usr/bin/env sh
#
# clean-mess.sh - Convert a SQL text output to CSV, for when
# someone sends you SQL text output of a table instead of a CSV...
#
# Beware, this will not properly handle double spaces in a column
# because that wasn't an issue for the data I received.
#
# In this case, it just does every .mess file in a folder called data