Skip to content

Instantly share code, notes, and snippets.

View andjc's full-sized avatar

Andj andjc

  • Melbourne, Australia
View GitHub Profile
@andjc
andjc / to-ipa.py
Created June 11, 2023 12:04 — forked from trhura/to-ipa.py
script to convert burmese syllables to ipa symbols
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
def get_ipa (syllable):
ipa = ''
ipa += get_cons_ipa(syllable)
ipa += get_medial_ipa(syllable)
ipa += get_vowel_ipa (syllable)
if u"\u028A" in ipa:
@andjc
andjc / detect_tagged_pdf.py
Created May 21, 2023 06:28 — forked from joelhsmith/detect_tagged_pdf.py
Python script to check if a PDF has tags. Result is export of tagged content to console and searches it for traditional acrobat tags
from pdfminer3.pdfinterp import PDFResourceManager, PDFPageInterpreter
from pdfminer3.pdfdevice import TagExtractor
from pdfminer3.pdfpage import PDFPage
from io import BytesIO
def convert_pdf(path, password=''):
rsrcmgr = PDFResourceManager()
retstr = BytesIO()
try:
@andjc
andjc / gitzip.sh
Created March 23, 2023 11:46 — forked from LeonardoCardoso/gitzip.sh
Zip folder ignoring files listed on .gitignore
#...
function gitzip() {
git archive -o $@.zip HEAD
}
#... gitzip ZIPPED_FILE_NAME
@andjc
andjc / .bash_profile
Created March 23, 2023 11:44 — forked from signaltrace-dev/.bash_profile
Aliases for Git Bash - handy functions for common tasks
# generated by Git for Windows
test -f ~/.profile && . ~/.profile
test -f ~/.bashrc && . ~/.bashrc
_gitzip(){
CURRDATE=`date +%Y%m%d`
NAME=${PWD##*/}
ARG=$1
LAST_COMMIT=$2
@andjc
andjc / gitzip.sh
Created March 23, 2023 11:44 — forked from dougalcampbell/gitzip.sh
gitzip -- create a zip file of a git project
#!/bin/bash
##
## I usually put this in my .bashrc
##
## When in a git project dir, run 'gitzip foo' to get a 'foo.zip' in the parent
## directory.
gitzip() { git archive HEAD --format=zip --prefix="$*/" > ../"$*.zip"; }
@andjc
andjc / quarter.py
Created March 14, 2023 11:02 — forked from aodin/quarter.py
Python 3 datetime.date subclass
import copy
import datetime
import pickle
# Each quarter corresponds to the following month and day combinations:
_q1 = (3, 31)
_q2 = (6, 30)
_q3 = (9, 30)
_q4 = (12, 31)
@andjc
andjc / thaisort.py
Created February 20, 2023 10:44 — forked from korakot/thaisort.py
Thai Sort
import icu
thkey = icu.Collator.createInstance(icu.Locale('th_TH')).getSortKey
words = 'ไก่ ไข่ ก ฮา'.split()
print(sorted(words, key=thkey)) # ['ก', 'ไก่', 'ไข่', 'ฮา']
@andjc
andjc / 1-unicode-js-regex.md
Created December 22, 2022 08:03 — forked from jakub-g/1-unicode-js-regex.md
Unicode-aware JavaScript regex cheat sheet

Unicode-aware JavaScript regex (Unicode property escapes /\p{..}\P{..}/u) cheat sheet

Browser support MDN

@andjc
andjc / icu_totitle.py
Last active December 22, 2022 00:13
titlecasing: using pyicu, or to_title(), a wrapper to python's inbuilt method str.title().
from icu import Locale, UnicodeString
# loc = Locale.createCanonical("haw_US")
loc = Locale("haw_US")
s1 = "ʻōlelo hawaiʻi"
s2 = "oude ijssel "
print(UnicodeString(s1).toTitle(loc))
print(UnicodeString(s2).toTitle(Locale("nl_NL")).trim())
@andjc
andjc / docstrings.py
Created August 31, 2022 09:35 — forked from redlotus/docstrings.py
Google Style Python Docstrings
# -*- coding: utf-8 -*-
"""Example Google style docstrings.
This module demonstrates documentation as specified by the `Google Python
Style Guide`_. Docstrings may extend over multiple lines. Sections are created
with a section header and a colon followed by a block of indented text.
Example:
Examples can be given using either the ``Example`` or ``Examples``
sections. Sections support any reStructuredText formatting, including