This file contains 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 numpy as np | |
print("List comprehensions") | |
print([x**2 for x in range(10) if x % 2 == 0]) | |
print("Nested list comprehensions") | |
matrix = [ | |
[1, 2, 3, 4], | |
[5, 6, 7, 8], | |
[9, 10, 11, 12], |
This file contains 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
{ | |
"name": "optional-deps-demo", | |
"version": "1.0.0", | |
"optionalDependencies": { | |
"@esbuild/darwin-arm64": "^0.18.16", | |
"@esbuild/win32-x64": "^0.18.16" | |
} | |
} |
This file contains 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
type Width = number; | |
type Height = number; | |
type AspectRatio = [Width, Height]; | |
type LowerUpperBounds = [number, number]; | |
function unreachable(): never { | |
throw new Error("unreachable!"); | |
} | |
function calculate(width: number, height: number, options: { ratioRange: LowerUpperBounds }): AspectRatio { |
This file contains 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 { useForm, Controller } from 'react-hook-form'; | |
import { zodResolver } from '@hookform/resolvers/zod'; | |
import * as z from 'zod'; | |
const schema = z.object({ | |
name: z.string().min(1, { message: 'Required' }).url(), | |
age: z.coerce | |
.number() | |
.default(0) | |
.refine( |
This file contains 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
/** | |
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode#strict_mode_for_modules | |
* @param a | |
* @param b | |
*/ | |
function esmIsStrictByDefault(a: number, b = 2) { | |
return a + b; | |
} | |
/** |
This file contains 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
function greet(name) { | |
const prefix = "hello"; | |
return prefix + " " + name; | |
} |
This file contains 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
using System; | |
using System.Collections.Generic; | |
using System.Reflection.Metadata.Ecma335; | |
namespace CovariantContravariant | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ |
This file contains 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
#[derive(Copy, Clone)] | |
struct Foo { | |
val: i32, | |
} | |
impl Foo { | |
fn new(val: i32) -> Self { | |
Foo { val } | |
} | |
} |
This file contains 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
// https://youtu.be/m40cF91F8_A | |
interface Observer<T> { | |
next: (value: T) => void; | |
error: (error: any) => void; | |
complete: () => void; | |
} | |
interface Unsubscriable { | |
unsubscribe: () => void; |
This file contains 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
.box { | |
width: 300px; | |
height: 250px; | |
background-color: cornflowerblue; | |
transition: 0.5s background-color; | |
background-size: cover; | |
background-position: center; | |
} |
NewerOlder