Skip to content

Instantly share code, notes, and snippets.

Avatar

Xavier Perez DuoSRX

View GitHub Profile
@DuoSRX
DuoSRX / bf.scala
Created Mar 8, 2015
Brainfuck in Scala
View bf.scala
import scala.util.parsing.combinator.RegexParsers
object BF extends App {
val raw = "+foobar+++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>."
val program = BFParser.parseAll(BFParser.program, raw).get
val vm = new VM(program)
vm.run
}
trait Command
@DuoSRX
DuoSRX / Main.hs
Created Dec 7, 2014
simplistic haskell web server
View Main.hs
{-# LANGUAGE ScopedTypeVariables #-}
module Main where
import Network (listenOn, withSocketsDo, accept, PortID(..), Socket)
import Control.Concurrent (forkIO)
import Control.Exception (handle, IOException)
import Control.Monad (liftM)
import System.IO (hSetBuffering, hPutStr, hClose, hGetContents, BufferMode(..), Handle, readFile)
import Debug.Trace
View keybase.md

Keybase proof

I hereby claim:

  • I am duosrx on github.
  • I am duosrx (https://keybase.io/duosrx) on keybase.
  • I have a public key whose fingerprint is E7BB 0DC5 2071 C340 14A0 68DE 477F 5091 D9BC 863D

To claim this, I am signing this object:

@DuoSRX
DuoSRX / brainfuck.rs
Created May 26, 2014
Brainfuck in Rust
View brainfuck.rs
use std::char::from_u32;
use std::str::from_char;
#[deriving(Eq, Show)]
pub enum Command {
Add(int),
Move(int),
Output,
LoopIn,
LoopOut,
@DuoSRX
DuoSRX / sidekiq.go
Last active May 6, 2021
Enqueue Sidekiq jobs from Go
View sidekiq.go
package main
import (
"crypto/rand"
"encoding/hex"
"encoding/json"
"fmt"
"github.com/garyburd/redigo/redis"
"io"
"time"
@DuoSRX
DuoSRX / gist:2363468
Created Apr 11, 2012
random dcpu16 stuff
View gist:2363468
set a, data
jsr strlen
set b, a
set a, data
jsr reverse
jsr print
set PC, end
; reverse the string in place at [a], of len b
:reverse
View schemy.rb
# Partial Scheme interpreter
# Heavily inspired by Peter Norvig's Lispy (http://norvig.com/lispy.html)
# TODO: add more datatypes (strings, floats)
# TODO: allow multiple arguments, like (+ 1 2 3 4 5)
class Env < Hash
def initialize(ks = [], vs = [], outer = nil)
@outer = outer
ks.zip(vs).each {|item| store(item[0], item[1])}
View gist:1288665
# 1.8
> 1.to_a
[1]
> 1.respond_to?(:to_a)
true
> a,b = 10
[10]
> a
[10]
> b
View gist:1068293
# Befunge-93 interpreter (http://en.wikipedia.org/wiki/Befunge)
class BefungeParser
attr_accessor :stack, :program, :px, :py, :direction, :debug_mode
Binary_ops = ['*', '+', '-', '/', '%']
def initialize(code)
@stack = []
@program = []
@px = 0
View gist:1067618
# A very simple Brainfuck interpreter
class BFParser
attr_accessor :memory, :loop_out, :loop_in, :code_size, :code
def initialize(code, stack_size = 10000)
@memory = [0] * stack_size
@code = code.split(//)
@code_size = code.length
@loop_in = []