Skip to content

Instantly share code, notes, and snippets.

NodeJS: Streams with (almost) real life examples

General idea

Basic idea of stream in software engineering implies existence of a data source and some destination entity to which the stream should output processed data. Simple bash example below should demonstrate how to get a list of all files with .js extension in a current working directory:

ls -la | grep ".js$"
interface IParticipant {
name: string;
}
interface IMatch {
host: string;
visitor: string;
}
type Participants = IParticipant[];
@dzzzchhh
dzzzchhh / scheduling.py
Last active July 30, 2020 09:52
tournament scheduling in python
participants = [
"Mike",
"Larry",
"Scottie",
"Dennis",
"Patrick",
"Kareem",
"Yao",
"Shaq"
]
@dzzzchhh
dzzzchhh / init.el
Last active May 26, 2021 11:13
init.el on top of prelude
(global-set-key (kbd "C-c C-s") 'avy-goto-char)
(global-set-key (kbd "C-c C-e") 'ace-delete-window)
(global-set-key (kbd "C-<f4>") 'delete-window)
(global-set-key (kbd "<f8>") 'magit)
(global-set-key (kbd "<f9>") 'docker-containers)
(add-hook 'js2-mode-hook 'prettier-js-mode)
(add-hook 'web-mode-hook 'prettier-js-mode)
(add-hook 'jsx-mode-hook 'prettier-js-mode)
(add-hook 'javascript-mode 'prettier-js-mode)
@dzzzchhh
dzzzchhh / dynamo.go
Created January 31, 2022 16:47
AWS DynamoDB in go (example)
package main
import (
"context"
"fmt"
"log"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/service/dynamodb"
"github.com/aws/aws-sdk-go-v2/service/dynamodb/types"
@dzzzchhh
dzzzchhh / example.el
Created April 26, 2022 04:00
list item as input
(setq work-duration (ivy-completing-read "Select amount of hours spent: "
(mapcar 'number-to-string (number-sequence 0.5 8 0.5))))
set -Ux dzch_gui_text_editor kate
function dzch-deep-read
fd $argv[1] -tf -X $dzch_gui_text_editor
end
function dzch-deep-rm
fd $argv[1] -tf -X rm
end
@dzzzchhh
dzzzchhh / ffmpeg-screencast.sh
Last active June 9, 2022 09:15
Linux - capture your screen with mic audio
ffmpeg -video_size 3840x2160 -framerate 60 -f x11grab -i $DISPLAY -f pulse -ac 2 -i default output.mkv
# packs a folder into a tarball
function pack
read -l -P 'Please provide the output tarball name (without extension): ' tarball_name
tar -czvf $tarball_name.tgz $argv[1]
end