Skip to content

Instantly share code, notes, and snippets.

View check_cfr.py
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 Apr 3, 2020
Parse and print XML to verify the structure manually
View check_xml.py
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 / download-aws-logs.sh
Last active Jul 23, 2021
Script that uses the aws cli to download cloudwatch logs to a file
View download-aws-logs.sh
#!/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 / InternalToExternalSD-XperiaM.md
Last active Nov 23, 2016
How to link internal SD to external SD (Sony Xperia M C2005 Android 4.3)
View InternalToExternalSD-XperiaM.md

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:
@gholker
gholker / JpgToPdf.java
Last active Jul 5, 2021
JPG to PDF in Java
View JpgToPdf.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;