Skip to content

Instantly share code, notes, and snippets.

View TheRockStarDBA's full-sized avatar
🏠
Working from home

Kin Shah TheRockStarDBA

🏠
Working from home
View GitHub Profile
@TheRockStarDBA
TheRockStarDBA / stackexchange.sql
Created July 9, 2023 20:28
https://dba.stackexchange.com/q/329095/8783 Same Variable Changing its Min/Max Values within the Same Group?
WITH ntiles AS (
SELECT
id,
height,
weight,
gender,
country,
favorite_color,
disease,
NTILE(5) OVER (PARTITION BY gender, country, favorite_color ORDER BY height) as height_ntile
@TheRockStarDBA
TheRockStarDBA / falsehoods-programming-time-list.md
Created March 2, 2023 19:20 — forked from timvisee/falsehoods-programming-time-list.md
Falsehoods programmers believe about time, in a single list

Falsehoods programmers believe about time

This is a compiled list of falsehoods programmers tend to believe about working with time.

Don't re-invent a date time library yourself. If you think you understand everything about time, you're probably doing it wrong.

Falsehoods

  • There are always 24 hours in a day.
  • February is always 28 days long.
  • Any 24-hour period will always begin and end in the same day (or week, or month).
@TheRockStarDBA
TheRockStarDBA / python.md
Created October 18, 2022 14:43 — forked from eyeseast/python.md
How to set up Python in 2022

Python

This is my recommended Python setup, as of Fall 2022. The Python landscape can be a confusing mess of overlapping tools that sometimes don't work well together. This is an effort to standardize our approach and environments.

Tools and helpful links:

@TheRockStarDBA
TheRockStarDBA / histogram.py
Created July 7, 2022 18:47 — forked from notareverser/histogram.py
Frequency analysis tool
#!/usr/bin/env python3
import argparse
import sys
import mmap
import logging
from collections import defaultdict
@TheRockStarDBA
TheRockStarDBA / Test-FileHash.ps1
Created February 22, 2022 21:15 — forked from potatoqualitee/Test-FileHash.ps1
Simple file hash comparison tool written in PowerShell
function Test-FileHash {
<#
.Synopsis
This is a simple file hash comparison tool that writes to Windows Events when changes are detected
.Description
This is a simple file hash comparison tool that writes to Windows Events when changes are detected
.PARAMETER FilePath
The path to the file to hash and compare
@TheRockStarDBA
TheRockStarDBA / cachedecorator.py
Created February 9, 2022 03:19 — forked from mminer/cachedecorator.py
An example of a Python decorator to simplify caching a function's result.
"""An example of a cache decorator."""
import json
from functools import wraps
from redis import StrictRedis
redis = StrictRedis()
def cached(func):
@TheRockStarDBA
TheRockStarDBA / log4j_rce_detection.md
Created February 2, 2022 22:29 — forked from Neo23x0/log4j_rce_detection.md
Log4j RCE CVE-2021-44228 Exploitation Detection

log4j RCE Exploitation Detection

You can use these commands and rules to search for exploitation attempts against log4j RCE vulnerability CVE-2021-44228

Grep / Zgrep

This command searches for exploitation attempts in uncompressed files in folder /var/log and all sub folders

sudo egrep -I -i -r '\$(\{|%7B)jndi:(ldap[s]?|rmi|dns|nis|iiop|corba|nds|http):/[^\n]+' /var/log
@TheRockStarDBA
TheRockStarDBA / scrapy_lambda_layer.sh
Created January 19, 2022 17:07 — forked from haranjackson/scrapy_lambda_layer.sh
Deploys Python Scrapy library to an AWS Lambda layer. You can specify the region, library version, and runtime.
REGION=eu-west-1
VER=1.7.3
RUNTIME=python3.7
docker run -v $(pwd):/out -it lambci/lambda:build-$RUNTIME \
pip install scrapy==$VER -t /out/build/scrapy/python
cd build/scrapy
zip -r ../../scrapy.zip python/
cd ../..
@TheRockStarDBA
TheRockStarDBA / github-wiki-how-to-image-links.md
Created October 23, 2021 14:05 — forked from TT--/github-wiki-how-to-image-links.md
GitHub Wiki How-To for Image and File links
@TheRockStarDBA
TheRockStarDBA / gist:db38b3414720fc8d9e2271ca08d84af6
Created October 22, 2021 12:45
ports and count of connections - powershell Net TCP Connection
Get-NetTCPConnection | Group-Object -Property State, OwningProcess | Select -Property Count, Name, @{Name="ProcessName";Expression={(Get-Process -PID ($_.Name.Split(',')[-1].Trim(' '))).Name}}, Group | Sort Count -Descending