This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Snippet Name: CocosSharp Extension Methods | |
Platform: All | |
Function: CocosSharp helpers for actions, layout, sizing, drawing | |
Includes: | |
- Awaitable CCNode.RunActionsWithTask - allows you to await the running of a set of actions (for example, in order to not proceed with subsequent code till an animation completes), without having to explicitly calculate the duration of the actions or use a callback. | |
- Easy relative positioning with CCNode.PlaceAt - allows you to position a CCNode relative to the boundaries of a parent CCNode. Fluent style, so can be used at initialisation time. | |
- Easy filled colours with CCDrawNode.FillWith and quick sprite initialisation with CCNode.WithSprite, also fluent. | |
- Quick insetting or outsetting with CCSize.MultiplyBy. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Snippet Name: InlineTableViewSource | |
Platform: iOS | |
Function: A subclass of UITableViewSource that allows you to define UITableViewDataSource and UITableViewDelegate methods inline, rather than subclassing. Lets you take advantage of closures and use tableviews where you can't create subclasses, like in Xamarin Sketches (compile and reference). | |
Funcs/Actions are prefixed with "_", feel free to alter if this disagrees with your styling guidelines. | |
Usage: | |
var cellId = new NSString("cell"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// I don't remember where this is taken/adapted from. | |
public static class AsyncExtensions | |
{ | |
public static async Task<T> TimeoutAfter<T>(this Task<T> task, TimeSpan timeout, CancellationTokenSource cancellationTokenSource = null) | |
{ | |
if (task == await Task.WhenAny(task, Task.Delay(timeout))) | |
return await task; | |
else | |
{ | |
if (cancellationTokenSource != null) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class BetterTcpSocketClient : ITcpSocketClient | |
{ | |
private TcpSocketClient _backingTcpSocketClient = new TcpSocketClient(); | |
private readonly Stream _readBuffer = new BlockingMemoryStream(); | |
private CancellationTokenSource _canceller; | |
public EventHandler<TcpSocketConnectedEventArgs> Connected { get; set; } | |
public EventHandler<TcpSocketDisconnectedEventArgs> Disconnected { get; set; } | |
public EventHandler<ErrorEventArgs> Errored { get; set; } | |
public Stream ReadStream |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class BetterUdpSocket : IDisposable | |
{ | |
private BlockingCollection<byte[]> _readBuffer; | |
private readonly UdpSocketReceiver _backingUdpSocketReceiver = new UdpSocketReceiver(); | |
public BetterUdpSocket() | |
{ | |
_backingUdpSocketReceiver.MessageReceived += OnMessageReceived; | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Query Kind="Program"> | |
<NuGetReference>Newtonsoft.Json</NuGetReference> | |
<NuGetReference Prerelease="true">rda.SocketHelpers</NuGetReference> | |
<Namespace>SocketHelpers.Discovery</Namespace> | |
<Namespace>SocketHelpers.Messaging</Namespace> | |
<Namespace>Sockets.Plugin</Namespace> | |
<Namespace>Splat</Namespace> | |
<Namespace>System.Reactive.Linq</Namespace> | |
<Namespace>System.Threading.Tasks</Namespace> | |
</Query> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open System | |
open System.IO | |
open System.Net | |
open Akka | |
open Akka.Actor | |
open Akka.FSharp | |
open Akka.Remote | |
open Akka.Actor | |
open Akka.Cluster |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Provides a convenience method for constructing an EnumerableStream<T>. | |
/// </summary> | |
public static class EnumerableStream | |
{ | |
public static EnumerableStream<T> Create<T>(IEnumerable<T> source, Func<T, List<byte>> serializer) | |
{ | |
return new EnumerableStream<T>(source, serializer); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Main() | |
{ | |
var myXamarinApps = | |
Directory | |
.EnumerateFiles(Path.Combine(Environment.GetEnvironmentVariable("HOMEPATH"), @"Music\iTunes\iTunes Media\Mobile Applications"), "*.ipa") | |
.Where(f=> ZipFile.Open(f, ZipArchiveMode.Read) | |
.GetRawEntries() | |
.Any(e=> e.FullName.Contains(".monotouch-"))); | |
foreach (var app in myXamarinApps) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class AcceptSelfSignedCertificateWebView : UIWebView | |
{ | |
private NSUrlRequest _failedRequest; | |
private bool _authenticated; | |
private bool OnShouldStartLoad(UIWebView webView, NSUrlRequest request, UIWebViewNavigationType navigationType) | |
{ | |
var result = _authenticated; | |
if (!_authenticated) | |
{ |
OlderNewer