Skip to content

Instantly share code, notes, and snippets.

@redent
redent / gist:6000294
Created July 15, 2013 14:19
REST Get/Post Sample using HttpClient with async/await and JSON content
private readonly IMvxJsonConverter _converter;
public async Task<T> GetAsync<T>(string url, CancellationToken cancellationToken) where T : new()
{
var client = new HttpClient();
var response = await client.GetAsync(url, cancellationToken);
var responseString = await response.Content.ReadAsStringAsync();
var result = _converter.DeserializeObject<T>(responseString);
return result;
@redent
redent / TCHorizontalSelectorView
Created September 6, 2013 09:12
Horizontal selector view with view reuse and infinite circular scrolling, allowing more than one element per page
//
// TCHorizontalSelectorView.m
// TwinCodersLibrary
//
// Created by Guillermo Gutiérrez on 16/01/13.
// Copyright (c) 2013 TwinCoders S.L. All rights reserved.
//
#import <UIKit/UIKit.h>
@redent
redent / gist:6965856
Created October 13, 2013 18:48
Duplicate symbol errors when compiling ARMv7 and ARMv7s using Google AdMob SDK.
/Developer/MonoTouch/usr/bin/mtouch -sdkroot "/Applications/Xcode.app/Contents/Developer" --cache "/Users/redent/Documents/workspace/MovieLend/MovieLend.Touch/obj/iPhone/Ad-Hoc/mtouch-cache" --nomanifest --nosign -dev "/Users/redent/Documents/workspace/MovieLend/MovieLend.Touch/bin/iPhone/Ad-Hoc/MovieLendTouch.app" -r "/Users/redent/Documents/workspace/MovieLend/MovieLend.Core/bin/Release/MovieLend.Core.dll" -r "/Users/redent/Documents/workspace/MovieLend/packages/MvvmCross.HotTuna.CrossCore.3.0.13/lib/MonoTouch40/Cirrious.CrossCore.dll" -r "/Users/redent/Documents/workspace/MovieLend/packages/MvvmCross.HotTuna.CrossCore.3.0.13/lib/MonoTouch40/Cirrious.CrossCore.Touch.dll" -r "/Users/redent/Documents/workspace/MovieLend/packages/MvvmCross.HotTuna.MvvmCrossLibraries.3.0.13/lib/MonoTouch40/Cirrious.MvvmCross.dll" -r "/Users/redent/Documents/workspace/MovieLend/packages/MvvmCross.HotTuna.CrossCore.3.0.13/lib/MonoTouch40/Cirrious.MvvmCross.Binding.dll" -r "/Users/redent/Documents/workspace/MovieLend/packages/Mvvm
@redent
redent / ParentViewController.Keyboard.cs
Last active May 2, 2018 21:47
Parent view controller to handle keyboard notifications to center views in the screen. UIScrollView related methods moved to an extension class.
using System;
using Foundation;
using UIKit;
using TwinCoders.TouchUtils.Extensions;
using CoreGraphics;
namespace SalesForce.Touch.Views
{
public abstract partial class ParentViewController
{
@redent
redent / TCCustomFont.m
Created December 6, 2013 18:56
Categories for specifying custom fonts in Interface Builder and Storyboard. More info here: http://stackoverflow.com/a/15155081/469218
#import <UIKit/UIKit.h>
@interface UIButton (TCCustomFont)
@property (nonatomic, copy) NSString* fontName;
@end
@implementation UIButton (TCCustomFont)
- (NSString *)fontName {
return self.titleLabel.font.fontName;
@redent
redent / UIButton+TCCustomFont.h
Created December 6, 2013 19:01
Categories for specifying custom fonts in Interface Builder and Storyboard. More info here: http://stackoverflow.com/a/15155081/469218
#import <UIKit/UIKit.h>
@interface UIButton (TCCustomFont)
@property (nonatomic, copy) NSString* fontName;
@end
@redent
redent / Reachability.cs
Last active November 2, 2017 11:26
MonoTouch Reachability class
using System;
using System.Net;
using MonoTouch.SystemConfiguration;
using MonoTouch.CoreFoundation;
public enum NetworkStatus {
NotReachable,
ReachableViaCarrierDataNetwork,
ReachableViaWiFiNetwork
@redent
redent / CollapsableSectionTableViewSource.cs
Created September 12, 2014 09:37
Xamarin sample of collapsable sections using MvvmCross
using System;
using MonoTouch.UIKit;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using MonoTouch.Foundation;
using Cirrious.MvvmCross.Binding.ExtensionMethods;
namespace TwinCoders.MvvmCross.TouchUtils.TableViews
{
@redent
redent / CodeIcon.cs
Last active August 29, 2015 14:06
Sample code for using Code Icons created by PaintCode. CodeIconButton can be used from Storyboard and can assign IconColor, IconSize and IconType directly from the interface builder. See SampleIcon to see how declare icons.
using System;
using System.Drawing;
using MonoTouch.UIKit;
namespace TwinCoders.TouchUtils.CodeViews
{
public abstract class CodeIcon : CodeImage
{
public UIColor FillColor { get; set; }
public float WidthHeightProportion { get; private set; }
@redent
redent / AppDelegate.m
Created March 4, 2015 13:54
Ejemplo de código para evitar que los dispositivos se registren sin alias en TwinPush
- (BOOL)shouldRegisterDeviceWithAlias:(NSString *)alias token:(NSString *)token {
return alias.length > 0;
}