Skip to content

Instantly share code, notes, and snippets.

@technogeeky
technogeeky / from-supertable-to-markdown.py
Created May 21, 2016 21:36
convert supertable datetime to markdown
# you'll need to:
# sudo pip install python-dateutil
# sudo pip install pytz
#
# to run this
import petl as etl
import sys
@technogeeky
technogeeky / Palette.cs
Created July 22, 2014 05:06
barebones palette definition
using System;
using Color32 = UnityEngine.Color32;
namespace KSPPP
{
public class Palette
{
public string name;
public int minSize;
public int maxSize;
@technogeeky
technogeeky / EmptyClass.cs
Last active August 29, 2015 14:04
10 regex/replaces to get ColorBrewer palettes in C#
using System;
using System.Text.RegularExpressions;
using Color32 = UnityEngine.Color32;
using System.Collections.Generic;
using System.Linq;
using KSPPP;
using UnityEngine;
@technogeeky
technogeeky / OffsetArray.cs
Created July 21, 2014 05:33
non-zero-indexed arrays in C# ( csharp ) are not implictly castable.
static Func<int,int,Array> OffsetArray = (size,start) => Array.CreateInstance(typeof(string), new[] { size }, new[] { start });
static Func<int,int,string[]> OffsetArrayString = (size,start) => (string[]) Array.CreateInstance(typeof(string), new[] { size }, new[] { start });
public static void Main ()
{
Array a = OffsetArray(24,1990);
a.SetValue("I was born", 1990);
a.SetValue("I dislocated my shoulder", 1996);
@technogeeky
technogeeky / As.hs
Created July 4, 2012 06:08
start of ASGS for DSLs
{-# LANGUAGE GADTs #-}
import Control.Monad.Fix (fix)
class ArithA eX (f :: * -> *) where
lit :: Int -> eX f Int
(-+-) :: eX f Int -> eX f Int -> eX f Int
class BindA eX (f :: * -> *) where
var :: f t -> eX f t
@technogeeky
technogeeky / notes.hs
Created June 25, 2012 19:33
rudvalis group notes
g = undefined -- group Ru
|| g = [ 2^14 , [3^3 , 5^3] , [ 7 , 13 , 29 ] ]
exp g = [ 2^4 , [] , [3 , 5 , 7 , 13 , 29 ] ]
01 -> ()
02 -> a, b
03 -> a
04 -> a, b, c, d
05 -> a, b
@technogeeky
technogeeky / Lenses.hs
Created June 25, 2012 19:13
paste of edwardk's stuff
infixl 8 ^.
infixr 4 %=
infixr 4 ^=
x ^. l = got (l Getting x)
l %= f = unsetting . l (Setting . f)
l ^= x = l %= const x
type Lens a b = forall f. Functor f => (b -> f b) -> a -> f a
@technogeeky
technogeeky / diractrick.hs
Created May 18, 2012 17:30
short description of Dirac trick
-- The situation Dirac faced was (and we are still) faced with is this:
psi = c_lower ((> 0) energy) + c_lower ((< 0) energy)
psiT = c_raise ((> 0) energy) + c_raise ((< 0) energy)
c_lower = undefined -- a fermion annihilation operator
c_raise = undefined -- a fermion creation operator
--
-- and I have deliberately avoided using pluses and minuses
-- except where we we are actually summing over all possible states