Skip to content

Instantly share code, notes, and snippets.

@MrChrisWeinert
MrChrisWeinert / 0_reuse_code.js
Created April 5, 2017 11:54
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@MrChrisWeinert
MrChrisWeinert / mitm.sh
Created April 28, 2019 16:06
I use this to fire up an access point and log all trafic flowing through it.
#!/bin/bash
# Catch ctrl c so we can exit cleanly
function control_c() {
echo Killing processes..
killall dnsmasq
killall hostapd
/etc/init.d/networking restart
}
trap control_c SIGINT
@MrChrisWeinert
MrChrisWeinert / tcpdump_docker.sh
Created May 21, 2019 13:39
Tcpdump for a given Docker container
#!/bin/bash
IP=`docker inspect MyContainerName | grep 'IPAddress":' | cut -f4 -d'"' | head -1` && sudo tcpdump -i docker0 host $IP
@MrChrisWeinert
MrChrisWeinert / DotNetCheck.ps1
Created May 21, 2019 13:40
Check for .NET 4.7.2
Get-ChildItem 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full\' | Get-ItemPropertyValue -Name Release | Foreach-Object { $_ -ge 461808 }
@MrChrisWeinert
MrChrisWeinert / diskspace.sh
Created May 31, 2019 20:42
Disk space usage by directory
#!/bin/bash
sudo du -ah --max-depth=1 / | sort -hr
@MrChrisWeinert
MrChrisWeinert / init.sh
Last active October 5, 2020 13:18
The start of some stuff I usually do for a new linux install
apt-get -y update
#Terminator console emulator
apt-get -y install terminator
apt-get -y install bat
#Setup custom aliases
echo "alias ll='ls -l'" > .bash_aliases
echo "alias nmap='nmap -g53 --randomize-hosts --script-args http.useragent=\"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36 Edge/12.0i\" '" >> .bash_aliases
echo "alias cat='bat --style=grid'" >> .bash_aliases
@MrChrisWeinert
MrChrisWeinert / linux_docker_networking_stuff
Last active July 5, 2022 19:50
Just a collection of stuff I use to troubleshoot Docker and networking issues
#Stop/Remove a specific Docker Container
docker stop containername && docker rm containername
#Stop all containers with "backend" in it:
docker rm $(docker ps -a | grep backend | cut -f1 -d' ')
#Stop all Docker Containers
docker stop $(docker ps -aq)
#Remove all Docker Containers
Enable-PSRemoting
Get-Item WSMan:\localhost\Client\TrustedHosts
Set-Item WSMan:\localhost\Client\TrustedHosts -Value 'RemoteServerName'
#This weird thing is only needed if you still can't run WSMan commands even after enabling all the trust settings (https://web.archive.org/web/20110615172805/http://www.shirmanov.com/2011/04/winrm-access-is-denied-on-local.html)
#("Enable-PSRemoting" should do it for you, this just manually does it)
reg add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v LocalAccountTokenFilterPolicy /t REG_DWORD /d 1 /f
#Load up a server list
[string[]]$ServerList = Get-Content C:\ALL-WEB-NORTHCENTRAL.lst
@MrChrisWeinert
MrChrisWeinert / mysql.txt
Created June 15, 2020 20:13
Generic mysql permission stuff (mostly for Wordpress)
connect:
sudo mysql --user=root
Show users and where they can connect from:
SELECT user,host FROM mysql.user;
Show user-specific privileges:
SHOW GRANTS FOR 'user'@'192.168.x.xx';
Update user privileges:
@MrChrisWeinert
MrChrisWeinert / MigrateBitbucketToAzureDevOps
Created July 29, 2020 16:22
Use this code to clone an existing Bitbucket repo into a temporary folder and push it to Azure DevOps
mkdir Codeios
cd Codeios/
git clone --bare http://chrisweinert@bitbucket.servername.com:1234/scm/somename/ios.git
cd ios.git/
git lfs fetch --all
git push --mirror https://companyname@dev.azure.com/companyname/Mobile/_git/ios