Skip to content

Instantly share code, notes, and snippets.

View andykuszyk's full-sized avatar

andykuszyk

  • Deliveroo
  • Southampton, UK
View GitHub Profile
@andykuszyk
andykuszyk / Increasing version numbers in project.json or AssemblyInfo.cs using Powershell.md
Last active June 1, 2016 11:37
Increasing version numbers in project.json or AssemblyInfo.cs using Powershell

#Increasing version numbers in project.json or AssemblyInfo.cs using Powershell

As part of an automated deployment process, I needed to increase the minor version numbers stored in both project.json and AssemblyInfo.cs files. I achieved this with broadly similar powershell scripts.

Project.json

## This script picks up a json file, locates the version property and
## increases the most minor version number by 1.
@andykuszyk
andykuszyk / replace-assembly-info-versions.ps1
Last active June 10, 2016 09:06
Replace version numbers in assembly info files
# This powershell script is aimed at batch replacing version numbers
# in assembly info files. Provide the old version number that needs replacing
# and the new version number to replace it with. Run the script
# in the solution directory (e.g. the one that contains [ProjectName]\properties folders)
Param([string]$oldVersion, [string]$newVersion)
foreach($folder in Get-ChildItem -dir) {
$assemblyInfoPath = "$folder\properties\AssemblyInfo.cs"
Write-Host "Assembly info path: $assemblyInfoPath"
if(Test-Path $assemblyInfoPath) {
@andykuszyk
andykuszyk / Creating and Publishing NuGet Packages.md
Last active July 8, 2021 14:51
Creating and Publishing NuGet Packages

Creating and Publishing NuGet Packages

Introduction

This document describes how to publish a nuget packages by creating a nuspec and then publishing it to a server.

How do we get from dll to publish nuget package?

In order to publish dlls as a nuget package, we need to perform these three steps:

  1. Create a nuspec;
  2. Pack the nuspec;
@andykuszyk
andykuszyk / Using AutoMapper to map complex classes with members that are hidden behind an interface.md
Last active July 28, 2016 12:47
Using AutoMapper to map complex classes with members that are hidden behind an interface

Using AutoMapper to map complex classes with members that are hidden behind an interface

Background

I recently wanted to use AutoMapper (a .NET library for mapping objects of one type to another) to map class containing many properties that were of a type that also needed to be mapped to another, similar type. To make matters worse, the type that I wanted to map to didn't just have properties of a custom type, but these types were actually interfaces with custom implementations.

For example, the type I wanted to map from looked something like this:

public class OriginalParent
{
  public OriginalChild ChildProperty { get; }
@andykuszyk
andykuszyk / RestoreSqlDb.ps1
Created August 1, 2016 09:49
Restoring SQL Server databases in Powershell
$dbName = "MyDatabase"
$serverAddress = ".\SqlServer"
# Delete the existing database.
$server = new-Object Microsoft.SqlServer.Management.Smo.Server($serverAddress)
if($server.Databases[$dbName)
{
$server.KillDatabase($dbName)
}
@andykuszyk
andykuszyk / Enable powershell remoting to a machine via IP address.ps1
Last active September 6, 2016 08:08
Enable powershell remoting to a machine via IP address
winrm quickconfig
winrm s winrm/config/client '@{TrustedHosts="myservername.domain"}'
# To list the trusted hosts:
Get-Item WSMan:\localhost\Client\TrustedHosts
@andykuszyk
andykuszyk / find-and-replace.ps1
Created August 29, 2016 12:35
A find and replace in files powershell script
Param([string]$fileName, [string]$find, [string]$replace)
(Get-Content $fileName -encoding UTF8) | foreach-object {
$_ -replace $find, $replace
} | Set-Content $fileName -encoding UTF8
@andykuszyk
andykuszyk / Clear credentials for Git.md
Created October 21, 2016 14:20
Clear credentials for Git

git credential-manager clear

@andykuszyk
andykuszyk / Grant execute permissions in SQL Server to user.sql
Created November 30, 2016 14:35
Grant execute permissions in SQL Server to user
use [dbname]
go
grant execute to [user]
@andykuszyk
andykuszyk / probabilities.ipynb
Last active February 16, 2017 12:17
Probabilities
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.