Skip to content

Instantly share code, notes, and snippets.

View xinmyname's full-sized avatar

Andy Sherwood xinmyname

View GitHub Profile
override func tableView(tableView: UITableView?, cellForRowAtIndexPath indexPath: NSIndexPath?) -> UITableViewCell?
{
let account = _accounts[indexPath!.row]
let cell = tableView!.dequeueReusableCellWithIdentifier("AccountViewCell") as UITableViewCell
cell.textLabel.text = account.name
cell.detailTextLabel.text = account.email
return cell
}
@xinmyname
xinmyname / gist:83cbf6d5dd9901d434f3
Last active August 29, 2015 14:02
What could be simpler?
MERGE INTO vegetation.PlotHeader AS Target
USING (VALUES(@PlotNumber,@SurveyDate,GETDATE(),@ProjectId,@PlantCommId,@Comments,@PlotId,@NorthShadePercentage,@EastShadePercentage,@SouthShadePercentage,@WestShadePercentage))
AS Source(PlotNumber,SurveyDate,LastModified,ProjectId,PlantCommId,Comments,PlotId,NorthShadePercentage,EastShadePercentage,SouthShadePercentage,WestShadePercentage)
ON
(
Target.SurveyDate = Source.SurveyDate AND
Target.ProjectId = Source.ProjectId AND
Target.PlantCommId = Source.PlantCommId AND
Target.PlotNumber = Source.PlotNumber
)
@xinmyname
xinmyname / serveandwatch.ps1
Created April 28, 2014 15:32
Start an HTTP server and watch the folder for changes
Start-Process python.exe -argument '-m http.server'; Start-Process livereloadx.cmd
using (var serviceRequest = new WebClient())
{
string token = GetAuthorizationToken("yourservice","owner", "NW1wr7/nlgggTFnB5L7nDBrOLC+o1E1P4ZZqPaP2mY4=");
serviceRequest.Headers["Authorization"] = string.Format("WRAP access_token=\"{0}\"", token);
string response = serviceRequest.DownloadString(new Uri(url));
return response;
}
// connects to ACS and gets WRAP Authorization token
@xinmyname
xinmyname / gist:6559023
Last active December 23, 2015 01:18
What could be simpler?
PS1='\[\033]0;${PWD}\007\]\[\033[00m\][${DVCSBRANCH} \[\033[1;32m\]a${INDEXADDED} \[\033[1;33m\]M${FILESMODIFIED} \[\033[1;34m\]D${FILESDELETED} \[\033[1;31m\]?${FILESADDED}\[\033[00m\]] \[\033[0;33m\]m${INDEXMODIFIED} \[\033[0;31m\]d${INDEXDELETED} \[\033[0;35m\]U${FILESUNMERGED} u${INDEXUNMERGED}\[\033[00m\]\n$>'
@xinmyname
xinmyname / implicit try
Created September 5, 2013 18:27
What if we had implicit try blocks in methods if you followed the method with a catch block? I think the meaning remains clear, but we lose a few lines and indentation.
private bool DoWork()
{
DoSomething();
DoSomethingElse();
return true;
}
catch (Exception ex)
{
_log.Error(ex);
@xinmyname
xinmyname / FMDatabaseFactory.m
Created March 3, 2013 20:46
FMDatabase factory class. Handles the creation of an FMDatabase object. Creates a new database from a template resource if necessary.
//
// FMDatabaseFactory.m
//
// Copyright (c) 2012 Andy Sherwood. All rights reserved.
//
#import "FMDatabaseFactory.h"
#import <FMDatabase.h>
@implementation FMDatabaseFactory
@xinmyname
xinmyname / SPListItemExtensions.cs
Created June 7, 2012 04:41
SharePoint object mapper
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Reflection;
using Microsoft.SharePoint;
namespace MileageSite.Layouts.MileageSite
{
public static class SPListItemExtensions
@xinmyname
xinmyname / saneTimeout.coffee
Created February 23, 2012 17:05
CoffeeScript setTimeout sanity restoration
setTimeout = (delay, exp) ->
window.setTimeout exp, delay
@xinmyname
xinmyname / gist:1862145
Created February 19, 2012 05:42
Fluent Parsing sample
public IEnumerable<InterfaceStatusEntry> ShowInterfaceStatus()
{
return ParserFactory
.CreateParser<InterfaceStatusParserBase>(_iosVersion.SoftwareFamily)
.Parse(_sshShellWrapper.Capture("show interface status"));
}