Skip to content

Instantly share code, notes, and snippets.

@deapsquatter
deapsquatter / Main.cs
Created January 22, 2016 06:53
Combobox Binding
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
comboBox1.DisplayMember = "Value";
Real: 00:00:00.026, CPU: 00:00:00.026, GC gen0: 1, gen1: 0
val findSeq : int list list =
[[1; 2; 3; -4; 5; 6; 78; 9]; [1; 2; 34; -5; 67; -8; 9];
[1; 23; -4; 5; 6; 78; -9]; [1; 23; -4; 56; 7; 8; 9];
[12; 3; 4; 5; -6; -7; 89]; [12; 3; -4; 5; 67; 8; 9];
[12; -3; -4; 5; -6; 7; 89]; [123; 4; -5; 67; -89];
[123; -4; -5; -6; -7; 8; -9]; [123; 45; -67; 8; -9]; [123; -45; -67; 89]]
@deapsquatter
deapsquatter / gist:b53f7a3e5d36ceeac848
Created May 10, 2015 18:27
Write a program that outputs all possibilities to put + or - or nothing between the numbers 1, 2, ..., 9 (in this order) such that the result is always 100. For example: 1 + 2 + 34 – 5 + 67 – 8 + 9 = 100.
#time "on"
let findSeq =
let rec find n s =
match s |> List.map(fun t -> (abs t).ToString().ToCharArray()) |> Array.concat |> Array.length with
|9 -> [s |> List.rev]
|x -> let ones =
match x with
|x when x > 1 -> find (n + 1) (n::s) @ find (n + 1) (-n::s)
|_ -> find (n + 1) (n::s)
let twos =
using System;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using Cirrious.CrossCore.Core;
using Cirrious.CrossCore.WeakSubscription;
using Cirrious.MvvmCross.Binding.Attributes;
using Cirrious.MvvmCross.Binding.BindingContext;
using Cirrious.MvvmCross.Binding.ExtensionMethods;
using MonoMac.AppKit;
using System;
using MonoMac.AppKit;
using MonoMac.Foundation;
namespace CentraStage.Mac
{
[Register("CsTableColumn")]
public class CsTableColumn : NSTableColumn
{
#region Constructors
using System;
using Cirrious.CrossCore.Core;
using Cirrious.MvvmCross.Binding.BindingContext;
using MonoMac.AppKit;
using MonoMac.Foundation;
namespace CentraStage.Mac
{
[Register("CsTableCellView")]
public class CsTableCellView : NSTableCellView, IMvxBindingContextOwner, IMvxDataConsumer
@deapsquatter
deapsquatter / gist:6778696
Last active December 24, 2015 09:39
Binding a NSTableViewSource
var source = new CsTableViewSource (myNSTableView);
var binding = this.CreateBindingSet<TaskManagerViewController, TaskManagerVM> ();
binding.Bind (source).For ((s) => s.ItemsSource).To ((vm) => vm.MyEnumerable);
binding.Apply ();
myNSTableView.Source = source;
@deapsquatter
deapsquatter / gist:5823304
Created June 20, 2013 14:40
Example test using Async
[Test( Description="Should Login OK" )]
public async void OK ()
{
var loginSession = LoginSession.Instance;
await loginSession.Login ("user", "password");
Assert.True (LoginSession.Instance.LoggedIn);
}
@deapsquatter
deapsquatter / gist:5719733
Last active December 18, 2015 03:39
An iPhone presenter for use with MvxTabBarViewController (MvvmCross)
class IPhoneViewPresenter : MvxModalNavSupportTouchViewPresenter
{
public IPhoneViewPresenter (UIApplicationDelegate applicationDelegate, UIWindow window)
:base(applicationDelegate, window)
{
}
HomeView homeView;
protected override UIViewController CurrentTopViewController
@deapsquatter
deapsquatter / gist:5644550
Created May 24, 2013 16:05
Useful in Xamarin.Droid when having to deal with Java.Util.IEnumeration. Now you can use Linq.
public static class Extensions
{
public static IEnumerable<T> GetEnumerable<T>(this Java.Util.IEnumeration enumeration) where T : class
{
while (enumeration.HasMoreElements)
yield return enumeration.NextElement() as T;
}
}