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
find /path/to/your/directory -type f -name '*.sh' -exec chmod +x {} \; |
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
AccessModifierOffset: -4 | |
AlignAfterOpenBracket: AlwaysBreak | |
AlignConsecutiveMacros: false | |
AlignConsecutiveAssignments: false | |
AlignConsecutiveDeclarations: false | |
AlignEscapedNewlines: DontAlign | |
AlignOperands: false | |
AlignTrailingComments: false | |
AllowAllArgumentsOnNextLine: false | |
AllowAllConstructorInitializersOnNextLine: false |
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 contextlib | |
from typing import Any, Generator | |
@contextlib.contextmanager | |
def suppress_stdout_stderr() -> Generator[None, Any, None]: | |
""" | |
A context manager that redirects stdout and stderr to /dev/null | |
""" | |
with open("/dev/null", "w", encoding="utf-8") as null: | |
with contextlib.redirect_stdout(null), contextlib.redirect_stderr(null): |
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
:: GenerateFileContents.bat | |
:: ~~~~~~~~~~~~~~~~~~~~~~~~ | |
:: Description: | |
:: This script generates a file that contains the contents of all files in a directory and its subdirectories. | |
:: | |
:: Parameters: | |
:: 1. Directory path to search for files in (i.e. "D:\Other\Java Projects\luhnalgorithm\src\main\java\com") | |
:: 2. Output file path (i.e. "D:\Other\Java Projects\luhnalgorithm\filecontents.txt") | |
:: 3. File extensions to look for (i.e. "java" or "java txt" or "java txt csv") | |
:: |
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
; ----------------------------------------------------------------------------- | |
; A 64-bit Linux application that writes the first 90 Fibonacci numbers. To | |
; assemble and run: | |
; | |
; nasm -f elf64 _fib.asm && gcc _fib.o -no-pie -o a.out && ./a.out | |
; ----------------------------------------------------------------------------- | |
global main | |
extern printf |
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
""" | |
A simple HTTP server that serves a single PDF file. | |
This script creates a basic HTTP server that serves a single PDF file to clients. | |
The server listens on port 8000 by default and serves the specified PDF file. | |
Clients can access the PDF file by visiting the server's IP address. | |
Usage: | |
python3 server.py | |
""" |
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
[mypy] | |
; The mypy configurations below are my personal preferences. | |
check_untyped_defs = True | |
disallow_any_generics = True | |
disallow_any_unimported = True | |
disallow_subclassing_any = True | |
disallow_untyped_calls = True | |
disallow_untyped_decorators = True | |
disallow_untyped_defs = True | |
ignore_missing_imports = True |
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
def print_attributes(obj: object, indent: int = 0) -> None: | |
""" | |
Recursively prints the attributes of an object. | |
Args: | |
obj (object): The object to print the attributes of. | |
indent (int, optional): The number of spaces to indent the output. Defaults to 0. | |
Returns: | |
None |
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
""" | |
A simple stack implementation using Generics. | |
This is a simple stack implementation using Generics. It is based on the | |
example from the Python docs: | |
https://docs.python.org/3/library/typing.html#user-defined-generic-types | |
""" | |
from typing import TypeVar, Generic |
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
def _rgb_to_hexadecimal( | |
rgb: tuple, include_prefix: bool = False, lowercase: bool = False | |
) -> str: | |
""" | |
Convert an RGB tuple to a hexadecimal color code. | |
Args: | |
rgb (tuple): The RGB tuple representing the color components. | |
include_prefix (bool, optional): Whether to include the '#' prefix in the hexadecimal color code. Defaults to False. | |
lowercase (bool, optional): Whether to use lowercase letters in the hexadecimal color code. Defaults to False. |