- When greater control is needed, :ref:`template string literals <tut-t-strings>`
can be useful. T-strings -- which begin with
t
orT
-- share the same syntax as f-strings but, unlike f-strings, produce a :class:`~string.templatelib.Template` instance rather than a simplestr
. Templates give you access to the static and interpolated (in curly braces) parts of the string before they are combined into a final string.>>> name = "World"
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
{ | |
"displayName": "Python 3.14", | |
"name": "python314", | |
"patterns": [ | |
{ | |
"include": "#statement" | |
}, | |
{ | |
"include": "#expression" | |
} |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Progress to Retirement</title> | |
<style> | |
body { | |
font-family: "Helvetica Neue", sans-serif; |
This is a pure Python implementation of code necessary to decode the Bluesky Firehose's low-level binary data format.
It does not depend on any third-party libraries for decoding; we implement DAG_CBOR and CARv1 decoding ourselves.
To run this, install Astral's UV.
Then:
This small Python script makes it easy to convert from ATProto DIDs to their associated handles and back again:
$ ./resolve.py handle @davepeck.org
did:plc:caznr5mgvjft4mu4p2vpttfx
$ ./resolve.py did did:plc:caznr5mgvjft4mu4p2vpttfx
davepeck.org
Connect to the Bluesky Jetstream, emitting one JSON line per message received.
To use, make sure you have Astral's UV installed.
Then, run it as:
$ uv run https://gist.githubusercontent.com/davepeck/5484fc026a2e8269cf1ead00fff0ef8f/raw/ab4b06145d01f16c216ca3135da2945abdaf0010/jetstream.py
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
"""BigQuery utilities.""" | |
import datetime | |
import typing as t | |
from abc import ABC, abstractmethod | |
from google.cloud import bigquery | |
from google.cloud.bigquery import query | |
type QueryParamValue = str | int | float | datetime.date | datetime.datetime | t.Sequence[ # noqa: E501 |
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
// note that a lot of code choices here are due to the fact that cloudfront edge uses | |
// a hilariously backwards version of javascript: | |
// | |
// "const", you say? what's that?! | |
// deal with the painful structure that cloudfront edge functions use for query params | |
function getURLSearchParamsString(obj) { | |
var str = []; | |
for (var param in obj) { | |
if (obj[param].multiValue) { |
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 time | |
from random import random | |
from typing import Set, Tuple | |
# Set the default BOARD_SIZE to 40 | |
BOARD_SIZE = 40 | |
def init_board_with_n_gliders(n: int) -> Set[Tuple[int, int]]: | |
"""Initialize a board with n gliders.""" |
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 fs from "fs"; | |
import url from "url"; | |
import { getCSSLanguageService } from "vscode-css-languageservice"; | |
import { TextDocument } from "vscode-languageserver-textdocument"; | |
/** Human-readable names for the potential diagnostic severities returned. */ | |
const severities = { 1: "ERR", 2: "WARN", 3: "INFO", 4: "HINT" }; | |
/** Format a position in a given file. */ |
NewerOlder