Skip to content

Instantly share code, notes, and snippets.

View yetanotherchris's full-sized avatar
🔏
;ÿÿÿÿrules

Chris S. yetanotherchris

🔏
;ÿÿÿÿrules
View GitHub Profile
@yetanotherchris
yetanotherchris / install-kops.sh
Last active March 25, 2024 23:52
Install Kops and prequisites on Ubuntu
# Install AWS CLI, Kubectl, Kops
sudo apt update
sudo apt install -y awscli
sudo snap install kubectl --classic
curl -LO https://github.com/kubernetes/kops/releases/download/1.7.0/kops-linux-amd64
chmod +x kops-linux-amd64
mv ./kops-linux-amd64 /usr/local/bin/kops
# Setup the AWS profile
aws config
@yetanotherchris
yetanotherchris / docker-automation.py
Created September 5, 2016 09:07
Automating Docker images and containers with Python ()
'''
This script brings up the entire stack of Docker containers, removing the current ones.
Docker compose was tried for this task and it wasn't customisable enough.
Docker cloud was tried (with stack files) and was buggy (failed to launch, no logs returned).
Docker machine was tried, but it can't connect to existing servers only ones it created.
Rancher was too heavy weight for the task, as the containers are lightweight in DigitalOcean.
Kubernetes would've been too heavy weight for DigitalOcean.
It was written in Powershell and worked. But then converting it to Bash was too much effort.
Powershell for Linux is too much effort to install without a debian package (and none standard)
#==========================================================================================
# Get the latest Chromedriver version number
#==========================================================================================
WriteHeader "Determining Chromedriver version"
$url = "http://chromedriver.storage.googleapis.com/";
$xml = [xml](wget $url);
$chromeDriver_version = 2.12;
# XML format: <ListBucketResult><Contents><Key>...</Key></Contents></ListBucketResult>
foreach ($item in $xml.ListBucketResult.Contents)
@yetanotherchris
yetanotherchris / update-dns.ps1
Created September 20, 2016 08:53
Update DNS entries in Powershell
Remove-DnsServerResourceRecord -Name "mysubdomain" -Force -RRType CName -ZoneName "example.com" -ComputerName "ADserver.example.com" -ErrorAction Ignore
Add-DnsServerResourceRecordCName -Name "mysubdomain" -HostNameAlias "mysubdomain.example.com" -ZoneName "example.com" -ComputerName "ADserver.example.com"
Add-DnsServerResourceRecordA -IPv4Address "10.1.2.3" -Name "another-server.example.com" -ZoneName "example.com" -ComputerName "ADserver.example.com"
@yetanotherchris
yetanotherchris / enable-hyperv-in-hyperv.ps1
Created October 15, 2017 09:14
Enable Hyper-V inside Hyper-V for Windows 10 Creators Edition. Run docker inside a Hyper-V VM
# Example: ./enable-hyperv-in-hyperv.ps1 -vmName "Windows 10"
param (
[Parameter(Mandatory = $true)]$vmName
)
Set-VMProcessor -VMName $vmName -ExposeVirtualizationExtensions $true
Get-VMNetworkAdapter -VMName $vmName | Set-VMNetworkAdapter -MacAddressSpoofing On
Write-Host "VM updated. Make sure your VM has dynamic memory enabled, and has 4gb or more"
@yetanotherchris
yetanotherchris / http-load-test.ps1
Created March 30, 2022 08:34
Powershell HTTP "load testing" (about 3-5 RPS)
while ($true) { $r = wget -uri "http://somesite.com?q=1" -headers @{"Accept-Tenant"="Nz"}; echo $r.Content }
@yetanotherchris
yetanotherchris / import-snippet.psm1
Created October 27, 2015 00:32
Downloads a snippet from visualstudiocodesnippets.com, for use with Visual Studio Package manager
function Import-Snippet($snippetId, $name)
{
# Save this in one of the locations found from $env:PSModulePath as "Import-Snippet\import-snippet.psm1"
# e.g. "D:\Chris\Documents\WindowsPowerShell\Modules\Import-Snippet\import-snippet.psm1"
# Then in powershell type "import-module import-snippet"
$fullUrl = "http://visualstudiocodesnippets.com/download/$snippetId"
$filePath = "$env:USERPROFILE\Documents\Visual Studio 2015\Code Snippets\Visual C#\My Code Snippets\$name.snippet"
wget -Uri "$fullUrl" -OutFile "$filePath"
Write-Host "Successfully saved $filePath" -ForegroundColor DarkGreen
@yetanotherchris
yetanotherchris / UpdateChromeDriver.ps1
Last active February 4, 2024 14:09
Downloads the latest ChromeDriver, installs it to c:\windows
# Make sure this is run as administrator
$user = [Security.Principal.WindowsIdentity]::GetCurrent();
$isAdmin = (New-Object Security.Principal.WindowsPrincipal $user).IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator)
if ($isAdmin -eq $false)
{
Write-Host "Please run this script as an administrator" -ForegroundColor Yellow
exit
}
$version = "2.15"
@yetanotherchris
yetanotherchris / win-features.ps1
Created February 6, 2017 10:26
installing windows features
# https://peter.hahndorf.eu/blog/WindowsFeatureViaCmd.html
Get-WindowsOptionalFeature -Online | Select FeatureName | Sort FeatureName
Enable-WindowsOptionalFeature -FeatureName IIS-WebServer -Online -All
@yetanotherchris
yetanotherchris / large-dummy-text-file.ps1
Created February 27, 2017 18:40
How to create large dummy file in Windows
for ($i = 0;$i -lt 1024;$i++) { echo $("-" * 1024) >> c:\test.txt }