Skip to content

Instantly share code, notes, and snippets.

View praeclarum's full-sized avatar

Frank A. Krueger praeclarum

View GitHub Profile
@praeclarum
praeclarum / EasyLayout.cs
Last active April 21, 2023 10:28
**OUT OF DATE** Please use the NuGet package https://www.nuget.org/packages/EasyLayout or the code on GitHub https://github.com/praeclarum/EasyLayout. (EasyLayout makes writing auto layout code in Xamarin.iOS easier. See [the example](https://gist.github.com/praeclarum/8185036) for hints on how to use this library.)
//
// Copyright (c) 2013-2015 Frank A. Krueger
//
// 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:
//
@praeclarum
praeclarum / Dsp.cs
Created April 9, 2013 19:38
DSP functions for Xamarin.iOS bound to the Accelerate framework. See it in action by buying my Spectrogram app for iOS: https://itunes.apple.com/us/app/live-spectrogram/id630831185
using System;
using System.Runtime.InteropServices;
namespace Circuit
{
public static class Dsp
{
class FftSetupD : IDisposable
{
public IntPtr Handle;
using System;
using MonoTouch.UIKit;
using System.Drawing;
namespace Async.iOS
{
public class LayoutViewController : UIViewController
{
UITextField text;
UIButton button;
@praeclarum
praeclarum / Layout.cs
Created March 16, 2013 05:23
A C# syntax for NSLayoutConstraints.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using MonoTouch.UIKit;
namespace Async.iOS
{
public static class Layout
{
@praeclarum
praeclarum / LinqToViews.cs
Created February 20, 2013 19:37
Linq to UIViews
public static View CreateDeclarativeUI (Database database)
{
var view = Binding.Bind (() => new View {
Subviews = from t in database.Tables select new HBox {
Title = t.Name,
Subviews = from c in t.Columns select new Label {
Text = t.Name + "::" + c.Name,
},
}
@praeclarum
praeclarum / ImapClient.cs
Created February 7, 2013 21:12
Oh mono, you make this too easy. I was wondering if I could write an IMAP client from scratch in MonoTouch. Turns out yes, and turns out that it's easy to do!
// Authenticating [email protected]
// S: * OK Gimap ready for requests from 64.225.210.112 oi7if5386254oac.123
// C: A0001 LOGIN [email protected] ****************
// S: * CAPABILITY IMAP4rev1 UNSELECT IDLE NAMESPACE QUOTA ID XLIST CHILDREN X-GM-EXT-1 UIDPLUS COMPRESS=DEFLATE
// S: A0001 OK [email protected] Frank Krueger authenticated (Success)
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
@praeclarum
praeclarum / AppDelegate.cs
Created December 5, 2012 00:45
Code used to measure the network performance of an iPhone 5 while traveling around Seattle
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Net;
using System.Threading;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
var WORLDBANK_HEADER = 0;
var WORLDBANK_DATA = 1;
var worldbank = JSON.parse (worldbankString);
var header = worldbank[WORLDBANK_HEADER];
worldbank[WORLDBANK_DATA].each (function () {
// la di da
@praeclarum
praeclarum / SimplifiedPolyline.cs
Created November 27, 2012 21:04
A simplified polyline that has only enough line segments to accurately represent the original polyline.
//
// Copyright 2012 Frank A. Krueger
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
@praeclarum
praeclarum / CsvReader.cs
Created September 19, 2012 19:05
CSV Reader - I never want to write this again
using System;
using System.IO;
using System.Collections.Generic;
using System.Text;
namespace ClosedQuestions
{
public class Record
{
string[] data;