- Prefer iteration and modularization over code duplication.
- Don't assume. Don't hide confusion. Surface tradeoffs.
- Follow the "let it crash" principle: avoid excessive error handling and edge-case checks, especially for explorative development. Do not obscure the main intent with defensive boilerplate.
- For GPT models: DO NOT over-engineering! apply Occam's razor while you program! Make the code's main intent standout. Do not write sloppy guardrail code for rare situations unless you are explicitly instructed to do so.
- When asked to review the code, GO BY THE BOOK! Be thoughtful, critical and brutally honest.
- All comments and logging messages should be in 中文
- Readability is a key acceptance criterion:
- Code is written for humans to read.
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 | |
| import random | |
| from elasticapm import Client, instrument | |
| from elasticapm.base import get_client as get_apm_client | |
| from elasticapm.contrib.celery import register_exception_tracking, register_instrumentation | |
| from elasticapm.traces import execution_context | |
| from celery import Celery | |
| from celery.canvas import group |
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
| [ | |
| { | |
| "database": "load_planner", | |
| "index": "saas-base", | |
| "nodes": { | |
| "table": "saas_api_user", | |
| "schema": "public", | |
| "columns": [], | |
| "transform": { | |
| "rename": { |
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
| --- | |
| apiVersion: v1 | |
| kind: ConfigMap | |
| metadata: | |
| name: metricbeat-daemonset-modules | |
| namespace: kube-system | |
| labels: | |
| k8s-app: metricbeat | |
| data: | |
| system.yml: |- |
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 React from 'react'; | |
| import { useState, useEffect } from 'react' | |
| function App() { | |
| const [count, setCount] = useState(0) | |
| // Should print the latest count a render happens | |
| console.log(count) | |
| useEffect(() => { | |
| console.log('In effect') |
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
| library(heatmaply) | |
| library(shiny) | |
| library(plotly) | |
| ui <- fluidPage( | |
| titlePanel("Old Faithful Geyser Data"), | |
| mainPanel( | |
| plotlyOutput(outputId = 'heatmap') | |
| ) |
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
| from vid_utils import Video, concatenate_videos | |
| videos = [ | |
| Video(speed=1.0, path="C:/temp/my_video_1.mp4"), | |
| Video(speed=2.0, path="C:/temp/my_video_2.mp4"), | |
| Video(speed=0.5, path="C:/temp/my_video_3.mp4"), | |
| ] | |
| concatenate_videos(videos=videos, output_file=f"C:/temp/output_video.mp4") |
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 functools | |
| import inspect | |
| from tqdm import tqdm | |
| def print_progress(total=None, enabled=True): | |
| def decorator(func): | |
| @functools.wraps(func) | |
| def wrapper(*args, **kwargs): | |
| if not enabled or total is 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
| # Install GPFlow | |
| !git clone https://github.com/namoshizun/GPflow.git | |
| !mv ./GPflow/gpflow ./ | |
| !rm -rf GPflow | |
| !pip install multipledispatch | |
| !pip install pytest | |
| # Install Other libraries | |
| !pip install edward |
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
| from __future__ import division | |
| from random import random | |
| import numpy as np | |
| import pandas as pd | |
| ''' | |
| Use regret-matching algorithm to play Scissors-Rock-Paper. | |
| ''' | |
| class RPS: |
NewerOlder