Skip to content

Instantly share code, notes, and snippets.

@sherwind
sherwind / dns-records-fetcher.sh
Created November 9, 2023 08:42
Fetch DNS records of a domain name
#!/bin/bash
# This script performs DNS queries to collect records for a given domain.
# It queries for ANY and AXFR records, as well as 'A' records for common subdomains.
# If nameservers are provided as arguments, it uses those. Otherwise, it finds
# and uses the authoritative nameservers for the domain.
# by sherwin@daganato.com, 2003-03-15
# Check if at least the domain is provided
if [ "$#" -lt 1 ]; then
@sherwind
sherwind / prompt-AI-code-builder
Created June 3, 2023 07:40
Use AI to build an application from scratch using its creativity, logic and skills. The AI has to generate and evaluate different approaches, reflect on its choices, and write the code for the best approach. Adopted from https://twitter.com/mattshumer_/status/1663939227552215054?t=0-jzGHOVlcCQQ3NMcw
Adopt the role of Software Engineering Mastermind 🧠, a master of all aspects of software engineering, from design and development to security and testing to documentation and delivery.
I want you to build [Application to build].
To do so, you will:
1. First, reason about how you will approach this. Generate at least three possible approaches, and explain the pros and cons of each.
2. Then, ask yourself some questions to reflect on your approaches. For example: How feasible is each approach? How efficient is each approach? How creative is each approach? How can each approach be improved?
3. Next, evaluate your approaches based on your reflection. Assign a score to each approach from 1 to 10, where 10 is the best. Explain why you gave each score.
4. Finally, choose the best approach based on your evaluation. Write the code, file by file, in full.
@sherwind
sherwind / alienvault-get_alarm.sh
Created May 27, 2021 07:39
Pulls an alarm and its events from AT&T's Alienvault USM Anywhere
#!/bin/bash
# Pulls an alarm and its events from AT&T's Alienvault USM Anywhere
# by Sherwin Daganato, 20210523
#
# USAGE:
# ./alienvault-get_alarm.sh https://<usm-host>.alienvault.cloud/#/alarm/5c931059-11cc-489d-b378-83f2d452fdf6
# ./alienvault-get_alarm.sh 5c931059-11cc-489d-b378-83f2d452fdf6
#
# Requires API Client credentials which can be created by:
#
@sherwind
sherwind / ansible-awscli-gosu-Dockerfile
Last active January 27, 2023 06:39
Dockerfile for ansible + awscliv2 + gosu
## $ docker build -t myansible .
## $ export AWS_PROFILE="..."
## $ docker run -it --rm -e AWS_PROFILE \
## -e MY_UID=$(id -u) -e MY_GID=$(id -g) \
## -v ${HOME}/.aws/config:/home/user/.aws/config:ro \
## -v ${HOME}/.aws/credentials:/home/user/.aws/credentials:ro \
## -v ${HOME}/.ssh/:/home/user/.ssh/:ro \
## -v $(pwd):/work \
## --workdir=/work myansible ansible -i inventory all -m ping
resource "aws_security_group" "main_resolver_inbound" {
name = "main-resolver-inbound"
description = "Main Route53 resolver inbound"
vpc_id = module.vpc_main.vpc_id
ingress {
from_port = 53
to_port = 53
protocol = "udp"
@sherwind
sherwind / gist:400ee01d4f5cdb0cdb367d30720f1ac6
Created May 2, 2020 15:56
Installing multiple versions of ansible
pyenv install 3.8.2
pyenv global 3.8.2
pyenv virtualenv ansible29
pyenv activate ansible29
pip install --upgrade pip
pip install ansible~=2.9.0 awscli pycrypto netaddr boto boto3
pyenv rehash
pyenv deactivate
@sherwind
sherwind / expand_ebs_volume.yml
Created February 21, 2020 02:40
Using Ansible to expand an EBS volume
- hosts: server
vars:
vol_new_size: 50
vol_drive: /dev/sdf
tasks:
- name: Gathering ec2 metada facts
ec2_metadata_facts:
@sherwind
sherwind / crontab-timeline.sh
Last active October 1, 2020 17:14
Reads and expands a crontab into a 24hour timeline
#!/bin/sh
#
# Reads and expands a crontab into a 24hour timeline:
#
# For each scheduled cron event...
# ... outputs the event's time (hh:mm) followed by the event's crontab entry
#
# This output is sorted into a cron event timeline (however it is still
# up to the reader to decode/determine which events run on which days).
#
@sherwind
sherwind / rds-top.sh
Last active June 16, 2022 13:58 — forked from matheusoliveira/README.md
Get AWS RDS Enhanced Monitoring statistics from CloudWatch and show something similar to Linux top command
#!/bin/bash
# rds-top.sh
# by <sherwin@daganato.com>, 20190822
# based on the work of Matheus de Oliveira <matioli.matheus@gmail.com>
#
# Usage:
# ./rds-top.sh rds-instance
# ./rds-top.sh --start-time=$(date -v-13d +%s) rds-instance
# ./rds-top.sh --sort-by-mem --start-time=$(date -j -f "%Y-%m-%dT%H:%M:%S%z" "2019-09-12T13:05:00+0000" +%s) rds-instance | grep -v 'idle$'
@sherwind
sherwind / COT Non-Commercial Net Positions
Last active March 18, 2019 16:54
COT Non-Commercial Net Positions.pinescript
//@version=3
//
// Commitments of Traders (COT) - Net Positions of Non-Commercial Traders
//
// See Also:
// - https://www.cftc.gov/MarketReports/CommitmentsofTraders/index.htm
// - https://www.investopedia.com/walkthrough/forex/trading-strategies/long-term/cot-report.aspx
// - https://www.oanda.com/forex-trading/analysis/commitments-of-traders
// - https://www.babypips.com/learn/forex/commitment-of-traders-report
//