Skip to content

Instantly share code, notes, and snippets.

View tintoy's full-sized avatar

Adam Friedman tintoy

View GitHub Profile
@tintoy
tintoy / NuGetFeedLister.csproj
Last active September 26, 2021 02:54
NuGet feed lister
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="NuGet.Client" Version="4.2.0" />
<PackageReference Include="NuGet.Configuration" Version="5.8.1" />
@tintoy
tintoy / RateCounter.cs
Last active October 30, 2019 20:57
Windowed rate-counter
/// <summary>
/// A simple windowed rate counter.
/// </summary>
/// <remarks>
/// Tracks an event count over a specific (moving) period of time. Locking omitted for clarity.
/// </remarks>
public class RateCounter
{
/// <summary>
/// Timestamps representing each event tracked by the counter.
@tintoy
tintoy / Program.cs
Last active April 17, 2019 13:24
Sub-verbs command line parser
using CommandLine;
using CommandLine.Text;
using System;
using System.Collections.Generic;
using System.Linq;
namespace SubVerbs
{
class Program
{
@tintoy
tintoy / DependencyInjectionActivator.cs
Created January 9, 2019 10:17
Microsoft.Extensions.DependencyInjection support for Hangfire
using Microsoft.Extensions.DependencyInjection;
using Hangfire;
using System;
public class DependencyInjectionActivator
: JobActivator
{
readonly IServiceProvider _serviceProvider;
public DependencyInjectionActivator(IServiceProvider serviceProvider)
@tintoy
tintoy / Program.cs
Created December 5, 2018 22:19
OmniSharp LSP client sample
using System;
using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using OmniSharp.Extensions.LanguageServer.Client;
using OmniSharp.Extensions.LanguageServer.Client.Processes;
using OmniSharp.Extensions.LanguageServer.Protocol.Models;
namespace SampleClient
@tintoy
tintoy / Model.cs
Last active October 28, 2018 06:50
OctoGrok
using Octopus.Client.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
namespace OctoMon
{
public class DeploymentTask
{
@tintoy
tintoy / Program.cs
Last active August 25, 2018 06:19
Discover available Kubernetes APIs
using HTTPlease;
using KubeClient;
using KubeClient.Models;
using KubeClient.ResourceClients;
using Newtonsoft.Json;
using Serilog;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
@tintoy
tintoy / K8sModelTransform.csproj
Last active April 29, 2018 06:00
Kubernetes model-transform to add base classes
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Buildalyzer" Version="0.4.0" />
<PackageReference Include="Buildalyzer.Workspaces" Version="0.4.0" />
@tintoy
tintoy / jumpbox-exec.py
Last active April 27, 2018 05:50
StackStorm action to execute a command over a chain of SSH hosts
#! /usr/bin/env python
import paramiko
import pprint
from st2common.runners.base_action import Action
from StringIO import StringIO
class JumpboxExec(Action):
def run(self, command, hosts):
@tintoy
tintoy / ssh_jump.py
Created April 27, 2018 02:45
SSH via jump-hosts using Paramiko
#!/usr/bin/env python3
import os
import paramiko
ssh_key_filename = os.getenv('HOME') + '/.ssh/id_rsa'
jumpbox_public_addr = '168.128.52.199'
jumpbox_private_addr = '10.0.5.10'
target_addr = '10.0.5.20'