Skip to content

Instantly share code, notes, and snippets.

# useful debugging on console
>>> import os
>>> os.environ['TDSDUMP'] = 'stdout'
>>>
>>> import pymssql
>>> conn = pymssql.connect(server="sqlserverhost")
# py3-extended unpacking
a, *b, c = [1, 2, 3, 4, 5]
# remove specific emails from the postqueue
mailq | tail -n +2 | grep -v '^ *(' | awk 'BEGIN { RS = "" }
# $7=sender, $8=recipient1, $9=recipient2
{ if ($8 == "[email protected]" && $9 == "")
print $1 }
' | tr -d '*!' | postsuper -d -
# ssh-keygen options
ssh-keygen -t ed25519 -f ssh_host_ed25519_key -N "" < /dev/null
ssh-keygen -t rsa -b 4096 -f ssh_host_rsa_key -N "" < /dev/null
SHOW ENGINE INNODB STATUS \G
Look for the Section -
TRANSACTIONS
We can use INFORMATION_SCHEMA Tables.
Useful Queries -
To check about all the locks transactions are waiting for -
@oxidizeddreams
oxidizeddreams / cloudwatch_log_subscriber.py
Created August 30, 2018 10:59 — forked from bwhaley/cloudwatch_log_subscriber.py
AWS lambda function to subscribe new CloudWatch Log groups to another lambda function
# Lambda function to subscribe all new cloudwatch log groups to a log shipper function
# Used in conjunction with https://github.com/SumoLogic/sumologic-aws-lambda
import os
import logging
import json
import uuid
import boto3
from botocore.exceptions import ClientError
@oxidizeddreams
oxidizeddreams / google
Created August 31, 2018 14:03
google search engine d0rk
# find people's LinkedIn profiles via google
“site:linkedin.com/in {person name}”
@oxidizeddreams
oxidizeddreams / aws.sg.unused
Created September 4, 2018 16:04 — forked from thibautsacreste/aws.sg.unused
Bash: list unused AWS security groups
#!/usr/bin/env bash
# lists all unused AWS security groups.
# a group is considered unused if it's not attached to any network interface.
# requires aws-cli and jq.
# all groups
aws ec2 describe-security-groups \
| jq --raw-output '.SecurityGroups[] | [.GroupName, .GroupId] | @tsv' \
| sort > /tmp/sg.all
@oxidizeddreams
oxidizeddreams / ansible.network
Created September 6, 2018 10:27
ansible_advanced_things
# network
# ipaddr: possible use case to verify lists of ip addresses from a database SELECT
# Example list of values
test_list = ['192.24.2.1', 'host.fqdn', '::1', '192.168.32.0/24', 'fe80::100/10', True, '', '42540766412265424405338506004571095040/64']
# {{ test_list | ipaddr }}
['192.24.2.1', '::1', '192.168.32.0/24', 'fe80::100/10', '2001:db8:32c:faad::/64']
@oxidizeddreams
oxidizeddreams / curl
Created September 7, 2018 01:16
calf curling
# curling files in a directory to an ftp[s] server
'''
#!/bin/bash
USER="satan/[email protected]"
PASS="s3cr3tp455w0rd!?"
FTPS="ftps://satan.sharefileftp.com"
END="/upload/damien"
for file in $(find spawn -iname '*.gpg' -type f -print | awk -F'/' '{print $2}'); do
@oxidizeddreams
oxidizeddreams / redshift_metadata.md
Created September 14, 2018 16:23 — forked from githoov/redshift_metadata.md
Redshift Metadata

Redshift Tables Used

pg_table_def, stl_query, stl_querytext, stl_tr_conflict, stl_explain, stl_alert_event_log, stl_ddltext, stl_scan, stl_save, stl_hashjoin, stl_hash, stl_plan_info, stl_return, and information_schema.table_constraints.

Queries to Extract Features

  • execution time
select (endtime - starttime) as execution_time_in_ms 
from stl_query 
where query = QUERY_ID;
@oxidizeddreams
oxidizeddreams / aws-change-volumes-type
Last active September 14, 2018 19:03
change volume_type for all EBS volumes in AWS
#!/bin/bash
while getopts "f:t:h:" option; do
case "${option}" in
f ) FILTERS=$OPTARG;;
t ) TYPE=$OPTARG;;
h )
echo "Usage:"
echo " ./aws-change-volumes-type -h Display this help message."
echo " ./aws-change-volumes-type -f 'Name=size,Values=5120' -t 'st1' "
exit 0