Skip to content

Instantly share code, notes, and snippets.

View secretorange's full-sized avatar

Lee Gunn secretorange

View GitHub Profile
@secretorange
secretorange / UnitTests.cs
Last active October 21, 2018 16:05
Version attribute for MSTest, useful for testing versioned API endpoints.
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Diagnostics;
namespace UnitTestProject
{
[TestClass]
public class UnitTests
{
[TestMethod]
@secretorange
secretorange / Folders.md
Last active April 14, 2018 12:49
Freelance setup

WORK IN PROGRESS

  • 📁 DEV (Development folder - anything dev related that can be thrown away)
  • 📁 DB (All databases for all projects)
  • 📁 PRJ (Projects)
  • 📁 ACC (Accounts - Invoices & receipts etc)

Details

@secretorange
secretorange / Constants.cs
Created April 12, 2018 07:36
Commonly used RegEx for DotNet. Email, Password etc.
public static class Constants
{
public static class RegEx
{
public const string Email = @"^[a-zA-Z0-9#'$%+/=?^_`{|}~-]+(?:\.[a-zA-Z0-9#'$%+/=?^_`{|}~-]+)*[a-zA-Z0-9#'$%+/=?^_`{|}~-]*@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z0-9]{2,}$";
// Passwords must be at least 8 characters and contain at 3 of 4 of the following: upper case (A-Z), lower case (a-z), number (0-9) and special character (e.g. !@#$%^&*)
public const string Password = "^((?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])|(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[^a-zA-Z0-9])|(?=.*?[A-Z])(?=.*?[0-9])(?=.*?[^a-zA-Z0-9])|(?=.*?[a-z])(?=.*?[0-9])(?=.*?[^a-zA-Z0-9])).{8,}$";
}
}

My SQL Snippets

Process List

SHOW PROCESSLIST

DROP all tables

SELECT concat('DROP TABLE IF EXISTS `', table_schema, '`.`', table_name, '`;')
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
namespace SecretOrange.Data
{
public class EasySort<T> where T : class
{
@secretorange
secretorange / ConditionalAnchorTagHelper.cs
Last active February 17, 2019 16:23
ASP.NET 5 Conditional Anchor Tag Helper. This tag helper will omit the anchor tag if the href is null or empty.
namespace SecretOrange
{
[HtmlTargetElement("a", Attributes = "asp-conditional")]
public class ConditionalAnchorTagHelper : TagHelper
{
public override async void Process(TagHelperContext context, TagHelperOutput output)
{
var href = context.AllAttributes["href"]?.Value.ToString();
if (String.IsNullOrWhiteSpace(href))
using System;
using System.Linq;
namespace MontyHall
{
public class Game
{
private static Random Random = new Random();
public static void Main(string[] args)