Skip to content

Instantly share code, notes, and snippets.

@gholker
gholker / JpgToPdf.java
Last active February 18, 2024 02:08
JPG to PDF in Java
import com.itextpdf.text.Document;
import com.itextpdf.text.Image;
import com.itextpdf.text.PageSize;
import com.itextpdf.text.pdf.PdfWriter;
import java.io.File;
import java.io.FileOutputStream;
import java.util.ArrayList;
import java.util.List;
@gholker
gholker / download-aws-logs.sh
Last active November 28, 2023 11:01
Script that uses the aws cli to download cloudwatch logs to a file
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
LOG_GROUP_NAME=""
LOG_STREAM_NAME=""
REGION=""
OUTPUT_FILE="$(date +"%Y%m%d").log"
@gholker
gholker / Dockerfile
Last active October 12, 2023 01:30
WhatsApp whapa dockerfile
# This is intended for use with https://github.com/B16f00t/whapa
# Put this file in the root folder as the repo above
#
# Build with `docker build -t gpsoauth_login -f Dockerfile .`
# Run with `docker run -it --rm -v $(pwd)/:/app gpsoauth_login`
#
# From with the bash shell you can run `python3 whagodrive.py`
FROM alpine:3.16
RUN apk upgrade --update-cache --available && \
import os
import sys
# Requires LXML. See: https://lxml.de/installation.html
from lxml import etree as ET
def check_file(path):
print(f'Checking file at path: {path}')
huge_tree_parser = ET.XMLParser(huge_tree=True)
tree = ET.parse(path, huge_tree_parser)
@gholker
gholker / check_xml.py
Last active April 3, 2020 15:29
Parse and print XML to verify the structure manually
import os
import sys
from lxml import etree as ET
def recurse(node, level=0):
for child in node.iterchildren():
text = (child.text or '')
if len(text) > 20:
@gholker
gholker / InternalToExternalSD-XperiaM.md
Last active November 23, 2016 00:53
How to link internal SD to external SD (Sony Xperia M C2005 Android 4.3)

How to link internal sd folder with external folder:

Note: these instructions are somewhat specific to the Sony Xperia M C2005 Android 4.3

  1. Root phone with TowelRoot: https://towelroot.com/
  2. Installed busybox: https://play.google.com/store/apps/details?id=com.bitcubate.root.busybox.complete
  3. Tried "mount -o bind folder1 folder2", but the bind wouldn't work when not root
  4. Used FolderMount app to link the folders (2.9.9 as of writing)
  5. Found that phone would reboot during the process. Found this explanation: