Is mocking really useful? (Betteridge says hello)
https://blog.boot.dev/clean-code/writing-good-unit-tests-dont-mock-database-connections
What is mocking? I like to call it the process of simulating a dependency in unit-tests in order to test the logic dependent on it.
It sounds good at first, but should you be mocking your dependencies? Or is there a better way? The article above shares a good view on these questions
https://blog.boot.dev/clean-code/writing-good-unit-tests-dont-mock-database-connections
What is mocking? I like to call it the process of simulating a dependency in unit-tests in order to test the logic dependent on it.
It sounds good at first, but should you be mocking your dependencies? Or is there a better way? The article above shares a good view on these questions
What are #cache memories? and how do they improve performance?
https://ecomputertips.com/what-is-cache-memory/
And now that you know about that, what are cache lines?
https://ecomputertips.com/cache-line/
https://ecomputertips.com/what-is-cache-memory/
And now that you know about that, what are cache lines?
https://ecomputertips.com/cache-line/
Accio
Photo
And at the end, how did rust improved its performance by improving cache access for CPU?
https://codspeed.io/blog/rust-1-78-performance-impact-of-the-128-bit-memory-alignment-fix
Basically they improved memory alignments in a way that the CPU has to read fewer cache-lines in some scenarios.
https://codspeed.io/blog/rust-1-78-performance-impact-of-the-128-bit-memory-alignment-fix
Basically they improved memory alignments in a way that the CPU has to read fewer cache-lines in some scenarios.
If you've been doing typescript for a while this could be interesting:
https://effect.website/
Effect introduces a new way to write typescript applications. it's mostly famous for its error handling method, basically there isn't any throw/try/catch. Errors are considered values and this usually results in safer programs
https://effect.website/
Effect introduces a new way to write typescript applications. it's mostly famous for its error handling method, basically there isn't any throw/try/catch. Errors are considered values and this usually results in safer programs
effect.website
Effect – The best way to build robust apps in TypeScript
Effect is a powerful TypeScript library designed to help developers easily create complex, synchronous, and asynchronous programs.
Accio
Footage from: Conway's game of life
Celluar automaton
A very simple yet interesting autometa theory. It consists of a grid which has a finate number of states (or squares) that can be on or off, each having ,for example, 8 neighbors. It also has a starting condition (The only input given to the machine) and then it simply iterates over and updates the grid based on its given conditions.
A basic example of it is the Conway's Game of Life which simulates, life!
In Conway's Game of Life, cells are either alive (black) or dead (white).
At each step:
- Any alive cell with fewer than two live neighbors dies, as if by underpopulation
- Any alive cell with two or three neighbors lives on
-Any alive cell with more than 3 live neighbors dies. As if by overpopulation
-Any dead cell with exactly 3 live neighbors becomes alive as if by reproduction
This may seem very basic, but it applies to other areas such as chemistry, biology, physics and even in music!
More on cellular automaton:
https://en.m.wikipedia.org/wiki/Cellular_automaton
#FSA #computation
A very simple yet interesting autometa theory. It consists of a grid which has a finate number of states (or squares) that can be on or off, each having ,for example, 8 neighbors. It also has a starting condition (The only input given to the machine) and then it simply iterates over and updates the grid based on its given conditions.
A basic example of it is the Conway's Game of Life which simulates, life!
In Conway's Game of Life, cells are either alive (black) or dead (white).
At each step:
- Any alive cell with fewer than two live neighbors dies, as if by underpopulation
- Any alive cell with two or three neighbors lives on
-Any alive cell with more than 3 live neighbors dies. As if by overpopulation
-Any dead cell with exactly 3 live neighbors becomes alive as if by reproduction
This may seem very basic, but it applies to other areas such as chemistry, biology, physics and even in music!
More on cellular automaton:
https://en.m.wikipedia.org/wiki/Cellular_automaton
#FSA #computation
Accio
GIF
Visualization of a lattice gas automaton. The shades of grey of the individual pixels are proportional to the gas particle density (between 0 and 4) at that pixel. The gas is surrounded by a shell of yellow cells that act as reflectors to create a closed space.
From CA wikipedia page
From CA wikipedia page
Accio
Footage from: Conway's game of life
If you are wondering where does such automata stands in terms of computational power, it is turing-complete
❤1
Accio
Photo
Build your own text editor with C in terminal
https://viewsourcecode.org/snaptoken/kilo
Kilo is a text editor written in C with <1000 lines of code (Thats why it's called a Kilo)
The link above is a step by step walk through of building it all over by yourself! You may do it for fun or even to refresh your basic C skills
I'm doing this tutorial myself, it's so easy to follow. If you want to know the story behind its creation see the authors blog post about it
#c #tui #kilo #editor
https://viewsourcecode.org/snaptoken/kilo
Kilo is a text editor written in C with <1000 lines of code (Thats why it's called a Kilo)
The link above is a step by step walk through of building it all over by yourself! You may do it for fun or even to refresh your basic C skills
I'm doing this tutorial myself, it's so easy to follow. If you want to know the story behind its creation see the authors blog post about it
#c #tui #kilo #editor
Just got rick rolled by svelte tutorial
Svelte is a lightweight and fast javascript framework used in front-end. similar to react but apparently easier to learn.
https://svelte.dev/
#javascript #js #svelte #frontend
Svelte is a lightweight and fast javascript framework used in front-end. similar to react but apparently easier to learn.
https://svelte.dev/
#javascript #js #svelte #frontend
svelte.dev
Web development for the rest of us
Zoxide, a better cd command
https://github.com/ajeetdsouza/zoxide
I've been using zoxide for some time now, it's simple yet effective
for example if you use
instead of
Zoxide will remember the path and next time you could use
to end up in the same directory
#shell
https://github.com/ajeetdsouza/zoxide
I've been using zoxide for some time now, it's simple yet effective
for example if you use
z path/to/mydir
instead of
cd path/to/mydir
Zoxide will remember the path and next time you could use
z mydir
to end up in the same directory
#shell
GitHub
GitHub - ajeetdsouza/zoxide: A smarter cd command. Supports all major shells.
A smarter cd command. Supports all major shells. Contribute to ajeetdsouza/zoxide development by creating an account on GitHub.
👍4
A useful bit trick I missed till now
You already know how to swap two variables without a third one using addition/subtraction or multiplication/division. But the problem is they can cause arithmetic overflow if the values are large enough.
Another way is to use XOR (exclusive OR) to swap variables like so:
#bit_manipulation
You already know how to swap two variables without a third one using addition/subtraction or multiplication/division. But the problem is they can cause arithmetic overflow if the values are large enough.
Another way is to use XOR (exclusive OR) to swap variables like so:
x = x ^ y
y = x ^ y
x = x ^ y
#bit_manipulation
🔥1
bc, which stands for basic calculator, is a..... basic calculator.
It's already installed in your linux system and can be used via your terminal. It takes raw infix expressions like below and evaluates them
Actually it's not just a cli application, it's a programming language! You can create a
Now we can run the program with bc fact.bc and use the following expression:
As you can see f is now recognized. It might not seem much but it will come in handy for simple math/programming problems. You can also define functions as you are giving your inputs to bc (like a repl).
#shell
It's already installed in your linux system and can be used via your terminal. It takes raw infix expressions like below and evaluates them
2 * 3 / (5 - 4) * 2
Actually it's not just a cli application, it's a programming language! You can create a
.bc file, give it to the program and then use it. A bc file sample for factorial function:define f(x){
if(x <= 1) return (1);
return (f(x-1) * x);
}Now we can run the program with bc fact.bc and use the following expression:
2 * 3 / f(3)
> 1
As you can see f is now recognized. It might not seem much but it will come in handy for simple math/programming problems. You can also define functions as you are giving your inputs to bc (like a repl).
#shell
Both bc and dc (a reverse polish notation calculator) were mainly developed by Lorinda Cherry, A computer scientist who had spent her time in Bell labs and also has developed eqn.
Lorinda passed away in 2022
Lorinda passed away in 2022
A very basic problem from project Euler to get started with dynamic programming:
https://projecteuler.net/problem=67
https://projecteuler.net/problem=67
projecteuler.net
#67 Maximum Path Sum II - Project Euler
A website dedicated to the fascinating world of mathematics and programming
❤1