Skip to content

Instantly share code, notes, and snippets.

View dbeattie71's full-sized avatar

Derek Beattie dbeattie71

  • Nebraska
  • 15:00 (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 / 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);
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
{
public class TextViewImeActionBinding : MvxAndroidTargetBinding
{
private bool subscribed;
private ICommand _command;
protected TextView TextView
{
get { return Target as TextView; }
}
/// <summary>
/// Author: softlion (softlion@softlion.com)
/// </summary>
/// <remarks>
/// Thanks to: Stuart Lodge
/// </remarks>
public class MvxRadioGroupSelectedIndexBinding : MvxAndroidTargetBinding
{
bool stopListeningCheckChanged = false;
<TextView
local:MvxBind="Text PasswordConfirm; ImeAction RegisterCommand"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Password"
android:inputType="textPassword"
android:imeOptions="actionSend" />