Skip to content

Instantly share code, notes, and snippets.

@blackpioter
blackpioter / DNS_A_to_revPTR_records.sh
Last active May 1, 2025 10:40
DNS Make rev-PTR from A records
cat ZONEFILE| grep -v "@\|TTL\|Serial\|after\|;" | awk -F" " '{ if ($3 == "A") print $0 }' | awk '{print $4" IN PTR "$1".DOMAIN."}'
@blackpioter
blackpioter / git_cs.sh
Last active May 1, 2025 10:34
git cheatsheet
## git reset hard to upstream
git reset --hard @{u}
## git remove directory from history
for branch in `git branch -a | grep remotes | grep -v HEAD | grep -v master`; do\n git branch --track ${branch##*/} $branch\ndone
git filter-branch -f --index-filter 'git rm --cached -r --ignore-unmatch DIRECTORY' \
--prune-empty --tag-name-filter cat -- --all
git filter-branch --index-filter \
@blackpioter
blackpioter / nginx_CS
Created June 21, 2016 08:37
nginx CS
## nginx nx: error logs for time span after 15:00
cat all | grep NAXSI_FMT | awk -F'[: ]' '$2 >= 15 { print }' > naxsi_after_15
## nginx: log_format
log_format: |
timed_combined '$remote_addr $remote_user [$time_local] '
'"$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent" $request_time $upstream_response_time'
## mysql: show mysql host,user,passwd
SELECT Host,user,password FROM mysql.user WHERE User = "root" ORDER BY (Host="localhost") ASC ;
## mysql: set empty root password
update user set password=PASSWORD("") where User='root';
flush privileges;

Keybase proof

I hereby claim:

  • I am blackpioter on github.
  • I am blackpioter (https://keybase.io/blackpioter) on keybase.
  • I have a public key whose fingerprint is 550A 5D5B 0FF9 F873 8AE6 2257 312A D4E7 15E5 7DDC

To claim this, I am signing this object:

@blackpioter
blackpioter / jenkins-backup.sh
Created November 28, 2016 15:48
jenkins-backup.sh
#!/bin/bash -xe
##################################################################################
function usage(){
echo "usage: $(basename $0) /path/to/jenkins_home jenkins.tar.gz"
}
function error_exit
{
@blackpioter
blackpioter / boto3_list_instances_env_role.py
Last active May 1, 2025 10:49
boto3_list_instances_env_role
#!/usr/bin/env python
import boto3
def list_instances_env_role(env, role):
"""
List of instances with tag:Environment and tag:Role
"""
@blackpioter
blackpioter / uid_awk.sh
Created February 8, 2021 10:46 — forked from staaldraad/uid_awk.sh
Get the uid, gid and user groups without touching /etc/passwd or running the `id` command
awk -F: 'END {print "uid:"u" gid:"g" groups:"gg}{if($1=="Uid"){split($2,a," ");u=a[1]}if($1=="Gid"){split($2,a," ");g=a[1]}if($1=="Groups"){gg=$2}}' /proc/self/status