Skip to content

Instantly share code, notes, and snippets.

View ghuntley's full-sized avatar
minimalist

Geoffrey Huntley ghuntley

minimalist
View GitHub Profile
@jacobtoye
jacobtoye / gist:4748297
Created February 10, 2013 03:58
MultilineEntryElement for Monotouch.Dialog
using System;
using CrossUI.Touch.Dialog.Elements;
using System.Drawing;
using MonoTouch.UIKit;
using MonoTouch.Foundation;
using CrossUI.Touch.Dialog;
/// <summary>
/// Multiline entry element.
/// </summary>
// assumes variable data, which is a homogenous collection of objects
// get keys
var keys = _.keys(data[0]);
// convert to csv string
var csv = keys.join(",");
_(data).each(function(row) {
csv += "\n";
csv += _(keys).map(function(k) {
@bscheiman
bscheiman / Raygun
Created May 5, 2013 07:46
Raygun wrapper for MonoTouch / Xamarin.iOS
public static class Raygun {
private static string ApiKey { get; set; }
private static Uri BaseUrl = new Uri("https://api.raygun.io/entries");
[DllImport(MonoTouch.Constants.SystemLibrary)]
internal static extern int sysctlbyname([MarshalAs(UnmanagedType.LPStr)] string property, IntPtr output, IntPtr oldLen, IntPtr newp,
uint newlen);
public static void Attach(string apiKey) {
anonymous
anonymous / gist:6221307
Created August 13, 2013 13:48
Based on ServiceStack's RequiredRoleAttribute, this class requires that you have AT LEAST one of the roles -- not all, like the default ServiceStack implementation
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited = true, AllowMultiple = true)]
public class RequiredOneRoleOfAttribute : RequestFilterAttribute
{
public List<string> RequiredRoles { get; set; }
public RequiredOneRoleOfAttribute(ApplyTo applyTo, params string[] roles)
{
this.RequiredRoles = roles.ToList();
this.ApplyTo = applyTo;
this.Priority = (int)RequestFilterPriority.RequiredRole;
@ghuntley
ghuntley / gist:6229621
Last active December 21, 2015 01:39 — forked from anonymous/gist:6221307
Based on ServiceStack's RequiredRoleAttribute, this class requires that you have AT LEAST one of the roles -- not all, like the default ServiceStack implementation
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited = true, AllowMultiple = true)]
public class RequiredOneRoleOfAttribute : RequestFilterAttribute
{
public List<string> RequiredRoles { get; set; }
public RequiredOneRoleOfAttribute(ApplyTo applyTo, params string[] roles)
{
this.RequiredRoles = roles.ToList();
this.ApplyTo = applyTo;
this.Priority = (int)RequestFilterPriority.RequiredRole;
@rid00z
rid00z / FollowFingerViewController
Last active December 21, 2015 08:08
ViewController that follows fingers.
public partial class FollowFingerViewController : UIViewController
{
static bool UserInterfaceIdiomIsPhone {
get { return UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone; }
}
UIView _square;
public FollowFingerViewController ()
{
@jamie94bc
jamie94bc / IUpgrade.cs
Created October 16, 2013 09:51
Interfaces for an upgrade service to handle changes between versions on an application. If required, IUpgradeService should be implemented in a PCL with the CurrentAppVersion left as abstract to implement on a per device basis.
/// <summary>
/// Defines an interface which upgrades
/// the application from a version which is great
/// or equal to <see cref="IUpgrade.FromVersion"/>
/// and before <see cref="IUpgrade.ToVersion"/>.
/// </summary>
public interface IUpgrade {
Version FromVersion { get; }
Version ToVersion { get; }
@waynegraham
waynegraham / generateTable.xsl
Created March 20, 2012 14:43
Converts Infopath XML to HTML table
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2011-11-08T19:40:02"
exclude-result-prefixes="my"
version="1.0">
<xsl:output method="html" />
<xsl:strip-space elements="*" />
<xsl:param name="delimter" select="'|'" />
@rdavisau
rdavisau / GetXamarinApps.cs
Created November 5, 2015 04:31
Checks your iTunes folder for any .ipas that look like Xamarin apps
void Main()
{
var myXamarinApps =
Directory
.EnumerateFiles(Path.Combine(Environment.GetEnvironmentVariable("HOMEPATH"), @"Music\iTunes\iTunes Media\Mobile Applications"), "*.ipa")
.Where(f=> ZipFile.Open(f, ZipArchiveMode.Read)
.GetRawEntries()
.Any(e=> e.FullName.Contains(".monotouch-")));
foreach (var app in myXamarinApps)
@ghuntley
ghuntley / FilesystemWatchCache.cs
Created April 5, 2016 11:36 — forked from anaisbetts/FilesystemWatchCache.cs
An Rx-friendly Filesystem Watcher
using System;
using System.IO;
using System.Reactive.Disposables;
using System.Reactive.Linq;
using ReactiveUI;
namespace SaveAllTheTime.Models
{
interface IFilesystemWatchCache
{