This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private function SetTimeZone($dtStr) | |
{ | |
$newDt = DateTime::createFromFormat(DateTime::ISO8601, $dtStr); | |
$newDt->setTimezone(new DateTimeZone('Australia/Perth')); | |
$newDtStr = $newDt->format("c"); | |
return $newDtStr; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// dependancies: Newtonsoft.Json, RestSharp; | |
public interface IRpcClient<T> | |
{ | |
string AccessToken { get; } | |
string BaseUrl { get; } | |
T DataStore { get; } | |
string Host { get; } | |
string Protocal { get; } | |
string RelativeUrl { get; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static IRestResponse<T> MakeRequest(string relativeUrl, Func<RestClient, RestRequest, IRestResponse<T>> clientFunc) | |
{ | |
var client = new RestClient("https://someresource.com"); | |
var request = new RestSharp.RestRequest(relativeUrl); | |
return clientFunc(client, request); | |
} | |
// example call | |
var request = MakeRequest("/api/whatever", (c, r) => c.Execute<SomeType>(r)); | |
var deserializedSomeTypeData = request.Data; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[System.Reflection.Assembly]::Load("System.EnterpriseServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a") | |
$publish = New-Object System.EnterpriseServices.Internal.Publish | |
$publish.GacInstall("C:\temp\{dllname}.dll") | |
iisreset |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static T GetFromMemoryCache<T>(string key, int cacheTime, Func<T> whenKeyNotFound) | |
{ | |
var items = MemoryCache.Default; | |
if (items[key] != null) | |
{ | |
// return from cache | |
return (T)items[key]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
internal class SpriteInfo | |
{ | |
public string Name { get; private set; } | |
public int X { get; private set; } | |
public int Y { get; private set; } | |
public int W { get; private set; } | |
public int H { get; private set; } | |
public SpriteInfo(string name, int x, int y, int w, int h) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class PredicateBuilder | |
{ | |
public static Expression<Func<T, bool>> And<T>(this Expression<Func<T, bool>> expr1, Expression<Func<T, bool>> expr2) | |
{ | |
var invokedExpr = Expression.Invoke(expr2, expr1.Parameters.Cast<Expression>()); | |
return Expression.Lambda<Func<T, bool>>(Expression.AndAlso(expr1.Body, invokedExpr), expr1.Parameters); | |
} | |
public static Expression<Func<T, bool>> False<T>() | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static T GetFromHttpCache<T>(string key, Cache items, int cacheTime, Func<T> whenKeyNotFound, CacheItemRemovedCallback onRemoveCallback = null) | |
{ | |
if (items[key] != null) | |
{ | |
// return from cache | |
return (T)items[key]; | |
} | |
// return new item from caller and add to cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://encrypted.google.com/search?hl=en&q=site%3Agist.github.com%2Fmichaelbramwell%20%7C%7C%20site%3Agithub.com%2Fmichaelbramwell |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class HtmlUglifyFilter : Stream | |
{ | |
private readonly Stream _responseStream; | |
private long _position; | |
public HtmlUglifyFilter(Stream inputStream) | |
{ | |
_responseStream = inputStream; | |
} |