Skip to content

Instantly share code, notes, and snippets.

View gist:6ba5cb2e55ddd1213732a6ffbbdab91e
public class Program
static HttpListener listener;
static HttpListenerContext context;
private const int bufferSize = 4096;
public static void Main()
listener = new HttpListener("http", 8500);
therealjohn / AsyncHelper.cs
Created Dec 15, 2016 — forked from rid00z/AsyncHelper.cs
This code can be used to task a async task and run it without the async part.
View AsyncHelper.cs
public static class AsyncHelper
private static readonly TaskFactory _myTaskFactory = new
public static TResult RunSync<TResult>(Func<Task<TResult>> func)
View Example GitIgnore for Xamarin Projects
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
# User-specific files
# Build results
View gist:c658d6c087847360afdc
public static UIImage FixOrientation(this UIImage image)
UIImage fixedImage = image;
// No-op if the orientation is already correct
if (image.Orientation == UIImageOrientation.Up) return image;
// We need to calculate the proper transformation to make the image upright.
// We do it in 2 steps: Rotate if Left/Right/Down, and then flip if Mirrored.
CGAffineTransform transform = CGAffineTransform.MakeIdentity();
View NSUrlSessionDataDelegate.cs
class DataTaskDelegate : NSUrlSessionDataDelegate
NSUrlSessionHandler This { get; set; }
public DataTaskDelegate(NSUrlSessionHandler that)
this.This = that;
public override void DidReceiveChallenge(NSUrlSession session, NSUrlSessionTask task, NSUrlAuthenticationChallenge challenge, Action<NSUrlSessionAuthChallengeDisposition, NSUrlCredential> completionHandler)
View gist:9900487
var accountStore = new MonoTouch.Accounts.ACAccountStore();
var accType = accountStore.FindAccountType(ACAccountType.Facebook);
var accounts = accountStore.FindAccounts(accType);
var post = new NSString("Hello Facebook!");
if(accounts.Count() > 0)
var accountType = accountStore.FindAccountType(ACAccountType.Facebook);
accountStore.RequestAccess(accountType, null, (granted, error) => {
therealjohn / gist:9340477
Created Mar 4, 2014
Post Image and Tweet
View gist:9340477
public void PostImageAndTweetToTwitter()
if (SLComposeViewController.IsAvailable (SLServiceKind.Twitter)) {
var post = new NSString("Testing Social Framework!");
var twitterRequest = SLRequest.Create(SLServiceKind.Twitter,
NSDictionary.FromObjectAndKey(post, new NSString("status"))
therealjohn / gist:7138336
Last active Dec 26, 2015
BTProgressHUD issue.
View gist:7138336
// Same results in all the ViewDidLoad, Appear, WillAppear, etc.
// The "Loading" dialog only shows for ~2ish seconds, then disappears. It disappears before the Dismiss();
public override void LoadView ()
base.LoadView ();
try {
LoadSomething().ContinueWith(task => { // 10 Second task