Skip to content

Instantly share code, notes, and snippets.

redis-cli --raw keys "$PATTERN" | xargs redis-cli del
@willm
willm / gist:64dba1ffe7d60db4f5637d306b8e2b82
Created July 15, 2020 07:29
Take a back up of a mysql db
mysqldump --user=drupal --password=''--host='' --opt 'DB_NAME' > database.sql
@willm
willm / ip addresses.sh
Created May 8, 2020 04:32
parse just the ip addresses from ifconfig
ifconfig | grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b"
@willm
willm / clean.sh
Created January 28, 2019 21:36
Reclaim docker disk space mac os
docker rm $(docker ps -a -q)
docker rmi $(docker images -q)
docker volume rm $(docker volume ls |awk '{print $2}')
rm -rf ~/Library/Containers/com.docker.docker/Data/*
@willm
willm / postgres_cheat.md
Created January 23, 2018 10:28
Postgres cheat sheet

Kill all sessions for a db

select pg_terminate_backend(pid)
from pg_stat_activity
where datname = 'doomed_database'
@willm
willm / format.vim
Created January 3, 2018 10:37
vim format current buffer in json
:%!python -m json.tool
@willm
willm / time.sh
Created September 5, 2017 13:15
time request curl
curl -s -w "%{time_total}\n" -o /dev/null http://www.google.com/
@willm
willm / app-engine.md
Last active July 10, 2017 08:08
App engine

Querying google datasstore

const datastore = require('@google-cloud/datastore')({
      projectId: 'captureappprod',
      keyFilename: '/path/to/key.json' // key optained from App engine / IAM admin / service accounts
});
function deviceCount(start, count=0) {
    const batchSize = 300;
    const query = datastore.createQuery('Device') // Device is the 'kind'
@willm
willm / list-groups.ps1
Created February 10, 2017 13:39
list AD groups for user
(New-Object System.DirectoryServices.DirectorySearcher("(&(objectCategory=User)(samAccountName=$($env:username)))")).FindOne().GetDirectoryEntry().memberOf
@willm
willm / fix-clipboard.sh
Created February 7, 2017 16:22
fix virtualbox clipboard
# from linux guest OS
killall VBoxClient
VBoxClient-all