Skip to content

Instantly share code, notes, and snippets.

View atombrella's full-sized avatar

Mads Jensen atombrella

View GitHub Profile
@atombrella
atombrella / wednesday.go
Created October 5, 2023 19:13
Find second last Wednesday of the Month
package utils
import "time"
func SecondLastWednesday(year int, month time.Month) int {
t := time.Date(year, month, 1, 0, 0, 0, 0, time.Local)
lastOfMonth := t.AddDate(0, 1, -1)
if lastOfMonth.Weekday() == 3 {
// Last day is a Wednesday
return (lastOfMonth.Day() - 7)
@atombrella
atombrella / Dockerfile
Created June 26, 2023 06:22
Docker Ubuntu Azure blob sta
FROM ubuntu:23.04
WORKDIR /opt
# adduser && addgroup
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y curl && \
curl -Ls https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -o /opt/packages-microsoft-prod.deb && \
dpkg -i /opt/packages-microsoft-prod.deb && \
@atombrella
atombrella / transformedTree.py
Created December 10, 2022 16:59
transform tree
# from typing import List, TypeVar
# Tree
# A
# / | \
# B C D
# / | |
# E F G
@atombrella
atombrella / shell.txt
Created November 17, 2022 21:28
trivy docker image with user
➜ docker run --rm -v ${HOME}/.cache:/root/.cache/ aquasec/trivy:user image python:3.4-alpine
2022-11-17T21:14:36.070Z INFO Need to update DB
2022-11-17T21:14:36.070Z INFO DB Repository: ghcr.io/aquasecurity/trivy-db
2022-11-17T21:14:36.070Z INFO Downloading DB...
846.35 KiB / 35.05 MiB [->___________________________________________________________] 2.36% ? p/s ?1.58 MiB / 35.05 MiB [-->____________________________________________________________] 4.50% ? p/s ?2.39 MiB / 35.05 MiB [---->__________________________________________________________] 6.82% ? p/s ?3.17 MiB / 35.05 MiB [---->______________________________________________] 9.04% 3.90 MiB p/s ETA 8s4.08 MiB / 35.05 MiB [----->____________________________________________] 11.63% 3.90 MiB p/s ETA 7s4.98 MiB / 35.05 MiB [------->__________________________________________] 14.21% 3.90 MiB p/s ETA 7s5.89 MiB / 35.05 MiB [-------->_________________________________________] 16.80% 3.94 MiB p/s ETA 7s6.92 MiB / 35.05 MiB [--------->__________________________
@atombrella
atombrella / errors.sarif
Created April 23, 2022 21:54
kube-score sarif output
{
"version": "2.1.0",
"$schema": "https://json.schemastore.org/sarif-2.1.0-rtm.5.json",
"runs": [
{
"tool": {
"driver": {
"name": "kube-score",
"informationUri": "https://kube-score.com/",
"rules": [

Add type annotations

PEP 484 and other PEP improve the expressiveness of this new addition. In my experience, it greatly improves the readability of the code, and as a bonus, IDE assistance. MyPy, Pyright, Pyre are possible choices for static type checkers that you can add to your CI/CD pipelines. MyPy seems to be the one that most people use.

@atombrella
atombrella / equal.py
Created January 24, 2022 13:18
Python __eq__ and __ne__ experiments
from typing import Any
class Something:
def __init__(self, *, a: int = 4) -> None:
self.a = a
def __eq__(self, other: Any) -> bool:
if isinstance(other, self.__class__):
return self.a == other.a
@atombrella
atombrella / gist:fa645d3a2d84bbc07ac30f7a93fdc095
Created September 24, 2021 16:57
Fetch Issue in Script Console
@com.onresolve.scriptrunner.parameters.annotation.ShortTextInput(description = "Enter Jira to execute the script on - leave empty for non-debug modes", label = "Jira Request Issue")
String jiraDebugIssue
Logger logger = Logger.getLogger("sacos.s5k.evalcreate")
logger.setLevel(Level.ALL)
IssueService issueService = ComponentAccessor.getIssueService()
IssueManager issueManager = ComponentAccessor.getIssueManager()
IssueInputParameters issueInputParameters = issueService.newIssueInputParameters();
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager()
@atombrella
atombrella / extract-website.sh
Created January 18, 2021 08:15
Scrape website with wget
# useful for extracting a website to text
wget --mirror --random-wait -R gif,png,jpg,webp,svg,css,js <website>/
for file in `find . -type f`; do A=`basename $file`;html2text "$file" > ../txt/$A.txt; done
cat ../txt/*| tr '[:punct:]' ' ' | tr 'A-Z' 'a-z' | tr ' ' '\n' | sort|egrep -e '^[a-zA-z]{4,15}$'|uniq -c|sort -n
@atombrella
atombrella / gist:2ed0a1838955b9c6434b90ad22c89b4e
Created April 30, 2019 11:46
docker nginx reverse proxy
# Dockerfile
version: '3.6'
services:
foo:
image: foo
restart: unless-stopped
ports:
- 9030:8080