Skip to content

Instantly share code, notes, and snippets.

View samilamti's full-sized avatar

Sami Lamti samilamti

View GitHub Profile
@samilamti
samilamti / gist:3742221
Created September 18, 2012 09:21
Private fields of the SemanticZoomViewController
List<UIViewController> controllers;
UIView currentZoomView;
int controllerIndex;
@samilamti
samilamti / gist:3891276
Created October 15, 2012 07:50
UIAlertView* wrapped in using statements
using (UIAlertViewDelegate del = new UIAlertViewOkCancelDelegate(OpenFile, Cancelled))
using (UIAlertView view = new UIAlertView(title, message, del, "Cancel", new string[] { "OK" }))
{
view.AlertViewStyle = UIAlertViewStyle.SecureTextInput;
view.Show ();
}
@samilamti
samilamti / uialertviews-without-using-wrappers.cs
Created October 15, 2012 07:59
Letting the Mono GC do its job
UIAlertViewDelegate del = new UIAlertViewOkCancelDelegate(DecryptFile, Cancelled);
UIAlertView view = new UIAlertView(title, message, del, "Cancel", new string[] { "OK" });
view.AlertViewStyle = UIAlertViewStyle.SecureTextInput;
view.Show ();
@samilamti
samilamti / AppDelegate.cs
Created October 22, 2012 08:01
Listening to connecting screens
NSNotificationCenter.DefaultCenter.AddObserver (UIScreen.DidConnectNotification, notification => {
UIScreen connectedScreen = (UIScreen)notification.Object;
CreateRemoteWindow(connectedScreen);
});
@samilamti
samilamti / AppDelegate.cs
Created October 22, 2012 10:57
Creating a remote window
void CreateRemoteWindow (UIScreen connectedScreen)
{
RectangleF frame = connectedScreen.Bounds;
this.remoteWindow = new UIWindow (frame) {
Screen = connectedScreen,
Hidden = false,
};
this.remoteWindow.RootViewController = aControllerOfMyChoosing;
}
@samilamti
samilamti / AppDelegate.cs
Created October 22, 2012 11:04
In your AppDelegate's FinishedLoading overload, you can query UIScreen for availability of other screens
if (UIScreen.Screens.Count() > 1) {
CreateRemoteWindow(UIScreen.Screens[1]);
}
@samilamti
samilamti / UIDefinitions.cs
Created March 30, 2013 09:12
Shared UIDefinitions class that needs to be implemented per platform to create the platform's native color object given RGB-values.
namespace NinjaLocator.Core
{
public abstract class UIDefinitions<TNativeColor>
{
protected abstract TNativeColor TranslateColor(byte red, byte green, byte blue);
private static UIDefinitions<TNativeColor> _instance;
public static TNativeColor BackgroundColor { get { return _instance.TranslateColor(Configuration.BG_RED, Configuration.BG_GREEN, Configuration.BG_BLUE); } }
public static TNativeColor ForegroundColor { get { return _instance.TranslateColor(Configuration.FG_RED, Configuration.FG_GREEN, Configuration.FG_BLUE); } }
@samilamti
samilamti / ServiceClient.cs
Last active December 15, 2015 14:39
Common facade for the Azure Mobile Services end-point we've defined. Kept abstract to allow for platform-specific client APIs for Azure Mobile Services.
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace NinjaLocator.Core
{
public abstract class ServiceClient<TAuthenticationProvider>
{
public TAuthenticationProvider AuhenticationProvider { get; set; }
public string AuthenticationToken { get; set; }
@samilamti
samilamti / IMobileServiceTable.cs
Created March 30, 2013 09:21
Abstraction over the Azure Mobile Services MobileServiceTable class.
using System.Collections.Generic;
using System.Threading.Tasks;
namespace NinjaLocator.Core
{
public interface IMobileServiceTable<T>
{
Task InsertAsync(T entity);
Task<IEnumerable<T>> ReadAsync();
}
@samilamti
samilamti / insert.js
Created March 30, 2013 18:01
Inserts - or updates - a Ninja entity of the ninja table.
function insert(item, user, request) {
item.LastSeen = new Date();
item.UserId = user.userId;
item.GroupName = item.GroupName.toUpperCase();
var ninjasTable = tables.getTable("ninja");
ninjasTable.where({ UserId: user.userId }).read({
success: function(results) {
if (results.length > 0) {
var existingNinja = results[0];
existingNinja.NickName = item.NickName;