Skip to content

Instantly share code, notes, and snippets.

@janus
janus / 00_readme.md
Created July 17, 2022 05:55 — forked from p4bl0-/00_readme.md
A complete compiler for a simple language (in less than 150 LoC)

This project is a tiny compiler for a very simple language consisting of boolean expression.

The language has two constants: 1 for true and 0 for false, and 4 logic gates: ! (not), & (and), | (or), and ^ (xor).

It can also use parentheses to manage priorities.

Here is its grammar in BNF format:

expr ::= "0" | "1"

@janus
janus / F#
Created April 3, 2019 09:06
Error and Exception
diff --git a/src/GWallet.Backend.Tests/GWallet.Backend.Tests.fsproj b/src/GWallet.Backend.Tests/GWallet.Backend.Tests.fsproj
index c095a47..8317fd1 100644
--- a/src/GWallet.Backend.Tests/GWallet.Backend.Tests.fsproj
+++ b/src/GWallet.Backend.Tests/GWallet.Backend.Tests.fsproj
@@ -72,6 +72,7 @@
<Reference Include="mscorlib" />
<Reference Include="nunit.framework">
<HintPath>..\..\packages\NUnit.2.6.4\lib\nunit.framework.dll</HintPath>
+ <Package>nunit</Package>
</Reference>
@janus
janus / FSharp
Last active February 23, 2019 07:40
Get Address Type
open Nethereum
open System
open System.Threading
open Nethereum.Web3
@janus
janus / rt.js
Created June 5, 2018 19:41
JavaScript Path Route
function Route() {
this.routeMatch = new RouterMatch();
this.indexPaddingStatic = 0;
this.indexPaddingDynamic = 0;
}
Route.prototype.dispatch = function(url) {
let routeCaptures = this.routeMatch.captureGroup;
@janus
janus / route.js
Created May 25, 2018 18:28
Skeleton for Server Router
function Route() {
this.routeMatch = new RouterMatch();
}
Route.prototype.execReg = function(url) {
let re = new RegExp(this.regs);
let myArray = re.exec(url);
return myArray;
@janus
janus / mathProxy.js
Last active May 24, 2018 08:38
Helping kids to play with Math
// This is just a sample script. Paste your real code (javascript or HTML) here.
/*
* Copy right holder Ikjo
* You are free to enjoy, however give credit to Ikjo
* examples
* mathProxy.twofourMultiplyonePlusfivefiveDividethree()
* mathProxy.two_four_Multiply_one_Plus_five_five_Divide_three()
* conditions
* math operators are titlized
* number are lower case
@janus
janus / gist:2a381026d1c07d98bb8aa4228495cde1
Created January 25, 2018 07:53 — forked from CristinaSolana/gist:1885435
Keeping a fork up to date

1. Clone your fork:

git clone git@github.com:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
@janus
janus / flat.js
Created February 21, 2017 07:24
JavaScript function that flattens array of any permutation
/**
* This is 'gentle' way of traversing an array
* and flatten it if it has multiple arrays.
* We chose not to use function reduce becuase
* we want ours to be intuitive.
*/
function flat(arr) {
@janus
janus / gist:1462082
Created December 11, 2011 18:52 — forked from jamescasbon/template.py
Pure python templates using with statement
"""
A really stupid python template language inspired by coffeekup, markaby.
Do not use this code, it will ruin your day. A byproduct of insomnia.
TL;DR
-----
This module defines a template language that allows us to do:
d = Doc()
@janus
janus / error
Created May 15, 2011 17:19 — forked from tj/error
if foo
if bar
something
else
something_else
else
baz