Skip to content

Instantly share code, notes, and snippets.

View PartTimeLegend's full-sized avatar

Antony Bailey PartTimeLegend

View GitHub Profile
Get-EC2Instance | Where-Object {$_.RunningInstance.StateReason.Code} | Start-EC2Instance
Get-EC2Instance | Where-Object {!$_.RunningInstance.StateReason.Code} | Remove-EC2Instance
@PartTimeLegend
PartTimeLegend / S3Sync.ps1
Last active March 23, 2021 11:41
Sync a dir to s3
param(
[Parameter(Mandatory=$True)]
[string]$localDirectory,
[Parameter(Mandatory=$True)]
[string]$s3Bucket,
[Parameter(Mandatory=$True)]
[string]$logFile
)
Write-Output "Syncing to S3 Bucket" $(Get-Date -Format o) > $logFile
aws s3 sync $localDirectory s3://$s3bucket > $logFile

Keybase proof

I hereby claim:

  • I am parttimelegend on github.
  • I am parttimelegend (https://keybase.io/parttimelegend) on keybase.
  • I have a public key ASBOysuH2LzHfN-GrFx_dY-yv1gTz-wL1jcnQ4ROD8AIdwo

To claim this, I am signing this object:

@PartTimeLegend
PartTimeLegend / securedelete.rb
Created April 8, 2019 13:43
Secure Delete in Ruby
files = {}
files.each do |filename|
originalFilesize = File.size(filename)
puts "Original Filesize #{originalFilesize}"
newFilesize = Random.rand(1,9999999999)
Random.rand(0xff).each do |byte|
File.open(filename, 'wb') do |fo|
newFilesize.times { fo.print(byte.chr) }
end
end
import boto3
ec2 = boto3.client('ec2')
volume_id= "i-1234567890"
list_of_snapshots = []
snapshots = ec2.describe_snapshots(Filters=[{'Name':'tag:volume_id', 'Values': [volume_id]}])['Snapshots']
for snapshot in snapshots:
if snapshot:
list_of_snapshots.append(snapshot['SnapshotId'])
print(list_of_snapshots)
echo "127.0.0.1 xn-9q8h" >> etc/hosts
#Copyright 2020 Antony Bailey <hi@antonybailey.net>
#
#Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
#
#The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
#
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH T
#Copyright 2020 Antony Bailey <hi@antonybailey.net>
#
#Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
#
#The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
#
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH T
@PartTimeLegend
PartTimeLegend / serveravailable.ps1
Created May 21, 2020 09:29
Check if a server is available
$s = "google.com"
$port = 443
if(!(Test-Connection -TargetName $s -TCPPort $port -quiet))
{
Write-Host “Problem connecting to $s”
Write-Host “Flushing DNS”
Invoke-Expression "ipconfig /flushdns"