Skip to content

Instantly share code, notes, and snippets.

View jakekara's full-sized avatar
💾

Jake jakekara

💾
View GitHub Profile
@jakekara
jakekara / lseek_size.c
Created May 10, 2017 14:18
Get a file size two ways -- using lseek and using stat.
/*
* determine a file's size with lseek
*/
#include <unistd.h> /* for lseek */
#include <stdio.h> /* for printf */
#include <fcntl.h> /* for open */
int main(int ac, char *av[])
{
@jakekara
jakekara / copy-dot-envs.py
Last active January 18, 2024 20:51
Copy dotenv files
"""Make a copy of all of my .env files in all of my projects"""
import os
import glob
import shutil
PROJECTS_DIR=os.path.expanduser("~/Projects/")
DEST_DIR = "dot_files"
try:
@jakekara
jakekara / comparison-python-3.12-versus-3.12-alpine.txt
Last active November 16, 2023 01:18
docker scout comparison of python:3.12-alpine versus python:3.12-alpine
## Overview
│ Analyzed Image │ Comparison Image
────────────────────┼────────────────────────────────────┼──────────────────────────────
Target │ python:3.12 │ python:3.12-alpine
digest │ 5a2936b50ea6 │ dc2e8896e2bc
platform │ linux/amd64 │ linux/amd64
vulnerabilities │ 1C 1H 8M 93L 5? │ 0C 2H 1M 0L
@jakekara
jakekara / python-3.12-alpine-patched.Dockerfile
Created November 16, 2023 01:17
Patched Dockerfile for python:3.12-alpine
# Dockerfile that patches 3.12-alpine
# as of Nov. 15, 2023771
# `docker scout cves` reports no vulnerabilities
FROM python:3.12-alpine
# Fixes CVE for pip
# https://scout.docker.com/v/CVE-2023-5752
RUN pip install --upgrade pip
@jakekara
jakekara / inbox_lambda.js
Created November 19, 2022 20:41
use lambda -> s3 as activitypub inbox
import json
import boto3
from hashlib import md5
from datetime import datetime
// simple lambda to act as an activitypub inbox so you can receive
// follow requests, comments, etc from other servers.
// 1. set this up in a lambda and point API gateway at it.
// 2. set the api URL as your inbox in your actor JSON response
@jakekara
jakekara / deliver.py
Last active November 19, 2022 19:41
deliver.py - send activitypub payload to mastodon server
"""
Deliver an ActivityPub message to an inbox
This is largely based on a ruby example `deliver.rb` from this blog post:
https://blog.joinmastodon.org/2018/06/how-to-implement-a-basic-activitypub-server/
"""
from datetime import datetime
@jakekara
jakekara / png_structure.py
Created December 12, 2016 00:41
Just some idle poking around inside the PNG file format with python. Ugly code, maybe-useful comments.
# Exploration in PNG
#
# Just poking through the PNG file structure.
#
# Found weird output when examining MacOS screenshots. They contain an
# "iDOT" chunk, the purpose of which I couldn't determine. This chunk type
# is not part of the PNG standard, and seems to break some programs'
# ability to process these files, according to complaints I'm finding on
# Google. See sample output below. If no one's already done it, maybe there
# is some value in writing e script to strip out these invalid iDOT chunks.
@jakekara
jakekara / generate-lambda-version-delete-commands.sh
Last active July 5, 2022 16:27
Generate delete commands for old versions of lambdas
# Generate a bunch of commands to delete all versions of
# lambdas with a given LAMBA_PREFIX
#
# this script generates `delete-commands.sh` which you can
# inspect first before running. this is super dangerous so
# you probably should not use this script.
LAMBDA_PREFIX=example-lambda-group-name
for FUNCTION in $(aws lambda list-functions --region=us-east-1 \
@jakekara
jakekara / README.md
Created September 28, 2020 19:49
Authenticating with gapi in a react/typescript project

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 / textgenrnn_ubuntu2104.sh
Last active June 9, 2021 19:32 — forked from pleonard212/textgenrnn_ubuntu2104.sh
textgenrnn ubuntu 21.04
conda create --name textgenrnn python
conda activate textgenrnn
conda install cudatoolkit==10.2.89
# this special conda source is vital to get the correct 8.1.x version of cudnn:
conda install -c conda-forge cudnn
git clone https://github.com/minimaxir/textgenrnn.git
cd textgenrnn
pip install -r requirements.txt