### Install and run Marimo tutorial Source: https://github.com/marimo-team/marimo This snippet shows how to install the marimo library using pip and then run the introductory tutorial. It's a common pattern for getting started with a new Python package. ```shell pip install marimo && marimo tutorial intro ``` -------------------------------- ### Install Wrangler with yarn Source: https://developers.cloudflare.com/r2/get-started Installs the latest version of the Wrangler CLI tool as a development dependency using yarn. Wrangler is essential for interacting with Cloudflare Workers and R2 Storage. ```bash yarn add -D wrangler@latest ``` -------------------------------- ### Install Wrangler with pnpm Source: https://developers.cloudflare.com/r2/get-started Installs the latest version of the Wrangler CLI tool as a development dependency using pnpm. Wrangler is essential for interacting with Cloudflare Workers and R2 Storage. ```bash pnpm add -D wrangler@latest ``` -------------------------------- ### Install Wrangler with npm Source: https://developers.cloudflare.com/r2/get-started Installs the latest version of the Wrangler CLI tool as a development dependency using npm. Wrangler is essential for interacting with Cloudflare Workers and R2 Storage. ```bash npm i -D wrangler@latest ``` -------------------------------- ### Manual NVM Installation and Setup (Shell) Source: https://github.com/nvm-sh/nvm This snippet details the manual installation of NVM. It clones the NVM repository into the specified directory, checks out the latest tag, and then sources the NVM script to make it available in the current shell session. This is useful for users who prefer manual control over their installations. ```shell export NVM_DIR="$HOME/.nvm" && ( git clone https://github.com/nvm-sh/nvm.git "$NVM_DIR" cd "$NVM_DIR" git checkout `git describe --abbrev=0 --tags --match "v[0-9]*" $(git rev-list --tags --max-count=1)` ) && . "$NVM_DIR/nvm.sh" ``` -------------------------------- ### nvm Use and Install with .nvmrc Example Source: https://github.com/nvm-sh/nvm Demonstrates how 'nvm use' and 'nvm install' commands automatically detect and utilize the Node.js version specified in a .nvmrc file, including downloading and installing the version if it's not already present. ```bash nvm use nvm install ``` -------------------------------- ### Install PyIceberg and PyArrow Libraries Source: https://blog.cloudflare.com/r2-data-catalog-public-beta Installs the necessary Python libraries, PyIceberg and PyArrow, which are required for interacting with Apache Iceberg tables and creating Arrow tables, respectively. These are essential for the Python example. ```python pip install pyiceberg pyarrow ``` -------------------------------- ### Configure rclone Source: https://rclone.org/install Initiates the configuration process for rclone. This command guides the user through setting up remotes and other necessary configurations. ```bash rclone config ``` -------------------------------- ### Install uv with standalone installer Source: https://docs.astral.sh/uv Installs uv using the official standalone installer script. This method is suitable for macOS and Linux systems via curl, and for Windows systems via PowerShell. It's a quick way to get uv set up without needing Rust or Python pre-installed. ```bash curl -LsSf https://astral.sh/uv/install.sh | sh ``` ```powershell powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex" ``` -------------------------------- ### Shell: Install Volta and Node.js Source: https://volta.sh/ This shell script snippet demonstrates how to install Volta, a JavaScript tool manager, using a curl command piped to bash. It then shows how to install Node.js using the installed Volta CLI and how to start using Node.js. ```shell # install Volta curl https://get.volta.sh | bash # install Node volta install node # start using Node node ``` -------------------------------- ### Install AWS SDK for Go v2 Source: https://context7_llms This command installs the AWS SDK for Go v2, which is necessary for interacting with Cloudflare R2 using the S3 API in Go applications. It uses the 'go get' command to download and manage the package dependencies. ```sh go get github.com/aws/aws-sdk-go-v2 ``` -------------------------------- ### Clone PDF Summarizer Repository and Install Dependencies Source: https://github.com/harshil1712/pdf-summarizer-r2-event-notification Clones the PDF summarizer project from GitHub and installs its Node.js dependencies using npm. ```shell git clone https://github.com/your-username/pdf-summarizer.git cd pdf-summarizer npm install ``` -------------------------------- ### Dockerfile: Setup Node.js with NVM Source: https://github.com/nvm-sh/nvm This Dockerfile configures a Ubuntu-based image to install and manage Node.js versions using NVM. It sets up necessary dependencies like curl, installs NVM, and configures the entrypoint to source the NVM environment before executing commands. ```dockerfile FROM ubuntu:latest ARG NODE_VERSION=20 # install curl RUN apt update && apt install curl -y # install nvm RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash # set env ENV NVM_DIR=/root/.nvm # install node RUN bash -c "source $NVM_DIR/nvm.sh && nvm install $NODE_VERSION" # set ENTRYPOINT for reloading nvm-environment ENTRYPOINT ["bash", "-c", "source $NVM_DIR/nvm.sh && exec \"$@\"", "--"] # set cmd to bash CMD ["/bin/bash"] ``` -------------------------------- ### Initialize Go Project and Add AWS SDK v2 Dependencies Source: https://github.com/aws/aws-sdk-go-v2 This snippet demonstrates the initial steps to set up a Go project for use with the AWS SDK v2. It includes initializing a Go module and adding the necessary SDK dependencies for core functionality, configuration loading, and the DynamoDB service client. This is essential for any Go project interacting with AWS. ```bash mkdir ~/helloaws cd ~/helloaws go mod init helloaws go get github.com/aws/aws-sdk-go-v2/aws go get github.com/aws/aws-sdk-go-v2/config go get github.com/aws/aws-sdk-go-v2/service/dynamodb ``` -------------------------------- ### List Available Marimo Tutorials Source: https://github.com/marimo-team/marimo Displays help information for the marimo tutorial command, listing available tutorials and their usage. This is a command-line utility. ```shell marimo tutorial --help ``` -------------------------------- ### Initialize Go Project for Cloudflare R2 SDK Source: https://github.com/aws/aws-sdk-go-v2 This snippet shows how to initialize a new Go project using Go modules. It creates a project directory and initializes the module, which is a prerequisite for managing SDK dependencies. ```shell mkdir ~/helloaws cd ~/helloaws go mod init helloaws ``` -------------------------------- ### Configure Scala Version in build.sbt Source: https://www.scala-sbt.org/ Scala build configuration file snippet defining the Scala version for the project. This is a minimal example to get started with Scala using sbt. ```scala ThisBuild / scalaVersion := "3.7.2" ``` -------------------------------- ### Install Marimo with Recommended Packages Source: https://github.com/marimo-team/marimo Installs the Marimo package along with recommended dependencies for full functionality. This command is typically run in a terminal or command prompt. ```shell pip install marimo[recommended] ``` -------------------------------- ### CSS for Starlight Footnote Styling Source: https://developers.cloudflare.com/r2/get-started Styles footnote elements within the Starlight documentation, setting their font size, line height, and color. This ensures footnotes are visually distinct but unobtrusive. ```css .footnote { font-size: 0.75rem; line-height: 1rem; color: var(--sl-colo ``` -------------------------------- ### Initialize AWS SDK and List DynamoDB Tables in Go Source: https://github.com/aws/aws-sdk-go-v2 This Go code initializes the AWS SDK for Go using default configuration, loads credentials from the environment, and creates a DynamoDB client. It then lists up to 5 DynamoDB tables in the 'us-west-2' region and prints their names. This snippet requires the AWS SDK for Go and assumes AWS credentials and region are configured. ```go package main import ( "context" "fmt" "log" "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/config" "github.com/aws/aws-sdk-go-v2/service/dynamodb" ) func main() { // Using the SDK's default configuration, load additional config // and credentials values from the environment variables, shared // credentials, and shared configuration files cfg, err := config.LoadDefaultConfig(context.TODO(), config.WithRegion("us-west-2")) if err != nil { log.Fatalf("unable to load SDK config, %v", err) } // Using the Config value, create the DynamoDB client svc := dynamodb.NewFromConfig(cfg) // Build the request with its input parameters resp, err := svc.ListTables(context.TODO(), &dynamodb.ListTablesInput{ Limit: aws.Int32(5), }) if err != nil { log.Fatalf("failed to list tables, %v", err) } fmt.Println("Tables:") for _, tableName := range resp.TableNames { fmt.Println(tableName) } } ``` -------------------------------- ### HTTP Request Example: GET Method Source: https://www.rfc-editor.org/rfc/rfc9110 An example of a GET request for a specific resource on a web server, including the HTTP version and Host header. ```http GET /pub/WWW/ HTTP/1.1 Host: www.example.org ``` -------------------------------- ### Docker Build and Run Examples Source: https://github.com/nvm-sh/nvm Demonstrates how to build a Docker image with a specific Node.js version using a build argument and how to run containers interactively or non-interactively to execute Node.js and npm commands. ```bash docker build -t nvmimage --build-arg NODE_VERSION=19 . ``` ```bash docker run --rm -it nvmimage root@0a6b5a237c14:/# nvm -v 0.40.3 root@0a6b5a237c14:/# node -v v19.9.0 root@0a6b5a237c14:/# npm -v 9.6.3 ``` ```bash user@host:/tmp/test $ docker run --rm -it nvmimage node -v v19.9.0 user@host:/tmp/test $ docker run --rm -it nvmimage npm -v 9.6.3 ``` -------------------------------- ### Client Setup Source: https://developers.cloudflare.com/r2/examples/aws/aws-sdk-net Demonstrates how to instantiate an S3 client with R2 configuration using explicit credentials. ```APIDOC ## Client Setup ### Description This section shows how to configure the AWS SDK for .NET to connect to Cloudflare R2 by explicitly providing your Access Key ID and Secret Access Key. ### Method C# ### Endpoint N/A (Client-side configuration) ### Parameters None ### Request Example ```csharp private static IAmazonS3 s3Client; public static void Main(string[] args) { var accessKey = ""; var secretKey = ""; var credentials = new BasicAWSCredentials(accessKey, secretKey); s3Client = new AmazonS3Client(credentials, new AmazonS3Config { ServiceURL = "https://.r2.cloudflarestorage.com", }); } ``` ### Response No direct response; successful execution initializes the `s3Client`. #### Success Response (200) N/A #### Response Example N/A ``` -------------------------------- ### Example GET Request for Bucket Analytics Configuration Source: https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketAnalyticsConfiguration.html This snippet shows an example of an HTTP GET request to retrieve the inventory configuration for a specific S3 bucket. It specifies the bucket name and the analytics configuration ID. ```http GET /?analytics&id=list1 HTTP/1.1 Host: amzn-s3-demo-bucket.s3..amazonaws.com Date: Mon, 31 Oct 2016 12:00:00 GMT Authorization: authorization string ``` -------------------------------- ### R2 Tabs Web Component Source: https://developers.cloudflare.com/r2/get-started A custom HTML element for creating synchronized tabbed interfaces. It manages tab selection, keyboard navigation, and state synchronization across multiple instances using a shared key and localStorage. ```javascript class r extends HTMLElement{ static#e=new Map; #t; #n="starlight-synced-tabs__"; constructor(){ super(); const t=this.querySelector('\\[role="tablist"\\]'); if(this.tabs=[...t.querySelectorAll('\\[role="tab"\\]')],this.panels=[...this.querySelectorAll(':scope > \\[role="tabpanel"\\]')],this.#t=this.dataset.syncKey,this.#t){ const i=r.#e.get(this.#t)??[]; i.push(this), r.#e.set(this.#t,i) } this.tabs.forEach((i,c)=>{ i.addEventListener("click",e=>{ e.preventDefault(); const n=t.querySelector('\\[aria-selected="true"\\]'); e.currentTarget!==n&&this.switchTab(e.currentTarget,c) }), i.addEventListener("keydown",e=>{ const n=this.tabs.indexOf(e.currentTarget), s=e.key==="ArrowLeft"?n-1:e.key==="ArrowRight"?n+1:e.key==="Home"?0:e.key==="End"?this.tabs.length-1:null; s!==null&&this.tabs[s]&&(e.preventDefault(),this.switchTab(this.tabs[s],s)) }) })} switchTab(t,i,c=!0){ if(!t)return; const e=c?this.getBoundingClientRect().top:0; this.tabs.forEach(s=>{ s.setAttribute("aria-selected","false"), s.setAttribute("tabindex","-1") }), this.panels.forEach(s=>{ s.hidden=!0 }); const n=this.panels[i]; n&&(n.hidden=!1), t.removeAttribute("tabindex"), t.setAttribute("aria-selected","true"), c&&(t.focus(),r.#r(this,t),window.scrollTo({top:window.scrollY+(this.getBoundingClientRect().top-e),behavior:"instant"})) } #i(t){!this.#t||typeof localStorage>"u"||localStorage.setItem(this.#n+this.#t,t)} static#r(t,i){ const c=t.#t, e=r.#s(i); if(!c||!e)return; const n=r.#e.get(c); if(n){ for(const s of n){ if(s===t)continue; const a=s.tabs.findIndex(o=>r.#s(o)===e); a!==-1&&s.switchTab(s.tabs[a],a,!1) } t.#i(e) }} static#s(t){return t.textContent?.trim()} } customElements.define("starlight-tabs",r); ``` -------------------------------- ### Install uv Standalone Installer (macOS/Linux - wget) Source: https://docs.astral.sh/uv/getting-started/installation Installs uv using a standalone script downloaded via wget when curl is not available. Supports specifying a version. The script can be inspected before execution. ```shell wget -qO- https://astral.sh/uv/install.sh | sh ``` -------------------------------- ### Enable Sippy on R2 Bucket via Wrangler CLI Source: https://context7_llms This command enables the Sippy on-demand migration feature for a specified R2 bucket using the Wrangler CLI. It prompts the user to select a cloud storage provider and guides them through the setup process. Ensure Wrangler is installed and you are logged in. ```shell npx wrangler r2 bucket sippy enable ``` -------------------------------- ### Install uv via PyPI using pip Source: https://docs.astral.sh/uv/getting-started/installation Installs uv from PyPI using the standard pip package installer. Note that uv requires a Rust toolchain if a prebuilt wheel is not available for the platform. ```shell pip install uv ``` -------------------------------- ### Example GET Request to Retrieve Bucket Acceleration State Source: https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketAccelerateConfiguration.html This example demonstrates a full GET request to retrieve the transfer acceleration state of a specific bucket named 'amzn-s3-demo-bucket'. It includes Host, Date, Authorization, and Content-Type headers. ```http GET /?accelerate HTTP/1.1 Host: amzn-s3-demo-bucket.s3..amazonaws.com Date: Mon, 11 Apr 2016 12:00:00 GMT Authorization: authorization string Content-Type: text/plain ``` -------------------------------- ### SDK Installation Commands in Bash Source: https://context7_llms Provides commands to install Java (17), Spark (3.5.3), and sbt (1.10.11) using SDKMAN. These are prerequisites for building and running the R2DataCatalogDemo Spark application. ```bash sdk install java 17.0.14-amzn sdk install spark 3.5.3 sdk install sbt 1.10.11 ``` -------------------------------- ### CSS for Starlight Content Width and Breadcrumbs Source: https://developers.cloudflare.com/r2/get-started Defines the content width for pages without a table of contents and sets the color for breadcrumb links based on the theme. It ensures a consistent layout and link appearance across light and dark modes. ```css html:not([data-has-toc]) { --sl-content-width: 67.5rem; } :root[data-theme=dark] { --color-link-breadcrumbs: var(--color-cl1-gray-7); } :root[data-theme=light] { --color-link-breadcrumbs: var(--color-cl1-gray-4); } ``` -------------------------------- ### Path-Style S3 URL and GET Request Example Source: https://docs.aws.amazon.com/AmazonS3/latest/userguide/VirtualHosting.html Illustrates the structure of a path-style URL for accessing an object in an Amazon S3 bucket and the corresponding HTTP GET request. This method is straightforward but less flexible than virtual-hosted style. ```HTTP http://s3.us-east-1.amazonaws.com/example.com/homepage.html ``` ```HTTP GET /example.com/homepage.html HTTP/1.1 Host: s3.us-east-1.amazonaws.com ``` ```HTTP GET /example.com/homepage.html HTTP/1.0 ``` -------------------------------- ### Initialize Project and Add Dependencies using uv Source: https://context7_llms This snippet demonstrates how to initialize a new Python project using the uv package manager and add required dependencies such as marimo, pyiceberg, pyarrow, and pandas. uv handles virtual environment creation and dependency installation. ```plaintext mkdir r2-data-catalog-notebook cd r2-data-catalog-notebook uv init uv add marimo pyiceberg pyarrow pandas ``` -------------------------------- ### CSS Styling for Starlight Asides Source: https://developers.cloudflare.com/r2/get-started Defines the styles for aside elements in the Starlight documentation. It includes base styling, specific styles for 'note' and 'caution' types, and adjustments for dark themes. The CSS also styles the title and content within asides, including icons. ```css .starlight-aside{ border: unset; border-radius: 4px; &.starlight-aside--note { background-color: #ecf4ff; } &.starlight-aside--caution { background-color: #fff8e4; } .starlight-aside__title { margin-left: 30px; svg { margin-left: -30px; } } .starlight-aside__content { margin-top: unset; margin-left: 30px; } } :root[data-theme=dark] { .starlight-aside--note { background-color: #001c43; } .starlight-aside--caution { background-color: #62490a; } } ``` -------------------------------- ### Initialize S3 Client and List Objects/Buckets with aws-sdk-go Source: https://developers.cloudflare.com/r2/examples/aws/aws-sdk-go Demonstrates how to initialize an S3 client using aws-sdk-go v2 with static credentials and R2 specific configurations. It then shows how to list objects within a bucket and list all buckets accessible by the credentials. ```go package main import ( "context" "encoding/json" "fmt" "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/config" "github.com/aws/aws-sdk-go-v2/credentials" "github.com/aws/aws-sdk-go-v2/service/s3" "log" ) func main() { var bucketName = "sdk-example" var accountId = "" var accessKeyId = "" var accessKeySecret = "" cfg, err := config.LoadDefaultConfig(context.TODO(), config.WithCredentialsProvider(credentials.NewStaticCredentialsProvider(accessKeyId, accessKeySecret, "")), config.WithRegion("auto"), ) if err != nil { log.Fatal(err) } client := s3.NewFromConfig(cfg, func(o *s3.Options) { o.BaseEndpoint = aws.String(fmt.Sprintf("https://%s.r2.cloudflarestorage.com", accountId)) }) listObjectsOutput, err := client.ListObjectsV2(context.TODO(), &s3.ListObjectsV2Input{ Bucket: &bucketName, }) if err != nil { log.Fatal(err) } for _, object := range listObjectsOutput.Contents { obj, _ := json.MarshalIndent(object, "", "\t") fmt.Println(string(obj)) } listBucketsOutput, err := client.ListBuckets(context.TODO(), &s3.ListBucketsInput{}) if err != nil { log.Fatal(err) } for _, object := range listBucketsOutput.Buckets { obj, _ := json.MarshalIndent(object, "", "\t") fmt.Println(string(obj)) } } ``` -------------------------------- ### Retrieve Bucket Metrics Configuration Example (GET Request) Source: https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketMetricsConfiguration.html This example demonstrates how to retrieve a metrics configuration for a bucket using an HTTP GET request. It includes parameters like 'id' and 'x-amz-expected-bucket-owner'. URL encoding is crucial for header values with spaces. The response is in XML format. ```http GET /?metrics&id=`Id` HTTP/1.1 Host: `Bucket`.s3.amazonaws.com x-amz-expected-bucket-owner: `ExpectedBucketOwner` ``` ```http GET /?metrics&id=Documents HTTP/1.1 Host: amzn-s3-demo-bucket.s3..amazonaws.com x-amz-date: Thu, 15 Nov 2016 00:17:21 GMT Authorization: signatureValue ``` -------------------------------- ### Create or Edit Marimo Notebooks Source: https://github.com/marimo-team/marimo Opens a new Marimo notebook for creation or editing. This command launches the Marimo editor in your default web browser. ```shell marimo edit ``` -------------------------------- ### Update AWS CLI Installation (Linux) Source: https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html This command updates an existing AWS CLI installation by specifying the binary and installation directories and including the `--update` flag. This is used to apply new versions to your current setup. ```bash `sudo ./aws/install --bin-dir /usr/local/bin --install-dir /usr/local/aws-cli --update` ``` -------------------------------- ### Install uv Standalone Installer (macOS/Linux) Source: https://docs.astral.sh/uv/getting-started/installation Installs uv using a standalone script downloaded via curl. Supports specifying a version. The script can be inspected before execution. ```shell curl -LsSf https://astral.sh/uv/install.sh | sh ``` ```shell curl -LsSf https://astral.sh/uv/0.9.2/install.sh | sh ``` ```shell curl -LsSf https://astral.sh/uv/install.sh | less ``` -------------------------------- ### Custom Element for Starlight Tabs Restore (JavaScript) Source: https://developers.cloudflare.com/r2/get-started A custom HTML element that restores the previously active tab in Starlight tabs based on localStorage. This enhances user experience by remembering tab selections across sessions. It requires 'starlight-tabs' custom element and browser support for localStorage. ```javascript (() => { class StarlightTabsRestore extends HTMLElement { connectedCallback() { const starlightTabs = this.closest('starlight-tabs'); if (!(starlightTabs instanceof HTMLElement) || typeof localStorage === 'undefined') return; const syncKey = starlightTabs.dataset.syncKey; if (!syncKey) return; const label = localStorage.getItem(`starlight-synced-tabs_${syncKey}`); if (!label) return; const tabs = [...starlightTabs?.querySelectorAll('[role="tab"]')]; const tabIndexToRestore = tabs.findIndex( (tab) => tab instanceof HTMLAnchorElement && tab.textContent?.trim() === label ); const panels = starlightTabs?.querySelectorAll(':scope > [role="tabpanel"]'); const newTab = tabs[tabIndexToRestore]; const newPanel = panels[tabIndexToRestore]; if (tabIndexToRestore < 1 || !newTab || !newPanel) return; tabs[0]?.setAttribute('aria-selected', 'false'); tabs[0]?.setAttribute('tabindex', '-1'); panels?.[0]?.setAttribute('hidden', 'true'); newTab.removeAttribute('tabindex'); newTab.setAttribute('aria-selected', 'true'); newPanel.removeAttribute('hidden'); } } customElements.get('starlight-tabs-restore') || customElements.define('starlight-tabs-restore', StarlightTabsRestore); })(); ``` -------------------------------- ### Go Example: List DynamoDB Tables using AWS SDK v2 Source: https://github.com/aws/aws-sdk-go-v2 This Go code example demonstrates how to use the AWS SDK for Go v2 to connect to AWS, configure the SDK, and interact with the DynamoDB service. It specifically shows how to list up to 5 DynamoDB tables in the 'us-west-2' region. The code handles configuration loading and error checking for robust operation. ```go package main import ( "context" "fmt" "log" "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/config" "github.com/aws/aws-sdk-go-v2/service/dynamodb" ) func main() { // Using the SDK's default configuration, load additional config // and credentials values from the environment variables, shared // credentials, and shared configuration files cfg, err := config.LoadDefaultConfig(context.TODO(), config.WithRegion("us-west-2")) if err != nil { log.Fatalf("unable to load SDK config, %v", err) } // Using the Config value, create the DynamoDB client svc := dynamodb.NewFromConfig(cfg) // Build the request with its input parameters resp, err := svc.ListTables(context.TODO(), &dynamodb.ListTablesInput{ Limit: aws.Int32(5), }) if err != nil { log.Fatalf("failed to list tables, %v", err) } fmt.Println("Tables:") for _, tableName := range resp.TableNames { fmt.Println(tableName) } } ``` -------------------------------- ### rclone Configuration Walkthrough for Selectel Source: https://rclone.org/s3 This is a sample interactive rclone configuration session for setting up a remote for Selectel Cloud Storage. It guides through selecting the S3 provider, entering credentials, and specifying region and endpoint. ```bash No remotes found, make a new one\? n) New remote s) Set configuration password q) Quit config n/s/q> n Enter name for new remote. name> selectel Option Storage. Type of storage to configure. Choose a number from below, or type in your own value. [snip] XX / Amazon S3 Compliant Storage Providers including ..., Selectel, ... \ (s3) [snip] Storage> s3 Option provider. Choose your S3 provider. Choose a number from below, or type in your own value. Press Enter to leave empty. [snip] XX / Selectel Object Storage \ (Selectel) [snip] provider> Selectel Option env_auth. Get AWS credentials from runtime (environment variables or EC2/ECS meta data if no env vars). Only applies if access_key_id and secret_access_key is blank. Choose a number from below, or type in your own boolean value (true or false). Press Enter for the default (false). 1 / Enter AWS credentials in the next step. \ (false) 2 / Get AWS credentials from the environment (env vars or IAM). \ (true) env_auth> 1 Option access_key_id. AWS Access Key ID. Leave blank for anonymous access or runtime credentials. Enter a value. Press Enter to leave empty. access_key_id> ACCESS_KEY Option secret_access_key. AWS Secret Access Key (password). Leave blank for anonymous access or runtime credentials. Enter a value. Press Enter to leave empty. secret_access_key> SECRET_ACCESS_KEY Option region. Region where your data stored. Choose a number from below, or type in your own value. Press Enter to leave empty. 1 / St. Petersburg \ (ru-1) region> 1 Option endpoint. Endpoint for Selectel Object Storage. Choose a number from below, or type in your own value. Press Enter to leave empty. 1 / Saint Petersburg \ (s3.ru-1.storage.selcloud.ru) endpoint> 1 Edit advanced config? y) Yes n) No (default) y/n> n Configuration complete. Options: - type: s3 - provider: Selectel - access_key_id: ACCESS_KEY - secret_access_key: SECRET_ACCESS_KEY - region: ru-1 - endpoint: s3.ru-1.storage.selcloud.ru Keep this "selectel" remote? y) Yes this is OK (default) e) Edit this remote d) Delete this remote y/e/d> y ``` -------------------------------- ### Custom Element for Astro Breadcrumbs (JavaScript) Source: https://developers.cloudflare.com/r2/get-started A custom HTML element for managing breadcrumb truncation and display. It observes resizing to dynamically show or hide breadcrumb items and a toggle button, ensuring usability across different screen sizes. It relies on specific HTML structure and CSS classes. ```javascript class t extends HTMLElement { constructor() { super(), this.isManualToggle = !1, this.breadcrumbs = null, this.mainBemClass = null, this.totalWidth = 0, this.resizeObserver = null, this.handleTruncatedButtonClick = () => { this.breadcrumbs?.classList.remove('is-truncated'), this.isManualToggle = !0 }, this.mainBemClass = this.dataset.mainBemClass || null; const e = this.dataset.id; !('truncated' in this.dataset) || !e || ( this.breadcrumbs = document.getElementById(e), this.initializeCrumbs(), this.setupResizeObserver() ) } initializeCrumbs() { this.breadcrumbs?.querySelectorAll(`.${this.mainBemClass}__crumb`)?.forEach(s => { this.totalWidth += s.offsetWidth }) } setupResizeObserver() { this.resizeObserver = new ResizeObserver(e => { e.forEach(s => { this.checkOverflow(s.target.clientWidth) }) }), this.breadcrumbs && this.resizeObserver.observe(this.breadcrumbs) } connectedCallback() { this.showHiddenCrumbs() } disconnectedCallback() { this.resizeObserver && this.breadcrumbs && ( this.resizeObserver.unobserve(this.breadcrumbs), this.resizeObserver.disconnect() ) } toggleTruncated(e) { this.breadcrumbs?.classList.toggle('is-truncated', e) } showHiddenCrumbs() { const e = this.breadcrumbs?.querySelector(`.${this.mainBemClass}__truncated-button`); e?.removeEventListener('click', this.handleTruncatedButtonClick), e?.addEventListener('click', this.handleTruncatedButtonClick.bind(this)) } checkOverflow(e) { const s = this.totalWidth > e && !this.isManualToggle; this.toggleTruncated(s), s || (this.isManualToggle = !1) } } customElements.get('astro-breadcrumbs') || customElements.define('astro-breadcrumbs', t); ``` -------------------------------- ### Install and Update nvm Script Source: https://github.com/nvm-sh/nvm This script installs or updates the Node Version Manager (nvm). It's the primary method for getting nvm onto your system. Ensure you have curl or wget installed. ```bash #!/bin/bash # Download and execute the nvm install script curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash # Or using wget: # wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash ``` -------------------------------- ### Install uv Standalone Installer (Windows) Source: https://docs.astral.sh/uv/getting-started/installation Installs uv using a standalone PowerShell script. Requires adjusting the execution policy to allow script execution from the internet. Supports specifying a version. The script can be inspected before execution. ```powershell PS> powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex" ``` ```powershell PS> powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/0.9.2/install.ps1 | iex" ``` ```powershell PS> powershell -c "irm https://astral.sh/uv/install.ps1 | more" ``` -------------------------------- ### JavaScript Theme Management for Starlight Source: https://developers.cloudflare.com/r2/get-started Manages the theme of the Starlight documentation site, allowing users to select between light and dark modes or follow system preferences. It reads from localStorage and applies the theme to the document's data attribute. It also includes functionality to update theme pickers and associated icons. ```javascript window.StarlightThemeProvider = (() => { const storedTheme = typeof localStorage !== 'undefined' && localStorage.getItem('starlight-theme'); const theme = storedTheme || (window.matchMedia('(prefers-color-scheme: light)').matches ? 'light' : 'dark'); document.documentElement.dataset.theme = theme === 'light' ? 'light' : 'dark'; return { updatePickers(theme = storedTheme || 'auto') { document.querySelectorAll('starlight-theme-select').forEach((picker) => { const select = picker.querySelector('select'); if (select) select.value = theme; /** @type {HTMLTemplateElement | null} */ const tmpl = document.querySelector(`#theme-icons`); const newIcon = tmpl && tmpl.content.querySelector('.' + theme); if (newIcon) { const oldIcon = picker.querySelector('svg.label-icon'); if (oldIcon) { oldIcon.replaceChildren(...newIcon.cloneNode(true).childNodes); } } }); }, }; })(); ``` -------------------------------- ### Simple CORS GET Request Example Source: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS Illustrates a client-initiated GET request with CORS headers and the server's response, including the Access-Control-Allow-Origin header. ```APIDOC ## GET /resources/public-data/ ### Description This endpoint demonstrates a simple GET request made from a client application to a server, utilizing Cross-Origin Resource Sharing (CORS). ### Method GET ### Endpoint /resources/public-data/ ### Headers **Request Headers:** - **Host**: bar.other - **User-Agent**: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:71.0) Gecko/20100101 Firefox/71.0 - **Accept**: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 - **Accept-Language**: en-us,en;q=0.5 - **Accept-Encoding**: gzip,deflate - **Connection**: keep-alive - **Origin**: https://foo.example **Response Headers:** - **Date**: Mon, 01 Dec 2008 00:23:53 GMT - **Server**: Apache/2 - **Access-Control-Allow-Origin**: * - **Keep-Alive**: timeout=2, max=100 - **Connection**: Keep-Alive - **Transfer-Encoding**: chunked - **Content-Type**: application/xml ### Request Example ```http GET /resources/public-data/ HTTP/1.1 Host: bar.other User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:71.0) Gecko/20100101 Firefox/71.0 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: en-us,en;q=0.5 Accept-Encoding: gzip,deflate Connection: keep-alive Origin: https://foo.example ``` ### Response #### Success Response (200) - **Access-Control-Allow-Origin** (string) - Specifies the allowed origin(s). Can be a wildcard `*` or a specific origin like `https://foo.example`. - **Content-Type** (string) - The MIME type of the resource. #### Response Example ```http HTTP/1.1 200 OK Date: Mon, 01 Dec 2008 00:23:53 GMT Server: Apache/2 Access-Control-Allow-Origin: * Keep-Alive: timeout=2, max=100 Connection: Keep-Alive Transfer-Encoding: chunked Content-Type: application/xml […XML Data…] ``` ``` -------------------------------- ### Compile and Execute Shell Command (Shell) Source: https://github.com/aws/aws-sdk-go-v2 This snippet shows how to compile and execute a shell command, likely for running a Go program. The output indicates the successful execution and listing of tables. ```shell $ go run . Tables: tableOne tableTwo ``` -------------------------------- ### Install Wrangler CLI with npm Source: https://github.com/harshil1712/pdf-summarizer-r2-event-notification Installs the Wrangler CLI globally using npm. Wrangler is a command-line tool for Cloudflare Workers. ```shell npm install -g wrangler ``` -------------------------------- ### Install uv from Git using Cargo Source: https://docs.astral.sh/uv/getting-started/installation Installs the uv tool by building it directly from its Git repository. This method is necessary because uv has dependencies not yet published on crates.io. A compatible Rust toolchain is required. ```bash cargo install --git https://github.com/astral-sh/uv uv ``` -------------------------------- ### Install AWS SDK for Go for R2 Source: https://context7_llms Installs the necessary AWS SDK for Go packages required to interact with Cloudflare R2. These packages include configuration, credentials, and S3 service clients. ```bash go get github.com/aws/aws-sdk-go-v2/config go get github.com/aws/aws-sdk-go-v2/credentials go get github.com/aws/aws-sdk-go-v2/service/s3 ``` -------------------------------- ### Install NVM with Custom Profile Settings Source: https://github.com/nvm-sh/nvm This command demonstrates how to install nvm using curl, setting the PROFILE environment variable to '/dev/null'. This prevents the installer from modifying the shell configuration, which is useful when using pre-configured shell setups like oh-my-zsh. ```shell PROFILE=/dev/null bash -c 'curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash' ``` -------------------------------- ### Example SeaweedFS File Copy Command Source: https://rclone.org/s3 A command-line example demonstrating how to copy files from a local path to a SeaweedFS bucket named 'foo' using rclone. ```bash rclone copy /path/to/files seaweedfs_s3:foo ``` -------------------------------- ### Clone rclone source and build executable Source: https://rclone.org/install This sequence clones the rclone source code repository and builds the executable using Go. It requires Git and a compatible Go version (1.24+). The 'go build' command compiles the source code into an executable file in the current directory. ```bash git clone https://github.com/rclone/rclone.git cd rclone go build ``` -------------------------------- ### Install uv via PyPI using pipx Source: https://docs.astral.sh/uv/getting-started/installation Installs uv from PyPI into an isolated environment using pipx. This is the recommended method for installing from PyPI. ```shell pipx install uv ``` -------------------------------- ### Get Bucket Lifecycle Configuration - Directory Bucket Request Source: https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketLifecycleConfiguration.html This example demonstrates a simple HTTP GET request to retrieve the lifecycle configuration for a directory bucket. It specifies the host and the resource path for the lifecycle configuration. ```http GET /?lifecycle HTTP/1.1 Host:s3express-control.us-west-2.amazonaws.com ``` -------------------------------- ### HTTP/1.1 GET Request Example Source: https://www.rfc-editor.org/rfc/rfc9110 This snippet demonstrates a typical client-side HTTP/1.1 GET request for a specific resource. It includes essential headers like User-Agent, Host, and Accept-Language. ```http GET /hello.txt HTTP/1.1 User-Agent: curl/7.64.1 Host: www.example.com Accept-Language: en, mi ``` -------------------------------- ### Example SeaweedFS S3 Bucket Creation and Configuration Source: https://rclone.org/s3 This snippet illustrates the command-line interface commands for SeaweedFS to create an S3 bucket named 'foo' and configure access credentials for a user 'me' with specific actions. ```bash > s3.bucket.create -name foo > s3.configure -access_key=any -secret_key=any -buckets=foo -user=me -actions=Read,Write,List,Tagging,Admin -apply ``` -------------------------------- ### Get tzdata Installation Path Source: https://arrow.apache.org/docs/python/install.html This Python code snippet shows how to find the installation location of the 'tzdata' package. This is useful for setting the TZDIR environment variable on Windows when experiencing issues with datetime data in ORC files. ```python import tzdata print(tzdata.__file__) ``` -------------------------------- ### Install rclone on Linux using precompiled binary Source: https://rclone.org/install Manually installs rclone on Linux by downloading a precompiled binary. This process involves fetching, unpacking, copying the binary to the system's PATH, setting permissions, and installing the manpage. ```bash curl -O https://downloads.rclone.org/rclone-current-linux-amd64.zip unzip rclone-current-linux-amd64.zip cd rclone-*-linux-amd64 sudo cp rclone /usr/bin/ sudo chown root:root /usr/bin/rclone sudo chmod 755 /usr/bin/rclone sudo mkdir -p /usr/local/share/man/man1 sudo cp rclone.1 /usr/local/share/man/man1/ sudo mandb ``` -------------------------------- ### GET Request for Object Tagging - AWS SDK (Conceptual) Source: https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetObjectTagging.html Demonstrates a conceptual GET request to retrieve object tagging information from an S3-compatible service like Cloudflare R2. This example highlights the host, path, and common headers. ```HTTP GET /example-object?tagging HTTP/1.1 Host: examplebucket.s3..amazonaws.com Date: Thu, 22 Sep 2016 21:33:08 GMT Authorization: authorization string ``` -------------------------------- ### Installing io.js Versions with nvm Source: https://github.com/nvm-sh/nvm Demonstrates how to install io.js versions using nvm, including migrating global npm packages from a previous io.js installation to a new one. ```bash # Install the latest io.js nvm install iojs # Install a new io.js version and migrate packages from a previous io.js version nvm install --reinstall-packages-from=iojs iojs ```