Skip to content

Instantly share code, notes, and snippets.

@srkirkland
srkirkland / factualresponse.cs
Created July 15, 2015 05:47
factual data return
public class FactualPlaceResponseContainer
{
public string Status { get; set; }
public FactualPlaceResponse Response { get; set; }
}
public class FactualPlaceResponse
{
[JsonProperty("included_rows")]
public int IncludedRows { get; set; }
@srkirkland
srkirkland / factualquery.cs
Created July 15, 2015 05:48
factual query using httpclient and oauth util
const string placeQuery = "http://api.v3.factual.com/t/places?geo={\"$point\":[38.544401,-121.742229]}";
using (var client = new HttpClient())
{
var header = OAuthUtil.GenerateHeader(new Uri(placeQuery), "KEY",
"SECRET", null, null, "GET");
client.DefaultRequestHeaders.Add("Authorization", header);
var res = client.GetAsync(placeQuery).Result;
res.EnsureSuccessStatusCode();
@srkirkland
srkirkland / xamarinoauth1.cs
Created July 15, 2015 07:09
oauth manually using xamarin.auth
const string placeQuery = "http://api.v3.factual.com/t/places?geo={\"$point\":[38.544401,-121.742229]}";
using (var client = new HttpClient())
{
var header = Xamarin.Auth.OAuth1.GetAuthorizationHeader ("GET", new Uri ("http://api.v3.factual.com/t/places"), new Dictionary<string,string> { {"geo","{\"$point\":[38.544401,-121.742229]}"} },
"key", "secret", string.Empty, string.Empty);
client.DefaultRequestHeaders.Add("Authorization", header);
var res = client.GetAsync(placeQuery).Result;
// res.EnsureSuccessStatusCode();
@srkirkland
srkirkland / updatestatuscodes.sql
Created August 6, 2015 23:20
update some status codes
select * from Gifts where Status = 'Completed' and StatusLevel = 10 --if any results we are on old scheme
update Gifts set StatusLevel = StatusLevel + 1 where StatusLevel > 5 --move all gifts financial review or higher up a level
update Gifts set StatusLevel = StatusLevel + 2 where StatusLevel = 5 --move from financial hold to financial review
@srkirkland
srkirkland / alertcontroller.cs
Created October 8, 2015 05:51
replacement for action sheet
var alertController = UIAlertController.Create (null, null, UIAlertControllerStyle.Alert);
alertController.AddAction (UIAlertAction.Create ("Cancel", UIAlertActionStyle.Cancel, null));
alertController.AddAction (UIAlertAction.Create ("Take photo", UIAlertActionStyle.Default, null));
alertController.AddAction (UIAlertAction.Create ("Take photo", UIAlertActionStyle.Default, null));
this.PresentViewController (alertController, true, null);
@srkirkland
srkirkland / funky.cs
Created October 27, 2015 23:05
funky gifts
var completed = RepositoryFactory.GiftRepository.Queryable.Where(x => x.IsCompleted).ToArray();
var trans = await
_givingFinancialService.GetKfsAccountDetails(
completed.Select(c => new KfsAccountQueryParams {KfsKey = c.KfsKey}).ToArray());
var grouped = trans.GroupBy(t => t.KfsKey).Select(t => new {t.Key, total = t.Sum(x => x.Amount)});
var joined = from c in completed
join g in grouped on c.KfsKey equals g.Key
@srkirkland
srkirkland / pdfcoupon.cs
Created November 24, 2015 19:37
pdf with floating box and ocr scan line
// Load HTML file
var pdfDocument = new Document(stream, options);
//pdfDocument.FitWindow = true;
Font myFont = FontRepository.OpenFont(HttpContext.Current.Server.MapPath("~/fonts/ocraextended.ttf"));
//Font myFont = FontRepository.OpenFont(".\\fonts\\ocraextended.ttf");
myFont.IsEmbedded = true;
//create text stamp
TextStamp textStamp = new TextStamp("0123456789000100000123456789");
@srkirkland
srkirkland / deletemerged.ps1
Created January 13, 2016 22:04
delete merged branches powershell
git branch --merged | ?{-not ($_ -like "*master")} | %{git branch -d $_.trim()}
@srkirkland
srkirkland / putonglasses.txt
Created May 6, 2016 18:48 — forked from cheeaun/putonglasses.txt
put on glasses unicode
(•_•)
( •_•)>⌐■-■
(⌐■_■)
@srkirkland
srkirkland / .eslintrc
Created July 27, 2016 01:01
eslint config file for react native app, based on facebook's f8 example and airbnb style, plus some of my own favorite rules.
{
"extends": "airbnb",
"plugins": [
"react"
],
"env": {
"es6": true,
"jasmine": true,
},
"rules": {