Skip to content

Instantly share code, notes, and snippets.

View mnemnion's full-sized avatar

Sam Atman mnemnion

  • Eastern Standard Tribe
View GitHub Profile
@mnemnion
mnemnion / seq-string.clj
Created October 16, 2013 17:28
seq-string turns a string into a seq on the characters.
(defn seq-string
"make a string seqable by character"
[split-me]
(seq (drop 1 (clojure.string/split split-me #""))))
( brute force ngaro assembler )
chain: ming'
: nop, 0 , ; immediate
: drop, 3 , ; immediate
: pop, 6 , ; immediate
: ;, 9 , ; immediate
: !jump, 12 , ; immediate
@mnemnion
mnemnion / hexdump.rx
Created April 16, 2014 17:45
A simple hex dump for Retro (11)
( Simple Hex Dump )
needs bad'
needs console'
8 constant (dump-width)
: putxt xt->d d->name puts ;
: hexabyte ( "hexes a byte" )
dup 10 <
@mnemnion
mnemnion / unprintable.txt
Created April 30, 2014 15:43
The bottom points of UTF-8.
       
                  ! " # $ % & ' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z [ \ ] ^ _ ` a b c d e f g h i j k l m n o p q r s t u v w x y z { | } ~ 
@mnemnion
mnemnion / badconst.rs
Created November 23, 2014 16:06
Constancy broken by newtype unwrapping
#![feature(tuple_indexing)]
use std::default::Default;
const WORKS_CONST: uint = 23 ;
const ALSO_WORKS_CONST: uint = WORKS_CONST + 5 ;
struct Wrapper(uint);
const WRAPPED_CONST: Wrapper = Wrapper(42) ;
const BAD_CONST: uint = WRAPPED_CONST.0 ;
@mnemnion
mnemnion / warnme.rs
Created November 23, 2014 17:24
This should be at least warned against
type Cell = u32 ;
type Kilo = u32 ;
fn main() {
let x: Cell = 5 ;
let y: Kilo = 10 ;
let z = x + y ;
println!("Cell is {}, Kilo is {}, Nonsense is {}", x, y, z);
}
@mnemnion
mnemnion / constr.rs
Created December 3, 2014 17:42
Constants aren't literal?
use std::fmt;
const FORMATTER: &'static str = "{}" ;
fn main() {
let x = 5i;
println! (FORMATTER, x);
}
@mnemnion
mnemnion / nilortwelve.lua
Created December 4, 2014 08:13
Inconsistent behavior between Lua 5.1 and LuaJit
function advise (adviceFn, ogFn)
return function (...) adviceFn(unpack(arg)) ogFn(unpack(arg)) end
end
function foo (x)
print ("foo")
print (x)
end
package main
import "fmt"
import "github.com/pointlander/peg"
type pegger peg.Peg {
fmt.Printf("hi")
}
func main() {
@mnemnion
mnemnion / dt.sh
Created July 16, 2016 02:25
Simple Bash functions: file -> .file, and .file -> file
#lazyfuncs for dotting and undotting stuff
function dt {
for file in "$@"; do
if [[ ${file:0:1} != "." ]]
then mv $file ".$file"
else echo "$file is already dotted"
fi
done
}