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
def cool(): | |
n = 0 | |
while True: | |
delta = yield n | |
if delta is not None: | |
n += delta | |
else: | |
n += 1 |
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 asyncio | |
import time | |
import random | |
from collections.abc import Callable | |
def roll(dice: int = 1, sides: int = 6) -> int: | |
total = 0 | |
for _ in range(dice): | |
total += random.randint(1, sides) |
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 heapq | |
from collections import deque | |
def switch(): | |
return Awaitable() | |
class Awaitable: |
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 docker | |
from docker.models.containers import Container | |
keep_container = False | |
docker_client = docker.from_env() | |
def wait_healthy(container_name): |
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
use std::rc::Rc; | |
pub enum List<T> { | |
Node { value: T, next: Rc<List<T>> }, | |
Empty, | |
} | |
impl <T> List<T> { | |
pub fn empty() -> Self { | |
List::Empty |
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
// iterators2.rs | |
// In this exercise, you'll learn some of the unique advantages that iterators | |
// can offer. Follow the steps to complete the exercise. | |
// Execute `rustlings hint iterators2` or use the `hint` watch subcommand for a hint. | |
// Step 1. | |
// Complete the `capitalize_first` function. | |
// "hello" -> "Hello" | |
pub fn capitalize_first(input: &str) -> String { | |
let mut c = input.chars(); |
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
// errors6.rs | |
// Using catch-all error types like `Box<dyn error::Error>` isn't recommended | |
// for library code, where callers might want to make decisions based on the | |
// error content, instead of printing it out or propagating it further. Here, | |
// we define a custom error type to make it possible for callers to decide | |
// what to do next when our function returns an error. | |
// Execute `rustlings hint errors6` or use the `hint` watch subcommand for a hint. |
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
{ | |
"$help": "https://aka.ms/terminal-documentation", | |
"$schema": "https://aka.ms/terminal-profiles-schema", | |
"actions": [], | |
"defaultProfile": "{00000000-0000-0000-ba54-000000000002}", | |
"profiles": | |
{ | |
"defaults": | |
{ | |
"antialiasingMode": "cleartype", |
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 math import pi | |
import bpy | |
import os | |
import copy | |
# export to blend file location | |
dirname = os.path.dirname | |
basedir = dirname(dirname(dirname(bpy.data.filepath))) | |
export_dir = os.path.join(basedir, "Assets", "Models") |
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
package merge | |
import ( | |
"testing" | |
) | |
func TestMergeTables(t *testing.T) { | |
alice := Table[string, *additive]{ | |
"vanilla": add(3), | |
"chocolate": add(5), |
NewerOlder