Skip to content

Instantly share code, notes, and snippets.

Eddie Antonio Santos eddieantonio

Block or report user

Report or block eddieantonio

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@eddieantonio
eddieantonio / dice.py
Created Aug 12, 2019
Showcase of dataclasses and module __getattr__().
View dice.py
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
from dataclasses import dataclass
from random import randint
import re
dn = re.compile(r'd([123456789][0123456789]*)')
__all__ = ['Die']
View huff.erl
%% Huffman Code for nêhiyawêwin %%
%% Note: Cree strings must be written in "askiy":
%% - short vowels and consonants: written in ASCII
%% - long vowels: ê is written as e; "âîô" written as "AIO" respectively.
%% - it's a very grounded character encoding 😉
%%
%% I haven't done extensive testing, but this usually uses half the bits to
%% represent Cree word forms. Maybe just gzip it instead?
-module(huff).
-export([encode/1, decode/1, tryit/1]).
@eddieantonio
eddieantonio / nrc_cr_cans.keyman-touch-layout
Last active Jul 9, 2019
Draft Plains Cree syllabics touch keyboard
View nrc_cr_cans.keyman-touch-layout
{
"phone": {
"font": "Euphemia",
"layer": [
{
"id": "default",
"row": [
{
"id": 1,
"key": [
@eddieantonio
eddieantonio / $cree-grapheme-stats.md
Last active Jun 25, 2019
Count unigrams and bigrams in the Wolfart-Ahenakew corpus
View $cree-grapheme-stats.md

Cree Grapheme Stats

Count unigrams and bigrams in the Wolfart-Ahenakew nêhiyawêwin corpus!

Why

When building a keyboard for typing Cree, it is useful to know which graphemes are typed often, and which pairs of graphemes are typed one

@eddieantonio
eddieantonio / nonullfree.c
Last active Apr 10, 2019
nonullfree.c -- throw errors when you call free(NULL)
View nonullfree.c
/**
* nonullfree.c -- throw errors when you call free(NULL)
*
* BUILDING:
*
* $ gcc -shared -fPIC nonullfree.c -ldl -o nonullfree.so
*
* USAGE (Linux):
*
* $ LD_PRELOAD=./nonullfree.so ./my-program
@eddieantonio
eddieantonio / compile_c_inline.py
Last active Mar 18, 2019
Demo of compiling a small C dynamic library in a Python script and directly loading it with ctypes.
View compile_c_inline.py
import ctypes
import tempfile
import distutils.ccompiler
from pathlib import Path
from random import randint
SOURCE_CODE = f"""
int roll(void) {{
return {randint(1, 6)};
@eddieantonio
eddieantonio / generate_forms_hfst.py
Last active Mar 9, 2019
Generate word forms using hfst-optimized-lookup
View generate_forms_hfst.py
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
# Copyright 2019 Eddie Antonio Santos <easantos@ualberta.ca>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
View using-the-fsts-example.py
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
# Install `fst_lookup` using pip:
#
# $ pip install fst-lookup
#
# Or, if you're using pipenv:
#
# $ pipenv install fst-lookup
View dull.py
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
"""
dull(1) dull(1)
NAME
dull -- the opposite of pointed
@eddieantonio
eddieantonio / pipe.py
Last active Dec 10, 2018
ceci n'est pas une pipe
View pipe.py
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
import re
from dataclasses import dataclass
from functools import partial
from typing import TypeVar, Generic, Callable
from unicodedata import normalize
A = TypeVar('A')
You can’t perform that action at this time.