IRB.conf[:USE_PAGER] = false
๐
There are three ways to find out where a method is defined in Ruby using IRB:
- using the
source_location
defined on the Method object - using the IRB
show_source
command - displaying information about an object using
ls
(for displaying the object but not the source file)
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
package main | |
import ( | |
"embed" | |
"encoding/json" | |
"fmt" | |
"io" | |
"io/fs" | |
"log" | |
"net/http" |
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
package main | |
import ( | |
"embed" | |
"fmt" | |
"io/fs" | |
"net/http" | |
"github.com/labstack/echo/v4" | |
) |
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 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 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 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 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
# example: | |
# $env:AWS_PROFILE="xxx" | |
# python .\main.py --days 3 --path "s3://mybucket/mydir" | |
import argparse | |
import boto3 | |
def main(): |
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 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 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
<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 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
// 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) | |
{ |
NewerOlder