Skip to content

Instantly share code, notes, and snippets.

@anka-213
anka-213 / Simple Brainfuck interpreter.py
Created May 22, 2017 12:31
Simple Brainfuck interpreter created by andreaskällberg - https://repl.it/IKt3/2
def get_dir(c):
# return 1 if c == '[' else -1 if c == ']' else 0
dirs = {'[':1, ']': -1}
return dirs[c] if c in dirs else 0
class Code:
code = ""
pc = 0
def __init__(self, code):
self.code = code
@anka-213
anka-213 / Simple Brainfuck interpreter.py
Created May 22, 2017 12:01
Simple Brainfuck interpreter created by andreaskällberg - https://repl.it/IKt3/1
from collections import defaultdict
def get_dir(c):
# return 1 if c == '[' else -1 if c == ']' else 0
dirs = {'[':1, ']': -1}
return dirs[c] if c in dirs else 0
class Code:
code = ""
pc = 0
@anka-213
anka-213 / playground.rs
Created October 12, 2016 20:10 — forked from anonymous/playground.rs
Shared via Rust Playground
#[derive(Debug)]
struct I(i32);
macro_rules! p {
($e:expr) => (println!("{:30}: {:?}", stringify!($e), $e));
}
trait PrefixStuff {
@anka-213
anka-213 / playground.rs
Created September 27, 2016 20:57 — forked from anonymous/playground.rs
Shared via Rust Playground
#![feature(unboxed_closures)]
#![feature(fn_traits)]
#[derive(Clone)]
struct Foo (i32);
type Bar = i32;
impl Foo {
fn go(&self, _: &i32) { }
@anka-213
anka-213 / playground.rs
Created September 27, 2016 00:46 — forked from anonymous/playground.rs
Shared via Rust Playground
#![feature(unboxed_closures)]
#![feature(fn_traits)]
#[derive(Clone)]
struct Pr {
pat: i32 //, mat: Matcher<'a,'a>
}
type MState = i32;
@anka-213
anka-213 / reuse_buf.rs
Last active September 24, 2016 18:22 — forked from anonymous/playground.rs
(un)Safe reusable buffers
//#![feature(question_mark)]
use std::ops::Deref;
use std::ops::DerefMut;
#[derive(Debug, Default)]
struct ReuseBuf {
inner: Vec<u32>,
used: bool
}
@anka-213
anka-213 / defer.rs
Created June 3, 2016 17:23 — forked from anonymous/playground.rs
Shared via Rust Playground
macro_rules! defer {
($x:expr) => {
let _x = {
struct Deferred<F: Fn()>(F);
impl<F: Fn()> Drop for Deferred<F> {
fn drop(&mut self) {
self.0();
}
}
// ==UserScript==
// @name BlockBlockAdBlock
// @namespace http://github.com/anka-213
// @version 0.1.1
// @description Block the BlockAdBlock script
// @author Andreas Källberg
// @match http://blockadblock.com/*
// @grant none
// @run-at document-start
// ==/UserScript==
@anka-213
anka-213 / playground.rs
Created May 12, 2016 22:44 — forked from anonymous/playground.rs
Shared via Rust Playground
#![allow(dead_code)]
#![allow(unused_variables)]
#![allow(unused_mut)]
struct Asdf(i32, Option<Gc<Asdf>>);
struct Gc<T>(*const T);
impl<T> Drop for Gc<T> {
fn drop(&mut self) {
@anka-213
anka-213 / gc.rs
Last active May 12, 2016 22:44 — forked from anonymous/playground.rs
Shared via Rust Playground
#![allow(dead_code)]
#![allow(unused_variables)]
#![allow(unused_mut)]
struct Asdf(i32, Option<Gc<Asdf>>);
struct Gc<T>(*const T);
impl<T> Drop for Gc<T> {
fn drop(&mut self) {