Skip to content

Instantly share code, notes, and snippets.

Avatar
💾

Jake jakekara

💾
View GitHub Profile
View .gitignore
matches
ngrams
*.swp
*.pem
*.json
venv
*.pyc
@jakekara
jakekara / DebugLogger.ts
Created Oct 7, 2020
A quick wrapper for console.log .warn .error functions to improve devtools debugging
View DebugLogger.ts
/**
* A cheap and cheerful logger that wraps console.log, .warn, .error, with
* labeling and silencing to make debugging with devtools easier.
*/
export default class DebugLogger {
private _label: string;
private _silent: boolean;
constructor(label: string) {
this._label = label;
@jakekara
jakekara / README.md
Created Sep 28, 2020
Authenticating with gapi in a react/typescript project
View README.md

Authenticating with Google API in react/typescript project

This was surprisingly annoying to figure out.

I used this Google API documentation for vanilla JS, but it was a lot more trouble than I expected to get it working in a TypeScript React project.

Long story short, you need to install:

  • gapi-script
  • @types/gapi
@jakekara
jakekara / glob.wl
Last active Jul 11, 2020
Find files with matching patterns using wolframscript
View glob.wl
#!/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 Feb 20, 2020
Generate input files for aria2c download manager
View aria2c_input_tools.py
"""
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 Sep 5, 2019
Simple approach to crop the margins of an image
View kill_margins.py
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 Sep 4, 2019
Download images from blakearchive
View blakescrape.py
# 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 Jun 20, 2019
tell me when it's lunch time
View lunch-time-checker.sh
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 Jun 20, 2019
One-liner Bash script that runs python -c to generate 40 (pseudo)random digits
View 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 Apr 11, 2019
scrape all attachments from newhavenct.gov
View nhblob.py
import requests
import magic
import mimetypes
class Blob:
def __init__(self,
blob_id,
base_url="http://www.newhavenct.gov/civicax/filebank/blobdload.aspx?blobid="):