Skip to content

Instantly share code, notes, and snippets.

View boj's full-sized avatar

Brian Jones boj

View GitHub Profile
@boj
boj / SimplexNoise.cs
Created February 7, 2012 14:14
Stefan Gustavson's "Simplex noise demystified" in C# + Unity3d Mathf methods.
using UnityEngine;
using System.Collections;
// copied and modified from http://webstaff.itn.liu.se/~stegu/simplexnoise/simplexnoise.pdf
public class SimplexNoise { // Simplex noise in 2D, 3D and 4D
private static int[][] grad3 = new int[][] {
new int[] {1,1,0}, new int[] {-1,1,0}, new int[] {1,-1,0}, new int[] {-1,-1,0},
new int[] {1,0,1}, new int[] {-1,0,1}, new int[] {1,0,-1}, new int[] {-1,0,-1},
new int[] {0,1,1}, new int[] {0,-1,1}, new int[] {0,1,-1}, new int[] {0,-1,-1}};
@boj
boj / config
Last active February 15, 2023 18:02
VMWare NixOS
// .config/termite/config
[options]
font = Liberation Mono 10
[colors]
foreground = #FFFFFF
background = #000000
@boj
boj / ColorPicker.cs
Created August 30, 2011 17:39
Unity3d Color Picker
using UnityEngine;
using System.Collections;
// relies on: http://forum.unity3d.com/threads/12031-create-random-colors?p=84625&viewfull=1#post84625
public class ColorPicker : MonoBehaviour {
public bool useDefinedPosition = false;
public int positionLeft = 0;
public int positionTop = 0;
@boj
boj / Oscillator.cs
Created November 9, 2012 15:43
Oscillator Experiment
using UnityEngine;
using System;
using System.Diagnostics;
using System.Threading;
// http://www.codeproject.com/Articles/30180/Simple-Signal-Generator
// http://blogs.msdn.com/b/dawate/archive/2009/06/25/intro-to-audio-programming-part-4-algorithms-for-different-sound-waves-in-c.aspx
class Oscilator : MonoBehaviour {
@boj
boj / Shader.shader
Created February 11, 2012 07:31
Grayscale Shader
Shader "Custom/Grey Texture" {
Properties {
_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
}
SubShader {
Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
LOD 200
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TemplateHaskell #-}
module Main where
import Control.Lens
import GHC.Generics
@boj
boj / Main.hs
Last active March 27, 2020 21:42
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TypeSynonymInstances #-}
{-# LANGUAGE TypeFamilies #-}
module Main where
import Data.Coerce
@boj
boj / Main.hs
Last active March 27, 2020 21:07
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TypeSynonymInstances #-}
{-# LANGUAGE TypeFamilies #-}
module Main where
import Data.Coerce
import Data.Tagged
data Validated
module Main where
import Data.Coerce
data Validated
data Unvalidated
class AbstractError e
data MyError = MyError String deriving (Show)
@boj
boj / shell.nix
Created February 29, 2020 00:38
Shell for hacking on Haskell Servant
{ compiler ? "ghc844" }:
let
nixpkgs = import <nixpkgs> {};
inherit (nixpkgs) pkgs stdenv;
in
# Make a new "derivation" that represents our shell
stdenv.mkDerivation {
name = "servant-dev";