Skip to content

Instantly share code, notes, and snippets.

View markryd's full-sized avatar

Mark Rydstrom markryd

  • Brisbane, Australia
View GitHub Profile
@markryd
markryd / react-autocomplete.d.ts
Created April 20, 2018 05:48
Start of typescript types for react-autocomplete
interface AutocompleteProps<T> {
items: T[];
value?: string;
onChange?(e: React.ChangeEvent<HTMLInputElement>, value: string): void;
onSelect?(value: string, item: T): void;
shouldItemRender?(item: T, value: string): boolean;
isItemSelectable?(item: T): boolean;
sortItems?(itemA: T, itemB: T, value: string): -1 | 0 | 1;
getItemValue(item: T): string;
renderItem(item: T, isHighlighted?: boolean, styles?: React.CSSProperties): JSX.Element;
@markryd
markryd / duplicates.xml
Created February 28, 2018 04:40
Build task to fail on duplicate package references
<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
<Error Text="A package is referenced more than once, check the csproj and remove the duplicate reference." Condition="@(PackageReference->Count()) != @(PackageReference->Distinct()->Count())" />
</Target>
@markryd
markryd / Disable-ARC.ps1
Created February 11, 2018 23:22
Powershell script to disable ARC on an Octopus project
# You can get this dll from your Octopus Server/Tentacle installation directory or from
# https://www.nuget.org/packages/Octopus.Client/
Add-Type -Path 'C:\Program Files\Octopus Deploy\Tentacle\Octopus.Client.dll'
$apikey = 'API-CHANGEME' # Get this from your profile
$octopusURI = 'http://localhost:8065' # Your server address
$projectName = 'A new project' # The namne of the project you want to disable ARC on
$endpoint = new-object Octopus.Client.OctopusServerEndpoint $octopusURI,$apikey
$repository = new-object Octopus.Client.OctopusRepository $endpoint
@markryd
markryd / Update-DeploymentStepPackageRequirement.ps1
Last active December 12, 2017 00:40
Update DeploymentStepPackageRequirement in all projects
# This script requires DeploymentStepPackageRequirement which is scheduled for release in Octopus 4.2
# You can this dll from your Octopus Server/Tentacle installation directory or from
# https://www.nuget.org/packages/Octopus.Client/
Add-Type -Path 'C:\path\to\client\lib\Octopus.Client.dll'
$apikey = 'API-YOURAPIKEY' # Get this from your profile
$octopusURI = 'http://localhost:8065' # Your server address
# create the connection to the Octopus Server
@markryd
markryd / heartbeat.sh
Last active April 18, 2017 02:38
nbn modem monitor
#!/bin/bash
# check if we are already rebooting and exit
if [ -f /home/pi/heartbeat/rebooting ] ; then
exit 0
fi
# ping and exit on success
ping -c 1 -w 5 8.8.8.8 &> /dev/null
if [ "$?" = 0 ] ; then
@markryd
markryd / convert-toxunit.ps1
Last active July 12, 2019 13:33
Do a rough conversion from nunit to xunit + fluentassertions
$testFolder = "C:\dev\Calamari\source\Calamari.Tests"
Function Convert-ToXunit {
Param(
[System.IO.FileInfo]$file
)
$result = (Get-Content $file.FullName -Raw) `
-replace 'using NUnit.Framework;', 'using Xunit;' `
-replace '\[Test\]', '[Fact]' `
if not exists (select column_name from INFORMATION_SCHEMA.columns where TABLE_SCHEMA = 'dbo' and table_name = 'Deployment' and column_name = 'ChannelId')
BEGIN
ALTER TABLE dbo.Deployment ADD ChannelId nvarchar(50) NULL
END
GO
-- Update column from json blob. Try to extract rather than joining on Release since it may have changed.
UPDATE dbo.Deployment
SET ChannelId = c.Id
FROM dbo.Deployment d INNER JOIN dbo.Channel c ON d.[JSON] LIKE '%"ChannelID":"' + c.Id + '"%'
@markryd
markryd / benchmark-azure-rm-load.ps1
Created June 7, 2016 01:19
Benchmark Azure RM Powershell loading
#CHANGE ME!
$OctopusAzureModulePath = "C:\Octopus\master\Calamari\Azure\1.0.20160602.084032\AzurePowershell"
$AzureRMModules = @(
"AzureRM.ApiManagement",
"AzureRM.Automation",
"AzureRM.Backup",
"AzureRM.Batch",
"AzureRM.Compute",
"AzureRM.DataFactories",
@markryd
markryd / register.sh
Created June 6, 2016 00:28
Register multiple Octopus SSH Targets for testing
#!/bin/bash
echo installing mono
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
echo "deb http://download.mono-project.com/repo/debian wheezy main" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list
sudo apt-get update
sudo apt-get install -y mono-complete
function createMachine() {
username=t-$RANDOM
@markryd
markryd / nancy-linqpad.cs
Created March 7, 2016 00:39
Run Nancy in Linqpad
// nuget in Nancy and Nancy.Hosting.Self
void Main()
{
using (var host = new Nancy.Hosting.Self.NancyHost(new Uri("http://localhost:8080"), new LinqpadNancyBootstrapper()))
{
host.Start();
Console.ReadLine();
}
}