Skip to content

Instantly share code, notes, and snippets.

@tomfanning
tomfanning / extract-pfx.sh
Created April 8, 2015 12:11
Shell script to extract certificate and key files suitable for nginx from a PFX file.
#!/bin/bash
set -e
if [ "$#" -ne 1 ]; then
echo "Usage: $0 filename.pfx" >&2
exit 1;
fi
if [ ! -e "$1" ]; then
echo "File not found: $1" >&2
@tomfanning
tomfanning / FixEnterpriseWsdl.cs
Created June 19, 2015 14:28
Program to patch Enterprise.wsdl which Salesforce thinks is okay but causes Microsoft's wsdl.exe to emit non-working code
namespace FixEnterpriseWsdl
{
using System;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Xml;
/// <summary>
/// Implements a fix for https://developer.salesforce.com/forums?id=906F0000000AiPEIA0
@tomfanning
tomfanning / gist:306a639a8bffbd0cfdf3
Created September 25, 2015 10:58
One liner for dumping HTTP request / response headers
tcpdump -A -s 10240 'tcp port 80 and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)' | egrep --line-buffered "^........(GET |HTTP\/|POST |HEAD )|^[A-Za-z0-9-]+: " | sed -r 's/^........(GET |HTTP\/|POST |HEAD )/\n\1/g'
@tomfanning
tomfanning / ubuntu-enable-totally-automatic-updates.txt
Last active November 9, 2017 10:37
Steps in Ubuntu to enable totally automatic updates with auto reboot
apt-get autoremove && apt-get update
apt-get install unattended-upgrades update-notifier-common
dpkg-reconfigure --priority=low unattended-upgrades
# choose yes
nano /etc/apt/apt.conf.d/50unattended-upgrades
# set Unattended-Upgrade::Remove-Unused-Dependencies "true";
# set Unattended-Upgrade::Automatic-Reboot "true";
# force install, using old config file if original is modified
@tomfanning
tomfanning / clear-credential-manager.cmd
Last active September 2, 2024 07:26
Batch file to clear all credentials from Windows Credential Manager
@echo off
cmdkey.exe /list > "%TEMP%\List.txt"
findstr.exe Target "%TEMP%\List.txt" > "%TEMP%\tokensonly.txt"
FOR /F "tokens=1,2 delims= " %%G IN (%TEMP%\tokensonly.txt) DO cmdkey.exe /delete:%%H
del "%TEMP%\List.txt" /s /f /q
del "%TEMP%\tokensonly.txt" /s /f /q
echo All done
pause
@tomfanning
tomfanning / gist:fef6fe807e5eeaf62e9c
Created December 13, 2015 20:09
Passwordless sudo
visudo
username ALL=(ALL) NOPASSWD: ALL
#!/bin/sh
### BEGIN INIT INFO
# Provides:
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start daemon at boot time
# Description: Enable service provided by daemon.
### END INIT INFO
@tomfanning
tomfanning / create-vm.ps1
Created January 11, 2016 14:56
Create a blank Hyper-V VM in the correct location
$ErrorActionPreference="Stop"
$vmname = read-host 'What name should the new VM have?'
$destdrive = read-host 'What drive should the new VM live on?'
$sourcevhdx = read-host 'What is the full path to the source VHDX? (enter for blank)'
$lan = read-host 'What virtual switch (name) should the VM be connected to? (enter for default)'
$destpath = $destdrive + ':\HyperV'
$vmrootpath = join-path $destpath $vmname
@tomfanning
tomfanning / rename-windows-administrator.ps1
Last active January 22, 2016 17:43
Rename Windows administrator
$admin=[adsi]"WinNT://./oldname,user"
$admin.psbase.rename("newname")
#$admin.SetPassword("")
$admin.CommitChanges()
$admin=[adsi]"WinNT://./vagrant,user"
$admin.psbase.rename("Administrator")
#$admin.SetPassword("")
$admin.CommitChanges()
@tomfanning
tomfanning / VmTools.psm1
Last active January 12, 2016 00:20
PowerShell module for VM management
$ErrorActionPreference = "Stop"
# run like this:
# import-module vmtools.psm1
# move-vm -VmName "test-vm" -DestRoot "c:\HyperV"
function Move-VM {
[CmdletBinding()]
param (
[parameter(Mandatory=$true)] [string]$VmName,