Skip to content

Instantly share code, notes, and snippets.

@eddieantonio
eddieantonio / sliceable.py
Created February 21, 2021 22:58
Get the slice[start:stop:step] of any Python iterable
class Sliceable:
def __init__(self, iterable):
self.it = iterable
def __getitem__(self, index):
if isinstance(index, int):
return self.it[int]
start = 0 if index.start is None else index.start
stop = inf if index.stop is None else index.stop
@eddieantonio
eddieantonio / itwewina.bib
Created June 29, 2021 21:01
.bib file for dictionary sources cited in itwewina.altlab.app
@book{CW,
title = {{nēhiýawēwin} : {itwēwina} / {Cree} : Words},
editor = {Arok Wolvengrey},
year = 2001,
publisher = {Canadian Plains Research Center},
address = {Regina, Saskatchewan}
}
@book{MD,
title = {{Maskwacîs} Dictionary of {Cree} Words / Nehiyaw Pîkiskweninisa},
@eddieantonio
eddieantonio / interval.cc
Created April 28, 2017 01:22
A C++ interval class with test cases.
/**
* Defining an interval on integer and floating point number lines.
*
* Compile with:
*
* $ c++ -std=c++11 interval.cc -o interval
*
* Run tests:
*
* $ ./interval
@eddieantonio
eddieantonio / word-break-property.ts
Created July 10, 2020 21:47
Wordbreak property enum values
export const enum WordBreakProperty {
/* 0 */ Other,
/* 1 */ LF,
/* 2 */ Newline,
/* 3 */ CR,
/* 4 */ WSegSpace,
/* 5 */ Double_Quote,
/* 6 */ Single_Quote,
/* 7 */ MidNum,
/* 8 */ MidNumLet,
/*!
* Copyright (c) 2020 Eddie Antonio Santos
*
* This Source Code Form is subject to the terms of the Mozilla Public License,
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
* obtain one at http://mozilla.org/MPL/2.0/.
*/
/**
* Simplifies interaction with <template> tags:
@eddieantonio
eddieantonio / create-syllabics-chart.py
Created May 19, 2020 15:05
Create a syllabics chart for Plains Cree (nêhiyawêwin) (ᓀᐦᐃᔭᐤ ᒐᐦᑭᐯᐦᐃᑲᓇ)
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
from cree_sro_syllabics import sro2syllabics
consonants = 'ptkcmnsy'
finals = ('h', 'hk', 'r', 'l', 'w')
vowels_circumflex = 'êioaîôâ'
vowels_macron = 'ēioaīōā'
Object.defineProperty(Set.prototype, 'addAll', {
enumerable: false,
configurable: false,
value: function (iterable) {
for (let item of iterable) {
this.add(item);
}
return this;
}
});
@eddieantonio
eddieantonio / javascript.sty
Last active April 25, 2020 13:34
Simple JavaScript definition for LaTeX's Listings package
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{javascript}[2017/04/13]
% Defines a Listings definition for JavaScript (ECMAscript 2016).
\RequirePackage{listings}
\lstdefinelanguage{JavaScript}{%
keywords={const, let, typeof, instanceof, new, true, false, catch, function, return, null, undefined, catch, switch, var, if, in, while, for, do, else, case, break},
keywordstyle=\bfseries,
@eddieantonio
eddieantonio / javascript-null-undefined.md
Created April 24, 2020 15:31
Checking for `null` or `undefined` in JavaScript

Checking for null or undefined in JavaScript

Say I want to check if a value v is either null or undefined in JavaScript. I might use this conditional:

if (!v) { ... } // 🙅‍♀️ wrong!