Skip to content

Instantly share code, notes, and snippets.

@tomfanning
tomfanning / install-dnc-hosting-bundle.ps1
Created November 18, 2018 13:14
Install .net core hosting bundle 2.1.5 on IIS
$ProgressPreference='SilentlyContinue'
wget https://download.visualstudio.microsoft.com/download/pr/86df96bb-384c-4d7a-82ce-2e4c2c871189/045870c1ab4004219cb312039c5a64d5/dotnet-hosting-2.1.5-win.exe -outfile .\dnc-hosting.exe
start-process -wait .\dnc-hosting.exe -args "/install /quiet /norestart" -nonewwindow
iisreset
@tomfanning
tomfanning / gist:43d8f3bd8de43b4b4d14a9539aa4426d
Created October 26, 2018 09:55
AWS Elastic Beanstalk / .NET Core web app quick demo
VS -> new solution -> .NET Core 2.1 web app (MVC)
untick HTTPS
restore packages
Run locally
Close
Right click
Publish
Choose folder-> publish
Publish immediately
Open publish folder
@tomfanning
tomfanning / install-service.sh
Created March 27, 2018 16:49
Installing a console app as a service in systemctl
echo "[Unit]
Description=My Service Name
[Service]
WorkingDirectory=$workingdir
ExecStart=$workingdir/binary-name
Restart=always
RestartSec=10 # Restart service after 10 seconds if it crashes
SyslogIdentifier=myservicename
User=root
Environment=\"ASPNETCORE_ENVIRONMENT=Production\"
# set up a swapfile
dd if=/dev/zero of=/swap.file bs=1024 count=1048576
mkswap /swap.file
chmod 0600 /swap.file
swapon /swap.file
echo "
/swap.file none swap sw 0 0" >> /etc/fstab
echo "
vm.swappiness=10" >> /etc/sysctl.conf
#!/bin/bash
# called by influx-mon.sh which is called by cron every minute
curloutput=$(curl -A "influx-mon" -ss -L --connect-timeout 5 -w "\n%{http_code}" $1)
exitcode=$?
body=$(echo "$curloutput" | head -n -1)
httpcode=$(echo "$curloutput" | tail -n 1)
if [ $exitcode -ne 0 ]; then
#!/bin/bash -e
# called by cron every minute
function postToInflux(){
curl -ss -o /dev/null --connect-timeout 5 -X POST 'https://influxdb.trlsoftware.com/write?db=database&u=user&p=pass' --data-binary "web_up,site=$1 value=$2 $(date +%s%N)"
}
declare -A sites
declare -A check
@tomfanning
tomfanning / userdata.ps1
Created March 13, 2018 14:19
AWS EC2 userdata script to set Windows admin password
<powershell>
$windows_admin_password="mypassword"
function log {
echo $args[0] | out-file -append c:\bootstrap-status.log
}
log "Setting Windows password"
$admin = [adsi]("WinNT://./administrator, user")
@tomfanning
tomfanning / devreset.ps1
Created February 2, 2018 15:26
Hyper-V stop-restore-start one-liner
$vmname="server2016eval"; $snapname='server2016eval - (02/02/2018 - 15:12:33)'; stop-vm $vmname; if ((get-vm $vmname).State -eq 'Running') {stop-vm -turnoff $vmname}; restore-vmsnapshot -name $snapname -confirm:$false -vmname $vmname; start-vm $vmname
@tomfanning
tomfanning / update-vs2017-layout.cmd
Created January 10, 2018 15:17
Replace VS2017 layout in-place
@echo off
rem A vs2017 folder must exist within this UNC
pushd %targetunc%
md %UserProfile%\Desktop\vs2017
copy vs2017\vs_professional.exe %UserProfile%\Desktop\vs2017
start /wait %UserProfile%\Desktop\vs2017\vs_professional.exe --layout %UserProfile%\Desktop\vs2017 --quiet
del /q /s vs2017
rd /q /s vs2017
robocopy /move /e %UserProfile%\Desktop\vs2017 vs2017 *
popd
@tomfanning
tomfanning / vm-superhub3.txt
Created January 5, 2018 22:25
Virgin Media Super Hub 3 router status research
Status page
curl 'http://192.168.100.1/snmpGet?oids=1.3.6.1.4.1.4115.1.3.4.1.5.9.0;1.3.6.1.4.1.4115.1.3.3.1.1.1.3.1.0;1.3.6.1.4.1.4491.2.1.14.1.5.4.0;1.3.6.1.4.1.4115.1.20.1.1.1.7.1.3.1;1.3.6.1.2.1.10.127.1.1.5.0;1.3.6.1.2.1.126.1.1.1.1.1.2;1.3.6.1.2.1.69.1.4.5.0;&_n=21943&_=1515184469506'
Item Status Comments
Acquired Downstream Channel(Hz) 547000000 Locked
Ranged Upstream Channel(Hz) 39400000 Locked
Provisioning State Online