Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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,
$ErrorActionPreference = "Stop"
# run the script in an elevated Powershell like this:
# iex ((new-object net.webclient).DownloadString('https://gist.githubusercontent.com/tomfanning/f75f6a808a9265b48af0/raw/'))
#todo: - install windows photo viewer, make it the default
# - unpin the remaining crud from the start menu
function Set-RegValue
{
@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 / gist:7dae3494e01ed9732b25
Last active February 15, 2016 13:56
Hyper-V additions for Ubuntu
#apt-get install --install-recommends linux-tools-virtual-lts-vivid linux-cloud-tools-virtual-lts-vivid
apt-get install hv-kvp-daemon-init
linux-virtual?
linux-cloud-tools-virtual
linux-tools-virtual
@tomfanning
tomfanning / jmeter.bat
Created May 17, 2016 13:07
jmeter.bat with greatly raised memory limits
@echo off
rem Licensed to the Apache Software Foundation (ASF) under one or more
rem contributor license agreements. See the NOTICE file distributed with
rem this work for additional information regarding copyright ownership.
rem The ASF licenses this file to You under the Apache License, Version 2.0
rem (the "License"); you may not use this file except in compliance with
rem the License. You may obtain a copy of the License at
rem
rem http://www.apache.org/licenses/LICENSE-2.0
@tomfanning
tomfanning / gist:382cbf0bbfe5b9124cc12ebeab1c4cd1
Created May 17, 2016 13:08
Batch file to run command line jmeter tests
del results.jtl
pushd C:\Users\Administrator\Desktop\apache-jmeter-2.13\bin
call jmeter.bat -n -t ..\..\jmeter-results\test-plan.jmx
popd
pause