Skip to content

Instantly share code, notes, and snippets.

View praeclarum's full-sized avatar

Frank A. Krueger praeclarum

View GitHub Profile
@praeclarum
praeclarum / TableViewController.cs
Last active January 5, 2021 14:31
All the boilerplate code needed to get a custom iOS UITableViewController up and running in C#
public class TableViewController : UITableViewController
{
static readonly NSString CellId = new NSString ("C");
readonly TableViewSource source = new TableViewSource ();
readonly List<string> rows = new List<string> ();
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
@praeclarum
praeclarum / Script.swift
Last active November 26, 2020 22:31
A little scripting language written in Swift. It supports first class functions (closures) and variable mutation. This code includes the AST, the interpreter, and a JavaScript parser.
//
// Script.swift
//
// Created by Frank A. Krueger on 6/28/15.
// Copyright © 2015 Krueger Systems, Inc. All rights reserved.
//
import Foundation
enum Val {
@praeclarum
praeclarum / Script.fs
Created August 26, 2015 06:37
Scripting language in F#
module k
(*
type TypeIdent = string
type TypeExpr = name:string? (string | TypeIdent | Or TypeExpr TypeExpr | And TypeExpr)
type TypeDecl = Type string TypeExpr
@praeclarum
praeclarum / Parsing.fs
Last active November 26, 2020 22:29
Parser combinator in F# tuned to perform "well enough" on iOS (Xamarin)
module Parsing
/// Remember where we are in the code.
/// This is a struct to keep memory pressure down.
/// (Significant perf improvements on iOS.)
type ParseState =
struct
val Code : string
val Index : int
new (code : string, index : int) =
@praeclarum
praeclarum / MeadowEnclosure.js
Created May 22, 2020 21:02
OpenJSCAD source code for the Meadow Enclosure shown at the Wilderness Labs Dev Camp
var resolution = 50;
var printerError = 0.05;
var xsize = 100;
var ysize = 100;
var height = 20;
@praeclarum
praeclarum / CodeShareReport.cs
Created January 13, 2012 20:42
Computes the code share stats for the iCircuit project
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using System.IO;
namespace CodeShareReport
{
class App
@praeclarum
praeclarum / Info.plist
Created October 18, 2020 20:15
Plist for QL thumbnails
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDisplayName</key>
<string>iCircuit Thumbnails</string>
<key>CFBundleName</key>
<string>CircuitThumbs</string>
<key>CFBundleIdentifier</key>
<string>com.kruegersystems.circuit.thumbs</string>
@praeclarum
praeclarum / Migrations.cs
Created August 30, 2020 20:47
Database migrations using Dapper
using System;
using System.Linq;
using Microsoft.Extensions.Logging;
using Dapper;
namespace Data
{
public class Migrations
{
private readonly Database database;
@praeclarum
praeclarum / EasyLayout.fs
Last active August 23, 2020 09:52
EasyLayout makes writing auto layout code in Xamarin.iOS F# easier.
module EasyLayout
open System
open System.Drawing
open Microsoft.FSharp.Quotations
open Microsoft.FSharp.Quotations.Patterns
open Microsoft.FSharp.Quotations.DerivedPatterns
open MonoTouch.Foundation
open MonoTouch.UIKit
var a = 10;
var b = 200;
Console.WriteLine((a > b) ? a : b);
Console.WriteLine((a > b) ? b : a);
Console.WriteLine(Math.Max(a, b));
Console.WriteLine(Math.Min(a, b));