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(); |
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) | |
{ |
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/ |
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(); |
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) |
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) => { |
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")) | |
); |
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 |