Skip to content

Instantly share code, notes, and snippets.

View andykuszyk's full-sized avatar

andykuszyk

  • Deliveroo
  • Southampton, UK
View GitHub Profile
@andykuszyk
andykuszyk / jenkins-api-python.py
Created June 7, 2017 16:25
jenkins-api-python
import requests
requests.post('http://{}/job/{}/buildWithParameters?{}={}'.format(
jenkins_url,
job_name,
parameter_name,
parameter_value
))
@andykuszyk
andykuszyk / linux-commands.md
Last active July 6, 2017 15:48
linux commands

See devices on local network

arp-scan --localnet

Check disk usage

du -h

Finding text in files

cat /path/to/file.txt | grep -o -P '.{0,3}string-to-match.{0,10}'

See first few lines in file

@andykuszyk
andykuszyk / remote-powershell.ps1
Created April 21, 2017 07:33
Remote powershell
$serverAddress = "1.1.1.1"
$userName = "user"
$securePassword = ConvertTo-SecureString -AsPlainText -Force -String "password"
$credentials = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $userName,$securePassword
$session = New-PSSession -ComputerName $serverAddress -Credential $credentials
Invoke-Command -Session $session -ScriptBlock {
Write-Host "hello world"
}
@andykuszyk
andykuszyk / probabilities.ipynb
Last active February 16, 2017 12:17
Probabilities
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@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 / Clear credentials for Git.md
Created October 21, 2016 14:20
Clear credentials for Git

git credential-manager clear

@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 / 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 / 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 / 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; }