Skip to content

Instantly share code, notes, and snippets.

View bradbrowne's full-sized avatar

Brad Browne bradbrowne

  • Melbourne, Australia
View GitHub Profile
@bradbrowne
bradbrowne / add-mssql-server-port-1433-to-macos-firewall.md
Created June 29, 2022 07:38
Add Microsoft SQL Server port 1433 to macOS Firewall rules

Open the /etc/pf.conf file in your favourite text editor in the Terminal:

sudo vim /etc/pf.conf

Add the following to the bottom of the /etc/pf.conf file:

pass in proto tcp from any to any port 1433
@bradbrowne
bradbrowne / download-rust-behind-proxy.ps1
Created October 7, 2019 05:29
Download Rust from behind proxy using PowerShell by setting Environment Variable
$proxy='http://bradb:password@wmn4:8080'
$ENV:HTTP_PROXY=$proxy
$ENV:HTTPS_PROXY=$proxy
cd ~\Downloads
.\rustup-init.exe
@bradbrowne
bradbrowne / clam-top-5-memory-usage-in-gb.ps1
Created September 12, 2018 01:34
PowerShell top 5 memory usage in GB
Get-Process -computername COMPUTERNAME | Sort-Object -Descending WS | select -first 5 | select name, description, @{l="Private Memory (GB)"; e={$_.privatememorysize / 1gb}}
@bradbrowne
bradbrowne / flux-convert-mga-zone-55-to-wgs-84.ps1
Last active July 26, 2018 06:00
flux-convert-mga-zone-55-to-wgs-84.ps1
ogr2ogr -f "MSSQL" -overwrite "MSSQL:server=.;database=Flux;trusted_connection=yes;" "MSSQL:server=.;database=Flux;trusted_connection=yes;tables=vmadmin.parish_polygon" -s_srs EPSG:28355 -t_srs EPSG:4326 -nlt POLYGON -nln mapdojo.parish_polygon -lco "FID=pfi" -sql "SELECT [ogr_geometry],CAST([pfi] AS INTEGER) AS pfi,[parishc],[parish],[pfi_cr],[ufi],[ufi_cr],[ufi_old] FROM [vmadmin].[parish_polygon]"
@bradbrowne
bradbrowne / gist:592fb79b0f48bcbceae186382f5c3089
Created July 26, 2018 05:53
flux-convert-mga-zone-55-to-wgs-84.cmd
ogr2ogr -limit 1 -f "MSSQL" -overwrite "MSSQL:server=.;database=Flux;trusted_connection=yes;" "MSSQL:server=.;database=Flux;trusted_connection=yes;tables=vmadmin.parish_polygon" -s_srs EPSG:28355 -t_srs EPSG:4326 -nln mapdojo.parish_polygon -lco "FID=pfi" -sql "SELECT [ogr_geometry],CAST([pfi] AS INTEGER) AS pfi,[parishc],[parish],[pfi_cr],[ufi],[ufi_cr],[ufi_old] FROM [vmadmin].[parish_polygon]"
@bradbrowne
bradbrowne / oracle-seconds-to-refresh-materialized-view.sql
Created July 13, 2018 01:24
Number of seconds to refresh Oracle Materialized View
SELECT
mview_name,
last_refresh_date "START_TIME",
CASE
WHEN fullrefreshtim <> 0 THEN
LAST_REFRESH_DATE + fullrefreshtim/60/60/24
WHEN increfreshtim <> 0 THEN
LAST_REFRESH_DATE + increfreshtim/60/60/24
ELSE
LAST_REFRESH_DATE
@bradbrowne
bradbrowne / flux-convert-epoch-milliseconds-to-local-standard-time-sql-server.sql
Last active July 5, 2018 05:54
Convert Epoch milliseconds as used by Javascript Date object and Unix timestamps to Local Standard Time via T-SQL for SQL Server
declare @epochMilliseconds bigint
set @epochMilliseconds = 1530769196903
declare @utcDateTime datetime
select @utcDateTime = DATEADD(MS, @epochMilliseconds%(3600*24*1000), DATEADD(DAY, @epochMilliseconds/(3600*24*1000), '1970-01-01 00:00:00.000'))
--The result is 2018-07-05 05:39:56.903
select CONVERT(datetime, SWITCHOFFSET(@utcDateTime, DATEPART(TZOFFSET, @utcDateTime AT TIME ZONE 'AUS Eastern Standard Time'))) AS [AUS Eastern Standard Time]
--The result is 2018-07-05 15:39:56.903
@bradbrowne
bradbrowne / get-url-associations-default-browser.ps1
Last active June 25, 2018 23:46
Get URL associations for the default browser selected by a user
Get-ItemProperty Registry::HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\Shell\Associations\URLAssociations\http\UserChoice
@bradbrowne
bradbrowne / clam-powershell-robocopy-loop-through-text-file-providing-path-names.ps1
Last active May 31, 2018 23:51
Loop through a text file containing file paths and use Robocopy to copy from source to destination using restartable and other options.
gc example.txt | % { robocopy $([System.IO.Path]::GetDirectoryName($_)) .\dst $([System.IO.Path]::GetFileName($_)) /z /w:20 /r:20 /j}
@bradbrowne
bradbrowne / clam-powershell-iis-website-admin.ps1
Created May 30, 2018 02:03
Windows PowerShell IIS Administration using Powershell
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Web.Administration")
$iis = New-Object Microsoft.Web.Administration.ServerManager
$iis.Sites