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
| /* | |
| * We want to be able to define new operations without having to add a new method | |
| * to each class every time. | |
| * | |
| * The Visitor pattern lets you execute an operation over a set of objects with | |
| * different classes by having a visitor object implement several variants of | |
| * the same operation, which correspond to all target classes. | |
| */ | |
| abstract class Figure { |
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
| /* | |
| |-- | |
| |-- | |
| |-- | |
| |-- | |
| |-- | |
| |-- | |
| |-- |
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 'dart:io'; | |
| import 'dart:async'; | |
| import 'package:http/http.dart' as http; | |
| import 'package:rxdart/rxdart.dart'; | |
| import 'package:green_way/shared/utils.dart'; | |
| import 'package:green_way/shared/constants.dart'; | |
| class FilesLoaderRepository { |
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
| /// Using binary search | |
| // [6, 7, 8, 9, 11, 13, 15, 0, 1, 2] | |
| function findPivot(nums) { | |
| let l = 0; | |
| let r = nums.length - 1; | |
| if (nums[l] < nums[r]) return 0; |
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
| function fourSum(nums: number[], target: number) { | |
| nums.sort((a, b) => a - b); | |
| let res: any = [], quad: any = []; | |
| // NOTE: better to use inner func since it has access to nums | |
| const kSum = (k, start, target) => { | |
| if (k != 2) { | |
| for (let i = start; i < nums.length - k + 1; i++) { | |
| if (i > start && nums[i - 1] == nums[i]) continue; |
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 'package:flutter/material.dart'; | |
| import 'package:go_router/go_router.dart'; | |
| main() { | |
| CustomNavigationHelper.instance; | |
| runApp(const App()); | |
| } | |
| class App extends StatelessWidget { | |
| const App({Key? key}) : super(key: key); |
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
| # Task 1. | |
| # Find the arithmetic mean of the list | |
| # 1.a -> find the sum of list | |
| # 1.b -> divide sum by list len | |
| # 1.c -> print result | |
| # | |
| # list = [13, 9, 14, 8, 100, 212, 57] | |
| # expected result: 59 | |
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
| (function() { | |
| function sleep(ms) { | |
| return new Promise(resolve => setTimeout(resolve, ms)); | |
| } | |
| async function* infiniteProcessing() { | |
| while (true) { | |
| await sleep(3000); | |
| yield Math.random(); | |
| } |
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
| * * * * * * * * * * * * Rendering Engine * * * * * * * * * * * * | |
| * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * | |
| 1. Constructing the DOM Tree | |
| 2. Constructing the CSSOM Tree |
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
| type Foo<T> = T extends { a: infer U, b: infer U } ? U : never; | |
| type T10 = Foo<{ a: string, b: string }>; // string | |
| type T11 = Foo<{ a: string, b: number }>; // string | number | |
| type T22 = Foo<{ a: string }>; // never | |
| /* * . * . * . * Type Systems vs Shapes * . * . * . */ |
NewerOlder