Skip to content

Instantly share code, notes, and snippets.

View jahan-addison's full-sized avatar

Jahan Addison jahan-addison

View GitHub Profile
@jahan-addison
jahan-addison / who_is_my_mummy.sh
Created September 10, 2021 18:47 — forked from joechrysler/who_is_my_mummy.sh
Find the nearest parent branch of the current git branch
#!/usr/bin/env zsh
git show-branch -a \
| grep '\*' \
| grep -v `git rev-parse --abbrev-ref HEAD` \
| head -n1 \
| sed 's/.*\[\(.*\)\].*/\1/' \
| sed 's/[\^~].*//'
# How it works:
@jahan-addison
jahan-addison / palidrome.cc
Created March 22, 2021 05:51
palidrome.cc
bool is_palindrome(std::string_view str)
{
auto letters_only{str
| std::views::filter([](char c) { return std::isalnum(c, std::locale{}); })
| std::views::transform([](char c) { return std::tolower(c, std::locale{}); })
};
auto reversed{letters_only | std::views::reverse};
return std::ranges::equal(letters_only, reversed);
}
// License: Public domain
// see: https://creativecommons.org/publicdomain/zero/1.0/deed.en
interface Option<T> {
value: T | null;
}
/**
* First-class None subtype for a value that is Maybe.None.
*/
Feature: Multiple site support
Only blog owners can post to a blog, except administrators,
who can post to all blogs.
Background:
Given a global administrator named "Greg"
And a blog named "Greg's anti-tax rants"
And a customer named "Dr. Bill"
And a blog named "Expensive Therapy" owned by "Dr. Bill"
{
"compilerOptions": {
"alwaysStrict": true,
"experimentalDecorators": true,
"module": "esnext",
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"moduleResolution": "node",
"noEmitOnError": false,
"jsx": "react",
-- https://en.wikipedia.org/wiki/Definite_clause_grammar
-- http://cs.union.edu/~striegnk/learn-prolog-now/html/node59.html#subsec.l7.firstexample
-- This grammar allows sentences like "he likes her" and "he likes him", but not "her likes he" and "him likes him".
sentence --> pronoun(subject), verb_phrase.
verb_phrase --> verb, pronoun(object).
pronoun(subject) --> [he].
pronoun(subject) --> [she].
@jahan-addison
jahan-addison / tsconfig.json
Last active June 21, 2020 00:31
Jahan Recommended tsconfig.json
{
"compilerOptions": {
"alwaysStrict": true,
"experimentalDecorators": true,
"module": "commonjs",
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"moduleResolution": "node",
"noEmitOnError": false,
"strict": true,

The Schema Documentation Language

Overview

The language is designed to be entirely agnostic and platform-independent — It is primarily designed as a comment block above javascript and YAML. By building the schema language as a general-purpose compiler, we have full control over syntax or where it can be used and can build documentation or metadata (such as JSON schema) across the board anywhere in our content.

Targets

The schema language may be compiled to more than one target. Currently, it compiles to JSONSchema — but Jekyll and HTML for self-documentation are in the future roadmap.

myactivity:
metadata:
title: 'Some Great Section'
description: '_____'
tags:
- 'something'
collection:
- 'pages.mypage'
- 'pages.mypage'
- 'pages.mypage'
@jahan-addison
jahan-addison / b.ebnf
Last active September 5, 2019 22:00
B Language LALR(1) EBNF-like grammar
/////////////////////////////////////////////////////////
// B Language Grammar
// Author: Jahan Addison
// LALR(1) EBNF-like Grammar
// Placed under CC0 1.0
/////////////////////////////////////////////////////////
program : ( definition ) *
definition : function_definition