Skip to content

Instantly share code, notes, and snippets.

View todthomson's full-sized avatar

Tod Thomson todthomson

View GitHub Profile
@teamtam
teamtam / ViewLocationExpander.cs
Last active September 19, 2017 03:00
ASP.NET Core customisation for arranging views vertically by feature
public class ViewLocationExpander : IViewLocationExpander
{
public IEnumerable<string> ExpandViewLocations(ViewLocationExpanderContext context, IEnumerable<string> viewLocations)
{
string[] locations = new string[]
{
"~/Features/{1}/{0}.cshtml",
"~/Features/Shared/{0}.cshtml",
};
return locations;
@andrewabest
andrewabest / Instructions.md
Last active February 16, 2018 05:46
CI for Cordova (iOS) via VSTS, MacInCloud and HockeyApp

Install the Cordova Build and HockeyApp VSTS extensions into your VSTS tenant.

Sign up for a MacInCloud account, and create a VSTS build agent.

Create a pool for your agent in VSTS: https://support.macincloud.com/support/solutions/articles/8000016614-getting-started-with-the-macincloud-vsts-previously-vso-build-agent-plan and configure the agent following the instructions in the article.

Sign up for a HockeyApp account. Create an API token that VSTS will use to talk to HockeyApp via Account Settings > API Tokens.

For HockeyApp, create a service endpoint in VSTS: https://support.hockeyapp.net/kb/third-party-bug-trackers-services-and-webhooks/how-to-use-hockeyapp-with-visual-studio-team-services-vsts-or-team-foundation-server-tfs#installation-for-vsts

@chranderson
chranderson / nvmCommands.js
Last active January 3, 2026 02:13
Useful NVM commands
// check version
node -v || node --version
// list locally installed versions of node
nvm ls
// list remove available versions of node
nvm ls-remote
// install specific version of node
@regisdiogo
regisdiogo / Startup.cs
Last active July 26, 2025 11:17
ASP.NET Core - Json serializer settings Enum as string and ignore null values
public class Startup
{
public IServiceProvider ConfigureServices(IServiceCollection services)
{
services.AddMvc().AddJsonOptions(options =>
{
options.SerializerSettings.Converters.Add(new Newtonsoft.Json.Converters.StringEnumConverter());
options.SerializerSettings.NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore;
});
}
@gertjvr
gertjvr / Autofac.SignalR.md
Last active August 4, 2023 06:56
Autofac.SignalR hub scoped dependencies per instance.

SignalR generates a hub for each method invoke ie onConnected, onDisconnect or any other methods on the hub. Autofac.SignalR all hub dependencies are resolved from the root container making them singletons.

I did find another solutions https://github.com/lethek/SignalR.Extras.Autofac but this required inheriting from a special lifetimehub, retro fitting this into an large existing solution would take a lot of work an re-testing.

The solutions below allows you to scope all dependencies per hub instance.

  • Install-Package Autofac.SignalR
  • Install-Package Castle.Core
@davidfowl
davidfowl / Example1.cs
Last active September 2, 2024 12:36
How .NET Standard relates to .NET Platforms
namespace Analogy
{
/// <summary>
/// This example shows that a library that needs access to target .NET Standard 1.3
/// can only access APIs available in that .NET Standard. Even though similar the APIs exist on .NET
/// Framework 4.5, it implements a version of .NET Standard that isn't compatible with the library.
/// </summary>INetCoreApp10
class Example1
{
public void Net45Application(INetFramework45 platform)
@Dalmirog-zz
Dalmirog-zz / script.ps1
Created September 15, 2015 20:36
Get all the variables scoped to a specific machine
#This script required the Octoposh module: http://dalmirog.github.io/OctoPosh/
$machine = "" #Name of the machine you want to look variables for.
$MachineID = Get-OctopusMachine -MachineName $machine -ResourceOnly | select -ExpandProperty Id
$variableSets = Get-OctopusVariableSet
$list = @()
foreach ($variableSet in $variableSets){
@jackawatts
jackawatts / XmlExpando
Last active August 29, 2024 00:29
Simple XmlExpando
using System;
using System.Collections.Generic;
using System.Dynamic;
using System.Linq;
using System.Xml.Linq;
namespace Expando
{
public static class XmlExpando
{
void Main()
{
IDb db;
new PersonNameProjection(
new PersonQuery(db.Table<Person>()).ByName("Tod")
).Execute();
}
@HarmJ0y
HarmJ0y / gist:fd98c4f16575ba28c091
Last active April 27, 2023 13:56
Powershell ADSI tricks
# Add a domain user to a remote server local group, if your current user has admin over the remote machine
powershell -c ([ADSI]'WinNT://SERVER/Administrators,group').add('WinNT://DOMAIN/USER,user')
# Get all local groups on a remote server
powershell -c "([ADSI]'WinNT://SERVER,computer').psbase.children | where { $_.psbase.schemaClassName -eq 'group' } | foreach { ($_.name)[0]}"
# Find members of the local Administrators group on a remote server
powershell -c "$([ADSI]'WinNT://SERVER/Administrators,group').psbase.Invoke('Members') | foreach { $_.GetType().InvokeMember('ADspath', 'GetProperty', $null, $_, $null).Replace('WinNT://', '') }"
# Enable the local Administrator account on a remote server