Skip to content

Instantly share code, notes, and snippets.

View andjc's full-sized avatar

Andj andjc

  • Melbourne, Australia
View GitHub Profile
@andjc
andjc / UAX_29.py
Created February 28, 2024 03:07 — forked from HughP/UAX_29.py
PyICU
# We start by loading up PyICU.
import PyICU as icu
# Let's create a test text. Notice it contains some punctuation.
test = u"This is (\"a\") test!"
# We create a wordbreak iterator. All break iterators in ICU are really RuleBasedBreakIterators, and we need to tell it which locale to take the word break rules from. Most locales have the same rules for UAX#29 so we will use English.
wb = icu.BreakIterator.createWordInstance(icu.Locale.getEnglish())
# An iterator is just that. It contains state and then we iterate over it. The state in this case is the text we want to break. So we set that.
@andjc
andjc / work-with-multiple-github-accounts.md
Created August 7, 2023 15:33 — forked from rahularity/work-with-multiple-github-accounts.md
How To Work With Multiple Github Accounts on your PC

How To Work With Multiple Github Accounts on a single Machine

Let suppose I have two github accounts, https://github.com/rahul-office and https://github.com/rahul-personal. Now i want to setup my mac to easily talk to both the github accounts.

NOTE: This logic can be extended to more than two accounts also. :)

The setup can be done in 5 easy steps:

Steps:

  • Step 1 : Create SSH keys for all accounts
  • Step 2 : Add SSH keys to SSH Agent
@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