Skip to content

Instantly share code, notes, and snippets.

View brettfreer's full-sized avatar

Brett Freer brettfreer

View GitHub Profile
@brettfreer
brettfreer / australian_date.bat
Created May 23, 2018 07:58
Set the Australian Date format in windows using the command line
rem Australian Date format
reg add "HKCU\Control Panel\International" /v sShortDate /t REG_SZ /d "dd/MM/yyyy" /f
reg add "HKCU\Control Panel\International" /v sCountry /t REG_SZ /d "Australia" /f
@brettfreer
brettfreer / set_proxy.bat
Created May 7, 2018 08:18
Set windows proxy server settings from the command line
rem Proxy settings
rem Substitute your own proxy server and exclusion list
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 1 /f
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyServer /t REG_SZ /d my-proxy-server.my-domain.com:3128 /f
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyOverride /t REG_SZ /d "192.168.1.*;10.5.1.*;<local>" /f
netsh winhttp set proxy my-proxy-server.my-domain.com:3128
@brettfreer
brettfreer / delete_printers.ps1
Created May 5, 2018 02:18
Removing all printers on a PC linked to a common server using PowerShell
$PrintServer = "\\old_print_server"
$Printers = Get-WmiObject -Class Win32_Printer
ForEach ($Printer in $Printers) {
If ($Printer.SystemName -like "$PrintServer") {
(New-Object -ComObject WScript.Network).RemovePrinterConnection($($Printer.Name))
}
}
@brettfreer
brettfreer / fibonacci.py
Created August 27, 2016 10:33
Return fibonacciNumber n
def fibonacci(n):
if n < 2:
return n
return fibonacci(n-2) + fibonacci(n-1)
@brettfreer
brettfreer / isPalendrome.py
Last active August 9, 2016 08:13
Test whether string is a palendrome
def isPalendrome(s):
return s == s[::-1]
@brettfreer
brettfreer / dynamodb_purge_table.py
Created July 6, 2016 10:36
Purge all items from an AWS dynamodb table with an exponential timing back-off
#!/usr/bin/env python3
""" Purge all items from an AWS dynamodb table with an exponential timing back-off
"""
import logging
from time import sleep
import boto3
from botocore.exceptions import ClientError
@brettfreer
brettfreer / dynamodb_copy_table.py
Created July 6, 2016 10:32
Copy an AWS dynamodb table to an existing table with an exponential timing back-off
#!/usr/bin/env python3
""" Copy an AWS dynamodb table to an existing table with an exponential timing back-off
Assume receiving table has a compatible schema
"""
import logging
from time import sleep
import boto3
@brettfreer
brettfreer / dynamodb_rename_attribute.py
Last active November 10, 2023 00:43
Rename an AWS dynamodb table attribute with an exponential timing backoff
#!/usr/bin/env python3
""" Rename an AWS dynamodb table attribute with an exponential timing back-off
"""
import logging
from time import sleep
import boto3
from boto3.dynamodb.conditions import Attr
@brettfreer
brettfreer / sum_of_digits.py
Created June 27, 2016 08:29
Return the sum of digits in an integer
def sum_of_digits(n):
s = 0
while n > 0:
s += n % 10
n /= 10
return s
@brettfreer
brettfreer / isDate.py
Last active July 6, 2016 10:38
Validate if a text string is a valid date with a supplied format string
import datetime
def isDate(date_text, fmt):
try:
datetime.datetime.strptime(date_text, fmt)
except ValueError:
return False
return True