Skip to content

Instantly share code, notes, and snippets.

@phase
phase / read-dt.org
Created December 18, 2022 04:17 — forked from queertypes/read-dt.org
Implement a Dependently Typed Language and Then Some
@phase
phase / bf.ml
Created July 25, 2016 04:36 — forked from darkf/bf.ml
Brainfuck interpreter in OCaml
let eval str =
let cells = Array.make 4096 0 in
let ptr = ref 0 in
let len = String.length str in
let rec evalbf c =
if c >= len then
c
else
match String.get str c with
@phase
phase / shell.c
Created July 14, 2016 23:37 — forked from parse/shell.c
Simple shell in C
/* Compile with: g++ -Wall –Werror -o shell shell.c */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
@phase
phase / string.sh
Last active May 17, 2016 03:19 — forked from earthgecko/bash.generate.random.alphanumeric.string.sh
shell/bash generate random string
#!/bin/bash
# bash generate random 5 character string)
cat /dev/urandom | tr -dc 'a-z' | fold -w 5 | head -n 1
@phase
phase / new_ruby_project_procedure.markdown
Created February 6, 2016 09:13
A walkthrough for creating a new Ruby project

New Ruby software project procedure

First, ensure the following tools are available on the local system and reasonably up to date:

  • Git
  • Git-flow
  • RVM
  • Bash
  • SSH
@phase
phase / zalgo.py
Last active November 8, 2015 06:02
Zalgo text generator
import random
import sys
import argparse
#Characters
superscript = [
"\u030d", "\u030e", "\u0304", "\u0305", "\u033f",
"\u0311", "\u0306", "\u0310", "\u0352", "\u0357",
"\u0351", "\u0307", "\u0308", "\u030a", "\u0342",
"\u0343", "\u0344", "\u034a", "\u034b", "\u034c",
@phase
phase / ReturnAdapter.java
Last active September 20, 2015 21:05 — forked from VijayKrishna/ReturnAdapter.java
Example code showing how the AdviceAdapter in ASM(.ow2.org) can be used/extended.
package self.vpalepu.stackoverflow;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.MethodVisitor;
import java.awt.Point;
import java.util.*;
public abstract class AbstractLattice implements Tiling<AbstractLattice.LatticeCell> {
// Use the idea of expansion and vertex mapping from my earlier aperiod tiling implementation.
private Map<Point, Set<LatticeCell>> vertexNeighbourhood = new HashMap<Point, Set<LatticeCell>>();
private int scale = -1;
// Geometry
private final int dx0, dy0, dx1, dy1;
@phase
phase / Fish
Last active August 29, 2015 14:24 — forked from anonymous/Fish
Fish f
⍝ Variables
⎕IO←0 ⍝ Arrays start with 0
S←⍬ ⍝ This will hold the stack(s)
i←'' ⍝ This is an input buffer
s←,0 ⍝ This will hold the markers for [ and ], the first stack is at pos 0.
D←4 2⍴D,⌽D←0 1 0 ¯1 ⍝ Directions
p←0 0 ⍝ Position (start at 0,0)
v←0 ⍝ This is set to 1 when reading a string