Skip to content

Instantly share code, notes, and snippets.

View tiffany352's full-sized avatar

Tiffany Bennett tiffany352

View GitHub Profile
@tiffany352
tiffany352 / bf.rs
Created August 9, 2013 06:28
Brainfuck interpreter in rust
use std::uint;
use std::io;
use std::str;
enum Token {
Add,
Sub,
Inc,
Dec,
Out,
#[ link(name = "frscript",
vers = "0.0",
uuid = "62527026-e47c-44ce-be34-7137e8194772") ];
#[ desc = "FRP Scripting Language" ];
#[ license = "Zlib/libpng" ];
#[ author = "tiffany" ];
#[ crate_type="lib" ];
parse.rs:172:25: 172:47 error: cannot determine a type for this bounded type parameter: unconstrained type
parse.rs:172 Ok(Token {value: TokenCreator::<T>::raw(text.slice(start, end).to_owned()), line: LineInfo::new(text, start+position, end+position)})
^~~~~~~~~~~~~~~~~~~~~~
use parse::*;
#[deriving(Clone)]
pub struct Prefix {
nick: ~str,
user: ~str,
host: ~str
}
impl ToStr for Prefix {
@tiffany352
tiffany352 / gist:7266437
Last active June 27, 2021 23:10
Greasemonkey script to replace html5 video with VLC player, modified from the broken http://userscripts.org/scripts/show/167777
// ==UserScript==
// @name HTML5 video using VLC plugin
// @grant none
// @include *
// ==/UserScript==
function html5vlc(){
var videos = document.getElementsByTagName("video");
var embeds = new Array(videos.length);
for (var i = 0; i < videos.length; i++) {
var vlc = document.createElement("embed");
use std::str::*;
use std::hashmap::*;
pub trait Parser<T>:Clone {
fn parse(&mut self, text: &str, position: uint) -> Result<Token<T>, SyntaxError>;
fn clone_as_owned_trait(&self) -> ~Parser<T>;
}
impl<T> Clone for ~Parser<T> {
fn clone(&self) -> ~Parser<T> {
let res = parse(&grammar, grammar.grammar.get(& &"repl-stat"), line, 0) .map_err(|e| pretty_error(e.line, e.to_str()))
.and_then(|tree| build_ast(&mut state.global, tree.clone()) .map_err(|e| pretty_error(e.line, e.to_str())))
.and_then(|ast| expand_macros(&mut state, ast.clone()) .map_err(|e| pretty_error(e.line, e.to_str())))
.and_then(|ast| typecheck(&mut state.global, ast.clone(), ~[]) .map_err(|e| pretty_error(e.line, e.to_str())))
.and_then(|ast| eval(&mut state, ast, ~[]) .map_err(|e| pretty_error(e.line, e.to_str())));
use std::str::*;
use std::hashmap::*;
trait CloneParser<T> {
fn clone_as_parser(&self) -> ~Parser<T>;
}
impl<T, U: Clone+Parser<T>> CloneParser<T> for U {
fn clone_as_parser(&self) -> ~Parser<T> {
~self.clone() as ~Parser<T>
data foo :: trait {
bar :: int -> int,
baz :: char array
}
data foobar :: struct {
val :: int
}
total 82M
-rwxr-xr-x 1 tiffany tiffany 34M Dec 3 17:22 gdb.exe*
-rwxr-xr-x 1 tiffany tiffany 20M Dec 3 16:30 libicudata50.dll*
-rwxr-xr-x 1 tiffany tiffany 1.8M Dec 3 16:30 icui18n50.dll*
-rwxr-xr-x 1 tiffany tiffany 1.5M Dec 3 16:30 libevent-2-0-5.dll*
-rwxr-xr-x 1 tiffany tiffany 1.4M Dec 3 16:30 libgettextlib-0-18-3.dll*
-rwxr-xr-x 1 tiffany tiffany 1.3M Dec 3 16:30 icuuc50.dll*
-rwxr-xr-x 1 tiffany tiffany 1.2M Dec 3 16:33 libgfortran-3.dll*
-rwxr-xr-x 1 tiffany tiffany 1.2M Dec 3 16:30 libgio-2.0-0.dll*
-rwxr-xr-x 1 tiffany tiffany 1.2M Dec 3 16:30 libglib-2.0-0.dll*