Skip to content

Instantly share code, notes, and snippets.

@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 / lcd.cpp
Created February 21, 2015 15:07
Double buffer arduino sketch
#include <Wire.h>
#include <LiquidCrystal.h>
#define LCD_WIDTH 16
#define LCD_HEIGHT 2
#define LCD_SIZE (LCD_WIDTH * LCD_HEIGHT)
class LCDDoubleBuffer {
@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 / enc.rb
Created February 7, 2015 13:18
Ruby Asymmetric Encryption
#!/usr/bin/env ruby
require 'base64'
require 'openssl'
common = {
:key_length => 4096,
:digest_func => OpenSSL::Digest::SHA256.new
}
@tuttlem
tuttlem / part.cpp
Last active August 29, 2015 14:13
Particle system
#include <alloc.h>
#include <conio.h>
#include <stdlib.h>
#define VIDEO_MODE_MCGA 0x13
#define VIDEO_MODE_TEXT 0x03
#define PARTICLE_COUNT 1000
@tuttlem
tuttlem / MVar.hs
Created March 19, 2014 04:49
MVar example
import Control.Concurrent
import Control.Concurrent.MVar
main :: IO ()
main = do
-- create an empty mvar
m <- newEmptyMVar
-- get another thread to put a value in it
forkIO $ putMVar m "A value"
@tuttlem
tuttlem / Lens.hs
Created March 18, 2014 14:29
Lens example
{-# LANGUAGE TemplateHaskell #-}
import Control.Lens
data Ball = Ball { _position :: (Double, Double), _velocity :: (Double, Double) }
deriving (Show)
-- create the accessors for the Ball type
makeLenses ''Ball
@tuttlem
tuttlem / StateMonad.hs
Created March 16, 2014 11:16
State Monad example
import Control.Monad.State
-- | Starts a value off.
-- This function doesn't perform any calculation at all, it just prepares an
-- initial value to start in the calculation pipeline
--
start :: Int -> State [String] Int
start x = do
put ["Starting with " ++ show x]
return x
@tuttlem
tuttlem / WriterMonad.hs
Created March 16, 2014 10:38
WriterMonad example
import Control.Monad.Writer
-- | Starts a value off.
-- This function doesn't perform any calculation at all, it just prepares an
-- initial value to start in the calculation pipeline
--
start :: Int -> Writer [String] Int
start x = do
tell (["Starting with " ++ show x])
return x
@tuttlem
tuttlem / ReaderMonad.hs
Created March 16, 2014 09:53
Reader monad example
import Control.Monad.Reader
-- | Shared configuration for this application.
-- Rather trivial (and useless), it just configures how our application will
-- address the user
--
data SalutationConfig = SalutationConfig { formal :: Bool }
-- | Returns a greeting
-- Takes in someone's name and returns a greeting string