Skip to content

Instantly share code, notes, and snippets.

View dbeattie71's full-sized avatar

Derek Beattie dbeattie71

  • Nebraska
  • 10:18 (UTC -05:00)
View GitHub Profile
@dbeattie71
dbeattie71 / gist:2266687
Created March 31, 2012 16:50 — forked from DVDPT/gist:1607680
RestSharp Async for windows phone 7
public static class RestSharpExtensions
{
public static Task<RestResponse<T>> ExecuteAsync<T>(this IRestClient client, IRestRequest request) where T : new()
{
return client.ExecuteAsync<T>(request, CancellationToken.None);
}
public static Task<RestResponse<T>> ExecuteAsync<T>(this IRestClient client, IRestRequest request, CancellationToken token) where T : new()
{
@dbeattie71
dbeattie71 / AsyncFileUploadClient.cs
Created April 17, 2012 01:00 — forked from pauldbau/AsyncFileUploadClient.cs
Quick and dirty async file upload using a copy of ServiceStack AsyncServiceClient as a base. Hardcoded to expect a JSON response. This could be used as a reference for integrating into ServiceStack properly, just don't have the time to do so personally
using System;
using System.IO;
using System.Net;
using System.Text;
using System.Threading;
using ServiceStack.Common.Web;
using ServiceStack.Logging;
using ServiceStack.ServiceHost;
using ServiceStack.Text;
using ServiceStack.ServiceClient.Web;
@dbeattie71
dbeattie71 / KeyboardTabBehavior.cs
Created November 1, 2012 22:31
KeyboardTabBehavior to work with Telerik TextBox and PasswordBox
public class KeyboardTabBehavior : Behavior<UIElement>
{
private KeyboardTabHelper _keyboardTabHelper;
protected override void OnAttached()
{
base.OnAttached();
_keyboardTabHelper = new KeyboardTabHelper(AssociatedObject);
}
@dbeattie71
dbeattie71 / Epoch.cs
Created November 6, 2012 20:01 — forked from txdv/Epoch.cs
Epoch class for handling unix times
using System;
namespace Epoch
{
public class Epoch
{
static readonly DateTime epochStart = new DateTime(1970, 1, 1, 0, 0, 0);
static readonly DateTimeOffset epochDateTimeOffset = new DateTimeOffset(1970, 1, 1, 0, 0, 0, TimeSpan.Zero);
@dbeattie71
dbeattie71 / RadListPickerEx
Created September 27, 2013 22:53
Make SelectedItems bindable
using System.Collections;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using Telerik.Windows.Controls;
namespace Travefy.UI.WP8.Controls
{
public interface IRemove
{
ICommand RemoveCommand { get; }
}
@dbeattie71
dbeattie71 / scale.cs
Created February 23, 2014 23:03 — forked from nicwise/scale.cs
public static UIImage ScaleImage(UIImage image, int maxSize)
{
UIImage res;
using (CGImage imageRef = image.CGImage)
{
CGImageAlphaInfo alphaInfo = imageRef.AlphaInfo;
CGColorSpace colorSpaceInfo = CGColorSpace.CreateDeviceRGB();
if (alphaInfo == CGImageAlphaInfo.None)
@dbeattie71
dbeattie71 / gist:9631328
Last active August 29, 2015 13:57 — forked from buildmaster/gist:1387224
Simple example of capturing a still image with AVCaptureDevice.
void initCameraView(){
NSError error = null;
captureSession = new AVCaptureSession(){
SessionPreset=AVCaptureSession.Preset640x480
};
var device = AVCaptureDevice.DefaultDeviceWithMediaType(AVMediaType.Video);
var deviceInput = AVCaptureDeviceInput.FromDevice(device,out error);
if(error!=null){
displayErrorOnMainQueueWithMessage(error,"Unable to setup capture");
return;
@dbeattie71
dbeattie71 / ParentViewController.Keyboard.cs
Created March 19, 2014 22:11 — forked from redent/ParentViewController.Keyboard.cs
Great example of how to slide the the view on input when the keyboard is displayed.
using System;
using MonoTouch.UIKit;
using MonoTouch.Foundation;
using System.Drawing;
namespace TwinCoders.Utils
{
public abstract partial class ParentViewController
{
@dbeattie71
dbeattie71 / gist:9728149
Created March 23, 2014 19:11
How to get double quotes around 'name' and 'filename' on Xamarin Monotouch iOS with the HttpClient.
else if (restRequest.ContentType == ContentTypes.MultipartFormData)
{
var multipartPartFormDataContent = new MultipartFormDataContent();
var contentJson = new StringContent(restRequest.GetRequestBody());
multipartPartFormDataContent.Add(contentJson);
httpRequestMessage.Content = contentJson;
if (restRequest.Files.Any())
foreach (var fileParameter in restRequest.Files)
{