Skip to content

Instantly share code, notes, and snippets.

View jamiltron's full-sized avatar

Justin Hamilton jamiltron

View GitHub Profile
@jamiltron
jamiltron / sdl_mixer_ogg.cpp
Last active June 16, 2017 04:18
sdl_mixer_ogg
#include <SDL.h>
#include <SDL_mixer.h>
#include <string>
#include <iostream>
Mix_Music *music = nullptr;
int main(int argc, char* argv[]) {
if (SDL_Init(SDL_INIT_AUDIO) < 0) {
return -1;
@jamiltron
jamiltron / ogg.cpp
Created June 16, 2017 02:07
Ogg file causes SFML-Audio 2.4.2 to hang forever.
#include <SFML/Audio.hpp>
#include <SFML/System.hpp>
#include <memory>
#include <fstream>
#include <iostream>
#include <string>
#include <algorithm>
class MyStream: public sf::InputStream
{
using UnityEngine;
using System.Collections;
public class TileMapMeshBuilder {
private static int vertsByTile = 4;
private Transform parentTransform;
private TileMap tileMap;
private Material tileMaterial;
@jamiltron
jamiltron / NetworkClient.cs
Created November 23, 2015 00:30
Unity LLAPI networking client/server
using System.Collections;
using System.Runtime.Serialization.Formatters.Binary;
using System.IO;
using UnityEngine;
using UnityEngine.Networking;
public class NetworkClient : MonoBehaviour {
public string host = "127.0.0.1";
public int port = 8000;
/** @const */ var ONE = 1;
/**
* A function to add 1 to a number.
* @param {number} n a number to be added.
* @return {number} The number + 1.
*/
var addOne = function (n) {
return n + ONE;
}
@jamiltron
jamiltron / Intermediate.hs
Created June 27, 2012 21:30
20 Intermediate Haskell Solutions
class Fluffy f where
furry :: (a -> b) -> f a -> f b
-- Exercise 1
-- Relative Difficulty: 1
instance Fluffy [] where
furry _ [] = []
furry f (x:xs) = (f x):(furry f xs)
-- Exercise 2
@jamiltron
jamiltron / Stack.hs
Created May 18, 2012 21:54
Haskell stack implementation using StateT and IO Maybe Integer
-- IO (Maybe Integer Stack)
-- I can't find the code currently I am basing this off of, but I wanted to be
-- able to learn more about using StateT along with Maybe types.
import Control.Monad.State
main :: IO ()
main = runStateT code Nothing >> return ()
code :: StateT (Maybe [Integer]) IO ()
code = do
@jamiltron
jamiltron / 5_2_1.rkt
Created January 27, 2012 04:59
Exercise 5.2.1 from TAPL in Racket
#lang racket
;; tru = \t. \f. t
(define tru
(lambda [t]
(lambda [f] t)))
;; fls = \t. \f. f
(define fls
(lambda [t]
@jamiltron
jamiltron / baseconv.clj
Created October 13, 2011 19:07
num to base 62
(def base62-alphabet
"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
(defn num->base62 [x]
(letfn [(base-conv [curr q]
(if (>= 0 q) curr
(recur (conj curr (nth base62-alphabet (rem q 62))) (quot q 62))))]
(base-conv '() x)))
@jamiltron
jamiltron / adder.lisp
Created September 30, 2011 17:05
Adder Closure example/question
(defun make-adder (x)
(lambda (y) (+ x y)))
(defun add-5 (x)
(funcall (make-adder 5) x))
(defun add-6 (x)
(funcall (make-adder 6) x))
(add-5 20)