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 tkinter as tk | |
def send_message(event=None): | |
message = input_entry.get() | |
if message.strip(): | |
chat_history.configure(state=tk.NORMAL) | |
chat_history.insert(tk.END, "You: " + message + "\n") | |
chat_history.configure(state=tk.DISABLED) | |
input_entry.delete(0, tk.END) |
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 sys | |
import importlib | |
sys.exit = lambda *args, **kwargs: ... | |
print(f"sys.exit overridden: {sys.exit}") | |
importlib.reload(sys) | |
print(f"sys.exit restored: {sys.exit}") | |
try: | |
print("test") | |
sys.exit(0) | |
except SystemExit as e: |
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 sys | |
from PyQt5.QtCore import Qt, QRect, QPoint | |
from PyQt5.QtGui import QPainter, QBrush, QColor, QRegion | |
from PyQt5.QtWidgets import QApplication, QWidget | |
class SeeThroughHoleWindow(QWidget): | |
def __init__(self): | |
super().__init__() | |
self.initUI() | |
self.dragging = 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
from tree_sitter import Language, Parser, Tree, Node | |
import tree_sitter_c | |
from typing import Generator | |
C_LANGUAGE = Language(tree_sitter_c.language(), "c") | |
parser = Parser() | |
parser.set_language(C_LANGUAGE) | |
c_code = """ |
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 sys | |
import termios | |
import tty | |
def get_text_area_size(): | |
# Save the terminal's original settings | |
fd = sys.stdin.fileno() | |
original_attributes = termios.tcgetattr(fd) | |
try: |
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 curses | |
def get_terminal_size(): | |
try: | |
# Initialize curses | |
stdscr = curses.initscr() | |
# Turn off echoing of keys, and enter cbreak mode, | |
# where no buffering is performed on keyboard input | |
curses.noecho() |
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 threading | |
import time | |
import signal | |
class ControlledExecution: | |
def __init__(self): | |
self.lock = threading.Lock() | |
self.condition = threading.Condition(self.lock) | |
self.shutdown = 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 threading | |
import time | |
class ControlledExecution: | |
def __init__(self): | |
self.lock = threading.Lock() | |
self.condition = threading.Condition(self.lock) | |
self.shutdown = False | |
def worker(self): |
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 threading | |
import time | |
import signal | |
class ControlledExecution: | |
def __init__(self): | |
self.lock = threading.Lock() | |
self.condition = threading.Condition(self.lock) | |
self.shutdown = False |
NewerOlder