View gist:6ba5cb2e55ddd1213732a6ffbbdab91e
This file contains 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 Program | |
{ | |
static HttpListener listener; | |
static HttpListenerContext context; | |
private const int bufferSize = 4096; | |
public static void Main() | |
{ | |
listener = new HttpListener("http", 8500); | |
listener.Start(); |
View AsyncHelper.cs
This file contains 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 static class AsyncHelper | |
{ | |
private static readonly TaskFactory _myTaskFactory = new | |
TaskFactory(CancellationToken.None, | |
TaskCreationOptions.None, | |
TaskContinuationOptions.None, | |
TaskScheduler.Default); | |
public static TResult RunSync<TResult>(Func<Task<TResult>> func) | |
{ |
View Example GitIgnore for Xamarin Projects
This file contains 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
## Ignore Visual Studio temporary files, build results, and | |
## files generated by popular Visual Studio add-ons. | |
# User-specific files | |
*.suo | |
*.user | |
*.sln.docstates | |
# Build results | |
[Dd]ebug/ |
View gist:c658d6c087847360afdc
This file contains 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 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
This file contains 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
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
This file contains 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
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) => { |
View gist:9340477
This file contains 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 void PostImageAndTweetToTwitter() | |
{ | |
if (SLComposeViewController.IsAvailable (SLServiceKind.Twitter)) { | |
var post = new NSString("Testing Social Framework!"); | |
var twitterRequest = SLRequest.Create(SLServiceKind.Twitter, | |
SLRequestMethod.Post, | |
NSUrl.FromString("https://upload.twitter.com/1/statuses/update_with_media.json"), | |
NSDictionary.FromObjectAndKey(post, new NSString("status")) | |
); |
View gist:7138336
This file contains 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
// 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 (); | |
BTProgressHUD.Show("Loading"); | |
try { | |
LoadSomething().ContinueWith(task => { // 10 Second task |