Skip to content

Instantly share code, notes, and snippets.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using MonoTouch.UIKit;
namespace Async.iOS
{
public static class Layout
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using MonoTouch.UIKit;
using System.Reflection;
using MonoTouch.Foundation;
namespace Praeclarum.UI
{
@atheken
atheken / FontCreator.cs
Created June 14, 2014 12:19
Xamarin iOS FontLoader for more fluent font creation/management.
public class FontCreator
{
private string _fontName;
private Dictionary<float, UIFont> _lookup = new Dictionary<float, UIFont> ();
public FontCreator (string fontName)
{
_fontName = fontName;
}
///<summary>Allows slim locks to be requesed using(LOCK.WriteLock()){ ... } syntax</summary>
public static class LockExtensions
{
public class DisposableCallback : IDisposable
{
public void Dispose ()
{
_callback ();
}
<!DOCTYPE html>
<head>
<title>Stay Standalone</title>
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<script src="stay_standalone.js" type="text/javascript"></script>
</head>
<body>
<ul>
<li><a href="http://google.com/">Remote Link (Google)</a></li>
@atheken
atheken / TranslateResizeMaskToConstraints.swift
Last active August 29, 2015 14:14
Make "TranslatesAutoresizingMaskIntoConstraints" a drop-down in Interface Builder.
@IBDesignable
class TranslateResizeMaskToConstraints: UIView {
@IBInspectable var Enabled:Bool = false
private var _interfaceBuilderContext = false
override func awakeFromNib() {
super.awakeFromNib()
setTranslatesAutoresizingMaskIntoConstraints(Enabled || _interfaceBuilderContext)
@atheken
atheken / customURL.m
Last active August 29, 2015 14:20 — forked from deivuh/customURL.m
Here is what you need to do to register your app for a custom URL scheme (for the example we will use a "myapp" scheme).
1) In your Info.plist, add a new entry for CFBundleURLTypes:
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>MyApp's URL</string>
<key>CFBundleURLSchemes</key>
@atheken
atheken / composer.json
Created August 21, 2015 14:55
Fix packagist url for composer on OS X
{
"repositories": [{
"type": "composer",
"url": "https://packagist.org"
}]
}
public static class ArrayUtils
{
public static void Push<T>(this T[] arr, T newItem)
{
arr = (new T[] { newItem }).Concat(arr).ToArray();
}
public static T Pop<T>(this T[] arr, T newItem)
{
T retval = default(T);
public static IEnumerable<T> Distinct(this IEnumerable<T> set, Func<T,U> propertySelector)
{
HashSet<U> distinct = new HashSet<U>();
foreach(var a in set)
{
var key = propertySelector.Invoke(a);
if(!distinct.Contains(key))
{
distinct.Add(key);
yield return a;