Skip to content

Instantly share code, notes, and snippets.

View praeclarum's full-sized avatar

Frank A. Krueger praeclarum

View GitHub Profile
@praeclarum
praeclarum / PinnedArray2.fs
Created March 4, 2015 15:15
PinnedArray2 for passing 2D arrays to native code
type PinnedArray2 (array : float[,]) =
let h = GCHandle.Alloc (array, GCHandleType.Pinned)
let ptr = Marshal.UnsafeAddrOfPinnedArrayElement(array, 0)
member this.Ptr = NativePtr.ofNativeInt<float>(ptr)
interface IDisposable with
member this.Dispose () = h.Free ()
@praeclarum
praeclarum / Parser.fs
Last active August 29, 2015 14:16
Parser for a little language in F#
module Parser =
type Position =
{
Code : string
Index : int
}
let ws p =
if p.Index >= p.Code.Length then p
2015-06-08 19:30:34.539 Mocast[717:131208] DATA /var/mobile/Containers/Data/Application/D2784AE1-D4E4-4555-9CB7-D576E6470AD4/Documents/Mocast.sqlite
2015-06-08 19:30:34.562 Mocast[717:131208] ERROR: System.DllNotFoundException: sqlite3
at (wrapper managed-to-native) SQLite.SQLite3:Open (byte[],intptr&,int,intptr)
at SQLite.SQLiteConnection..ctor (System.String databasePath, SQLiteOpenFlags openFlags, Boolean storeDateTimeAsTicks) [0x00066] in /Users/fak/Dropbox/Projects/sqlite-net/src/SQLite.cs:219
at SQLite.SQLiteConnection..ctor (System.String databasePath, Boolean storeDateTimeAsTicks) [0x00000] in /Users/fak/Dropbox/Projects/sqlite-net/src/SQLite.cs:181
at Mocast.MocastStorage..ctor () [0x00089] in /Users/fak/Dropbox/Projects/Mocast/Mocast/Mocast/MocastStorage.cs:49
at Mocast.AppDelegate.FinishedLaunching (UIKit.UIApplication app, Foundation.NSDictionary options) [0x0002a] in /Users/fak/Dropbox/Projects/Mocast/Mocast/AppDelegate.cs:58
ERROR: System.DllNotFoundException: sqlite3
at (wrapper
@praeclarum
praeclarum / Seq.swift
Last active August 29, 2015 14:24
Some function and SequenceType extensions that I found missing in Swift 2
//
// Seq.swift
//
// Created by Frank A. Krueger on 7/8/15.
// Copyright © 2015 Krueger Systems, Inc. All rights reserved.
// MIT Licensed
//
import Foundation
@praeclarum
praeclarum / PieChartLayer.cs
Created August 2, 2015 03:15
CA Layer example
using System;
using MonoTouch.CoreGraphics;
using MonoTouch.Foundation;
using MonoTouch.CoreAnimation;
using System.Drawing;
namespace Presentation.AnimationPresentation
{
class PieChartLayer : CALayer
{
@praeclarum
praeclarum / ObservableTableView
Created January 3, 2011 15:36
This class knows how to listen to INotifyCollectionChanged to populate and keep a UITableView in sync with a data source.
using System;
using MonoTouch.UIKit;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using MonoTouch.Foundation;
using System.Collections;
namespace ObservableTableView
{
public class RowSelectedEventArgs : EventArgs {
@praeclarum
praeclarum / gist:870347
Created March 15, 2011 05:22
Multi file project operations for IPhone and MonoMac
diff --git a/extras/MonoDevelop.IPhone/MonoDevelop.IPhone/IPhoneProject.cs b/extras/MonoDevelop.IPhone/MonoDevelop.IPhone/IPhoneProject.cs
index c0010f1..a591e12 100644
--- a/extras/MonoDevelop.IPhone/MonoDevelop.IPhone/IPhoneProject.cs
+++ b/extras/MonoDevelop.IPhone/MonoDevelop.IPhone/IPhoneProject.cs
@@ -516,13 +516,18 @@ namespace MonoDevelop.IPhone
return;
}
- if (String.IsNullOrEmpty (MainNibFile) && Path.GetFileName (e.ProjectFile.FilePath) == "MainWindow.xib") {
- MainNibFile = e.ProjectFile.FilePath;
@praeclarum
praeclarum / Dropbox.cs
Created June 19, 2011 17:56
Initial implementation of the Dropbox API
public class DropboxCredentials {
public string Email { get; set; }
public string Token { get; set; }
public string TokenSecret { get; set; }
public string DisplayName { get; set; }
public string Uid { get; set; }
public string LastDirectory { get; set; }
public DropboxCredentials() {
Email = "";
@praeclarum
praeclarum / Identifier.cs
Created June 19, 2011 22:41
Separates an identifier into its constituent parts
using System;
using System.Collections.Generic;
using NUnit.Framework;
namespace DevSearchTest
{
class Identifier
{
public static string[] Separate(string rawId)
{
@praeclarum
praeclarum / Data.cs
Created July 1, 2011 18:15
A version of sqlite-net that also supports MySql
//
// Copyright (c) 2009-2010 Krueger Systems, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//