This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Usage: ./fix-sony-heif /path/to/directory/with/photos | |
# Works by fixing EXIF rotation info and renaming .HIF to .HEIC. | |
# Based on discussion here: https://www.reddit.com/r/SonyAlpha/comments/173qnzg/comment/kr4dcoc/ | |
if [ $# == 1 ]; then | |
cd $1 | |
fi | |
exiftool '-Orientation<CameraOrientation' -ext hif * -r |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A solver for A-Puzzle-A-Day from https://www.thingiverse.com/thing:4876979 | |
# Solutions are printed with terminal color escape sequences. | |
from typing import Dict, List, Tuple | |
import attrs | |
import numpy as np | |
import termcolor | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name .io Link for GitHub Profiles | |
// @namespace http://zecong.hu/ | |
// @version 0.1 | |
// @description Adds a link to github.io website if the user has such a repository. | |
// @author Zecong Hu | |
// @include /^https?:\/\/(www\.)?github\.com\/([^\/]+)\/?$/ | |
// ==/UserScript== | |
(function() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# There are times when you're supposed to output a JSONL file, but forgot to put newlines between JSON objects. | |
# The `pickle` package can handle things like that, but `json` would complain that there are extra trailing characters | |
# and refuse to parse, although it's perfectly capable of doing so. What a stupid design. | |
# This snippet utilized lower-level APIs in `json` to handle such case. | |
import json | |
from typing import Any, List | |
import tqdm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from PyPDF2 import PdfFileReader, PdfFileWriter | |
from PyPDF2.filters import FlateDecode | |
DIR = "path/to/pdf/file" | |
def main(): | |
pdf = PdfFileReader(os.path.join(DIR, "pfpl.pdf")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import itertools | |
from typing import List, Optional | |
import requests | |
def get_url(url_base: str, xs: List[int]) -> str: | |
return url_base + "".join(chr(x + 97) for x in xs) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright (c) 2021 Zecong Hu | |
# | |
# Permission to use, copy, modify, and/or distribute this software for any | |
# purpose with or without fee is hereby granted. | |
# | |
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | |
# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY | |
# AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | |
# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | |
# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR |