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
export class StatusCodeError extends Error { | |
statusCode: number; | |
constructor(statusCode: number, message: string, ...params: any[]) { | |
// Pass remaining arguments (including vendor specific ones) to parent constructor | |
super(message); | |
// Maintains proper stack trace for where our error was thrown (only available on V8) |
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
const delayPromise = (time: number) => | |
<T>(result) => | |
new Promise<T>((response) => | |
setTimeout(() => { | |
response(result); | |
}, time) | |
); |
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
using System; | |
namespace Lski.Toolbox.Txt { | |
public static class StringExtensions | |
{ | |
/// <summary> | |
/// Performs a case insenstive equality check on two strings. | |
/// </summary> | |
public static bool IsEqual(this string strA, string strB) |
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
using System; | |
namespace Lski.Exceptions { | |
/// <summary> | |
/// Static methods to throw conditionally is te assertion is false. | |
/// </summary> | |
/// <remarks> | |
/// A major advantage to a method like this is reduced IL and assembly code as according to | |
/// <a href="https://referencesource.microsoft.com/#mscorlib/system/throwhelper.cs">ThrowHelper.cs</a>. |
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
using System; | |
namespace Lski.Exceptions { | |
/// <summary> | |
/// Static methods to throw exceptions with a smaller footprint | |
/// </summary> | |
/// <remarks> | |
/// A major advantage to a method like this is reduced IL and assembly code as according to | |
/// <a href="https://referencesource.microsoft.com/#mscorlib/system/throwhelper.cs">ThrowHelper.cs</a>. |
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
/** | |
* Shorthand function for document.createElement. Accepts and appends attributes to the newly created element and appends child element, if any. | |
* @param tagName The name of the element eg. a or script | |
* @param attributes Any additional attributes to add to the element after creating. Eg. href | |
* @param children Any child elements you want appended on creating this element, obviously they could be createElement calls as well | |
*/ | |
export function createElement(tagName, attributes, children) { | |
const ele = attributes === (void 0) | |
? document.createElement(tagName) | |
: Object.assign(document.createElement(tagName), attributes); |
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
<# | |
.SYNOPSIS | |
Converts windows path into a linux path and vice versa. | |
.DESCRIPTION | |
Converts windows path into a linux path and vice versa. Use WSL under the hood, so needs to be installed. | |
See docs wslpath docs for more information. | |
.PARAMETER path | |
The path to convert |
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 GuidExtensions { | |
/// <summary> | |
/// Converts a Guid into a short format useful urls | |
/// </summary> | |
/// <remarks> | |
/// See <see>https://madskristensen.net/blog/A-shorter-and-URL-friendly-GUID</see> for a more detailed explantion. | |
/// </remarks> | |
public static string ToShortFormat(this Guid guid) => | |
Convert.ToBase64String(guid.ToByteArray()) |
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
using System; | |
using System.Net.Http; | |
using System.Threading; | |
using System.Threading.Tasks; | |
namespace HttpWrapper | |
{ | |
/// <summary> | |
/// A concrete implementation of IHttpClient, which can be used easily for mocking | |
/// </summary> |
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
using System; | |
using System.Diagnostics; | |
using System.Runtime.InteropServices; | |
namespace WebBrowser | |
{ | |
public static class Browser | |
{ | |
public static Process Launch(string url, string browser = null) | |
{ |