Skip to content

Instantly share code, notes, and snippets.

View praeclarum's full-sized avatar

Frank A. Krueger praeclarum

View GitHub Profile
@praeclarum
praeclarum / Speaker.cs
Created June 26, 2014 19:08
Easy way to asynchronously speak some text on iOS with C#
using System;
using MonoTouch.AVFoundation;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace Praeclarum
{
/// <summary>
/// Easy way to asynchronously speak some text.
/// <code>
@praeclarum
praeclarum / NoiseAnimation.fs
Created December 20, 2014 19:10
A little iOS app that shows a noisy square moving in a field of noise
namespace NoiseAnimation
#nowarn "64"
open System
open UIKit
open Foundation
open CoreGraphics
[<AutoOpen>]
@praeclarum
praeclarum / MarkovChain.fs
Last active August 29, 2015 14:13
Markov Chain that learns by observing data.
/// Markov chain that learns by observing data.
/// Let it observe a sequence of states.
/// Then you can ask it, given a state,
/// what are the probabilities of the next states occuring?
/// This chain can remember history to make better predictions.
type MarkovChain (numStates : int, memory : int) =
let numPrevious = 1 + memory
let matrixSize = int (System.Math.Pow (float numStates, float numPrevious))
@praeclarum
praeclarum / gist:37cf63de2d26ad1a5942
Created February 7, 2015 06:46
My First CoreCLR OS X Run
Last login: Fri Feb 6 22:16:42 on ttys004
muon:~ fak$ cd Applications/
muon:Applications fak$ cd coreclr-osx/
muon:coreclr-osx fak$ ls
corerun libcoreclr.dylib libmscordaccore.dylib mscorlib.dll
muon:coreclr-osx fak$ ./corerun
Usage: corerun [OPTIONS] assembly [ARGUMENTS]
Execute the specified managed assembly with the passed in arguments
Options:
@praeclarum
praeclarum / gist:c11200dc8c05edc1046f
Created February 7, 2015 07:08
My Second CoreCLR OS X Run
muon:coreclr-osx fak$ ls -al
total 51768
drwxr-xr-x 8 fak staff 272 Feb 6 23:06 .
drwx------ 7 fak staff 238 Feb 6 22:36 ..
-rwxr-xr-x 1 fak staff 49820 Feb 6 22:31 corerun
-rw-r--r-- 1 fak staff 194 Feb 6 22:50 helloworld.cs
-rwxr-xr-x 1 fak staff 3072 Feb 6 22:50 helloworld.exe
-rwxr-xr-x 1 fak staff 23490408 Feb 6 23:05 libcoreclr.dylib
-rwxr-xr-x 1 fak staff 4176 Feb 6 23:05 libmscordaccore.dylib
-rw-r--r--@ 1 fak staff 2941952 Feb 6 22:38 mscorlib.dll
@praeclarum
praeclarum / gist:8cc6e666a90944c59e7c
Created February 7, 2015 07:39
Backtrace of crash
muon:coreclr-osx fak$ ls -al
total 51776
drwxr-xr-x 9 fak staff 306 Feb 6 23:13 .
drwx------ 7 fak staff 238 Feb 6 22:36 ..
-rw-r--r--@ 1 fak staff 6148 Feb 6 23:13 .DS_Store
-rwxr-xr-x 1 fak staff 49820 Feb 6 22:31 corerun
-rw-r--r-- 1 fak staff 194 Feb 6 22:50 helloworld.cs
-rwxr-xr-x 1 fak staff 3072 Feb 6 22:50 helloworld.exe
-rwxr-xr-x 1 fak staff 23490408 Feb 6 23:05 libcoreclr.dylib
-rwxr-xr-x 1 fak staff 4176 Feb 6 23:05 libmscordaccore.dylib
using System;
namespace TestApps
{
public class HelloWorldApp
{
public static int Main (string[] args)
{
Console.WriteLine ("Hello, world. It's " + DateTime.Now);
return 0;
muon:coreclr-osx fak$ ./corerun h.exe
libc++abi.dylib: terminating with uncaught exception of type std::out_of_range: basic_string
Abort trap: 6
muon:coreclr-osx fak$ lldb ./corerun h.exe
(lldb) target create "./corerun"
Current executable set to './corerun' (x86_64).
(lldb) settings set -- target.run-args "h.exe"
(lldb) run
Process 37845 launched: './corerun' (x86_64)
libc++abi.dylib: terminating with uncaught exception of type std::out_of_range: basic_string
muon:coreclr-osx fak$ ls -al
total 51792
drwxr-xr-x 11 fak staff 374 Feb 6 23:50 .
drwx------ 7 fak staff 238 Feb 6 22:36 ..
-rw-r--r--@ 1 fak staff 6148 Feb 6 23:13 .DS_Store
-rwxr-xr-x 1 fak staff 49820 Feb 6 22:31 corerun
-rw-r--r--@ 1 fak staff 110 Feb 6 23:49 h.cs
-rwxr-xr-x 1 fak staff 3072 Feb 6 23:50 h.exe
-rw-r--r-- 1 fak staff 194 Feb 6 22:50 helloworld.cs
-rwxr-xr-x 1 fak staff 3072 Feb 6 22:50 helloworld.exe
@praeclarum
praeclarum / ListDiff.fs
Created February 19, 2015 20:26
Finds a diff between two sequences (that contain possibly different types). Include merge.
namespace Praeclarum
type ListDiffAction<'TSource, 'TDestination> =
| Add of Destination : 'TDestination
| Update of Source : 'TSource * Destination : 'TDestination
| Remove of Source : 'TSource
/// Finds a diff between two sequences (that contain possibly different types).
/// Actions are generated such that the order of items in the