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 / shiftkeytraingwheels.ahk
Created October 14, 2012 12:11
Shift key training wheels as per http://stevelosh.com/blog/2012/10/a-modern-space-cadet/ using Autohotkey
<+q::RETURN
<+w::RETURN
<+e::RETURN
<+r::RETURN
<+t::RETURN
<+a::RETURN
<+s::RETURN
<+d::RETURN
<+f::RETURN
<+g::RETURN
$LShift::
$RShift::
Key := SubStr(A_ThisHotkey,2)
Send, {%Key% Down}
KeyWait, %Key%
Send, {%Key% Up}
If ( A_PriorHotkey == A_ThisHotkey )
SendRaw, % InStr(Key,"L") ? "(" : ")"
Return
@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]' `
@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();
}
}
@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
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 + '"%'