Latest Posts (20 found)
alavi.me 1 months ago

Using E-Ink tablet as monitor for Linux

Yesterday, I was writing and doing research about software licenses. I read through heaps and walls of legal text and different licenses, taking notes and making sense of them. After about fourteen hours of this, I felt like my eyes were ready to quit. I thought it would be really nice if I could use my old Android E-ink tablet as a display for reading and writing text, with much less strain on the eyes. I got it to work and I'm going to document it here so both the future me remembers, and maybe you find it useful and your eyes thank you. Here is what I am working with: The latency with VNC is very little. The main bottleneck is the low refresh rate and the lag of my old E-ink tablet . This can be a much better experience with a newer tablet with higher refresh rate . I still like this though; It is good for just writing with minimal distractions, and less eye strain, but it is amazing for reading . I think this will be best used in a dual monitor setup (minus the e-ink). One is just a mirror to the e-ink, which sometimes helps, taking glances at it for some things that need color. The second monitor will be used for other things besides reading and writing. Deskreen is great, and has its use cases, specially that it's so simple to use even a hamster can use it. But the issue was that you should view your screen inside a browser. That has two problems for our use case: So Deskreen failed for me. Setting up a VNC servers seemed a bit daunting at first (that's why I'm writing this) but I got it working in ~20 minutes. We will use TigerVNC as our server, and AVNC for our Android client (E-ink tablet) As always, the Arch wiki is a great resource, regardless of your distro. See TigerVNC arch wiki . Here, I will provide a quick-start. install the tiger vnc package. For arch: Then, according to the Arch wiki, NOTE : Notice the . 1400x1050 is roughly the resolution of my E-ink display , that my computer display also supports, while tells the coordinates of the screen (xrandr things). So this means that "Share a 1400x1050 view of my screen, starting from position 0, 0 (top left corner)". This makes the screen fit perfectly within the tablet's display with no borders and use as much screen as possible. You could just go with your original resolution and get more borders. NOTE : the file is used for . we will be using which needs these options passed to it directly (more on that later). NOTE : you must change the resolution of your computer screen to 1400x1050, or whatever you set in . Now to quickly test. NOTE : We are passing all the configurations we want directly to because it doesn't read from . NOTE : The only mandatory option is . The rest are optional, see what suits you: . Of course, both devices need to be reachable within their network connections. There are a couple of ways to do this, listed in the Arch wiki . I will just use a simple script to go into my "e-ink mode", so I can quickly run it from my script runner. You can probably find the script here It looks something like this: If you feel like you have to encrypt your VNC connection, see arch wiki . I don't think it is needed for me since I am using this at home or work, there aren't many threats. Use a light theme for Neovim and other things when using with E-ink. The theme that is installed by default is pretty sweet: or just try on different themes! But it's best the theme is high contrast and has true white background (not gray or something). OS: Linux (Arch, btw. but doesn't matter) E-ink tablet: Onyx BOOX Air 2 (It being Android matters, if not, you must find a VNC client for your tablet) I just want to mirror one of my screens to the tablet, I don't care about extending the screen . The streaming quality is not amazing. For reading text, you need crisp letters and high quality The input lag is way too much. My rusty BOOX Air2 already has considerable input and rendering lag. I can't afford anymore. Create a password using which will store the hashed password in . Ensure the file's permission is set to 0600 . If creating vncserver access for another user, you must be logged in as that user before running vncpasswd. Edit to define user mappings. Each user defined in this file will have a corresponding port on which its session will run . The number in the file corresponds to a TCP port. By default, :1 is TCP port 5901 (5900+1) . If another parallel server is needed, a second instance can then run on the next highest, free port, i.e. 5902 (5900+2). Create $XDG_CONFIG_HOME/tigervnc/config and at a minimum, define the type of session desired with a line like session=foo where foo corresponds to whichever desktop environment is to run. One can see which desktop environments are available on the system by seeing their corresponding .desktop files within /usr/share/xsessions/. For example: Running the above command will also output on which port it is listening on (default is 5900).\ Open the port in your firewall if needed.\ Now connect from the client (Android E-ink table) with AVNC(or any VNC client) to the IP and port (e.g. 192.168.0.50:5900). If you feel like you have to encrypt your VNC connection, see arch wiki . I don't think it is needed for me since I am using this at home or work, there aren't many threats. Use a light theme for Neovim and other things when using with E-ink. The theme that is installed by default is pretty sweet: or just try on different themes! But it's best the theme is high contrast and has true white background (not gray or something).

2 views
alavi.me 6 months ago

/now

Updated on 2025 July A page that tells you what this person is focused on at this point in their life. Outstanding book. Very simple and easy to read, while very practical. I'm already applying the concepts and patterns in this book in my work. Just this week I refactored an old legacy piece of our software at work with functional patterns and also optimized it's performance by quite a lot. A very comprehensive resource for learning the Clojure language from scratch. The examples and explanations are great. The book is very long but as a very comprehensive book, it should be. So many things about Clojure appealed to me very much. It's simplicity, elegance, stability, community, culture and more. I see how many great opensource projects are created with it, which means it is very efficient to create with. It lets you express your thoughts instead of wrestling with the language. I'll have to write about to appeal of Clojure more in depth later. I started programming with C and the JS. I don't know, maybe it's how my brain works but I just can't relate to OOP. Never could. Instead, my brain and thoughts have always been closer to the functional paradigm. Functional programming has been really tickling my brain and I want to become great at it, and it will probably be the main way I program later on. I am close to officially becoming the tech leader of my company. This is a role that I feel so comfortable in and I think I am somewhat gifted in it. But like anything else, I need experience and knowledge. I have braced myself and my company that I am for sure going to mess up a bit at first, but I will learn and quickly adapt. I'm pretty OK with English and Persian is my mother tongue. I'm choosing Arabic as my third human language , since it will be very useful and I will gain access to a new plethora of wisdom in Arabic.

0 views
alavi.me 7 months ago

Ethics & Engineering

Since thousands of years ago we have had doctors and we have had engineers. (Proof from ancient Iran, at least ~7500BC) 1 2 Medical practitioners and doctors have had codes of conduct for ethics, like the Hippocratic oath by Hippocrates (400 BC) and Ethics of Doctors by Ishaq Bin-Ali Al-Rahawi (600 CE). They at least have to take one course about ethics and take the Hippocratic oath, which doesn't mean they will necessarily obey it, but at least they have heard it once. This is important because doctors and medical practitioners work with lives, and them not abiding by ethics can cause disasters and cause the loss of lives. I want to talk about why is there no mandatory course about ethics and philosophy for engineering students? Or even if there is, it is not a topic very much talked about in the world of engineers. We are much more fascinated by technicalities than matters like ethics. Although in the world of software engineers the matters of ethics are very bold, with movements like Free software and FOSS , the percentage of engineers who truly care and support these concepts is very small. Of course, what doctors do is very delicate and deals with human lives and safety a lot, but doesn't an engineer's work deal with lives? Can't we safely say that in the current age, The work of an engineer is more critical than the work of a doctor? The footprint of engineering is more prevalent in our lives than any other time in history. Everything, even medicine heavily depends on engineering now. You can't make pharmaceuticals without engineering, you can't conduct a surgery without engineering, and hell, you can't even obtain knowledge from your computer without engineering. Engineering is the pillar of our society's advancements. Sadly, most engineers (that I know of, at least) have never even considered that there is a concept such as ethics in engineering. The same way that it means everything that a doctor abides by these ethics, it is even more critical (Whatever "More critical than critical" means) for an engineer to abide them and think about the consequences of their actions. This issue is felt more in a field that is very abstract, like software engineering. A civil engineer can see and know that if they build a road wrong or a building wrong, it will visibly cause disaster and people will be hurt. They will directly see the consequences of their mistakes. But software engineers, for example, deal with much more philosophical and abstract concepts like consent, privacy, freedom, fairness, neutrality, etc. A software engineer designing embedded software for a pacemaker must be very aware of the consequences of a bug in their software, and the consequences can be very tangible. But if they implement the capability for the pacemaker to connect to your smartphone and then send all your cardiac and maybe other biological data to their servers without your consent, or in a way that you cannot really refuse it, which they will eventually sell the data to the best buyer, the consequences of this action are not very tangible. The engineer might convince themself that this is not a big deal and no harm can be done through this. Because things like privacy are abstract matters and are not widely accepted as a basic human right. I have had countless debates with educated people about why privacy and freedom are important. And sometimes I can't convince them at all! If I punch somebody in the face, they will immediately realize how bad punching someone in the face for no reason is, and how much it hurts, and if it bleeds. But it is very hard to make people see and feel the consequences of lack of something like privacy and freedom. It's very hard to make somebody numb to getting punched in the face, but it's very easy for them to become numb to the lack of freedom. “In a world where privacy is seen as a luxury, remember that it is a basic human right.” – Edward Snowden If you need help understanding why privacy is important, visit this short article . Also visit whyprivacymatters.org So we see how a lack of ethics can ruin our world, especially the lack of it within the disciplines of engineering. Here are some significant elements of the state of our world today: This, This is the result of a lack of ethics in engineering . We are living the consequences of lack of ethics. Not only in engineering but in all the fields. But I think that currently, the lack of engineering ethics is having a very notable effect on us. Following ethics, needs a backbone. The courage to stand up, the courage to say no, The courage to turn down a big paycheck for a more modest paycheck with a better cause. To go a different route than the others. And it also needs integrity and dignity. I understand it is very idealistic to never break. We are human after all and make mistakes. And sometimes, there is no other choice. So first ask yourself, "Is there really no other choice?", If there isn't, choose the bad option not the worse option. But if there is another viable choice, there are no excuses. A human without morals and ethics is no human, But a talking animal... A human without morals and ethics is no human, but a talking animal. What differs humans from animals is our morals and ethics, our codes of conduct, boundaries and philosophies. It doesn't matter to me how much technical skills you have , If you can write an operating system in 10 minutes, Or if you have figured out quantum computers. If you do not have morals and ethics, to me you are just an impressive beast. The same way a puzzle solving chimpanzee might amuse me. This is why I do not admire people like Elon Musk, Bill Gates, Mark Zuckerberg, Sam Altman, and the rest. I am in love with engineering and technology, but it doesn't matter to me what technical achievements they have made. From what I see, the net outcome of their actions is that they have made our world a worse place. In the name of progression, we are losing the true meanings and values of life. The train of life is getting more steam power and moving faster and faster, and we are not riding it anymore, we are not looking out the window and enjoying the view, we are not eating at the buffet. We are only trying to catch up because we are not on board anymore. We are having a hard time breathing, our drinking water is mostly polluted, The food we eat is mostly polluted, We are constantly being spied on, and you will shamelessly get punished for trying to fight or escape them. This is not progression. We have gone the wrong route because we have forgotten our base values. The world has become greedy, and nothing can satisfy it. Do you know why my country is called Iran and our people have called themselves Iranian for thousands of years? "Iranian" means free. Free from greed, free from temptation, free from envy. Free from this mortal world.^[3] This is what my people chose to call themselves because this was the highest value for them. Being free. In the old times in Iran, We had Hakims. Hakims were known and praised for their hekmat(wisdom) . We also had scientists but they were not nearly as celebrated and respected as our wise men and women . People would go to these people and ask for guidance and wisdom. These were people like Hakim Abolqasem Ferdowsi (who wrote the Shaahnameh ), Saadi , Mowlavi (known as Rumi in foreign countries) and so on. The words of these people are still alive and inspiring millions of people all around the world. Their wisdom is still relevant and words to live by. We have moved on from wisdom, to an obsession and fetishism for pure science and technological improvement. Technology for the sake of technology, without philosophy and thought behind it. Technology must be solving problems and improving life quality, not creating more problems to sell more solutions. Technology must be solving problems and improving life quality, not creating more problems to sell more solutions. When you mention that technology is making our lives worse, a very common argument is along the lines of: "Have you seen how people lived a hundred years ago? Working in fields with all kinds of diseases and all the problems?" . I agree. Life was indeed hard, and I don't suggest we should get rid of technology and improvements , But emphasize on the improvements part. And people being dirty and sick doesn't necessarily mean that they were not happy either. I might be wrong, but when my grandparents tell me their stories and stories about their parents (Even though none of them were dirty, sick, or doing hard labor) and show me their photo albums or diaries, the prior generations seem much happier to me, and they agree with this. If you read stories from the books of Saadi from around 850 years ago, people were pretty much as happy as we are today, if not happier. Because happiness isn't an absolute value, it is relative. I don't have solutions for the biggest problems of humanity, of course. But here are my thoughts. We should start from ourselves. Each and every one of us are another building block of this world. A single brick can make or break a million brick structure. We cannot change the whole world but we can change ourselves, and the sphere of life that we carry around us. Ever since I was a kid, long before I knew what quantum mechanics were or what quantum entanglement is -And I still don't know what they are-, I always thought about a concept that defines how we humans and our universe are fully entangled. I strongly believe in this and have felt it. Even a thought forming in your mind can change the thoughts that form in the minds of others, Your intents have direct reflections on other people and the outside world. And when those intents and thoughts get materialized by strong belief, they have far greater and more noticeable results. So form and cultivate your intents, And materialize them by your belief. This is my plan for changing the world, maybe a microscopic step. But billions and billions of microscopic steps create a whole marathon. Even though there are inherently bad and evil people and groups, trying to actively make the world worse, but they will always exist and we can't change them. So while we do fight them, don't blame everything on them and then do nothing. Forgive me if I have ranted too much, but I think we engineers are too busy (or have been purposely made busy) with "Check out this new framework", "Check out this new Rust rewrite" "Check out this cool new tool" "Check out this brand-new research" that we are constantly playing catch-up and working mindlessly, and we have strayed from our true purpose. Dear colleagues and engineers around the world, please put down your tutorials and tools for a while, And think about why you are doing this? What is your purpose? And what are the ethics and morals of it? Are you currently doing anything unethical or immoral? If yes, how can you stop it? How can you actually make the world a better place? May we create a better society and find harmony with each other and our world, Starting with ourselves. https://en.wikipedia.org/wiki/History_of_Iran ↩ https://www.worldhistory.org/Persia/ ↩ Constant surveillance and control (No privacy) Humans have the illusion of freedom but they have less freedom than ever before. You have to pay for water, good air, food, soil, things that nature just gave us but are monopolized and restricted now. You are a product to big companies. They are making money off of you and then selling it back to you. Think about how YouTube, Facebook, Instagram, X, TikTok, etc. are making money. The majority of people are following mindlessly whatever is forced onto them. Unethical company owners and managers give unethical orders, and unethical engineers follow through with the orders. This is no different from the military leader ordering genocide and the soldiers that execute the order. Both are guilty and immoral. Think about the harm that is caused by the engineers who are implementing forced telemetry and surveillance into software like Google Search or your phone's OS (or every other closed source software). Think about the engineers who hid and redacted known faults of the reactor in Chernobyl, which caused the death and suffering of millions of people. People are getting more and more powerless against the things that are happening to them and eventually become numb. So they will follow through with more unethical acts. And close their eyes more upon injustice. The planet that we are living on is at its worst state from the beginning of human kind. The planet and its nature will never be destroyed, but our lives that depend on it will be. Humans are a small fraction of nature and the world's ecosystem. We are currently moving against nature, which is THE "unstoppable force". The only outcome will be our eradication. https://ethicalengineer.ttu.edu/articles/engineering-ethics-and-its-impact-on-society https://raeng.org.uk/media/batgo4ye/engineering_ethics_in_practice_shorter.pdf https://en.wikipedia.org/wiki/Engineering_ethics https://en.wikipedia.org/wiki/Ethics_of_technology https://en.wikipedia.org/wiki/History_of_Iran ↩ https://www.worldhistory.org/Persia/ ↩

0 views
alavi.me 9 months ago

My portrait in Zirab

Portrait of me in village of Zirab - Mazandaran. Taken by my dear sister. Camera: Nikon D3500 Lens: Nikkor 14-140mm f3.5 Edited with Rawtherapee and GIMP

0 views
alavi.me 9 months ago

Tunnel Friends

My good friends walking. Taken on a trip with my friends to the north of Iran - Mazandaran. Camera: Nikon D3500 Lens: Nikkor 14-140mm f3.5 Edited with Rawtherapee

0 views
alavi.me 9 months ago

Family at the beach

A family camping at the beach by their car. Taken on a trip with my friends to the north of Iran - Mazandaran. Camera: Nikon D3500 Lens: Nikkor 14-140mm f3.5 Edited with Rawtherapee

0 views
alavi.me 10 months ago

My Checklist And Tips For Server Setup

Disclaimer: I'm by no means a professional systems administrator or DevOps engineer. I'm a software engineer that works a lot on servers. These are just how I do things. Maybe not necessarily the best way or even the correct way. But I will be updating and refining this post as I learn more (or post them in separate new posts). I will be very happy if you share your own tips and tricks with me( contact me ) If I want to work with a server with more than 4GiB of ram and I know that there will be many use cases for that server, I will go with Debian Linux . It is true and tested, stable and has good community support and resources for server use cases. If the server is limited on resources, and it will be used for specific things like only containerization or only a single service, I will go with Alpine Linux . It is super lightweight and the package manager is so fast, it's unbelievable. But for most cases, for the checklist and tips here the Linux distribution doesn't matter that much. So let's get started. You can install all the tools on debian with this command: There is no way I am editing any text without my neovim . When you have a good editor that you are efficient with, editing config files and searching around the server becomes so much faster and less tiring. Tmux is an absolute life saver when SSH-ing into servers. The fact that you might get disconnected from the SSH server and don't lose any work is amazing, The way it lets you have multiple panes and windws and sessions is amazing, it just makes working on servers so much easier and more enjoyable. I hate the default tmux keymaps, so I always import my own config . NOTE: You can also use Wezterm for multiplexing. Using will multiplex the SSH connection, but if a Wezterm daemon isn't installed and running on the host, The sessions will get destroyed. So this isn't as good as the Tmux method, since even with the daemon you have to install wezterm on both the client and the host. But it's good for simple sessions that don't have Tmux installed. Yes, is cool and all, but honestly the usability and information that btop provides is on another level. I install btop on anything I use, and it is the only "task manager" that I need. Exploring files on a server can be a real pain, so I always install to easily navigate and manipulate files and directories on my servers. I used to use ranger but the instability of python and constant bugs and crashes really got on my nerves. I realized why you really shouldn't make TUI/CLI tools with python. nnn is much more stable and written in C. I also looked into yazi but it really doesn't seem stable(I don't care that it's written in Rust) and the development approach doesn't seem to have stability and simplicity in mind(it's on version 25 and had 25 releases. A major release with every release!) No more and for logs. Super useful for navigating logs and debugging. NOTE: does not work with docker and docker bypasses the firewall. (see github issue ) although you can use a tool like ufw-docker NOTE: Remember to configure firewall for docker NOTE: It's much better to use podman in production These below articles provide good information on this matter https://docs.docker.com/engine/network/packet-filtering-firewalls/ https://dev.to/soerenmetje/how-to-secure-a-docker-host-using-firewalld-2joo on a server might sound strange, but honestly I think it's just good practice to use less and less. Why take unneeded risks? Recently, I accidentally ran instead of and made a pinky promise to myself that I will only use from now on. There isn't a downside that I can think of. Only more safety. can be very useful if you want to transfer lots of files, much faster and better than When you realize that 90% of the work that you do on a server can be achieved from a neovim session, It really makes things a lot easier. You can use the file explorer built within vim to explore files, use for a terminal within your neovim, and create splits ( ) and tabs ( ). So if you have a raw server with only vim, you have most of the things that you need right there. The tools that I listed prior are super useful and make things a lot easier and better, but if you want to keep it minimal, a lot can be done with just vim. Remember that more complete multiplexers like also have sessions, meaning you can disconnect from the SSH and reconnect later and don't lose any work. Podman has a lot of benefits over docker. I haven't tested podman in serious conditions yet, but it seems like it is pretty mature. If feasible, it is a more desirable option. 5 reasons to choose podman in 2025 - redhat podman vs docker comparison - geekygadgets ultimate docker to podman migration guide how to transition from docker to podman If you setup a lot of servers(I don't. Maybe 10/year) consider automating your repetitive tasks. Automation can be achieved with tools like Ansible or simple bash/sh scripts. You don't notice that backups are important until you need them. Try to keep the 3-2-1 principle in mind: I finally realized that for taking backups, you don't have strict how-tos. It very much depends on your use case and situation. Just be sure that you take backups from parts of the system that you can't afford to lose. You also most likely will need custom bash scripts for taking backups, depending on the services running on the server. So don't try to find a "do it all" tool that just magically "does backups". Here are some good tools that can help the backup process: on a server might sound strange, but honestly I think it's just good practice to use less and less. Why take unneeded risks? Recently, I accidentally ran instead of and made a pinky promise to myself that I will only use from now on. There isn't a downside that I can think of. Only more safety. can be very useful if you want to transfer lots of files, much faster and better than Update and upgrade the server Set datetime and timezone Setup firewall Allow ssh port Deny all incoming, allow all outgoing Setup SSH Copy ssh key to server: disable root login enable ssh-key auth disable password auth Make sure swap is enabled Set hostname Enable and configure debian wiki Edit to send emails on upgrades and errors ( setup a mail server ) Enable automatic upgrades Three copies of your data: Your three copies include your original or production data plus two more copies. On two different media: You should store your data on two different forms of media. This means something different today than it did in the late 2000s. I’ll talk a little more about this in a bit. One copy off-site: You should keep one copy of your data off-site in a remote location, ideally more than a few miles away from your other two copies. [source] Borg backup

0 views
alavi.me 1 years ago

Understanding Sample Rate, Bit Rate And Bit Depth

These are my notes as a software engineer on understanding Sample rate, bit rate and bit depth. The explanations might seem incoherent at first, but I think if you read the whole post it becomes more clear. Also read the relevant and good posts for some other explanations from other perspectives. The notes are written in an outline style. Sounds in our world are analog. The sounds that you hear or the sounds that you make are all analog signals Analog signals happen in continuous time. meaning, if we want to draw a diagram of the signal representing it's intensity on one axis and time on another (A signal is a series of changes in time), the diagram would look like this: In order for these signals to be understood, used and processed in our digital devices (phones, PC, TV, etc.) they should be converted into digital signals, used within the device and then either be sent to another digital medium, or be converted to an analog signal again and then sent to an analog medium (Digital signals are explained later). Example from sound : Your voice(analog) -> travels through air to reach microphone(analog) -> microphone vibrates (analog) -> gets converted to digital -> sent as digital signal to a speaker via a digital medium (digital signals on a wire)-> the speaker vibrates the air in a way that recreates your voice (analog) -> travels through air (analog) -> The listener's ear picks up the vibrations(analog) -> Signals in nervous system (?) Time, As we define it, is continuous(or as continuous as it gets) so anything happening in our world is continuous, since it happens in time. Also note that all of the things that I said might not be true, since we really don't have a concrete definition of what time is, and the line between continuity and being discrete is blurry(like most other things in our world). In digital signal processing , a digital signal is a representation of a physical(analog) signal that is sampled and quantized. A digital signal is an abstraction that is discrete in time and amplitude. [1] See how in the above diagram, no values can exist between the defined values. A "bit" is the smallest value in a digital system. it's either 0 or 1 One bit can represent 2 values, and 2 bits can represent 4 values. The general rule is with $n$ bits we can represent $2^n$ values. Bit depth refers to "how many bits do we have for the number we want to represent our intensity with?" so the more bits we have, more values we can express. so our estimations of our analog signal's intensity becomes more accurate A 24-bit audio is more accurate in terms of the intensity of each sample than a 16-bit Example with color: An image with 8-bit depth is more accurate in displaying different intensities (shades) of colors We can say that: if (sample_rate $\rightarrow \infty$ and bit_depth $\rightarrow \infty$) then Our signal is analog bit rate ( bitrate or as a variable R ) is the number of bits that are conveyed or processed per unit of time.[2] The bit rate is expressed in the unit bit per second (symbol: bit/s ), often in conjunction with an SI prefix such as kilo (1 kbit/s = 1,000 bit/s), mega (1 Mbit/s = 1,000 kbit/s), giga (1 Gbit/s = 1,000 Mbit/s) or tera (1 Tbit/s = 1,000 Gbit/s).[2] 1: Digital signal - wikipedia 2: Bit rate - wikipedia Sounds in our world are analog. The sounds that you hear or the sounds that you make are all analog signals Analog signals happen in continuous time. meaning, if we want to draw a diagram of the signal representing it's intensity on one axis and time on another (A signal is a series of changes in time), the diagram would look like this: In order for these signals to be understood, used and processed in our digital devices (phones, PC, TV, etc.) they should be converted into digital signals, used within the device and then either be sent to another digital medium, or be converted to an analog signal again and then sent to an analog medium (Digital signals are explained later). Example from sound : Your voice(analog) -> travels through air to reach microphone(analog) -> microphone vibrates (analog) -> gets converted to digital -> sent as digital signal to a speaker via a digital medium (digital signals on a wire)-> the speaker vibrates the air in a way that recreates your voice (analog) -> travels through air (analog) -> The listener's ear picks up the vibrations(analog) -> Signals in nervous system (?) A digital signal is a type of discrete signal (as opposed to continuous ). Discrete signal : we will ignore the continuity of time, and assume that time happens in discrete amounts. So there will be nothing there between time 1 and time 2. Now digital means: our time is discrete, and our intensities are also discrete In digital signal processing , a digital signal is a representation of a physical(analog) signal that is sampled and quantized. A digital signal is an abstraction that is discrete in time and amplitude. [1] Now, With that explanation of digital signals, we can understand the basics of how we convert analog signal to digital: In discrete time intervals (for example every second), we will sample our signal. Meaning, we will measure it at that moment. This is called our sample rate (here our sample rate is 1 sample per second) Now that we took the sample, since our original signal is continuous, our measured intensity value is a Real number($\mathbb{R}$) and can be something like 0.333333.... or $\pi$ (3.14...), we cannot use that number in our digital system! So we have to round it to a defined value . Imagine our digital signal graph as a checkered graph. The vertical lines are your time intervals (sample rate as we defined earlier) and the vertical lines are your defined values, to which you will round your intensities. The more dense the vertical lines are, the higher your sample rate. And the more dense your horizontal lines, the higher accuracy for rounding your intensities you have ( Bit depth ) Analog signal: Digital signal with lower bit depth and sample rate ( we consider the thicker lines as our bit depth and sample rate values in this example ): Digital signal with higher bit depth and sample rate ( all lines are considered as our bit depth and sample rate values): Notice how as we raise the sample rate and bit depth, we get closer to our actual analog signal A "bit" is the smallest value in a digital system. it's either 0 or 1 One bit can represent 2 values, and 2 bits can represent 4 values. The general rule is with $n$ bits we can represent $2^n$ values. Bit depth refers to "how many bits do we have for the number we want to represent our intensity with?" so the more bits we have, more values we can express. so our estimations of our analog signal's intensity becomes more accurate A 24-bit audio is more accurate in terms of the intensity of each sample than a 16-bit Example with color: An image with 8-bit depth is more accurate in displaying different intensities (shades) of colors bit rate ( bitrate or as a variable R ) is the number of bits that are conveyed or processed per unit of time.[2] The bit rate is expressed in the unit bit per second (symbol: bit/s ), often in conjunction with an SI prefix such as kilo (1 kbit/s = 1,000 bit/s), mega (1 Mbit/s = 1,000 kbit/s), giga (1 Gbit/s = 1,000 Mbit/s) or tera (1 Tbit/s = 1,000 Gbit/s).[2] Let's learn about waveforms - The pudding Bit rate vs. Sample rate vs. Bit depth - waveroom Continuous vs discrete signals. What is the difference? - engineeryoursound Digital audio basics: sample rate and bit depth - izotope 1: Digital signal - wikipedia 2: Bit rate - wikipedia

0 views
alavi.me 1 years ago

Authentication and Authorization: Quick notes

These are some quick notes I took(read "copy/pasted") for understanding about auth in general and, the difference between Authentication and Authorization. You go to the airport, the security guy checks your identification card(ID) which contains an identity . Then, the security guy checks your face or fingerprint to make sure you, are truly the owner of that identity ( Authentication ) Authentication does not just apply to verifying human users. Computer systems also need to check servers, software, APIs , and other computers to be sure they are who they "say" they are. Authentication is an important part of identity and access management (IAM) , which dictates who can view data and what they can do with it. But it applies to many other areas of security as well, including: TLS: Almost all major websites today support Transport Layer Security (TLS) . TLS, among other functions, authenticates the identity of a web server to ensure user devices do not load fake websites. APIs: Most modern web applications rely on APIs in order to function. Properly secured APIs authenticate both endpoints of the API integration in order to prevent attacks directed at those APIs. Email: Emails are authenticated using a process called DomainKey Identified Mail (DKIM) . DKIM helps ensure email messages come from servers that are allowed to use the domain (e.g. @cloudflare.com) that the email comes from. Non-authenticated email messages are likely to end up in spam folders While authentication is concerned with verifying identity, authorization is concerned with permissions, or what someone is allowed to do once they gain access to a protected system or resource. A person's entire identity cannot be uploaded and stored in a computer, so "identity" in a computing context means a certain set of properties that can be conveniently measured and recorded digitally. To verify identity, a computer system will assess a user for characteristics that are specific to them. (authentication factors) Something the user knows (e.g. a password) Something the user has (e.g. a soft token or hard token) Something the user is (e.g. fingerprint, face, biometrics) What is Authentication - cloudflare What is identity and access management(IAM) - cloudflare Difference between Authorization and Authentication - Geeks For Geeks

0 views
alavi.me 1 years ago

How to record meetings with high quality with light software on Linux (Easyeffects + SSR)

NOTE: Helvum is a tool for Pipewire so this doesn't apply to systems that only use PulseAudio. I was having problems with using Simple Screen Recorder(SSR) for recording meetings. Either the input voice from my microphone wouldn't be recorded, or the system sound from my sound card wouldn't be recorded. I fixed it by using Helvum to connect the output of my microphone, directly to the input of SSR. And while at it, why not use Easyeffects to get a good quality recording? My preferred recording setup: Now the recording consists of your enhanced(denoised, reverb, pitch corrected or whatever you like), plus the sounds coming from your system(your peers talking in a meeting or discord, your game, etc.) Here is how it looks in Helvum: NOTE: I installed Helvum from the arch repos but the recommended way(due to Helvum's docs) is flatpak. NOTE: I use "Deep Noise Remover( DeepFilterNet )" in Easyeffects for noise canceling. It works really good, specially in very noisy environments. I installed it using using arch's AUR package but there are other ways to install it ( docs ) I don't think this is necessarily the best way to record things, but it works well enough for me. SSR is very lightweight compared to things like OBS, and Easyeffects is great for controlling and enhancing the sound of your input and output sounds. Set input profile of SSR > Audio input > Backend: PulseAudio , Source: Monitor of Built-in Audio Analog Stereo (or monitor of your preferred output device) For meetings. I also like to scale to video down. More than HD is overkill for a meeting or conference recording in most cases. Set Output profile of SSR > Video > Codec: Other > Codec name: libx265 (the default is H.246) Connect "Easyeffect Source" capture channels to "SimpleScreenRecorder" input channels in Helvum

0 views
alavi.me 1 years ago

Why I Built My Website With Zola Static Site Generator

I wanted a simple, lightweight, static website, so I chose a SSG. A Static Site Generator or SSG is a technology that helps you code dynamically, and then gives you static output. Meaning only simple HTML/CSS/etc. And after the build step, which turns your dynamic code into static assets, nothing is rendered on the server and there is no dynamic rendering on the client. It's like manually creating HTML pages like the old days, but gets rid of the redundancy and repetitive work and also makes your website much more maintainable and easier to edit or change. From the different SSGs like Hugo , Vitepress , 11ty and Zola , I chose Zola because it has a good and easy templating engine, great docs, is easy to setup, and also is built in Rust, and since I like and know Rust, doing custom stuff in it will be more enjoyable and easier for me. At first when I started programming and getting more involved with software and the web, I would get so excited by seeing websites with fancy animations and bells and whistles, like the websites you see on dribbble, or those Apple product pages with lots of animations. That was my standard for how a high quality website looks like, so flashy and charming. But as I matured a bit into a software engineer and gathered more experience in the web and software world, I started to appreciate simplicity more, and more, and more. While back then, seeing a very cool scroll animation would make me WOW, now seeing a very simple HTML+CSS page that is super lightweight and very easy to use makes me WOW. Because when you strip all the animations, all the heavy CSS and JS, that's the real engineering product. If your website works, feels and looks good without these distractions and crutches, (in my opinion) you have engineered and created a good website. And I think this is the case for any other engineering product. For example let's talk about cars a bit. You can find cars that have so many options: cruise control, heated seats, an advanced computer to interact with, good looks, lots of bells and whistles, but after you drive 100K kilometers with them, they start to look absolutely trashed and it doesn't take much longer for them to fall apart and fail completely; You can also buy a well built Japanese car that looks like your grandma's purse, has no extra options whatsoever beyond safety and essentials, but after 100K kilometers this car still looks and feels new (assuming you take good care of it), and you can drive it for at least 400-500K kilometers. I go with the second option any day, and that is what engineering is to me. The first car is built by marketers, the second car is built by engineers and sold by marketers. So I wanted to create my website as simple, lightweight and well built as I can, while still looking decent, and also avoid JS, or even if I had to use JS, I wanted the website to be still fully functional without it. After some research I realized a static site generator(SSG) is what I want. But how did I come to that conclusion? Let's see. A static website is made up of one or more HTML webpages that load the same way every time. Static websites contrast with dynamic websites, which load differently based on any number of changing data inputs, such as the user's location, the time of day, or user actions. While static webpages are simple HTML files that can load quickly, dynamic webpages require the execution of JavaScript code within the browser in order to render. 1 In short: static website = website comprised of simple HTML/CSS/image/... (static) assets. Let's think from scratch about how you would create a website in the beginning days. You would create a page with HTML, your page had a header, some side bars, some content and your content can have a certain structure. Now if you want to create another page but with different content, you have to copy and paste from your first page and change the content (so you can maintain the same overall structure of header, nav bar, footer, etc.). But just imagine how hard that is. And good luck if you want to refactor or change something; You have to change it in every single page. And keep in mind this example is very basic. It can get way more complex. So instead, what if I could code dynamically, but get static output? This is exactly what a SSG does for you. You code your website dynamically and then it gets compiled into static assets that you can deploy on the web. In cloudflare's words: A static site generator is a tool that generates a full static HTML website based on raw data and a set of templates. Essentially, a static site generator automates the task of coding individual HTML pages and gets those pages ready to serve to users ahead of time. 1 Server-side rendering (SSR) is a technique for rendering web pages on the server-side before sending them to the client's browser. In SSR, the server generates the HTML content of a web page based on the requested URL and data, and sends it to the client's browser as a complete HTML document. 2 Static site generation (SSG) is a technique for building web pages by pre-generating HTML, CSS, and JavaScript files at build time instead of rendering them on the server or client-side. In SSG, a static site generator tool like Jekyll, Hugo, or Gatsby.js is used to compile the website's content from data sources such as markdown files, JSON files, or CMS data, and generate a set of static files that can be served directly to the browser without any server-side processing. The generated static files can be deployed on a web server or a content delivery network (CDN) and served quickly to the end-users with low latency. SSG offers several benefits such as fast loading times, improved security, and scalability. Since SSG renders web pages at build time, there is no need to generate pages dynamically on the server or client-side. This reduces the processing overhead and enables faster loading times. 2 So with the above points being said, SSR and SSG are two different rendering patterns. SSR usually means that the website is still interactive and dynamic, but the interactions get rendered on the server and then sent back to the client; The new HTML will be replaced by the old one. SSG means the end results are a bunch of static assets, And nothing will be rendered on the server after you have compiled and built your website and deployed it. Your SSG result is a static website (as opposed to dynamic). So while it's true that the client receives static assets both from a SSR and SSG website, the difference is between the end results still being dynamic and rendered on the server in a SSR website, and the end results being fully static in a SSG website. "Ok so it helps me create and manage my website more easily and efficiently by eliminating redundant work, so I can mostly focus on the content. Isn't that what a CMS(Content Management System) does too?" Well kind of, but lets see how cloudflare explains a CMS 1 : In the early days of the Internet, websites were stored as static HTML sites, with all webpages laid out and hard coded in advance. This was inefficient because it required developers to code each webpage manually. Content management systems (CMS) emerged as a way for developers to avoid all that manual setup. Instead of coding the pages ahead of time, content is stored in a CMS database, and when a user requests a page, the server does the following: Content in the CMS has to fit in one of the fields offered by the CMS database, but as long as it does, it should appear in its proper place on the website every time. A static site generator is a compromise between these two approaches. Like a CMS, it allows developers to use templates and automatically generates webpages — but it does the latter ahead of time, instead of in response to a user's request. This makes for faster website performance, because the webpages are instantly ready for delivery to end users. 1 While what couldflare said isn't wrong, this is the explanation for our classic CMS like wordpress , joomla , etc. The whole question of "CMS vs. SSG" is a wrong question. These are two different things and comparing them is like comparing apples and oranges. CMS is "Content Management System", and SSG is "Static Site Generator". So you can have a CMS for your SSG! Projects like Siteleaf and Static CMS do exactly that. But most of the time, you don't need a CMS for you SSG because it's already pretty straight forward. But some use cases that I can think of for SSG+CMS is for example when your organization's website is built with a SSG and you want all colleagues, even the non technical ones, to be able to write blog posts very easily and manage the content more easily. So why didn't I use something like wordpress? Now that I knew I wanted to use an SSG, I had to choose one. The most attractive options to me were: Vitepress got eliminated because it generates SPAs and uses JS on the client side to hydrate the page content. While I still use it for docs in our organization and think it's great, it didn't fit my needs here. 11ty looked cool, had a great possum mascot, and was very flexible. But being very flexible and DIY was also a downside for me since I didn't want to wrestle too much with the website and focus more on my content. Also, the docs seemed kind of scary and confusing. It came down to Hugo vs. Zola. Hugo is super popular, has very big community and is well maintained, it's super fast on builds, has great docs, and is focused on blogging. Zola was also very on par with Hugo. It's Blazingly™ Fast(Rust, obviously!), very good and simple docs, easy to setup and is focused on contents. Also, both Hugo and Zola are installed using a single binary file which makes the dev experience much better. The main points that made me choose Zola over Hugo were: Hugo uses Go's and which are said to be very odd and hard to learn. 3 4 But Zola uses the Tera templating engine which has very sane syntax and is more straightforward. Zola is built with Rust, and I really like Rust, So if sometime I have to do some deep customization, I will have to deal with Rust instead of Go which is a plus for me. And even if I find something is wrong with Zola, I might be able to fix it myself and create a PR, since it's in the Rust ecosystem. If something is super popular, I kind of lose my interest in it. I tend to always love underrated things. This is how my website looks like at the time of writing this blog post(since it might change in the future). I created it using the Duckquill theme. This is my second blog post, and up to this point I'm very happy with my website and Zola. Cloudflare. What Is A Static Site Generator?. https://www.cloudflare.com/learning/performance/static-site-generator/ ↩ ↩2 ↩3 ↩4 G. Cocca, “Rendering Patterns for Web Apps – Server-Side, Client-Side, and SSG Explained,” Freecodecamp, https://www.freecodecamp.org/news/rendering-patterns. ↩ ↩2 M. T. Miller, “Jekyll vs Hugo vs Gatsby vs next vs Zola vs eleventy,” Mark Thomas Miller, https://mtm.dev/static (accessed Mar. 15, 2024). ↩ K. Woortman, “Replacing Hugo by Zola as Static Site Generator for my blog,” Memoji of me, https://koenwoortman.com/replacing-hugo-with-zola/ (accessed Mar. 15, 2024). ↩ Queries the database for the right content Identifies the template the content will fit into Generates the page Serves the page to the user Because I wanted a static, lightweight website I wanted customizability. With something like wordpress you stay very limited. I have created and maintained wordpress websites and nothing is more frustrating than creating a blog post or content in wordpress. With most SSGs, you can just use markdown for you your content which is much more maintainable and much easier to write. Vitepress -> Since I'm very familiar and good with Vue and Vite Hugo -> Heard it's name a lot, and seen many websites that caught my attention using it 11ty -> Looked cool, very flexible and had great community Zola -> Also looked cool, good and straightforward docs, and built with Rust (I'm a Rust fangirl, sorry) Hugo uses Go's and which are said to be very odd and hard to learn. 3 4 But Zola uses the Tera templating engine which has very sane syntax and is more straightforward. Zola is built with Rust, and I really like Rust, So if sometime I have to do some deep customization, I will have to deal with Rust instead of Go which is a plus for me. And even if I find something is wrong with Zola, I might be able to fix it myself and create a PR, since it's in the Rust ecosystem. If something is super popular, I kind of lose my interest in it. I tend to always love underrated things. Cloudflare. What Is A Static Site Generator?. https://www.cloudflare.com/learning/performance/static-site-generator/ ↩ ↩2 ↩3 ↩4 G. Cocca, “Rendering Patterns for Web Apps – Server-Side, Client-Side, and SSG Explained,” Freecodecamp, https://www.freecodecamp.org/news/rendering-patterns. ↩ ↩2 M. T. Miller, “Jekyll vs Hugo vs Gatsby vs next vs Zola vs eleventy,” Mark Thomas Miller, https://mtm.dev/static (accessed Mar. 15, 2024). ↩ K. Woortman, “Replacing Hugo by Zola as Static Site Generator for my blog,” Memoji of me, https://koenwoortman.com/replacing-hugo-with-zola/ (accessed Mar. 15, 2024). ↩

0 views
alavi.me 1 years ago

Hi Mom!

- Look mom! I made it! I'm finally a valid internet citizen with my own website! + Ummm... That's sweet honey! But why in the world would you need a website for? I think every tech person can agree with me that nobody hates tech more than us techie people. One of the biggest love-hate relationships of my life is between me and technology. On one hand, It makes doing things a lot easier, but on the other hand it becomes a PAIN very quickly. Overall you can see my formulated thoughts in the graph below: But even with this being said, I have to emphasise on the special hatred I preserve within the depths of my soul for social media. I was tired of the social media changing every couple of years, The fact that you don't decide what to consume, you get fed by a feed , The way you have to juggle between numerous social medias to stay relevant, etc. So I found myself on a hard decision. Since I don't have enough money to be able to pull option 1 off, I decided to go with option 2. But how do I show my portfolio to other people? How do I share this cute cat pic that I took last week to the whole world? Now nobody will ever know about how cute that cat was. How do I whine about something to so many people at once? DMing them all separately is an option, but not a wise one. This is an injustice!! What if I could put this stuff somewhere and create it how I like it? What about putting them on a page and being able to somehow share it with many people and many devices that are connected to each other somewhat like how a spider's web  is connected. What should I call it? pageweb? wage? websheet? ... AHA! I'll call it a web-page™ . I knew what I wanted. a central hub to link everything together, like my emails, different Git accounts, matrix account, mastadon, etc. These platforms might go under any second, and then You will have to be like, "Oh, 'A' is so last year now; here is my new account on 'B'." or something like this. But even 20 years from now, if I keep this website up,  You would know that if you want anything about Alavi, you should come to my website; A journal for my not-so-personal things that I can easily address and share with other people and help them use my experiences. I want to have a monologue of a rant. I don't want interjections upon my holy naggings. We don't want any democracy here. not hearing Zuckerberg or one of his friends breathing through my phone's speaker every time I opened one of those apps is also a plus. So I got my tools out, played some rocky music, and got to work. I created some web-pages™, and together they formed a web-site™ . Spectacular! Now I can nag, rant, share cat pictures, and be a showoff all in one place! Free of Zucc or Elon, or any other unhealthy individual but myself.(Almost) - "Ummm... I would love to get to know you better, We should keep in touch :')" + "Sure thing! Here's my website, make sure you subscribe to the RSS feed ;)" Go throw a pie into Zuckerberg's face Abandon social media and live a peaceful life

0 views
alavi.me 1 years ago

Me Pixelart

My pixel art, created with pixilart and Gimp. This was my first experience in creating pixel art and I had a ton of fun doing it!

0 views
alavi.me 3 years ago

JTimar logo

Logo for JTimar application of APS Co. . Created using adobe illustrator. CC BY-NC-ND

0 views
alavi.me 4 years ago

APS logo

Recreated the logo for APS Co. With a more modern look. Created using Inkscape. CC-BY-NC-ND

0 views
alavi.me 4 years ago

Cycas Logo EN

Logo for a company working in the electronics field name cycas. I tried to include both the cycas plant and electronics in it; And this version also includes traditional Persian architecture and design elements. Created with Inkscape.

0 views