Accio
107 subscribers
43 photos
1 file
81 links
Resources I find useful
github.com/Keivan-sf

Share ur interesting stuff with me:
@ke1vans
Download Telegram
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
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
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
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
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
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
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
👍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:
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
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
How should you decide between divide-and-conquer and dynamic programming?

If you are trying to decide between these two you already know your problem has Optimal substructure. Meaning it can be broken into smaller problems and solved by combining the optimal solutions of these subproblems.
Now in order to find out which solution is more suitable you should see if it has Overlapping subproblems or not. A problem has overlapping subproblems when its solution might try to solve some subproblems more than once rather than generating new ones. For example if you go with a divide-and-conquer approach to generate a Fibonacci sequence, you'll be solving overlapping subproblems. e.g.:
F(6) = F(5) + F(4)
Both F(5) and F(4) are gonna try and solve for F(3) separately

In summary:
Going for devide-and-conquer or dynamic programming is normally a good decision if the problem has Optimal substructure.
Going for dynamic programming is normally a good decision if the problem also has Overlapping subproblems.
👍2🍓1
Additionally, a greedy algorithm is usually used to solve a problem with optimal substructure if it produces an optimal solution at each step. For example Dijkstra, Kruskal, and ...

#dp #greedy #devide_and_conquer
In case you missed it, dylanaraps an open source contributor known for creating neofetch, kisslinux, fff and a few other famous projects, archived and abandoned all of his repos two months ago and left the following message on his github readme:
😁1🐳1