Skip to content

Instantly share code, notes, and snippets.

@marcmartino
marcmartino / machine.js
Last active June 1, 2020 01:15
Generated by XState Viz: https://xstate.js.org/viz
const setSpeechNodeContext = (lang, text) =>
assign({
speechNodeTranscript: {
text,
lang,
},
});
const setListenNodeContext = (lang, responses) =>
@marcmartino
marcmartino / machine.js
Last active May 30, 2020 20:10
Generated by XState Viz: https://xstate.js.org/viz
//
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@marcmartino
marcmartino / consonatJamo.ts
Last active December 31, 2019 21:44
hangul jamo info
export enum jamoAttr {
consonant,
vowel,
singleJamo,
doubleJamo,
composedJamo,
validInitialPosition,
validFinalPosition,
verticalVowel,
horizontalVowel,
@marcmartino
marcmartino / speechExpectation.ts
Created November 27, 2019 16:07
first attempt at fleshing out cogeneration of regex and grammars based on the same adts for use in speech recognition
enum QtyOperators {
Optional,
OnePlus,
ZeroPlus
}
type SpeechExpectation = {
captureName?: string;
qty?: QtyOperators;
inputs: (SpeechExpectation | string)[];
union?: true;
type Tuple<T, U> = [T, U];
type Predicate<T> = (value: T) => boolean;
type Callback<T, U> = (value: T) => U;
type Route<T, U> = <V>(
predicate: Predicate<T>,
callback: Callback<T, V>
) => RouteResponse<T, U | V>;
interface RouteResponse<T, U> {
@marcmartino
marcmartino / CardQueues.d.ts
Last active January 30, 2019 03:39
CardQueues Snippets
type Card = {
id: number,
phrase: string,
translation: string,
};
type CardQueue = Card[] | "Completed";
type CardQueues = [CardQueue, CardQueue];
type UpdatedQueues = {
updatedAt: Date,
queues: CardQueues,
@marcmartino
marcmartino / getOrderedWordsList.sql
Created January 23, 2019 14:38
scripts for getting the next list items
SELECT
Asses.id,
Groups.orderNum,
Defs.phrase, Defs.definition AS translation,
Items.phrase, Items.translation
FROM WordGroups AS Groups
INNER JOIN WordListAssignments AS Asses
ON Groups.id = Asses.wordGroupId
AND Groups.wordListId = 1
INNER JOIN WordListItems AS Items
@marcmartino
marcmartino / wordlists.create.sql
Last active December 30, 2018 01:39
word lists schema
CREATE TABLE `WordLists` (
`id` int NOT NULL AUTO_INCREMENT,
`name` varchar(100) NOT NULL,
`description` varchar(300),
PRIMARY KEY (`id`)
);
CREATE TABLE `WordGroups` (
`id` int NOT NULL AUTO_INCREMENT,
`wordListId` int NOT NULL,
@marcmartino
marcmartino / sm4.ts
Created November 5, 2018 01:30
attempt at sm4, likely inconsistent but sm5 is significantly different so no dwelling
const answers: CardAnswer[] = [
{
"hesitationDetected": true,
"correct": true,
"timeSpent": 5000,
"date": new Date("2018-11-01T15:13:00.000Z")
},
{
"hesitationDetected": false,
"correct": false,
@marcmartino
marcmartino / sm2.ts
Last active November 4, 2018 21:13
typescript implementation of the supermemo 2 algorithm
interface CardAnswer {
[key: string]: (boolean | number | date)
hesitationDetected: boolean;
correct: boolean;
timeSpent: number;
date: date;
ef?: number;
interval?: number;
}