Skip to content

Instantly share code, notes, and snippets.

@tuttlem
tuttlem / strlen.asm
Created January 7, 2013 21:44
strlen - nasm
_strlen:
push rcx ; save and clear out counter
xor rcx, rcx
_strlen_next:
cmp [rdi], byte 0 ; null byte yet?
jz _strlen_null ; yes, get out
@tuttlem
tuttlem / test.c
Created December 28, 2013 06:41
freeglut simple
#include <GL/glut.h>
void resize(int width, int height) {
// avoid div-by-zero
if (height == 0) {
height = 1;
}
// calculate the aspect ratio
@tuttlem
tuttlem / test.lua
Created January 8, 2014 02:21
Testing Lua script
x = 10
@tuttlem
tuttlem / mystify.c
Created February 8, 2015 13:45
Mystify
#include <stdlib.h>
#include <cairo/cairo.h>
#include <gtk/gtk.h>
#include <gdk/gdk.h>
#define N_VERTS 5
#define WIN_WIDTH 1024
@tuttlem
tuttlem / gist:4198408
Created December 3, 2012 21:47
fpu - printing floating points
; compiled on linux 64 bit using the following
;
; nasm -f elf32 print.asm -o print.o
; gcc -m32 print.o -o print
;
[bits 32]
section .text
@tuttlem
tuttlem / basic.asm
Last active June 30, 2019 14:17
Basic MASM32 Boilerplate
; #########################################################################
.386
.model flat, stdcall
option casemap :none
; #########################################################################
include windows.inc
@tuttlem
tuttlem / tree.hs
Created January 3, 2013 21:49
haskell - tree insert
singleton :: a -> Tree a
singleton x = Node x EmptyTree EmptyTree
treeInsert :: (Ord a) => a -> Tree a -> Tree a
treeInsert x EmptyTree = singleton x
treeInsert x (Node a left right)
| x == a = Node x left right
| x < a = Node a (treeInsert x left) right
| x > a = Node a left (treeInsert x right)
@tuttlem
tuttlem / cards.hs
Created December 30, 2012 12:11
haskell - cards shuffle
-- | Seeds a list of cards with a random value
seedCards :: StdGen -> [Card] -> [(Card, Int)]
seedCards g [] = []
seedCards g (c:cs) = x:seedCards ng cs
where (seed, ng) = randomR(1, 10000) g :: (Int, StdGen)
x = (c, seed)
-- | Makes an ordered deck of cards
makeDeck :: [Card]
makeDeck = [Card v s | v <- [Ace .. King], s <- [Heart .. Spade]]
@tuttlem
tuttlem / gist:4131110
Created November 22, 2012 13:12
MessageBox Masm Body
; #########################################################################
.code
start:
invoke GetModuleHandle, NULL ; provides the instance handle
mov hInstance, eax
invoke GetCommandLine ; provides the command line address
mov szCommandLine, eax
@tuttlem
tuttlem / main.go
Created September 27, 2017 14:46
REST API Todo
package main
import (
"os"
"encoding/json"
"net/http"
"strconv"
"github.com/gorilla/mux"
"github.com/gorilla/handlers"