This document provides guidelines for maintaining high-quality Rust code. These rules MUST be followed by all AI coding agents and contributors.
All code you write MUST be fully optimized.
"Fully optimized" includes:
If you encounter a problem where you cannot commit changes in Git – neither through the terminal nor via the GitHub Desktop application – the issue might be a freeze during the Git commit process. This is often caused by GPG lock issues. Below is a concise and step-by-step guide to resolve this problem.
Open your terminal and try to perform a GPG operation (like signing a test message). If you see repeated messages like gpg: waiting for lock (held by [process_id]) ..., it indicates a lock issue.
| import http.server | |
| import socketserver | |
| from http import HTTPStatus | |
| class Handler(http.server.SimpleHTTPRequestHandler): | |
| def do_GET(self): | |
| self.send_response(HTTPStatus.OK) | |
| self.end_headers() | |
| self.wfile.write(b'Hello world') |
If you ever need to download an entire website, perhaps for off-line viewing, wget can do the job — for example:
$ wget --recursive --no-clobber --page-requisites --html-extension --convert-links --restrict-file-names=windows --domains website.org --no-parent www.website.org/tutorials/html/
This command downloads the website www.website.org/tutorials/html/.
The options are:
--recursive: download the entire website--domains website.org: don't follow links outside website.org| class EmbedMap extends HTMLElement { | |
| constructor () { | |
| super(); | |
| } | |
| loadScript(src, callback) { | |
| let script = document.createElement('script'); | |
| script.src = src; | |
| script.addEventListener('load', callback); | |
| document.querySelector('head').appendChild(script); | |
| } |
| from django import forms | |
| class EmptyChoiceField(forms.ChoiceField): | |
| def __init__(self, choices=(), empty_label=None, required=True, widget=None, label=None, | |
| initial=None, help_text=None, *args, **kwargs): | |
| # prepend an empty label if it exists (and field is not required!) | |
| if not required and empty_label is not None: | |
| choices = tuple([(u'', empty_label)] + list(choices)) |
This is my recommended Python setup, as of Fall 2022. The Python landscape can be a confusing mess of overlapping tools that sometimes don't work well together. This is an effort to standardize our approach and environments.
| """Reloads the `my_turtle.py` code on save. | |
| Put simple turtle instructions in the `my_turtle.py` file, | |
| and they'll be re-run (on a clean window) on each file save. | |
| Usage: | |
| 1/ put some turtle instructions in a `my_turtle.py` file | |
| (eg `turtle.forward(100)`) | |
| 2/ run `python watch_turtle.py` on a commandline | |
| (no dependencies needed) |
| <!doctype html> | |
| <meta charset=utf-8> | |
| <title>Test DOM Content Loaded and promises</title> | |
| <script> | |
| console.log(document.querySelector('main')) // => null | |
| document.ready = new Promise( | |
| (resolve) => document.addEventListener('DOMContentLoaded', resolve)) | |
| document.ready.then(() => console.log(document.querySelector('main'))) // => <main> | |
| </script> | |
| <main></main> |