Skip to content

Instantly share code, notes, and snippets.

@srkirkland
srkirkland / outgoingips.ps1
Created December 6, 2016 23:54
powershell for outgoing IP addresses
Get-AzureRmResource -ResourceGroupName "Default-Web-WestUS" -ResourceType Microsoft.Web/sites `
-ResourceName prepurchasing -ApiVersion 2015-08-01 | select -expand Properties |
ft @{l=”OutboundIPAddresses”; e={$_.OutboundIPAddresses -split “,”}}
@srkirkland
srkirkland / mockextension.cs
Created November 28, 2016 19:47
Moq extensions to turn queryable set of data into a mocked db set that will return that data
public static class MockExtensions
{
public static Mock<DbSet<T>> MockDbSet<T>(this IQueryable<T> data) where T : class, new()
{
var mockSet = new Mock<DbSet<T>>();
mockSet.As<IQueryable<T>>().Setup(m => m.Provider).Returns(data.Provider);
mockSet.As<IQueryable<T>>().Setup(m => m.Expression).Returns(data.Expression);
mockSet.As<IQueryable<T>>().Setup(m => m.ElementType).Returns(data.ElementType);
mockSet.As<IQueryable<T>>().Setup(m => m.GetEnumerator()).Returns(data.GetEnumerator());
@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": {
@srkirkland
srkirkland / putonglasses.txt
Created May 6, 2016 18:48 — forked from cheeaun/putonglasses.txt
put on glasses unicode
(•_•)
( •_•)>⌐■-■
(⌐■_■)
@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 / 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 / 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 / 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 / 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 / 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();