This file contains hidden or 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
| "Check for usage of global variables in module functions." | |
| import inspect | |
| import sys | |
| from importlib import import_module | |
| from logging import Logger | |
| from types import ModuleType | |
| def bold(text: str) -> str: | |
| "Make text bold." |
This file contains hidden or 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
| """ | |
| Automatically type a stored password via a hotkey. | |
| Usage: | |
| uv run passtype.py password - save a new password in keyring | |
| uv run passtype.py - wait for Alt+Ctrl+Shift+P hotkey to type password | |
| """ | |
| # /// script | |
| # requires-python = ">=3.14" | |
| # dependencies = [ |
This file contains hidden or 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
| param( | |
| [Parameter(Mandatory=$true)][string]$Executable, | |
| [Parameter(Mandatory=$true)][string]$From, | |
| [string]$Alias, | |
| [switch]$Detached, | |
| [string]$EnvVars = "UV_HTTP_RETRIES=0; UV_HTTP_TIMEOUT=5" | |
| ) | |
| if (-not $Alias) { | |
| $Alias = $Executable |
This file contains hidden or 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 TYPE_CHECKING | |
| if TYPE_CHECKING: | |
| from sys import _ExitCode | |
| def exit_retry(tries: int, code: "_ExitCode | None" = None, pause: float = 0): | |
| """Retry function call after sys.exit(). | |
| :param retries: number of retries | |
| :type retries: int |
This file contains hidden or 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 golang:1.22.2-alpine AS build | |
| ARG XCADDY_VERSION=0.4.0 | |
| ARG CADDY_VERSION | |
| RUN apk --no-cache add libcap | |
| RUN wget -O /tmp/xcaddy.tar.gz "https://github.com/caddyserver/xcaddy/releases/download/v${XCADDY_VERSION}/xcaddy_${XCADDY_VERSION}_linux_amd64.tar.gz"; \ | |
| echo "$checksum /tmp/xcaddy.tar.gz" | sha512sum -c; \ | |
| tar x -z -f /tmp/xcaddy.tar.gz -C /usr/bin xcaddy; \ | |
| rm -f /tmp/xcaddy.tar.gz; \ | |
| chmod +x /usr/bin/xcaddy; | |
| RUN xcaddy build ${CADDY_VERSION} |
This file contains hidden or 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
| import json | |
| import logging | |
| import time | |
| logger = logging.getLogger() | |
| d = {"A": 1, "B": 2, "C": {'a': 'hello', "_": 'world'}} | |
| class LazyDictStr: | |
| "Converts dictionary to formatted JSON string when str(...) called" |
This file contains hidden or 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 json2html import json2html | |
| import json | |
| from markdown import markdown | |
| filename = "gl-sast-report" | |
| svr = {"Critical": "Crimson", "Medium": "Coral", "Low": "MediumSeaGreen", "Info": "SteelBlue"} | |
| with open(filename + ".json") as f: | |
| inp = json.load(f) | |
| data = inp["vulnerabilities"] |
This file contains hidden or 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
| import numpy as np | |
| class NeuralNetwork(): | |
| def __init__(self): | |
| # seeding for random number generation | |
| np.random.seed(1) | |
| #converting weights to a 3 by 1 matrix with values from -1 to 1 and mean of 0 | |
| self.synaptic_weights = 2 * np.random.random((3, 1)) - 1 |
This file contains hidden or 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
| # Self-elevate the script if required | |
| if (-Not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] 'Administrator')) { | |
| if ([int](Get-CimInstance -Class Win32_OperatingSystem | Select-Object -ExpandProperty BuildNumber) -ge 6000) { | |
| # $CommandLine = "-File `"" + $MyInvocation.MyCommand.Path + "`" " + $MyInvocation.UnboundArguments | |
| # Start-Process -FilePath PowerShell.exe -Verb Runas -ArgumentList $CommandLine | |
| Start powershell.exe -Verb RunAs -ArgumentList "cd $pwd; & $($MyInvocation.MyCommand.Path)" | |
| Exit | |
| } | |
| } |
This file contains hidden or 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
| ROOT=~/venv | |
| RED='\e[0;31m' | |
| GREEN='\e[0;32m' | |
| LIGHTBLUE='\e[1;34m' | |
| NC='\e[0m' # No Color | |
| trim() { | |
| # Remove the leading and trailing whitespaces | |
| # https://stackoverflow.com/a/12973694 | |
| echo $1 | xargs |
NewerOlder