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 'dart:async'; | |
class Observable { | |
Function subscriberFunction; | |
Observable(this.subscriberFunction); | |
subscribe(observer) { | |
this.subscriberFunction(observer); | |
} |
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 'dart:html'; | |
class Storage { | |
Map db = {'count': 0}; | |
Map deps = {'count': []}; | |
void add(String key, dynamic value) { | |
db[key] = value; | |
} |
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
# pip install click | |
import click | |
import os | |
@click.command() | |
@click.option('--watch', is_flag=True, help='Watch file changes during build.') | |
@click.option('--restart', is_flag=True, help='Delete conflicting outputs.') | |
def generate(**kwargs): | |
'''Run build_runner source code generation''' |
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
Iterable<int> inner() sync* { | |
for (final i in [4, 5, 6]) { | |
yield i; | |
} | |
} | |
Iterable<int> outer() sync* { | |
for (final i in [1, 2, 3]) { | |
yield i; | |
} |
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
{ | |
"react functional component": { | |
"prefix": "rfc", | |
"body": [ | |
"export const ${TM_FILENAME_BASE/(\\w)/${1:/upcase}/}: React.FC = () => {", | |
" return <>$0</>", | |
"}" | |
], | |
"description": "react functional component" | |
}, |
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
// difference between and_then vs map for `Option` | |
fn increment(n: i32) -> Option<i32> { | |
Some(n).map(|x| x + 1) | |
} | |
fn main() { | |
let one = Some(1); | |
let four = one | |
.map(|one| one + 1) |
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 'dart:async'; | |
import 'dart:convert'; | |
import 'dart:io' as io; | |
/// Reads a single line from [stdin] asynchronously. | |
Future<String> readLine() async { | |
final c = Completer<String>(); // completer | |
final l = io.stdin // stdin | |
.transform(utf8.decoder) // decode | |
.transform(const LineSplitter()) // split line |
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
@font-face { | |
font-family: 'Inter Fallback'; | |
src: local('Arial'); | |
ascent-override: 90%; | |
descent-override: 22.43%; | |
line-gap-override: 0%; | |
size-adjust: 107.64%; | |
} | |
@font-face { |
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 {Module, Inject, Injectable, ConfigurableModuleBuilder} from '@nestjs/common' | |
const {ConfigurableModuleClass, MODULE_OPTIONS_TOKEN} = new ConfigurableModuleBuilder<unknown>().build() | |
@Injectable() | |
class DropperService<T> { | |
constructor(@Inject(MODULE_OPTIONS_TOKEN) private readonly value: T) {} | |
drop(): T { | |
return this.value |
OlderNewer