Skip to content

Instantly share code, notes, and snippets.

View jfoshee's full-sized avatar
🗺️
Exploring

Jacob Foshee jfoshee

🗺️
Exploring
View GitHub Profile
@jfoshee
jfoshee / format-sql-insert
Last active December 19, 2015 13:39
Format a SQL INSERT statement to line up column names with values.
$('#output').text('Ready');
var splitArgList = function (s) {
var first_paren = s.indexOf('(') + 1;
var opening = s.substring(0, first_paren).trim();
var args_closing = s.substring(first_paren);
var last_paren = args_closing.lastIndexOf(')');
var args = args_closing.substring(0, last_paren)
var closing = args_closing.substring(last_paren).trim();
return [opening, args, closing];
@jfoshee
jfoshee / ListPickerViewModel.cs
Created March 22, 2013 19:20
Implementation of MonoTouch (Xamarin.iOS) UIPickerViewModel for an IList<T>.
namespace Unplugged
{
public abstract class ListPickerViewModel<TItem> : UIPickerViewModel
{
public TItem SelectedItem { get; private set; }
IList<TItem> _items;
public IList<TItem> Items
{
get { return _items; }
@jfoshee
jfoshee / UIViewAnimations.cs
Last active December 14, 2015 01:39
An RAII style class for setting UIView.AnimationsEnabled MonoTouch / Xamarin.iOS
using System;
using MonoTouch.UIKit;
public sealed class UIViewAnimations : IDisposable
{
public UIViewAnimations(bool enabled)
{
_wasEnabled = UIView.AnimationsEnabled;
UIView.AnimationsEnabled = enabled;
}
@jfoshee
jfoshee / gist:3086735
Created July 10, 2012 22:48
Convert text string to UIImage in MonoTouch
static public UIImage StringToImage(string s, float fontSize)
{
return StringToImage(s, UIFont.FromName("Helvetica", fontSize));
}
static public UIImage StringToImage(string s, UIFont font)
{
var ns = new NSString(s);
var size = ns.StringSize(font);
UIGraphics.BeginImageContext(size);