Skip to content

Instantly share code, notes, and snippets.

@igorw
igorw / AccessMap.php
Last active August 29, 2015 14:11
Code generated using a markov chain. Input is the symfony code base. Markov transitions use 18-grams, and there is a `php -l` check. DISCLAIMER: These files are generated! Run them at your own risk!
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* @see Symfony\Component\HttpFoundation;
/**
<?php
$n = 6;
$rules = [];
$ngrams = [];
foreach (read_csv('tweets.csv') as $data) {
$source = $data['text'];
$source = htmlspecialchars_decode($source);
.comm tape,4000,32
.globl i
.data
.align 8
.type i, @object
.size i, 8
i:
.quad tape
.section .rodata
@igorw
igorw / past.php
Created October 24, 2014 19:43
The Past Monad
<?php
namespace igorw;
class Past {
private $value;
private $pastValues;
function __construct($value, array $pastValues = []) {
$this->value = $value;

kayladnls/machine-forget

A simple machine forgetting library.

Example

Here is an example of how you can instruct the machine to forget the answer:

# data
store 0 "Hello, world of spaces!"
# p = 0
push 0
label 3 # beginning
# *p
dup
@igorw
igorw / binary-adder.php
Last active August 29, 2015 14:04
A binary full adder. Inspired by The Reasoned Schemer.
<?php
function bit_xor($x, $y) {
return intval($x xor $y);
}
function bit_and($x, $y) {
return intval($x && $y);
}
<?php
namespace igorw\lusp;
// all functions return a pair of [val, env]
function evaluate($expr, $env = []) {
if (is_string($expr)) {
if (is_numeric($expr)) {
$val = (float) $expr;
<?php
require 'vendor/autoload.php';
$loop = React\EventLoop\Factory::create();
$socket = new React\Socket\Server($loop);
$socket->on('connection', function ($conn) {
echo "Oh look! A connection!\n";
$conn->pipe($conn);
(run* [q]
(fresh [a d]
(!= (lcons a d) '(2))
(== (lcons a d) '(2))
(== q [a d])))
;= ([2 ()])