Skip to content

Instantly share code, notes, and snippets.

View lojikil's full-sized avatar
🌊
cantankerous and querulous, he was as the sea to the shore

Logyi, hajnalvédő lojikil

🌊
cantankerous and querulous, he was as the sea to the shore
View GitHub Profile

Crafting a Compiler from Scratch: Implementation Notes

For the past two weeks or so, I've been working on a little compiler project in C, mostly for educational purposes, i.e. to understand how a compiler really works. I'm not using any libraries, other than the C runtime library.

Introduction

I have a hand-written lexer and parser, and a simple code generator targetting

@DarinM223
DarinM223 / typeclassses.md
Last active March 31, 2023 03:35
Typeclasses in Haskell, Scala, and Rust

Type classes

Type classes have some advantages over Java style interfaces. One advantage is the ability to implement functions that do not need to take in an instance of the interface.

For example, (FromString v) takes in a String and returns v, and it doesn't have to take v as a parameter.

@chriseth
chriseth / MyToken.solidity
Created December 19, 2017 15:30
MyToken - IULIA example
contract MyToken {
function MyToken() {
assembly {
// Store the creator at storage slot zero
sstore(0, caller())
}
}
function () payable {
assembly {
// Protection against sending Ether
(* Good morning everyone, I'm currently learning ocaml for one of my CS class and needed to implement
an avl tree using ocaml. I thought that it would be interesting to go a step further and try
to verify the balance property of the avl tree using the type system. Here's the resulting code
annotated for people new to the ideas of type level programming :)
*)
(* the property we are going to try to verify is that at each node of our tree, the height difference between
the left and the right sub-trees is at most of 1. *)
@walm
walm / main.go
Last active May 15, 2024 06:01
Simple Golang DNS Server
package main
import (
"fmt"
"log"
"strconv"
"github.com/miekg/dns"
)
@anvaka
anvaka / 00.Intro.md
Last active June 4, 2024 13:48
npm rank

npm rank

This gist is updated daily via cron job and lists stats for npm packages:

  1. Top 1,000 most depended-upon packages
  2. Top 1,000 packages with largest number of dependencies
  3. Top 1,000 packages with highest PageRank score
@lloeki
lloeki / debian-xhyve.sh
Created August 27, 2015 17:21
Running debian 8.1 in xhyve
#!/bin/bash
# unfortunately debian currently panics in xhyve
tmp=$(mktemp -d)
pushd "$tmp"
iso="$HOME"/Downloads/debian-8.1.0-amd64-netinst.iso
#iso="$HOME"/Downloads/debian-8.1.0-i386-netinst.iso
echo "fixing disk"
dd if=/dev/zero bs=2k count=1 of=tmp.iso
import argparse
import datetime
import urllib
import urllib2
import json
import sys
_token = 'YOUR_SLACK_API_KEY'
_files_list_url = 'https://slack.com/api/files.list'
_files_delete_url = 'https://slack.com/api/files.delete'
@yawaramin
yawaramin / ParseTags.hs
Last active September 18, 2016 14:59
Parse text tags
{-# LANGUAGE OverloadedStrings #-}
module Main where
import qualified Data.Map as M
import qualified Data.Text as T
import qualified Data.Text.IO as TIO
{- A document part is like a piece of syntax. -}
data DocPart =
Tag T.Text [T.Text] | Run T.Text