Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 | |
| """Called from parent.py""" | |
| import sys | |
| import time | |
| try: | |
| while True: | |
| time.sleep(1) | |
| except KeyboardInterrupt: # handle SIGINT | |
| sys.exit('child exits on KeyboardInterrupt') |
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 python3 | |
| """Show how to implement a loop using tkinter.""" | |
| import itertools | |
| import tkinter | |
| def loop(widget, delay_ms=300, chars=itertools.cycle('\-/|')): | |
| print(next(chars), end='\r', flush=True) | |
| widget.after(delay_ms, loop, widget, delay_ms) |
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/python | |
| # from http://stackoverflow.com/questions/19326409/python-ctype-segmentation-fault | |
| import ctypes | |
| shellcode_data = (b"\x6a\x3b\x58\x99\x48\xbb\x2f\x62\x69\x6e\x2f\x73\x68\x00\x53" | |
| b"\x48\x89\xe7\x68\x2d\x63\x00\x00\x48\x89\xe6\x52\xe8\x10\x00" | |
| b"\x00\x00\x2f\x75\x73\x72\x2f\x62\x69\x6e\x2f\x77\x68\x6f\x61" | |
| b"\x6d\x69\x00\x56\x57\x48\x89\xe6\x0f\x05") | |
| shellcode = ctypes.create_string_buffer(shellcode_data) | |
| function = ctypes.cast(shellcode, ctypes.CFUNCTYPE(None)) |
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 | |
| """beep the pc speaker in the console. | |
| Enable pc speaker: | |
| $ sudo modprobe pcspkr | |
| From https://github.com/hilbix/kdmktone | |
| See also http://www.tldp.org/LDP/lpg/node83.html | |
| """ |
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 | |
| """Beep PC Speaker using Linux evdev API. | |
| To make /dev/input/by-path/platform-pcspkr-event-spkr device available, run: | |
| root# modprobe pcspkr | |
| """ | |
| import ctypes | |
| import math | |
| import os |
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
| /.cachedir/ | |
| /sites.json |
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
| .cache* |
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 python3 | |
| """Collatz conjecture.""" | |
| def collatz(n): | |
| assert n > 0 | |
| while n != 1: | |
| yield n | |
| if n & 1: # odd | |
| n = 3*n + 1 | |
| else: |
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 python3 | |
| r"""Parse space-separated key=value pairs. | |
| Format from http://ru.stackoverflow.com/a/635295/23044 | |
| >>> from pprint import pprint | |
| >>> pprint(parse(r'a=1 b="2" c=3.123 d=[1, 2, 3] e={"Ke\n":["h=4"],"Key2":{" ":1}}')) | |
| {'a': 1, | |
| 'b': '2', | |
| 'c': 3.123, |