Skip to content

Instantly share code, notes, and snippets.

@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"
}]
}
@atheken
atheken / Jawn.swift
Created November 12, 2015 14:53
Super lazy JSON lookups.
struct Jawn {
let value:AnyObject?
var string:String? { return self.value as? String }
var int:Int? { return self.value as? Int }
var double:Double? { return self.value as? Double }
var array:[Jawn]? { return (self.value as? NSArray)?.map{Jawn($0)} }
var bool:Bool? { return self.value as? Bool }
var dictionary:[String:Jawn]? {
guard let dictionary = self.value as? NSDictionary else {
@atheken
atheken / Jawn.swift
Last active November 12, 2015 14:55
Super lazy JSON lookups.
struct Jawn {
let value:AnyObject?
var string:String? { return self.value as? String }
var int:Int? { return self.value as? Int }
var double:Double? { return self.value as? Double }
var array:[Jawn]? { return (self.value as? NSArray)?.map{Jawn($0)} }
var bool:Bool? { return self.value as? Bool }
var dictionary:[String:Jawn]? {
guard let dictionary = self.value as? NSDictionary else {
@atheken
atheken / mail.php
Last active October 5, 2018 07:26
Example `config/mail.php` to send mail using Postmark from Laravel
<?php
return [
'username' => env('<YOUR_POSTMARK_SERVER_TOKEN>'),
'password' => env('<YOUR_POSTMARK_SERVER_TOKEN>'),
'host' => env('MAIL_HOST', 'smtp.postmarkapp.com'),
// Optionally, set "smtp" to "log" if you want to trap emails during testing.
@atheken
atheken / gist:5cad91c1f26f49a225108d39ed60b25f
Created January 9, 2017 20:20 — forked from MatthewSteeples/gist:5588087
Code to rename namespaces from compiled assemblies using Mono.Cecil
using Mono.Cecil;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;
namespace CecilTest