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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 && \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# from typing import List, TypeVar | |
# Tree | |
# A | |
# / | \ | |
# B C D | |
# / | | | |
# E F G |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
➜ 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 [--------->__________________________ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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": [ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Dockerfile | |
version: '3.6' | |
services: | |
foo: | |
image: foo | |
restart: unless-stopped | |
ports: | |
- 9030:8080 |