Skip to content

Instantly share code, notes, and snippets.

@zolotyh
zolotyh / index.js
Created September 4, 2019 13:41
Что этот код делает и что в этом коде не так.
'use strict'
const fs = require('fs').promises;
function write(){
return fs.mkdir('./tmp').then(function(){
fs.writeFile('./tmp/foo.txt', 'Hello World');
}).catch((err) => {
/// handle error
console.log(err);
@zolotyh
zolotyh / index.js
Created September 4, 2019 13:40
В каком порядке выведутся цифры и почему?
document.querySelector('body').addEventListener('click', () => console.log(1));
setTimeout(() => console.log(2), 0);
for (var i = 0; i < 1000000000000; i++) {/*code*/}
console.log(3);
FROM google/dart:2.4
WORKDIR /app
ADD pubspec.* /app/
ENV PATH="$PATH":"$HOME/.pub-cache/bin"
RUN pub global activate webdev
RUN pub get
ADD . /app
RUN pub get --offline
void main(){
print((new TestClass() as dynamic).test());
}
class TestClass {
@override
noSuchMethod(Invocation invocation){
print(1231231);
}
}
import 'dart:async';
import 'dart:io';
void main() async {
var controller = StreamController<int>.broadcast();
controller.stream.listen(print);
controller.stream.listen(print);
import 'dart:io';
void main() {
Directory.current.list().where((FileSystemEntity i) => i is Directory).map((i) => "path $i").listen((i){ stdout.writeln(i); });
}
import 'dart:async';
import 'dart:io';
void main() async {
try {
await Directory('temp').create();
await File('temp/temp').create();
} catch(e){
}
Iterable<BigInt> getFibIterator() sync* {
var initial = true;
BigInt prev = null;
BigInt beforePrev = BigInt.from(1);
while(true){
if(initial && prev == null){
initial = false;
prev = BigInt.from(0);
yield BigInt.from(0);
} else {
void main(){
print(fib(5));
print(fibCached(100));
}
int fib(input) {
if (input == 0) {
return 0;
} else if (input == 1) {
return 1;
void main(){
final bar2= Bar2();
assert(bar2.bar1 =='test1');
assert(bar2.bar1 =='test2');
final bar = Bar('test1');
assert(bar.bar1 == 'test1');
assert(bar.bar2 == 'test2');
}