This Tutorial moved to here: https://github.com/stavalfi/lectures/tree/master/Java%20Streams%20-%20Series
All the methods and the documentation are taken from lodash docs
Manipulating collections using functional and declerative code.
The following exercises are for experimenting and learning Redux. Do not use any external library except rxjs
(it's optional and recommended).
Documentations:
Write your allocator. Allocate a big block of bytes and manage its allocations and deallocations by your self. For example, allocate an array of 20,000
bytes and divide it into 10 cells such that each cell contains 2,000
bytes. The user can allocate and free cells of 2,000
bytes whenever he wants.
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 WebSocket from 'ws' | |
function throttle<T>(callback: (message: T) => Promise<void>, interval = 1000): (message: T) => Promise<void> { | |
return (message: T) => Promise.resolve() | |
} | |
interface Message { | |
type: string | |
content: string | |
} |
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
// must have: redis-cli, redis-server executables | |
// need npm modules: @stavalfi/create-folder-structure, execa, lodash | |
// tested on node 14. | |
// RUN single instance: `ts-node <file-name>.ts 1` | |
// RUN cluster of masters only: `ts-node <file-name>.ts 3` // can be 3+ | |
// close with ctrl+c. make sure ports are closed after that as well. | |
/////////////////// |
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
// this is just part of the code: | |
// based on iordis client in NodeJS | |
const [[error, result]] = await client.multi([['slowlog', 'get', '-1']]).exec() | |
if (error) { | |
throw error | |
} | |
const slowLogs = result as [id: number, ts: number, executionTime: number, command: string[]][] | |
const descOrder = slowLogs.sort((a, b) => b[2] - a[2]) | |
for (const slowLog of descOrder) { |
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
if status is-interactive | |
# Commands to run in interactive sessions can go here | |
end | |
fnm env | source | |
secrethub completion fish | source | |
set PATH $HOME/.cargo/bin /Users/stavalfi/.fnm/node-versions/v14.18.1/installation/bin $PATH | |
alias config.fish "code ~/.config/fish/config.fish" | |
alias config.vimrc "code ~/.vimrc" | |
alias crw "cargo watch -qcx 'run -q'" |