This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// No number specifier | |
Console.WriteLine("a) {0}", numSingle); | |
// Round up, ignore any decimal points. | |
Console.WriteLine("a) {0:##}", numSingle); | |
// Round up to 1 dp. | |
Console.WriteLine("b) {0:.#}", numSingle); | |
// Round up to 2 dp. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string ivAsBase64; | |
string encryptedTextAsBase64; | |
string keyAsBase64; | |
using (AesCryptoServiceProvider aes = new AesCryptoServiceProvider()) | |
{ | |
// Store the IV (they can be stored if you don't re-use a key) | |
aes.GenerateIV(); | |
byte[] iv = aes.IV; | |
ivAsBase64 = Convert.ToBase64String(iv); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Runtime.InteropServices; | |
using Microsoft.Win32.SafeHandles; | |
using System.Threading; | |
using System.ComponentModel; | |
namespace ConsoleApplication1 | |
{ | |
class Program | |
{ | |
[DllImport("kernel32.dll")] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo yum update -y | |
echo "======= INSTALLING RPM FOR MONO =======" | |
sudo mkdir -p /tmp/mono_dependencies | |
cd /tmp/mono_dependencies | |
sudo wget https://dl.fedoraproject.org/pub/fedora/linux/development/rawhide/Everything/x86_64/os/Packages/l/libpng15-1.5.30-11.fc33.x86_64.rpm | |
sudo yum install -y libpng15-1.5.30-11.fc33.x86_64.rpm | |
echo "======= INSTALLING MONO ============" | |
sudo yum install -y yum-utils |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#========================================================================================== | |
# 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
while ($true) { $r = wget -uri "http://somesite.com?q=1" -headers @{"Accept-Tenant"="Nz"}; echo $r.Content } |
NewerOlder