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
| read_file_slice() { | |
| local path="$1" | |
| local start_byte="${2:-0}" | |
| local length="${3:-32768}" | |
| local show_hex="${4:-false}" | |
| # Safety caps | |
| (( length > 131072 )) && length=131072 | |
| (( start_byte < 0 )) && start_byte=0 |
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 re | |
| # 256-color to hex mapping (simplified xterm-256color palette) | |
| def ansi_256_to_hex(n): | |
| try: | |
| n = int(n) | |
| if 0 <= n <= 7: # Standard colors | |
| colors = ['#000000', '#FF0000', '#00FF00', '#FFFF00', '#0000FF', '#FF00FF', '#00FFFF', '#FFFFFF'] | |
| return colors[n] | |
| elif 8 <= n <= 15: # Bright colors (approximated to standard) |
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
| # Save as proxy2.py on your LOCAL machine | |
| import socket | |
| import threading | |
| from socketserver import ThreadingMixIn, TCPServer, StreamRequestHandler | |
| class SOCKSProxyHandler(StreamRequestHandler): | |
| def handle(self): | |
| print("New connection") | |
| # Read initial byte to determine SOCKS version | |
| version = self.connection.recv(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
| import anyio | |
| from anyio import Path | |
| from tree_sitter_language_pack import get_language, get_parser | |
| import os | |
| from typing import Dict, Optional | |
| async def scan_file(file_path: str, language_extensions: dict) -> tuple[str, Optional[dict]]: | |
| """Scan a single file and return its parsed data.""" | |
| ext = os.path.splitext(file_path)[1] | |
| for lang, exts in language_extensions.items(): |
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 pygments import highlight | |
| from pygments.lexers import get_lexer_by_name | |
| from pygments.formatters import TerminalFormatter | |
| def render_markdown_to_console(markdown_text): | |
| lines = markdown_text.split('\n') | |
| in_code_block = False | |
| current_language = None | |
| code_buffer = [] | |
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 fcntl | |
| import hashlib | |
| import os | |
| import re | |
| import subprocess | |
| from ansible.plugins.action import ActionBase, display | |
| from ansible.plugins.filter.core import to_nice_yaml |
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 copy | |
| import math | |
| def box(remaining, capacity): | |
| if len(remaining) >= capacity: | |
| weights = [b.item_weight for b in remaining[:capacity]] | |
| return sum(weights) |
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
| #!/usr/bin/env python | |
| """ | |
| Shlaxfile for shlax itself. | |
| """ | |
| from shlax.shortcuts import * | |
| env = dict( | |
| DJANGO_SETTINGS_MODULE='ylserver.settings', | |
| UWSGI_MODULE='ylserver.wsgi:application', |
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
| aoeu |
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
| 14/02 2019 04:39:23 jpic@jpic ~/src/ansible-compose (master) | |
| $ ansible-compose [email protected]/home/jpic/bar stop | |
| Running ssh [email protected] bash -euxc 'cd /home/jpic/bar; docker-compose stop' | |
| + cd /home/jpic/bar | |
| + docker-compose stop |
NewerOlder