How I Setup Dark Theme in My Blog
Dark mode or night mode is becoming more and more popular these days. As the amount of time we are spending in front of the computer increases, we started to look more into on how to improve our experience. Dark mode/Night mode is one such setting. What it does (mainly) is it makes all the white part of the application to black - major chunk of which would be the background. When the color of the background is made black, it emits less light. Now not all displays are the same, each display creates the dark color in different ways. Like:
- On an
LCD screen
. The liquid crystal elements block the white light from the backlight. And this results in a dark (almost black) pixel. - On an
OLED screen
. The pixel is turned off, no light is emitted, this produces a deep black. - On a
CRT screen
. The electron beam is turned off as it passes the pixel. Producing no phosphorescent glow. - On an
e-Ink screen
. Little spherical beads which are half black/half white, are rotated so their black side is facing outwards.
Regardless as you can see, darker colors results in less lights being emitted and leading to less strain to the eye. As a person who spend more time in front of a screen, I cannot fathom how useful this is. I have been a huge advocate of using night color/night mode in computer to improve developer health. Hence this article and why my blog has a dark mode now.
Append to File using Bash
Using String in Active Record(Rails) Enum
Rails model helps you define enum on a database integer field quite easily. The enum method which rails provide in its model is not an interface to the enum datatype available in some databases, but converting or using a integer field as an enum. Enum type or Enumerated type is user defined data type where you define the set of value the data type will have. If you consider regular or basic or primitive data types, they are pretty much like enum where the values it can hold is defined already by the language. Ruby dynamic type system does hide all this complexity for us while we develop.
Enum is quite useful when you want to make sure that only a specified list of values are saved for a field.