๐
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 main | |
import ( | |
"embed" | |
"fmt" | |
"io/fs" | |
"net/http" | |
"github.com/labstack/echo/v4" | |
) |
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
import argparse | |
import os | |
import re | |
def sanitize_filename(filename): | |
# Replace characters not allowed in Windows filenames with underscores | |
sanitized = re.sub(r'[<>:"/\\|?*]', "_", filename) | |
# Remove non-ASCII characters | |
sanitized = re.sub(r"[^\x00-\x7F]", "_", sanitized) |
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 pathlib import Path | |
from textual import events, on | |
from textual.app import App, ComposeResult | |
from textual.containers import Container, Horizontal | |
from textual.screen import ModalScreen | |
from textual.widgets import Button, DataTable, Footer, Header, Label | |
from rich.text import Text |
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
# example: | |
# $env:AWS_PROFILE="xxx" | |
# python .\main.py --days 3 --path "s3://mybucket/mydir" | |
import argparse | |
import boto3 | |
def main(): |
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
import pexpect | |
def otp(): | |
import requests | |
vault_id = "xxxxxxxxx" | |
item_id = "xxxxxxxx" | |
url = f"http://localhost:18080/v1/vaults/{vault_id}/items/{item_id}" | |
headers = { | |
"Authorization": "Bearer xxxx", # noqa: E501 |
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
<div> | |
<button class="btn btn-dark" type="button" | |
x-on:click="copyToClipboard" | |
id="clipboard-000"> | |
<i class="bi bi-clipboard"></i> Copy to clipboard | |
</button> | |
<div class="d-none" id="clipboard-000-text">Text to be copied to the clipboard</div> | |
</div> |
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
// https://github.com/microsoft/referencesource/blob/master/System.Web/CrossSiteScriptingValidation.cs | |
private static readonly char[] StartingChars = new char[] { '<', '&' }; | |
private static bool IsAtoZ(char c) | |
{ | |
return c is >= 'a' and <= 'z' or >= 'A' and <= 'Z'; | |
} | |
private static bool IsDangerousString(string s) | |
{ |
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
#!/usr/bin/env bash | |
# JS script paths are absolute in some Ruby docs, convert them to relative. | |
fd --type file --extension html --full-path 'ruby_.*' --exec sd --string-mode 'src="/js/' 'src="js/' |
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
func openBrowser(url string) { | |
var err error | |
switch runtime.GOOS { | |
case "linux": | |
err = exec.Command("xdg-open", url).Start() | |
case "windows": | |
err = exec.Command("rundll32", "url.dll,FileProtocolHandler", url).Start() | |
case "darwin": | |
err = exec.Command("open", url).Start() |
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
# https://stackoverflow.com/questions/3854692/generate-password-in-python | |
import string | |
import secrets | |
length = 42 | |
password = "" | |
for _ in range(length): | |
l = secrets.choice(string.ascii_lowercase) | |
u = secrets.choice(string.ascii_uppercase) |
NewerOlder