diff options
| author | Mitja Felicijan <mitja.felicijan@gmail.com> | 2023-05-26 00:40:40 +0200 |
|---|---|---|
| committer | Mitja Felicijan <mitja.felicijan@gmail.com> | 2023-05-26 00:40:40 +0200 |
| commit | 43b0708769eb61392050045b881f8e6ba39c5b66 (patch) | |
| tree | 3939579a13b8325325d5ebb8e05324a41ed78a6d | |
| parent | 49e7e7d555a6cd9810d81561fa3e98e3d64502be (diff) | |
| download | mitjafelicijan.com-43b0708769eb61392050045b881f8e6ba39c5b66.tar.gz | |
Massive update to posts, archetypes
Added a archetypes for creating notes and posts so it auto-populates
fields.
Fixed existing posts so they align with the rule of 80 columns now.
72 files changed, 2584 insertions, 930 deletions
diff --git a/archetypes/notes.md b/archetypes/notes.md new file mode 100644 index 0000000..9f13d6d --- /dev/null +++ b/archetypes/notes.md | |||
| @@ -0,0 +1,11 @@ | |||
| 1 | --- | ||
| 2 | title: "{{ replace .Name "-" " " | title }}" | ||
| 3 | url: {{ .Name }}.html | ||
| 4 | date: {{ .Date }} | ||
| 5 | type: notes | ||
| 6 | draft: true | ||
| 7 | tags: [] | ||
| 8 | --- | ||
| 9 | |||
| 10 | Start here ... | ||
| 11 | |||
diff --git a/archetypes/posts.md b/archetypes/posts.md new file mode 100644 index 0000000..b9dad61 --- /dev/null +++ b/archetypes/posts.md | |||
| @@ -0,0 +1,9 @@ | |||
| 1 | --- | ||
| 2 | title: "{{ replace .Name "-" " " | title }}" | ||
| 3 | url: new-post.html | ||
| 4 | date: {{ .Date }} | ||
| 5 | draft: true | ||
| 6 | --- | ||
| 7 | |||
| 8 | Start here ... | ||
| 9 | |||
diff --git a/content/notes/cachebusting-in-hugo.md b/content/notes/cachebusting-in-hugo.md index 65d7769..34e1684 100644 --- a/content/notes/cachebusting-in-hugo.md +++ b/content/notes/cachebusting-in-hugo.md | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | --- | 1 | --- |
| 2 | title: Cache busting in Hugo | 2 | title: Cache busting in Hugo |
| 3 | url: cachebusting-in-hugo.html | 3 | url: cachebusting-in-hugo.html |
| 4 | date: 2023-05-01 | 4 | date: 2023-05-01T12:00:00+02:00 |
| 5 | type: notes | 5 | type: notes |
| 6 | draft: false | 6 | draft: false |
| 7 | tags: [hugo, cachebusting] | 7 | tags: [hugo, cachebusting] |
diff --git a/content/notes/catv-weechat-config.md b/content/notes/catv-weechat-config.md index 3e6e612..ea53120 100644 --- a/content/notes/catv-weechat-config.md +++ b/content/notes/catv-weechat-config.md | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | --- | 1 | --- |
| 2 | title: "#cat-v on weechat configuration" | 2 | title: "#cat-v on weechat configuration" |
| 3 | url: catv-weechat-config.html | 3 | url: catv-weechat-config.html |
| 4 | date: 2023-05-09 | 4 | date: 2023-05-09T12:00:00+02:00 |
| 5 | type: notes | 5 | type: notes |
| 6 | draft: false | 6 | draft: false |
| 7 | tags: [irc, weechat, cat-v] | 7 | tags: [irc, weechat, cat-v] |
diff --git a/content/notes/convert-mkv.md b/content/notes/convert-mkv.md index bafdfb3..0e1987a 100644 --- a/content/notes/convert-mkv.md +++ b/content/notes/convert-mkv.md | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | --- | 1 | --- |
| 2 | title: Convert all MKV files into other formats | 2 | title: Convert all MKV files into other formats |
| 3 | url: convert-mkv.html | 3 | url: convert-mkv.html |
| 4 | date: 2023-05-14 | 4 | date: 2023-05-14T12:00:00+02:00 |
| 5 | type: notes | 5 | type: notes |
| 6 | draft: false | 6 | draft: false |
| 7 | tags: [ffmpeg, mkv, webm, mp4] | 7 | tags: [ffmpeg, mkv, webm, mp4] |
diff --git a/content/notes/dcss-materials.md b/content/notes/dcss-materials.md new file mode 100644 index 0000000..e446224 --- /dev/null +++ b/content/notes/dcss-materials.md | |||
| @@ -0,0 +1,69 @@ | |||
| 1 | --- | ||
| 2 | title: Dungeon Crawl Stone Soup Materials | ||
| 3 | url: dcss-materials.html | ||
| 4 | date: 2023-05-25T22:00:00+02:00 | ||
| 5 | type: notes | ||
| 6 | draft: false | ||
| 7 | tags: [dcss] | ||
| 8 | --- | ||
| 9 | |||
| 10 | An amazing game deserves an amazing guide. All this material can be find in | ||
| 11 | some for on another on [craw's](https://github.com/crawl/crawl) official | ||
| 12 | repository. | ||
| 13 | |||
| 14 | - [DCSS Quickstart](/notes/dcss-quickstart.pdf) - Very short introduction to the game | ||
| 15 | - [DCSS Manual](/notes/dcss_manual.pdf) - Extensive manual about the game | ||
| 16 | |||
| 17 |  | ||
| 18 | |||
| 19 | **Movement and Exploration** | ||
| 20 | |||
| 21 | - You can move around with the numpad (try numlock on and off), vi-keys, or clicking with the mouse. Arrow keys work, though you can't move diagonally with them. Pressing Shift and a direction will move until you see/hit something. | ||
| 22 | - Pressing `>` will take you down a staircase, and `<` to go up a staircase. | ||
| 23 | - You can open doors by walking into them, and close them with `C`. | ||
| 24 | - You can autoexplore by pressing `o`. | ||
| 25 | - You can re-view recent messages with `Ctrl-p`. | ||
| 26 | |||
| 27 | **Monsters and Combat** | ||
| 28 | |||
| 29 | - You can pick up items with `,` or `g`. | ||
| 30 | - Wield weapons with `w`. Weapons have different stats. | ||
| 31 | - (You may also engage in Unarmed Combat, though it isn't very effective when untrained). | ||
| 32 | - Attack monsters in melee by walking in their direction (or with Ctrl-direction). | ||
| 33 | - You can wait with `.` or `s`, passing your turn - such as to get monsters into a corridor with you. | ||
| 34 | - You can rest with `5`, waiting until you are fully healed, or something noteworthy happens. | ||
| 35 | - Either mouseover and rightclick, or use `x` then `v` on the monster to examine monsters. Monsters with a red border are 'dangerous' relative to your current XP level (XL). | ||
| 36 | - Quiver (often ranged) actions for further use with `Q`. | ||
| 37 | - You can fire ranged weapons manually with `f`, or auto-target your quiver with `p` or `Shift-Tab`. Throwing weapons can be thrown immediately, while launchers (like bows) need to be wielded first. | ||
| 38 | |||
| 39 | **Items and Inventory** | ||
| 40 | |||
| 41 | - View your inventory by pressing `i`. Most item related commands can also be done with this menu. | ||
| 42 | - You can wear amour with `W;` amour gives `AC`, while heavier body armour reduces `EV`. | ||
| 43 | - Autoexplore will automatically pick up useful items, such as potions and scrolls, if you aren't in danger. | ||
| 44 | - You can read scrolls with `r` and drink ("quaff") potions with `q`. | ||
| 45 | - Equipment items may have brands, with special properties. Branded equipment is blue when unidentified. | ||
| 46 | - Equipment items may be artifacts, often with unique properties, and are unmodifiable. They are written in white. | ||
| 47 | - You can evoke wands with `V`. | ||
| 48 | - You can put on jewelry with `P`, and remove it with `R`. | ||
| 49 | - Gold is used in shops, which can be interacted with by either `>` or `<`. | ||
| 50 | |||
| 51 | **Magic and Spellcasting** | ||
| 52 | |||
| 53 | - Once you find a spellbook, you can memorize spells with `M`. | ||
| 54 | - You need to be the same XL as the spell's spell level in order to learn it, in addition to training magical skill (to lower failure rate). | ||
| 55 | - Cast spells by pressing `z`, then the letter assigned to the spell. You may also Quiver a spell and then use it like a ranged weapon (with Shift-Tab). | ||
| 56 | - You can view your memorized spells by pressing `I` (capital-i) or `z`. | ||
| 57 | - Like HP, you can recover MP by resting (with 5). | ||
| 58 | - Many spells can be positioned more effectively, or combined with other spells, in order to get (more effective) use out of them. | ||
| 59 | - Heavier body amour and shields hamper spellcasting. | ||
| 60 | |||
| 61 | **Gods and Divine Abilities** | ||
| 62 | |||
| 63 | - You may look at a god's overview by praying at their altar (with `>` or `<`). After praying, you can worship the god by pressing Enter afterwards. | ||
| 64 | - Gods all have unique features about them. Trog, the god of the tutorial, is also the god of rage and bloodshed, and so despises spellcasting. | ||
| 65 | - Gods like and dislike different things. Most gods either like killing things (like Trog) or exploring new areas (like Elyvilon), rewarding you piety (divine favor) for doing so. | ||
| 66 | - You should learn to use and even rely on divine abilities often, as they are usually very strong. Trog's Berserk gives you 1.5x health, 1.5x speed (to all valid actions), and a big damage boost. Note that Berserk prevents most actions other than move and melee attack, and runs out very quickly if you aren't attacking. And after berserk ends, you are slowed down and can't berserk again for a short time. | ||
| 67 | - In addition, the vast majority of abilities consume piety in the process. Regardless, this ability is very cheap, and the benefits are incredible, so don't hold back! | ||
| 68 | - Pressing `^` will let you view your current god, abilities, and piety. | ||
| 69 | |||
diff --git a/content/notes/download-youtube-videos.md b/content/notes/download-youtube-videos.md index 455c550..6d26d12 100644 --- a/content/notes/download-youtube-videos.md +++ b/content/notes/download-youtube-videos.md | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | --- | 1 | --- |
| 2 | title: Download list of YouTube files | 2 | title: Download list of YouTube files |
| 3 | url: download-youtube-videos.html | 3 | url: download-youtube-videos.html |
| 4 | date: 2023-05-13 | 4 | date: 2023-05-13T12:00:00+02:00 |
| 5 | type: notes | 5 | type: notes |
| 6 | draft: false | 6 | draft: false |
| 7 | tags: [youtube, yt-dlp, ffmpeg, webm, mp4] | 7 | tags: [youtube, yt-dlp, ffmpeg, webm, mp4] |
diff --git a/content/notes/extend-lua-with-custom-c.md b/content/notes/extend-lua-with-custom-c.md index 2151237..eaa55a1 100644 --- a/content/notes/extend-lua-with-custom-c.md +++ b/content/notes/extend-lua-with-custom-c.md | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | --- | 1 | --- |
| 2 | title: Extend Lua with custom C functions using Clang | 2 | title: Extend Lua with custom C functions using Clang |
| 3 | url: extend-lua-with-custom-c.html | 3 | url: extend-lua-with-custom-c.html |
| 4 | date: 2023-05-23 | 4 | date: 2023-05-23T12:00:00+02:00 |
| 5 | type: notes | 5 | type: notes |
| 6 | draft: false | 6 | draft: false |
| 7 | tags: [lua, clang, c] | 7 | tags: [lua, clang, c] |
diff --git a/content/notes/fix-plan9-bootloader.md b/content/notes/fix-plan9-bootloader.md index 675eabc..fdd9425 100644 --- a/content/notes/fix-plan9-bootloader.md +++ b/content/notes/fix-plan9-bootloader.md | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | --- | 1 | --- |
| 2 | title: Fix bootloader not being written in Plan9 | 2 | title: Fix bootloader not being written in Plan9 |
| 3 | url: fix-plan9-bootloader.html | 3 | url: fix-plan9-bootloader.html |
| 4 | date: 2023-05-11 | 4 | date: 2023-05-11T12:00:00+02:00 |
| 5 | type: notes | 5 | type: notes |
| 6 | draft: false | 6 | draft: false |
| 7 | tags: [plan9, bootloader] | 7 | tags: [plan9, bootloader] |
diff --git a/content/notes/fresh-9front-desktop.md b/content/notes/fresh-9front-desktop.md index 71edd04..840126a 100644 --- a/content/notes/fresh-9front-desktop.md +++ b/content/notes/fresh-9front-desktop.md | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | --- | 1 | --- |
| 2 | title: My brand new Plan9/9front desktop | 2 | title: My brand new Plan9/9front desktop |
| 3 | url: fresh-9front-desktop.html | 3 | url: fresh-9front-desktop.html |
| 4 | date: 2023-05-24 | 4 | date: 2023-05-24T12:00:00+02:00 |
| 5 | type: notes | 5 | type: notes |
| 6 | draft: false | 6 | draft: false |
| 7 | tags: [plan9, 9front] | 7 | tags: [plan9, 9front] |
diff --git a/content/notes/git-push-multiple-origins.md b/content/notes/git-push-multiple-origins.md index 14b6ed0..929a5dc 100644 --- a/content/notes/git-push-multiple-origins.md +++ b/content/notes/git-push-multiple-origins.md | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | --- | 1 | --- |
| 2 | title: Push to multiple origins at once in Git | 2 | title: Push to multiple origins at once in Git |
| 3 | url: git-push-multiple-origins.html | 3 | url: git-push-multiple-origins.html |
| 4 | date: 2023-05-06 | 4 | date: 2023-05-06T12:00:00+02:00 |
| 5 | type: notes | 5 | type: notes |
| 6 | draft: false | 6 | draft: false |
| 7 | tags: [git] | 7 | tags: [git] |
diff --git a/content/notes/install-plan9port-linux.md b/content/notes/install-plan9port-linux.md index 7e8994d..b74d2c0 100644 --- a/content/notes/install-plan9port-linux.md +++ b/content/notes/install-plan9port-linux.md | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | --- | 1 | --- |
| 2 | title: Install Plan9port on Linux | 2 | title: Install Plan9port on Linux |
| 3 | url: install-plan9port-linux.html | 3 | url: install-plan9port-linux.html |
| 4 | date: 2023-05-12 | 4 | date: 2023-05-12T12:00:00+02:00 |
| 5 | type: notes | 5 | type: notes |
| 6 | draft: false | 6 | draft: false |
| 7 | tags: [plan9, plan9port, linux] | 7 | tags: [plan9, plan9port, linux] |
diff --git a/content/notes/mass-set-permission.md b/content/notes/mass-set-permission.md index 84ec97a..b57374c 100644 --- a/content/notes/mass-set-permission.md +++ b/content/notes/mass-set-permission.md | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | --- | 1 | --- |
| 2 | title: Change permissions of matching files recursively | 2 | title: Change permissions of matching files recursively |
| 3 | url: mass-set-permission.html | 3 | url: mass-set-permission.html |
| 4 | date: 2023-05-16 | 4 | date: 2023-05-16T12:00:00+02:00 |
| 5 | type: notes | 5 | type: notes |
| 6 | draft: false | 6 | draft: false |
| 7 | tags: [linux, find, chmod] | 7 | tags: [linux, find, chmod] |
diff --git a/content/notes/mount-plan9-over-network.md b/content/notes/mount-plan9-over-network.md index 9e9875e..f643395 100644 --- a/content/notes/mount-plan9-over-network.md +++ b/content/notes/mount-plan9-over-network.md | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | --- | 1 | --- |
| 2 | title: Mount Plan9 over network | 2 | title: Mount Plan9 over network |
| 3 | url: mount-plan9-over-network.html | 3 | url: mount-plan9-over-network.html |
| 4 | date: 2023-05-07 | 4 | date: 2023-05-07T12:00:00+02:00 |
| 5 | type: notes | 5 | type: notes |
| 6 | draft: false | 6 | draft: false |
| 7 | tags: [plan9, linux, 9pfs] | 7 | tags: [plan9, linux, 9pfs] |
diff --git a/content/notes/non-blocking-shell-exec-csharp.md b/content/notes/non-blocking-shell-exec-csharp.md index 6de081e..cf43716 100644 --- a/content/notes/non-blocking-shell-exec-csharp.md +++ b/content/notes/non-blocking-shell-exec-csharp.md | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | --- | 1 | --- |
| 2 | title: Execute not blocking async shell command in C# | 2 | title: Execute not blocking async shell command in C# |
| 3 | url: non-blocking-shell-exec-csharp.html | 3 | url: non-blocking-shell-exec-csharp.html |
| 4 | date: 2023-05-22 | 4 | date: 2023-05-22T12:00:00+02:00 |
| 5 | type: notes | 5 | type: notes |
| 6 | draft: false | 6 | draft: false |
| 7 | tags: [csharp, async, shell] | 7 | tags: [csharp, async, shell] |
diff --git a/content/notes/parse-rss-with-lua.md b/content/notes/parse-rss-with-lua.md index 1757d45..1efeae5 100644 --- a/content/notes/parse-rss-with-lua.md +++ b/content/notes/parse-rss-with-lua.md | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | --- | 1 | --- |
| 2 | title: Parse RSS feeds with Lua | 2 | title: Parse RSS feeds with Lua |
| 3 | url: parse-rss-with-lua.html | 3 | url: parse-rss-with-lua.html |
| 4 | date: 2023-05-23 | 4 | date: 2023-05-23T12:00:00+02:00 |
| 5 | type: notes | 5 | type: notes |
| 6 | draft: false | 6 | draft: false |
| 7 | tags: [lua, rss] | 7 | tags: [lua, rss] |
diff --git a/content/notes/plan9-screenshot.md b/content/notes/plan9-screenshot.md index fe21ee4..c8a8f23 100644 --- a/content/notes/plan9-screenshot.md +++ b/content/notes/plan9-screenshot.md | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | --- | 1 | --- |
| 2 | title: Take a screenshot in Plan9 | 2 | title: Take a screenshot in Plan9 |
| 3 | url: plan9-screenshot.html | 3 | url: plan9-screenshot.html |
| 4 | date: 2023-05-10 | 4 | date: 2023-05-10T12:00:00+02:00 |
| 5 | type: notes | 5 | type: notes |
| 6 | draft: false | 6 | draft: false |
| 7 | tags: [plan9, screenshot] | 7 | tags: [plan9, screenshot] |
diff --git a/content/notes/preview-troff-man-pages.md b/content/notes/preview-troff-man-pages.md index acda0d6..ad94256 100644 --- a/content/notes/preview-troff-man-pages.md +++ b/content/notes/preview-troff-man-pages.md | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | --- | 1 | --- |
| 2 | title: Previews how man page written in Troff will look like | 2 | title: Previews how man page written in Troff will look like |
| 3 | url: preview-troff-man-pages.html | 3 | url: preview-troff-man-pages.html |
| 4 | date: 2023-05-15 | 4 | date: 2023-05-15T12:00:00+02:00 |
| 5 | type: notes | 5 | type: notes |
| 6 | draft: false | 6 | draft: false |
| 7 | tags: [troff, man] | 7 | tags: [troff, man] |
diff --git a/content/notes/run-9front-in-qemu.md b/content/notes/run-9front-in-qemu.md index 0001162..3bf2ff5 100644 --- a/content/notes/run-9front-in-qemu.md +++ b/content/notes/run-9front-in-qemu.md | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | --- | 1 | --- |
| 2 | title: Run 9front in Qemu | 2 | title: Run 9front in Qemu |
| 3 | url: run-9front-in-qemu.html | 3 | url: run-9front-in-qemu.html |
| 4 | date: 2023-05-05 | 4 | date: 2023-05-05T12:00:00+02:00 |
| 5 | type: notes | 5 | type: notes |
| 6 | draft: false | 6 | draft: false |
| 7 | tags: [plan9, qemu] | 7 | tags: [plan9, qemu] |
diff --git a/content/notes/show-xterm-colors.md b/content/notes/show-xterm-colors.md index fc7280b..008966b 100644 --- a/content/notes/show-xterm-colors.md +++ b/content/notes/show-xterm-colors.md | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | --- | 1 | --- |
| 2 | title: Display xterm color palette | 2 | title: Display xterm color palette |
| 3 | url: write-iso-usb.html | 3 | url: write-iso-usb.html |
| 4 | date: 2023-05-25 | 4 | date: 2023-05-25T12:00:00+02:00 |
| 5 | type: notes | 5 | type: notes |
| 6 | draft: false | 6 | draft: false |
| 7 | tags: [linux, xterm, palette] | 7 | tags: [linux, xterm, palette] |
diff --git a/content/notes/something.md b/content/notes/something.md new file mode 100644 index 0000000..435ea8c --- /dev/null +++ b/content/notes/something.md | |||
| @@ -0,0 +1,11 @@ | |||
| 1 | --- | ||
| 2 | title: "Something" | ||
| 3 | url: something.html | ||
| 4 | date: 2023-05-26T00:37:57+02:00 | ||
| 5 | type: notes | ||
| 6 | draft: true | ||
| 7 | tags: [] | ||
| 8 | --- | ||
| 9 | |||
| 10 | Start here ... | ||
| 11 | |||
diff --git a/content/notes/tmux-sane-defaults.md b/content/notes/tmux-sane-defaults.md index f23e19d..bd76d28 100644 --- a/content/notes/tmux-sane-defaults.md +++ b/content/notes/tmux-sane-defaults.md | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | --- | 1 | --- |
| 2 | title: Sane defaults for tmux with more visible statusbar | 2 | title: Sane defaults for tmux with more visible statusbar |
| 3 | url: tmux-sane-defaults.html | 3 | url: tmux-sane-defaults.html |
| 4 | date: 2023-05-25 | 4 | date: 2023-05-25T12:00:00+02:00 |
| 5 | type: notes | 5 | type: notes |
| 6 | draft: false | 6 | draft: false |
| 7 | tags: [tmux] | 7 | tags: [tmux] |
diff --git a/content/notes/write-iso-usb.md b/content/notes/write-iso-usb.md index 860e6a7..9e379fd 100644 --- a/content/notes/write-iso-usb.md +++ b/content/notes/write-iso-usb.md | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | --- | 1 | --- |
| 2 | title: Write ISO to USB Key | 2 | title: Write ISO to USB Key |
| 3 | url: write-iso-usb.html | 3 | url: write-iso-usb.html |
| 4 | date: 2023-05-08 | 4 | date: 2023-05-08T12:00:00+02:00 |
| 5 | type: notes | 5 | type: notes |
| 6 | draft: false | 6 | draft: false |
| 7 | tags: [linux, iso, usb] | 7 | tags: [linux, iso, usb] |
| @@ -12,3 +12,6 @@ Write ISO to USB key. Nothing fancy here. | |||
| 12 | ```sh | 12 | ```sh |
| 13 | sudo dd if=iso_file.iso of=/dev/sdX bs=4M status=progress conv=fdatasync | 13 | sudo dd if=iso_file.iso of=/dev/sdX bs=4M status=progress conv=fdatasync |
| 14 | ``` | 14 | ``` |
| 15 | |||
| 16 | |||
| 17 | |||
diff --git a/content/pages/books.md b/content/pages/books.md index 473efab..9f58ec5 100644 --- a/content/pages/books.md +++ b/content/pages/books.md | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | --- | 1 | --- |
| 2 | title: Books I've read so far | 2 | title: Books I've read so far |
| 3 | date: 2022-08-27 | 3 | date: 2022-08-27T12:00:00+02:00 |
| 4 | url: books.html | 4 | url: books.html |
| 5 | draft: false | 5 | draft: false |
| 6 | --- | 6 | --- |
diff --git a/content/pages/curriculum-vitae.md b/content/pages/curriculum-vitae.md index 762234e..4fee27c 100644 --- a/content/pages/curriculum-vitae.md +++ b/content/pages/curriculum-vitae.md | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | --- | 1 | --- |
| 2 | title: Curriculum Vitae | 2 | title: Curriculum Vitae |
| 3 | date: 2022-08-27 | 3 | date: 2022-08-27T12:00:00+02:00 |
| 4 | url: curriculum-vitae.html | 4 | url: curriculum-vitae.html |
| 5 | draft: false | 5 | draft: false |
| 6 | --- | 6 | --- |
diff --git a/content/posts/2011-01-13-most-likely-to-succeed-in-year-of-2011.md b/content/posts/2011-01-13-most-likely-to-succeed-in-year-of-2011.md index fdd0075..bdf965a 100644 --- a/content/posts/2011-01-13-most-likely-to-succeed-in-year-of-2011.md +++ b/content/posts/2011-01-13-most-likely-to-succeed-in-year-of-2011.md | |||
| @@ -1,19 +1,35 @@ | |||
| 1 | --- | 1 | --- |
| 2 | title: Most likely to succeed in the year of 2011 | 2 | title: Most likely to succeed in the year of 2011 |
| 3 | url: most-likely-to-succeed-in-year-of-2011.html | 3 | url: most-likely-to-succeed-in-year-of-2011.html |
| 4 | date: 2011-01-13 | 4 | date: 2011-01-13T12:00:00+02:00 |
| 5 | draft: false | 5 | draft: false |
| 6 | --- | 6 | --- |
| 7 | 7 | ||
| 8 | The year of 2010 was definitely the year of Geo-location. The market responded beautifully and lots of very cool services were launched. We all have to thank the mobile market for such extensive adoption. With new generations of mobile phones that are not only buffed with high-tech hardware but are also affordable. We can now manage tasks that were not so long time ago, almost Star Trek’ish. And all this had and has great influence on the destination to which we are going now. | 8 | The year of 2010 was definitely the year of Geo-location. The market responded |
| 9 | beautifully and lots of very cool services were launched. We all have to thank | ||
| 10 | the mobile market for such extensive adoption. With new generations of mobile | ||
| 11 | phones that are not only buffed with high-tech hardware but are also affordable. | ||
| 12 | We can now manage tasks that were not so long time ago, almost Star Trek’ish. | ||
| 13 | And all this had and has great influence on the destination to which we are | ||
| 14 | going now. | ||
| 9 | 15 | ||
| 10 | Reading all this articles about new innovation about new thriving technologies makes me wonder what’s the next step. The future is the mesh, like Lisa Gansky said in her book The Mesh. | 16 | Reading all this articles about new innovation about new thriving technologies |
| 17 | makes me wonder what’s the next step. The future is the mesh, like Lisa Gansky | ||
| 18 | said in her book The Mesh. | ||
| 11 | 19 | ||
| 12 | Many still have conservative views on distributed systems. The problems with security of information. Fear of not controlling every aspect of information flow. I am very opened to distributed systems and heterogeneous applications, and I think this is the correct and best way to proceed. | 20 | Many still have conservative views on distributed systems. The problems with |
| 21 | security of information. Fear of not controlling every aspect of information | ||
| 22 | flow. I am very opened to distributed systems and heterogeneous applications, | ||
| 23 | and I think this is the correct and best way to proceed. | ||
| 13 | 24 | ||
| 14 | This year will definitely be about communication platforms. Mobile to mobile. Machine to mobile and vice versa. All the tech is available and ready to put into action. Wireless is today’s new mantra. And the concept of semantic web is now ready for industry. | 25 | This year will definitely be about communication platforms. Mobile to mobile. |
| 26 | Machine to mobile and vice versa. All the tech is available and ready to put | ||
| 27 | into action. Wireless is today’s new mantra. And the concept of semantic web | ||
| 28 | is now ready for industry. | ||
| 15 | 29 | ||
| 16 | Applications and developers now can gain access to new layers of systems and can prepare and build solutions to meet the high quality needs of market. The speed is everything now. | 30 | Applications and developers now can gain access to new layers of systems and |
| 31 | can prepare and build solutions to meet the high quality needs of market. The | ||
| 32 | speed is everything now. | ||
| 17 | 33 | ||
| 18 | My vote goes to “Machine to Machine” and “Embedded Systems”! | 34 | My vote goes to “Machine to Machine” and “Embedded Systems”! |
| 19 | 35 | ||
| @@ -22,3 +38,4 @@ My vote goes to “Machine to Machine” and “Embedded Systems”! | |||
| 22 | - [COOS Project (connectivity initiative)](http://www.coosproject.org/maven-site/1.0.0/project-info.html) | 38 | - [COOS Project (connectivity initiative)](http://www.coosproject.org/maven-site/1.0.0/project-info.html) |
| 23 | - [Community for machine-to-machine](http://m2m.com/index.jspa) | 39 | - [Community for machine-to-machine](http://m2m.com/index.jspa) |
| 24 | - [Embedded system](http://en.wikipedia.org/wiki/Embedded_system) | 40 | - [Embedded system](http://en.wikipedia.org/wiki/Embedded_system) |
| 41 | |||
diff --git a/content/posts/2012-03-09-led-technology-not-so-eco.md b/content/posts/2012-03-09-led-technology-not-so-eco.md index 514b1c3..6e5aab9 100644 --- a/content/posts/2012-03-09-led-technology-not-so-eco.md +++ b/content/posts/2012-03-09-led-technology-not-so-eco.md | |||
| @@ -1,20 +1,32 @@ | |||
| 1 | --- | 1 | --- |
| 2 | title: LED technology might not be as eco-friendly as you think | 2 | title: LED technology might not be as eco-friendly as you think |
| 3 | url: led-technology-not-so-eco.html | 3 | url: led-technology-not-so-eco.html |
| 4 | date: 2012-03-09 | 4 | date: 2012-03-09T12:00:00+02:00 |
| 5 | draft: false | 5 | draft: false |
| 6 | --- | 6 | --- |
| 7 | 7 | ||
| 8 | There is a lot of talk about LED technology. It is beginning to infiltrate industry at a fast rate, and it’s a challenge for designers and also engineers. I wondered when a weakness will be revealed. Then I stomped on an article talking about harm in using LED technology. It looks like this magical technology is not so magical and eco-friendly. | 8 | There is a lot of talk about LED technology. It is beginning to infiltrate |
| 9 | industry at a fast rate, and it’s a challenge for designers and also engineers. | ||
| 10 | I wondered when a weakness will be revealed. Then I stomped on an article | ||
| 11 | talking about harm in using LED technology. It looks like this magical | ||
| 12 | technology is not so magical and eco-friendly. | ||
| 9 | 13 | ||
| 10 | A new study from the University of California indicates that LED lights contain toxic metals, and should be produced, used and disposed of carefully. Besides the lead and nickel, the bulbs and their associated parts were also found to contain arsenic, copper, and other metals that have been linked to different cancers, neurological damage, kidney disease, hypertension, skin rashes and other illnesses in humans, and to ecological damage in waterways. | 14 | A new study from the University of California indicates that LED lights |
| 15 | contain toxic metals, and should be produced, used and disposed of carefully. | ||
| 16 | Besides the lead and nickel, the bulbs and their associated parts were also | ||
| 17 | found to contain arsenic, copper, and other metals that have been linked to | ||
| 18 | different cancers, neurological damage, kidney disease, hypertension, skin | ||
| 19 | rashes and other illnesses in humans, and to ecological damage in waterways. | ||
| 11 | 20 | ||
| 12 | Since then, I haven’t yet found any regulation for disposal of LED lights or any other regulation or standard. This might be a problem in the future. And it is a massive drawback. This might have quite an impact on consumer market. | 21 | Since then, I haven’t yet found any regulation for disposal of LED lights or |
| 13 | 22 | any other regulation or standard. This might be a problem in the future. And | |
| 14 | Nevertheless, there is a potential, and I am sure the market will adapt. I also hope I will be reading documents regarding solution for this concern soon. | 23 | it is a massive drawback. This might have quite an impact on consumer market. |
| 15 | 24 | ||
| 25 | Nevertheless, there is a potential, and I am sure the market will adapt. I | ||
| 26 | also hope I will be reading documents regarding solution for this concern soon. | ||
| 16 | 27 | ||
| 17 | **Additional resources:** | 28 | **Additional resources:** |
| 18 | 29 | ||
| 19 | - [Recycling and Disposal of Light Bulbs](http://ezinearticles.com/?Recycling-and-Disposal-of-Light-Bulbs&id=1091304) | 30 | - [Recycling and Disposal of Light Bulbs](http://ezinearticles.com/?Recycling-and-Disposal-of-Light-Bulbs&id=1091304) |
| 20 | - [How to Dispose of a Low-Energy Light Bulb](http://www.ehow.com/how_7483442_dispose-lowenergy-light-bulb.html) | 31 | - [How to Dispose of a Low-Energy Light Bulb](http://www.ehow.com/how_7483442_dispose-lowenergy-light-bulb.html) |
| 32 | |||
diff --git a/content/posts/2013-10-24-wireless-sensor-networks.md b/content/posts/2013-10-24-wireless-sensor-networks.md index e8948fb..dabdebc 100644 --- a/content/posts/2013-10-24-wireless-sensor-networks.md +++ b/content/posts/2013-10-24-wireless-sensor-networks.md | |||
| @@ -1,25 +1,55 @@ | |||
| 1 | --- | 1 | --- |
| 2 | title: Wireless sensor networks | 2 | title: Wireless sensor networks |
| 3 | url: wireless-sensor-networks.html | 3 | url: wireless-sensor-networks.html |
| 4 | date: 2013-10-24 | 4 | date: 2013-10-24T12:00:00+02:00 |
| 5 | draft: false | 5 | draft: false |
| 6 | --- | 6 | --- |
| 7 | 7 | ||
| 8 | Zigbee networks have this wonderful capability to self-heal, which means they can reorder connections between them if one of them is inoperable. This works our of the box when you deploy them. But you have to have in mind that achieving this is not as easy as you would think. None of it is plug&play. So to make your life a bit easier, here are some pointers which, I hope, will help you. | 8 | Zigbee networks have this wonderful capability to self-heal, which means they |
| 9 | can reorder connections between them if one of them is inoperable. This works | ||
| 10 | our of the box when you deploy them. But you have to have in mind that | ||
| 11 | achieving this is not as easy as you would think. None of it is plug&play. | ||
| 12 | So to make your life a bit easier, here are some pointers which, I hope, | ||
| 13 | will help you. | ||
| 9 | 14 | ||
| 10 | - Be careful when you are ordering your equipment abroad. There are many rules and regulations you need to comply before you get your Xbee radios. What they do is they wait until you prove that you won’t use the technology for some kind of evil take over control of the world project :). For this, they have EAR (Export Administration Regulations) which basically means “This product may require a license to export from the United States.”. | 15 | - Be careful when you are ordering your equipment abroad. There are many rules |
| 11 | - I don’t know if this applies for every country, but when we purchased our Xbee radios from Mouser, this was mandatory! What we needed to do was to print out a form and write information about our company and send them a copy via email. With this document, we proved that we are a legitimate company. | 16 | and regulations you need to comply before you get your Xbee radios. What they |
| 12 | - When you complete your purchase and send all the documentation, you are not clear yet. Then customs will take it from there :). There will be some additional costs. Before purchasing, make sure you have as much information about costs as possible. Because it can get costly in the end. | 17 | do is they wait until you prove that you won’t use the technology for some |
| 13 | - I suggest you use companies from your country. You can seriously cut your costs. Here in Slovenia, the best option so far as I know is Farnell. And based on my personal experience, they rock! All I need to say! | 18 | kind of evil take over control of the world project :). For this, they have |
| 14 | - Make plans when ordering larger quantities. Do not, I say, do not make your orders in December! :) Believe me! You will have problems with stock they can provide for you. So, we were forced to buy some things from Mouser, which was extremely painful because of all the regulations you need to obey when importing goods from the USA. | 19 | EAR (Export Administration Regulations) which basically means “This product |
| 15 | - Make sure that firmware version on your Xbee radios is exactly the same! Do not get creative!!! I propose using templates. You can get template by exporting settings/profile in X-CTU application. Make sure you have enabled “Upgrade firmware” so you can be sure each radio has the same firmware. | 20 | may require a license to export from the United States.”. |
| 16 | - And again: make plans! Plan everything! In months advanced! You will thank me later :) | 21 | - I don’t know if this applies for every country, but when we purchased our |
| 22 | Xbee radios from Mouser, this was mandatory! What we needed to do was to | ||
| 23 | print out a form and write information about our company and send them a | ||
| 24 | copy via email. With this document, we proved that we are a legitimate | ||
| 25 | company. | ||
| 26 | - When you complete your purchase and send all the documentation, you are not | ||
| 27 | clear yet. Then customs will take it from there :). There will be some | ||
| 28 | additional costs. Before purchasing, make sure you have as much information | ||
| 29 | about costs as possible. Because it can get costly in the end. | ||
| 30 | - I suggest you use companies from your country. You can seriously cut your | ||
| 31 | costs. Here in Slovenia, the best option so far as I know is Farnell. And | ||
| 32 | based on my personal experience, they rock! All I need to say! | ||
| 33 | - Make plans when ordering larger quantities. Do not, I say, do not make your | ||
| 34 | orders in December! :) Believe me! You will have problems with stock they | ||
| 35 | can provide for you. So, we were forced to buy some things from Mouser, | ||
| 36 | which was extremely painful because of all the regulations you need to obey | ||
| 37 | when importing goods from the USA. | ||
| 38 | - Make sure that firmware version on your Xbee radios is exactly the same! Do | ||
| 39 | not get creative!!! I propose using templates. You can get template by | ||
| 40 | exporting settings/profile in X-CTU application. Make sure you have enabled | ||
| 41 | “Upgrade firmware” so you can be sure each radio has the same firmware. | ||
| 42 | - And again: make plans! Plan everything! In months advanced! You will thank | ||
| 43 | me later :) | ||
| 17 | - Test, test, test. Wireless networks can be tricky. | 44 | - Test, test, test. Wireless networks can be tricky. |
| 18 | 45 | ||
| 19 | If you are serious, I suggest you buy this book, Building Wireless Sensor Networks. You will get a glimpse of how networks work in lumens terms. It is a good starting point for everybody who wants to build wireless networks. | 46 | If you are serious, I suggest you buy this book, Building Wireless Sensor |
| 47 | Networks. You will get a glimpse of how networks work in lumens terms. It is | ||
| 48 | a good starting point for everybody who wants to build wireless networks. | ||
| 20 | 49 | ||
| 21 | **Additional resources:** | 50 | **Additional resources:** |
| 22 | 51 | ||
| 23 | - http://www.digi.com/aboutus/export/generalexportinfo | 52 | - http://www.digi.com/aboutus/export/generalexportinfo |
| 24 | - http://doresearch.stanford.edu/research-scholarship/export-controls/export-controlled-or-embargoed-countries-entities-and-persons | 53 | - http://doresearch.stanford.edu/research-scholarship/export-controls/export-controlled-or-embargoed-countries-entities-and-persons |
| 25 | - http://www.bis.doc.gov/licensing/exportingbasics.htm | 54 | - http://www.bis.doc.gov/licensing/exportingbasics.htm |
| 55 | |||
diff --git a/content/posts/2015-11-10-software-development-pitfalls.md b/content/posts/2015-11-10-software-development-pitfalls.md index ec7fcb8..57e9736 100644 --- a/content/posts/2015-11-10-software-development-pitfalls.md +++ b/content/posts/2015-11-10-software-development-pitfalls.md | |||
| @@ -1,72 +1,182 @@ | |||
| 1 | --- | 1 | --- |
| 2 | title: Software development and my favorite pitfalls | 2 | title: Software development and my favorite pitfalls |
| 3 | url: software-development-pitfalls.html | 3 | url: software-development-pitfalls.html |
| 4 | date: 2015-11-10 | 4 | date: 2015-11-10T12:00:00+02:00 |
| 5 | draft: false | 5 | draft: false |
| 6 | --- | 6 | --- |
| 7 | 7 | ||
| 8 | Over the years I had the privilege to work on some very excited projects both in software development field and also in electronics field and every experience taught me some invaluable lessons about how NOT TO approach development. And through this post I will try to point out some absurd, outdated techniques I find the most annoying and damaging during a development cycle. There will be swearing because this topic really gets on my nerves and I never coherently tried to explain them in writing. So if I get heated up, please bear with me. | 8 | Over the years I had the privilege to work on some very excited projects both |
| 9 | 9 | in software development field and also in electronics field and every experience | |
| 10 | As new methods of project management are emerging, underlying processes still stay old and outdated. This is mainly because we as people are unable to completely shift away from these approaches. | 10 | taught me some invaluable lessons about how NOT TO approach development. And |
| 11 | 11 | through this post I will try to point out some absurd, outdated techniques I | |
| 12 | I was always struggling with communication, and many times that cost me a relationship or two because I was not on the ball all the time. Through every experience, I became more convinced that I am the problem and never ever doubted that the problem may be that communication never evolved a single step from emails. And if you think for a second, not many things have changed around this topic. We just have different representations of email (message boards, chats, project management tools). And I believe this is the real issue we are facing now. | 12 | find the most annoying and damaging during a development cycle. There will be |
| 13 | 13 | swearing because this topic really gets on my nerves and I never coherently | |
| 14 | There are many articles written about hyper connectivity and the effects that are a direct result of it. But mainstream does nothing towards it. We are just putting out fires, and we do nothing to prevent it. I am certain this will be a major source of grief in coming years. And what we all can do to avoid this is to change our mindset and experiment on our communication skills, development approaches. We need to maximize possible output that a person can give. And to achieve this we need to listen to them, encourage them. I know that not everybody is a naturally born leader, but with enough practice and encouragement they also can become active participants in leadership. | 14 | tried to explain them in writing. So if I get heated up, please bear with me. |
| 15 | 15 | ||
| 16 | There are many talks now about methodologies such as Scrum, Kanban, Cleanroom and they all fucking piss me of :). These are all boxes that imprison people and take away their freedom of thought. This is a straightforward mindfuck / amputation of creativity. | 16 | As new methods of project management are emerging, underlying processes still |
| 17 | 17 | stay old and outdated. This is mainly because we as people are unable to | |
| 18 | Let me list a couple of things that I find really destructive and bad for a project and in a long run company. | 18 | completely shift away from these approaches. |
| 19 | |||
| 20 | I was always struggling with communication, and many times that cost me a | ||
| 21 | relationship or two because I was not on the ball all the time. Through every | ||
| 22 | experience, I became more convinced that I am the problem and never ever | ||
| 23 | doubted that the problem may be that communication never evolved a single step | ||
| 24 | from emails. And if you think for a second, not many things have changed around | ||
| 25 | this topic. We just have different representations of email (message boards, | ||
| 26 | chats, project management tools). And I believe this is the real issue we are | ||
| 27 | facing now. | ||
| 28 | |||
| 29 | There are many articles written about hyper connectivity and the effects that | ||
| 30 | are a direct result of it. But mainstream does nothing towards it. We are just | ||
| 31 | putting out fires, and we do nothing to prevent it. I am certain this will be | ||
| 32 | a major source of grief in coming years. And what we all can do to avoid this | ||
| 33 | is to change our mindset and experiment on our communication skills, | ||
| 34 | development approaches. We need to maximize possible output that a person can | ||
| 35 | give. And to achieve this we need to listen to them, encourage them. I know | ||
| 36 | that not everybody is a naturally born leader, but with enough practice and | ||
| 37 | encouragement they also can become active participants in leadership. | ||
| 38 | |||
| 39 | There are many talks now about methodologies such as Scrum, Kanban, Cleanroom | ||
| 40 | and they all fucking piss me of :). These are all boxes that imprison people | ||
| 41 | and take away their freedom of thought. This is a straightforward | ||
| 42 | mindfuck / amputation of creativity. | ||
| 43 | |||
| 44 | Let me list a couple of things that I find really destructive and bad for a | ||
| 45 | project and in a long run company. | ||
| 19 | 46 | ||
| 20 | ## Ping emails | 47 | ## Ping emails |
| 21 | 48 | ||
| 22 | Ping emails are emails you have to write as soon as you receive an email. Its sole purpose is to inform the sender that you received their email, and you are working on it. Its result is only to calm down the sender that their task is being dealt with. It’s intent basically is, I did my job by sending you this email, so I am on clear grounds. I categorize this email as fuck you email. This is one of the most irritating types of emails I need to write. This is the ultimate control freak show you can experience, and it gives the sender a false feeling of control. Newsflash: We do not live in 1982 where there was a possibility that email never reached the destination. I really hate this from the bottom of my heart. | 49 | Ping emails are emails you have to write as soon as you receive an email. Its |
| 23 | 50 | sole purpose is to inform the sender that you received their email, and you | |
| 24 | They should be like: “Yes, I am fucking alive, and I am at your service my leash!”. I guess if I would reply like this, I wouldn’t have to write any more of this kind of messages. | 51 | are working on it. Its result is only to calm down the sender that their task |
| 52 | is being dealt with. It’s intent basically is, I did my job by sending you | ||
| 53 | this email, so I am on clear grounds. I categorize this email as fuck you email. | ||
| 54 | This is one of the most irritating types of emails I need to write. This is | ||
| 55 | the ultimate control freak show you can experience, and it gives the sender a | ||
| 56 | false feeling of control. Newsflash: We do not live in 1982 where there was a | ||
| 57 | possibility that email never reached the destination. I really hate this from | ||
| 58 | the bottom of my heart. | ||
| 59 | |||
| 60 | They should be like: “Yes, I am fucking alive, and I am at your service my | ||
| 61 | leash!”. I guess if I would reply like this, I wouldn’t have to write any | ||
| 62 | more of this kind of messages. | ||
| 25 | 63 | ||
| 26 | ## Everybody is a project manager | 64 | ## Everybody is a project manager |
| 27 | 65 | ||
| 28 | Well, this is a tough one. I noticed that as soon as you let people to give their suggestions, you are basically screwed. There is a truth in the saying: “Give low expectations and deliver little more than you promised.”. | 66 | Well, this is a tough one. I noticed that as soon as you let people to give |
| 67 | their suggestions, you are basically screwed. There is a truth in the saying: | ||
| 68 | “Give low expectations and deliver little more than you promised.”. | ||
| 29 | 69 | ||
| 30 | People tend to take a role of a manager as soon as they are presented with an opportunity. And by getting angry at them, you only provoke yourself. They are not at fault. You just need to tell them they are only giving suggestions and not tasks at the beginning and everything will be alright. But if you give them a feeling that they are in control, you will have immense problems explaining why their features are not in current release. | 70 | People tend to take a role of a manager as soon as they are presented with an |
| 71 | opportunity. And by getting angry at them, you only provoke yourself. They are | ||
| 72 | not at fault. You just need to tell them they are only giving suggestions and | ||
| 73 | not tasks at the beginning and everything will be alright. But if you give | ||
| 74 | them a feeling that they are in control, you will have immense problems | ||
| 75 | explaining why their features are not in current release. | ||
| 31 | 76 | ||
| 32 | Project mission must be always leading project requirements and any deviation from it will result in major project butchering. And by this, I mean that the project will get its own path, and you will be left with half done software that helps nobody. Clear mission goals and clean execution will allow you to develop software will clear intent. | 77 | Project mission must be always leading project requirements and any deviation |
| 78 | from it will result in major project butchering. And by this, I mean that the | ||
| 79 | project will get its own path, and you will be left with half done software | ||
| 80 | that helps nobody. Clear mission goals and clean execution will allow you to | ||
| 81 | develop software will clear intent. | ||
| 33 | 82 | ||
| 34 | ## We are never wrong | 83 | ## We are never wrong |
| 35 | 84 | ||
| 36 | I find this type of arrogance the worst. We must always conduct ourselves that we are infallible and cannot make mistakes. As soon as a procedure or process is established, there is no room for changes or improvements. This is the most idiotic thing someone can say of think. I think that processes need to involve and change over time. This is imperative and need to have in your organization if you want to improve and develop company. We all need to grow balls and change everything in order to adapt to current situations. Being a prisoner of predefined processes kills creativity. | 85 | I find this type of arrogance the worst. We must always conduct ourselves that |
| 37 | 86 | we are infallible and cannot make mistakes. As soon as a procedure or process | |
| 38 | I am constantly trying new software for project managing and communication. I believe every team has its own dynamic, and it needs to be discovered organically and naturally through many experiments. By putting the team in a box, you are amputating their creativity and therefore minimizing their potential. But if you talk to an executive, you will mainly find archetypical thinking and a strong need to compartmentalize everything from business processes to resource management. And this type of management that often displays micromanagement techniques only works for short periods (couple of years) and then employees either leave the company or become basically retarded drones on autopilot. | 87 | is established, there is no room for changes or improvements. This is the most |
| 88 | idiotic thing someone can say of think. I think that processes need to involve | ||
| 89 | and change over time. This is imperative and need to have in your organization | ||
| 90 | if you want to improve and develop company. We all need to grow balls and change | ||
| 91 | everything in order to adapt to current situations. Being a prisoner of | ||
| 92 | predefined processes kills creativity. | ||
| 93 | |||
| 94 | I am constantly trying new software for project managing and communication. | ||
| 95 | I believe every team has its own dynamic, and it needs to be discovered | ||
| 96 | organically and naturally through many experiments. By putting the team in a | ||
| 97 | box, you are amputating their creativity and therefore minimizing their | ||
| 98 | potential. But if you talk to an executive, you will mainly find archetypical | ||
| 99 | thinking and a strong need to compartmentalize everything from business | ||
| 100 | processes to resource management. And this type of management that often | ||
| 101 | displays micromanagement techniques only works for short periods (couple of | ||
| 102 | years) and then employees either leave the company or become basically retarded | ||
| 103 | drones on autopilot. | ||
| 39 | 104 | ||
| 40 | ## Micromanaging | 105 | ## Micromanaging |
| 41 | 106 | ||
| 42 | This basically implies that everybody on the team is an idiot who needs to have a to-do list that they cannot write themselves. How about spoon-feeding the team at launch because besides the team leader, everybody must be a retarded idiot at best? | 107 | This basically implies that everybody on the team is an idiot who needs to |
| 108 | have a to-do list that they cannot write themselves. How about spoon-feeding | ||
| 109 | the team at launch because besides the team leader, everybody must be a | ||
| 110 | retarded idiot at best? | ||
| 43 | 111 | ||
| 44 | I prefer milestones as they give developers much more freedom and creativity in developing and not waste their time checking some bizarre to-do list that was not even thought through. Projects constantly change throughout the development cycle, and all you are left at the end is a list of unchecked tasks and the wrath of management why they are not completed. Best WTF moment! | 112 | I prefer milestones as they give developers much more freedom and creativity |
| 113 | in developing and not waste their time checking some bizarre to-do list that | ||
| 114 | was not even thought through. Projects constantly change throughout the | ||
| 115 | development cycle, and all you are left at the end is a list of unchecked tasks | ||
| 116 | and the wrath of management why they are not completed. Best WTF moment! | ||
| 45 | 117 | ||
| 46 | ## Human contact — no need for it! | 118 | ## Human contact — no need for it! |
| 47 | 119 | ||
| 48 | We are vigorously trying to eliminate physical contact by replacing short meetings with software, with no regards that we are not machines. Many times a simple 5-min meeting at morning can solve most of the problems. In rapid development, short bursts of man to man communication is possibly the best way to go. | 120 | We are vigorously trying to eliminate physical contact by replacing short |
| 121 | meetings with software, with no regards that we are not machines. Many times | ||
| 122 | a simple 5-min meeting at morning can solve most of the problems. In rapid | ||
| 123 | development, short bursts of man to man communication is possibly the best | ||
| 124 | way to go. | ||
| 49 | 125 | ||
| 50 | We now have all this software available, and all what we get out of it is a giant clusterfuck. An obstacle and not a solution. So, why we still use them? | 126 | We now have all this software available, and all what we get out of it is a |
| 127 | giant clusterfuck. An obstacle and not a solution. So, why we still use them? | ||
| 51 | 128 | ||
| 52 | ## MVP is killing innovation | 129 | ## MVP is killing innovation |
| 53 | 130 | ||
| 54 | Many will disagree with me on this one, but I stand strong by this statement. What I noticed in my experience that all this buzz words around us only mislead and capture us in a circle of solving issues that already have a solution, but we are unable to see it without using some fancy word for it. | 131 | Many will disagree with me on this one, but I stand strong by this statement. |
| 132 | What I noticed in my experience that all this buzz words around us only | ||
| 133 | mislead and capture us in a circle of solving issues that already have a | ||
| 134 | solution, but we are unable to see it without using some fancy word for it. | ||
| 55 | 135 | ||
| 56 | The toughest thing to do for a developer is to minimize requirements. Well, this is though only for bad developers. Yes, I said it. There are many types of developers out there. And those unable to minimize feature scope are the ones you don’t need on your team. Their only goal is to solve problems that exist only in their heads. And then you have to argue with them, and waste energy on them, instead of developing your awesome product. They are a cancer and I suggest you cut them off. | 136 | The toughest thing to do for a developer is to minimize requirements. Well, |
| 137 | this is though only for bad developers. Yes, I said it. There are many types | ||
| 138 | of developers out there. And those unable to minimize feature scope are the | ||
| 139 | ones you don’t need on your team. Their only goal is to solve problems that | ||
| 140 | exist only in their heads. And then you have to argue with them, and waste | ||
| 141 | energy on them, instead of developing your awesome product. They are a cancer | ||
| 142 | and I suggest you cut them off. | ||
| 57 | 143 | ||
| 58 | MVP as an idea is great, but sadly people don’t understand underlying philosophy, and they spent too much time focusing and fixating on something that every sane person with normal IQ will understand without some made up acronym. And the result is a lot of talking and barely no execution. | 144 | MVP as an idea is great, but sadly people don’t understand underlying |
| 145 | philosophy, and they spent too much time focusing and fixating on something | ||
| 146 | that every sane person with normal IQ will understand without some made up | ||
| 147 | acronym. And the result is a lot of talking and barely no execution. | ||
| 59 | 148 | ||
| 60 | Well, MVP is not directly killing innovation, but stupid people do when they try to understand it. | 149 | Well, MVP is not directly killing innovation, but stupid people do when they |
| 150 | try to understand it. | ||
| 61 | 151 | ||
| 62 | ## Pressure wasteland | 152 | ## Pressure wasteland |
| 63 | 153 | ||
| 64 | You must never allow to be pressured into confirming a deadline if you are not confident. We often feel a need that we are in service of others, which is true to some extent. But it is also true that others are in service to us to some extent. And we forget this all the time. We are all pressured all the time to make decisions just to calm other people down. And when they leave your office you experience WTF moment :) How the hell did they manage to fuck me up again? | 154 | You must never allow to be pressured into confirming a deadline if you are not |
| 65 | 155 | confident. We often feel a need that we are in service of others, which is | |
| 66 | People need to realize that the more pressure you put on somebody, the less they will be able to do. So 5-min update email requests will only resolve in mental breakdown and inability to work that day. Constant poking is probably the only thing I lose my mind instantly. For all you that are doing this: “Stop bothering us with your insecurities and let us do our job. We will do it quicker and better without you breathing down our necks.” | 156 | true to some extent. But it is also true that others are in service to us to |
| 67 | 157 | some extent. And we forget this all the time. We are all pressured all the | |
| 68 | If this happens to me, I end up with no energy at the end. Don’t you get it? You will get much more from and out of me if you ask me like a human person and not your personal butler. On a long run, you are destroying your relationships and nobody would want to work with you. Your schizophrenic approach will damage only you in a long run. Nobody is anybody’s property. | 158 | time to make decisions just to calm other people down. And when they leave |
| 159 | your office you experience WTF moment :) How the hell did they manage to | ||
| 160 | fuck me up again? | ||
| 161 | |||
| 162 | People need to realize that the more pressure you put on somebody, the less | ||
| 163 | they will be able to do. So 5-min update email requests will only resolve in | ||
| 164 | mental breakdown and inability to work that day. Constant poking is probably | ||
| 165 | the only thing I lose my mind instantly. For all you that are doing this: | ||
| 166 | “Stop bothering us with your insecurities and let us do our job. We will do | ||
| 167 | it quicker and better without you breathing down our necks.” | ||
| 168 | |||
| 169 | If this happens to me, I end up with no energy at the end. Don’t you get it? | ||
| 170 | You will get much more from and out of me if you ask me like a human person | ||
| 171 | and not your personal butler. On a long run, you are destroying your | ||
| 172 | relationships and nobody would want to work with you. Your schizophrenic | ||
| 173 | approach will damage only you in a long run. Nobody is anybody’s property. | ||
| 69 | 174 | ||
| 70 | ## Conclusion | 175 | ## Conclusion |
| 71 | 176 | ||
| 72 | I am guilty of many things described in this post. And I find it hard sometimes to acknowledge this. And I lie to myself and try vigorously to find some explanation why I do these things. There is always space for growth. And maybe you will also find some of yourself in this post and realize what needs to change for you to evolve. | 177 | I am guilty of many things described in this post. And I find it hard sometimes |
| 178 | to acknowledge this. And I lie to myself and try vigorously to find some | ||
| 179 | explanation why I do these things. There is always space for growth. And | ||
| 180 | maybe you will also find some of yourself in this post and realize what needs | ||
| 181 | to change for you to evolve. | ||
| 182 | |||
diff --git a/content/posts/2017-03-07-golang-profiling-simplified.md b/content/posts/2017-03-07-golang-profiling-simplified.md index 92ff881..7eee2dd 100644 --- a/content/posts/2017-03-07-golang-profiling-simplified.md +++ b/content/posts/2017-03-07-golang-profiling-simplified.md | |||
| @@ -1,27 +1,40 @@ | |||
| 1 | --- | 1 | --- |
| 2 | title: Golang profiling simplified | 2 | title: Golang profiling simplified |
| 3 | url: golang-profiling-simplified.html | 3 | url: golang-profiling-simplified.html |
| 4 | date: 2017-03-07 | 4 | date: 2017-03-07T12:00:00+02:00 |
| 5 | draft: false | 5 | draft: false |
| 6 | --- | 6 | --- |
| 7 | 7 | ||
| 8 | Many posts have been written regarding profiling in Golang and I haven’t found proper tutorial regarding this. Almost all of them are missing some part of important information and it gets pretty frustrating when you have a deadline and are not finding simple distilled solution. | 8 | Many posts have been written regarding profiling in Golang and I haven’t found |
| 9 | proper tutorial regarding this. Almost all of them are missing some part of | ||
| 10 | important information and it gets pretty frustrating when you have a deadline | ||
| 11 | and are not finding simple distilled solution. | ||
| 9 | 12 | ||
| 10 | Nevertheless, after searching and experimenting I have found a solution that works for me and probably should also for you. | 13 | Nevertheless, after searching and experimenting I have found a solution that |
| 14 | works for me and probably should also for you. | ||
| 11 | 15 | ||
| 12 | ## Where are my pprof files? | 16 | ## Where are my pprof files? |
| 13 | 17 | ||
| 14 | By default pprof files are generated in /tmp/ folder. You can override folder where this files are generated programmatically in your golang code as we will see below in example. | 18 | By default pprof files are generated in /tmp/ folder. You can override folder |
| 19 | where this files are generated programmatically in your golang code as we will | ||
| 20 | see below in example. | ||
| 15 | 21 | ||
| 16 | ## Why is my CPU profile empty? | 22 | ## Why is my CPU profile empty? |
| 17 | 23 | ||
| 18 | I have found out that sometimes CPU profile is empty because program was not executing long enough. Programs, that execute too quickly don’t produce pprof file in my cases. Well, file is generated but only contains 4KB of information. | 24 | I have found out that sometimes CPU profile is empty because program was not |
| 25 | executing long enough. Programs, that execute too quickly don’t produce pprof | ||
| 26 | file in my cases. Well, file is generated but only contains 4KB of information. | ||
| 19 | 27 | ||
| 20 | ## Profiling | 28 | ## Profiling |
| 21 | 29 | ||
| 22 | As you can see from examples we are executing dummy_benchmark functions to ensure some sort of execution. Memory profiling can be done without such a “complex” function. But CPU profiling needs it. | 30 | As you can see from examples we are executing dummy_benchmark functions to |
| 31 | ensure some sort of execution. Memory profiling can be done without such a | ||
| 32 | “complex” function. But CPU profiling needs it. | ||
| 23 | 33 | ||
| 24 | Both memory and CPU profiling examples are almost the same. Only parameters in main function when calling profile.Start are different. When we set profile.ProfilePath(“.”) we tell profiler to store pprof files in the same folder as our program. | 34 | Both memory and CPU profiling examples are almost the same. Only parameters |
| 35 | in main function when calling profile.Start are different. When we set | ||
| 36 | profile.ProfilePath(“.”) we tell profiler to store pprof files in the same | ||
| 37 | folder as our program. | ||
| 25 | 38 | ||
| 26 | ### Memory profiling | 39 | ### Memory profiling |
| 27 | 40 | ||
| @@ -109,3 +122,4 @@ This will generate PDF document with visualized profile. | |||
| 109 | 122 | ||
| 110 | - [Memory PDF profile example](/assets/go-profiling/golang-profiling-mem.pdf) | 123 | - [Memory PDF profile example](/assets/go-profiling/golang-profiling-mem.pdf) |
| 111 | - [CPU PDF profile example](/assets/go-profiling/golang-profiling-cpu.pdf) | 124 | - [CPU PDF profile example](/assets/go-profiling/golang-profiling-cpu.pdf) |
| 125 | |||
diff --git a/content/posts/2017-04-17-what-i-ve-learned-developing-ad-server.md b/content/posts/2017-04-17-what-i-ve-learned-developing-ad-server.md index 6fca4ce..1b9be06 100644 --- a/content/posts/2017-04-17-what-i-ve-learned-developing-ad-server.md +++ b/content/posts/2017-04-17-what-i-ve-learned-developing-ad-server.md | |||
| @@ -1,11 +1,14 @@ | |||
| 1 | --- | 1 | --- |
| 2 | title: What I've learned developing ad server | 2 | title: What I've learned developing ad server |
| 3 | url: what-i-ve-learned-developing-ad-server.html | 3 | url: what-i-ve-learned-developing-ad-server.html |
| 4 | date: 2017-04-17 | 4 | date: 2017-04-17T12:00:00+02:00 |
| 5 | draft: false | 5 | draft: false |
| 6 | --- | 6 | --- |
| 7 | 7 | ||
| 8 | For the past year and half I have been developing native advertising server that contextually matches ads and displays them in different template forms on variety of websites. This project grew from serving thousands of ads per day to millions. | 8 | For the past year and half I have been developing native advertising server |
| 9 | that contextually matches ads and displays them in different template forms | ||
| 10 | on variety of websites. This project grew from serving thousands of ads per | ||
| 11 | day to millions. | ||
| 9 | 12 | ||
| 10 | The system is made from couple of core components: | 13 | The system is made from couple of core components: |
| 11 | 14 | ||
| @@ -13,29 +16,56 @@ The system is made from couple of core components: | |||
| 13 | - Utils - cronjobs and queue management tools, | 16 | - Utils - cronjobs and queue management tools, |
| 14 | - Dashboard UI. | 17 | - Dashboard UI. |
| 15 | 18 | ||
| 16 | Initial release was using [MongoDB](https://www.mongodb.com/) for full-text search but was later replaced by [Elasticsearch](https://www.elastic.co/) for better CPU utilization and better search performance. This provided us with many amazing functionalities of [Elasticsearch](https://www.elastic.co/). You should check it out if you do any search related operations. | 19 | Initial release was using [MongoDB](https://www.mongodb.com/) for full-text |
| 20 | search but was later replaced by [Elasticsearch](https://www.elastic.co/) | ||
| 21 | for better CPU utilization and better search performance. This provided us | ||
| 22 | with many amazing functionalities of [Elasticsearch](https://www.elastic.co/). | ||
| 23 | You should check it out if you do any search related operations. | ||
| 17 | 24 | ||
| 18 | Because the premise of the server is to provide native ad experience, they are rendered on the client side via simple templating engine. This ensures that ads can be displayed number of different ways based on the visual style of the page. And this makes JavaScript client library quite complex. | 25 | Because the premise of the server is to provide native ad experience, they |
| 26 | are rendered on the client side via simple templating engine. This ensures | ||
| 27 | that ads can be displayed number of different ways based on the visual style | ||
| 28 | of the page. And this makes JavaScript client library quite complex. | ||
| 19 | 29 | ||
| 20 | So now that you know basic information about the product lets get into the lessons we learned. | 30 | So now that you know basic information about the product lets get into the |
| 31 | lessons we learned. | ||
| 21 | 32 | ||
| 22 | ## Aggregate everything | 33 | ## Aggregate everything |
| 23 | 34 | ||
| 24 | After beta version was released everything (impressions, clicks, etc) was written in nanosecond resolution in the database. At that time we were using [PostgreSQL](https://www.postgresql.org/) and database quickly grew way above 200GB in disk space. And that was problematic. Statistics took disturbingly long time to aggregate. Also using indexes on stats table in database was no help after we reached 500 million datapoints. | 35 | After beta version was released everything (impressions, clicks, etc) was |
| 36 | written in nanosecond resolution in the database. At that time we were using | ||
| 37 | [PostgreSQL](https://www.postgresql.org/) and database quickly grew way above | ||
| 38 | 200GB in disk space. And that was problematic. Statistics took disturbingly | ||
| 39 | long time to aggregate. Also using indexes on stats table in database was no | ||
| 40 | help after we reached 500 million datapoints. | ||
| 25 | 41 | ||
| 26 | > There is a marketing product information and there is real life experience. And the tend to be quite the opposite. | 42 | > There is a marketing product information and there is real life experience. |
| 43 | And the tend to be quite the opposite. | ||
| 27 | 44 | ||
| 28 | This was the reason that now everything is aggregated on daily basis and this data is then fed to Elastic in form of daily summary. With this we achieved we can now track many more dimensions such as zone, channel and platform information. And with this information we can now adapt occurrences of ads on specific places more precisely. | 45 | This was the reason that now everything is aggregated on daily basis and this |
| 46 | data is then fed to Elastic in form of daily summary. With this we achieved we | ||
| 47 | can now track many more dimensions such as zone, channel and platform information. | ||
| 48 | And with this information we can now adapt occurrences of ads on specific | ||
| 49 | places more precisely. | ||
| 29 | 50 | ||
| 30 | We have also adapted [Redis](https://redis.io/) as a full-time citizen in our stack. Because Redis also stores information on a local disk we have some sort of backup if server would accidentally suffer some failure. | 51 | We have also adapted [Redis](https://redis.io/) as a full-time citizen in our |
| 52 | stack. Because Redis also stores information on a local disk we have some sort | ||
| 53 | of backup if server would accidentally suffer some failure. | ||
| 31 | 54 | ||
| 32 | All the real-time statistics for ad serving and redirecting is presented as counters in Redis instance and daily extracted and pushed to Elastic. | 55 | All the real-time statistics for ad serving and redirecting is presented as |
| 56 | counters in Redis instance and daily extracted and pushed to Elastic. | ||
| 33 | 57 | ||
| 34 | ## Measure everything | 58 | ## Measure everything |
| 35 | 59 | ||
| 36 | The thing about software is that we really don't know how well it is performing under load until such load is presented. When testing locally everything is fine but when on production things tend to fall apart. | 60 | The thing about software is that we really don't know how well it is performing |
| 61 | under load until such load is presented. When testing locally everything is | ||
| 62 | fine but when on production things tend to fall apart. | ||
| 37 | 63 | ||
| 38 | As a solution for this we are measuring everything we can. Function execution time (by encapsulating functions with timers), server performance (cpu, memory, disk, etc), Nginx and [uWSGI](https://uwsgi-docs.readthedocs.io/) performance. We sacrifice a bit of performance for the sake of this information. And we store all this information for later analysis. | 64 | As a solution for this we are measuring everything we can. Function execution |
| 65 | time (by encapsulating functions with timers), server performance (cpu, memory, | ||
| 66 | disk, etc), Nginx and [uWSGI](https://uwsgi-docs.readthedocs.io/) performance. | ||
| 67 | We sacrifice a bit of performance for the sake of this information. And we | ||
| 68 | store all this information for later analysis. | ||
| 39 | 69 | ||
| 40 | **Example of function execution time** | 70 | **Example of function execution time** |
| 41 | 71 | ||
| @@ -69,17 +99,28 @@ As a solution for this we are measuring everything we can. Function execution ti | |||
| 69 | } | 99 | } |
| 70 | ``` | 100 | ``` |
| 71 | 101 | ||
| 72 | We have also started profiling with [cProfile](https://pymotw.com/2/profile/) and then visualizing with [KCachegrind](http://kcachegrind.sourceforge.net/). This provides much more detailed look into code execution. | 102 | We have also started profiling with [cProfile](https://pymotw.com/2/profile/) |
| 103 | and then visualizing with [KCachegrind](http://kcachegrind.sourceforge.net/). | ||
| 104 | This provides much more detailed look into code execution. | ||
| 73 | 105 | ||
| 74 | ## Cache control is your friend | 106 | ## Cache control is your friend |
| 75 | 107 | ||
| 76 | Because we use Javascript library for rendering ads we rely on this script extensively and when in need we need to be able to change behavior of the script quickly. | 108 | Because we use Javascript library for rendering ads we rely on this script |
| 109 | extensively and when in need we need to be able to change behavior of the | ||
| 110 | script quickly. | ||
| 77 | 111 | ||
| 78 | In our case we can not simply replace javascript url in html code. It usually takes a day or two for the guys who maintain sites to change code or add ?ver=xxx attribute. And this makes rapid deployment and testing very difficult and time consuming. There is a limitation of how much you can test locally. | 112 | In our case we can not simply replace javascript url in html code. It usually |
| 113 | takes a day or two for the guys who maintain sites to change code or add | ||
| 114 | ?ver=xxx attribute. And this makes rapid deployment and testing very difficult | ||
| 115 | and time consuming. There is a limitation of how much you can test locally. | ||
| 79 | 116 | ||
| 80 | We are now in the process of integrating [Google Tag Manager](https://www.google.com/analytics/tag-manager/) but couple of websites are developed on ASP.net platform that have some problems with tag manager. With a solution below we are certain that we are serving latest version of the script. | 117 | We are now in the process of integrating [Google Tag Manager](https://www.google.com/analytics/tag-manager/) |
| 118 | but couple of websites are developed on ASP.net platform that have some | ||
| 119 | problems with tag manager. With a solution below we are certain that we are | ||
| 120 | serving latest version of the script. | ||
| 81 | 121 | ||
| 82 | And it only takes one mistake and users have the script cached and in case of caching it for 1 year you probably know where the problem is. | 122 | And it only takes one mistake and users have the script cached and in case of |
| 123 | caching it for 1 year you probably know where the problem is. | ||
| 83 | 124 | ||
| 84 | ```nginx | 125 | ```nginx |
| 85 | # nginx ➜ /etc/nginx/sites-available/default | 126 | # nginx ➜ /etc/nginx/sites-available/default |
| @@ -102,7 +143,10 @@ location /static/ { | |||
| 102 | } | 143 | } |
| 103 | ``` | 144 | ``` |
| 104 | 145 | ||
| 105 | Also be careful when redirecting to url in your python code. We noticed that if we didn't precisely setup cache control and expire headers in response we didn't get the request on the server and therefore couldn't measure clicks. So when redirecting do as follows and there will be no problems. | 146 | Also be careful when redirecting to url in your python code. We noticed that |
| 147 | if we didn't precisely setup cache control and expire headers in response we | ||
| 148 | didn't get the request on the server and therefore couldn't measure clicks. | ||
| 149 | So when redirecting do as follows and there will be no problems. | ||
| 106 | 150 | ||
| 107 | ```python | 151 | ```python |
| 108 | # python ➜ bottlepy web micro-framework | 152 | # python ➜ bottlepy web micro-framework |
| @@ -113,22 +157,42 @@ response.set_header("Location", url) | |||
| 113 | return response | 157 | return response |
| 114 | ``` | 158 | ``` |
| 115 | 159 | ||
| 116 | > Cache control in browsers is quite aggressive and you need to be precise to avoid future problems. We learned that lesson the hard way. | 160 | > Cache control in browsers is quite aggressive and you need to be precise |
| 161 | to avoid future problems. We learned that lesson the hard way. | ||
| 117 | 162 | ||
| 118 | ## Learn NGINX | 163 | ## Learn NGINX |
| 119 | 164 | ||
| 120 | When deciding on a web server we went with Nginx as a reverse proxy for our applications. We adapted micro-service oriented architecture early in the project to ensure when we scale we can easily add additional servers to our cluster. And Nginx was crucial to perform load balancing and static content delivery. | 165 | When deciding on a web server we went with Nginx as a reverse proxy for our |
| 166 | applications. We adapted micro-service oriented architecture early in the | ||
| 167 | project to ensure when we scale we can easily add additional servers to our | ||
| 168 | cluster. And Nginx was crucial to perform load balancing and static content | ||
| 169 | delivery. | ||
| 121 | 170 | ||
| 122 | At first our config file was quite simple and later grew larger. After patching and adding new settings I sat down and learned more about the guts of Nginx. This proved to be very useful and we were able to squeeze much more out of our setup. So I advise you to take your time and read through the [documentation](https://nginx.org/en/docs/). This saved us a lot of headache. Googling for solutions only goes so far. | 171 | At first our config file was quite simple and later grew larger. After patching |
| 172 | and adding new settings I sat down and learned more about the guts of Nginx. | ||
| 173 | This proved to be very useful and we were able to squeeze much more out of our | ||
| 174 | setup. So I advise you to take your time and read through the | ||
| 175 | [documentation](https://nginx.org/en/docs/). This saved us a lot of headache. | ||
| 176 | Googling for solutions only goes so far. | ||
| 123 | 177 | ||
| 124 | ## Use Redis/Memcached | 178 | ## Use Redis/Memcached |
| 125 | 179 | ||
| 126 | As explained above we are using caching basically for everything. It is the corner stone of our services. At first we were very careful about the quantity of things we stored in [Redis](https://redis.io/). But we later found out that the memory footprint is very low even when storing large amount of data in it. | 180 | As explained above we are using caching basically for everything. It is the |
| 181 | corner stone of our services. At first we were very careful about the quantity | ||
| 182 | of things we stored in [Redis](https://redis.io/). But we later found out that | ||
| 183 | the memory footprint is very low even when storing large amount of data in it. | ||
| 127 | 184 | ||
| 128 | So we gradually increased our usage to caching whole HTML outputs of dashboard. This improved our performance in order of magnitude. And by using native TTL support this goes hand in hand with our needs. | 185 | So we gradually increased our usage to caching whole HTML outputs of dashboard. |
| 186 | This improved our performance in order of magnitude. And by using native TTL | ||
| 187 | support this goes hand in hand with our needs. | ||
| 129 | 188 | ||
| 130 | The reason why we choose [Redis](https://redis.io/) over [Memcached](https://memcached.org/) was the nature of scalability of Redis out of the box. But all this can be achieved with Memcached. | 189 | The reason why we choose [Redis](https://redis.io/) over [Memcached](https://memcached.org/) |
| 190 | was the nature of scalability of Redis out of the box. But all this can be | ||
| 191 | achieved with Memcached. | ||
| 131 | 192 | ||
| 132 | ## Conclusion | 193 | ## Conclusion |
| 133 | 194 | ||
| 134 | There are a lot more details that could have been written and every single topic in here deserves it's own post but you probably got the idea about the problems we faced. | 195 | There are a lot more details that could have been written and every single |
| 196 | topic in here deserves it's own post but you probably got the idea about | ||
| 197 | the problems we faced. | ||
| 198 | |||
diff --git a/content/posts/2017-04-21-profiling-python-web-applications-with-visual-tools.md b/content/posts/2017-04-21-profiling-python-web-applications-with-visual-tools.md index 466d838..911e6e0 100644 --- a/content/posts/2017-04-21-profiling-python-web-applications-with-visual-tools.md +++ b/content/posts/2017-04-21-profiling-python-web-applications-with-visual-tools.md | |||
| @@ -1,11 +1,14 @@ | |||
| 1 | --- | 1 | --- |
| 2 | title: Profiling Python web applications with visual tools | 2 | title: Profiling Python web applications with visual tools |
| 3 | url: profiling-python-web-applications-with-visual-tools.html | 3 | url: profiling-python-web-applications-with-visual-tools.html |
| 4 | date: 2017-04-21 | 4 | date: 2017-04-21T12:00:00+02:00 |
| 5 | draft: false | 5 | draft: false |
| 6 | --- | 6 | --- |
| 7 | 7 | ||
| 8 | I have been profiling my software with KCachegrind for a long time now and I was missing this option when I am developing API's or other web services. I always knew that this is possible but never really took the time and dive into it. | 8 | I have been profiling my software with KCachegrind for a long time now and I |
| 9 | was missing this option when I am developing API's or other web services. I | ||
| 10 | always knew that this is possible but never really took the time and dive | ||
| 11 | into it. | ||
| 9 | 12 | ||
| 10 | Before we begin there are some requirements. We will need to: | 13 | Before we begin there are some requirements. We will need to: |
| 11 | 14 | ||
| @@ -25,7 +28,8 @@ We will be dividing this post into two main categories: | |||
| 25 | 28 | ||
| 26 | ## Simple web-service | 29 | ## Simple web-service |
| 27 | 30 | ||
| 28 | Let's use virtualenv so we won't pollute our base system. If you don't have virtualenv installed on your system you can install it with pip command. | 31 | Let's use virtualenv so we won't pollute our base system. If you don't have |
| 32 | virtualenv installed on your system you can install it with pip command. | ||
| 29 | 33 | ||
| 30 | ```bash | 34 | ```bash |
| 31 | # let's install virtualenv globally | 35 | # let's install virtualenv globally |
| @@ -69,7 +73,8 @@ $ pip install bottle | |||
| 69 | $ deactivate | 73 | $ deactivate |
| 70 | ``` | 74 | ``` |
| 71 | 75 | ||
| 72 | We are now ready to write simple web service. Let's create file app.py and paste code bellow in this newly created file. | 76 | We are now ready to write simple web service. Let's create file app.py and |
| 77 | paste code bellow in this newly created file. | ||
| 73 | 78 | ||
| 74 | ```python | 79 | ```python |
| 75 | # -*- coding: utf-8 -*- | 80 | # -*- coding: utf-8 -*- |
| @@ -121,7 +126,8 @@ if __name__ == '__main__': | |||
| 121 | # open browser 'http://0.0.0.0:4000' | 126 | # open browser 'http://0.0.0.0:4000' |
| 122 | ``` | 127 | ``` |
| 123 | 128 | ||
| 124 | When browser hits awesome\_random\_number() function profile is created in prof/ subfolder. | 129 | When browser hits awesome\_random\_number() function profile is created in |
| 130 | prof/ subfolder. | ||
| 125 | 131 | ||
| 126 | ## Visualize profile | 132 | ## Visualize profile |
| 127 | 133 | ||
| @@ -133,17 +139,27 @@ $ pyprof2calltree -i awesome_random_number.prof | |||
| 133 | # this creates 'awesome_random_number.prof.log' file in the same folder | 139 | # this creates 'awesome_random_number.prof.log' file in the same folder |
| 134 | ``` | 140 | ``` |
| 135 | 141 | ||
| 136 | This file can be opened with visualizing tools listed above. In this case we will be using Profilling Viewer under MacOS. You can open image in new tab. As you can see from this example there is hierarchy of execution order of your code. | 142 | This file can be opened with visualizing tools listed above. In this case we |
| 143 | will be using Profilling Viewer under MacOS. You can open image in new tab. | ||
| 144 | As you can see from this example there is hierarchy of execution order of | ||
| 145 | your code. | ||
| 137 | 146 | ||
| 138 |  | 147 |  |
| 139 | 148 | ||
| 140 | > Make sure you convert output of the cProfile output every time you want to refresh and take a look at your possible optimizations because cProfile updates .prof file every time browser hits the function. | 149 | > Make sure you convert output of the cProfile output every time you want to |
| 150 | refresh and take a look at your possible optimizations because cProfile | ||
| 151 | updates .prof file every time browser hits the function. | ||
| 141 | 152 | ||
| 142 | This is just a simple example but when you are developing real-life applications this can be very illuminating, especially to see which parts of your code are bottlenecks and need to be optimized. | 153 | This is just a simple example but when you are developing real-life applications |
| 154 | this can be very illuminating, especially to see which parts of your code are | ||
| 155 | bottlenecks and need to be optimized. | ||
| 143 | 156 | ||
| 144 | ## Update 2017-04-22 | 157 | ## Update 2017-04-22 |
| 145 | 158 | ||
| 146 | Reddit user [mvt](https://www.reddit.com/user/mvt) also recommended this awesome web based profile visualizer [SnakeViz](https://jiffyclub.github.io/snakeviz/) that directly takes output from [cProfile](https://docs.python.org/2/library/profile.html#module-cProfile) module. | 159 | Reddit user [mvt](https://www.reddit.com/user/mvt) also recommended this |
| 160 | awesome web based profile visualizer [SnakeViz](https://jiffyclub.github.io/snakeviz/) | ||
| 161 | that directly takes output from [cProfile](https://docs.python.org/2/library/profile.html#module-cProfile) | ||
| 162 | module. | ||
| 147 | 163 | ||
| 148 | <div class="reddit-embed" data-embed-media="www.redditmedia.com" data-embed-parent="false" data-embed-live="false" data-embed-uuid="583880c1-002e-41ed-a373-020a0ef2cff9" data-embed-created="2017-04-22T19:46:54.810Z"><a href="https://www.reddit.com/r/Python/comments/66v373/profiling_python_web_applications_with_visual/dgljhsb/">Comment</a> from discussion <a href="https://www.reddit.com/r/Python/comments/66v373/profiling_python_web_applications_with_visual/">Profiling Python web applications with visual tools</a>.</div><script async src="https://www.redditstatic.com/comment-embed.js"></script> | 164 | <div class="reddit-embed" data-embed-media="www.redditmedia.com" data-embed-parent="false" data-embed-live="false" data-embed-uuid="583880c1-002e-41ed-a373-020a0ef2cff9" data-embed-created="2017-04-22T19:46:54.810Z"><a href="https://www.reddit.com/r/Python/comments/66v373/profiling_python_web_applications_with_visual/dgljhsb/">Comment</a> from discussion <a href="https://www.reddit.com/r/Python/comments/66v373/profiling_python_web_applications_with_visual/">Profiling Python web applications with visual tools</a>.</div><script async src="https://www.redditstatic.com/comment-embed.js"></script> |
| 149 | 165 | ||
| @@ -160,7 +176,8 @@ $ snakeviz awesome_random_number.prof | |||
| 160 | 176 | ||
| 161 |  | 177 |  |
| 162 | 178 | ||
| 163 | Reddit user [ccharles](https://www.reddit.com/user/ccharles) suggested a better way for installing pip software by targeting user level instead of using sudo. | 179 | Reddit user [ccharles](https://www.reddit.com/user/ccharles) suggested a better |
| 180 | way for installing pip software by targeting user level instead of using sudo. | ||
| 164 | 181 | ||
| 165 | <div class="reddit-embed" data-embed-media="www.redditmedia.com" data-embed-parent="false" data-embed-live="false" data-embed-uuid="f4f0459e-684d-441e-bebe-eb49b2f0a31d" data-embed-created="2017-04-22T19:46:10.874Z"><a href="https://www.reddit.com/r/Python/comments/66v373/profiling_python_web_applications_with_visual/dglpzkx/">Comment</a> from discussion <a href="https://www.reddit.com/r/Python/comments/66v373/profiling_python_web_applications_with_visual/">Profiling Python web applications with visual tools</a>.</div><script async src="https://www.redditstatic.com/comment-embed.js"></script> | 182 | <div class="reddit-embed" data-embed-media="www.redditmedia.com" data-embed-parent="false" data-embed-live="false" data-embed-uuid="f4f0459e-684d-441e-bebe-eb49b2f0a31d" data-embed-created="2017-04-22T19:46:10.874Z"><a href="https://www.reddit.com/r/Python/comments/66v373/profiling_python_web_applications_with_visual/dglpzkx/">Comment</a> from discussion <a href="https://www.reddit.com/r/Python/comments/66v373/profiling_python_web_applications_with_visual/">Profiling Python web applications with visual tools</a>.</div><script async src="https://www.redditstatic.com/comment-embed.js"></script> |
| 166 | 183 | ||
| @@ -182,4 +199,6 @@ $ echo $PATH | |||
| 182 | $ pip install snakeviz --user | 199 | $ pip install snakeviz --user |
| 183 | ``` | 200 | ``` |
| 184 | 201 | ||
| 185 | Or as suggested by [mvt](https://www.reddit.com/user/mvt) you can use [pipsi](https://github.com/mitsuhiko/pipsi). | 202 | Or as suggested by [mvt](https://www.reddit.com/user/mvt) you can |
| 203 | use [pipsi](https://github.com/mitsuhiko/pipsi). | ||
| 204 | |||
diff --git a/content/posts/2017-08-11-simple-iot-application.md b/content/posts/2017-08-11-simple-iot-application.md index b34fe6b..a0ac4be 100644 --- a/content/posts/2017-08-11-simple-iot-application.md +++ b/content/posts/2017-08-11-simple-iot-application.md | |||
| @@ -1,21 +1,40 @@ | |||
| 1 | --- | 1 | --- |
| 2 | title: Simple IOT application supported by real-time monitoring and data history | 2 | title: Simple IOT application supported by real-time monitoring and data history |
| 3 | url: simple-iot-application.html | 3 | url: simple-iot-application.html |
| 4 | date: 2017-08-11 | 4 | date: 2017-08-11T12:00:00+02:00 |
| 5 | draft: false | 5 | draft: false |
| 6 | --- | 6 | --- |
| 7 | 7 | ||
| 8 | ## Initial thoughts | 8 | ## Initial thoughts |
| 9 | 9 | ||
| 10 | I have been developing these kind of application for the better part of my last 5 years and people keep asking me how to approach developing such application and I will give a try explaining it here. | 10 | I have been developing these kind of application for the better part of my last |
| 11 | 11 | 5 years and people keep asking me how to approach developing such application | |
| 12 | IOT applications are really no different than any other kind of applications. We have data that needs to be collected and visualized in some form of tables or charts. The main difference here is that most of the times these data is collected by some kind of device foreign to developer that mainly operates in web domain. But fear not, it's not that different than writing some JavaScript. | 12 | and I will give a try explaining it here. |
| 13 | 13 | ||
| 14 | There are many devices able to transmit data via wireless or wired network by default but for the sake of example we will be using commonly known Arduino with wireless module already on the board → [Arduino MKR1000](https://store.arduino.cc/arduino-mkr1000). | 14 | IOT applications are really no different than any other kind of applications. |
| 15 | 15 | We have data that needs to be collected and visualized in some form of tables | |
| 16 | In order to make this little project as accessible to others as possible I will try to make it as inexpensive as possible. And by this I mean that I will avoid using hosted virtual servers and will be using my own laptop as a server. But you must buy Arduino MKR1000 to follow steps below. But if you would want to deploy this software I would suggest using [DigitalOcean](https://www.digitalocean.com) → smallest VPS is only per month making this one of the most affordable option out there. Please notice that this software will not run on stock web hosting that only supports LAMP (Linux, Apache, MySQL, and PHP). | 16 | or charts. The main difference here is that most of the times these data is |
| 17 | 17 | collected by some kind of device foreign to developer that mainly operates in | |
| 18 | _But before we begin please take notice that this is strictly experimental code and not well optimized and there are much better ways in handling some aspects of the application but that requires much deeper knowledge of technology that is not needed for an example like this._ | 18 | web domain. But fear not, it's not that different than writing some JavaScript. |
| 19 | |||
| 20 | There are many devices able to transmit data via wireless or wired network by | ||
| 21 | default but for the sake of example we will be using commonly known Arduino | ||
| 22 | with wireless module already on the board → [Arduino MKR1000](https://store.arduino.cc/arduino-mkr1000). | ||
| 23 | |||
| 24 | In order to make this little project as accessible to others as possible I will | ||
| 25 | try to make it as inexpensive as possible. And by this I mean that I will avoid | ||
| 26 | using hosted virtual servers and will be using my own laptop as a server. But | ||
| 27 | you must buy Arduino MKR1000 to follow steps below. But if you would want to | ||
| 28 | deploy this software I would suggest using | ||
| 29 | [DigitalOcean](https://www.digitalocean.com) → smallest VPS is only per month | ||
| 30 | making this one of the most affordable option out there. Please notice that | ||
| 31 | this software will not run on stock web hosting that only supports LAMP | ||
| 32 | (Linux, Apache, MySQL, and PHP). | ||
| 33 | |||
| 34 | But before we begin please take notice that this is strictly experimental code | ||
| 35 | and not well optimized and there are much better ways in handling some aspects | ||
| 36 | of the application but that requires much deeper knowledge of technology that | ||
| 37 | is not needed for an example like this. | ||
| 19 | 38 | ||
| 20 | **Development steps** | 39 | **Development steps** |
| 21 | 40 | ||
| @@ -23,23 +42,33 @@ _But before we begin please take notice that this is strictly experimental code | |||
| 23 | 2. Prototype C++ code that will read "sensor data" and transmit it to API. | 42 | 2. Prototype C++ code that will read "sensor data" and transmit it to API. |
| 24 | 3. Data visualization with charts → extends Python web application. | 43 | 3. Data visualization with charts → extends Python web application. |
| 25 | 44 | ||
| 26 | Step 1. and 3. will share the same web application. One route will be dedicated to API and another to serving HTML with chart. | 45 | Step 1. and 3. will share the same web application. One route will be dedicated |
| 46 | to API and another to serving HTML with chart. | ||
| 27 | 47 | ||
| 28 | Schema below represents what we will try to achieve and how different parts correlates to each other. | 48 | Schema below represents what we will try to achieve and how different parts |
| 49 | correlates to each other. | ||
| 29 | 50 | ||
| 30 |  | 51 |  |
| 31 | 52 | ||
| 32 | ## Simple Python API | 53 | ## Simple Python API |
| 33 | 54 | ||
| 34 | I have always been a fan of simplicity so we will be using [Bottle: Python Web Framework](https://bottlepy.org/docs/dev/). It is a single file web framework that seriously simplifies working with routes, templating and has built-in web server that satisfies our need in this case. | 55 | I have always been a fan of simplicity so we will be using [Bottle: Python Web Framework](https://bottlepy.org/docs/dev/). |
| 56 | It is a single file web framework that seriously simplifies working with routes, | ||
| 57 | templating and has built-in web server that satisfies our need in this case. | ||
| 35 | 58 | ||
| 36 | First we need to install bottle package. This can be done by downloading ```bottle.py``` and placing it in the root of your application or by using pip software ```pip install bottle --user```. | 59 | First we need to install bottle package. This can be done by downloading |
| 60 | ```bottle.py``` and placing it in the root of your application or by using | ||
| 61 | pip software ```pip install bottle --user```. | ||
| 37 | 62 | ||
| 38 | If you are using Linux or MacOS then Python is already installed. If you will try to test this on Windows please install [Python for Windows](https://www.python.org/downloads/windows/). There may be some problems with path when you will try to launch ```python webapp.py``` so please take care of this before you continue. | 63 | If you are using Linux or MacOS then Python is already installed. If you will |
| 64 | try to test this on Windows please install [Python for Windows](https://www.python.org/downloads/windows/). | ||
| 65 | There may be some problems with path when you will try to launch | ||
| 66 | ```python webapp.py``` so please take care of this before you continue. | ||
| 39 | 67 | ||
| 40 | ### Basic web application | 68 | ### Basic web application |
| 41 | 69 | ||
| 42 | Most basic bottle application is quite simple. Paste code below in ```webapp.py``` file and save. | 70 | Most basic bottle application is quite simple. Paste code below in |
| 71 | ```webapp.py``` file and save. | ||
| 43 | 72 | ||
| 44 | ```python | 73 | ```python |
| 45 | # -*- coding: utf-8 -*- | 74 | # -*- coding: utf-8 -*- |
| @@ -67,29 +96,60 @@ if __name__ == "__main__": | |||
| 67 | ) | 96 | ) |
| 68 | ``` | 97 | ``` |
| 69 | 98 | ||
| 70 | To run this simple application you should open command prompt or terminal on your machine and go to the folder containing your file and type ```python webapp.py```. If everything goes ok then open your web browser and point it to ```http://0.0.0.0:5000```. | 99 | To run this simple application you should open command prompt or terminal on |
| 100 | your machine and go to the folder containing your file and type | ||
| 101 | ```python webapp.py```. If everything goes ok then open your web browser and | ||
| 102 | point it to ```http://0.0.0.0:5000```. | ||
| 71 | 103 | ||
| 72 | If you would like change the port of your application (like port 80) and not use root to run your app this will present a problem. The TCP/IP port numbers below 1024 are privileged ports → this is a security feature. So in order of simplicity and security use a port number above 1024 like I have used port 5000. | 104 | If you would like change the port of your application (like port 80) and not |
| 105 | use root to run your app this will present a problem. The TCP/IP port numbers | ||
| 106 | below 1024 are privileged ports → this is a security feature. So in order of | ||
| 107 | simplicity and security use a port number above 1024 like I have used port | ||
| 108 | 5000. | ||
| 73 | 109 | ||
| 74 | If this fails at any time please fix it before you continue, because nothing below will work otherwise. | 110 | If this fails at any time please fix it before you continue, because nothing |
| 111 | below will work otherwise. | ||
| 75 | 112 | ||
| 76 | We use 0.0.0.0 as default host so that this app is available over your local network. If you find your local ip ```ifconfig``` and try accessing this site with your phone (if on same network/router as your machine) this should work as well (example of such ip ```http://192.168.1.15:5000```). This is a must have because Arduino will be accessing this application to send it's data. | 113 | We use 0.0.0.0 as default host so that this app is available over your local |
| 114 | network. If you find your local ip ```ifconfig``` and try accessing this site | ||
| 115 | with your phone (if on same network/router as your machine) this should work | ||
| 116 | as well (example of such ip ```http://192.168.1.15:5000```). This is a must | ||
| 117 | have because Arduino will be accessing this application to send it's data. | ||
| 77 | 118 | ||
| 78 | ### Web application security | 119 | ### Web application security |
| 79 | 120 | ||
| 80 | There is a lot to be said about security and is a topic of many books. Of course all this can not be written here but to just establish some basic security → you should always use SSL with your application. Some fantastic free certificates are available by [Let's Encrypt - Free SSL/TLS Certificates](https://letsencrypt.org). With SSL certificate installed you should then make use of HTTP headers and send your "API key" via a header. If your key is send via header then this key is encrypted by SSL and send encrypted over the network. Never send your api keys by GET parameter like ```http://example.com/?api_key=somekeyvalue```. The problem that this kind of sending presents is that this key is visible in logs and by network sniffers. | 121 | There is a lot to be said about security and is a topic of many books. Of course |
| 122 | all this can not be written here but to just establish some basic | ||
| 123 | security → you should always use SSL with your application. Some fantastic free | ||
| 124 | certificates are available by [Let's Encrypt - Free SSL/TLS Certificates](https://letsencrypt.org). | ||
| 125 | With SSL certificate installed you should then make use of HTTP headers and | ||
| 126 | send your "API key" via a header. If your key is send via header then this | ||
| 127 | key is encrypted by SSL and send encrypted over the network. Never send your | ||
| 128 | api keys by GET parameter like ```http://example.com/?api_key=somekeyvalue```. | ||
| 129 | The problem that this kind of sending presents is that this key is visible in | ||
| 130 | logs and by network sniffers. | ||
| 81 | 131 | ||
| 82 | There is a fantastic article describing some aspects about security: [11 Web Application Security Best Practices](https://www.keycdn.com/blog/web-application-security-best-practices/). Please check it out. | 132 | There is a fantastic article describing some aspects about security: [11 Web Application Security Best Practices](https://www.keycdn.com/blog/web-application-security-best-practices/). Please check it out. |
| 83 | 133 | ||
| 84 | ### Simple API for writing data-points | 134 | ### Simple API for writing data-points |
| 85 | 135 | ||
| 86 | We will now be using boilerplate code from example above and extend it to be able to write data received by API to local storage. For example use I will use SQLite3 because it plays well with Python and can store quite large amount of data. I have been using it to collect gigabytes of data in a single database without any corruption or problems → your experience may vary. | 136 | We will now be using boilerplate code from example above and extend it to be |
| 137 | able to write data received by API to local storage. For example use I will | ||
| 138 | use SQLite3 because it plays well with Python and can store quite large amount | ||
| 139 | of data. I have been using it to collect gigabytes of data in a single database | ||
| 140 | without any corruption or problems → your experience may vary. | ||
| 87 | 141 | ||
| 88 | To avoid learning SQLite I will be using [Dataset: databases for lazy people](https://dataset.readthedocs.io/en/latest/index.html). This package abstracts SQL and simplifies writing and reading data from database. You should install this package with pip software ```pip install dataset --user```. | 142 | To avoid learning SQLite I will be using [Dataset: databases for lazy people](https://dataset.readthedocs.io/en/latest/index.html). |
| 143 | This package abstracts SQL and simplifies writing and reading data from | ||
| 144 | database. You should install this package with pip software | ||
| 145 | ```pip install dataset --user```. | ||
| 89 | 146 | ||
| 90 | Because API will use POST method I will be testing if code works correctly by using [Restlet Client for Google Chrome](https://chrome.google.com/webstore/detail/restlet-client-rest-api-t/aejoelaoggembcahagimdiliamlcdmfm). This software also allows you to set headers → for basic security with API_KEY. | 147 | Because API will use POST method I will be testing if code works correctly by |
| 148 | using [Restlet Client for Google Chrome](https://chrome.google.com/webstore/detail/restlet-client-rest-api-t/aejoelaoggembcahagimdiliamlcdmfm). | ||
| 149 | This software also allows you to set headers → for basic security with API_KEY. | ||
| 91 | 150 | ||
| 92 | To quickly generate passwords or API keys I usually use this nifty website [RandomKeygen](https://randomkeygen.com/). | 151 | To quickly generate passwords or API keys I usually use this nifty website |
| 152 | [RandomKeygen](https://randomkeygen.com/). | ||
| 93 | 153 | ||
| 94 | Copy and paste code below over your previous code in file ```webapp.py```. | 154 | Copy and paste code below over your previous code in file ```webapp.py```. |
| 95 | 155 | ||
| @@ -144,31 +204,53 @@ if __name__ == "__main__": | |||
| 144 | ) | 204 | ) |
| 145 | ``` | 205 | ``` |
| 146 | 206 | ||
| 147 | To run this simply go to folder containing python file and run ```python webapp.py``` from terminal. If everything goes ok you should have simple API available via POST method on /api route. | 207 | To run this simply go to folder containing python file and run |
| 208 | ```python webapp.py``` from terminal. If everything goes ok you should have | ||
| 209 | simple API available via POST method on /api route. | ||
| 148 | 210 | ||
| 149 | After testing the service with Restlet Client you should be able to view your data in a database file ```data.db```. | 211 | After testing the service with Restlet Client you should be able to view |
| 212 | your data in a database file ```data.db```. | ||
| 150 | 213 | ||
| 151 |  | 214 |  |
| 152 | 215 | ||
| 153 | You can also check the contents of new database file by using desktop client for SQLite → [DB Browser for SQLite](http://sqlitebrowser.org/). | 216 | You can also check the contents of new database file by using desktop client |
| 217 | for SQLite → [DB Browser for SQLite](http://sqlitebrowser.org/). | ||
| 154 | 218 | ||
| 155 |  | 219 |  |
| 156 | 220 | ||
| 157 | Table structure is as simple as it can be. We have ts (timestamp) and value (value from Arduino). As you can see timestamp is generated on API side. If you would happen to have atomic clock on Arduino it would be then better to generate and send timestamp with the value. This would be particularity useful if we would be collecting sensor data at a higher frequency and then sending this data in bulk to API. | 221 | Table structure is as simple as it can be. We have ts (timestamp) and |
| 222 | value (value from Arduino). As you can see timestamp is generated on API | ||
| 223 | side. If you would happen to have atomic clock on Arduino it would be then | ||
| 224 | better to generate and send timestamp with the value. This would be | ||
| 225 | particularity useful if we would be collecting sensor data at a higher | ||
| 226 | frequency and then sending this data in bulk to API. | ||
| 158 | 227 | ||
| 159 | If you will deploy this app with uWSGI and multi-threaded, use DSN (Data Source Name) url with ```?check_same_thread=False```. | 228 | If you will deploy this app with uWSGI and multi-threaded, use |
| 229 | DSN (Data Source Name) url with ```?check_same_thread=False```. | ||
| 160 | 230 | ||
| 161 | Ok, now that we have some sort of a working API with some basic security so unwanted people can not post data to your database can we proceed further and try to program Arduino to send data to API. | 231 | Ok, now that we have some sort of a working API with some basic security |
| 232 | so unwanted people can not post data to your database can we proceed further | ||
| 233 | and try to program Arduino to send data to API. | ||
| 162 | 234 | ||
| 163 | ## Sending data to API with Arduino MKR1000 | 235 | ## Sending data to API with Arduino MKR1000 |
| 164 | 236 | ||
| 165 | First of all you should have MKR1000 module and microUSB cable to proceed. If you have ever done any work with Arduino you should know that you also need [Arduino IDE](https://www.arduino.cc/en/Main/Software). On provided link you should be able to download and install IDE. Once that task is completed and you have successfully run blink example you should proceed to the next step. | 237 | First of all you should have MKR1000 module and microUSB cable to proceed. |
| 238 | If you have ever done any work with Arduino you should know that you also | ||
| 239 | need [Arduino IDE](https://www.arduino.cc/en/Main/Software). On provided link | ||
| 240 | you should be able to download and install IDE. Once that task is completed | ||
| 241 | and you have successfully run blink example you should proceed to the next step. | ||
| 166 | 242 | ||
| 167 | In order to use wireless capabilities of MKR1000 you need to first install [WiFi101 library](https://www.arduino.cc/en/Reference/WiFi101) in Arduino IDE. Please check before you install, you may already have it installed. | 243 | In order to use wireless capabilities of MKR1000 you need to first install |
| 244 | [WiFi101 library](https://www.arduino.cc/en/Reference/WiFi101) in Arduino IDE. | ||
| 245 | Please check before you install, you may already have it installed. | ||
| 168 | 246 | ||
| 169 | Code below is a working example that sends data to API. Before you try to test your code make sure you have run Python web application. Then change settings for wifi, api endpoint and api_key. If by some reason code bellow doesn't work for you please leave a comment and I'll try to help. | 247 | Code below is a working example that sends data to API. Before you try to test |
| 248 | your code make sure you have run Python web application. Then change settings | ||
| 249 | for wifi, api endpoint and api_key. If by some reason code bellow doesn't work | ||
| 250 | for you please leave a comment and I'll try to help. | ||
| 170 | 251 | ||
| 171 | Once you have opened IDE and copied this code try to compile and upload it. Then open "Serial monitor" to see if any output is presented by Arduino. | 252 | Once you have opened IDE and copied this code try to compile and upload it. |
| 253 | Then open "Serial monitor" to see if any output is presented by Arduino. | ||
| 172 | 254 | ||
| 173 | ```c | 255 | ```c |
| 174 | #include <WiFi101.h> | 256 | #include <WiFi101.h> |
| @@ -225,7 +307,6 @@ void setup() { | |||
| 225 | } | 307 | } |
| 226 | 308 | ||
| 227 | void loop() { | 309 | void loop() { |
| 228 | |||
| 229 | WiFiClient client; | 310 | WiFiClient client; |
| 230 | 311 | ||
| 231 | if (client.connect(server, port)) { | 312 | if (client.connect(server, port)) { |
| @@ -251,32 +332,54 @@ void loop() { | |||
| 251 | 332 | ||
| 252 | // waits for x seconds and continue looping | 333 | // waits for x seconds and continue looping |
| 253 | delay(timeout); | 334 | delay(timeout); |
| 254 | |||
| 255 | } | 335 | } |
| 256 | ``` | 336 | ``` |
| 257 | 337 | ||
| 258 | As seen from example you can notice that Arduino is generating random integer between [ 0 .. 1000 ]. You can easily replace this with a temperature sensor or any other kind of sensor. | 338 | As seen from example you can notice that Arduino is generating random integer |
| 339 | between [ 0 .. 1000 ]. You can easily replace this with a temperature sensor | ||
| 340 | or any other kind of sensor. | ||
| 259 | 341 | ||
| 260 | Now that we have API under the hood and Arduino is sending demo data we can now focus on data visualization. | 342 | Now that we have API under the hood and Arduino is sending demo data we can |
| 343 | now focus on data visualization. | ||
| 261 | 344 | ||
| 262 | ## Data visualization | 345 | ## Data visualization |
| 263 | 346 | ||
| 264 | Before we continue we should examine our project folder structure. Currently we only have two files in our project: | 347 | Before we continue we should examine our project folder structure. Currently |
| 348 | we only have two files in our project: | ||
| 265 | 349 | ||
| 266 | _simple-iot-app/_ | 350 | _simple-iot-app/_ |
| 267 | 351 | ||
| 268 | * _webapp.py_ | 352 | * _webapp.py_ |
| 269 | * _data.db_ | 353 | * _data.db_ |
| 270 | 354 | ||
| 271 | We will now add HTML template that will contain CSS and JavaScript code inline for the simplicity reason. And for the bottle framework to be able to scan root application folder for templates we will add ```bottle.TEMPLATE_PATH.insert(0, "./")``` in ```webapp.py```. By default bottle framework uses ```views/``` subfolder to store templates. This is not the ideal situation and if you will use bottle to develop web applications you should use native behavior and store templates in it's predefined folder. But for the sake of example we will over-ride this. Be careful to fully replace your code with new code that is provided below. Avoid partially replacing code in file :) Also new code for reading data-points is provided in Python example below. | 355 | We will now add HTML template that will contain CSS and JavaScript code inline |
| 272 | 356 | for the simplicity reason. And for the bottle framework to be able to scan root | |
| 273 | First we add new route to our web application. It should be trigger when browser hits root of application ```http://0.0.0.0:5000/```. This route will do nothing more than render ```frontend.html``` template. This is done by ```return bottle.template("frontend.html")```. Check code below to further examine how exactly this is done. | 357 | application folder for templates we will add |
| 274 | 358 | ```bottle.TEMPLATE_PATH.insert(0, "./")``` in ```webapp.py```. By default bottle | |
| 275 | Now we will expand ```/api``` route and use different methods to write or read data-points. For writing data-point we will use POST method and for reading points we will use GET method. GET method will return JSON object with latest readings and historical data. | 359 | framework uses ```views/``` subfolder to store templates. This is not the ideal |
| 276 | 360 | situation and if you will use bottle to develop web applications you should use | |
| 277 | There is a fantastic JavaScript library for plotting time-series charts called [MetricsGraphics.js](https://www.metricsgraphicsjs.org) that is based on [D3.js](https://d3js.org/) library for visualizing data. | 361 | native behavior and store templates in it's predefined folder. But for the sake |
| 278 | 362 | of example we will over-ride this. Be careful to fully replace your code with | |
| 279 | Data schema required by MetricsGraphics.js → to achieve this we need to transform data from database into this format: | 363 | new code that is provided below. Avoid partially replacing code in file :) Also |
| 364 | new code for reading data-points is provided in Python example below. | ||
| 365 | |||
| 366 | First we add new route to our web application. It should be trigger when browser | ||
| 367 | hits root of application ```http://0.0.0.0:5000/```. This route will do nothing | ||
| 368 | more than render ```frontend.html``` template. This is done by | ||
| 369 | ```return bottle.template("frontend.html")```. Check code below to further | ||
| 370 | examine how exactly this is done. | ||
| 371 | |||
| 372 | Now we will expand ```/api``` route and use different methods to write or | ||
| 373 | read data-points. For writing data-point we will use POST method and for | ||
| 374 | reading points we will use GET method. GET method will return JSON object | ||
| 375 | with latest readings and historical data. | ||
| 376 | |||
| 377 | There is a fantastic JavaScript library for plotting time-series charts | ||
| 378 | called [MetricsGraphics.js](https://www.metricsgraphicsjs.org) that is | ||
| 379 | based on [D3.js](https://d3js.org/) library for visualizing data. | ||
| 380 | |||
| 381 | Data schema required by MetricsGraphics.js → to achieve this we need to | ||
| 382 | transform data from database into this format: | ||
| 280 | 383 | ||
| 281 | ```json | 384 | ```json |
| 282 | [ | 385 | [ |
| @@ -291,7 +394,9 @@ Data schema required by MetricsGraphics.js → to achieve this we need to transf | |||
| 291 | ] | 394 | ] |
| 292 | ``` | 395 | ``` |
| 293 | 396 | ||
| 294 | Web application is now complete and we only need ```frontend.html``` that we will develop now. If you would try to start web app now and go to root app this will return error because we don't have frontend.html yet. | 397 | Web application is now complete and we only need ```frontend.html``` that we |
| 398 | will develop now. If you would try to start web app now and go to root app | ||
| 399 | this will return error because we don't have frontend.html yet. | ||
| 295 | 400 | ||
| 296 | ```python | 401 | ```python |
| 297 | # -*- coding: utf-8 -*- | 402 | # -*- coding: utf-8 -*- |
| @@ -372,7 +477,9 @@ if __name__ == "__main__": | |||
| 372 | ) | 477 | ) |
| 373 | ``` | 478 | ``` |
| 374 | 479 | ||
| 375 | And now finally we can implement ```frontend.html```. Create file with this name and copy code below. When you are done you can start web application. Steps for this part are listed below the code. | 480 | And now finally we can implement ```frontend.html```. Create file with this |
| 481 | name and copy code below. When you are done you can start web application. | ||
| 482 | Steps for this part are listed below the code. | ||
| 376 | 483 | ||
| 377 | ```html | 484 | ```html |
| 378 | <!DOCTYPE html> | 485 | <!DOCTYPE html> |
| @@ -465,9 +572,11 @@ Ok, lets now start application and start feeding it data. | |||
| 465 | 2. connect Arduino MKR1000 to power source | 572 | 2. connect Arduino MKR1000 to power source |
| 466 | 3. open browser and go to ```http://0.0.0.0:5000``` | 573 | 3. open browser and go to ```http://0.0.0.0:5000``` |
| 467 | 574 | ||
| 468 | If everything goes well you should be seeing new data-points rendered on chart every 5 seconds. | 575 | If everything goes well you should be seeing new data-points rendered on |
| 576 | chart every 5 seconds. | ||
| 469 | 577 | ||
| 470 | If you navigate to ```http://0.0.0.0:5000``` you should see rendered chart as shown on picture below. | 578 | If you navigate to ```http://0.0.0.0:5000``` you should see rendered chart |
| 579 | as shown on picture below. | ||
| 471 | 580 | ||
| 472 |  | 581 |  |
| 473 | 582 | ||
| @@ -475,9 +584,12 @@ Complete application with all the code is available for [download](/assets/iot-a | |||
| 475 | 584 | ||
| 476 | ## Conclusion | 585 | ## Conclusion |
| 477 | 586 | ||
| 478 | I hope this clarifies some aspects of IOT application development. Of course this is a minimal example and is far from what can be done in real life with some further dive into other technologies. | 587 | I hope this clarifies some aspects of IOT application development. Of course |
| 588 | this is a minimal example and is far from what can be done in real life with | ||
| 589 | some further dive into other technologies. | ||
| 479 | 590 | ||
| 480 | If you would like to continue exploring IOT world here are some interesting resources for you to examine: | 591 | If you would like to continue exploring IOT world here are some interesting |
| 592 | resources for you to examine: | ||
| 481 | 593 | ||
| 482 | * [Reading Sensors with an Arduino](https://www.allaboutcircuits.com/projects/reading-sensors-with-an-arduino/) | 594 | * [Reading Sensors with an Arduino](https://www.allaboutcircuits.com/projects/reading-sensors-with-an-arduino/) |
| 483 | * [MQTT 101 – How to Get Started with the lightweight IoT Protocol](http://www.hivemq.com/blog/how-to-get-started-with-mqtt) | 595 | * [MQTT 101 – How to Get Started with the lightweight IoT Protocol](http://www.hivemq.com/blog/how-to-get-started-with-mqtt) |
| @@ -485,3 +597,4 @@ If you would like to continue exploring IOT world here are some interesting reso | |||
| 485 | * [Internet of Things (IoT) Tutorials](http://www.tutorialspoint.com/internet_of_things/) | 597 | * [Internet of Things (IoT) Tutorials](http://www.tutorialspoint.com/internet_of_things/) |
| 486 | 598 | ||
| 487 | Any comment or additional ideas are welcomed in comments below. | 599 | Any comment or additional ideas are welcomed in comments below. |
| 600 | |||
diff --git a/content/posts/2018-01-16-using-digitalocean-spaces-object-storage-with-fuse.md b/content/posts/2018-01-16-using-digitalocean-spaces-object-storage-with-fuse.md index 75f7799..bfc77ee 100644 --- a/content/posts/2018-01-16-using-digitalocean-spaces-object-storage-with-fuse.md +++ b/content/posts/2018-01-16-using-digitalocean-spaces-object-storage-with-fuse.md | |||
| @@ -1,36 +1,67 @@ | |||
| 1 | --- | 1 | --- |
| 2 | title: Using DigitalOcean Spaces Object Storage with FUSE | 2 | title: Using DigitalOcean Spaces Object Storage with FUSE |
| 3 | url: using-digitalocean-spaces-object-storage-with-fuse.html | 3 | url: using-digitalocean-spaces-object-storage-with-fuse.html |
| 4 | date: 2018-01-16 | 4 | date: 2018-01-16T12:00:00+02:00 |
| 5 | draft: false | 5 | draft: false |
| 6 | --- | 6 | --- |
| 7 | 7 | ||
| 8 | Couple of months ago [DigitalOcean](https://www.digitalocean.com) introduced new product called [Spaces](https://blog.digitalocean.com/introducing-spaces-object-storage/) which is Object Storage very similar to Amazon's S3. This really peaked my interest, because this was something I was missing and even the thought of going over the internet for such functionality was in no interest to me. Also in fashion with their previous pricing this also is very cheap and pricing page is a no-brainer compared to AWS or GCE. [Prices are clearly and precisely defined and outlined](https://www.digitalocean.com/pricing/). You must love them for that :) | 8 | Couple of months ago [DigitalOcean](https://www.digitalocean.com) introduced |
| 9 | new product called [Spaces](https://blog.digitalocean.com/introducing-spaces-object-storage/) | ||
| 10 | which is Object Storage very similar to Amazon's S3. This really peaked my | ||
| 11 | interest, because this was something I was missing and even the thought of | ||
| 12 | going over the internet for such functionality was in no interest to me. Also | ||
| 13 | in fashion with their previous pricing this also is very cheap and pricing | ||
| 14 | page is a no-brainer compared to AWS or GCE. [Prices are clearly and precisely defined and outlined](https://www.digitalocean.com/pricing/). | ||
| 15 | You must love them for that :) | ||
| 9 | 16 | ||
| 10 | ## Initial requirements | 17 | ## Initial requirements |
| 11 | 18 | ||
| 12 | * Is it possible to use them as a mounted drive with FUSE? (tl;dr YES) | 19 | * Is it possible to use them as a mounted drive with FUSE? (tl;dr YES) |
| 13 | * Will the performance degrade over time and over different sizes of objects? (tl;dr NO&YES) | 20 | * Will the performance degrade over time and over different sizes of objects? |
| 14 | * Can storage be mounted on multiple machines at the same time and be writable? (tl;dr YES) | 21 | (tl;dr NO&YES) |
| 15 | 22 | * Can storage be mounted on multiple machines at the same time and be writable? | |
| 16 | > Let me be clear. This scripts I use are made just for benchmarking and are not intended to be used in real-life situations. Besides that, I am looking into using this approaches but adding caching service in front of it and then dumping everything as an object to storage. This could potentially be some interesting post of itself. But in case you would need real-time data without eventual consistency please take this scripts as they are: not usable in such situations. | 23 | (tl;dr YES) |
| 24 | |||
| 25 | > Let me be clear. This scripts I use are made just for benchmarking and are | ||
| 26 | > not intended to be used in real-life situations. Besides that, I am looking | ||
| 27 | > into using this approaches but adding caching service in front of it and then | ||
| 28 | > dumping everything as an object to storage. This could potentially be some | ||
| 29 | > interesting post of itself. But in case you would need real-time data without | ||
| 30 | > eventual consistency please take this scripts as they are: not usable in such | ||
| 31 | > situations. | ||
| 17 | 32 | ||
| 18 | ## Is it possible to use them as a mounted drive with FUSE? | 33 | ## Is it possible to use them as a mounted drive with FUSE? |
| 19 | 34 | ||
| 20 | Well, actually they can be used in such manor. Because they are similar to [AWS S3](https://aws.amazon.com/s3/) many tools are available and you can find many articles and [Stackoverflow items](https://stackoverflow.com/search?q=s3+fuse). | 35 | Well, actually they can be used in such manor. Because they are similar to |
| 36 | [AWS S3](https://aws.amazon.com/s3/) many tools are available and you can find | ||
| 37 | many articles and [Stackoverflow items](https://stackoverflow.com/search?q=s3+fuse). | ||
| 21 | 38 | ||
| 22 | To make this work you will need DigitalOcean account. If you don't have one you will not be able to test this code. But if you have an account then you go and [create new Droplet](https://cloud.digitalocean.com/droplets/new?size=s-1vcpu-1gb®ion=ams3&distro=debian&distroImage=debian-9-x64&options=private_networking,install_agent). If you click on this link you will already have preselected Debian 9 with smallest VM option. | 39 | To make this work you will need DigitalOcean account. If you don't have one you |
| 40 | will not be able to test this code. But if you have an account then you go and | ||
| 41 | [create new Droplet](https://cloud.digitalocean.com/droplets/new?size=s-1vcpu-1gb®ion=ams3&distro=debian&distroImage=debian-9-x64&options=private_networking,install_agent). | ||
| 42 | If you click on this link you will already have preselected Debian 9 with | ||
| 43 | smallest VM option. | ||
| 23 | 44 | ||
| 24 | * Please be sure to add you SSH key, because we will login to this machine remotely. | 45 | * Please be sure to add you SSH key, because we will login to this machine |
| 25 | * If you change your region please remember which one you choose because we will need this information when we try to mount space to our machine. | 46 | remotely. |
| 47 | * If you change your region please remember which one you choose because we | ||
| 48 | will need this information when we try to mount space to our machine. | ||
| 26 | 49 | ||
| 27 | Instuctions on how to use SSH keys and how to setup them are available in article [How To Use SSH Keys with DigitalOcean Droplets](https://www.digitalocean.com/community/tutorials/how-to-use-ssh-keys-with-digitalocean-droplets). | 50 | Instuctions on how to use SSH keys and how to setup them are available in article |
| 51 | [How To Use SSH Keys with DigitalOcean Droplets](https://www.digitalocean.com/community/tutorials/how-to-use-ssh-keys-with-digitalocean-droplets). | ||
| 28 | 52 | ||
| 29 |  | 53 |  |
| 30 | 54 | ||
| 31 | After we created Droplet it's time to create new Space. This is done by clicking on a button [Create](https://cloud.digitalocean.com/spaces/new) (right top corner) and selecting Spaces. Choose pronounceable ```Unique name``` because we will use it in examples below. You can either choose Private or Public, it doesn't matter in our case. And you can always change that in the future. | 55 | After we created Droplet it's time to create new Space. This is done by clicking |
| 56 | on a button [Create](https://cloud.digitalocean.com/spaces/new) (right top | ||
| 57 | corner) and selecting Spaces. Choose pronounceable ```Unique name``` because we | ||
| 58 | will use it in examples below. You can either choose Private or Public, it | ||
| 59 | doesn't matter in our case. And you can always change that in the future. | ||
| 32 | 60 | ||
| 33 | When you have created new Space we should [generate Access key](https://cloud.digitalocean.com/settings/api/tokens). This link will guide to the page when you can generate this key. After you create new one, please save provided Key and Secret because Secret will not be shown again. | 61 | When you have created new Space we should [generate Access key](https://cloud.digitalocean.com/settings/api/tokens). |
| 62 | This link will guide to the page when you can generate this key. After you | ||
| 63 | create new one, please save provided Key and Secret because Secret will not | ||
| 64 | be shown again. | ||
| 34 | 65 | ||
| 35 |  | 66 |  |
| 36 | 67 | ||
| @@ -59,9 +90,14 @@ s3fs UNIQUE-NAME /mnt/ -ourl=https://ams3.digitaloceanspaces.com -ouse_cache=/tm | |||
| 59 | echo "Hello cruel world" > /mnt/hello.txt | 90 | echo "Hello cruel world" > /mnt/hello.txt |
| 60 | ``` | 91 | ``` |
| 61 | 92 | ||
| 62 | After all this you can return to your browser and go to [DigitalOcean Spaces](https://cloud.digitalocean.com/spaces) and click on your created space. If file hello.txt is present you have successfully mounted space to your machine and wrote data to it. | 93 | After all this you can return to your browser and go to |
| 94 | [DigitalOcean Spaces](https://cloud.digitalocean.com/spaces) and click on your | ||
| 95 | created space. If file hello.txt is present you have successfully mounted | ||
| 96 | space to your machine and wrote data to it. | ||
| 63 | 97 | ||
| 64 | I choose the same region for my Droplet and my Space but you don't have to. You can have different regions. What this actually does to performance I don't know. | 98 | I choose the same region for my Droplet and my Space but you don't have to. |
| 99 | You can have different regions. What this actually does to performance I | ||
| 100 | don't know. | ||
| 65 | 101 | ||
| 66 | Additional information on FUSE: | 102 | Additional information on FUSE: |
| 67 | 103 | ||
| @@ -70,7 +106,9 @@ Additional information on FUSE: | |||
| 70 | 106 | ||
| 71 | ## Will the performance degrade over time and over different sizes of objects? | 107 | ## Will the performance degrade over time and over different sizes of objects? |
| 72 | 108 | ||
| 73 | For this task I didn't want to just read and write text files or uploading images. I actually wanted to figure out if using something like SQlite is viable in this case. | 109 | For this task I didn't want to just read and write text files or uploading |
| 110 | images. I actually wanted to figure out if using something like SQlite is | ||
| 111 | viable in this case. | ||
| 74 | 112 | ||
| 75 | ### Measurement experiment 1: File copy | 113 | ### Measurement experiment 1: File copy |
| 76 | 114 | ||
| @@ -96,13 +134,17 @@ n=0; while (( n++ < 100 )); do (time cp 1MB.dat /mnt/1MB.$n.dat) |& tee -a 1MB.r | |||
| 96 | n=0; while (( n++ < 100 )); do (time cp 10MB.dat /mnt/10MB.$n.dat) |& tee -a 10MB.results.txt; done | 134 | n=0; while (( n++ < 100 )); do (time cp 10MB.dat /mnt/10MB.$n.dat) |& tee -a 10MB.results.txt; done |
| 97 | ``` | 135 | ``` |
| 98 | 136 | ||
| 99 | Files of size 100MB were not successfully transferred and ended up displaying error (cp: failed to close '/mnt/100MB.1.dat': Operation not permitted). | 137 | Files of size 100MB were not successfully transferred and ended up displaying |
| 138 | error (cp: failed to close '/mnt/100MB.1.dat': Operation not permitted). | ||
| 100 | 139 | ||
| 101 | As I suspected, object size is not really that important. Sadly I don't have the time to test performance over periods of time. But if some of you would do it please send me your data. I would be interested in seeing results. | 140 | As I suspected, object size is not really that important. Sadly I don't have |
| 141 | the time to test performance over periods of time. But if some of you would do | ||
| 142 | it please send me your data. I would be interested in seeing results. | ||
| 102 | 143 | ||
| 103 | **Here are plotted results** | 144 | **Here are plotted results** |
| 104 | 145 | ||
| 105 | You can download [raw result here](/assets/do-fuse/copy-benchmarks.tsv). Measurements are in seconds. | 146 | You can download [raw result here](/assets/do-fuse/copy-benchmarks.tsv). |
| 147 | Measurements are in seconds. | ||
| 106 | 148 | ||
| 107 | <script src="//cdn.plot.ly/plotly-latest.min.js"></script> | 149 | <script src="//cdn.plot.ly/plotly-latest.min.js"></script> |
| 108 | <div id="copy-benchmarks"></div> | 150 | <div id="copy-benchmarks"></div> |
| @@ -135,11 +177,18 @@ You can download [raw result here](/assets/do-fuse/copy-benchmarks.tsv). Measure | |||
| 135 | })(); | 177 | })(); |
| 136 | </script> | 178 | </script> |
| 137 | 179 | ||
| 138 | As far as these tests show, performance is quite stable and can be predicted which is fantastic. But this is a small test and spans only over couple of hours. So you should not completely trust them. | 180 | As far as these tests show, performance is quite stable and can be predicted |
| 181 | which is fantastic. But this is a small test and spans only over couple of | ||
| 182 | hours. So you should not completely trust them. | ||
| 139 | 183 | ||
| 140 | ### Measurement experiment 2: SQLite performanse | 184 | ### Measurement experiment 2: SQLite performanse |
| 141 | 185 | ||
| 142 | I was unable to use database file directly from mounted drive so this is a no-go as I suspected. So I executed code below on a local disk just to get some benchmarks. I inserted 1000 records with DROPTABLE, CREATETABLE, INSERTMANY, FETCHALL, COMMIT for 1000 times to generate statistics. As you can see performance of SQLite is quite amazing. You could then potentially just copy file to mounted drive and be done with it. | 186 | I was unable to use database file directly from mounted drive so this is a |
| 187 | no-go as I suspected. So I executed code below on a local disk just to get | ||
| 188 | some benchmarks. I inserted 1000 records with DROPTABLE, CREATETABLE, | ||
| 189 | INSERTMANY, FETCHALL, COMMIT for 1000 times to generate statistics. As you can | ||
| 190 | see performance of SQLite is quite amazing. You could then potentially just | ||
| 191 | copy file to mounted drive and be done with it. | ||
| 143 | 192 | ||
| 144 | ```python | 193 | ```python |
| 145 | import time | 194 | import time |
| @@ -218,7 +267,11 @@ result_time = CLOSE = end_time - start_time | |||
| 218 | print("CLOSE: %g seconds" % (result_time)) | 267 | print("CLOSE: %g seconds" % (result_time)) |
| 219 | ``` | 268 | ``` |
| 220 | 269 | ||
| 221 | You can download [raw result here](/assets/do-fuse/sqlite-benchmarks.tsv). And again, these results are done on a local block storage and do not represent capabilities of object storage. With my current approach and state of the test code these can not be done. I would need to make Python code much more robust and check locking etc. | 270 | You can download [raw result here](/assets/do-fuse/sqlite-benchmarks.tsv). And |
| 271 | again, these results are done on a local block storage and do not represent | ||
| 272 | capabilities of object storage. With my current approach and state of the test | ||
| 273 | code these can not be done. I would need to make Python code much more robust | ||
| 274 | and check locking etc. | ||
| 222 | 275 | ||
| 223 | <div id="sqlite-benchmarks"></div> | 276 | <div id="sqlite-benchmarks"></div> |
| 224 | <script> | 277 | <script> |
| @@ -252,10 +305,24 @@ You can download [raw result here](/assets/do-fuse/sqlite-benchmarks.tsv). And a | |||
| 252 | 305 | ||
| 253 | ## Can storage be mounted on multiple machines at the same time and be writable? | 306 | ## Can storage be mounted on multiple machines at the same time and be writable? |
| 254 | 307 | ||
| 255 | Well, this one didn't take long to test. And the answer is **YES**. I mounted space on both machines and measured same performance on both machines. But because file is downloaded before write and then uploaded on complete there could potentially be problems is another process is trying to access the same file. | 308 | Well, this one didn't take long to test. And the answer is **YES**. I mounted |
| 309 | space on both machines and measured same performance on both machines. But | ||
| 310 | because file is downloaded before write and then uploaded on complete there | ||
| 311 | could potentially be problems is another process is trying to access the same | ||
| 312 | file. | ||
| 256 | 313 | ||
| 257 | ## Observations and conslusion | 314 | ## Observations and conslusion |
| 258 | 315 | ||
| 259 | Using Spaces in this way makes it easier to access and manage files. But besides that you would need to write additional code to make this one play nice with you applications. | 316 | Using Spaces in this way makes it easier to access and manage files. But |
| 317 | besides that you would need to write additional code to make this one play | ||
| 318 | nice with you applications. | ||
| 319 | |||
| 320 | Nevertheless, this was extremely simple to setup and use and this is just | ||
| 321 | another excellent product in DigitalOcean product line. I found this exercise | ||
| 322 | very valuable and am thinking about implementing some sort of mechanism for | ||
| 323 | SQLite, so data can be stored on Spaces and accessed by many VM's. For a | ||
| 324 | project where data doesn't need to be accessible in real-time and can have | ||
| 325 | couple of minutes old data this would be very interesting. If any of you find | ||
| 326 | this proposal interesting please write in a comment box below or shoot me an | ||
| 327 | email and I will keep you posted. | ||
| 260 | 328 | ||
| 261 | Nevertheless, this was extremely simple to setup and use and this is just another excellent product in DigitalOcean product line. I found this exercise very valuable and am thinking about implementing some sort of mechanism for SQLite, so data can be stored on Spaces and accessed by many VM's. For a project where data doesn't need to be accessible in real-time and can have couple of minutes old data this would be very interesting. If any of you find this proposal interesting please write in a comment box below or shoot me an email and I will keep you posted. | ||
diff --git a/content/posts/2019-01-03-encoding-binary-data-into-dna-sequence.md b/content/posts/2019-01-03-encoding-binary-data-into-dna-sequence.md index 577e241..a57201f 100644 --- a/content/posts/2019-01-03-encoding-binary-data-into-dna-sequence.md +++ b/content/posts/2019-01-03-encoding-binary-data-into-dna-sequence.md | |||
| @@ -1,47 +1,71 @@ | |||
| 1 | --- | 1 | --- |
| 2 | title: Encoding binary data into DNA sequence | 2 | title: Encoding binary data into DNA sequence |
| 3 | url: encoding-binary-data-into-dna-sequence.html | 3 | url: encoding-binary-data-into-dna-sequence.html |
| 4 | date: 2019-01-03 | 4 | date: 2019-01-03T12:00:00+02:00 |
| 5 | draft: false | 5 | draft: false |
| 6 | --- | 6 | --- |
| 7 | 7 | ||
| 8 | ## Initial thoughts | 8 | ## Initial thoughts |
| 9 | 9 | ||
| 10 | Imagine a world where you could go outside and take a leaf from a tree and put it through your personal DNA sequencer and get data like music, videos or computer programs from it. Well, this is all possible now. It was not done on a large scale because it is quite expensive to create DNA strands but it's possible. | 10 | Imagine a world where you could go outside and take a leaf from a tree and put |
| 11 | it through your personal DNA sequencer and get data like music, videos or | ||
| 12 | computer programs from it. Well, this is all possible now. It was not done | ||
| 13 | on a large scale because it is quite expensive to create DNA strands but it's | ||
| 14 | possible. | ||
| 11 | 15 | ||
| 12 | Encoding data into DNA sequence is relatively simple process once you understand the relationship between binary data and nucleotides and scientists have been making large leaps in this field in order to provide viable long-term storage solution for our data that would potentially survive our specie if case of global disaster. We could imprint all the world's knowledge into plants and ensure the survival of our knowledge. | 16 | Encoding data into DNA sequence is relatively simple process once you understand |
| 17 | the relationship between binary data and nucleotides and scientists have been | ||
| 18 | making large leaps in this field in order to provide viable long-term storage | ||
| 19 | solution for our data that would potentially survive our specie if case of | ||
| 20 | global disaster. We could imprint all the world's knowledge into plants and | ||
| 21 | ensure the survival of our knowledge. | ||
| 13 | 22 | ||
| 14 | More optimistic usage for this technology would be easier storage of ever growing data we produce every day. Once machines for sequencing DNA become fast enough and cheaper this could mean the next evolution of storing data and abandoning classical hard and solid state drives in data warehouses. | 23 | More optimistic usage for this technology would be easier storage of ever |
| 24 | growing data we produce every day. Once machines for sequencing DNA become fast | ||
| 25 | enough and cheaper this could mean the next evolution of storing data and | ||
| 26 | abandoning classical hard and solid state drives in data warehouses. | ||
| 15 | 27 | ||
| 16 | As we currently stand this is still not viable but it is quite an amazing and cool technology. | 28 | As we currently stand this is still not viable but it is quite an amazing and |
| 29 | cool technology. | ||
| 17 | 30 | ||
| 18 | My interests in this field are purely in encoding processes and experimental testing mainly because I don't have the access to this expensive machines. My initial goal was to create a toolkit that can be used by everybody to encode their data into a proper DNA sequence. | 31 | My interests in this field are purely in encoding processes and experimental |
| 32 | testing mainly because I don't have the access to this expensive machines. My | ||
| 33 | initial goal was to create a toolkit that can be used by everybody to encode | ||
| 34 | their data into a proper DNA sequence. | ||
| 19 | 35 | ||
| 20 | ## Glossary | 36 | ## Glossary |
| 21 | 37 | ||
| 22 | **deoxyribose** | 38 | **deoxyribose** |
| 23 | A five-carbon sugar molecule with a hydrogen atom rather than a hydroxyl group in the 2′ position; the sugar component of DNA nucleotides. | 39 | A five-carbon sugar molecule with a hydrogen atom rather than a hydroxyl group |
| 40 | in the 2′ position; the sugar component of DNA nucleotides. | ||
| 24 | 41 | ||
| 25 | **double helix** | 42 | **double helix** |
| 26 | The molecular shape of DNA in which two strands of nucleotides wind around each other in a spiral shape. | 43 | The molecular shape of DNA in which two strands of nucleotides wind around |
| 44 | each other in a spiral shape. | ||
| 27 | 45 | ||
| 28 | **nitrogenous base** | 46 | **nitrogenous base** |
| 29 | A nitrogen-containing molecule that acts as a base; often referring to one of the purine or pyrimidine components of nucleic acids. | 47 | A nitrogen-containing molecule that acts as a base; often referring to one of |
| 48 | the purine or pyrimidine components of nucleic acids. | ||
| 30 | 49 | ||
| 31 | **phosphate group** | 50 | **phosphate group** |
| 32 | A molecular group consisting of a central phosphorus atom bound to four oxygen atoms. | 51 | A molecular group consisting of a central phosphorus atom bound to four oxygen |
| 52 | atoms. | ||
| 33 | 53 | ||
| 34 | **RGB** | 54 | **RGB** |
| 35 | The RGB color model is an additive color model in which red, green and blue light are added together in various ways to reproduce a broad array of colors. | 55 | The RGB color model is an additive color model in which red, green and blue |
| 56 | light are added together in various ways to reproduce a broad array of colors. | ||
| 36 | 57 | ||
| 37 | **GCC** | 58 | **GCC** |
| 38 | The GNU Compiler Collection is a compiler system produced by the GNU Project supporting various programming languages. | 59 | The GNU Compiler Collection is a compiler system produced by the GNU Project |
| 60 | supporting various programming languages. | ||
| 39 | 61 | ||
| 40 | ## Data encoding | 62 | ## Data encoding |
| 41 | 63 | ||
| 42 | **TL;DR:** Encoding involves the use of a code to change original data into a form that can be used by an external process. | 64 | **TL;DR:** Encoding involves the use of a code to change original data into a |
| 65 | form that can be used by an external process. | ||
| 43 | 66 | ||
| 44 | Encoding is the process of converting data into a format required for a number of information processing needs, including: | 67 | Encoding is the process of converting data into a format required for a number |
| 68 | of information processing needs, including: | ||
| 45 | 69 | ||
| 46 | - Program compiling and execution | 70 | - Program compiling and execution |
| 47 | - Data transmission, storage and compression/decompression | 71 | - Data transmission, storage and compression/decompression |
| @@ -49,7 +73,9 @@ Encoding is the process of converting data into a format required for a number o | |||
| 49 | 73 | ||
| 50 | Encoding can have two meanings: | 74 | Encoding can have two meanings: |
| 51 | 75 | ||
| 52 | - In computer technology, encoding is the process of applying a specific code, such as letters, symbols and numbers, to data for conversion into an equivalent cipher. | 76 | - In computer technology, encoding is the process of applying a specific code, |
| 77 | such as letters, symbols and numbers, to data for conversion into an | ||
| 78 | equivalent cipher. | ||
| 53 | - In electronics, encoding refers to analog to digital conversion. | 79 | - In electronics, encoding refers to analog to digital conversion. |
| 54 | 80 | ||
| 55 | ## Quick history of DNA | 81 | ## Quick history of DNA |
| @@ -73,13 +99,19 @@ Encoding can have two meanings: | |||
| 73 | 99 | ||
| 74 | ## What is DNA? | 100 | ## What is DNA? |
| 75 | 101 | ||
| 76 | Deoxyribonucleic acid, a self-replicating material which is **present in nearly all living organisms** as the main constituent of chromosomes. It is the **carrier of genetic information**. | 102 | Deoxyribonucleic acid, a self-replicating material which is |
| 103 | **present in nearly all living organisms** as the main constituent of | ||
| 104 | chromosomes. It is the **carrier of genetic information**. | ||
| 77 | 105 | ||
| 78 | > The nitrogen in our DNA, the calcium in our teeth, the iron in our blood, the carbon in our apple pies were made in the interiors of collapsing stars. We are made of starstuff. | 106 | > The nitrogen in our DNA, the calcium in our teeth, the iron in our blood, |
| 79 | > | 107 | > the carbon in our apple pies were made in the interiors of collapsing stars. |
| 108 | > We are made of starstuff. | ||
| 80 | > **-- Carl Sagan, Cosmos** | 109 | > **-- Carl Sagan, Cosmos** |
| 81 | 110 | ||
| 82 | The nucleotide in DNA consists of a sugar (deoxyribose), one of four bases (cytosine (C), thymine (T), adenine (A), guanine (G)), and a phosphate. Cytosine and thymine are pyrimidine bases, while adenine and guanine are purine bases. The sugar and the base together are called a nucleoside. | 111 | The nucleotide in DNA consists of a sugar (deoxyribose), one of four bases |
| 112 | (cytosine (C), thymine (T), adenine (A), guanine (G)), and a phosphate. | ||
| 113 | Cytosine and thymine are pyrimidine bases, while adenine and guanine are purine | ||
| 114 | bases. The sugar and the base together are called a nucleoside. | ||
| 83 | 115 | ||
| 84 |  | 116 |  |
| 85 | 117 | ||
| @@ -88,6 +120,7 @@ The nucleotide in DNA consists of a sugar (deoxyribose), one of four bases (cyto | |||
| 88 | ## Encode binary data into DNA sequence | 120 | ## Encode binary data into DNA sequence |
| 89 | 121 | ||
| 90 | As an input file you can use any file you want: | 122 | As an input file you can use any file you want: |
| 123 | |||
| 91 | - ASCII files, | 124 | - ASCII files, |
| 92 | - Compiled programs, | 125 | - Compiled programs, |
| 93 | - Multimedia files (MP3, MP4, MVK, etc), | 126 | - Multimedia files (MP3, MP4, MVK, etc), |
| @@ -95,15 +128,19 @@ As an input file you can use any file you want: | |||
| 95 | - Database files, | 128 | - Database files, |
| 96 | - etc. | 129 | - etc. |
| 97 | 130 | ||
| 98 | Note: If you would copy all the bytes from RAM to file or pipe data to file you could encode also this data as long as you provide file pointer to the encoder. | 131 | Note: If you would copy all the bytes from RAM to file or pipe data to file you |
| 132 | could encode also this data as long as you provide file pointer to the encoder. | ||
| 99 | 133 | ||
| 100 | ### Basic Encoding | 134 | ### Basic Encoding |
| 101 | 135 | ||
| 102 | As already mentioned, the Basic Encoding is based on a simple mapping. Since DNA is composed of 4 nucleotides (Adenine, Cytosine, Guanine, Thymine; usually referred using the first letter). Using this technique we can encode | 136 | As already mentioned, the Basic Encoding is based on a simple mapping. Since |
| 137 | DNA is composed of 4 nucleotides (Adenine, Cytosine, Guanine, Thymine; usually | ||
| 138 | referred using the first letter). Using this technique we can encode | ||
| 103 | 139 | ||
| 104 | $$ log_2(4) = log_2(2^2) = 2 bits $$ | 140 | $$ log_2(4) = log_2(2^2) = 2 bits $$ |
| 105 | 141 | ||
| 106 | using a single nucleotide. In this way, we are able to use the 4 bases that compose the DNA strand to encode each byte of data. | 142 | using a single nucleotide. In this way, we are able to use the 4 bases that |
| 143 | compose the DNA strand to encode each byte of data. | ||
| 107 | 144 | ||
| 108 | | Two bits | Nucleotides | | 145 | | Two bits | Nucleotides | |
| 109 | | -------- | ---------------- | | 146 | | -------- | ---------------- | |
| @@ -112,7 +149,8 @@ using a single nucleotide. In this way, we are able to use the 4 bases that comp | |||
| 112 | | 01 | **C** (Cytosine) | | 149 | | 01 | **C** (Cytosine) | |
| 113 | | 11 | **T** (Thymine) | | 150 | | 11 | **T** (Thymine) | |
| 114 | 151 | ||
| 115 | With this in mind we can simply encode any data by using two-bit to Nucleotides conversion. | 152 | With this in mind we can simply encode any data by using two-bit to |
| 153 | Nucleotides conversion. | ||
| 116 | 154 | ||
| 117 | ```python | 155 | ```python |
| 118 | { Algorithm 1: Naive byte array to DNA encode } | 156 | { Algorithm 1: Naive byte array to DNA encode } |
| @@ -135,15 +173,29 @@ begin | |||
| 135 | end | 173 | end |
| 136 | ``` | 174 | ``` |
| 137 | 175 | ||
| 138 | Another encoding would be **Goldman encoding**. Using this encoding helps with Nonsense mutation (amino acids replaced by a stop codon) that occurs and is the most problematic during translation because it leads to truncated amino acid sequences, which in turn results in truncated proteins. | 176 | Another encoding would be **Goldman encoding**. Using this encoding helps with |
| 177 | Nonsense mutation (amino acids replaced by a stop codon) that occurs and is | ||
| 178 | the most problematic during translation because it leads to truncated amino | ||
| 179 | acid sequences, which in turn results in truncated proteins. | ||
| 139 | 180 | ||
| 140 | [Where to store big data? In DNA: Nick Goldman at TEDxPrague](https://www.youtube.com/watch?v=a4PiGWNsIEU) | 181 | [Where to store big data? In DNA: Nick Goldman at TEDxPrague](https://www.youtube.com/watch?v=a4PiGWNsIEU) |
| 141 | 182 | ||
| 142 | ### FASTA file format | 183 | ### FASTA file format |
| 143 | 184 | ||
| 144 | In bioinformatics, FASTA format is a text-based format for representing either nucleotide sequences or peptide sequences, in which nucleotides or amino acids are represented using single-letter codes. The format also allows for sequence names and comments to precede the sequences. The format originates from the FASTA software package, but has now become a standard in the field of bioinformatics. | 185 | In bioinformatics, FASTA format is a text-based format for representing either |
| 145 | 186 | nucleotide sequences or peptide sequences, in which nucleotides or amino acids | |
| 146 | The first line in a FASTA file started either with a ">" (greater-than) symbol or, less frequently, a ";" (semicolon) was taken as a comment. Subsequent lines starting with a semicolon would be ignored by software. Since the only comment used was the first, it quickly became used to hold a summary description of the sequence, often starting with a unique library accession number, and with time it has become commonplace to always use ">" for the first line and to not use ";" comments (which would otherwise be ignored). | 187 | are represented using single-letter codes. The format also allows for sequence |
| 188 | names and comments to precede the sequences. The format originates from the | ||
| 189 | FASTA software package, but has now become a standard in the field of | ||
| 190 | bioinformatics. | ||
| 191 | |||
| 192 | The first line in a FASTA file started either with a ">" (greater-than) symbol | ||
| 193 | or, less frequently, a ";" (semicolon) was taken as a comment. Subsequent | ||
| 194 | lines starting with a semicolon would be ignored by software. Since the only | ||
| 195 | comment used was the first, it quickly became used to hold a summary | ||
| 196 | description of the sequence, often starting with a unique library accession | ||
| 197 | number, and with time it has become commonplace to always use ">" for the first | ||
| 198 | line and to not use ";" comments (which would otherwise be ignored). | ||
| 147 | 199 | ||
| 148 | ``` | 200 | ``` |
| 149 | ;LCBO - Prolactin precursor - Bovine | 201 | ;LCBO - Prolactin precursor - Bovine |
| @@ -166,7 +218,8 @@ GLMPFLHTSKHRSMMLRPLSQALFWTLTMDLLTLTWIGSQPVEYPYTIIGQMASILYFSIILAFLPIAGX | |||
| 166 | IENY | 218 | IENY |
| 167 | ``` | 219 | ``` |
| 168 | 220 | ||
| 169 | FASTA format was extended by [FASTQ](https://en.wikipedia.org/wiki/FASTQ_format) format from the [Sanger Centre](https://www.sanger.ac.uk/) in Cambridge. | 221 | FASTA format was extended by [FASTQ](https://en.wikipedia.org/wiki/FASTQ_format) |
| 222 | format from the [Sanger Centre](https://www.sanger.ac.uk/) in Cambridge. | ||
| 170 | 223 | ||
| 171 | ### PNG encoded DNA sequence | 224 | ### PNG encoded DNA sequence |
| 172 | 225 | ||
| @@ -177,7 +230,8 @@ FASTA format was extended by [FASTQ](https://en.wikipedia.org/wiki/FASTQ_format) | |||
| 177 | | C ➞ Cytosine | (255,0,0) | Red | | 230 | | C ➞ Cytosine | (255,0,0) | Red | |
| 178 | | T ➞ Thymine | (255,255,0) | Yellow | | 231 | | T ➞ Thymine | (255,255,0) | Yellow | |
| 179 | 232 | ||
| 180 | With this in mind we can create a simple algorithm to create PNG representation of a DNA sequence. | 233 | With this in mind we can create a simple algorithm to create PNG representation |
| 234 | of a DNA sequence. | ||
| 181 | 235 | ||
| 182 | ```python | 236 | ```python |
| 183 | { Algorithm 2: Naive DNA to PNG encode from FASTA file } | 237 | { Algorithm 2: Naive DNA to PNG encode from FASTA file } |
| @@ -198,9 +252,11 @@ end | |||
| 198 | 252 | ||
| 199 | ## Encoding text file in practice | 253 | ## Encoding text file in practice |
| 200 | 254 | ||
| 201 | In this example we will take a simple text file as our input stream for encoding. This file will have a quote from Niels Bohr and saved as txt file. | 255 | In this example we will take a simple text file as our input stream for |
| 256 | encoding. This file will have a quote from Niels Bohr and saved as txt file. | ||
| 202 | 257 | ||
| 203 | > How wonderful that we have met with a paradox. Now we have some hope of making progress. | 258 | > How wonderful that we have met with a paradox. Now we have some hope of |
| 259 | > making progress. | ||
| 204 | > ― Niels Bohr | 260 | > ― Niels Bohr |
| 205 | 261 | ||
| 206 | First we encode text file into FASTA file. | 262 | First we encode text file into FASTA file. |
| @@ -250,7 +306,8 @@ After encoding into PNG format this file looks like this. | |||
| 250 | 306 | ||
| 251 | The larger the input stream is the larger the PNG file would be. | 307 | The larger the input stream is the larger the PNG file would be. |
| 252 | 308 | ||
| 253 | Compiled basic Hello World C program with [GCC](https://www.gnu.org/software/gcc/) would [look like](/assets/dna-sequence/sample.png). | 309 | Compiled basic Hello World C program with [GCC](https://www.gnu.org/software/gcc/) |
| 310 | would [look like](/assets/dna-sequence/sample.png). | ||
| 254 | 311 | ||
| 255 | ```c | 312 | ```c |
| 256 | // gcc -O3 -o sample sample.c | 313 | // gcc -O3 -o sample sample.c |
| @@ -265,10 +322,12 @@ main() { | |||
| 265 | ## Toolkit for encoding data | 322 | ## Toolkit for encoding data |
| 266 | 323 | ||
| 267 | I have created a toolkit with two main programs: | 324 | I have created a toolkit with two main programs: |
| 325 | |||
| 268 | - dnae-encode (encodes file into FASTA file) | 326 | - dnae-encode (encodes file into FASTA file) |
| 269 | - dnae-png (encodes FASTA file into PNG) | 327 | - dnae-png (encodes FASTA file into PNG) |
| 270 | 328 | ||
| 271 | Toolkit with full source code is available on [github.com/mitjafelicijan/dna-encoding](https://github.com/mitjafelicijan/dna-encoding). | 329 | Toolkit with full source code is available on |
| 330 | [github.com/mitjafelicijan/dna-encoding](https://github.com/mitjafelicijan/dna-encoding). | ||
| 272 | 331 | ||
| 273 | ### dnae-encode | 332 | ### dnae-encode |
| 274 | 333 | ||
| @@ -311,11 +370,13 @@ First we generate some binary sample data with dd. | |||
| 311 | dd if=<(openssl enc -aes-256-ctr -pass pass:"$(dd if=/dev/urandom bs=128 count=1 2>/dev/null | base64)" -nosalt < /dev/zero) of=1KB.bin bs=1KB count=1 iflag=fullblock | 370 | dd if=<(openssl enc -aes-256-ctr -pass pass:"$(dd if=/dev/urandom bs=128 count=1 2>/dev/null | base64)" -nosalt < /dev/zero) of=1KB.bin bs=1KB count=1 iflag=fullblock |
| 312 | ``` | 371 | ``` |
| 313 | 372 | ||
| 314 | Our freshly generated 1KB file looks something like this (its full of garbage data as intended). | 373 | Our freshly generated 1KB file looks something like this (its full of garbage |
| 374 | data as intended). | ||
| 315 | 375 | ||
| 316 |  | 376 |  |
| 317 | 377 | ||
| 318 | We create following binary files: | 378 | We create following binary files: |
| 379 | |||
| 319 | - 1KB.bin | 380 | - 1KB.bin |
| 320 | - 10KB.bin | 381 | - 10KB.bin |
| 321 | - 100KB.bin | 382 | - 100KB.bin |
| @@ -323,7 +384,8 @@ We create following binary files: | |||
| 323 | - 10MB.bin | 384 | - 10MB.bin |
| 324 | - 100MB.bin | 385 | - 100MB.bin |
| 325 | 386 | ||
| 326 | After this we create FASTA files for all the binary files by encoding them into DNA sequence. | 387 | After this we create FASTA files for all the binary files by encoding them |
| 388 | into DNA sequence. | ||
| 327 | 389 | ||
| 328 | ```bash | 390 | ```bash |
| 329 | ./dnae-encode -i 100MB.bin -o 100MB.fa | 391 | ./dnae-encode -i 100MB.bin -o 100MB.fa |
| @@ -348,3 +410,4 @@ gzip -9 < 10MB.fa > 10MB.fa.gz | |||
| 348 | - https://opentextbc.ca/biology/chapter/9-1-the-structure-of-dna/ | 410 | - https://opentextbc.ca/biology/chapter/9-1-the-structure-of-dna/ |
| 349 | - https://arxiv.org/abs/1801.04774 | 411 | - https://arxiv.org/abs/1801.04774 |
| 350 | - https://en.wikipedia.org/wiki/FASTA_format | 412 | - https://en.wikipedia.org/wiki/FASTA_format |
| 413 | |||
diff --git a/content/posts/2019-10-14-simplifying-and-reducing-clutter.md b/content/posts/2019-10-14-simplifying-and-reducing-clutter.md index deb0cb8..13f4f42 100644 --- a/content/posts/2019-10-14-simplifying-and-reducing-clutter.md +++ b/content/posts/2019-10-14-simplifying-and-reducing-clutter.md | |||
| @@ -1,22 +1,57 @@ | |||
| 1 | --- | 1 | --- |
| 2 | title: Simplifying and reducing clutter in my life and work | 2 | title: Simplifying and reducing clutter in my life and work |
| 3 | url: simplifying-and-reducing-clutter.html | 3 | url: simplifying-and-reducing-clutter.html |
| 4 | date: 2019-10-14 | 4 | date: 2019-10-14T12:00:00+02:00 |
| 5 | draft: false | 5 | draft: false |
| 6 | --- | 6 | --- |
| 7 | 7 | ||
| 8 | I recently moved my main working machine back from Hachintosh to Linux. Well the experiment was interesting and I have done some great work on macOS but it was time to move back. | 8 | I recently moved my main working machine back from Hachintosh to Linux. Well |
| 9 | 9 | the experiment was interesting and I have done some great work on macOS but it | |
| 10 | I actually really missed Linux. The simplicity of `apt-get` or just the amount of software that exists for Linux should be a no-brainer. I spent most of my time on macOS finding solutions to make things work. Using [Brew](https://brew.sh/) was just a horrible experience and far from package managers of Linux. At least they managed to get that `sudo` debacle sorted. | 10 | was time to move back. |
| 11 | 11 | ||
| 12 | Not all was bad. macOS in general was a perfectly good environment. Things like Docker and tooling like this worked without any hiccups. My normal tools like coding IDE worked flawlessly and the whole look and feel is just superb. I have been using MacBook Air for couple of years so I was used to the system but never as a daily driver. | 12 | I actually really missed Linux. The simplicity of `apt-get` or just the amount |
| 13 | 13 | of software that exists for Linux should be a no-brainer. I spent most of my | |
| 14 | One of the things I did after I installed Linux back on my machine was cleaning up my Dropbox folder. I have everything on Dropbox. Even projects folder. I write code for living so my whole life revolves around couple of megs of code (with assets). So it's not like I have huge files on my machine. I don't have movies or music or pictures on my PC. All of that stuff is in cloud. I use Google music and I have Netflix account which is more than enough for me. | 14 | time on macOS finding solutions to make things work. Using [Brew](https://brew.sh/) |
| 15 | 15 | was just a horrible experience and far from package managers of Linux. At least | |
| 16 | I also went and deleted some of the repositories on my Github account. I have deleted more code than deployed. People find this strange but for me deleting something feels so cathartic and also forces me to write better code next time around when I am faced with similar problem. That was a huge relief if I am being totally honest. | 16 | they managed to get that `sudo` debacle sorted. |
| 17 | 17 | ||
| 18 | Next step was to do something with my webpage. I have been using some scripts I wrote a while ago to generate static pages from markdown source posts. I kept on adding and adding stuff on top of it and it became a source of a frustration. And this is just a simple blog and I was using gulp and npm. Anyways after couple of hours of searching and testing static generators I found an interesting one [https://github.com/piranha/gostatic](https://github.com/piranha/gostatic) and I just decided to use this one. It was the only one that had a simple templating engine, not that I really need one. But others had this convoluted way of trying to solve everything and at the end just required quite bigger learning curve I was ready to go with. So I deleted couple of old posts, simplified HTML, trashed most of the CSS and went with [https://motherfuckingwebsite.com/](https://motherfuckingwebsite.com/) aesthetics. Yeah, the previous site was more visually stimulating but all I really care is the content at this point. And Times New Roman font is kind of awesome. | 18 | Not all was bad. macOS in general was a perfectly good environment. Things like |
| 19 | 19 | Docker and tooling like this worked without any hiccups. My normal tools like | |
| 20 | I stopped working on most of the projects in the past couple of months because the overhead was just too insane. There comes a point when you stretch yourself too much and then you stop progressing and with that comes dissatisfaction. | 20 | coding IDE worked flawlessly and the whole look and feel is just superb. I have |
| 21 | been using MacBook Air for couple of years so I was used to the system but | ||
| 22 | never as a daily driver. | ||
| 23 | |||
| 24 | One of the things I did after I installed Linux back on my machine was cleaning | ||
| 25 | up my Dropbox folder. I have everything on Dropbox. Even projects folder. I | ||
| 26 | write code for living so my whole life revolves around couple of megs of code | ||
| 27 | (with assets). So it's not like I have huge files on my machine. I don't have | ||
| 28 | movies or music or pictures on my PC. All of that stuff is in cloud. I use | ||
| 29 | Google music and I have Netflix account which is more than enough for me. | ||
| 30 | |||
| 31 | I also went and deleted some of the repositories on my Github account. I have | ||
| 32 | deleted more code than deployed. People find this strange but for me deleting | ||
| 33 | something feels so cathartic and also forces me to write better code next time | ||
| 34 | around when I am faced with similar problem. That was a huge relief if I am | ||
| 35 | being totally honest. | ||
| 36 | |||
| 37 | Next step was to do something with my webpage. I have been using some scripts | ||
| 38 | I wrote a while ago to generate static pages from markdown source posts. I kept | ||
| 39 | on adding and adding stuff on top of it and it became a source of a | ||
| 40 | frustration. And this is just a simple blog and I was using gulp and npm. | ||
| 41 | Anyways after couple of hours of searching and testing static generators I | ||
| 42 | found an interesting one [https://github.com/piranha/gostatic](https://github.com/piranha/gostatic) | ||
| 43 | and I just decided to use this one. It was the only one that had a simple | ||
| 44 | templating engine, not that I really need one. But others had this convoluted | ||
| 45 | way of trying to solve everything and at the end just required quite bigger | ||
| 46 | learning curve I was ready to go with. So I deleted couple of old posts, | ||
| 47 | simplified HTML, trashed most of the CSS and went with | ||
| 48 | [https://motherfuckingwebsite.com/](https://motherfuckingwebsite.com/) aesthetics. | ||
| 49 | Yeah, the previous site was more visually stimulating but all I really care is | ||
| 50 | the content at this point. And Times New Roman font is kind of awesome. | ||
| 51 | |||
| 52 | I stopped working on most of the projects in the past couple of months because | ||
| 53 | the overhead was just too insane. There comes a point when you stretch yourself | ||
| 54 | too much and then you stop progressing and with that comes dissatisfaction. | ||
| 21 | 55 | ||
| 22 | So that's about it. Moving forward minimal style. | 56 | So that's about it. Moving forward minimal style. |
| 57 | |||
diff --git a/content/posts/2019-10-19-using-sentiment-analysis-for-clickbait-detection.md b/content/posts/2019-10-19-using-sentiment-analysis-for-clickbait-detection.md index 30b0fd4..995da25 100644 --- a/content/posts/2019-10-19-using-sentiment-analysis-for-clickbait-detection.md +++ b/content/posts/2019-10-19-using-sentiment-analysis-for-clickbait-detection.md | |||
| @@ -1,21 +1,29 @@ | |||
| 1 | --- | 1 | --- |
| 2 | title: Using sentiment analysis for clickbait detection in RSS feeds | 2 | title: Using sentiment analysis for clickbait detection in RSS feeds |
| 3 | url: using-sentiment-analysis-for-clickbait-detection-in-rss-feeds.html | 3 | url: using-sentiment-analysis-for-clickbait-detection-in-rss-feeds.html |
| 4 | date: 2019-10-19 | 4 | date: 2019-10-19T12:00:00+02:00 |
| 5 | draft: false | 5 | draft: false |
| 6 | --- | 6 | --- |
| 7 | 7 | ||
| 8 | ## Initial thoughts | 8 | ## Initial thoughts |
| 9 | 9 | ||
| 10 | One of the things that interested me for a while now is if major well established news sites use click bait titles to drive additional traffic to their sites and generate additional impressions. | 10 | One of the things that interested me for a while now is if major well |
| 11 | established news sites use click bait titles to drive additional traffic | ||
| 12 | to their sites and generate additional impressions. | ||
| 11 | 13 | ||
| 12 | Goal is to see how article titles and actual content of article differ from each other and see if titles are clickbaited. | 14 | Goal is to see how article titles and actual content of article differ from |
| 15 | each other and see if titles are clickbaited. | ||
| 13 | 16 | ||
| 14 | ## Preparing and cleaning data | 17 | ## Preparing and cleaning data |
| 15 | 18 | ||
| 16 | For this example I opted to just use RSS feed from a new website and decided to go with [The Guardian](https://www.theguardian.com) World news. While this gets us limited data (~40) articles and also description (actual content) is trimmed this really doesn't reflect the actual article contents. | 19 | For this example I opted to just use RSS feed from a new website and decided |
| 20 | to go with [The Guardian](https://www.theguardian.com) World news. While this | ||
| 21 | gets us limited data (~40) articles and also description (actual content) is | ||
| 22 | trimmed this really doesn't reflect the actual article contents. | ||
| 17 | 23 | ||
| 18 | To get better content I could use web scraping and use RSS as link list and fetch contents directly from website, but for this simple example this will suffice. | 24 | To get better content I could use web scraping and use RSS as link list and |
| 25 | fetch contents directly from website, but for this simple example this will | ||
| 26 | suffice. | ||
| 19 | 27 | ||
| 20 | There are couple of requirements we need to install before we continue: | 28 | There are couple of requirements we need to install before we continue: |
| 21 | 29 | ||
| @@ -39,9 +47,15 @@ for item in feed.entries: | |||
| 39 | 47 | ||
| 40 | ## Perform sentiment analysis | 48 | ## Perform sentiment analysis |
| 41 | 49 | ||
| 42 | Since we now have cleaned up data in our `feed.entries` object we can start with performing sentiment analysis. | 50 | Since we now have cleaned up data in our `feed.entries` object we can start with |
| 51 | performing sentiment analysis. | ||
| 43 | 52 | ||
| 44 | There are many sentiment analysis libraries available that range from rule-based sentiment analysis up to machine learning supported analysis. To keep things simple I decided to use rule-based analysis library [vaderSentiment](https://github.com/cjhutto/vaderSentiment) from [C.J. Hutto](https://github.com/cjhutto). Really nice library and quite easy to use. | 53 | There are many sentiment analysis libraries available that range from rule-based |
| 54 | sentiment analysis up to machine learning supported analysis. To keep things | ||
| 55 | simple I decided to use rule-based analysis library | ||
| 56 | [vaderSentiment](https://github.com/cjhutto/vaderSentiment) from | ||
| 57 | [C.J. Hutto](https://github.com/cjhutto). Really nice library and quite | ||
| 58 | easy to use. | ||
| 45 | 59 | ||
| 46 | ```python | 60 | ```python |
| 47 | from vaderSentiment.vaderSentiment import SentimentIntensityAnalyzer | 61 | from vaderSentiment.vaderSentiment import SentimentIntensityAnalyzer |
| @@ -54,7 +68,9 @@ for item in feed.entries: | |||
| 54 | sentiment_results.append([sentiment_title['compound'], sentiment_description['compound']]) | 68 | sentiment_results.append([sentiment_title['compound'], sentiment_description['compound']]) |
| 55 | ``` | 69 | ``` |
| 56 | 70 | ||
| 57 | Now that we have this data in a shape that is compatible with matplotlib we can plot results to see the difference between title and description sentiment of an article. | 71 | Now that we have this data in a shape that is compatible with matplotlib we can |
| 72 | plot results to see the difference between title and description sentiment of | ||
| 73 | an article. | ||
| 58 | 74 | ||
| 59 | ```python | 75 | ```python |
| 60 | import matplotlib.pyplot as plt | 76 | import matplotlib.pyplot as plt |
| @@ -69,12 +85,16 @@ plt.show() | |||
| 69 | ## Results and assets | 85 | ## Results and assets |
| 70 | 86 | ||
| 71 | 1. Because of the small sample size further conclusions are impossible to make. | 87 | 1. Because of the small sample size further conclusions are impossible to make. |
| 72 | 2. Rule-based approach may not be the best way of doing this. By using deep learning we would be able to get better insights. | 88 | 2. Rule-based approach may not be the best way of doing this. By using deep |
| 73 | 3. **Next step would be to** periodically fetch RSS items and store them over a longer period of time and then perform analysis again and use either machine learning or deep learning on top of it. | 89 | learning we would be able to get better insights. |
| 90 | 3. **Next step would be to** periodically fetch RSS items and store them over | ||
| 91 | a longer period of time and then perform analysis again and use either | ||
| 92 | machine learning or deep learning on top of it. | ||
| 74 | 93 | ||
| 75 |  | 94 |  |
| 76 | 95 | ||
| 77 | Figure above displays difference between title and description sentiment for specific RSS feed item. 1 means positive and -1 means negative sentiment. | 96 | Figure above displays difference between title and description sentiment for |
| 97 | specific RSS feed item. 1 means positive and -1 means negative sentiment. | ||
| 78 | 98 | ||
| 79 | [» Download Jupyter Notebook](/assets/sentiment-analysis/sentiment-analysis.ipynb) | 99 | [» Download Jupyter Notebook](/assets/sentiment-analysis/sentiment-analysis.ipynb) |
| 80 | 100 | ||
| @@ -84,3 +104,4 @@ Figure above displays difference between title and description sentiment for spe | |||
| 84 | - [AFINN-based sentiment analysis for Node.js by Andrew Sliwinski](https://github.com/thisandagain/sentiment) | 104 | - [AFINN-based sentiment analysis for Node.js by Andrew Sliwinski](https://github.com/thisandagain/sentiment) |
| 85 | - [Sentiment Analysis with LSTMs in Tensorflow by Adit Deshpande](https://github.com/adeshpande3/LSTM-Sentiment-Analysis) | 105 | - [Sentiment Analysis with LSTMs in Tensorflow by Adit Deshpande](https://github.com/adeshpande3/LSTM-Sentiment-Analysis) |
| 86 | - [Sentiment analysis on tweets using Naive Bayes, SVM, CNN, LSTM, etc. by Abdul Fatir](https://github.com/abdulfatir/twitter-sentiment-analysis) | 106 | - [Sentiment analysis on tweets using Naive Bayes, SVM, CNN, LSTM, etc. by Abdul Fatir](https://github.com/abdulfatir/twitter-sentiment-analysis) |
| 107 | |||
diff --git a/content/posts/2020-03-22-simple-sse-based-pubsub-server.md b/content/posts/2020-03-22-simple-sse-based-pubsub-server.md index 939a62d..77c42a9 100644 --- a/content/posts/2020-03-22-simple-sse-based-pubsub-server.md +++ b/content/posts/2020-03-22-simple-sse-based-pubsub-server.md | |||
| @@ -1,25 +1,41 @@ | |||
| 1 | --- | 1 | --- |
| 2 | title: Simple Server-Sent Events based PubSub Server | 2 | title: Simple Server-Sent Events based PubSub Server |
| 3 | url: simple-server-sent-events-based-pubsub-server.html | 3 | url: simple-server-sent-events-based-pubsub-server.html |
| 4 | date: 2020-03-22 | 4 | date: 2020-03-22T12:00:00+02:00 |
| 5 | draft: false | 5 | draft: false |
| 6 | --- | 6 | --- |
| 7 | 7 | ||
| 8 | ## Before we continue ... | 8 | ## Before we continue ... |
| 9 | 9 | ||
| 10 | Publisher Subscriber model is nothing new and there are many amazing solutions out there, so writing a new one would be a waste of time if other solutions wouldn't have quite complex install procedures and weren't so hard to maintain. But to be fair, comparing this simple server with something like [Kafka](https://kafka.apache.org/) or [RabbitMQ](https://www.rabbitmq.com/) is laughable at the least. Those solutions are enterprise grade and have many mechanisms there to ensure messages aren't lost and much more. Regardless of these drawbacks, this method has been tested on a large website and worked until now without any problems. So now, that we got that cleared up, let's continue. | 10 | Publisher Subscriber model is nothing new and there are many amazing solutions |
| 11 | 11 | out there, so writing a new one would be a waste of time if other solutions | |
| 12 | ***Wiki definition:** Publish/subscribe messaging, or pub/sub messaging, is a form of asynchronous service-to-service communication used in serverless and microservices architectures. In a pub/sub model, any message published to a topic is immediately received by all the subscribers to the topic.* | 12 | wouldn't have quite complex install procedures and weren't so hard to maintain. |
| 13 | But to be fair, comparing this simple server with something like | ||
| 14 | [Kafka](https://kafka.apache.org/) or [RabbitMQ](https://www.rabbitmq.com/) is | ||
| 15 | laughable at the least. Those solutions are enterprise grade and have many | ||
| 16 | mechanisms there to ensure messages aren't lost and much more. Regardless of | ||
| 17 | these drawbacks, this method has been tested on a large website and worked | ||
| 18 | until now without any problems. So now, that we got that cleared up, let's | ||
| 19 | continue. | ||
| 20 | |||
| 21 | ***Wiki definition:** Publish/subscribe messaging, or pub/sub messaging, is a | ||
| 22 | form of asynchronous service-to-service communication used in serverless and | ||
| 23 | microservices architectures. In a pub/sub model, any message published to a | ||
| 24 | topic is immediately received by all the subscribers to the topic.* | ||
| 13 | 25 | ||
| 14 | ## General goals | 26 | ## General goals |
| 15 | 27 | ||
| 16 | - provide a simple server that relays messages to all the connected clients, | 28 | - provide a simple server that relays messages to all the connected clients, |
| 17 | - messages can be posted on specific topics, | 29 | - messages can be posted on specific topics, |
| 18 | - messages get sent via [Server-Sent Events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events) to all the subscribers. | 30 | - messages get sent via [Server-Sent Events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events) |
| 31 | to all the subscribers. | ||
| 19 | 32 | ||
| 20 | ## How exactly does the pub/sub model work? | 33 | ## How exactly does the pub/sub model work? |
| 21 | 34 | ||
| 22 | The easiest way to explain this is with diagram bellow. Basic function is simple. We have subscribers that receive messages, and we have publishers that create and post messages. Similar model is also well know pattern that works on a premise of consumers and producers, and they take similar roles. | 35 | The easiest way to explain this is with diagram bellow. Basic function is |
| 36 | simple. We have subscribers that receive messages, and we have publishers that | ||
| 37 | create and post messages. Similar model is also well know pattern that works | ||
| 38 | on a premise of consumers and producers, and they take similar roles. | ||
| 23 | 39 | ||
| 24 |  | 40 |  |
| 25 | 41 | ||
| @@ -29,16 +45,23 @@ The easiest way to explain this is with diagram bellow. Basic function is simple | |||
| 29 | - consumer is receiving messages from subscribed topic, | 45 | - consumer is receiving messages from subscribed topic, |
| 30 | - servers is also known as Broker, | 46 | - servers is also known as Broker, |
| 31 | - broker does not store messages or tracks success, | 47 | - broker does not store messages or tracks success, |
| 32 | - broker uses [FIFO](https://en.wikipedia.org/wiki/FIFO_(computing_and_electronics)) method for delivering messages, | 48 | - broker uses [FIFO](https://en.wikipedia.org/wiki/FIFO_(computing_and_electronics)) |
| 33 | - if consumer wants to receive messages from a topic, producer and consumer topics must match, | 49 | method for delivering messages, |
| 50 | - if consumer wants to receive messages from a topic, producer and consumer topics | ||
| 51 | must match, | ||
| 34 | - consumer can subscribe to multiple topics, | 52 | - consumer can subscribe to multiple topics, |
| 35 | - producer can publish to multiple topics, | 53 | - producer can publish to multiple topics, |
| 36 | - each message has a messageId. | 54 | - each message has a messageId. |
| 37 | 55 | ||
| 38 | **Known drawbacks:** | 56 | **Known drawbacks:** |
| 39 | 57 | ||
| 40 | - messages will not be stored in a persistent queue or unreceived messages like [DeadLetterQueue](https://en.wikipedia.org/wiki/Dead_letter_queue) so old messages could be lost on server restart, | 58 | - messages will not be stored in a persistent queue or unreceived messages like |
| 41 | - [Server-Sent Events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events) opens a long-running connection between the client and the server so make sure if your setup is load balanced that the load balancer in this case can have long opened connection, | 59 | [DeadLetterQueue](https://en.wikipedia.org/wiki/Dead_letter_queue) so old |
| 60 | messages could be lost on server restart, | ||
| 61 | - [Server-Sent Events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events) | ||
| 62 | opens a long-running connection between the client and the server so make | ||
| 63 | sure if your setup is load balanced that the load balancer in this case can | ||
| 64 | have long opened connection, | ||
| 42 | - no system moderation due to the dynamic nature of creating queues. | 65 | - no system moderation due to the dynamic nature of creating queues. |
| 43 | 66 | ||
| 44 | ## Server-Sent Events | 67 | ## Server-Sent Events |
| @@ -49,13 +72,16 @@ Read more about it on [official specification page](https://html.spec.whatwg.org | |||
| 49 | 72 | ||
| 50 |  | 73 |  |
| 51 | 74 | ||
| 52 | Check [https://caniuse.com/#feat=eventsource](https://caniuse.com/#feat=eventsource) for latest information about browser support. | 75 | Check [https://caniuse.com/#feat=eventsource](https://caniuse.com/#feat=eventsource) |
| 76 | for latest information about browser support. | ||
| 53 | 77 | ||
| 54 | ### Known issues | 78 | ### Known issues |
| 55 | 79 | ||
| 56 | - Firefox 52 and below do not support EventSource in web/shared workers | 80 | - Firefox 52 and below do not support EventSource in web/shared workers |
| 57 | - In Firefox prior to version 36 server-sent events do not reconnect automatically in case of a connection interrupt (bug) | 81 | - In Firefox prior to version 36 server-sent events do not reconnect |
| 58 | - Reportedly, CORS in EventSource is currently supported in Firefox 10+, Opera 12+, Chrome 26+, Safari 7.0+. | 82 | automatically in case of a connection interrupt (bug) |
| 83 | - Reportedly, CORS in EventSource is currently supported in Firefox 10+, | ||
| 84 | Opera 12+, Chrome 26+, Safari 7.0+. | ||
| 59 | - Antivirus software may block the event streaming data chunks. | 85 | - Antivirus software may block the event streaming data chunks. |
| 60 | 86 | ||
| 61 | Source: [https://caniuse.com/#feat=eventsource](https://caniuse.com/#feat=eventsource) | 87 | Source: [https://caniuse.com/#feat=eventsource](https://caniuse.com/#feat=eventsource) |
| @@ -78,7 +104,8 @@ data: this is line two | |||
| 78 | <blank line> | 104 | <blank line> |
| 79 | ``` | 105 | ``` |
| 80 | 106 | ||
| 81 | And you can specify your own event types (the above messages will all trigger the message event): | 107 | And you can specify your own event types (the above messages will all trigger |
| 108 | the message event): | ||
| 82 | 109 | ||
| 83 | ```bash | 110 | ```bash |
| 84 | id: 36 | 111 | id: 36 |
| @@ -89,7 +116,8 @@ data: 103.34 | |||
| 89 | 116 | ||
| 90 | ### Server requirements | 117 | ### Server requirements |
| 91 | 118 | ||
| 92 | The important thing is how you send headers and which headers are sent by the server that triggers browser to threat response as a EventStream. | 119 | The important thing is how you send headers and which headers are sent by the |
| 120 | server that triggers browser to threat response as a EventStream. | ||
| 93 | 121 | ||
| 94 | Headers responsible for this are: | 122 | Headers responsible for this are: |
| 95 | 123 | ||
| @@ -101,15 +129,23 @@ Connection: keep-alive | |||
| 101 | 129 | ||
| 102 | ### Debugging with Google Chrome | 130 | ### Debugging with Google Chrome |
| 103 | 131 | ||
| 104 | Google Chrome provides build-in debugging and exploration tool for [Server-Sent Events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events) which is quite nice and available from Developer Tools under Network tab. | 132 | Google Chrome provides build-in debugging and exploration tool for |
| 133 | [Server-Sent Events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events) | ||
| 134 | which is quite nice and available from Developer Tools under Network tab. | ||
| 105 | 135 | ||
| 106 | > You can debug only client side events that get received and not the server ones. For debugging server events add `console.log` to `server.js` code and print out events. | 136 | > You can debug only client side events that get received and not the server |
| 137 | > ones. For debugging server events add `console.log` to `server.js` code and | ||
| 138 | > print out events. | ||
| 107 | 139 | ||
| 108 |  | 140 |  |
| 109 | 141 | ||
| 110 | ## Server implementation | 142 | ## Server implementation |
| 111 | 143 | ||
| 112 | For the sake of this example we will use [Node.js](https://nodejs.org/en/) with [Express](https://expressjs.com) as our router since this is the easiest way to get started and we will use already written SSE library for node [sse-pubsub](https://www.npmjs.com/package/sse-pubsub) so we don't reinvent the wheel. | 144 | For the sake of this example we will use [Node.js](https://nodejs.org/en/) |
| 145 | with [Express](https://expressjs.com) as our router since this is the easiest | ||
| 146 | way to get started and we will use already written SSE library for node | ||
| 147 | [sse-pubsub](https://www.npmjs.com/package/sse-pubsub) so we don't reinvent | ||
| 148 | the wheel. | ||
| 113 | 149 | ||
| 114 | ```bash | 150 | ```bash |
| 115 | npm init --yes | 151 | npm init --yes |
| @@ -216,11 +252,17 @@ app.listen(port, () => { | |||
| 216 | 252 | ||
| 217 | ### Our custom message format | 253 | ### Our custom message format |
| 218 | 254 | ||
| 219 | Each message posted on a server must be in a specific format that out server accepts. Having structure like this allows us to have multiple separated type of events on each topic. | 255 | Each message posted on a server must be in a specific format that out server |
| 256 | accepts. Having structure like this allows us to have multiple separated type | ||
| 257 | of events on each topic. | ||
| 220 | 258 | ||
| 221 | With this we can separate streams and only receive events that belong to the topic. | 259 | With this we can separate streams and only receive events that belong to the |
| 260 | topic. | ||
| 222 | 261 | ||
| 223 | One example would be, that we have index page and we want to receive messages about new upvotes or new subscribers but we don't want to follow events for other pages. This reduces clutter and overall network. And structure is much nicer and maintanable. | 262 | One example would be, that we have index page and we want to receive messages |
| 263 | about new upvotes or new subscribers but we don't want to follow events for | ||
| 264 | other pages. This reduces clutter and overall network. And structure is much | ||
| 265 | nicer and maintanable. | ||
| 224 | 266 | ||
| 225 | ```json | 267 | ```json |
| 226 | { | 268 | { |
| @@ -236,11 +278,15 @@ One example would be, that we have index page and we want to receive messages ab | |||
| 236 | 278 | ||
| 237 | <video src="/assets/simple-pubsub-server/clients.m4v" controls></video> | 279 | <video src="/assets/simple-pubsub-server/clients.m4v" controls></video> |
| 238 | 280 | ||
| 239 | You can download [the code](../simple-pubsub-server/sse-pubsub-server.zip) and follow along. | 281 | You can download [the code](../simple-pubsub-server/sse-pubsub-server.zip) |
| 282 | and follow along. | ||
| 240 | 283 | ||
| 241 | ### Publisher | 284 | ### Publisher |
| 242 | 285 | ||
| 243 | As talked about above publisher is the one that send messages to the broker/server. Message inside the payload can be whatever you want (string, object, array). I would however personally avoid send large chunks of data like blobs and such. | 286 | As talked about above publisher is the one that send messages to the |
| 287 | broker/server. Message inside the payload can be whatever you want (string, | ||
| 288 | object, array). I would however personally avoid send large chunks of data | ||
| 289 | like blobs and such. | ||
| 244 | 290 | ||
| 245 | ```html | 291 | ```html |
| 246 | <!DOCTYPE html> | 292 | <!DOCTYPE html> |
| @@ -309,16 +355,23 @@ As talked about above publisher is the one that send messages to the broker/serv | |||
| 309 | </body> | 355 | </body> |
| 310 | 356 | ||
| 311 | </html> | 357 | </html> |
| 312 | |||
| 313 | ``` | 358 | ``` |
| 314 | 359 | ||
| 315 | ### Subscriber | 360 | ### Subscriber |
| 316 | 361 | ||
| 317 | Subscriber is responsible for receiving new messages that come from server via publisher. The code bellow is very rudimentary but works and follows the implementation guidelines for EventSource. | 362 | Subscriber is responsible for receiving new messages that come from server via |
| 363 | publisher. The code bellow is very rudimentary but works and follows the | ||
| 364 | implementation guidelines for EventSource. | ||
| 318 | 365 | ||
| 319 | You can use either Developer Tools Console to see incoming messages or you can defer to Debugging with Google Chrome section above to see all EventStream messages. | 366 | You can use either Developer Tools Console to see incoming messages or you can |
| 367 | defer to Debugging with Google Chrome section above to see all EventStream | ||
| 368 | messages. | ||
| 320 | 369 | ||
| 321 | > Don't be alarmed if the subscriber gets disconnected from the server every so often. The code we have here resets connection every 15s but it automatically get reconnected and fetches all messages up to last received message id. This setting can be adjusted in `server.js` file; search for the `maxStreamDuration` variable. | 370 | > Don't be alarmed if the subscriber gets disconnected from the server every |
| 371 | > so often. The code we have here resets connection every 15s but it | ||
| 372 | > automatically get reconnected and fetches all messages up to last received | ||
| 373 | > message id. This setting can be adjusted in `server.js` file; search for | ||
| 374 | > the `maxStreamDuration` variable. | ||
| 322 | 375 | ||
| 323 | ```html | 376 | ```html |
| 324 | <!DOCTYPE html> | 377 | <!DOCTYPE html> |
| @@ -383,7 +436,6 @@ You can use either Developer Tools Console to see incoming messages or you can d | |||
| 383 | </body> | 436 | </body> |
| 384 | 437 | ||
| 385 | </html> | 438 | </html> |
| 386 | |||
| 387 | ``` | 439 | ``` |
| 388 | 440 | ||
| 389 | ## Reading further | 441 | ## Reading further |
| @@ -394,3 +446,4 @@ You can use either Developer Tools Console to see incoming messages or you can d | |||
| 394 | - [An HTTP/2 extension for bidirectional messaging communication](https://tools.ietf.org/id/draft-xie-bidirectional-messaging-01.html) | 446 | - [An HTTP/2 extension for bidirectional messaging communication](https://tools.ietf.org/id/draft-xie-bidirectional-messaging-01.html) |
| 395 | - [Introduction to HTTP/2](https://developers.google.com/web/fundamentals/performance/http2) | 447 | - [Introduction to HTTP/2](https://developers.google.com/web/fundamentals/performance/http2) |
| 396 | - [The WebSocket API (WebSockets)](https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API) | 448 | - [The WebSocket API (WebSockets)](https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API) |
| 449 | |||
diff --git a/content/posts/2020-03-27-create-placeholder-images-with-sharp.md b/content/posts/2020-03-27-create-placeholder-images-with-sharp.md index fc8eb0c..f7dd362 100644 --- a/content/posts/2020-03-27-create-placeholder-images-with-sharp.md +++ b/content/posts/2020-03-27-create-placeholder-images-with-sharp.md | |||
| @@ -1,13 +1,18 @@ | |||
| 1 | --- | 1 | --- |
| 2 | title: Create placeholder images with sharp Node.js image processing library | 2 | title: Create placeholder images with sharp Node.js image processing library |
| 3 | url: create-placeholder-images-with-sharp.html | 3 | url: create-placeholder-images-with-sharp.html |
| 4 | date: 2020-03-27 | 4 | date: 2020-03-27T12:00:00+02:00 |
| 5 | draft: false | 5 | draft: false |
| 6 | --- | 6 | --- |
| 7 | 7 | ||
| 8 | I have been searching for a solution to pre-generate some placeholder images for image server I needed to develop that resizes images on S3. I though this would be a 15min job and quickly found out how very mistaken I was. | 8 | I have been searching for a solution to pre-generate some placeholder images |
| 9 | for image server I needed to develop that resizes images on S3. I though this | ||
| 10 | would be a 15min job and quickly found out how very mistaken I was. | ||
| 9 | 11 | ||
| 10 | Even though Node.js is not really the best way to do this kind of things (surely something written in C or Rust or even Golang would be the correct way to do this but we didn't need the speed in our case) I found an excellent library [sharp - High performance Node.js image processing](https://github.com/lovell/sharp). | 12 | Even though Node.js is not really the best way to do this kind of things |
| 13 | (surely something written in C or Rust or even Golang would be the correct way | ||
| 14 | to do this but we didn't need the speed in our case) I found an excellent | ||
| 15 | library [sharp - High performance Node.js image processing](https://github.com/lovell/sharp). | ||
| 11 | 16 | ||
| 12 | Getting things running was a breeze. | 17 | Getting things running was a breeze. |
| 13 | 18 | ||
| @@ -45,15 +50,23 @@ s3.putObject({ | |||
| 45 | }).promise(); | 50 | }).promise(); |
| 46 | ``` | 51 | ``` |
| 47 | 52 | ||
| 48 | All this code was wrapped inside a web service with some additional security checks and defensive coding to detect if key is missing on S3. | 53 | All this code was wrapped inside a web service with some additional security |
| 54 | checks and defensive coding to detect if key is missing on S3. | ||
| 49 | 55 | ||
| 50 | And at that point I needed to return placeholder images as a response in case key is missing or x,y are not allowed by the server etc. I could have created PNG in Gimp and just serve them but I wanted to respect aspect ratio and I didn't want to return some mangled images. | 56 | And at that point I needed to return placeholder images as a response in case |
| 57 | key is missing or x,y are not allowed by the server etc. I could have created | ||
| 58 | PNG in Gimp and just serve them but I wanted to respect aspect ratio and I | ||
| 59 | didn't want to return some mangled images. | ||
| 51 | 60 | ||
| 52 | > Main problem with finding a clean solution I could copy and paste and change a bit was a task. API is changing constantly and there weren't clear examples or I was unable to find them. | 61 | > Main problem with finding a clean solution I could copy and paste and change |
| 62 | a bit was a task. API is changing constantly and there weren't clear examples | ||
| 63 | or I was unable to find them. | ||
| 53 | 64 | ||
| 54 | ## Generating placeholder images using SVG | 65 | ## Generating placeholder images using SVG |
| 55 | 66 | ||
| 56 | What I ended up was using SVG to generate text and created image with sharp and used composition to combine both layers. Response returned by this function is a buffer you can use to either upload to S3 or save to local file. | 67 | What I ended up was using SVG to generate text and created image with sharp and |
| 68 | used composition to combine both layers. Response returned by this function is | ||
| 69 | a buffer you can use to either upload to S3 or save to local file. | ||
| 57 | 70 | ||
| 58 | ```js | 71 | ```js |
| 59 | const generatePlaceholderImageWithText = async (width, height, message) => { | 72 | const generatePlaceholderImageWithText = async (width, height, message) => { |
| @@ -78,6 +91,11 @@ const generatePlaceholderImageWithText = async (width, height, message) => { | |||
| 78 | } | 91 | } |
| 79 | ``` | 92 | ``` |
| 80 | 93 | ||
| 81 | That is about it. Nothing more to it. You can change the color of the image by changing `background` and if you want to change text styling you can adapt SVG to your needs. | 94 | That is about it. Nothing more to it. You can change the color of the image by |
| 95 | changing `background` and if you want to change text styling you can adapt | ||
| 96 | SVG to your needs. | ||
| 97 | |||
| 98 | > Also be careful about the length of the text. This function positions text | ||
| 99 | > at the center and adds `20px` padding on all sides. If text is longer than | ||
| 100 | > the image it will get cut. | ||
| 82 | 101 | ||
| 83 | > Also be careful about the length of the text. This function positions text at the center and adds `20px` padding on all sides. If text is longer than the image it will get cut. | ||
diff --git a/content/posts/2020-03-29-the-strange-case-of-elasticsearch-allocation-failure.md b/content/posts/2020-03-29-the-strange-case-of-elasticsearch-allocation-failure.md index a976a7e..d0f4bac 100644 --- a/content/posts/2020-03-29-the-strange-case-of-elasticsearch-allocation-failure.md +++ b/content/posts/2020-03-29-the-strange-case-of-elasticsearch-allocation-failure.md | |||
| @@ -1,19 +1,37 @@ | |||
| 1 | --- | 1 | --- |
| 2 | title: The strange case of Elasticsearch allocation failure | 2 | title: The strange case of Elasticsearch allocation failure |
| 3 | url: the-strange-case-of-elasticsearch-allocation-failure.html | 3 | url: the-strange-case-of-elasticsearch-allocation-failure.html |
| 4 | date: 2020-03-29 | 4 | date: 2020-03-29T12:00:00+02:00 |
| 5 | draft: false | 5 | draft: false |
| 6 | --- | 6 | --- |
| 7 | 7 | ||
| 8 | I've been using Elasticsearch in production for 5 years now and never had a single problem with it. Hell, never even known there could be a problem. Just worked. All this time. The first node that I deployed is still being used in production, never updated, upgraded, touched in anyway. | 8 | I've been using Elasticsearch in production for 5 years now and never had a |
| 9 | 9 | single problem with it. Hell, never even known there could be a problem. Just | |
| 10 | All this bliss came to an abrupt end this Friday when I got notification that Elasticsearch cluster went warm. Well, warm is not that bad right? Wrong! Quickly after that I got another email which sent chills down my spine. Cluster is now red. RED! Now, shit really hit the fan! | 10 | worked. All this time. The first node that I deployed is still being used in |
| 11 | 11 | production, never updated, upgraded, touched in anyway. | |
| 12 | I tried googling what could be the problem and after executing allocation function noticed that some shards were unassigned and 5 attempts were already made (which is BTW to my luck the maximum) and that meant I am basically fucked. They also applied that one should wait for cluster to re-balance itself. So, I waited. One hour, two hours, several hours. Nothing, still RED. | 12 | |
| 13 | 13 | All this bliss came to an abrupt end this Friday when I got notification that | |
| 14 | The strangest thing about it all was, that queries were still being fulfilled. Data was coming out. On the outside it looked like nothing was wrong but everybody that would look at the cluster would know immediately that something was very very wrong and we were living on borrowed time here. | 14 | Elasticsearch cluster went warm. Well, warm is not that bad right? Wrong! |
| 15 | 15 | Quickly after that I got another email which sent chills down my spine. | |
| 16 | > **Please, DO NOT do what I did.** Seriously! Please ask someone on official forums or if you know an expert please consult him. There could be million of reasons and these solution fit my problem. Maybe in your case it would disastrous. I had all the data backed up and even if I would fail spectacularly I would be able to restore the data. It would be a huge pain and I would loose couple of days but I had a plan B. | 16 | Cluster is now red. RED! Now, shit really hit the fan! |
| 17 | |||
| 18 | I tried googling what could be the problem and after executing allocation | ||
| 19 | function noticed that some shards were unassigned and 5 attempts were already | ||
| 20 | made (which is BTW to my luck the maximum) and that meant I am basically fucked. | ||
| 21 | They also applied that one should wait for cluster to re-balance itself. So, | ||
| 22 | I waited. One hour, two hours, several hours. Nothing, still RED. | ||
| 23 | |||
| 24 | The strangest thing about it all was, that queries were still being fulfilled. | ||
| 25 | Data was coming out. On the outside it looked like nothing was wrong but | ||
| 26 | everybody that would look at the cluster would know immediately that something | ||
| 27 | was very very wrong and we were living on borrowed time here. | ||
| 28 | |||
| 29 | > **Please, DO NOT do what I did.** Seriously! Please ask someone on official | ||
| 30 | forums or if you know an expert please consult him. There could be million of | ||
| 31 | reasons and these solution fit my problem. Maybe in your case it would | ||
| 32 | disastrous. I had all the data backed up and even if I would fail spectacularly | ||
| 33 | I would be able to restore the data. It would be a huge pain and I would | ||
| 34 | loose couple of days but I had a plan B. | ||
| 17 | 35 | ||
| 18 | Executing allocation and told me what the problem was but no clear solution yet. | 36 | Executing allocation and told me what the problem was but no clear solution yet. |
| 19 | 37 | ||
| @@ -21,9 +39,14 @@ Executing allocation and told me what the problem was but no clear solution yet. | |||
| 21 | GET /_cat/allocation?format=json | 39 | GET /_cat/allocation?format=json |
| 22 | ``` | 40 | ``` |
| 23 | 41 | ||
| 24 | I got a message that `ALLOCATION_FAILED` with additional info `failed to create shard, failure ioexception[failed to obtain in-memory shard lock]`. Well splendid! I must also say that our cluster is capable more than enough to handle the traffic. Also JVM memory pressure never was an issue. So what happened really then? | 42 | I got a message that `ALLOCATION_FAILED` with additional info |
| 43 | `failed to create shard, failure ioexception[failed to obtain in-memory shard lock]`. | ||
| 44 | Well splendid! I must also say that our cluster is capable more than enough | ||
| 45 | to handle the traffic. Also JVM memory pressure never was an issue. So what | ||
| 46 | happened really then? | ||
| 25 | 47 | ||
| 26 | I tried also re-routing failed ones with no success due to AWS restrictions on having managed Elasticsearch cluster (they lock some of the functions). | 48 | I tried also re-routing failed ones with no success due to AWS restrictions |
| 49 | on having managed Elasticsearch cluster (they lock some of the functions). | ||
| 27 | 50 | ||
| 28 | ```yaml | 51 | ```yaml |
| 29 | POST /_cluster/reroute?retry_failed=true | 52 | POST /_cluster/reroute?retry_failed=true |
| @@ -37,7 +60,10 @@ I got a message that significantly reduced my options. | |||
| 37 | } | 60 | } |
| 38 | ``` | 61 | ``` |
| 39 | 62 | ||
| 40 | After that I went on a hunt again. I won't bother you with all the details because hours/days went by until I was finally able to re-index the problematic index and hoped for the best. Until that moment even re-indexing was giving me errors. | 63 | After that I went on a hunt again. I won't bother you with all the details |
| 64 | because hours/days went by until I was finally able to re-index the problematic | ||
| 65 | index and hoped for the best. Until that moment even re-indexing was giving | ||
| 66 | me errors. | ||
| 41 | 67 | ||
| 42 | ```yaml | 68 | ```yaml |
| 43 | POST _reindex | 69 | POST _reindex |
| @@ -51,7 +77,8 @@ POST _reindex | |||
| 51 | } | 77 | } |
| 52 | ``` | 78 | ``` |
| 53 | 79 | ||
| 54 | I needed to do this multiple times to get all the documents re-indexed. Then I dropped the original one with the following command. | 80 | I needed to do this multiple times to get all the documents re-indexed. Then |
| 81 | I dropped the original one with the following command. | ||
| 55 | 82 | ||
| 56 | ```yaml | 83 | ```yaml |
| 57 | DELETE /myindex | 84 | DELETE /myindex |
| @@ -71,6 +98,10 @@ POST _reindex | |||
| 71 | } | 98 | } |
| 72 | ``` | 99 | ``` |
| 73 | 100 | ||
| 74 | On the surface it looks like all is working but I have a long road in front of me to get all the things working again. Cluster now shows that it is in Green mode but I am also getting a notification that the cluster has processing status which could mean million of things. | 101 | On the surface it looks like all is working but I have a long road in front |
| 102 | of me to get all the things working again. Cluster now shows that it is in | ||
| 103 | Green mode but I am also getting a notification that the cluster has | ||
| 104 | processing status which could mean million of things. | ||
| 75 | 105 | ||
| 76 | Godspeed! | 106 | Godspeed! |
| 107 | |||
diff --git a/content/posts/2020-03-30-my-love-and-hate-relationship-with-nodejs.md b/content/posts/2020-03-30-my-love-and-hate-relationship-with-nodejs.md index 2b8b35b..47b95d5 100644 --- a/content/posts/2020-03-30-my-love-and-hate-relationship-with-nodejs.md +++ b/content/posts/2020-03-30-my-love-and-hate-relationship-with-nodejs.md | |||
| @@ -1,41 +1,112 @@ | |||
| 1 | --- | 1 | --- |
| 2 | title: My love and hate relationship with Node.js | 2 | title: My love and hate relationship with Node.js |
| 3 | url: my-love-and-hate-relationship-with-nodejs.html | 3 | url: my-love-and-hate-relationship-with-nodejs.html |
| 4 | date: 2020-03-30 | 4 | date: 2020-03-30T12:00:00+02:00 |
| 5 | draft: false | 5 | draft: false |
| 6 | --- | 6 | --- |
| 7 | 7 | ||
| 8 | Previous project I was working on was being coded in [Golang](https://golang.org/). Also was my first project using it. And damn, that was an awesome experience. The whole thing is just superb. From how errors are handled. The C-like way you handle compiling. The way the language is structured making it incredibly versatile and easy to learn. | 8 | Previous project I was working on was being coded in [Golang](https://golang.org/). |
| 9 | Also was my first project using it. And damn, that was an awesome experience. | ||
| 10 | The whole thing is just superb. From how errors are handled. The C-like way | ||
| 11 | you handle compiling. The way the language is structured making it incredibly | ||
| 12 | versatile and easy to learn. | ||
| 9 | 13 | ||
| 10 | It may cause some pain for somebody that is not used of using interfaces to map JSON and doing the recompilation all the time. But we have tools like [entr](http://eradman.com/entrproject/) and [make](https://www.gnu.org/software/make/) to fix that. | 14 | It may cause some pain for somebody that is not used of using interfaces to map |
| 15 | JSON and doing the recompilation all the time. But we have tools like | ||
| 16 | [entr](http://eradman.com/entrproject/) and [make](https://www.gnu.org/software/make/) | ||
| 17 | to fix that. | ||
| 11 | 18 | ||
| 12 | But we are not here to talk about my undying love for **Golang**. Only in some way we probably should. It is an excellent example of how modern language should be designed. And because I have used it extensively in the last couple of years this probably taints my views of other languages. And is doing me a great disservice. Nevertheless, here we are. | 19 | But we are not here to talk about my undying love for **Golang**. Only in some |
| 20 | way we probably should. It is an excellent example of how modern language | ||
| 21 | should be designed. And because I have used it extensively in the last couple | ||
| 22 | of years this probably taints my views of other languages. And is doing me a | ||
| 23 | great disservice. Nevertheless, here we are. | ||
| 13 | 24 | ||
| 14 | About two years ago I started flirting with [Node.js](https://nodejs.org/en/) for a project I started working on. What I wanted was to have things written in a language that is widely used, and we could get additional developers for. As much as **Golang** is amazing it's really hard to get developers for it. Even now. And after playing around with it for a week I felt in love with the speed of iteration and massive package ecosystem. Do you want SSO? You got it! Do you want some esoteric library for something? There is a strong chance somebody wrote it. It is so extensive that you find yourself evaluating packages based on **GitHub stars** and number of contributors. You get swallowed by the vanity metrics and that potentially will become the downfall of Node.js. | 25 | About two years ago I started flirting with [Node.js](https://nodejs.org/en/) |
| 26 | for a project I started working on. What I wanted was to have things written | ||
| 27 | in a language that is widely used, and we could get additional developers for. | ||
| 28 | As much as **Golang** is amazing it's really hard to get developers for it. | ||
| 29 | Even now. And after playing around with it for a week I felt in love with the | ||
| 30 | speed of iteration and massive package ecosystem. Do you want SSO? You got it! | ||
| 31 | Do you want some esoteric library for something? There is a strong chance | ||
| 32 | somebody wrote it. It is so extensive that you find yourself evaluating | ||
| 33 | packages based on **GitHub stars** and number of contributors. You get | ||
| 34 | swallowed by the vanity metrics and that potentially will become the downfall | ||
| 35 | of Node.js. | ||
| 15 | 36 | ||
| 16 | Because of the sheer amount of choice I often got anxiety when choosing libraries. Will I choose the correct one? Is this library something that will be supported for a foreseeable future or not? I am used of using libraries that are being in development for 10 years plus (Python, C) and that gave me some sort of comfort. And it is probably unfair to Node.js and community to expect same dedication. | 37 | Because of the sheer amount of choice I often got anxiety when choosing |
| 38 | libraries. Will I choose the correct one? Is this library something that will | ||
| 39 | be supported for a foreseeable future or not? I am used of using libraries that | ||
| 40 | are being in development for 10 years plus (Python, C) and that gave me some | ||
| 41 | sort of comfort. And it is probably unfair to Node.js and community to expect | ||
| 42 | same dedication. | ||
| 17 | 43 | ||
| 18 | Moving forward ... Work started and things were great. **Speed of iteration was insane**. For some feature that I would need a day in Golang only took me hour or two. I became lazy! Using packages all over the place. Falling into the same trap as others. Packages on top of packages. And [npm](https://www.npmjs.com/) didn't help at all. The way that the package manager works is just horrendous. And not allowing to have node_modules outside the project is also the stupidest idea ever. | 44 | Moving forward ... Work started and things were great. |
| 45 | **Speed of iteration was insane**. For some feature that I would need a day | ||
| 46 | in Golang only took me hour or two. I became lazy! Using packages all over | ||
| 47 | the place. Falling into the same trap as others. Packages on top of packages. | ||
| 48 | And [npm](https://www.npmjs.com/) didn't help at all. The way that the package | ||
| 49 | manager works is just horrendous. And not allowing to have node_modules outside | ||
| 50 | the project is also the stupidest idea ever. | ||
| 19 | 51 | ||
| 20 | So at that point I started feeling the technical debt that comes with Node.js and the whole ecosystem. What nobody tells you is that **structuring large Node.js apps** is more problematic than one would think. And going microservice for every single thing is also a bad idea. The amount of networking you introduce with that approach always ends up being a pain in the ass. And I don't even want to go into system administration here. The overhead is insane. Package-lock.json made many days feel like living hell for me. And I would eat the cost of all this if it meant for better development experience. Well, it didn't. | 52 | So at that point I started feeling the technical debt that comes with Node.js |
| 53 | and the whole ecosystem. What nobody tells you is that | ||
| 54 | **structuring large Node.js apps** is more problematic than one would think. | ||
| 55 | And going microservice for every single thing is also a bad idea. The amount | ||
| 56 | of networking you introduce with that approach always ends up being a pain in | ||
| 57 | the ass. And I don't even want to go into system administration here. The | ||
| 58 | overhead is insane. Package-lock.json made many days feel like living hell | ||
| 59 | for me. And I would eat the cost of all this if it meant for better development | ||
| 60 | experience. Well, it didn't. | ||
| 21 | 61 | ||
| 22 | The **lack of Typescript** support in the interpreter is still mind boggling to me. Why haven't they added native support yet for this is beyond me?! That would have solved so many problems. Lack of type safety became a problem somewhere in the middle of the project where the codebase was sufficiently large enough to present problems. We started adding arguments to functions and there was **no way to implicitly define argument types**. And because at that point there were a lot of functions, it became impossible to know what each one accepts, development became more and more trial and error based. | 62 | The **lack of Typescript** support in the interpreter is still mind boggling |
| 63 | to me. Why haven't they added native support yet for this is beyond me?! That | ||
| 64 | would have solved so many problems. Lack of type safety became a problem | ||
| 65 | somewhere in the middle of the project where the codebase was sufficiently | ||
| 66 | large enough to present problems. We started adding arguments to functions | ||
| 67 | and there was **no way to implicitly define argument types**. And because at | ||
| 68 | that point there were a lot of functions, it became impossible to know what | ||
| 69 | each one accepts, development became more and more trial and error based. | ||
| 23 | 70 | ||
| 24 | I tried **implementing Typescript**, but that would present a large refactor that we were not willing to do at that point. The benefits were not enough. I also tried [Flow - static type checker](https://flow.org/) but implementation was also horrible. What Typescript and Flow forces you is to have src folder and then **transpile** your code into dist folder and run it with node. WTH is that all about. Why can't this be done in memory or some virtual file system? Why? I see no reason why this couldn't be done like this. But it is what it is. I abandoned all hope for static type checking. | 71 | I tried **implementing Typescript**, but that would present a large refactor |
| 72 | that we were not willing to do at that point. The benefits were not enough. | ||
| 73 | I also tried [Flow - static type checker](https://flow.org/) but implementation | ||
| 74 | was also horrible. What Typescript and Flow forces you is to have src folder | ||
| 75 | and then **transpile** your code into dist folder and run it with node. WTH is | ||
| 76 | that all about. Why can't this be done in memory or some virtual file system? | ||
| 77 | Why? I see no reason why this couldn't be done like this. But it is what it is. | ||
| 78 | I abandoned all hope for static type checking. | ||
| 25 | 79 | ||
| 26 | One of the problems that resulted from not having interfaces or types was inability to model out our data from **Elasticsearch**. I could have done a **pedestrian implementation** of it, but there must be a better way of doing this without resorting to some hack basically. Or maybe I haven't found a solution, which is also a possibility. I have looked, though. No juice! | 80 | One of the problems that resulted from not having interfaces or types was |
| 81 | inability to model out our data from **Elasticsearch**. I could have done | ||
| 82 | a **pedestrian implementation** of it, but there must be a better way of doing | ||
| 83 | this without resorting to some hack basically. Or maybe I haven't found a | ||
| 84 | solution, which is also a possibility. I have looked, though. No juice! | ||
| 27 | 85 | ||
| 28 | **Error handling?** Is that a joke? | 86 | **Error handling?** Is that a joke? |
| 29 | 87 | ||
| 30 | Thank god for **await/async**. Without it, I would have probably just abandoned the whole thing and went with something else like Python. That's all I am going to say about this :) | 88 | Thank god for **await/async**. Without it, I would have probably just abandoned |
| 89 | the whole thing and went with something else like Python. That's all I am | ||
| 90 | going to say about this :) | ||
| 91 | |||
| 92 | I started asking myself a question if Node.js is actually ready to be used in | ||
| 93 | a **large scale applications**? And this was a totally wrong question. What I | ||
| 94 | should have been asking myself was, how to use Node.js in large scale | ||
| 95 | application. And you don't get this in **marketing material** for Express or | ||
| 96 | Koa etc. They never tell you this. Making Node.js scale on infrastructure or | ||
| 97 | in codebase is really **more of an art than a science**. And just like with the | ||
| 98 | whole JavaScript ecosystem: | ||
| 31 | 99 | ||
| 32 | I started asking myself a question if Node.js is actually ready to be used in a **large scale applications**? And this was a totally wrong question. What I should have been asking myself was, how to use Node.js in large scale application. And you don't get this in **marketing material** for Express or Koa etc. They never tell you this. Making Node.js scale on infrastructure or in codebase is really **more of an art than a science**. And just like with the whole JavaScript ecosystem: | ||
| 33 | - impossible to master, | 100 | - impossible to master, |
| 34 | - half of your time you work on your tooling, | 101 | - half of your time you work on your tooling, |
| 35 | - just accept transpilers that convert one code into another (holly smokes), | 102 | - just accept transpilers that convert one code into another (holly smokes), |
| 36 | - error handling is a joke, | 103 | - error handling is a joke, |
| 37 | - standards? What standards? | 104 | - standards? What standards? |
| 38 | 105 | ||
| 39 | But on the other hand. As I did, you will also learn to love it. Learn to use it quickly and do impossible things in crazy limited time. | 106 | But on the other hand. As I did, you will also learn to love it. Learn to use |
| 107 | it quickly and do impossible things in crazy limited time. | ||
| 40 | 108 | ||
| 41 | I hate to admit it. But I love Node.js. Dammit, I love it :) | 109 | I hate to admit it. But I love Node.js. Dammit, I love it :) |
| 110 | |||
| 111 | 2023 Update: I hate Node.js! | ||
| 112 | |||
diff --git a/content/posts/2020-05-05-remote-work.md b/content/posts/2020-05-05-remote-work.md index d4b5cbe..54a7d1b 100644 --- a/content/posts/2020-05-05-remote-work.md +++ b/content/posts/2020-05-05-remote-work.md | |||
| @@ -1,37 +1,70 @@ | |||
| 1 | --- | 1 | --- |
| 2 | title: Remote work and how it affects the daily lives of people | 2 | title: Remote work and how it affects the daily lives of people |
| 3 | url: remote-work.html | 3 | url: remote-work.html |
| 4 | date: 2020-05-05 | 4 | date: 2020-05-05T12:00:00+02:00 |
| 5 | draft: false | 5 | draft: false |
| 6 | --- | 6 | --- |
| 7 | 7 | ||
| 8 | I have been working remotely for the past 5 years. I love it. Love the freedom and make your schedule thingy. | 8 | I have been working remotely for the past 5 years. I love it. Love the freedom |
| 9 | and make your schedule thingy. | ||
| 9 | 10 | ||
| 10 | ## You work more not less | 11 | ## You work more not less |
| 11 | 12 | ||
| 12 | I've heard from people things like: "Oh, you are so lucky, working from home, having all the free time you want". It was obvious they had no clue what means working remotely. They had this romantic idea of remote work. You can watch TV whenever you like, you can go outside for a picnic if you want and stuff like that. | 13 | I've heard from people things like: "Oh, you are so lucky, working from home, |
| 14 | having all the free time you want". It was obvious they had no clue what means | ||
| 15 | working remotely. They had this romantic idea of remote work. You can watch TV | ||
| 16 | whenever you like, you can go outside for a picnic if you want and stuff like | ||
| 17 | that. | ||
| 13 | 18 | ||
| 14 | This may be true if you work a day or two in a week from home. But if you go completely remote all these changes completely. I take some time to acclimate but then you start feeling the consequences of going fully remote. And it's not all rainbows and unicorns. Rather the opposite. | 19 | This may be true if you work a day or two in a week from home. But if you go |
| 20 | completely remote all these changes completely. I take some time to acclimate | ||
| 21 | but then you start feeling the consequences of going fully remote. And it's not | ||
| 22 | all rainbows and unicorns. Rather the opposite. | ||
| 15 | 23 | ||
| 16 | ## Feeling lost | 24 | ## Feeling lost |
| 17 | 25 | ||
| 18 | At first, I remembered I felt lost. I was not used to this kind of environment. It felt disoriented and a part of you that is used to procrastinate turns on. You start thinking of a workday as a whole day. And soon this idea of "I can do this later" starts creeping in. Well, I have the whole day ahead of me. I can do this a bit later. | 26 | At first, I remembered I felt lost. I was not used to this kind of environment. |
| 27 | It felt disoriented and a part of you that is used to procrastinate turns on. | ||
| 28 | You start thinking of a workday as a whole day. And soon this idea of "I can do | ||
| 29 | this later" starts creeping in. Well, I have the whole day ahead of me. I can | ||
| 30 | do this a bit later. | ||
| 19 | 31 | ||
| 20 | ## Hyper-performance | 32 | ## Hyper-performance |
| 21 | 33 | ||
| 22 | As a direct result, you become more focused on your work since you don't have all the interruptions common in the workplace. And you can quickly get used to this hyper-performance. But this mode requires also a lot of peace and quiet. | 34 | As a direct result, you become more focused on your work since you don't have |
| 35 | all the interruptions common in the workplace. And you can quickly get used to | ||
| 36 | this hyper-performance. But this mode requires also a lot of peace and quiet. | ||
| 23 | 37 | ||
| 24 | And here we come to the ugly parts of all this. **People rarely have the self-control** to not waste other people's time. It is paralyzing when people start calling you, sending you chat messages, etc. The thing is, that when I achieve this hyper-performance mode I am completely embroiled in the problem I am solving and this kind of interruptions mess with your head. I need an hour at least to get back in the zone. Sometimes not achieving the same focus the whole day. | 38 | And here we come to the ugly parts of all this. **People rarely have the self-control** |
| 39 | to not waste other people's time. It is paralyzing when people start calling | ||
| 40 | you, sending you chat messages, etc. The thing is, that when I achieve this | ||
| 41 | hyper-performance mode I am completely embroiled in the problem I am solving | ||
| 42 | and this kind of interruptions mess with your head. I need an hour at least to | ||
| 43 | get back in the zone. Sometimes not achieving the same focus the whole day. | ||
| 25 | 44 | ||
| 26 | I know that life is not how you want it to be and takes its route but from what I've learned this kind of interruptions can be avoided in 90% of the case easily just by closing any chat programs and putting your phone in a drawer. | 45 | I know that life is not how you want it to be and takes its route but from what |
| 46 | I've learned this kind of interruptions can be avoided in 90% of the case | ||
| 47 | easily just by closing any chat programs and putting your phone in a drawer. | ||
| 27 | 48 | ||
| 28 | ## Suggestion to all the new remote workers | 49 | ## Suggestion to all the new remote workers |
| 29 | 50 | ||
| 30 | - Stop wasting other people's time. You don't bother people at their desks in the office either. | 51 | - Stop wasting other people's time. You don't bother people at their desks |
| 31 | - Do not replace daily chats in the hallways with instant messaging software. It will only interrupt people. Nothing good will come of it. | 52 | in the office either. |
| 32 | - Set your working hours and try to not allow it to bleed outside these boundaries and maintain your routine. | 53 | - Do not replace daily chats in the hallways with instant messaging software. |
| 33 | - Be prepared that hours will be longer regardless of your good intentions and your well thought of routine. | 54 | It will only interrupt people. Nothing good will come of it. |
| 34 | - Try to be hyper-focused and do only one thing at the time. Multitasking is the enemy of progress. | 55 | - Set your working hours and try to not allow it to bleed outside these |
| 35 | - Avoid long meetings and if possible eliminate them. Rather take time to write them out and allow others to respond in their own time. Meetings are usually a large waste of time and most of the people attending them are there just because the manager said so. | 56 | boundaries and maintain your routine. |
| 57 | - Be prepared that hours will be longer regardless of your good intentions | ||
| 58 | and your well thought of routine. | ||
| 59 | - Try to be hyper-focused and do only one thing at the time. Multitasking is | ||
| 60 | the enemy of progress. | ||
| 61 | - Avoid long meetings and if possible eliminate them. Rather take time to write | ||
| 62 | them out and allow others to respond in their own time. Meetings are usually a | ||
| 63 | large waste of time and most of the people attending them are there just | ||
| 64 | because the manager said so. | ||
| 36 | - The software will not solve your problems. And throwing money at problems neither. | 65 | - The software will not solve your problems. And throwing money at problems neither. |
| 37 | - If you are in a managerial position don't supervise any single minute of workers. They are probably giving you more hours anyways. Track progress weekly not daily. You hired them and give them the benefit of the doubt that they will deliver what you agreed upon. | 66 | - If you are in a managerial position don't supervise any single minute of |
| 67 | workers. They are probably giving you more hours anyways. Track progress | ||
| 68 | weekly not daily. You hired them and give them the benefit of the doubt that | ||
| 69 | they will deliver what you agreed upon. | ||
| 70 | |||
diff --git a/content/posts/2020-08-15-systemd-disable-wake-onmouse.md b/content/posts/2020-08-15-systemd-disable-wake-onmouse.md index 09e5036..fabdc32 100644 --- a/content/posts/2020-08-15-systemd-disable-wake-onmouse.md +++ b/content/posts/2020-08-15-systemd-disable-wake-onmouse.md | |||
| @@ -1,23 +1,43 @@ | |||
| 1 | --- | 1 | --- |
| 2 | title: Disable mouse wake from suspend with systemd service | 2 | title: Disable mouse wake from suspend with systemd service |
| 3 | url: disable-mouse-wake-from-suspend-with-systemd-service.html | 3 | url: disable-mouse-wake-from-suspend-with-systemd-service.html |
| 4 | date: 2020-08-15 | 4 | date: 2020-08-15T12:00:00+02:00 |
| 5 | draft: false | 5 | draft: false |
| 6 | --- | 6 | --- |
| 7 | 7 | ||
| 8 | I recently bought [ThinkPad X220](https://www.laptopmag.com/reviews/laptops/lenovo-thinkpad-x220) just as a joke on eBay to test Linux distributions and play around with things and not destroy my main machine. Little to my knowledge I felt in love with it. Man, they really made awesome machines back then. | 8 | I recently bought [ThinkPad X220](https://www.laptopmag.com/reviews/laptops/lenovo-thinkpad-x220) |
| 9 | just as a joke on eBay to test Linux distributions and play around with things | ||
| 10 | and not destroy my main machine. Little to my knowledge I felt in love with it. | ||
| 11 | Man, they really made awesome machines back then. | ||
| 9 | 12 | ||
| 10 | After changing disk that came with it to SSD and installing Ubuntu to test if everything works I noticed that even after a single touch of my external mouse the system would wake up from sleep even though the lid was shut down. | 13 | After changing disk that came with it to SSD and installing Ubuntu to test if |
| 14 | everything works I noticed that even after a single touch of my external mouse | ||
| 15 | the system would wake up from sleep even though the lid was shut down. | ||
| 11 | 16 | ||
| 12 | I wouldn't even noticed it if laptop didn't have [LED sleep indicator](https://support.lenovo.com/lk/en/solutions/~/media/Images/ContentImages/p/pd025386_x1_status_03.ashx?w=426&h=262). I already had a bad experience with Linux and it's power management. I had a [Dell Inspiron 7537](https://www.pcmag.com/reviews/dell-inspiron-15-7537) laptop with a touchscreen and while traveling it decided to wake up and started cooking in my backpack to the point that the digitizer responsible for touch actually glue off and the whole screen got wrecked. So, I am a bit touchy about this. | 17 | I wouldn't even noticed it if laptop didn't have |
| 18 | [LED sleep indicator](https://support.lenovo.com/lk/en/solutions/~/media/Images/ContentImages/p/pd025386_x1_status_03.ashx?w=426&h=262). | ||
| 19 | I already had a bad experience with Linux and it's power management. I had a | ||
| 20 | [Dell Inspiron 7537](https://www.pcmag.com/reviews/dell-inspiron-15-7537) laptop | ||
| 21 | with a touchscreen and while traveling it decided to wake up and started cooking | ||
| 22 | in my backpack to the point that the digitizer responsible for touch actually | ||
| 23 | glue off and the whole screen got wrecked. So, I am a bit touchy about this. | ||
| 13 | 24 | ||
| 14 | I went on solution hunting and to my surprise there is no easy way to disable specific devices to perform wake up. Why is this not under the power management tab in setting is really strange. | 25 | I went on solution hunting and to my surprise there is no easy way to disable |
| 26 | specific devices to perform wake up. Why is this not under the power management | ||
| 27 | tab in setting is really strange. | ||
| 15 | 28 | ||
| 16 | After googling for a solution I found [this nice article describing the solution](https://codetrips.com/2020/03/18/ubuntu-disable-mouse-wake-from-suspend/) that worked for me. The only problem with this solution was that he added his solution to `.bashrc` and this triggers `sudo` that asks for a password each time new terminal is opened, which get annoying quickly since I open a lot of terminals all the time. | 29 | After googling for a solution I found [this nice article describing the solution](https://codetrips.com/2020/03/18/ubuntu-disable-mouse-wake-from-suspend/) |
| 30 | that worked for me. The only problem with this solution was that he added his | ||
| 31 | solution to `.bashrc` and this triggers `sudo` that asks for a password each | ||
| 32 | time new terminal is opened, which get annoying quickly since I open a lot of | ||
| 33 | terminals all the time. | ||
| 17 | 34 | ||
| 18 | I followed his instructions and got to solution `sudo sh -c "echo 'disabled' > /sys/bus/usb/devices/2-1.1/power/wakeup"`. | 35 | I followed his instructions and got to solution |
| 36 | `sudo sh -c "echo 'disabled' > /sys/bus/usb/devices/2-1.1/power/wakeup"`. | ||
| 19 | 37 | ||
| 20 | I created a system service file `sudo nano /etc/systemd/system/disable-mouse-wakeup.service` and removed `sudo` and replaced `sh` with `/usr/bin/sh` and pasted all that in `ExecStart`. | 38 | I created a system service file `sudo nano /etc/systemd/system/disable-mouse-wakeup.service` |
| 39 | and removed `sudo` and replaced `sh` with `/usr/bin/sh` and pasted all that | ||
| 40 | in `ExecStart`. | ||
| 21 | 41 | ||
| 22 | ```ini | 42 | ```ini |
| 23 | [Unit] | 43 | [Unit] |
| @@ -44,4 +64,8 @@ sudo systemctl start disable-mouse-wakeup.service | |||
| 44 | sudo systemctl status disable-mouse-wakeup.service | 64 | sudo systemctl status disable-mouse-wakeup.service |
| 45 | ``` | 65 | ``` |
| 46 | 66 | ||
| 47 | This will permanently disable that device from wakeing up you computer on boot. If you have many devices you would like to surpress from waking up your machine I would create a shell script and call that instead of direclty doing it in service file. | 67 | This will permanently disable that device from wakeing up you computer on boot. |
| 68 | If you have many devices you would like to surpress from waking up your machine | ||
| 69 | I would create a shell script and call that instead of direclty doing it in | ||
| 70 | service file. | ||
| 71 | |||
diff --git a/content/posts/2020-09-06-esp-and-micropython.md b/content/posts/2020-09-06-esp-and-micropython.md index 481be0a..ac79a6d 100644 --- a/content/posts/2020-09-06-esp-and-micropython.md +++ b/content/posts/2020-09-06-esp-and-micropython.md | |||
| @@ -1,34 +1,45 @@ | |||
| 1 | --- | 1 | --- |
| 2 | title: Getting started with MicroPython and ESP8266 | 2 | title: Getting started with MicroPython and ESP8266 |
| 3 | url: esp8266-and-micropython-guide.html | 3 | url: esp8266-and-micropython-guide.html |
| 4 | date: 2020-09-06 | 4 | date: 2020-09-06T12:00:00+02:00 |
| 5 | draft: false | 5 | draft: false |
| 6 | --- | 6 | --- |
| 7 | 7 | ||
| 8 | ## Introduction | 8 | ## Introduction |
| 9 | 9 | ||
| 10 | A while ago I bought some [ESP8266](https://www.espressif.com/en/products/socs/esp8266) and [ESP32](https://www.espressif.com/en/products/socs/esp32) dev boards to play around with and I finally found a project to try it out. | 10 | A while ago I bought some [ESP8266](https://www.espressif.com/en/products/socs/esp8266) |
| 11 | and [ESP32](https://www.espressif.com/en/products/socs/esp32) dev boards to | ||
| 12 | play around with and I finally found a project to try it out. | ||
| 11 | 13 | ||
| 12 | For my project, I used [ESP32](https://www.espressif.com/en/products/socs/esp32) but I could easily choose [ESP8266](https://www.espressif.com/en/products/socs/esp8266). This guide contains which tools I use and how I prepared my workspace to code for [ESP8266](https://www.espressif.com/en/products/socs/esp8266). | 14 | For my project, I used [ESP32](https://www.espressif.com/en/products/socs/esp32) |
| 15 | but I could easily choose [ESP8266](https://www.espressif.com/en/products/socs/esp8266). | ||
| 16 | This guide contains which tools I use and how I prepared my workspace to code | ||
| 17 | for [ESP8266](https://www.espressif.com/en/products/socs/esp8266). | ||
| 13 | 18 | ||
| 14 |  | 19 |  |
| 15 | 20 | ||
| 16 | This guide covers: | 21 | This guide covers: |
| 22 | |||
| 17 | - flashing SOC | 23 | - flashing SOC |
| 18 | - install proper tooling | 24 | - install proper tooling |
| 19 | - deploying a simple script | 25 | - deploying a simple script |
| 20 | 26 | ||
| 21 | > Make sure that you are using **a good USB cable**. I had some problems with mine and once I replaced it everything started to work. | 27 | > Make sure that you are using **a good USB cable**. I had some problems with |
| 28 | mine and once I replaced it everything started to work. | ||
| 22 | 29 | ||
| 23 | ## Flashing the SOC | 30 | ## Flashing the SOC |
| 24 | 31 | ||
| 25 | Plug your ESP8266 to USB port and check if the device was recognized with executing `dmesg | grep ch341-uart`. | 32 | Plug your ESP8266 to USB port and check if the device was recognized with |
| 33 | executing `dmesg | grep ch341-uart`. | ||
| 26 | 34 | ||
| 27 | Then check if the device is available under `/dev/` by running `ls /dev/ttyUSB*`. | 35 | Then check if the device is available under `/dev/` by running `ls /dev/ttyUSB*`. |
| 28 | 36 | ||
| 29 | > **Linux users**: if a device is not available be sure you are in `dialout` group. You can check this by executing `groups $USER`. You can add a user to `dialout` group with `sudo adduser $USER dialout`. | 37 | > **Linux users**: if a device is not available be sure you are in `dialout` |
| 38 | > group. You can check this by executing `groups $USER`. You can add a user to | ||
| 39 | > `dialout` group with `sudo adduser $USER dialout`. | ||
| 30 | 40 | ||
| 31 | After these conditions are meet go to the navigate to [https://micropython.org/download/esp8266/](https://micropython.org/download/esp8266/) and download `esp8266-20200902-v1.13.bin`. | 41 | After these conditions are meet go to the navigate to [https://micropython.org/download/esp8266/](https://micropython.org/download/esp8266/) |
| 42 | and download `esp8266-20200902-v1.13.bin`. | ||
| 32 | 43 | ||
| 33 | ```sh | 44 | ```sh |
| 34 | mkdir esp8266-test | 45 | mkdir esp8266-test |
| @@ -37,7 +48,8 @@ cd esp8266-test | |||
| 37 | wget https://micropython.org/resources/firmware/esp8266-20200902-v1.13.bin | 48 | wget https://micropython.org/resources/firmware/esp8266-20200902-v1.13.bin |
| 38 | ``` | 49 | ``` |
| 39 | 50 | ||
| 40 | After obtaining firmware we will need some tooling to flash the firmware to the board. | 51 | After obtaining firmware we will need some tooling to flash the firmware to |
| 52 | the board. | ||
| 41 | 53 | ||
| 42 | ```sh | 54 | ```sh |
| 43 | sudo pip3 install esptool | 55 | sudo pip3 install esptool |
| @@ -45,7 +57,8 @@ sudo pip3 install esptool | |||
| 45 | 57 | ||
| 46 | You can read more about `esptool` at [https://github.com/espressif/esptool/](https://github.com/espressif/esptool/). | 58 | You can read more about `esptool` at [https://github.com/espressif/esptool/](https://github.com/espressif/esptool/). |
| 47 | 59 | ||
| 48 | Before flashing the firmware we need to erase the flash on device. Substitute `USB0` with the device listed in output of `ls /dev/ttyUSB*`. | 60 | Before flashing the firmware we need to erase the flash on device. Substitute |
| 61 | `USB0` with the device listed in output of `ls /dev/ttyUSB*`. | ||
| 49 | 62 | ||
| 50 | ```sh | 63 | ```sh |
| 51 | esptool.py --port /dev/ttyUSB0 erase_flash | 64 | esptool.py --port /dev/ttyUSB0 erase_flash |
| @@ -57,9 +70,11 @@ If flash was successfully erased it is now time to flash the new firmware to it. | |||
| 57 | esptool.py --port /dev/ttyUSB0 --baud 460800 write_flash --flash_size=detect 0 esp8266-20200902-v1.13.bin | 70 | esptool.py --port /dev/ttyUSB0 --baud 460800 write_flash --flash_size=detect 0 esp8266-20200902-v1.13.bin |
| 58 | ``` | 71 | ``` |
| 59 | 72 | ||
| 60 | If everything went ok you can try accessing MicroPython REPL with `screen /dev/ttyUSB0 115200` or `picocom /dev/ttyUSB0 -b115200`. | 73 | If everything went ok you can try accessing MicroPython REPL with ` |
| 74 | screen /dev/ttyUSB0 115200` or `picocom /dev/ttyUSB0 -b115200`. | ||
| 61 | 75 | ||
| 62 | > Sometimes you will need to press `ENTER` in `screen` or `picocom` to access REPL. | 76 | > Sometimes you will need to press `ENTER` in `screen` or `picocom` to access |
| 77 | > REPL. | ||
| 63 | 78 | ||
| 64 | When you are in REPL you can test if all is working properly following steps. | 79 | When you are in REPL you can test if all is working properly following steps. |
| 65 | 80 | ||
| @@ -68,7 +83,8 @@ When you are in REPL you can test if all is working properly following steps. | |||
| 68 | > machine.freq() | 83 | > machine.freq() |
| 69 | ``` | 84 | ``` |
| 70 | 85 | ||
| 71 | This should output a number representing a frequency of the CPU (mine was `80000000`). | 86 | This should output a number representing a frequency of the CPU (mine was |
| 87 | `80000000`). | ||
| 72 | 88 | ||
| 73 | When you are in `screen` or `picocom` these can help you a bit. | 89 | When you are in `screen` or `picocom` these can help you a bit. |
| 74 | 90 | ||
| @@ -81,7 +97,8 @@ When you are in `screen` or `picocom` these can help you a bit. | |||
| 81 | 97 | ||
| 82 | ## Install better tooling | 98 | ## Install better tooling |
| 83 | 99 | ||
| 84 | Now, to make our lives a little bit easier there are couple of additional tools that will make this whole experience a little more bearable. | 100 | Now, to make our lives a little bit easier there are couple of additional tools |
| 101 | that will make this whole experience a little more bearable. | ||
| 85 | 102 | ||
| 86 | There are twq cool ways of uploading local files to SOC flash. | 103 | There are twq cool ways of uploading local files to SOC flash. |
| 87 | 104 | ||
| @@ -113,7 +130,8 @@ ampy --delay 2 --port /dev/ttyUSB0 cat boot.py | |||
| 113 | 130 | ||
| 114 | ### rshell | 131 | ### rshell |
| 115 | 132 | ||
| 116 | Even though `ampy` is a cool tool I opted with `rshell` in the end since it's much more polished and feature rich. | 133 | Even though `ampy` is a cool tool I opted with `rshell` in the end since it's |
| 134 | much more polished and feature rich. | ||
| 117 | 135 | ||
| 118 | ```bash | 136 | ```bash |
| 119 | # installing ampy | 137 | # installing ampy |
| @@ -126,7 +144,9 @@ Now that `rshell` is installed we can connect to the board. | |||
| 126 | rshell --buffer-size=30 -p /dev/ttyUSB0 -a | 144 | rshell --buffer-size=30 -p /dev/ttyUSB0 -a |
| 127 | ``` | 145 | ``` |
| 128 | 146 | ||
| 129 | This will open a shell inside bash and from here you can execute multiple commands. You can check what is supported with `help` once you are inside of a shell. | 147 | This will open a shell inside bash and from here you can execute multiple |
| 148 | commands. You can check what is supported with `help` once you are inside of | ||
| 149 | a shell. | ||
| 130 | 150 | ||
| 131 | ```bash | 151 | ```bash |
| 132 | m@turing ~/Junk/esp8266-test | 152 | m@turing ~/Junk/esp8266-test |
| @@ -151,11 +171,14 @@ boards cd cp echo exit filetype ls repl rsync | |||
| 151 | Use Control-D (or the exit command) to exit rshell. | 171 | Use Control-D (or the exit command) to exit rshell. |
| 152 | ``` | 172 | ``` |
| 153 | 173 | ||
| 154 | > Inside a shell `ls` will display list of files on your machine. To get list of files on flash folder `/pyboard` is remapped inside the shell. To list files on flash you must perform `ls /pyboard`. | 174 | > Inside a shell `ls` will display list of files on your machine. To get list |
| 175 | > of files on flash folder `/pyboard` is remapped inside the shell. To list files | ||
| 176 | > on flash you must perform `ls /pyboard`. | ||
| 155 | 177 | ||
| 156 | #### Moving files to flash | 178 | #### Moving files to flash |
| 157 | 179 | ||
| 158 | To avoid copying files all the time I used `rsync` function from the inside of `rshell`. | 180 | To avoid copying files all the time I used `rsync` function from the |
| 181 | inside of `rshell`. | ||
| 159 | 182 | ||
| 160 | ```bash | 183 | ```bash |
| 161 | rsync . /pyboard | 184 | rsync . /pyboard |
| @@ -163,9 +186,11 @@ rsync . /pyboard | |||
| 163 | 186 | ||
| 164 | #### Executing scripts | 187 | #### Executing scripts |
| 165 | 188 | ||
| 166 | It is a pain to continuously reboot the device to trigger `/pyboard/boot.py` and there is a better way of testing local scripts on remote device. | 189 | It is a pain to continuously reboot the device to trigger `/pyboard/boot.py` |
| 190 | and there is a better way of testing local scripts on remote device. | ||
| 167 | 191 | ||
| 168 | Lets assume we have `src/freq.py` file that displays CPU frequency of a remote device. | 192 | Lets assume we have `src/freq.py` file that displays CPU frequency of a |
| 193 | remote device. | ||
| 169 | 194 | ||
| 170 | ```py | 195 | ```py |
| 171 | # src/freq.py | 196 | # src/freq.py |
| @@ -191,5 +216,6 @@ repl | |||
| 191 | 216 | ||
| 192 | ## Additional resources | 217 | ## Additional resources |
| 193 | 218 | ||
| 194 | - [https://randomnerdtutorials.com/getting-started-micropython-esp32-esp8266/](https://randomnerdtutorials.com/getting-started-micropython-esp32-esp8266/) | 219 | - https://randomnerdtutorials.com/getting-started-micropython-esp32-esp8266/ |
| 195 | - [http://docs.micropython.org/en/latest/esp8266/quickref.html](http://docs.micropython.org/en/latest/esp8266/quickref.html) | 220 | - http://docs.micropython.org/en/latest/esp8266/quickref.html |
| 221 | |||
diff --git a/content/posts/2020-09-08-bind-warning-on-login.md b/content/posts/2020-09-08-bind-warning-on-login.md index 62c421d..d5d725e 100644 --- a/content/posts/2020-09-08-bind-warning-on-login.md +++ b/content/posts/2020-09-08-bind-warning-on-login.md | |||
| @@ -1,15 +1,23 @@ | |||
| 1 | --- | 1 | --- |
| 2 | title: Fix bind warning in .profile on login in Ubuntu | 2 | title: Fix bind warning in .profile on login in Ubuntu |
| 3 | url: bind-warning-on-login-in-ubuntu.html | 3 | url: bind-warning-on-login-in-ubuntu.html |
| 4 | date: 2020-09-08 | 4 | date: 2020-09-08T12:00:00+02:00 |
| 5 | draft: false | 5 | draft: false |
| 6 | --- | 6 | --- |
| 7 | 7 | ||
| 8 | Recently I moved back to [bash](https://www.gnu.org/software/bash/) as my default shell. I was previously using [fish](https://fishshell.com/) and got used to the cool features it has. But, regardless of that, I wanted to move to a more standard shell because I was hopping back and forth with exporting variables and stuff like that which got pretty annoying. | 8 | Recently I moved back to [bash](https://www.gnu.org/software/bash/) as my |
| 9 | default shell. I was previously using [fish](https://fishshell.com/) and got | ||
| 10 | used to the cool features it has. But, regardless of that, I wanted to move to | ||
| 11 | a more standard shell because I was hopping back and forth with exporting | ||
| 12 | variables and stuff like that which got pretty annoying. | ||
| 9 | 13 | ||
| 10 | So I embarked on a mission to make [bash](https://www.gnu.org/software/bash/) more like [fish](https://fishshell.com/) and in the process found that I really missed autosuggest with TAB on changing directories. | 14 | So I embarked on a mission to make [bash](https://www.gnu.org/software/bash/) |
| 15 | more like [fish](https://fishshell.com/) and in the process found that I really | ||
| 16 | missed autosuggest with TAB on changing directories. | ||
| 11 | 17 | ||
| 12 | I found a nice alternative that emulates [zsh](http://zsh.sourceforge.net/) like autosuggestion and autocomplete so I added the following to my `.bashrc` file. | 18 | I found a nice alternative that emulates [zsh](http://zsh.sourceforge.net/) |
| 19 | like autosuggestion and autocomplete so I added the following to my `.bashrc` | ||
| 20 | file. | ||
| 13 | 21 | ||
| 14 | ```bash | 22 | ```bash |
| 15 | bind "TAB:menu-complete" | 23 | bind "TAB:menu-complete" |
| @@ -19,13 +27,18 @@ bind "set menu-complete-display-prefix on" | |||
| 19 | bind '"\e[Z":menu-complete-backward' | 27 | bind '"\e[Z":menu-complete-backward' |
| 20 | ``` | 28 | ``` |
| 21 | 29 | ||
| 22 | I haven't noticed anything wrong with this and all was working fine until I restarted my machine and then I got this error. | 30 | I haven't noticed anything wrong with this and all was working fine until I |
| 31 | restarted my machine and then I got this error. | ||
| 23 | 32 | ||
| 24 |  | 33 |  |
| 25 | 34 | ||
| 26 | When I pressed OK, I got into the [Gnome shell](https://wiki.gnome.org/Projects/GnomeShell) and all was working fine, but the error was still bugging me. I started looking for the reason why this is happening and found a solution to this error on [Remote SSH Commands - bash bind warning: line editing not enabled](https://superuser.com/a/892682). | 35 | When I pressed OK, I got into the [Gnome shell](https://wiki.gnome.org/Projects/GnomeShell) |
| 36 | and all was working fine, but the error was still bugging me. I started looking | ||
| 37 | for the reason why this is happening and found a solution to this error on | ||
| 38 | [Remote SSH Commands - bash bind warning: line editing not enabled](https://superuser.com/a/892682). | ||
| 27 | 39 | ||
| 28 | So I added a simple `if [ -t 1 ]` around `bind` statements to avoid running commands that presume the session is interactive when it isn't. | 40 | So I added a simple `if [ -t 1 ]` around `bind` statements to avoid running |
| 41 | commands that presume the session is interactive when it isn't. | ||
| 29 | 42 | ||
| 30 | ```bash | 43 | ```bash |
| 31 | if [ -t 1 ]; then | 44 | if [ -t 1 ]; then |
| @@ -38,3 +51,4 @@ fi | |||
| 38 | ``` | 51 | ``` |
| 39 | 52 | ||
| 40 | After logging out and back in the problem was gone. | 53 | After logging out and back in the problem was gone. |
| 54 | |||
diff --git a/content/posts/2020-09-09-digitalocean-sync.md b/content/posts/2020-09-09-digitalocean-sync.md index e7da657..2eeea2e 100644 --- a/content/posts/2020-09-09-digitalocean-sync.md +++ b/content/posts/2020-09-09-digitalocean-sync.md | |||
| @@ -1,43 +1,80 @@ | |||
| 1 | --- | 1 | --- |
| 2 | title: Using Digitalocean Spaces to sync between computers | 2 | title: Using Digitalocean Spaces to sync between computers |
| 3 | url: digitalocean-spaces-to-sync-between-computers.html | 3 | url: digitalocean-spaces-to-sync-between-computers.html |
| 4 | date: 2020-09-09 | 4 | date: 2020-09-09T12:00:00+02:00 |
| 5 | draft: false | 5 | draft: false |
| 6 | --- | 6 | --- |
| 7 | 7 | ||
| 8 | I've been using [Dropbox](https://www.dropbox.com/) for probably **10+ years** now and I-ve became so used to it that it runs in the background that I don't even imagine a world without it. But it's not without problems. | 8 | I've been using [Dropbox](https://www.dropbox.com/) for probably **10+ years** |
| 9 | 9 | now and I-ve became so used to it that it runs in the background that I don't | |
| 10 | At first I had problems with `.venv` environments for Python and the only solution for excluding synchronization for this folder was to manually exclude a specific folder which is not really scalable. FYI, my whole project folder is synced on [Dropbox](https://www.dropbox.com/). This of course introduced a lot of syncing of files and folders that are not needed or even break things on other machines. In the case of **Python**, I couldn't use that on my second machine. I needed to delete `.venv` folder and pip it again which synced files again to the main machine. This was very frustrating. **Nodejs** handles this much nicer and I can just run the scripts without deleting `node_modules` again and reinstalling. However, `node_modules` is a beast of its own. It creates so many files that OS has a problem counting them when you check the folder contents for size. | 10 | even imagine a world without it. But it's not without problems. |
| 11 | 11 | ||
| 12 | I wanted something similar to Dropbox. I could without the instant syncing but it would need to be fast and had the option for me to exclude folders like `node_modules, .venv, .git` and folders like that. | 12 | At first I had problems with `.venv` environments for Python and the only |
| 13 | 13 | solution for excluding synchronization for this folder was to manually exclude | |
| 14 | I went on a hunt for an alternative to [Dropbox](https://www.dropbox.com/) and found: | 14 | a specific folder which is not really scalable. FYI, my whole project folder is |
| 15 | synced on [Dropbox](https://www.dropbox.com/). This of course introduced a lot | ||
| 16 | of syncing of files and folders that are not needed or even break things on | ||
| 17 | other machines. In the case of **Python**, I couldn't use that on my second | ||
| 18 | machine. I needed to delete `.venv` folder and pip it again which synced files | ||
| 19 | again to the main machine. This was very frustrating. **Nodejs** handles this | ||
| 20 | much nicer and I can just run the scripts without deleting `node_modules` again | ||
| 21 | and reinstalling. However, `node_modules` is a beast of its own. It creates so | ||
| 22 | many files that OS has a problem counting them when you check the folder | ||
| 23 | contents for size. | ||
| 24 | |||
| 25 | I wanted something similar to Dropbox. I could without the instant syncing | ||
| 26 | but it would need to be fast and had the option for me to exclude folders like | ||
| 27 | `node_modules, .venv, .git` and folders like that. | ||
| 28 | |||
| 29 | I went on a hunt for an alternative to [Dropbox](https://www.dropbox.com/) | ||
| 30 | and found: | ||
| 15 | 31 | ||
| 16 | - [Tresorit](https://tresorit.com/) | 32 | - [Tresorit](https://tresorit.com/) |
| 17 | - [Sync.com](https://sync.com) | 33 | - [Sync.com](https://sync.com) |
| 18 | - [Box](https://www.box.com/) | 34 | - [Box](https://www.box.com/) |
| 19 | 35 | ||
| 20 | You know, the usual list of suspects. I didn't include [Google drive](https://drive.google.com) or [One drive](https://onedrive.live.com/) since they are even more draconian than Dropbox. | 36 | You know, the usual list of suspects. I didn't include [Google drive](https://drive.google.com) |
| 37 | or [One drive](https://onedrive.live.com/) since they are even more draconian | ||
| 38 | than Dropbox. | ||
| 21 | 39 | ||
| 22 | > All this does not stem from me being paranoid but recently these companies have became more and more aggressive and they keep violating our privacy when they share our data with 3rd party services. It is getting out of control. | 40 | > All this does not stem from me being paranoid but recently these companies |
| 41 | > have became more and more aggressive and they keep violating our privacy when | ||
| 42 | > they share our data with 3rd party services. It is getting out of control. | ||
| 23 | 43 | ||
| 24 | So, my main problem was still there. No way of excluding a specific folder from syncing. And before we go into "*But you have git, isn't that enough?*", I must say, that many of the files (PDFs, spreadsheets, etc) I have in a `git` repo don't get pushed upstream to Git and I still want to have them synced across my computers. | 44 | So, my main problem was still there. No way of excluding a specific folder |
| 45 | from syncing. And before we go into "*But you have git, isn't that enough?*", | ||
| 46 | I must say, that many of the files (PDFs, spreadsheets, etc) I have in a `git` | ||
| 47 | repo don't get pushed upstream to Git and I still want to have them synced | ||
| 48 | across my computers. | ||
| 25 | 49 | ||
| 26 | I initially wanted to use [rsync](https://linux.die.net/man/1/rsync) but I would need to then have a remote VPS or transfer between my computers directly. I wanted a solution where all my files could be accessible to me without my machine. | 50 | I initially wanted to use [rsync](https://linux.die.net/man/1/rsync) but I |
| 51 | would need to then have a remote VPS or transfer between my computers directly. | ||
| 52 | I wanted a solution where all my files could be accessible to me without my | ||
| 53 | machine. | ||
| 27 | 54 | ||
| 28 | > **WARNING: This solution will cost you money!** DigitalOcean Spaces are $5 per month and there are some bandwidth limitations and if you go beyond that you get billed additionally. | 55 | > **WARNING: This solution will cost you money!** DigitalOcean Spaces are $5 |
| 56 | per month and there are some bandwidth limitations and if you go beyond that | ||
| 57 | you get billed additionally. | ||
| 29 | 58 | ||
| 30 | Then I remembered that I could use something like [S3](https://en.wikipedia.org/wiki/Amazon_S3) since it has versioning and is fully managed. I didn't want to go down the AWS rabbit hole with this so I choose [DigitalOcean Spaces](https://www.digitalocean.com/products/spaces/). | 59 | Then I remembered that I could use something like [S3](https://en.wikipedia.org/wiki/Amazon_S3) |
| 60 | since it has versioning and is fully managed. I didn't want to go down the AWS | ||
| 61 | rabbit hole with this so I choose [DigitalOcean Spaces](https://www.digitalocean.com/products/spaces/). | ||
| 31 | 62 | ||
| 32 | Then I needed a command-line tool to sync between source and target. I found this nice tool [s3cmd](https://s3tools.org/s3cmd) and it is in the Ubuntu repositories. | 63 | Then I needed a command-line tool to sync between source and target. I found |
| 64 | this nice tool [s3cmd](https://s3tools.org/s3cmd) and it is in the Ubuntu | ||
| 65 | repositories. | ||
| 33 | 66 | ||
| 34 | ```bash | 67 | ```bash |
| 35 | sudo apt install s3cmd | 68 | sudo apt install s3cmd |
| 36 | ``` | 69 | ``` |
| 37 | 70 | ||
| 38 | After installation will I create a new Space bucket on DigitalOcean. Remember the zone you will choose because you will need it when you will configure `s3cmd`. | 71 | After installation will I create a new Space bucket on DigitalOcean. Remember |
| 72 | the zone you will choose because you will need it when you will configure `s3cmd`. | ||
| 39 | 73 | ||
| 40 | Then I visited [Digitalocean Applications & API](https://cloud.digitalocean.com/account/api/tokens) and generated **Spaces access keys**. Save both key and secret somewhere safe because when you will leave the page secret will not be available anymore to you and you will need to re-generate it. | 74 | Then I visited [Digitalocean Applications & API](https://cloud.digitalocean.com/account/api/tokens) |
| 75 | and generated **Spaces access keys**. Save both key and secret somewhere safe | ||
| 76 | because when you will leave the page secret will not be available anymore to | ||
| 77 | you and you will need to re-generate it. | ||
| 41 | 78 | ||
| 42 | ```bash | 79 | ```bash |
| 43 | # enter your key and secret and correct endpoint | 80 | # enter your key and secret and correct endpoint |
| @@ -45,7 +82,9 @@ Then I visited [Digitalocean Applications & API](https://cloud.digitalocean.com/ | |||
| 45 | # I created my bucket in Amsterdam regiin | 82 | # I created my bucket in Amsterdam regiin |
| 46 | s3cmd --configure | 83 | s3cmd --configure |
| 47 | ``` | 84 | ``` |
| 48 | After that I played around with options for `s3cmd` and got to the following command. | 85 | |
| 86 | After that I played around with options for `s3cmd` and got to the following | ||
| 87 | command. | ||
| 49 | 88 | ||
| 50 | ```bash | 89 | ```bash |
| 51 | # I executed this command from my projects folder | 90 | # I executed this command from my projects folder |
| @@ -53,12 +92,19 @@ cd projects | |||
| 53 | s3cmd sync --delete-removed --exclude 'node_modules/*' --exclude '.git/*' --exclude '.venv/*' ./ s3://my-bucket-name/projects/ | 92 | s3cmd sync --delete-removed --exclude 'node_modules/*' --exclude '.git/*' --exclude '.venv/*' ./ s3://my-bucket-name/projects/ |
| 54 | ``` | 93 | ``` |
| 55 | 94 | ||
| 56 | When syncing int he other direction you will need to change the order of the `SOURCE` and `TARGET` to `s3://my-bucket-name/projects/` and `./`. | 95 | When syncing int he other direction you will need to change the order of the |
| 96 | `SOURCE` and `TARGET` to `s3://my-bucket-name/projects/` and `./`. | ||
| 97 | |||
| 98 | > Be sure that all the paths have trailing slash so that sync knows that this | ||
| 99 | > are directories. | ||
| 57 | 100 | ||
| 58 | > Be sure that all the paths have trailing slash so that sync knows that this are directories. | 101 | I am planning to implement some sort of a `.ignore` file that will enable me to |
| 102 | have a project-specific exclude options. | ||
| 59 | 103 | ||
| 60 | I am planning to implement some sort of a `.ignore` file that will enable me to have a project-specific exclude options. | 104 | I am currently running this every hour as a cronjob which is perfectly fine |
| 105 | for now when I am testing how this whole thing works and how it all will turn | ||
| 106 | out. | ||
| 61 | 107 | ||
| 62 | I am currently running this every hour as a cronjob which is perfectly fine for now when I am testing how this whole thing works and how it all will turn out. | 108 | I have also created a small Gnome extension which is still very unstable, but |
| 109 | when/if this whole experiment pays of I will share on Github. | ||
| 63 | 110 | ||
| 64 | I have also created a small Gnome extension which is still very unstable, but when/if this whole experiment pays of I will share on Github. | ||
diff --git a/content/posts/2021-01-24-replacing-dropbox-with-s3.md b/content/posts/2021-01-24-replacing-dropbox-with-s3.md index f44aa63..0253368 100644 --- a/content/posts/2021-01-24-replacing-dropbox-with-s3.md +++ b/content/posts/2021-01-24-replacing-dropbox-with-s3.md | |||
| @@ -1,25 +1,41 @@ | |||
| 1 | --- | 1 | --- |
| 2 | title: Replacing Dropbox in favor of DigitalOcean spaces | 2 | title: Replacing Dropbox in favor of DigitalOcean spaces |
| 3 | url: replacing-dropbox-in-favor-of-digitalocean-spaces.html | 3 | url: replacing-dropbox-in-favor-of-digitalocean-spaces.html |
| 4 | date: 2021-01-24 | 4 | date: 2021-01-24T12:00:00+02:00 |
| 5 | draft: false | 5 | draft: false |
| 6 | --- | 6 | --- |
| 7 | 7 | ||
| 8 | A few months ago I experimented with DigitalOcean spaces as my backup solution that could [replace Dropbox eventually](/digitalocean-spaces-to-sync-between-computers.html). That solution worked quite nicely, and I was amazed how smashing together a couple of existing solutions would work this fine. | 8 | A few months ago I experimented with DigitalOcean spaces as my backup solution |
| 9 | that could [replace Dropbox eventually](/digitalocean-spaces-to-sync-between-computers.html). | ||
| 10 | That solution worked quite nicely, and I was amazed how smashing together a | ||
| 11 | couple of existing solutions would work this fine. | ||
| 9 | 12 | ||
| 10 | I have been running that solution in the background for a couple of months now and kind of forgot about it. But recent developments around deplatforming and having us people hostages of technology and big companies speed up my goals to become less dependent on [Google](https://edition.cnn.com/2020/12/17/tech/google-antitrust-lawsuit/index.html), [Dropbox](https://www.pcworld.com/article/2048680/dropbox-takes-a-peek-at-files.html) etc and take back some control. | 13 | I have been running that solution in the background for a couple of months now |
| 14 | and kind of forgot about it. But recent developments around deplatforming and | ||
| 15 | having us people hostages of technology and big companies speed up my goals to | ||
| 16 | become less dependent on [Google](https://edition.cnn.com/2020/12/17/tech/google-antitrust-lawsuit/index.html), | ||
| 17 | [Dropbox](https://www.pcworld.com/article/2048680/dropbox-takes-a-peek-at-files.html) | ||
| 18 | etc and take back some control. | ||
| 11 | 19 | ||
| 12 | I am not a conspiracy theory nut, but to be honest, what these companies are doing lately is out of control. It is a matter of principle at this point. I have almost completely degoogled my life all the way from ditching Gmail, YouTube and most of the services surrounding Google. And I must tell you, I feel so good. I haven't felt this way for a long time. | 20 | I am not a conspiracy theory nut, but to be honest, what these companies are |
| 21 | doing lately is out of control. It is a matter of principle at this point. I | ||
| 22 | have almost completely degoogled my life all the way from ditching Gmail, | ||
| 23 | YouTube and most of the services surrounding Google. And I must tell you, I | ||
| 24 | feel so good. I haven't felt this way for a long time. | ||
| 13 | 25 | ||
| 14 | **Anyways. Let's get to the meat of things.** | 26 | **Anyways. Let's get to the meat of things.** |
| 15 | 27 | ||
| 16 | Before you continue you should read my post about [syncing to Dropbox](/digitalocean-spaces-to-sync-between-computers.html). | 28 | Before you continue you should read my post about [syncing to Dropbox](/digitalocean-spaces-to-sync-between-computers.html). |
| 17 | 29 | ||
| 18 | > Also to note, I am using Linux on my machine with Gnome desktop environment. This should work on MacOS too. To use this on Windows I suggest using [Subsystem for Linux](https://docs.microsoft.com/en-us/windows/wsl/install-win10) or [Cygwin](https://www.cygwin.com/). | 30 | > Also to note, I am using Linux on my machine with Gnome desktop environment. |
| 31 | This should work on MacOS too. To use this on Windows I suggest using | ||
| 32 | [Subsystem for Linux](https://docs.microsoft.com/en-us/windows/wsl/install-win10) | ||
| 33 | or [Cygwin](https://www.cygwin.com/). | ||
| 19 | 34 | ||
| 20 | ## Folder structure | 35 | ## Folder structure |
| 21 | 36 | ||
| 22 | I liked structure from Dropbox. One folder where everything is located and synced. So, that's why adopted this also for my sync setup. | 37 | I liked structure from Dropbox. One folder where everything is located and |
| 38 | synced. So, that's why adopted this also for my sync setup. | ||
| 23 | 39 | ||
| 24 | ```go | 40 | ```go |
| 25 | ~/Vault | 41 | ~/Vault |
| @@ -29,7 +45,11 @@ I liked structure from Dropbox. One folder where everything is located and synce | |||
| 29 | ↳ projects | 45 | ↳ projects |
| 30 | ``` | 46 | ``` |
| 31 | 47 | ||
| 32 | All of my code is located in `~/Vault/projects` folder. And most of the projects are Git repositories. I do not use this sync method for backup per see but in case I reinstall my machine I can easily recreate all the important folder structure with one quick command. No external drives needed that can fail etc. | 48 | All of my code is located in `~/Vault/projects` folder. And most of the |
| 49 | projects are Git repositories. I do not use this sync method for backup per | ||
| 50 | see but in case I reinstall my machine I can easily recreate all the important | ||
| 51 | folder structure with one quick command. No external drives needed that can | ||
| 52 | fail etc. | ||
| 33 | 53 | ||
| 34 | ## Sync script | 54 | ## Sync script |
| 35 | 55 | ||
| @@ -66,9 +86,12 @@ notify-send \ | |||
| 66 | "Vault sync succeded at `date +"%D %T"`" | 86 | "Vault sync succeded at `date +"%D %T"`" |
| 67 | ``` | 87 | ``` |
| 68 | 88 | ||
| 69 | This script also backups some of the dotfiles I use and sends notification to Gnome notification center. It is a straightforward solution. Nothing special going on. | 89 | This script also backups some of the dotfiles I use and sends notification to |
| 90 | Gnome notification center. It is a straightforward solution. Nothing special | ||
| 91 | going on. | ||
| 70 | 92 | ||
| 71 | > One obvious benefit of this is that I can omit syncing Node's `node_modules` or Python's `.venv` and `.git` folders. | 93 | > One obvious benefit of this is that I can omit syncing Node's `node_modules` |
| 94 | > or Python's `.venv` and `.git` folders. | ||
| 72 | 95 | ||
| 73 | You can use this script in a combination with [Cron](https://en.wikipedia.org/wiki/Cron). | 96 | You can use this script in a combination with [Cron](https://en.wikipedia.org/wiki/Cron). |
| 74 | 97 | ||
| @@ -76,13 +99,14 @@ You can use this script in a combination with [Cron](https://en.wikipedia.org/wi | |||
| 76 | 0 2 * * * sh ~/Vault/bin/vault-backup.sh | 99 | 0 2 * * * sh ~/Vault/bin/vault-backup.sh |
| 77 | ``` | 100 | ``` |
| 78 | 101 | ||
| 79 | When you start syncing your local stuff with a remote server you can review your items on DigitalOcean. | 102 | When you start syncing your local stuff with a remote server you can review |
| 103 | your items on DigitalOcean. | ||
| 80 | 104 | ||
| 81 |  | 105 |  |
| 82 | 106 | ||
| 83 | I have been using this script now for quite some time, and it's working flawlessly. I also uninstalled Dropbox and stopped using it completely. | 107 | I have been using this script now for quite some time, and it's working |
| 84 | 108 | flawlessly. I also uninstalled Dropbox and stopped using it completely. | |
| 85 | All I need to do is write a Bash script that does the reverse and downloads from remote server to local folder. This could be another post. | ||
| 86 | |||
| 87 | 109 | ||
| 110 | All I need to do is write a Bash script that does the reverse and downloads | ||
| 111 | from remote server to local folder. This could be another post. | ||
| 88 | 112 | ||
diff --git a/content/posts/2021-01-25-goaccess.md b/content/posts/2021-01-25-goaccess.md index e8fcee3..efbd175 100644 --- a/content/posts/2021-01-25-goaccess.md +++ b/content/posts/2021-01-25-goaccess.md | |||
| @@ -1,28 +1,42 @@ | |||
| 1 | --- | 1 | --- |
| 2 | title: Using GoAccess with Nginx to replace Google Analytics | 2 | title: Using GoAccess with Nginx to replace Google Analytics |
| 3 | url: using-goaccess-with-nginx-to-replace-google-analytics.html | 3 | url: using-goaccess-with-nginx-to-replace-google-analytics.html |
| 4 | date: 2021-01-25 | 4 | date: 2021-01-25T12:00:00+02:00 |
| 5 | draft: false | 5 | draft: false |
| 6 | --- | 6 | --- |
| 7 | 7 | ||
| 8 | ## Introduction | 8 | ## Introduction |
| 9 | 9 | ||
| 10 | I know! You cannot simply replace Google Analytics with parsing access logs and displaying a couple of charts. But to be honest, I actually never used Google Analytics to the fullest extent and was usually interested in seeing page hits and which pages were visited most often. | 10 | I know! You cannot simply replace Google Analytics with parsing access logs and |
| 11 | displaying a couple of charts. But to be honest, I actually never used Google | ||
| 12 | Analytics to the fullest extent and was usually interested in seeing page | ||
| 13 | hits and which pages were visited most often. | ||
| 11 | 14 | ||
| 12 | I recently moved my blog from Firebase to a VPS and also decided to remove Google Analytics tracking code from the site since its quite malicious and tracks users across other pages also and is creating a profile of a user, and I've had it. But I also need some insight of what is happening on a server and which content is being read the most etc. | 15 | I recently moved my blog from Firebase to a VPS and also decided to remove |
| 16 | Google Analytics tracking code from the site since its quite malicious and | ||
| 17 | tracks users across other pages also and is creating a profile of a user, and | ||
| 18 | I've had it. But I also need some insight of what is happening on a server | ||
| 19 | and which content is being read the most etc. | ||
| 13 | 20 | ||
| 14 | I have looked at many existing solutions like: | 21 | I have looked at many existing solutions like: |
| 22 | |||
| 15 | - [Umami](https://umami.is/) | 23 | - [Umami](https://umami.is/) |
| 16 | - [Freshlytics](https://github.com/sheshbabu/freshlytics) | 24 | - [Freshlytics](https://github.com/sheshbabu/freshlytics) |
| 17 | - [Matomo](https://matomo.org/) | 25 | - [Matomo](https://matomo.org/) |
| 18 | 26 | ||
| 19 | But the more I looked at them the more I noticed that I am replacing one evil with another one. Don't get me wrong. Some of these solutions are absolutely fantastic but would require installation of databases and something like PHP or Node. And I was not ready to put those things on my fresh server. Also having Docker installed is out of the question. | 27 | But the more I looked at them the more I noticed that I am replacing one evil |
| 28 | with another one. Don't get me wrong. Some of these solutions are absolutely | ||
| 29 | fantastic but would require installation of databases and something like PHP | ||
| 30 | or Node. And I was not ready to put those things on my fresh server. Also | ||
| 31 | having Docker installed is out of the question. | ||
| 20 | 32 | ||
| 21 | ## Opting for log parsing | 33 | ## Opting for log parsing |
| 22 | 34 | ||
| 23 | So, I defaulted to parsing already existing logs and generating HTML reports from this data. | 35 | So, I defaulted to parsing already existing logs and generating HTML reports |
| 36 | from this data. | ||
| 24 | 37 | ||
| 25 | I found this amazing software [GoAccess](https://goaccess.io/) which provides all the functionalities I need, and it's a single binary. Written in Go. | 38 | I found this amazing software [GoAccess](https://goaccess.io/) which provides |
| 39 | all the functionalities I need, and it's a single binary. Written in Go. | ||
| 26 | 40 | ||
| 27 | GoAccess can be used in two different modes. | 41 | GoAccess can be used in two different modes. |
| 28 | 42 | ||
| @@ -32,11 +46,15 @@ GoAccess can be used in two different modes. | |||
| 32 |  | 46 |  |
| 33 | <center><i>Running in a browser</i></center> | 47 | <center><i>Running in a browser</i></center> |
| 34 | 48 | ||
| 35 | I, however, need this to run in a browser. So, the second option is the way to go. The Idea is to periodically run cronjob and export this report into a folder that gets then server by Nginx behind a Basic authentication. | 49 | I, however, need this to run in a browser. So, the second option is the way |
| 50 | to go. The Idea is to periodically run cronjob and export this report into a | ||
| 51 | folder that gets then server by Nginx behind a Basic authentication. | ||
| 36 | 52 | ||
| 37 | ## Getting Nginx ready | 53 | ## Getting Nginx ready |
| 38 | 54 | ||
| 39 | I choose Ubuntu on [DigitalOcean](https://www.digitalocean.com/). First I installed [Nginx](https://nginx.org/en/), and [Letsencrypt](https://letsencrypt.org/getting-started/) certbot and all the necessary dependencies. | 55 | I choose Ubuntu on [DigitalOcean](https://www.digitalocean.com/). First I |
| 56 | installed [Nginx](https://nginx.org/en/), and [Letsencrypt](https://letsencrypt.org/getting-started/) | ||
| 57 | certbot and all the necessary dependencies. | ||
| 40 | 58 | ||
| 41 | ```sh | 59 | ```sh |
| 42 | # log in as root user | 60 | # log in as root user |
| @@ -49,7 +67,8 @@ apt update && apt upgrade -y | |||
| 49 | apt install nginx certbot python3-certbot-nginx apache2-utils | 67 | apt install nginx certbot python3-certbot-nginx apache2-utils |
| 50 | ``` | 68 | ``` |
| 51 | 69 | ||
| 52 | After all this is installed we can create a new configuration for a statistics. Stats will be available at `stats.domain.com`. | 70 | After all this is installed we can create a new configuration for a statistics. |
| 71 | Stats will be available at `stats.domain.com`. | ||
| 53 | 72 | ||
| 54 | ```sh | 73 | ```sh |
| 55 | # creates directory where html will be hosted | 74 | # creates directory where html will be hosted |
| @@ -71,20 +90,27 @@ server { | |||
| 71 | } | 90 | } |
| 72 | ``` | 91 | ``` |
| 73 | 92 | ||
| 74 | Now we check if the configuration is ok. We can do this with `nginx -t`. If all is ok, we can restart Nginx with `service nginx restart`. | 93 | Now we check if the configuration is ok. We can do this with `nginx -t`. If |
| 94 | all is ok, we can restart Nginx with `service nginx restart`. | ||
| 75 | 95 | ||
| 76 | After all that you should add A record for this domain that points to IP of a droplet. | 96 | After all that you should add A record for this domain that points to IP of |
| 97 | a droplet. | ||
| 77 | 98 | ||
| 78 | Before enabling SSL you should test if DNS records have propagated with `curl stats.domain.com`. | 99 | Before enabling SSL you should test if DNS records have propagated with |
| 100 | `curl stats.domain.com`. | ||
| 79 | 101 | ||
| 80 | Now, it's time to provision TLS certificate. To achieve this, you execute command `certbot --nginx`. Follow the wizard and when you are asked about redirection always choose 2 (always redirect to HTTPS). | 102 | Now, it's time to provision TLS certificate. To achieve this, you execute command |
| 103 | `certbot --nginx`. Follow the wizard and when you are asked about redirection | ||
| 104 | always choose 2 (always redirect to HTTPS). | ||
| 81 | 105 | ||
| 82 | When this is done you can visit https://stats.domain.com and you should get 404 not found error which is correct. | 106 | When this is done you can visit https://stats.domain.com and you should get 404 |
| 107 | not found error which is correct. | ||
| 83 | 108 | ||
| 84 | 109 | ||
| 85 | ## Getting GoAccess ready | 110 | ## Getting GoAccess ready |
| 86 | 111 | ||
| 87 | If you are using Debian like system GoAccess should be available in repository. Otherwise refer to the official website. | 112 | If you are using Debian like system GoAccess should be available in repository. |
| 113 | Otherwise refer to the official website. | ||
| 88 | 114 | ||
| 89 | ```sh | 115 | ```sh |
| 90 | apt install goaccess | 116 | apt install goaccess |
| @@ -122,11 +148,19 @@ goaccess \ | |||
| 122 | rm /var/log/nginx/access-all.log | 148 | rm /var/log/nginx/access-all.log |
| 123 | ``` | 149 | ``` |
| 124 | 150 | ||
| 125 | Because after a while nginx creates multiple files with access logs we use [`zcat`](https://linux.die.net/man/1/zcat) to extract Gziped contents and create a file that has all the access logs. After this file is used we delete it. | 151 | Because after a while nginx creates multiple files with access logs we use |
| 152 | [`zcat`](https://linux.die.net/man/1/zcat) to extract Gziped contents and | ||
| 153 | create a file that has all the access logs. After this file is used we | ||
| 154 | delete it. | ||
| 126 | 155 | ||
| 127 | If you want to exclude your home IP's result look at the `--exclude-ip` option in script and instead of `0.0.0.0` add your own home IP address. You can find your home IP by executing `curl ifconfig.me` from your local machine and NOT from the droplet. | 156 | If you want to exclude your home IP's result look at the `--exclude-ip` option |
| 157 | in script and instead of `0.0.0.0` add your own home IP address. You can find | ||
| 158 | your home IP by executing `curl ifconfig.me` from your local machine and NOT | ||
| 159 | from the droplet. | ||
| 128 | 160 | ||
| 129 | Test the script by executing `sh /var/www/html/stats.domain.com/generate-stats.sh` and then checking `https://stats.domain.com`. If you can see stats instead of 404 than you are set. | 161 | Test the script by executing `sh /var/www/html/stats.domain.com/generate-stats.sh` |
| 162 | and then checking `https://stats.domain.com`. If you can see stats instead of | ||
| 163 | 404 than you are set. | ||
| 130 | 164 | ||
| 131 | It's time to add this script to cron with `cron -e`. | 165 | It's time to add this script to cron with `cron -e`. |
| 132 | 166 | ||
| @@ -136,13 +170,17 @@ It's time to add this script to cron with `cron -e`. | |||
| 136 | 170 | ||
| 137 | ## Securing with Basic authentication | 171 | ## Securing with Basic authentication |
| 138 | 172 | ||
| 139 | You probably don't want stats to be publicly available, so we should create a user and a password for Basic authentication. | 173 | You probably don't want stats to be publicly available, so we should create a |
| 174 | user and a password for Basic authentication. | ||
| 140 | 175 | ||
| 141 | First we create a password for a user `stats` with `htpasswd -c /etc/nginx/.htpasswd stats`. | 176 | First we create a password for a user `stats` with `htpasswd -c /etc/nginx/.htpasswd stats`. |
| 142 | 177 | ||
| 143 | Now we update config file with `nano /etc/nginx/sites-available/stats.domain.com`. You probably noticed that the file looks a bit different from before. This is because `certbot` added additional rules for SSL. | 178 | Now we update config file with `nano /etc/nginx/sites-available/stats.domain.com`. |
| 179 | You probably noticed that the file looks a bit different from before. This is | ||
| 180 | because `certbot` added additional rules for SSL. | ||
| 144 | 181 | ||
| 145 | Your location portion the config file should now look like. You should add `auth_basic` and `auth_basic_user_file` lines to the file. | 182 | Your location portion the config file should now look like. You should add |
| 183 | `auth_basic` and `auth_basic_user_file` lines to the file. | ||
| 146 | 184 | ||
| 147 | ```nginx | 185 | ```nginx |
| 148 | location / { | 186 | location / { |
| @@ -152,8 +190,12 @@ location / { | |||
| 152 | } | 190 | } |
| 153 | ``` | 191 | ``` |
| 154 | 192 | ||
| 155 | Test if config is still ok with `nginx -t` and if it is you can restart Nginx with `service nginx restart`. | 193 | Test if config is still ok with `nginx -t` and if it is you can restart |
| 194 | Nginx with `service nginx restart`. | ||
| 195 | |||
| 196 | If you now visit `https://stats.domain.com` you should be prompted for username | ||
| 197 | and password. If not, try reopening your browser. | ||
| 156 | 198 | ||
| 157 | If you now visit `https://stats.domain.com` you should be prompted for username and password. If not, try reopening your browser. | 199 | That is all. You now have analytics for your server that gets refreshed every |
| 200 | 10 minutes. | ||
| 158 | 201 | ||
| 159 | That is all. You now have analytics for your server that gets refreshed every 10 minutes. | ||
diff --git a/content/posts/2021-06-26-simple-world-clock.md b/content/posts/2021-06-26-simple-world-clock.md index 80d1e32..f42af11 100644 --- a/content/posts/2021-06-26-simple-world-clock.md +++ b/content/posts/2021-06-26-simple-world-clock.md | |||
| @@ -1,21 +1,31 @@ | |||
| 1 | --- | 1 | --- |
| 2 | title: Simple world clock with eInk display and Raspberry Pi Zero | 2 | title: Simple world clock with eInk display and Raspberry Pi Zero |
| 3 | url: simple-world-clock-with-eiink-display-and-raspberry-pi-zero.html | 3 | url: simple-world-clock-with-eiink-display-and-raspberry-pi-zero.html |
| 4 | date: 2021-06-26 | 4 | date: 2021-06-26T12:00:00+02:00 |
| 5 | draft: false | 5 | draft: false |
| 6 | --- | 6 | --- |
| 7 | 7 | ||
| 8 | Our team is spread across the world, from the USA all the way to Australia, so having some sort of world clock makes sense. | 8 | Our team is spread across the world, from the USA all the way to Australia, |
| 9 | so having some sort of world clock makes sense. | ||
| 9 | 10 | ||
| 10 | Currently, I am using an extension for Gnome called [Timezone extension](https://extensions.gnome.org/extension/2657/timezones-extension/), and it serves the purpose quite well. | 11 | Currently, I am using an extension for Gnome called |
| 12 | [Timezone extension](https://extensions.gnome.org/extension/2657/timezones-extension/), | ||
| 13 | and it serves the purpose quite well. | ||
| 11 | 14 | ||
| 12 | But I also have a bunch of electronics that I bought through the time, and I am not using any of them, and it's time to stop hording this stuff and use it in a project. | 15 | But I also have a bunch of electronics that I bought through the time, and I |
| 16 | am not using any of them, and it's time to stop hording this stuff and use it | ||
| 17 | in a project. | ||
| 13 | 18 | ||
| 14 | A while ago I bought a small eInk display [Inky pHAT](https://shop.pimoroni.com/products/inky-phat?variant=12549254217811) and I have a bunch of [Raspberry Pi's Zero](https://www.raspberrypi.org/products/raspberry-pi-zero/) lying around that I really need to use. | 19 | A while ago I bought a small eInk display |
| 20 | [Inky pHAT](https://shop.pimoroni.com/products/inky-phat?variant=12549254217811) | ||
| 21 | and I have a bunch of [Raspberry Pi's Zero](https://www.raspberrypi.org/products/raspberry-pi-zero/) | ||
| 22 | lying around that I really need to use. | ||
| 15 | 23 | ||
| 16 |  | 24 |  |
| 17 | 25 | ||
| 18 | Since the Inky [Inky pHAT](https://shop.pimoroni.com/products/inky-phat?variant=12549254217811) is essentially a HAT, it can easily be added on top of the [Raspberry Pi Zero](https://www.raspberrypi.org/products/raspberry-pi-zero/). | 26 | Since the Inky [Inky pHAT](https://shop.pimoroni.com/products/inky-phat?variant=12549254217811) |
| 27 | is essentially a HAT, it can easily be added on top of the | ||
| 28 | [Raspberry Pi Zero](https://www.raspberrypi.org/products/raspberry-pi-zero/). | ||
| 19 | 29 | ||
| 20 | First, I installed the necessary software on Raspberry Pi with `pip3 install inky`. | 30 | First, I installed the necessary software on Raspberry Pi with `pip3 install inky`. |
| 21 | 31 | ||
| @@ -66,7 +76,8 @@ board.set_image(img) | |||
| 66 | board.show() | 76 | board.show() |
| 67 | ``` | 77 | ``` |
| 68 | 78 | ||
| 69 | And because eInk displays are rather slow to refresh and the clock requires refreshing only once a minute, this can be done through cronjob. | 79 | And because eInk displays are rather slow to refresh and the clock requires |
| 80 | refreshing only once a minute, this can be done through cronjob. | ||
| 70 | 81 | ||
| 71 | Before we add this job to cron we need to make `clock.py` executable with `chmod +x clock.py`. | 82 | Before we add this job to cron we need to make `clock.py` executable with `chmod +x clock.py`. |
| 72 | 83 | ||
| @@ -80,8 +91,13 @@ So, we end up with a result like this. | |||
| 80 | 91 | ||
| 81 |  | 92 |  |
| 82 | 93 | ||
| 83 | And for the enclosure that can be 3D printed, but I haven't yet something like this can be used. | 94 | And for the enclosure that can be 3D printed, but I haven't yet something like |
| 95 | this can be used. | ||
| 84 | 96 | ||
| 85 | <iframe id="vs_iframe" src="https://www.viewstl.com/?embedded&url=https%3A%2F%2Fmitjafelicijan.com%2Fassets%2Fworld-clock%2Fenclosure.stl&color=gray&bgcolor=white&edges=no&orientation=front&noborder=no" style="border:0;margin:0;width:100%;height:400px;"></iframe> | 97 | <iframe id="vs_iframe" src="https://www.viewstl.com/?embedded&url=https%3A%2F%2Fmitjafelicijan.com%2Fassets%2Fworld-clock%2Fenclosure.stl&color=gray&bgcolor=white&edges=no&orientation=front&noborder=no" style="border:0;margin:0;width:100%;height:400px;"></iframe> |
| 86 | 98 | ||
| 87 | You can download my [STL file for the enclosure here](/assets/world-clock/enclosure.stl), but make sure that dimensions make sense and also opening for USB port should be added or just use a drill and some hot glue to make it stick in the enclosure. | 99 | You can download my [STL file for the enclosure here](/assets/world-clock/enclosure.stl), |
| 100 | but make sure that dimensions make sense and also opening for USB port should | ||
| 101 | be added or just use a drill and some hot glue to make it stick in the | ||
| 102 | enclosure. | ||
| 103 | |||
diff --git a/content/posts/2021-07-30-from-internet-consumer-to-full-hominum-again.md b/content/posts/2021-07-30-from-internet-consumer-to-full-hominum-again.md index 85b6c91..27e0905 100644 --- a/content/posts/2021-07-30-from-internet-consumer-to-full-hominum-again.md +++ b/content/posts/2021-07-30-from-internet-consumer-to-full-hominum-again.md | |||
| @@ -1,34 +1,104 @@ | |||
| 1 | --- | 1 | --- |
| 2 | title: My journey from being an internet über consumer to being a full hominum again | 2 | title: My journey from being an internet über consumer to being a full hominum again |
| 3 | url: from-internet-consumer-to-full-hominum-again.html | 3 | url: from-internet-consumer-to-full-hominum-again.html |
| 4 | date: 2021-07-30 | 4 | date: 2021-07-30T12:00:00+02:00 |
| 5 | draft: false | 5 | draft: false |
| 6 | --- | 6 | --- |
| 7 | 7 | ||
| 8 | It's been almost a year since I started purging all my online accounts and going down this rabbit hole of being almost independent of the current internet machine. Even though I initially thought that I will have problems adapting, I was pleasantly surprised that the transition went so smoothly. Even better, it brought many benefits to my life. Such as increased focus, less stress about trivial things, etc. | 8 | It's been almost a year since I started purging all my online accounts and |
| 9 | going down this rabbit hole of being almost independent of the current internet | ||
| 10 | machine. Even though I initially thought that I will have problems adapting, | ||
| 11 | I was pleasantly surprised that the transition went so smoothly. Even better, | ||
| 12 | it brought many benefits to my life. Such as increased focus, less stress | ||
| 13 | about trivial things, etc. | ||
| 9 | 14 | ||
| 10 | It all started with me doing small changes like unsubscribing from emails that I have either subscribed to by accepting terms and conditions. Or even some more malicious emails that I was getting because I was on a shared mailing list. And the later ones I hate the most of all. How the hell do they keep sharing my email and sending me unsolicited emails and get away with it? I have a suspicion that these marketing people share an Excel file between them and keep resubscribing me when they import lists into Mailchimp or similar software. | 15 | It all started with me doing small changes like unsubscribing from emails that |
| 16 | I have either subscribed to by accepting terms and conditions. Or even some | ||
| 17 | more malicious emails that I was getting because I was on a shared mailing | ||
| 18 | list. And the later ones I hate the most of all. How the hell do they keep | ||
| 19 | sharing my email and sending me unsolicited emails and get away with it? I | ||
| 20 | have a suspicion that these marketing people share an Excel file between them | ||
| 21 | and keep resubscribing me when they import lists into Mailchimp or similar | ||
| 22 | software. | ||
| 11 | 23 | ||
| 12 | It's fascinating to see how much crap you get subscribed to when you are not paying attention. It got so bad that my primary Gmail address is a full of junk and need constant monitoring and cleaning up. And because I want to have Inbox Zero, this presents an additional problem for me. | 24 | It's fascinating to see how much crap you get subscribed to when you are not |
| 25 | paying attention. It got so bad that my primary Gmail address is a full of junk | ||
| 26 | and need constant monitoring and cleaning up. And because I want to have Inbox | ||
| 27 | Zero, this presents an additional problem for me. | ||
| 13 | 28 | ||
| 14 | The stress that email presented for me didn't occur to me for a long time. I was noticing that I was unable to go through one single hour without hysterically refreshing email. And if somebody wrote me something, I needed to see it right then, even though I didn't immediately reply to it. I can only describe this with FOMO (fear of missing out). I have no other explanation than that. It was crippling, and I was constantly context switching, which I will address further down this post in more details. | 29 | The stress that email presented for me didn't occur to me for a long time. I |
| 30 | was noticing that I was unable to go through one single hour without | ||
| 31 | hysterically refreshing email. And if somebody wrote me something, I needed | ||
| 32 | to see it right then, even though I didn't immediately reply to it. I can | ||
| 33 | only describe this with FOMO (fear of missing out). I have no other explanation | ||
| 34 | than that. It was crippling, and I was constantly context switching, which I | ||
| 35 | will address further down this post in more details. | ||
| 15 | 36 | ||
| 16 | This was one of the reasons why I spawned up my personal email server, and I am using it now as my primary and person email. I still have Gmail as my “junk” email that I use for throw away stuff. I log in to Gmail once a week and check if there are any important emails that I got, but apart from that, it's sitting dormant and collecting dust. | 37 | This was one of the reasons why I spawned up my personal email server, and I |
| 38 | am using it now as my primary and person email. I still have Gmail as my “junk” | ||
| 39 | email that I use for throw away stuff. I log in to Gmail once a week and check | ||
| 40 | if there are any important emails that I got, but apart from that, it's | ||
| 41 | sitting dormant and collecting dust. | ||
| 17 | 42 | ||
| 18 | The more I was watching the world loose it's self with allowing anti freedom things to happen to it, the more I started to realize that something has to change. I don't have the power to change the world. And I also don't have a grandiose opinion of myself to even think to try it. But what I can do is to not subscribe to this consumer way of thinking. I will not be complicit in this. My moral and ethical stances won't allow it. So, this brings us to the second part of my journey. | 43 | The more I was watching the world loose it's self with allowing anti freedom |
| 44 | things to happen to it, the more I started to realize that something has to | ||
| 45 | change. I don't have the power to change the world. And I also don't have a | ||
| 46 | grandiose opinion of myself to even think to try it. But what I can do is to | ||
| 47 | not subscribe to this consumer way of thinking. I will not be complicit in | ||
| 48 | this. My moral and ethical stances won't allow it. So, this brings us to the | ||
| 49 | second part of my journey. | ||
| 19 | 50 | ||
| 20 | I was using all these 3rd party services because I was either lazy or OK with the drawbacks of them. I watched these services and companies became more and more evil. It is evil if you sell your user's data in this manner. Nobody reads privacy policies and everybody is OK with accepting them, and they pray on that flaw in human nature. I really hate the hypocrisy they manage to muster. These companies prey on our laziness, and we are at fault here. Nobody else. And I truly understand the reasons why we rather accept and move on, and not object and have our lives a little more difficult. They have perfected this through years of small changes that make us a little more dependent on them. You could not convince a person to give away all his rights and data in one day. This was gradual and slow. And it caught us all in surprise. When I really stopped and thought about it, I felt repulsed. By really stopping and thinking about it, I really mean stopping and thinking about it. Thoroughly and in depth. | 51 | I was using all these 3rd party services because I was either lazy or OK with |
| 52 | the drawbacks of them. I watched these services and companies became more and | ||
| 53 | more evil. It is evil if you sell your user's data in this manner. Nobody reads | ||
| 54 | privacy policies and everybody is OK with accepting them, and they pray on that | ||
| 55 | flaw in human nature. I really hate the hypocrisy they manage to muster. These | ||
| 56 | companies prey on our laziness, and we are at fault here. Nobody else. And I | ||
| 57 | truly understand the reasons why we rather accept and move on, and not object | ||
| 58 | and have our lives a little more difficult. They have perfected this through | ||
| 59 | years of small changes that make us a little more dependent on them. You could | ||
| 60 | not convince a person to give away all his rights and data in one day. This was | ||
| 61 | gradual and slow. And it caught us all in surprise. When I really stopped and | ||
| 62 | thought about it, I felt repulsed. By really stopping and thinking about it, | ||
| 63 | I really mean stopping and thinking about it. Thoroughly and in depth. | ||
| 21 | 64 | ||
| 22 | Each step I took depleted my character a bit more. Like I was trading myself bit by bit without understanding what it all meant. What it meant to be a full person, not divided by all this bought attention they want from me. They don't just get your data, but they also take your attention away from you. They scatter your and go with the divide and conquer tactic from there. And a person divided is a person not fully there. Not at the moment. Not alive fully. | 65 | Each step I took depleted my character a bit more. Like I was trading myself |
| 66 | bit by bit without understanding what it all meant. What it meant to be a full | ||
| 67 | person, not divided by all this bought attention they want from me. They don't | ||
| 68 | just get your data, but they also take your attention away from you. They | ||
| 69 | scatter your and go with the divide and conquer tactic from there. And a person | ||
| 70 | divided is a person not fully there. Not at the moment. Not alive fully. | ||
| 23 | 71 | ||
| 24 | I was unable to form long thoughts. Well, I thought I was. But now that I see what being a full person is again, I can see that I was not at my 100% back then. | 72 | I was unable to form long thoughts. Well, I thought I was. But now that I see |
| 73 | what being a full person is again, I can see that I was not at my 100% back | ||
| 74 | then. | ||
| 25 | 75 | ||
| 26 | A revolt was inevitable. There was no other way of continuing my story without it. Without taking back my attention, my thoughts, my time, and my privacy, regardless of how too late it maybe is. | 76 | A revolt was inevitable. There was no other way of continuing my story without |
| 77 | it. Without taking back my attention, my thoughts, my time, and my privacy, | ||
| 78 | regardless of how too late it maybe is. | ||
| 27 | 79 | ||
| 28 | This has nothing to do with conspiracy theories. Even less with changing the world. All I wanted was to get my life back in order and not waste the energy that could be spent in other, better places. | 80 | This has nothing to do with conspiracy theories. Even less with changing the |
| 81 | world. All I wanted was to get my life back in order and not waste the energy | ||
| 82 | that could be spent in other, better places. | ||
| 29 | 83 | ||
| 30 | I started reading more. I can focus now fully on things I work on. Furthermore, I have the mental acuity that I never had before. My mind feels sharp. I don't get angry so much. I can cherish the finer things in life now without the need to interpret them intellectually. Not only that, but I have a feeling of belonging again. Sense of purpose has returned with a vengeance. And I can now help people without depleting myself. | 84 | I started reading more. I can focus now fully on things I work on. Furthermore, |
| 85 | I have the mental acuity that I never had before. My mind feels sharp. I don't | ||
| 86 | get angry so much. I can cherish the finer things in life now without the need | ||
| 87 | to interpret them intellectually. Not only that, but I have a feeling of | ||
| 88 | belonging again. Sense of purpose has returned with a vengeance. And I can | ||
| 89 | now help people without depleting myself. | ||
| 31 | 90 | ||
| 32 | The last step so far was to finish closing all the remaining online accounts that I still had. And when I was thinking what value they bring me, I wasn't surprised that the answer was none. I wasn't logging in them and using them. I stopped being afraid of FOMO. If somebody wants to get in contact me, they will find a way. I am one search away. | 91 | The last step so far was to finish closing all the remaining online accounts |
| 92 | that I still had. And when I was thinking what value they bring me, I wasn't | ||
| 93 | surprised that the answer was none. I wasn't logging in them and using them. | ||
| 94 | I stopped being afraid of FOMO. If somebody wants to get in contact me, they | ||
| 95 | will find a way. I am one search away. | ||
| 96 | |||
| 97 | We are not beholden to anybody. Our lives are our own. So dare yourself to | ||
| 98 | delete Facebook, LinkedIn. To unsubscribe. Dare yourself to take your time | ||
| 99 | and attention back. Use that time and energy to go for a walk without thinking | ||
| 100 | about work. Read a book instead of reading comment on social media that you | ||
| 101 | will forget in an hour. Enrich your life instead of wasting it. It only | ||
| 102 | requires a small step. And you will feel the benefits immediately. Lose the | ||
| 103 | weight of the world that is crushing you without your consent. | ||
| 33 | 104 | ||
| 34 | We are not beholden to anybody. Our lives are our own. So dare yourself to delete Facebook, LinkedIn. To unsubscribe. Dare yourself to take your time and attention back. Use that time and energy to go for a walk without thinking about work. Read a book instead of reading comment on social media that you will forget in an hour. Enrich your life instead of wasting it. It only requires a small step. And you will feel the benefits immediately. Lose the weight of the world that is crushing you without your consent. | ||
diff --git a/content/posts/2021-08-01-linux-cheatsheet.md b/content/posts/2021-08-01-linux-cheatsheet.md index 8c0d125..3747d43 100644 --- a/content/posts/2021-08-01-linux-cheatsheet.md +++ b/content/posts/2021-08-01-linux-cheatsheet.md | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | --- | 1 | --- |
| 2 | title: List of essential Linux commands for server management | 2 | title: List of essential Linux commands for server management |
| 3 | url: linux-cheatsheet.html | 3 | url: linux-cheatsheet.html |
| 4 | date: 2021-08-01 | 4 | date: 2021-08-01T12:00:00+02:00 |
| 5 | draft: false | 5 | draft: false |
| 6 | --- | 6 | --- |
| 7 | 7 | ||
| @@ -283,3 +283,4 @@ lsof -u <user> | |||
| 283 | # -n 1 means every second | 283 | # -n 1 means every second |
| 284 | watch -n 1 df -h | 284 | watch -n 1 df -h |
| 285 | ``` | 285 | ``` |
| 286 | |||
diff --git a/content/posts/2021-12-03-debian-based-riced-up-distribution-for-developers.md b/content/posts/2021-12-03-debian-based-riced-up-distribution-for-developers.md index 56816a0..b8d93a6 100644 --- a/content/posts/2021-12-03-debian-based-riced-up-distribution-for-developers.md +++ b/content/posts/2021-12-03-debian-based-riced-up-distribution-for-developers.md | |||
| @@ -1,21 +1,38 @@ | |||
| 1 | --- | 1 | --- |
| 2 | title: Debian based riced up distribution for Developers and DevOps folks | 2 | title: Debian based riced up distribution for Developers and DevOps folks |
| 3 | url: debian-based-riced-up-distribution-for-developers-and-devops-folks.html | 3 | url: debian-based-riced-up-distribution-for-developers-and-devops-folks.html |
| 4 | date: 2021-12-03 | 4 | date: 2021-12-03T12:00:00+02:00 |
| 5 | draft: false | 5 | draft: false |
| 6 | --- | 6 | --- |
| 7 | 7 | ||
| 8 | ## Introduction | 8 | ## Introduction |
| 9 | 9 | ||
| 10 | I have been using [Ubuntu](https://ubuntu.com/) for quite a longtime now. I have used [Debian](https://www.debian.org/) in the past and [Manjaro](https://manjaro.org/). Also had [Arch](https://archlinux.org/) for some time and even ran [Gentoo](https://www.gentoo.org/) way back. | 10 | I have been using [Ubuntu](https://ubuntu.com/) for quite a longtime now. I |
| 11 | 11 | have used [Debian](https://www.debian.org/) in the past and [Manjaro](https://manjaro.org/). | |
| 12 | What I learned from all this is that I prefer running a bit older versions and having them be stable than run bleeding edge rolling release. For that reason, I stuck with Ubuntu for a couple of years now. I am also at a point in my life where I just don't care what is cool or hip anymore. I just want a stable system that doesn't get in my way. | 12 | Also had [Arch](https://archlinux.org/) for some time and even ran |
| 13 | 13 | [Gentoo](https://www.gentoo.org/) way back. | |
| 14 | During all this, I noticed that these distributions were getting very bloated and a lot of software got included that I usually uninstall on fresh installation. Maybe this is my OCD speaking, but why do I have to give fresh installation min 1 GB of ram out of the box just to have a blank screen in front of me? I get it, there are many things included in the distro to make my life easier. I understand. But at this point I have a feeling that modern Linux distributions are becoming similar to [Node.js project with node_modules](https://devhumor.com/content/uploads/images/August2017/node-modules.jpg). Just a crazy number of packages serving very little or no purpose, just supporting other software. | 14 | |
| 15 | 15 | What I learned from all this is that I prefer running a bit older versions and | |
| 16 | I felt I needed a fresh start. To start over with something minimal and clean. Something that would put a little more joy into using a computer again. | 16 | having them be stable than run bleeding edge rolling release. For that reason, |
| 17 | 17 | I stuck with Ubuntu for a couple of years now. I am also at a point in my life | |
| 18 | For the first version, I wanted to target the following machines I have at home that I want this thing to work on. | 18 | where I just don't care what is cool or hip anymore. I just want a stable |
| 19 | system that doesn't get in my way. | ||
| 20 | |||
| 21 | During all this, I noticed that these distributions were getting very bloated | ||
| 22 | and a lot of software got included that I usually uninstall on fresh | ||
| 23 | installation. Maybe this is my OCD speaking, but why do I have to give fresh | ||
| 24 | installation min 1 GB of ram out of the box just to have a blank screen in | ||
| 25 | front of me? I get it, there are many things included in the distro to make my | ||
| 26 | life easier. I understand. But at this point I have a feeling that modern Linux | ||
| 27 | distributions are becoming similar to [Node.js project with node_modules](https://devhumor.com/content/uploads/images/August2017/node-modules.jpg). | ||
| 28 | Just a crazy number of packages serving very little or no purpose, just | ||
| 29 | supporting other software. | ||
| 30 | |||
| 31 | I felt I needed a fresh start. To start over with something minimal and clean. | ||
| 32 | Something that would put a little more joy into using a computer again. | ||
| 33 | |||
| 34 | For the first version, I wanted to target the following machines I have at | ||
| 35 | home that I want this thing to work on. | ||
| 19 | 36 | ||
| 20 | ```yaml | 37 | ```yaml |
| 21 | # My main stationary work machine | 38 | # My main stationary work machine |
| @@ -35,61 +52,99 @@ Memory: 15891MiB | |||
| 35 | 52 | ||
| 36 | ## How should I approach this? | 53 | ## How should I approach this? |
| 37 | 54 | ||
| 38 | I knew I wanted to use [minimal Debian netinst ](https://www.debian.org/CD/netinst/) for the base to give myself a head start. No reason to go through changing the installer and also testing all that behemoth of a thing. So, some sort of ricing was the only logical option to get this thing of the grounds somewhat quickly. | 55 | I knew I wanted to use [minimal Debian netinst ](https://www.debian.org/CD/netinst/) |
| 39 | 56 | for the base to give myself a head start. No reason to go through changing the | |
| 57 | installer and also testing all that behemoth of a thing. So, some sort of | ||
| 58 | ricing was the only logical option to get this thing of the grounds somewhat | ||
| 59 | quickly. | ||
| 40 | 60 | ||
| 41 | > **What is ricing anyway?** | 61 | > **What is ricing anyway?** |
| 42 | > The term “RICE” stands for Race Inspired Cosmetic Enhancement. A group of people (could be one, idk) decided to see if they could tweak their own distros like they/others did their cars. This gave rise to a community of Linux/Unix enthusiasts trying to make their distros look cooler and better than others... For more information, read this article [What in the world is ricing!?](https://pesos.github.io/2020/07/14/what-is-ricing.html). | 62 | > The term “RICE” stands for Race Inspired Cosmetic Enhancement. A group of |
| 63 | > people (could be one, idk) decided to see if they could tweak their own | ||
| 64 | > distros like they/others did their cars. This gave rise to a community of | ||
| 65 | > Linux/Unix enthusiasts trying to make their distros look cooler and better | ||
| 66 | > than others... For more information, read this article | ||
| 67 | > [What in the world is ricing!?](https://pesos.github.io/2020/07/14/what-is-ricing.html). | ||
| 43 | 68 | ||
| 44 | I didn't want this to just be a set of config files for theming purpose. I wanted this to include a set of pre-installed tools and services that are being used all the time by a modern developer. Theming is just a tiny part of it. Fonts being applied across the distro and things like that. | 69 | I didn't want this to just be a set of config files for theming purpose. I |
| 70 | wanted this to include a set of pre-installed tools and services that are being | ||
| 71 | used all the time by a modern developer. Theming is just a tiny part of it. | ||
| 72 | Fonts being applied across the distro and things like that. | ||
| 45 | 73 | ||
| 46 | First, I choose terminal installer and left it to load additional components. Avoid using graphical installer in this case. | 74 | First, I choose terminal installer and left it to load additional components. |
| 75 | Avoid using graphical installer in this case. | ||
| 47 | 76 | ||
| 48 |  | 77 |  |
| 49 | 78 | ||
| 50 | After that I selected hostname and created a normal user and set password for that user and root user and choose guided mode for disk partitioning. | 79 | After that I selected hostname and created a normal user and set password for |
| 80 | that user and root user and choose guided mode for disk partitioning. | ||
| 51 | 81 | ||
| 52 |  | 82 |  |
| 53 | 83 | ||
| 54 | I left it run to install all the things required for the base system and opted out of scanning additional media for use by the package manager. Those will be downloaded from the internet during installation. | 84 | I left it run to install all the things required for the base system and opted |
| 85 | out of scanning additional media for use by the package manager. Those will be | ||
| 86 | downloaded from the internet during installation. | ||
| 55 | 87 | ||
| 56 |  | 88 |  |
| 57 | 89 | ||
| 58 | 90 | ||
| 59 | I opted out of the popularity contest, and **now comes the important part**. Uncheck all the boxes in Software selection and only leave 'standard system utilities'. I also left an SSH server, so I was able to log in to the machine from my main PC. | 91 | I opted out of the popularity contest, and **now comes the important part**. |
| 92 | Uncheck all the boxes in Software selection and only leave 'standard system | ||
| 93 | utilities'. I also left an SSH server, so I was able to log in to the machine | ||
| 94 | from my main PC. | ||
| 60 | 95 | ||
| 61 |  | 96 |  |
| 62 | 97 | ||
| 63 | At this point, I installed GRUB bootloader on the disk where I installed the system. | 98 | At this point, I installed GRUB bootloader on the disk where I installed the |
| 99 | system. | ||
| 64 | 100 | ||
| 65 |  | 101 |  |
| 66 | 102 | ||
| 67 | That concluded the installation of base Debian and after restarting the computer I was prompted with the login screen. | 103 | That concluded the installation of base Debian and after restarting the |
| 104 | computer I was prompted with the login screen. | ||
| 68 | 105 | ||
| 69 |  | 106 |  |
| 70 | 107 | ||
| 71 | Now that I had the base installation, it was time to choose what software do I want to include in this so-called distribution. I wanted out of the box developer experience, so I had plenty to choose. | 108 | Now that I had the base installation, it was time to choose what software do I |
| 109 | want to include in this so-called distribution. I wanted out of the box | ||
| 110 | developer experience, so I had plenty to choose. | ||
| 72 | 111 | ||
| 73 | Let's not waste time and go through the list. | 112 | Let's not waste time and go through the list. |
| 74 | 113 | ||
| 75 | ## Desktop environments | 114 | ## Desktop environments |
| 76 | 115 | ||
| 77 | I have been using [Gnome](https://www.gnome.org/) for my whole Linux life. From version 2 forward. It's been quite a ride. I hated version 3 when it came out and replaced version 2. But I got used to it. And now with version 40+ they also made couple of changes which I found both frustrating and presently surprised. | 116 | I have been using [Gnome](https://www.gnome.org/) for my whole Linux life. |
| 117 | From version 2 forward. It's been quite a ride. I hated version 3 when it | ||
| 118 | came out and replaced version 2. But I got used to it. And now with version | ||
| 119 | 40+ they also made couple of changes which I found both frustrating and | ||
| 120 | presently surprised. | ||
| 78 | 121 | ||
| 79 | The amount of vertical space you loose because of the beefy title bars on windows is ridiculous. And then in case of [Tilix](https://gnunn1.github.io/tilix-web/) you also have tabs, and you are 100px deep. Vertical space is one of the most important things for a developer. The more real estate you have, the more code you can have in a viewport. | 122 | The amount of vertical space you loose because of the beefy title bars on |
| 123 | windows is ridiculous. And then in case of [Tilix](https://gnunn1.github.io/tilix-web/) | ||
| 124 | you also have tabs, and you are 100px deep. Vertical space is one of the most | ||
| 125 | important things for a developer. The more real estate you have, the more | ||
| 126 | code you can have in a viewport. | ||
| 80 | 127 | ||
| 81 | But on the other hand, I still love how Gnome feels and looks. I gotta give them that. They really are trying to make Gnome feel unified and modern. | 128 | But on the other hand, I still love how Gnome feels and looks. I gotta give |
| 129 | them that. They really are trying to make Gnome feel unified and modern. | ||
| 82 | 130 | ||
| 83 | Regardless of all the nice things Gnome has, I was looking at the tiling window managers for some time, but never had the nerve to actually go with it. But now was the ideal time to give it a go. No guts, no glory kind of a thing. | 131 | Regardless of all the nice things Gnome has, I was looking at the tiling |
| 132 | window managers for some time, but never had the nerve to actually go with | ||
| 133 | it. But now was the ideal time to give it a go. No guts, no glory kind of | ||
| 134 | a thing. | ||
| 84 | 135 | ||
| 85 | One of the requirements for me was easy custom layouts because I use a really strange monitor with aspect ratio of 32:9. So relying on included layouts most of them have is a non-starter. | 136 | One of the requirements for me was easy custom layouts because I use a really |
| 137 | strange monitor with aspect ratio of 32:9. So relying on included layouts | ||
| 138 | most of them have is a non-starter. | ||
| 86 | 139 | ||
| 87 | What I was doing in Gnome was having windows in a layout like the diagram below. This is my common practice. And if you look at it you can clearly see I was replicating tiling window manager setup in Gnome. | 140 | What I was doing in Gnome was having windows in a layout like the diagram |
| 141 | below. This is my common practice. And if you look at it you can clearly see | ||
| 142 | I was replicating tiling window manager setup in Gnome. | ||
| 88 | 143 | ||
| 89 |  | 144 |  |
| 90 | 145 | ||
| 91 | 146 | That made me look into a bunch of tiling window managers and then tested them | |
| 92 | That made me look into a bunch of tiling window managers and then tested them out. Candidates I was looking at were: | 147 | out. Candidates I was looking at were: |
| 93 | 148 | ||
| 94 | - [i3](https://i3wm.org/) | 149 | - [i3](https://i3wm.org/) |
| 95 | - [bspwm](https://github.com/baskerville/bspwm) | 150 | - [bspwm](https://github.com/baskerville/bspwm) |
| @@ -99,16 +154,21 @@ That made me look into a bunch of tiling window managers and then tested them ou | |||
| 99 | - [Qtile](http://www.qtile.org/) | 154 | - [Qtile](http://www.qtile.org/) |
| 100 | - [dwm](https://dwm.suckless.org/) | 155 | - [dwm](https://dwm.suckless.org/) |
| 101 | 156 | ||
| 102 | You can also check article [13 Best Tiling Window Managers for Linux](https://www.tecmint.com/best-tiling-window-managers-for-linux/) I was referencing while testing them out. | 157 | You can also check article [13 Best Tiling Window Managers for Linux](https://www.tecmint.com/best-tiling-window-managers-for-linux/) |
| 103 | 158 | I was referencing while testing them out. | |
| 104 | While all of them provided what I needed, I liked i3 the most. What particular caught my eye was the ease to use and tree based layouts which allows flexible layouts. I know others can be set up also to have custom layouts other than spiral, dwindle etc. I think i3 is a good entry-level window manager for somebody like me. | ||
| 105 | 159 | ||
| 160 | While all of them provided what I needed, I liked i3 the most. What particular | ||
| 161 | caught my eye was the ease to use and tree based layouts which allows flexible | ||
| 162 | layouts. I know others can be set up also to have custom layouts other than | ||
| 163 | spiral, dwindle etc. I think i3 is a good entry-level window manager for | ||
| 164 | somebody like me. | ||
| 106 | 165 | ||
| 107 | ## Batteries included | 166 | ## Batteries included |
| 108 | 167 | ||
| 109 | The source for the whole thing is located on Github https://github.com/mitjafelicijan/dfd-rice. | 168 | The source for the whole thing is located on Github https://github.com/mitjafelicijan/dfd-rice. |
| 110 | 169 | ||
| 111 | Currenly included: | 170 | Currenly included: |
| 171 | |||
| 112 | - `non-free` (enables non-free packages in apt) | 172 | - `non-free` (enables non-free packages in apt) |
| 113 | - `sudo` (adds sudo and adds user to sudo group) | 173 | - `sudo` (adds sudo and adds user to sudo group) |
| 114 | - `essentials` (gcc, htop, zip, curl, etc...) | 174 | - `essentials` (gcc, htop, zip, curl, etc...) |
| @@ -133,16 +193,19 @@ Currenly included: | |||
| 133 | - `docker` (with docker-compose) | 193 | - `docker` (with docker-compose) |
| 134 | - `ansible` | 194 | - `ansible` |
| 135 | 195 | ||
| 136 | Install script also allows you to install only specific packages (example for: essentials ohmybash docker rust). | 196 | Install script also allows you to install only specific packages (example for: |
| 197 | essentials ohmybash docker rust). | ||
| 137 | 198 | ||
| 138 | ```sh | 199 | ```sh |
| 139 | su - root \ | 200 | su - root \ |
| 140 | bash -c "$(wget -q https://raw.github.com/mitjafelicijan/dfd-rice/master/tools/install.sh -O -)" -- \ | 201 | bash -c "$(wget -q https://raw.github.com/mitjafelicijan/dfd-rice/master/tools/install.sh -O -)" -- \ |
| 141 | essentials ohmybash docker rust | 202 | essentials ohmybash docker rust |
| 142 | |||
| 143 | ``` | 203 | ``` |
| 144 | 204 | ||
| 145 | Currently, most of these recipes use what Debian and this is totally fine with me since I never use bleeding edge features of a package. But if something major would come to light, I will replace it with a possible compilation script or something similar. | 205 | Currently, most of these recipes use what Debian and this is totally fine with |
| 206 | me since I never use bleeding edge features of a package. But if something | ||
| 207 | major would come to light, I will replace it with a possible compilation | ||
| 208 | script or something similar. | ||
| 146 | 209 | ||
| 147 | This is some of the output from the installation script. | 210 | This is some of the output from the installation script. |
| 148 | 211 | ||
| @@ -150,7 +213,6 @@ This is some of the output from the installation script. | |||
| 150 | 213 | ||
| 151 | Let's take a look at some examples in the installation script. | 214 | Let's take a look at some examples in the installation script. |
| 152 | 215 | ||
| 153 | |||
| 154 | ### Docker recipe | 216 | ### Docker recipe |
| 155 | 217 | ||
| 156 | ```sh | 218 | ```sh |
| @@ -170,7 +232,11 @@ systemctl status docker --no-pager | |||
| 170 | 232 | ||
| 171 | ### Making bash pretty | 233 | ### Making bash pretty |
| 172 | 234 | ||
| 173 | I really like [Oh My Zsh](https://ohmyz.sh/), but I don't like zsh shell. When I used it, I constantly needed to be aware of it and running bash scripts was a pain. So, I was really delighted when I found out that a version for bash existed called [Oh My Bash](https://ohmybash.nntoan.com/). Let's take a look at the recipe for installing it. | 235 | I really like [Oh My Zsh](https://ohmyz.sh/), but I don't like zsh shell. |
| 236 | When I used it, I constantly needed to be aware of it and running bash scripts | ||
| 237 | was a pain. So, I was really delighted when I found out that a version for | ||
| 238 | bash existed called [Oh My Bash](https://ohmybash.nntoan.com/). Let's take a | ||
| 239 | look at the recipe for installing it. | ||
| 174 | 240 | ||
| 175 | ```sh | 241 | ```sh |
| 176 | # ohmybash | 242 | # ohmybash |
| @@ -180,17 +246,29 @@ T1=${!} | |||
| 180 | wait ${T1} | 246 | wait ${T1} |
| 181 | ``` | 247 | ``` |
| 182 | 248 | ||
| 183 | Because OhMyBash does `exec bash` at the end, this traps our script inside another shell and our script cannot continue. For that reason, I executed this in background. But that presents a new problem. Because this is executed in background, we lose track of progress naturally. And that strange trick with `T1=${!}` and `wait ${T1}` waits for the background process to finish before continuing to another task in bash script. | 249 | Because OhMyBash does `exec bash` at the end, this traps our script inside |
| 184 | 250 | another shell and our script cannot continue. For that reason, I executed | |
| 185 | Check [Multi-Threaded Processing in Bash Scripts](https://www.cloudsavvyit.com/12277/how-to-use-multi-threaded-processing-in-bash-scripts/) for more details. | 251 | this in background. But that presents a new problem. Because this is executed |
| 252 | in background, we lose track of progress naturally. And that strange trick | ||
| 253 | with `T1=${!}` and `wait ${T1}` waits for the background process to finish | ||
| 254 | before continuing to another task in bash script. | ||
| 186 | 255 | ||
| 256 | Check [Multi-Threaded Processing in Bash Scripts](https://www.cloudsavvyit.com/12277/how-to-use-multi-threaded-processing-in-bash-scripts/) | ||
| 257 | for more details. | ||
| 187 | 258 | ||
| 188 | ## Conclusion | 259 | ## Conclusion |
| 189 | 260 | ||
| 190 | Take a look at https://github.com/mitjafelicijan/dfd-rice/blob/develop/tools/install.sh script to get familiar with it. This is just a first iteration and I will continue to update it because I need this in my life. | 261 | Take a look at https://github.com/mitjafelicijan/dfd-rice/blob/develop/tools/install.sh |
| 262 | script to get familiar with it. This is just a first iteration and I will | ||
| 263 | continue to update it because I need this in my life. | ||
| 191 | 264 | ||
| 192 | The current version boots in 4s to the login prompt, and after you log in, the desktop environment loads in 2s. So, its fast, very fast. And on clean boot, I measured ~230 MB of RAM usage. | 265 | The current version boots in 4s to the login prompt, and after you log in, |
| 266 | the desktop environment loads in 2s. So, its fast, very fast. And on clean | ||
| 267 | boot, I measured ~230 MB of RAM usage. | ||
| 193 | 268 | ||
| 194 | And this is how it looks with two terminals side by side. I really like the simplicity and clean interface. I will polish the colors and stuff like that, but I really do like the results. | 269 | And this is how it looks with two terminals side by side. I really like the |
| 270 | simplicity and clean interface. I will polish the colors and stuff like that, | ||
| 271 | but I really do like the results. | ||
| 195 | 272 | ||
| 196 |  | 273 |  |
| 274 | |||
diff --git a/content/posts/2021-12-25-running-golang-application-as-pid1.md b/content/posts/2021-12-25-running-golang-application-as-pid1.md index 3d1f266..e3b7fa2 100644 --- a/content/posts/2021-12-25-running-golang-application-as-pid1.md +++ b/content/posts/2021-12-25-running-golang-application-as-pid1.md | |||
| @@ -1,43 +1,62 @@ | |||
| 1 | --- | 1 | --- |
| 2 | title: Running Golang application as PID 1 with Linux kernel | 2 | title: Running Golang application as PID 1 with Linux kernel |
| 3 | url: running-golang-application-as-pid1.html | 3 | url: running-golang-application-as-pid1.html |
| 4 | date: 2021-12-25 | 4 | date: 2021-12-25T12:00:00+02:00 |
| 5 | draft: false | 5 | draft: false |
| 6 | --- | 6 | --- |
| 7 | 7 | ||
| 8 | ## Unikernels, kernels, and alike | 8 | ## Unikernels, kernels, and alike |
| 9 | 9 | ||
| 10 | I have been reading a lot about [unikernernels](https://en.wikipedia.org/wiki/Unikernel) lately and found them very intriguing. When you push away all the marketing speak and look at the idea, it makes a lot of sense. | 10 | I have been reading a lot about [unikernernels](https://en.wikipedia.org/wiki/Unikernel) |
| 11 | lately and found them very intriguing. When you push away all the marketing | ||
| 12 | speak and look at the idea, it makes a lot of sense. | ||
| 11 | 13 | ||
| 12 | > A unikernel is a specialized, single address space machine image constructed by using library operating systems. ([Wikipedia](https://en.wikipedia.org/wiki/Unikernel)) | 14 | > A unikernel is a specialized, single address space machine image constructed |
| 15 | > by using library operating systems. ([Wikipedia](https://en.wikipedia.org/wiki/Unikernel)) | ||
| 13 | 16 | ||
| 14 | I really like the explanation from the article [Unikernels: Rise of the Virtual Library Operating System](https://queue.acm.org/detail.cfm?id=2566628). Really worth a read. | 17 | I really like the explanation from the article |
| 18 | [Unikernels: Rise of the Virtual Library Operating System](https://queue.acm.org/detail.cfm?id=2566628). | ||
| 19 | Really worth a read. | ||
| 15 | 20 | ||
| 16 | If we compare a normal operating system to a unikernel side by side, they would look something like this. | 21 | If we compare a normal operating system to a unikernel side by side, they would |
| 22 | look something like this. | ||
| 17 | 23 | ||
| 18 |  | 24 |  |
| 19 | 25 | ||
| 20 | From this image, we can see how the complexity significantly decreases with the use of Unikernels. This comes with a price, of course. Unikernels are hard to get running and require a lot of work since you don't have an actual proper kernel running in the background providing network access and drivers etc. | 26 | From this image, we can see how the complexity significantly decreases with |
| 27 | the use of Unikernels. This comes with a price, of course. Unikernels are hard | ||
| 28 | to get running and require a lot of work since you don't have an actual proper | ||
| 29 | kernel running in the background providing network access and drivers etc. | ||
| 21 | 30 | ||
| 22 | So as a half step to make the stack simpler, I started looking into using Linux kernel as a base and going from there. I came across this [Youtube video talking about Building the Simplest Possible Linux System](https://www.youtube.com/watch?v=Sk9TatW9ino) by [Rob Landley](https://landley.net) and apart from statically compiling the application to be run as PID1 there was really no other obstacles. | 31 | So as a half step to make the stack simpler, I started looking into using |
| 32 | Linux kernel as a base and going from there. I came across this | ||
| 33 | [Youtube video talking about Building the Simplest Possible Linux System](https://www.youtube.com/watch?v=Sk9TatW9ino) | ||
| 34 | by [Rob Landley](https://landley.net) and apart from statically compiling the | ||
| 35 | application to be run as PID1 there was really no other obstacles. | ||
| 23 | 36 | ||
| 24 | ## What is PID 1? | 37 | ## What is PID 1? |
| 25 | 38 | ||
| 26 | PID 1 is the first process that Linux kernel starts after the boot process. It also has a couple of unique properties that are unique to it. | 39 | PID 1 is the first process that Linux kernel starts after the boot process. |
| 40 | It also has a couple of unique properties that are unique to it. | ||
| 27 | 41 | ||
| 28 | - When the process with PID 1 dies for any reason, all other processes are killed with KILL signal. | 42 | - When the process with PID 1 dies for any reason, all other processes are |
| 29 | - When any process having children dies for any reason, its children are re-parented to process with PID 1. | 43 | killed with KILL signal. |
| 44 | - When any process having children dies for any reason, its children are | ||
| 45 | re-parented to process with PID 1. | ||
| 30 | - Many signals which have default action of Term do not have one for PID 1. | 46 | - Many signals which have default action of Term do not have one for PID 1. |
| 31 | - When the process with PID 1 dies for any reason, kernel panics, which result in system crash. | 47 | - When the process with PID 1 dies for any reason, kernel panics, which |
| 48 | result in system crash. | ||
| 32 | 49 | ||
| 33 | PID 1 is considered as an Init application which takes care of running other and handling services like: | 50 | PID 1 is considered as an Init application which takes care of running other |
| 51 | and handling services like: | ||
| 34 | 52 | ||
| 35 | - sshd, | 53 | - sshd, |
| 36 | - nginx, | 54 | - nginx, |
| 37 | - pulseaudio, | 55 | - pulseaudio, |
| 38 | - etc. | 56 | - etc. |
| 39 | 57 | ||
| 40 | If you are on a Linux machine, you can check what your process is with PID 1 by running the following. | 58 | If you are on a Linux machine, you can check what your process is with PID 1 |
| 59 | by running the following. | ||
| 41 | 60 | ||
| 42 | ```sh | 61 | ```sh |
| 43 | $ cat /proc/1/status | 62 | $ cat /proc/1/status |
| @@ -51,23 +70,34 @@ PPid: 0 | |||
| 51 | ... | 70 | ... |
| 52 | ``` | 71 | ``` |
| 53 | 72 | ||
| 54 | As we can see on my machine the process with id of 1 is [systemd](https://systemd.io/) which is a software suite that provides an array of system components for Linux operating systems. If you look closely you can also see that the `PPid` (process id of the parent process) is `0` which additionally confirms that this process doesn't have a parent. | 73 | As we can see on my machine the process with id of 1 is [systemd](https://systemd.io/) |
| 74 | which is a software suite that provides an array of system components for Linux | ||
| 75 | operating systems. If you look closely you can also see that the `PPid` | ||
| 76 | (process id of the parent process) is `0` which additionally confirms that | ||
| 77 | this process doesn't have a parent. | ||
| 55 | 78 | ||
| 56 | ## So why even run application as PID 1 instead of just using a container? | 79 | ## So why even run application as PID 1 instead of just using a container? |
| 57 | 80 | ||
| 58 | Containers are wonderful, but they come with a lot of baggage. And because they are in their nature layered, the images require quite a lot of space and also a lot of additional software to handle them. They are not as lightweight as they seem, and many popular images require 500 MB plus disk space. | 81 | Containers are wonderful, but they come with a lot of baggage. And because they |
| 82 | are in their nature layered, the images require quite a lot of space and also a | ||
| 83 | lot of additional software to handle them. They are not as lightweight as they | ||
| 84 | seem, and many popular images require 500 MB plus disk space. | ||
| 59 | 85 | ||
| 60 | The idea of running this as PID 1 would result in a significantly smaller footprint, as we will see later in the post. | 86 | The idea of running this as PID 1 would result in a significantly smaller footprint, |
| 87 | as we will see later in the post. | ||
| 61 | 88 | ||
| 62 | > You could run a simple init system inside Docker container described more in this article [Docker and the PID 1 zombie reaping problem](https://blog.phusion.nl/2015/01/20/docker-and-the-pid-1-zombie-reaping-problem/). | 89 | > You could run a simple init system inside Docker container described more |
| 90 | > in this article [Docker and the PID 1 zombie reaping problem](https://blog.phusion.nl/2015/01/20/docker-and-the-pid-1-zombie-reaping-problem/). | ||
| 63 | 91 | ||
| 64 | ## The master plan | 92 | ## The master plan |
| 65 | 93 | ||
| 66 | 1. Compile Linux kernel with the default definitions. | 94 | 1. Compile Linux kernel with the default definitions. |
| 67 | 2. Prepare a Hello World application in Golang that is statically compiled. | 95 | 2. Prepare a Hello World application in Golang that is statically compiled. |
| 68 | 3. Run it with [QEMU](https://www.qemu.org/) and providing Golang application as init application / PID 1. | 96 | 3. Run it with [QEMU](https://www.qemu.org/) and providing Golang application |
| 97 | as init application / PID 1. | ||
| 69 | 98 | ||
| 70 | For the sake of simplicity we will not be cross-compiling any of it and just use the 64bit version. | 99 | For the sake of simplicity we will not be cross-compiling any of it and just |
| 100 | use the 64bit version. | ||
| 71 | 101 | ||
| 72 | ## Compiling Linux kernel | 102 | ## Compiling Linux kernel |
| 73 | 103 | ||
| @@ -87,12 +117,15 @@ $ time make -j `nproc` | |||
| 87 | $ cd .. | 117 | $ cd .. |
| 88 | ``` | 118 | ``` |
| 89 | 119 | ||
| 90 | At this point we have kernel image that is located in `arch/x86_64/boot/bzImage`. We will use this in QEMU later. | 120 | At this point we have kernel image that is located in `arch/x86_64/boot/bzImage`. |
| 121 | We will use this in QEMU later. | ||
| 91 | 122 | ||
| 92 | To make our lives a bit easier lets move the kernel image to another place. Lets create a folder `bin/` in the root of our project with `mkdir -p bin`. | 123 | To make our lives a bit easier lets move the kernel image to another place. |
| 124 | Lets create a folder `bin/` in the root of our project with `mkdir -p bin`. | ||
| 93 | 125 | ||
| 94 | 126 | ||
| 95 | At this point we can copy `bzImage` to `bin/` folder with `cp linux-5.15.7/arch/x86_64/boot/bzImage bin/bzImage`. | 127 | At this point we can copy `bzImage` to `bin/` folder with |
| 128 | `cp linux-5.15.7/arch/x86_64/boot/bzImage bin/bzImage`. | ||
| 96 | 129 | ||
| 97 | The folder structure of this experiment should look like this. | 130 | The folder structure of this experiment should look like this. |
| 98 | 131 | ||
| @@ -106,7 +139,8 @@ pid1/ | |||
| 106 | 139 | ||
| 107 | ## Preparing PID 1 application in Golang | 140 | ## Preparing PID 1 application in Golang |
| 108 | 141 | ||
| 109 | This step is relatively easy. The only thing we must have in mind that we will need to compile the binary as a static one. | 142 | This step is relatively easy. The only thing we must have in mind that we will |
| 143 | need to compile the binary as a static one. | ||
| 110 | 144 | ||
| 111 | Let's create `init.go` file in the root of the project. | 145 | Let's create `init.go` file in the root of the project. |
| 112 | 146 | ||
| @@ -126,7 +160,9 @@ func main() { | |||
| 126 | } | 160 | } |
| 127 | ``` | 161 | ``` |
| 128 | 162 | ||
| 129 | If you notice, we have a forever loop in the main, with a simple sleep of 1 second to not overwhelm the CPU. This is because PID 1 should never complete and/or exit. That would result in a kernel panic. Which is BAD! | 163 | If you notice, we have a forever loop in the main, with a simple sleep of 1 |
| 164 | second to not overwhelm the CPU. This is because PID 1 should never complete | ||
| 165 | and/or exit. That would result in a kernel panic. Which is BAD! | ||
| 130 | 166 | ||
| 131 | There are two ways of compiling Golang application. Statically and dynamically. | 167 | There are two ways of compiling Golang application. Statically and dynamically. |
| 132 | 168 | ||
| @@ -146,7 +182,10 @@ $ ldd init | |||
| 146 | not a dynamic executable | 182 | not a dynamic executable |
| 147 | ``` | 183 | ``` |
| 148 | 184 | ||
| 149 | At this point, we need to create [initramfs](https://www.linuxfromscratch.org/blfs/view/svn/postlfs/initramfs.html) (abbreviated from "initial RAM file system", is the successor of initrd. It is a cpio archive of the initial file system that gets loaded into memory during the Linux startup process). | 185 | At this point, we need to create [initramfs](https://www.linuxfromscratch.org/blfs/view/svn/postlfs/initramfs.html) |
| 186 | (abbreviated from "initial RAM file system", is the successor of initrd. It | ||
| 187 | is a cpio archive of the initial file system that gets loaded into memory | ||
| 188 | during the Linux startup process). | ||
| 150 | 189 | ||
| 151 | ```sh | 190 | ```sh |
| 152 | $ echo init | cpio -o --format=newc > initramfs | 191 | $ echo init | cpio -o --format=newc > initramfs |
| @@ -167,7 +206,10 @@ pid1/ | |||
| 167 | 206 | ||
| 168 | ## Running all of it with QEMU | 207 | ## Running all of it with QEMU |
| 169 | 208 | ||
| 170 | [QEMU](https://www.qemu.org/) is a free and open-source hypervisor. It emulates the machine's processor through dynamic binary translation and provides a set of different hardware and device models for the machine, enabling it to run a variety of guest operating systems. | 209 | [QEMU](https://www.qemu.org/) is a free and open-source hypervisor. It emulates |
| 210 | the machine's processor through dynamic binary translation and provides a set | ||
| 211 | of different hardware and device models for the machine, enabling it to run a | ||
| 212 | variety of guest operating systems. | ||
| 171 | 213 | ||
| 172 | ```sh | 214 | ```sh |
| 173 | $ qemu-system-x86_64 -serial stdio -kernel bin/bzImage -initrd bin/initramfs -append "console=ttyS0" -m 128 | 215 | $ qemu-system-x86_64 -serial stdio -kernel bin/bzImage -initrd bin/initramfs -append "console=ttyS0" -m 128 |
| @@ -212,7 +254,12 @@ The whole [log file here](/assets/pid1/qemu.log). | |||
| 212 | 254 | ||
| 213 | ## Size comparison | 255 | ## Size comparison |
| 214 | 256 | ||
| 215 | The cool thing about this approach is that the Linux kernel and the application together only take around 12 MB, which is impressive as hell. And we need to also know that the size of bzImage (Linux kernel) could be greatly decreased by going into `make menuconfig` and removing a ton of features from the kernel, making the size even smaller. I managed to get kernel size down to 2 MB and still working properly. | 257 | The cool thing about this approach is that the Linux kernel and the application |
| 258 | together only take around 12 MB, which is impressive as hell. And we need to | ||
| 259 | also know that the size of bzImage (Linux kernel) could be greatly decreased | ||
| 260 | by going into `make menuconfig` and removing a ton of features from the kernel, | ||
| 261 | making the size even smaller. I managed to get kernel size down to 2 MB and | ||
| 262 | still working properly. | ||
| 216 | 263 | ||
| 217 | ```sh | 264 | ```sh |
| 218 | total 12M | 265 | total 12M |
| @@ -224,7 +271,8 @@ total 12M | |||
| 224 | 271 | ||
| 225 | First we need to create proper folder structure with `mkdir -p iso/boot/grub`. | 272 | First we need to create proper folder structure with `mkdir -p iso/boot/grub`. |
| 226 | 273 | ||
| 227 | Then we need to download the [grub binary](https://github.com/littleosbook/littleosbook/raw/master/files/stage2_eltorito). You can read more about this program on https://github.com/littleosbook/littleosbook. | 274 | Then we need to download the [grub binary](https://github.com/littleosbook/littleosbook/raw/master/files/stage2_eltorito). |
| 275 | You can read more about this program on https://github.com/littleosbook/littleosbook. | ||
| 228 | 276 | ||
| 229 | ```sh | 277 | ```sh |
| 230 | $ wget -O iso/boot/grub/stage2_eltorito https://github.com/littleosbook/littleosbook/raw/master/files/stage2_eltorito | 278 | $ wget -O iso/boot/grub/stage2_eltorito https://github.com/littleosbook/littleosbook/raw/master/files/stage2_eltorito |
| @@ -275,12 +323,24 @@ genisoimage -R \ | |||
| 275 | iso | 323 | iso |
| 276 | ``` | 324 | ``` |
| 277 | 325 | ||
| 278 | This will produce `GoAsPID1.iso` which you can use with [Virtualbox](https://www.virtualbox.org/) or [Gnome Boxes](https://apps.gnome.org/app/org.gnome.Boxes/). | 326 | This will produce `GoAsPID1.iso` which you can use with [Virtualbox](https://www.virtualbox.org/) |
| 327 | or [Gnome Boxes](https://apps.gnome.org/app/org.gnome.Boxes/). | ||
| 279 | 328 | ||
| 280 | <video src="/assets/pid1/boxes.mp4" controls></video> | 329 | <video src="/assets/pid1/boxes.mp4" controls></video> |
| 281 | 330 | ||
| 282 | ## Is running applications as PID 1 even worth it? | 331 | ## Is running applications as PID 1 even worth it? |
| 283 | 332 | ||
| 284 | Well, the answer to this is not as simple as one would think. Sometimes it is and sometimes it's not. For embedded systems and very specialized applications it is worth for sure. But in normal uses, I don't think so. It was an interesting exercise in compiling kernels and looking at the guts of the Linux kernel, but sticking to containers for most of the things is a better option in my opinion. | 333 | Well, the answer to this is not as simple as one would think. Sometimes it is |
| 334 | and sometimes it's not. For embedded systems and very specialized applications | ||
| 335 | it is worth for sure. But in normal uses, I don't think so. It was an interesting | ||
| 336 | exercise in compiling kernels and looking at the guts of the Linux kernel, | ||
| 337 | but sticking to containers for most of the things is a better option in my | ||
| 338 | opinion. | ||
| 339 | |||
| 340 | An interesting experiment would be creating an image that supports networking | ||
| 341 | and could be deployed to AWS as an EC2 instance and observing how it fares. | ||
| 342 | But in that case, we would need to write some sort of supervisor that would | ||
| 343 | run on a separate EC2 that would check if other EC2 instances are running | ||
| 344 | properly. Remember that if your application fails, kernel panics and the | ||
| 345 | whole machine is inoperable in this case. | ||
| 285 | 346 | ||
| 286 | An interesting experiment would be creating an image that supports networking and could be deployed to AWS as an EC2 instance and observing how it fares. But in that case, we would need to write some sort of supervisor that would run on a separate EC2 that would check if other EC2 instances are running properly. Remember that if your application fails, kernel panics and the whole machine is inoperable in this case. | ||
diff --git a/content/posts/2021-12-30-wap-mobile-web-before-the-web.md b/content/posts/2021-12-30-wap-mobile-web-before-the-web.md index 6664639..1ee82b5 100644 --- a/content/posts/2021-12-30-wap-mobile-web-before-the-web.md +++ b/content/posts/2021-12-30-wap-mobile-web-before-the-web.md | |||
| @@ -1,15 +1,24 @@ | |||
| 1 | --- | 1 | --- |
| 2 | title: Wireless Application Protocol and the mobile web before the web | 2 | title: Wireless Application Protocol and the mobile web before the web |
| 3 | url: wap-mobile-web-before-the-web.html | 3 | url: wap-mobile-web-before-the-web.html |
| 4 | date: 2021-12-30 | 4 | date: 2021-12-30T12:00:00+02:00 |
| 5 | draft: false | 5 | draft: false |
| 6 | --- | 6 | --- |
| 7 | 7 | ||
| 8 | ## A little stroll down the history lane | 8 | ## A little stroll down the history lane |
| 9 | 9 | ||
| 10 | About two weeks ago, I watched this outstanding documentary on YouTube [Springboard: the secret history of the first real smartphone](https://www.youtube.com/watch?v=b9_Vh9h3Ohw) about the history of smartphones and phones in general. It brought back so many memories. I never had an actual smartphone before the Android. The closest to smartphone was [Sony Ericsson P1](https://www.gsmarena.com/sony_ericsson_p1-1982.php). A fantastic phone and I broke it in Prague after a party and that was one of those rare occasions where I was actually mad at myself. But nevertheless, after that phone, the next one was an Android one. | 10 | About two weeks ago, I watched this outstanding documentary on YouTube |
| 11 | [Springboard: the secret history of the first real smartphone](https://www.youtube.com/watch?v=b9_Vh9h3Ohw) | ||
| 12 | about the history of smartphones and phones in general. It brought back so many | ||
| 13 | memories. I never had an actual smartphone before the Android. The closest to | ||
| 14 | smartphone was [Sony Ericsson P1](https://www.gsmarena.com/sony_ericsson_p1-1982.php). | ||
| 15 | A fantastic phone and I broke it in Prague after a party and that was one of | ||
| 16 | those rare occasions where I was actually mad at myself. But nevertheless, | ||
| 17 | after that phone, the next one was an Android one. | ||
| 11 | 18 | ||
| 12 | Before that, I only owned normal phones from Nokia and Siemens etc. Nothing special, actually. These are the phones we are talking about. Before 2007. Apple and Android phones didn't exist yet. | 19 | Before that, I only owned normal phones from Nokia and Siemens etc. Nothing |
| 20 | special, actually. These are the phones we are talking about. Before 2007. | ||
| 21 | Apple and Android phones didn't exist yet. | ||
| 13 | 22 | ||
| 14 | These phones were rocking: | 23 | These phones were rocking: |
| 15 | 24 | ||
| @@ -25,19 +34,43 @@ Let's take a look at these beauties. | |||
| 25 | 34 | ||
| 26 | ## WAP - Wireless Application Protocol | 35 | ## WAP - Wireless Application Protocol |
| 27 | 36 | ||
| 28 | Not that one! We are talking about Wireless Application Protocol and not Cardi B's song 😃 | 37 | Not that one! We are talking about Wireless Application Protocol and not |
| 38 | Cardi B's song 😃 | ||
| 29 | 39 | ||
| 30 | WAP stands for Wireless Application Protocol. It is a protocol designed for micro-browsers, and it enables the access of internet in the mobile devices. It uses the mark-up language WML (Wireless Markup Language and not HTML), WML is defined as XML 1.0 application. Furthermore, it enables creating web applications for mobile devices. In 1998, WAP Forum was founded by Ericson, Motorola, Nokia and Unwired Planet whose aim was to standardize the various wireless technologies via protocols. [(source)](https://www.geeksforgeeks.org/wireless-application-protocol/) | 40 | WAP stands for Wireless Application Protocol. It is a protocol designed for |
| 41 | micro-browsers, and it enables the access of internet in the mobile devices. | ||
| 42 | It uses the mark-up language WML (Wireless Markup Language and not HTML), WML | ||
| 43 | is defined as XML 1.0 application. Furthermore, it enables creating web | ||
| 44 | applications for mobile devices. In 1998, WAP Forum was founded by Ericson, | ||
| 45 | Motorola, Nokia and Unwired Planet whose aim was to standardize the various | ||
| 46 | wireless technologies via protocols. | ||
| 47 | [(source)](https://www.geeksforgeeks.org/wireless-application-protocol/) | ||
| 31 | 48 | ||
| 32 | WAP protocol was resulted by the joint efforts of the various members of WAP Forum. In 2002, WAP forum was merged with various other forums of the industry, resulting in the formation of Open Mobile Alliance (OMA). [(source)](https://www.geeksforgeeks.org/wireless-application-protocol/) | 49 | WAP protocol was resulted by the joint efforts of the various members of WAP |
| 50 | Forum. In 2002, WAP forum was merged with various other forums of the industry, | ||
| 51 | resulting in the formation of Open Mobile Alliance (OMA). | ||
| 52 | [(source)](https://www.geeksforgeeks.org/wireless-application-protocol/) | ||
| 33 | 53 | ||
| 34 | These were some wild times. Devices had tiny screens and data transmission rates were abominable. But they were capable of rendering WML (Wireless Markup Language). This was very similar to HTML, actually. It is a markup language, after all. | 54 | These were some wild times. Devices had tiny screens and data transmission rates |
| 55 | were abominable. But they were capable of rendering WML (Wireless Markup | ||
| 56 | Language). This was very similar to HTML, actually. It is a markup language, | ||
| 57 | after all. | ||
| 35 | 58 | ||
| 36 | These pages could be served by [Apache](https://apache.org/) and could be generated by CGI scripts on the backend. The only difference was the limited markup language. | 59 | These pages could be served by [Apache](https://apache.org/) and could be |
| 60 | generated by CGI scripts on the backend. The only difference was the limited | ||
| 61 | markup language. | ||
| 37 | 62 | ||
| 38 | ## WML - Wireless Markup Language | 63 | ## WML - Wireless Markup Language |
| 39 | 64 | ||
| 40 | Just like web browsers use HTML for content structure, older mobile device browsers use WML - if you need to support really old mobile phones using WML browsers, you will need to know about it. WML is XML-based (an XML vocabulary just like XHTML and MathML, but not HTML) and does not use the same metaphor as HTML. HTML is a single document with some metadata packed away in the head, and a body encapsulating the visible page. With WML, the metaphor does not envisage a page, but rather a deck of cards. A WML file might have several pages or cards contained within it. [(source)](https://www.w3.org/wiki/Introduction_to_mobile_web) | 65 | Just like web browsers use HTML for content structure, older mobile device |
| 66 | browsers use WML - if you need to support really old mobile phones using WML | ||
| 67 | browsers, you will need to know about it. WML is XML-based (an XML vocabulary | ||
| 68 | just like XHTML and MathML, but not HTML) and does not use the same metaphor | ||
| 69 | as HTML. HTML is a single document with some metadata packed away in the head, | ||
| 70 | and a body encapsulating the visible page. With WML, the metaphor does not | ||
| 71 | envisage a page, but rather a deck of cards. A WML file might have several | ||
| 72 | pages or cards contained within it. | ||
| 73 | [(source)](https://www.w3.org/wiki/Introduction_to_mobile_web) | ||
| 41 | 74 | ||
| 42 | ```html | 75 | ```html |
| 43 | <?xml version="1.0"?> | 76 | <?xml version="1.0"?> |
| @@ -53,7 +86,10 @@ There is an amazing tutorial on [Tutorialpoint about WML](https://www.tutorialsp | |||
| 53 | 86 | ||
| 54 | ## Converting Digg to WML | 87 | ## Converting Digg to WML |
| 55 | 88 | ||
| 56 | This task is completely useless and not really feasible nowadays, but I had to give it a try for old-time sake. Since the data is already there in a form of RSS feed, I could take this feed and parse it and create a WML version of the homepage. | 89 | This task is completely useless and not really feasible nowadays, but I had to |
| 90 | give it a try for old-time sake. Since the data is already there in a form of | ||
| 91 | RSS feed, I could take this feed and parse it and create a WML version of the | ||
| 92 | homepage. | ||
| 57 | 93 | ||
| 58 | We will need: | 94 | We will need: |
| 59 | 95 | ||
| @@ -130,17 +166,25 @@ with open('www/index.wml', 'w+') as fp: | |||
| 130 | fp.write(html) | 166 | fp.write(html) |
| 131 | ``` | 167 | ``` |
| 132 | 168 | ||
| 133 | This script will create a folder `www` and in the folder `www/images` for storing resized images. | 169 | This script will create a folder `www` and in the folder `www/images` for |
| 170 | storing resized images. | ||
| 134 | 171 | ||
| 135 | > Be sure you don't use SSL and use just normal HTTP for serving the content. These old phones will have problems with TLS 1.3 etc. | 172 | > Be sure you don't use SSL and use just normal HTTP for serving the content. |
| 173 | > These old phones will have problems with TLS 1.3 etc. | ||
| 136 | 174 | ||
| 137 | If you look at the python file, I convert all the images into tiny B&W images. They should be WBMP (Wireless BitMaP) but I choose JPEGs for this, and it seems to work properly. | 175 | If you look at the python file, I convert all the images into tiny B&W images. |
| 176 | They should be WBMP (Wireless BitMaP) but I choose JPEGs for this, and it | ||
| 177 | seems to work properly. | ||
| 138 | 178 | ||
| 139 | Because I currently don't have a phone old enough to test it on, I used an emulator. And it was really hard to find one. I found [WAP Proof](http://wap-proof.sharewarejunction.com/) on shareware junction, and it did the job well enough. I will try to find and actual device to test it on. | 179 | Because I currently don't have a phone old enough to test it on, I used an |
| 180 | emulator. And it was really hard to find one. I found [WAP Proof](http://wap-proof.sharewarejunction.com/) | ||
| 181 | on shareware junction, and it did the job well enough. I will try to find and | ||
| 182 | actual device to test it on. | ||
| 140 | 183 | ||
| 141 | <video src="/assets/wap/emulator.mp4" controls></video> | 184 | <video src="/assets/wap/emulator.mp4" controls></video> |
| 142 | 185 | ||
| 143 | If you are using Nginx to serve the contents, add a directive to the hosts file that will automatically server `index.wml` file. | 186 | If you are using Nginx to serve the contents, add a directive to the hosts file |
| 187 | that will automatically server `index.wml` file. | ||
| 144 | 188 | ||
| 145 | ```nginx | 189 | ```nginx |
| 146 | server { | 190 | server { |
| @@ -150,4 +194,7 @@ server { | |||
| 150 | 194 | ||
| 151 | ## Conclusion | 195 | ## Conclusion |
| 152 | 196 | ||
| 153 | Well, this was pointless, but very fun! I hope you enjoyed it as much as I did. I will try to find an old phone to test it on. If you have any questions, feel free to ask in the comments. | 197 | Well, this was pointless, but very fun! I hope you enjoyed it as much as I did. |
| 198 | I will try to find an old phone to test it on. If you have any questions, | ||
| 199 | feel free to ask in the comments. | ||
| 200 | |||
diff --git a/content/posts/2022-06-30-trying-out-helix-editor.md b/content/posts/2022-06-30-trying-out-helix-editor.md index 5e25980..c1da4a5 100644 --- a/content/posts/2022-06-30-trying-out-helix-editor.md +++ b/content/posts/2022-06-30-trying-out-helix-editor.md | |||
| @@ -1,31 +1,53 @@ | |||
| 1 | --- | 1 | --- |
| 2 | title: Trying out Helix code editor as my main editor | 2 | title: Trying out Helix code editor as my main editor |
| 3 | url: tying-out-helix-code-editor.html | 3 | url: tying-out-helix-code-editor.html |
| 4 | date: 2022-06-30 | 4 | date: 2022-06-30T12:00:00+02:00 |
| 5 | draft: false | 5 | draft: false |
| 6 | --- | 6 | --- |
| 7 | 7 | ||
| 8 | I have been searching for a lightweight code editor for quite some time. One of the main reasons was that I wanted something that doesn't burn through CPU and RAM usage is not through the roof. I have been mostly using Visual Studio Code. It's been an outstanding editor. I have no quarrel with it at all. It's just time to spice life up with something new. | 8 | I have been searching for a lightweight code editor for quite some time. One of |
| 9 | the main reasons was that I wanted something that doesn't burn through CPU and | ||
| 10 | RAM usage is not through the roof. I have been mostly using Visual Studio Code. | ||
| 11 | It's been an outstanding editor. I have no quarrel with it at all. It's just | ||
| 12 | time to spice life up with something new. | ||
| 9 | 13 | ||
| 10 | I have been on this search for a couple of years. I have tried Vim, Neovim, Emacs, Doom Emacs, Micro and couple more. Among most of them, I liked Micro and Doom Emacs the most. Micro editor was a little too basic for me. And Doom Emacs was a bit too hardcore. This does not reflect on any of the editors. It's just my personal preference. | 14 | I have been on this search for a couple of years. I have tried Vim, Neovim, |
| 15 | Emacs, Doom Emacs, Micro and couple more. Among most of them, I liked Micro | ||
| 16 | and Doom Emacs the most. Micro editor was a little too basic for me. And Doom | ||
| 17 | Emacs was a bit too hardcore. This does not reflect on any of the editors. It's | ||
| 18 | just my personal preference. | ||
| 11 | 19 | ||
| 12 | > I tried Helix Editor about a year ago. But I didn't pay attention to it. Tried it and saw it's similar to Vi and just said no. I was premature to dismiss it. | 20 | > I tried Helix Editor about a year ago. But I didn't pay attention to it. |
| 21 | > Tried it and saw it's similar to Vi and just said no. I was premature to | ||
| 22 | > dismiss it. | ||
| 13 | 23 | ||
| 14 | One of the things I actually miss is line wrapping for certain files. When writing Markdown, line wrapping would be very helpful. Editing such a document is frustrating to say the least. Some of the Markdown to HTML converters don't take kindly of new lines between sentences. Not paragraphs, sentences. And I use Markdown to write this blog you are reading. | 24 | One of the things I actually miss is line wrapping for certain files. When |
| 25 | writing Markdown, line wrapping would be very helpful. Editing such a document | ||
| 26 | is frustrating to say the least. Some of the Markdown to HTML converters don't | ||
| 27 | take kindly of new lines between sentences. Not paragraphs, sentences. And I | ||
| 28 | use Markdown to write this blog you are reading. | ||
| 15 | 29 | ||
| 16 | But other than this, I have been extremely satisfied by it. It's been a pleasant surprise. There have been zero issues with the editor. | 30 | But other than this, I have been extremely satisfied by it. It's been a pleasant |
| 31 | surprise. There have been zero issues with the editor. | ||
| 17 | 32 | ||
| 18 | One thing to do before you are able to use autocompletion and make use Language Server support is to install the language server with NPM. | 33 | One thing to do before you are able to use autocompletion and make use Language |
| 34 | Server support is to install the language server with NPM. | ||
| 19 | 35 | ||
| 20 | ```sh | 36 | ```sh |
| 21 | npm install -g typescript typescript-language-server | 37 | npm install -g typescript typescript-language-server |
| 22 | ``` | 38 | ``` |
| 23 | 39 | ||
| 24 | I am still getting used to the keyboard shortcuts and getting better. What Helix does really well is packing in sane defaults and even though because currently there is no plugin support I haven't found any need for them. It has all that you would need. It goes to extreme measures to show a user what is going on with popups that show you what the keyboard shortcuts are. | 40 | I am still getting used to the keyboard shortcuts and getting better. What Helix |
| 41 | does really well is packing in sane defaults and even though because currently | ||
| 42 | there is no plugin support I haven't found any need for them. It has all that | ||
| 43 | you would need. It goes to extreme measures to show a user what is going on | ||
| 44 | with popups that show you what the keyboard shortcuts are. | ||
| 25 | 45 | ||
| 26 | And it comes us packed with many [really good themes](https://github.com/helix-editor/helix/wiki/Themes). | 46 | And it comes us packed with many |
| 47 | [really good themes](https://github.com/helix-editor/helix/wiki/Themes). | ||
| 27 | 48 | ||
| 28 |  | 49 |  |
| 29 | 50 | ||
| 30 | It's still young but has this mature feeling to it. It has sane defaults and mimics Vim (works a bit differently, but the overall idea is similar). | 51 | It's still young but has this mature feeling to it. It has sane defaults and |
| 52 | mimics Vim (works a bit differently, but the overall idea is similar). | ||
| 31 | 53 | ||
diff --git a/content/posts/2022-07-05-what-would-dna-sound-if-synthesized.md b/content/posts/2022-07-05-what-would-dna-sound-if-synthesized.md index 002eb5d..15bbf2b 100644 --- a/content/posts/2022-07-05-what-would-dna-sound-if-synthesized.md +++ b/content/posts/2022-07-05-what-would-dna-sound-if-synthesized.md | |||
| @@ -1,23 +1,44 @@ | |||
| 1 | --- | 1 | --- |
| 2 | title: What would DNA sound if synthesized to an audio file | 2 | title: What would DNA sound if synthesized to an audio file |
| 3 | url: what-would-dna-sound-if-synthesized.html | 3 | url: what-would-dna-sound-if-synthesized.html |
| 4 | date: 2022-07-05 | 4 | date: 2022-07-05T12:00:00+02:00 |
| 5 | draft: false | 5 | draft: false |
| 6 | --- | 6 | --- |
| 7 | 7 | ||
| 8 | ## Introduction | 8 | ## Introduction |
| 9 | 9 | ||
| 10 | Lately, I have been thinking a lot about the nature of life, what are the foundation blocks of life and things like that. It's remarkable how complex and on the other hand simple the creation is when you look at it. The miracle of life keeps us grounded when our imagination goes wild. If the DNA are the blocks of life, you could consider them to be an API nature provided us to better understand all of this chaos masquerading as order. | 10 | Lately, I have been thinking a lot about the nature of life, what are the |
| 11 | 11 | foundation blocks of life and things like that. It's remarkable how complex | |
| 12 | I have been reading a lot about superintelligence and our somehow misguided path to create general artificial intelligence. What would the building blocks or our creation look like? Is the compression really the ultimate storage of information? Will our creation also ponder this questions when creating new worlds for themselves, or will we just disappear into the vastness of possibilities? It is a little offensive that we are playing God whilst being completely ignorant of our own reality. Who knows! Like many other breakthroughs, this one will also come at a cost not known to us when it finally happens. | 12 | and on the other hand simple the creation is when you look at it. The miracle |
| 13 | 13 | of life keeps us grounded when our imagination goes wild. If the DNA are the | |
| 14 | To keep things a bit lighter, I decided to convert some popular DNA sequences into an audio files for us to listen to. I am not the first one, nor I will be the last one to do this. But it is an interesting exercise in better understanding the relationship between art and science. Maybe listening to DNA instead of parsing it will find a way into better understanding, or at least enjoying the creation and cryptic nature of life. | 14 | blocks of life, you could consider them to be an API nature provided us to |
| 15 | better understand all of this chaos masquerading as order. | ||
| 16 | |||
| 17 | I have been reading a lot about superintelligence and our somehow misguided | ||
| 18 | path to create general artificial intelligence. What would the building blocks | ||
| 19 | or our creation look like? Is the compression really the ultimate storage of | ||
| 20 | information? Will our creation also ponder this questions when creating new | ||
| 21 | worlds for themselves, or will we just disappear into the vastness of | ||
| 22 | possibilities? It is a little offensive that we are playing God whilst being | ||
| 23 | completely ignorant of our own reality. Who knows! Like many other | ||
| 24 | breakthroughs, this one will also come at a cost not known to us when it | ||
| 25 | finally happens. | ||
| 26 | |||
| 27 | To keep things a bit lighter, I decided to convert some popular DNA sequences | ||
| 28 | into an audio files for us to listen to. I am not the first one, nor I will be | ||
| 29 | the last one to do this. But it is an interesting exercise in better | ||
| 30 | understanding the relationship between art and science. Maybe listening to DNA | ||
| 31 | instead of parsing it will find a way into better understanding, or at least | ||
| 32 | enjoying the creation and cryptic nature of life. | ||
| 15 | 33 | ||
| 16 | ## DNA encoding and primer example | 34 | ## DNA encoding and primer example |
| 17 | 35 | ||
| 18 | I have been exploring DNA in the past in my post from about 3 years ago in [Encoding binary data into DNA sequence](/encoding-binary-data-into-dna-sequence.html) where I have been converting all sorts of data into DNA sequences. | 36 | I have been exploring DNA in the past in my post from about 3 years ago in |
| 37 | [Encoding binary data into DNA sequence](/encoding-binary-data-into-dna-sequence.html) | ||
| 38 | where I have been converting all sorts of data into DNA sequences. | ||
| 19 | 39 | ||
| 20 | This will be a similar exercise but instead of converting to DNA, I will be generating tones from Nucleotides. | 40 | This will be a similar exercise but instead of converting to DNA, I will be |
| 41 | generating tones from Nucleotides. | ||
| 21 | 42 | ||
| 22 | | Nucleotides | Note | Frequency | | 43 | | Nucleotides | Note | Frequency | |
| 23 | | ---------------- | ---- | --------- | | 44 | | ---------------- | ---- | --------- | |
| @@ -28,11 +49,15 @@ This will be a similar exercise but instead of converting to DNA, I will be gene | |||
| 28 | 49 | ||
| 29 | Since we do not have T in equal-tempered scale, I choose D to represent T note. | 50 | Since we do not have T in equal-tempered scale, I choose D to represent T note. |
| 30 | 51 | ||
| 31 | You can check [Frequencies for equal-tempered scale, A4 = 440 Hz](https://pages.mtu.edu/~suits/notefreqs.html). For this tuning, we also choose `Speed of Sound = 345 m/s = 1130 ft/s = 770 miles/hr`. | 52 | You can check [Frequencies for equal-tempered scale, A4 = 440 Hz](https://pages.mtu.edu/~suits/notefreqs.html). |
| 53 | For this tuning, we also choose `Speed of Sound = 345 m/s = 1130 ft/s = 770 miles/hr`. | ||
| 32 | 54 | ||
| 33 | Now that we have this out of the way, we can also brush up on the DNA sequencing a bit. This is a famous quote I also used for the encoding tests, and it goes like this. | 55 | Now that we have this out of the way, we can also brush up on the DNA |
| 56 | sequencing a bit. This is a famous quote I also used for the encoding tests, | ||
| 57 | and it goes like this. | ||
| 34 | 58 | ||
| 35 | > How wonderful that we have met with a paradox. Now we have some hope of making progress. | 59 | > How wonderful that we have met with a paradox. Now we have some hope of |
| 60 | > making progress. | ||
| 36 | > ― Niels Bohr | 61 | > ― Niels Bohr |
| 37 | 62 | ||
| 38 | ```shell | 63 | ```shell |
| @@ -47,11 +72,16 @@ AACCTCACCAAACGGGACAAGATCGCCGGCGGGCTAGTATACAAGAACGCTTGCCAGTAC | |||
| 47 | AACC | 72 | AACC |
| 48 | ``` | 73 | ``` |
| 49 | 74 | ||
| 50 | This is what we gonna work with to get things rolling forward, when creating parser and waveform generator. | 75 | This is what we gonna work with to get things rolling forward, when creating |
| 76 | parser and waveform generator. | ||
| 51 | 77 | ||
| 52 | ## Parsing DNA data | 78 | ## Parsing DNA data |
| 53 | 79 | ||
| 54 | This step is rather simple one. All we need to do is parse input DNA sequence in [FASTA format](https://en.wikipedia.org/wiki/FASTA_format) well known in [Bioinformatics](https://en.wikipedia.org/wiki/Bioinformatics) to extract single Nucleotides that will be converted into separate tones based on equal-tempered scale explained above. | 80 | This step is rather simple one. All we need to do is parse input DNA sequence in |
| 81 | [FASTA format](https://en.wikipedia.org/wiki/FASTA_format) well known | ||
| 82 | in [Bioinformatics](https://en.wikipedia.org/wiki/Bioinformatics) to extract | ||
| 83 | single Nucleotides that will be converted into separate tones based on | ||
| 84 | equal-tempered scale explained above. | ||
| 55 | 85 | ||
| 56 | ```python | 86 | ```python |
| 57 | nucleotide_tone_map = { | 87 | nucleotide_tone_map = { |
| @@ -71,7 +101,8 @@ def generate_from_dna_sequence(sequence): | |||
| 71 | 101 | ||
| 72 | ## Generating sine wave | 102 | ## Generating sine wave |
| 73 | 103 | ||
| 74 | Because we are essentially creating a long stream of notes we will be appending sine notes to a global array we will later use for creating a WAV file out of it. | 104 | Because we are essentially creating a long stream of notes we will be appending |
| 105 | sine notes to a global array we will later use for creating a WAV file out of it. | ||
| 75 | 106 | ||
| 76 | ```python | 107 | ```python |
| 77 | import math | 108 | import math |
| @@ -87,7 +118,8 @@ def append_sinewave(freq=440.0, duration_milliseconds=500, volume=1.0): | |||
| 87 | return | 118 | return |
| 88 | ``` | 119 | ``` |
| 89 | 120 | ||
| 90 | The sine wave generated here is the standard beep. If you want something more aggressive, you could try a square or saw tooth waveform. | 121 | The sine wave generated here is the standard beep. If you want something more |
| 122 | aggressive, you could try a square or saw tooth waveform. | ||
| 91 | 123 | ||
| 92 | ## Generating a WAV file from accumulated sine waves | 124 | ## Generating a WAV file from accumulated sine waves |
| 93 | 125 | ||
| @@ -112,15 +144,23 @@ def save_wav(file_name): | |||
| 112 | wav_file.close() | 144 | wav_file.close() |
| 113 | ``` | 145 | ``` |
| 114 | 146 | ||
| 115 | 44100 is the industry standard sample rate - CD quality. If you need to save on file size, you can adjust it downwards. The standard for low quality is, 8000 or 8kHz. | 147 | 44100 is the industry standard sample rate - CD quality. If you need to save |
| 148 | on file size, you can adjust it downwards. The standard for low quality is, | ||
| 149 | 8000 or 8kHz. | ||
| 116 | 150 | ||
| 117 | WAV files here are using short, 16 bit, signed integers for the sample size. So, we multiply the floating-point data we have by 32767, the maximum value for a short integer. | 151 | WAV files here are using short, 16 bit, signed integers for the sample size. |
| 152 | So, we multiply the floating-point data we have by 32767, the maximum value | ||
| 153 | for a short integer. | ||
| 118 | 154 | ||
| 119 | > It is theoretically possible to use the floating point -1.0 to 1.0 data directly in a WAV file, but not obvious how to do that using the wave module in Python. | 155 | > It is theoretically possible to use the floating point -1.0 to 1.0 data |
| 156 | > directly in a WAV file, but not obvious how to do that using the wave module | ||
| 157 | > in Python. | ||
| 120 | 158 | ||
| 121 | ## Generating Spectograms | 159 | ## Generating Spectograms |
| 122 | 160 | ||
| 123 | I have tried two methods of doing this and both were just fine. I however opted out to use the [SoX - Sound eXchange, the Swiss Army knife of audio manipulation](https://linux.die.net/man/1/sox) one because it didn't require anything else. | 161 | I have tried two methods of doing this and both were just fine. I however opted |
| 162 | out to use the [SoX - Sound eXchange, the Swiss Army knife of audio manipulation](https://linux.die.net/man/1/sox) | ||
| 163 | one because it didn't require anything else. | ||
| 124 | 164 | ||
| 125 | ```shell | 165 | ```shell |
| 126 | sox output.wav -n spectrogram -o spectrogram.png | 166 | sox output.wav -n spectrogram -o spectrogram.png |
| @@ -134,7 +174,8 @@ An example spectrogram of Ludwig van Beethoven Symphony No. 6 First movement. | |||
| 134 | 174 | ||
| 135 |  | 175 |  |
| 136 | 176 | ||
| 137 | The other option could also be in combination with [gnuplot](http://www.gnuplot.info/). This would require an intermediary step, however. | 177 | The other option could also be in combination with [gnuplot](http://www.gnuplot.info/). |
| 178 | This would require an intermediary step, however. | ||
| 138 | 179 | ||
| 139 | ```shell | 180 | ```shell |
| 140 | sox output.wav audio.dat | 181 | sox output.wav audio.dat |
| @@ -173,7 +214,10 @@ plot "audio_only.dat" with lines lt rgb 'red' | |||
| 173 | 214 | ||
| 174 | ## Pre-generated sequences | 215 | ## Pre-generated sequences |
| 175 | 216 | ||
| 176 | What I did was take interesting parts from an animal's genome and feed it to a tone generator script. This then generated a WAV file and I converted those to MP3, so they can be played in a browser. The last step was creating a spectrogram based on a WAV file. | 217 | What I did was take interesting parts from an animal's genome and feed it to a |
| 218 | tone generator script. This then generated a WAV file and I converted those to | ||
| 219 | MP3, so they can be played in a browser. The last step was creating a | ||
| 220 | spectrogram based on a WAV file. | ||
| 177 | 221 | ||
| 178 | ### Niels Bohr quote | 222 | ### Niels Bohr quote |
| 179 | 223 | ||
| @@ -185,7 +229,8 @@ What I did was take interesting parts from an animal's genome and feed it to a t | |||
| 185 | 229 | ||
| 186 | ### Mouse | 230 | ### Mouse |
| 187 | 231 | ||
| 188 | This is part of a mouse genome `Mus_musculus.GRCm39.dna.nonchromosomal`. You can get [genom data here](http://ftp.ensembl.org/pub/release-106/fasta/mus_musculus/dna/). | 232 | This is part of a mouse genome `Mus_musculus.GRCm39.dna.nonchromosomal`. |
| 233 | You can get [genom data here](http://ftp.ensembl.org/pub/release-106/fasta/mus_musculus/dna/). | ||
| 189 | 234 | ||
| 190 | <audio controls> | 235 | <audio controls> |
| 191 | <source src="/assets/dna-synthesized/mouse/out.mp3" type="audio/mpeg"> | 236 | <source src="/assets/dna-synthesized/mouse/out.mp3" type="audio/mpeg"> |
| @@ -195,7 +240,8 @@ This is part of a mouse genome `Mus_musculus.GRCm39.dna.nonchromosomal`. You can | |||
| 195 | 240 | ||
| 196 | ### Bison | 241 | ### Bison |
| 197 | 242 | ||
| 198 | This is part of a bison genome `Bison_bison_bison.Bison_UMD1.0.cdna`. You can get [genom data here](http://ftp.ensembl.org/pub/release-106/fasta/bison_bison_bison/cdna/). | 243 | This is part of a bison genome `Bison_bison_bison.Bison_UMD1.0.cdna`. |
| 244 | You can get [genom data here](http://ftp.ensembl.org/pub/release-106/fasta/bison_bison_bison/cdna/). | ||
| 199 | 245 | ||
| 200 | <audio controls> | 246 | <audio controls> |
| 201 | <source src="/assets/dna-synthesized/bison/out.mp3" type="audio/mpeg"> | 247 | <source src="/assets/dna-synthesized/bison/out.mp3" type="audio/mpeg"> |
| @@ -205,7 +251,8 @@ This is part of a bison genome `Bison_bison_bison.Bison_UMD1.0.cdna`. You can ge | |||
| 205 | 251 | ||
| 206 | ### Taurus | 252 | ### Taurus |
| 207 | 253 | ||
| 208 | This is part of a taurus genome `Bos_taurus.ARS-UCD1.2.cdna`. You can get [genom data here](http://ftp.ensembl.org/pub/release-106/fasta/bos_taurus/cdna/). | 254 | This is part of a taurus genome `Bos_taurus.ARS-UCD1.2.cdna`. |
| 255 | You can get [genom data here](http://ftp.ensembl.org/pub/release-106/fasta/bos_taurus/cdna/). | ||
| 209 | 256 | ||
| 210 | <audio controls> | 257 | <audio controls> |
| 211 | <source src="/assets/dna-synthesized/taurus/out.mp3" type="audio/mpeg"> | 258 | <source src="/assets/dna-synthesized/taurus/out.mp3" type="audio/mpeg"> |
| @@ -215,9 +262,14 @@ This is part of a taurus genome `Bos_taurus.ARS-UCD1.2.cdna`. You can get [genom | |||
| 215 | 262 | ||
| 216 | ## Making a drummer out of a DNA sequence | 263 | ## Making a drummer out of a DNA sequence |
| 217 | 264 | ||
| 218 | To make things even more interesting, I decided to send this data via MIDI to my [Elektron Model:Samples](https://www.elektron.se/en/model-samples). This is a really cool piece of equipment that supports MIDI in via USB and 3.5 mm audio jack. | 265 | To make things even more interesting, I decided to send this data via MIDI to |
| 266 | my [Elektron Model:Samples](https://www.elektron.se/en/model-samples). This is | ||
| 267 | a really cool piece of equipment that supports MIDI in via USB and 3.5 mm | ||
| 268 | audio jack. | ||
| 219 | 269 | ||
| 220 | Elektron is connected to my MacBook via USB cable and audio out is patched to a Sony Bluetooth speaker I have that supports 3.5 mm audio in. Elektron doesn't have internal speakers. | 270 | Elektron is connected to my MacBook via USB cable and audio out is patched to |
| 271 | a Sony Bluetooth speaker I have that supports 3.5 mm audio in. Elektron | ||
| 272 | doesn't have internal speakers. | ||
| 221 | 273 | ||
| 222 |  | 274 |  |
| 223 | 275 | ||
| @@ -225,9 +277,12 @@ Elektron is connected to my MacBook via USB cable and audio out is patched to a | |||
| 225 | 277 | ||
| 226 |  | 278 |  |
| 227 | 279 | ||
| 228 | For communicating with Elektron, I choose `pygame` Python module that has MIDI built in. With this, it was rather simple to send notes to the device. All I did was map MIDI notes to the actual Nucleotides. | 280 | For communicating with Elektron, I choose `pygame` Python module that has MIDI |
| 281 | built in. With this, it was rather simple to send notes to the device. All I | ||
| 282 | did was map MIDI notes to the actual Nucleotides. | ||
| 229 | 283 | ||
| 230 | Before all of this I also checked Audio MIDI Setup app under MacOS and checked MIDI Studio by pressing ⌘-2. | 284 | Before all of this I also checked Audio MIDI Setup app under MacOS and checked |
| 285 | MIDI Studio by pressing ⌘-2. | ||
| 231 | 286 | ||
| 232 |  | 287 |  |
| 233 | 288 | ||
| @@ -273,12 +328,27 @@ pygame.midi.quit() | |||
| 273 | 328 | ||
| 274 | <video src="/assets/dna-synthesized/elektron/elektron.mp4" controls></video> | 329 | <video src="/assets/dna-synthesized/elektron/elektron.mp4" controls></video> |
| 275 | 330 | ||
| 276 | All of this could be made much more interesting if I choose different instruments for different Nucleotides, or doing more funky stuff with Elektron. But for now, this should be enough. It is just a proof of concept. Something to play around with. | 331 | All of this could be made much more interesting if I choose different |
| 332 | instruments for different Nucleotides, or doing more funky stuff with Elektron. | ||
| 333 | But for now, this should be enough. It is just a proof of concept. Something | ||
| 334 | to play around with. | ||
| 277 | 335 | ||
| 278 | ## Going even further | 336 | ## Going even further |
| 279 | 337 | ||
| 280 | As you probably notice, the end results are quite similar to each other. This is to be expected because we are operating only with 4 notes essentially. What could make this more interesting is using something like [Supercollider](https://supercollider.github.io/) to create more interesting sounds. By transposing notes or using effects based on repeated data in a sequence. Possibilities are endless. | 338 | As you probably notice, the end results are quite similar to each other. This |
| 339 | is to be expected because we are operating only with 4 notes essentially. What | ||
| 340 | could make this more interesting is using something like [Supercollider](https://supercollider.github.io/) | ||
| 341 | to create more interesting sounds. By transposing notes or using effects based | ||
| 342 | on repeated data in a sequence. Possibilities are endless. | ||
| 343 | |||
| 344 | It is really astonishing what can be achieved with a little bit of code and an | ||
| 345 | idea. I could see this becoming an interesting background soundscape instrument | ||
| 346 | if done properly. It could replace random note generator with something more | ||
| 347 | intriguing, biological, natural. | ||
| 281 | 348 | ||
| 282 | It is really astonishing what can be achieved with a little bit of code and an idea. I could see this becoming an interesting background soundscape instrument if done properly. It could replace random note generator with something more intriguing, biological, natural. | 349 | I actually find the results fascinating. I took some time and listened to this |
| 350 | music of nature. Even though it's quite the same, it's also quite different. | ||
| 351 | The subtle differences on repeat kind of creates music on its own. Makes you | ||
| 352 | wonder. It kind of puts Occam’s Razor in its place. Nature for sure loves to | ||
| 353 | make things as energy efficient as possible. | ||
| 283 | 354 | ||
| 284 | I actually find the results fascinating. I took some time and listened to this music of nature. Even though it's quite the same, it's also quite different. The subtle differences on repeat kind of creates music on its own. Makes you wonder. It kind of puts Occam’s Razor in its place. Nature for sure loves to make things as energy efficient as possible. | ||
diff --git a/content/posts/2022-08-13-algae-spotted-on-river-sava.md b/content/posts/2022-08-13-algae-spotted-on-river-sava.md index 40b960f..faa2df1 100644 --- a/content/posts/2022-08-13-algae-spotted-on-river-sava.md +++ b/content/posts/2022-08-13-algae-spotted-on-river-sava.md | |||
| @@ -1,11 +1,15 @@ | |||
| 1 | --- | 1 | --- |
| 2 | title: Aerial photography of algae spotted on river Sava | 2 | title: Aerial photography of algae spotted on river Sava |
| 3 | url: aerial-photography-of-algae-spotted-on-river-sava.html | 3 | url: aerial-photography-of-algae-spotted-on-river-sava.html |
| 4 | date: 2022-08-13 | 4 | date: 2022-08-13T12:00:00+02:00 |
| 5 | draft: false | 5 | draft: false |
| 6 | --- | 6 | --- |
| 7 | 7 | ||
| 8 | This is a bit of a different post than I usually write, but quite interesting one to me. River Sava has plenty of hydropower plants located down the stream. This makes regulating the strength of a current easier than normally. Because of lower stream strength and high temperatures, algae has formed on the river. This is the first time I've seen something like this in my whole life. | 8 | This is a bit of a different post than I usually write, but quite interesting |
| 9 | one to me. River Sava has plenty of hydropower plants located down the stream. | ||
| 10 | This makes regulating the strength of a current easier than normally. Because | ||
| 11 | of lower stream strength and high temperatures, algae has formed on the river. | ||
| 12 | This is the first time I've seen something like this in my whole life. | ||
| 9 | 13 | ||
| 10 | Below are some photographs taken from a DJI drone capturing the event. | 14 | Below are some photographs taken from a DJI drone capturing the event. |
| 11 | 15 | ||
| @@ -21,4 +25,6 @@ Below are some photographs taken from a DJI drone capturing the event. | |||
| 21 | 25 | ||
| 22 |  | 26 |  |
| 23 | 27 | ||
| 24 | I will try to get more photos of this in the future days and if something intriguing shows up will post it again on the blog. | 28 | I will try to get more photos of this in the future days and if something |
| 29 | intriguing shows up will post it again on the blog. | ||
| 30 | |||
diff --git a/content/posts/2022-10-06-state-of-web-technologies-in-year-2022.md b/content/posts/2022-10-06-state-of-web-technologies-in-year-2022.md index 6e5f938..120dcae 100644 --- a/content/posts/2022-10-06-state-of-web-technologies-in-year-2022.md +++ b/content/posts/2022-10-06-state-of-web-technologies-in-year-2022.md | |||
| @@ -1,126 +1,303 @@ | |||
| 1 | --- | 1 | --- |
| 2 | title: State of Web Technologies and Web development in year 2022 | 2 | title: State of Web Technologies and Web development in year 2022 |
| 3 | url: state-of-web-technologies-and-web-development-in-year-2022.html | 3 | url: state-of-web-technologies-and-web-development-in-year-2022.html |
| 4 | date: 2022-10-06 | 4 | date: 2022-10-06T12:00:00+02:00 |
| 5 | draft: false | 5 | draft: false |
| 6 | --- | 6 | --- |
| 7 | 7 | ||
| 8 | ## Initial thoughts | 8 | ## Initial thoughts |
| 9 | 9 | ||
| 10 | *This post is a critique on the current state of web development. It is an opinionated post! I will learn more about this in the future, and probably slightly change my mind about some of the things I criticize.* | 10 | *This post is a critique on the current state of web development. It is an |
| 11 | opinionated post! I will learn more about this in the future, and probably | ||
| 12 | slightly change my mind about some of the things I criticize.* | ||
| 11 | 13 | ||
| 12 | I have started working on a hobby project about two weeks ago, and I wanted to use that situation as a learning one. Trying new things, new technologies, new tools. I always considered myself to be an adventurous person when it comes to technology. I never shy away from trying new languages, new operating systems etc. Likewise, I find the whole experience satisfying, and it tickles that part of my brain that finds discovery the highest of the mountains to climb. | 14 | I have started working on a hobby project about two weeks ago, and I wanted to |
| 15 | use that situation as a learning one. Trying new things, new technologies, new | ||
| 16 | tools. I always considered myself to be an adventurous person when it comes to | ||
| 17 | technology. I never shy away from trying new languages, new operating systems | ||
| 18 | etc. Likewise, I find the whole experience satisfying, and it tickles that part | ||
| 19 | of my brain that finds discovery the highest of the mountains to climb. | ||
| 13 | 20 | ||
| 14 | What I always wanted to make was a coding game, that you would play in a browser (just to eliminate building binaries for each operating system) where you would level up your character and go into these scriptable battles. You know, RPG elements. | 21 | What I always wanted to make was a coding game, that you would play in a |
| 22 | browser (just to eliminate building binaries for each operating system) where | ||
| 23 | you would level up your character and go into these scriptable battles. You | ||
| 24 | know, RPG elements. | ||
| 15 | 25 | ||
| 16 | So, the natural way to go would be some sort of SPA (single page application) with basic routing and some state management. Nothing crazy. | 26 | So, the natural way to go would be some sort of SPA (single page application) |
| 27 | with basic routing and some state management. Nothing crazy. | ||
| 17 | 28 | ||
| 18 | > **Before we move on**, I have to be transparent. Take my views on this with a grain of salt. I have only scratched the surface with these technologies, and my knowledge is full of gaps. This is my experience using some of these products for the first time or in a limited capacity. | 29 | > **Before we move on**, I have to be transparent. Take my views on this with |
| 19 | > | 30 | > a grain of salt. I have only scratched the surface with these technologies, |
| 31 | > and my knowledge is full of gaps. This is my experience using some of these | ||
| 32 | > products for the first time or in a limited capacity. | ||
| 20 | 33 | ||
| 21 | Having this out of the way, I got myself a fresh pot of coffee and down the rabbit hole I went. | 34 | Having this out of the way, I got myself a fresh pot of coffee and down the |
| 35 | rabbit hole I went. | ||
| 22 | 36 | ||
| 23 | ## Giving React JS a spin | 37 | ## Giving React JS a spin |
| 24 | 38 | ||
| 25 | I first tried [React JS](https://reactjs.org/). I kind of like it. Furthermore, I have worked with libraries like this in the past and also wrote a couple of them (nothing compared to that level), but I had the basic understanding of what was going on. I rolled up a project quickly and had basic things done in a matter of two hours, which was impressive. | 39 | I first tried [React JS](https://reactjs.org/). I kind of like it. Furthermore, |
| 26 | 40 | I have worked with libraries like this in the past and also wrote a couple of | |
| 27 | I prefer using [Tailwind CSS](https://tailwindcss.com/) for my styling pleasures, and integrating that was also a painless experience. It was actually nice to see that some things got better with time. In about 2 minutes I got Tailwind working, and I was able to use classes at my disposal. All that `postcss` stuff was taken care of by adding a couple of things in config files (all described really well in their documentation). | 41 | them (nothing compared to that level), but I had the basic understanding of |
| 28 | 42 | what was going on. I rolled up a project quickly and had basic things done in | |
| 29 | It is not that different from Vue which I have had more encounters with in the past People will probably call me a lunatic for saying this. But you know, it is the truth. Same same, but different. I still believe that using libraries like this is beneficial. I am not a JavaScript purist. They all have their quirks, but at the end of the day, I truly believe it’s worth it. | 43 | a matter of two hours, which was impressive. |
| 44 | |||
| 45 | I prefer using [Tailwind CSS](https://tailwindcss.com/) for my styling | ||
| 46 | pleasures, and integrating that was also a painless experience. It was actually | ||
| 47 | nice to see that some things got better with time. In about 2 minutes I got | ||
| 48 | Tailwind working, and I was able to use classes at my disposal. All that | ||
| 49 | `postcss` stuff was taken care of by adding a couple of things in config files | ||
| 50 | (all described really well in their documentation). | ||
| 51 | |||
| 52 | It is not that different from Vue which I have had more encounters with in the | ||
| 53 | past People will probably call me a lunatic for saying this. But you know, it | ||
| 54 | is the truth. Same same, but different. I still believe that using libraries | ||
| 55 | like this is beneficial. I am not a JavaScript purist. They all have their | ||
| 56 | quirks, but at the end of the day, I truly believe it’s worth it. | ||
| 30 | 57 | ||
| 31 | ## Bundlers and Transpilers | 58 | ## Bundlers and Transpilers |
| 32 | 59 | ||
| 33 | I still reject calling [Typescript](https://www.typescriptlang.org/) to [JavaScript](https://www.javascript.com/) conversion a "compilation process". I call them [transpilers](https://devopedia.org/transpiler), and I don’t care! 😈 | 60 | I still reject calling [Typescript](https://www.typescriptlang.org/) to |
| 61 | [JavaScript](https://www.javascript.com/) conversion a "compilation process". | ||
| 62 | I call them [transpilers](https://devopedia.org/transpiler), and I don’t care! 😈 | ||
| 34 | 63 | ||
| 35 | And if you want to fight this, take a look at this little chart and be mad at it! | 64 | And if you want to fight this, take a look at this little chart and be mad at it! |
| 36 | 65 | ||
| 37 |  | 66 |  |
| 38 | 67 | ||
| 39 | The first one that I ever used was [webpack](https://webpack.js.org/), and it was an absolute horrific experience. Saying this, it is an absolutely fantastic tool. I felt more like a config editor than actually a programmer. To be fair, I am a huge fan of [make](https://www.gnu.org/software/make/), and you can do as you wish with this information. I like my build systems simple. | 68 | The first one that I ever used was [webpack](https://webpack.js.org/), and it |
| 40 | 69 | was an absolute horrific experience. Saying this, it is an absolutely | |
| 41 | Also, isn’t it interesting that we need something like [Babel](https://babeljs.io/) to make JavaScript code work in a browser that has only one client side scripting available, which is by no accident also JavaScript. Why? I know why it’s needed, but seriously, why. | 70 | fantastic tool. I felt more like a config editor than actually a programmer. |
| 42 | 71 | To be fair, I am a huge fan of [make](https://www.gnu.org/software/make/), | |
| 43 | I haven’t used Babel for years now. Or if I did, it was packaged together by some other bundler thingy. Which does not make things better, but at least I didn’t need to worry about it. | 72 | and you can do as you wish with this information. I like my build systems |
| 44 | 73 | simple. | |
| 45 | I really don’t like complicated build systems. I really don’t like abstracting code and making things appear magical. The older I get, the more I appreciate clear and clean, expressive code. No one-liners, if possible. | 74 | |
| 46 | 75 | Also, isn’t it interesting that we need something like [Babel](https://babeljs.io/) | |
| 47 | But I have to give props to [Vite](https://vitejs.dev/)! This was one of the best developer experiences I have ever had. Granted, it still has magical properties. And yes, it still is a bundler and abstracts things to the nth degree. But at least it didn’t force me to configure 700 lines of JSON. And I know that this makes me a hypocrite. You can’t have it all. Nonetheless, my reasoning here is, if using bundlers is inevitable, then at least they should provide an excellent developer experience. | 76 | to make JavaScript code work in a browser that has only one client side |
| 48 | 77 | scripting available, which is by no accident also JavaScript. Why? I know | |
| 49 | I also noticed that now the catch-all phrase is “blazingly fast” and “lightning fast” and “next generation” and stuff like that. I mean, yeah, tools should get faster with time. But saying that starting a project now takes 2 seconds instead of 20 seconds is something that is a break it or make it kind of a deal is ridiculous. I don’t mind waiting a couple of seconds every couple of days. I also don’t create 700 projects every day, and also who does? This argument has no bite. All I want is a decent reload time (~100ms is more than good enough for me) and that is it. | 78 | why it’s needed, but seriously, why. |
| 50 | 79 | ||
| 51 | You don’t need to sell me benefits if I only get them when I start a fresh project, and then try to convince me that this is somehow changing the fate of the universe. First of all, it is not. And second, if this is your only argument for your tool, I would advise you to maybe re-focus your efforts to something else. Vite says that startup times are really fast. And if that would be the only thing differentiating it from other tools, I would ignore it. But it has some really compelling features like [Hot Module Replacement](https://www.geeksforgeeks.org/reactjs-hot-module-replacement/) that really works well. It was a joy to use. | 80 | I haven’t used Babel for years now. Or if I did, it was packaged together by |
| 81 | some other bundler thingy. Which does not make things better, but at least | ||
| 82 | I didn’t need to worry about it. | ||
| 83 | |||
| 84 | I really don’t like complicated build systems. I really don’t like abstracting | ||
| 85 | code and making things appear magical. The older I get, the more I appreciate | ||
| 86 | clear and clean, expressive code. No one-liners, if possible. | ||
| 87 | |||
| 88 | But I have to give props to [Vite](https://vitejs.dev/)! This was one of the | ||
| 89 | best developer experiences I have ever had. Granted, it still has magical | ||
| 90 | properties. And yes, it still is a bundler and abstracts things to the nth | ||
| 91 | degree. But at least it didn’t force me to configure 700 lines of JSON. And | ||
| 92 | I know that this makes me a hypocrite. You can’t have it all. Nonetheless, | ||
| 93 | my reasoning here is, if using bundlers is inevitable, then at least they | ||
| 94 | should provide an excellent developer experience. | ||
| 95 | |||
| 96 | I also noticed that now the catch-all phrase is “blazingly fast” and | ||
| 97 | “lightning fast” and “next generation” and stuff like that. I mean, yeah, | ||
| 98 | tools should get faster with time. But saying that starting a project now takes | ||
| 99 | 2 seconds instead of 20 seconds is something that is a break it or make it kind | ||
| 100 | of a deal is ridiculous. I don’t mind waiting a couple of seconds every couple | ||
| 101 | of days. I also don’t create 700 projects every day, and also who does? This | ||
| 102 | argument has no bite. All I want is a decent reload time (~100ms is more than | ||
| 103 | good enough for me) and that is it. | ||
| 104 | |||
| 105 | You don’t need to sell me benefits if I only get them when I start a fresh | ||
| 106 | project, and then try to convince me that this is somehow changing the fate | ||
| 107 | of the universe. First of all, it is not. And second, if this is your only | ||
| 108 | argument for your tool, I would advise you to maybe re-focus your efforts to | ||
| 109 | something else. Vite says that startup times are really fast. And if that | ||
| 110 | would be the only thing differentiating it from other tools, I would ignore | ||
| 111 | it. But it has some really compelling features like | ||
| 112 | [Hot Module Replacement](https://www.geeksforgeeks.org/reactjs-hot-module-replacement/) | ||
| 113 | that really works well. It was a joy to use. | ||
| 52 | 114 | ||
| 53 | So, I will be definitely using Vite in the future. | 115 | So, I will be definitely using Vite in the future. |
| 54 | 116 | ||
| 55 | ## Jam Stack, Mach Stack no snack | 117 | ## Jam Stack, Mach Stack no snack |
| 56 | 118 | ||
| 57 | Let's get a couple of the acronyms out of the way, so we all know what we are talking about: | 119 | Let's get a couple of the acronyms out of the way, so we all know what we are |
| 120 | talking about: | ||
| 58 | 121 | ||
| 59 | - Jam Stack - JavaScript, API and Markup | 122 | - Jam Stack - JavaScript, API and Markup |
| 60 | - Mach Stack - Microservices, API-first, Cloud-Native SaaS, Headless | 123 | - Mach Stack - Microservices, API-first, Cloud-Native SaaS, Headless |
| 61 | 124 | ||
| 62 | It is so hard to follow all these new trendy things happening around you, that it makes you have a massive **FOMO** all the time. But on the other hand, you also don’t want to be that old fart that doesn’t move with the times and still writes his trusty jQuery code while listening to Blink 182 All the small things on full blast. It’s a good song, don’t get me wrong, but there are other songs out there. | 125 | It is so hard to follow all these new trendy things happening around you, that |
| 63 | 126 | it makes you have a massive **FOMO** all the time. But on the other hand, you | |
| 64 | I have to admit. [Vercel](https://vercel.com/) is really cool! Love the simplicity of the service. You could compare it to [Netlify](https://www.netlify.com/). I haven’t tried Netlify extensively, but from a couple of experimental deployments I still prefer Vercel. It is much more streamlined, but maybe this is bias in me. I really like Vercel’s Analytics, which give you a [Core Web Vitals report](https://web.dev/vitals/) in their admin console. Kind of cool, I’m not going to lie. | 127 | also don’t want to be that old fart that doesn’t move with the times and still |
| 65 | 128 | writes his trusty jQuery code while listening to Blink 182 All the small things | |
| 66 | This whole idea about frontend and backend merging into [SSR (server-side rendering)](https://www.debugbear.com/blog/server-side-rendering) looks so good on paper. It almost doesn’t come with any major flaws. | 129 | on full blast. It’s a good song, don’t get me wrong, but there are other songs |
| 67 | 130 | out there. | |
| 68 | But when it comes to the actual implementation, there is much to be desired. I’m going to lump [Next.js](https://nextjs.org/) and [Nuxt.js](https://nuxtjs.org/) together because they are essentially the same thing, just a different library. | 131 | |
| 69 | 132 | I have to admit. [Vercel](https://vercel.com/) is really cool! Love the | |
| 70 | Now comes the reality. Mixing backend and frontend in this manner creates this weird mental model where you kind of rely on magical properties of these libraries. You relinquish control over to them for better developer experience. But is that really true? Initially, I was so stoked about it. However, the more I used them, the more I felt uncomfortable. I felt dirty, actually. Maybe this is because I come from old ways of doing things where you control every step of request, and allowing something to hijack it feels like blasphemy. | 133 | simplicity of the service. You could compare it to [Netlify](https://www.netlify.com/). |
| 71 | 134 | I haven’t tried Netlify extensively, but from a couple of experimental | |
| 72 | More than that, some pretty significant technical issues arose from this. How do you do JWT token authentication? You put it in `api` folder and then do some fetching and storing into local state management. But doing this also requires some tinkering with await/async stuff on the React/Vue side of things. And then you need to write middleware for it. And the more I look at it, the more I see that this whole thing was not meant to be used like this, and it all feels and looks like a huge hack. | 135 | deployments I still prefer Vercel. It is much more streamlined, but maybe this |
| 73 | 136 | is bias in me. I really like Vercel’s Analytics, which give you a | |
| 74 | The issue I have with this is that they over-promise and under-deliver. They want to be an all-in-one replacement for everything, and they don’t deliver on this promise. And how could they?! We have to be fair. It is an impossible task. | 137 | [Core Web Vitals report](https://web.dev/vitals/) in their admin console. Kind |
| 75 | 138 | of cool, I’m not going to lie. | |
| 76 | They sell you [NoOps](https://www.geeksforgeeks.org/overview-of-noops/), but when you need to accomplish something a little bit more out of the scope of Hello World, you have to make hacky decisions to make it work. And having a deployment strategy that relies on many moving parts is never a good idea. Abstracting too much is usually a sign of bad architecture. | 139 | |
| 77 | 140 | This whole idea about frontend and backend merging into [SSR (server-side rendering)](https://www.debugbear.com/blog/server-side-rendering) | |
| 78 | Lately, this has become a huge trend that will for sure bite us in the future. And let’s not get it twisted. By doing this, PaaS providers like [AWS](https://aws.amazon.com/), [GCS](https://cloud.google.com/), etc. obscure their billing, and you end up paying more than you really should. And even if that is not an issue, it comes down to the principle of things. AWS is known for having multiple “currencies“ inside their projects like write operations, read operations, etc. which add up, and it creates this impossible to track billing scheme. It all behaves suspiciously like a pay-to-win game you could find on mobile phones that scams you out of your money. | 141 | looks so good on paper. It almost doesn’t come with any major flaws. |
| 79 | 142 | ||
| 80 | And as far as I am concerned, the most important thing was me not coding the functionalities for the game I want to make. I was battling libraries and cloud providers. How to deploy, what settings are relevant. Bad documentation or multiple versions of achieving the same thing. You are getting bombarded by all this information, and you don’t really have any control over it. Production-ready code becomes a joke, essentially. Especially if you tend to work on that project for a prolonged period of time. | 143 | But when it comes to the actual implementation, there is much to be desired. |
| 81 | 144 | I’m going to lump [Next.js](https://nextjs.org/) and [Nuxt.js](https://nuxtjs.org/) | |
| 82 | All of these options end up creating a fatigue. What to choose, what not to choose. Unnecessary worrying about if the stack will still be deemed worthy in six months. There is elegance in simplicity. | 145 | together because they are essentially the same thing, just a different library. |
| 83 | 146 | ||
| 84 | > JavaScript UI frameworks and libraries work in cycles. Every six months or so, a new one pops up, claiming that it has revolutionized UI development. Thousands of developers adopt it into their new projects, blog posts are written, Stack Overflow questions are asked and answered, and then a newer (and even more revolutionary) framework pops up to usurp the throne. — Ian Allen | 147 | Now comes the reality. Mixing backend and frontend in this manner creates this |
| 148 | weird mental model where you kind of rely on magical properties of these | ||
| 149 | libraries. You relinquish control over to them for better developer experience. | ||
| 150 | But is that really true? Initially, I was so stoked about it. However, the | ||
| 151 | more I used them, the more I felt uncomfortable. I felt dirty, actually. Maybe | ||
| 152 | this is because I come from old ways of doing things where you control every | ||
| 153 | step of request, and allowing something to hijack it feels like blasphemy. | ||
| 154 | |||
| 155 | More than that, some pretty significant technical issues arose from this. How | ||
| 156 | do you do JWT token authentication? You put it in `api` folder and then do some | ||
| 157 | fetching and storing into local state management. But doing this also requires | ||
| 158 | some tinkering with await/async stuff on the React/Vue side of things. And then | ||
| 159 | you need to write middleware for it. And the more I look at it, the more I see | ||
| 160 | that this whole thing was not meant to be used like this, and it all feels and | ||
| 161 | looks like a huge hack. | ||
| 162 | |||
| 163 | The issue I have with this is that they over-promise and under-deliver. They | ||
| 164 | want to be an all-in-one replacement for everything, and they don’t deliver | ||
| 165 | on this promise. And how could they?! We have to be fair. It is an impossible | ||
| 166 | task. | ||
| 167 | |||
| 168 | They sell you [NoOps](https://www.geeksforgeeks.org/overview-of-noops/), but | ||
| 169 | when you need to accomplish something a little bit more out of the scope of | ||
| 170 | Hello World, you have to make hacky decisions to make it work. And having a | ||
| 171 | deployment strategy that relies on many moving parts is never a good idea. | ||
| 172 | Abstracting too much is usually a sign of bad architecture. | ||
| 173 | |||
| 174 | Lately, this has become a huge trend that will for sure bite us in the future. | ||
| 175 | And let’s not get it twisted. By doing this, PaaS providers like | ||
| 176 | [AWS](https://aws.amazon.com/), [GCS](https://cloud.google.com/), etc. obscure | ||
| 177 | their billing, and you end up paying more than you really should. And even if | ||
| 178 | that is not an issue, it comes down to the principle of things. AWS is known | ||
| 179 | for having multiple “currencies“ inside their projects like write operations, | ||
| 180 | read operations, etc. which add up, and it creates this impossible to track | ||
| 181 | billing scheme. It all behaves suspiciously like a pay-to-win game you could | ||
| 182 | find on mobile phones that scams you out of your money. | ||
| 183 | |||
| 184 | And as far as I am concerned, the most important thing was me not coding the | ||
| 185 | functionalities for the game I want to make. I was battling libraries and | ||
| 186 | cloud providers. How to deploy, what settings are relevant. Bad documentation | ||
| 187 | or multiple versions of achieving the same thing. You are getting bombarded | ||
| 188 | by all this information, and you don’t really have any control over it. | ||
| 189 | Production-ready code becomes a joke, essentially. Especially if you tend to | ||
| 190 | work on that project for a prolonged period of time. | ||
| 191 | |||
| 192 | All of these options end up creating a fatigue. What to choose, what not to | ||
| 193 | choose. Unnecessary worrying about if the stack will still be deemed worthy | ||
| 194 | in six months. There is elegance in simplicity. | ||
| 195 | |||
| 196 | > JavaScript UI frameworks and libraries work in cycles. Every six months or | ||
| 197 | > so, a new one pops up, claiming that it has revolutionized UI development. | ||
| 198 | > Thousands of developers adopt it into their new projects, blog posts are | ||
| 199 | > written, Stack Overflow questions are asked and answered, and then a newer | ||
| 200 | > (and even more revolutionary) framework pops up to usurp the throne. | ||
| 201 | > — Ian Allen | ||
| 85 | 202 | ||
| 86 |  | 203 |  |
| 87 | 204 | ||
| 88 | And this jab at these libraries and cloud providers is not done out of malice. It is a real concern that I have about them. In my life, I have seen technologies come and go, but the basics always stick around. So surrendering all the power you have to a library or a cloud provider is in my opinion a stupid move. | 205 | And this jab at these libraries and cloud providers is not done out of malice. |
| 206 | It is a real concern that I have about them. In my life, I have seen | ||
| 207 | technologies come and go, but the basics always stick around. So surrendering | ||
| 208 | all the power you have to a library or a cloud provider is in my opinion a | ||
| 209 | stupid move. | ||
| 89 | 210 | ||
| 90 | ## Tailwind CSS still rocks! | 211 | ## Tailwind CSS still rocks! |
| 91 | 212 | ||
| 92 | You know, many people say negative things about Tailwind. And after a lot of deliberation, I came to the conclusion that Tailwind is good for two types of developers. Tailwind is good for a complete noob or a senior developer. A complete noob doesn’t really care about inner workings of CSS, and a senior developer also doesn’t care about CSS. Well, at least, not anymore. And developers in between usually have the biggest issues with it. Not always of course, but in a lot of cases. | 213 | You know, many people say negative things about Tailwind. And after a lot of |
| 93 | 214 | deliberation, I came to the conclusion that Tailwind is good for two types of | |
| 94 | I like the creature comforts of Tailwind. Being utility first would make me argue that it is actually more similar to [Sass](https://sass-lang.com/) or [Less](https://lesscss.org/) than something like Bootstrap. Not technically, but ideologically. After I started using it, I never looked back. I use it every time I need to do something web related. | 215 | developers. Tailwind is good for a complete noob or a senior developer. A |
| 95 | 216 | complete noob doesn’t really care about inner workings of CSS, and a senior | |
| 96 | Writing CSS for general things feels like going several steps back. Instead of focusing on what you are actually trying to achieve, you focus on notations like [BEM](https://en.bem.info/methodology/css/), code structuring, optimizing HTML size. Just doing things that make 0.1% difference. You know that saying: Early optimization is the root of all evil. Exactly that. | 217 | developer also doesn’t care about CSS. Well, at least, not anymore. And |
| 97 | 218 | developers in between usually have the biggest issues with it. Not always of | |
| 98 | I am also not saying that Tailwind is the cure for everything. Sometimes custom CSS is necessary. But from what I found out in using it for almost two years in a production environment (on a site getting quite a lot of traffic and constantly being changed), I can say without any reservations that Tailwind saved our asses countless times. We would be rewriting CSS all the time without it. And I don’t really think writing CSS is the best way to spend my time. | 219 | course, but in a lot of cases. |
| 99 | 220 | ||
| 100 | I have also noticed that people who criticize Tailwind the most never actually used it in a real project that has a long lifetime with plenty of changes that will happen in the future. | 221 | I like the creature comforts of Tailwind. Being utility first would make me |
| 222 | argue that it is actually more similar to [Sass](https://sass-lang.com/) or | ||
| 223 | [Less](https://lesscss.org/) than something like Bootstrap. Not technically, | ||
| 224 | but ideologically. After I started using it, I never looked back. I use it | ||
| 225 | every time I need to do something web related. | ||
| 226 | |||
| 227 | Writing CSS for general things feels like going several steps back. Instead of | ||
| 228 | focusing on what you are actually trying to achieve, you focus on notations | ||
| 229 | like [BEM](https://en.bem.info/methodology/css/), code structuring, optimizing | ||
| 230 | HTML size. Just doing things that make 0.1% difference. You know that saying: | ||
| 231 | Early optimization is the root of all evil. Exactly that. | ||
| 232 | |||
| 233 | I am also not saying that Tailwind is the cure for everything. Sometimes custom | ||
| 234 | CSS is necessary. But from what I found out in using it for almost two years | ||
| 235 | in a production environment (on a site getting quite a lot of traffic and | ||
| 236 | constantly being changed), I can say without any reservations that Tailwind | ||
| 237 | saved our asses countless times. We would be rewriting CSS all the time without | ||
| 238 | it. And I don’t really think writing CSS is the best way to spend my time. | ||
| 239 | |||
| 240 | I have also noticed that people who criticize Tailwind the most never actually | ||
| 241 | used it in a real project that has a long lifetime with plenty of changes that | ||
| 242 | will happen in the future. | ||
| 101 | 243 | ||
| 102 | But you know, whatever floats your boat! | 244 | But you know, whatever floats your boat! |
| 103 | 245 | ||
| 104 | ## Code maintainability | 246 | ## Code maintainability |
| 105 | 247 | ||
| 106 | Somehow, people also stopped talking about maintenance. If you constantly try to catch the latest and greatest train, you are by that logic always trying new things. Which is a good thing if you want to learn about technologies and try them. But for the production environment, you have to have a stable stack that doesn’t change every 6 months. | 248 | Somehow, people also stopped talking about maintenance. If you constantly try |
| 249 | to catch the latest and greatest train, you are by that logic always trying | ||
| 250 | new things. Which is a good thing if you want to learn about technologies and | ||
| 251 | try them. But for the production environment, you have to have a stable stack | ||
| 252 | that doesn’t change every 6 months. | ||
| 107 | 253 | ||
| 108 | You can lock dependencies for sure. Nevertheless, the hype train moves along anyway. And the mindset this breeds goes against locking the code. This bleeding-edge rolling release cycle is not helping. That is why enterprise solutions usually look down on these popular stacks and only do bare minimum to appear hip and cool. | 254 | You can lock dependencies for sure. Nevertheless, the hype train moves along |
| 255 | anyway. And the mindset this breeds goes against locking the code. This | ||
| 256 | bleeding-edge rolling release cycle is not helping. That is why enterprise | ||
| 257 | solutions usually look down on these popular stacks and only do bare minimum to | ||
| 258 | appear hip and cool. | ||
| 109 | 259 | ||
| 110 | With that said, I still think that progress is good, but should be taken with a grain of salt. If your project is something that should be built once and then rarely updated, going with the latest stack is a possible way to go. But, if you are working on a project that lasts for years, you should probably approach it with some level of caution. Web development is often times too volatile. | 260 | With that said, I still think that progress is good, but should be taken with a |
| 261 | grain of salt. If your project is something that should be built once and then | ||
| 262 | rarely updated, going with the latest stack is a possible way to go. But, if | ||
| 263 | you are working on a project that lasts for years, you should probably approach | ||
| 264 | it with some level of caution. Web development is often times too volatile. | ||
| 111 | 265 | ||
| 112 | ## Web development has a marketing issue | 266 | ## Web development has a marketing issue |
| 113 | 267 | ||
| 114 | I noticed that almost every project now has this marketing spin put on it. Everything is blazingly fast now. I get it, they are competing for your attention, but what happened to just being truthful and not inflating reality. | 268 | I noticed that almost every project now has this marketing spin put on it. |
| 269 | Everything is blazingly fast now. I get it, they are competing for your | ||
| 270 | attention, but what happened to just being truthful and not inflating reality. | ||
| 115 | 271 | ||
| 116 | And in order to appeal to mass market, they leave things out of their marketing materials. These open-source projects are now behaving more and more like companies do. Which is a scary thought on its self. | 272 | And in order to appeal to mass market, they leave things out of their marketing |
| 273 | materials. These open-source projects are now behaving more and more like | ||
| 274 | companies do. Which is a scary thought on its self. | ||
| 117 | 275 | ||
| 118 | And we are also seeing a rise in a concept of building a company in the open, which is a good thing, don't get me wrong. But when it is using open-source to lure people and then lock them in their ecosystem, there is where I have issues with it. | 276 | And we are also seeing a rise in a concept of building a company in the open, |
| 277 | which is a good thing, don't get me wrong. But when it is using open-source to | ||
| 278 | lure people and then lock them in their ecosystem, there is where I have issues | ||
| 279 | with it. | ||
| 119 | 280 | ||
| 120 | This might be because I have been using GNU/Linux for 20 years now and have been so beholden for my success to open-source that I see issues when open-source is being used to trick people into a false sense of security that these projects are built in the spirit of open-source. Because there is a difference. They are NOT! They have a really specific goal in mind. And the open-source is being used as a delivery system. Which is in my opinion disgusting! | 281 | This might be because I have been using GNU/Linux for 20 years now and have |
| 282 | been so beholden for my success to open-source that I see issues when | ||
| 283 | open-source is being used to trick people into a false sense of security that | ||
| 284 | these projects are built in the spirit of open-source. Because there is a | ||
| 285 | difference. They are NOT! They have a really specific goal in mind. And the | ||
| 286 | open-source is being used as a delivery system. Which is in my opinion | ||
| 287 | disgusting! | ||
| 121 | 288 | ||
| 122 | ## Conclusion | 289 | ## Conclusion |
| 123 | 290 | ||
| 124 | I will end my post with this. Web development is running now in circles. People are discovering [RPC](https://www.tutorialspoint.com/remote-procedure-call-rpc) now and this is the now the next big thing. [GraphQL](https://graphql.org/) is so passé. And I am so tired of it all. Of blazingly fast libraries, of all these new technologies that are actually just a remake of old ones. Of just the general spirit of the web. I will just use what I already know. Which worked 10 years ago and will work 10 years after this. I will adopt a couple of little tools like Vite. But I will not waste my time on this anymore. | 291 | I will end my post with this. Web development is running now in circles. People |
| 292 | are discovering [RPC](https://www.tutorialspoint.com/remote-procedure-call-rpc) | ||
| 293 | now and this is the now the next big thing. [GraphQL](https://graphql.org/) is | ||
| 294 | so passé. And I am so tired of it all. Of blazingly fast libraries, of all | ||
| 295 | these new technologies that are actually just a remake of old ones. Of just | ||
| 296 | the general spirit of the web. I will just use what I already know. Which worked | ||
| 297 | 10 years ago and will work 10 years after this. I will adopt a couple of | ||
| 298 | little tools like Vite. But I will not waste my time on this anymore. | ||
| 299 | |||
| 300 | It was a good exercise to get in touch with what’s new now. Nothing really | ||
| 301 | changed that much. FOMO is now cured! Now I have to get my ass back to actually | ||
| 302 | code and make the project that I wanted to make in the first place. | ||
| 125 | 303 | ||
| 126 | It was a good exercise to get in touch with what’s new now. Nothing really changed that much. FOMO is now cured! Now I have to get my ass back to actually code and make the project that I wanted to make in the first place. | ||
diff --git a/content/posts/2022-10-10-sentiment-based-on-political-bias.md b/content/posts/2022-10-10-sentiment-based-on-political-bias.md deleted file mode 100644 index fc03a5e..0000000 --- a/content/posts/2022-10-10-sentiment-based-on-political-bias.md +++ /dev/null | |||
| @@ -1,84 +0,0 @@ | |||
| 1 | --- | ||
| 2 | title: Sentiment distribution analysis based on political bias in online publications | ||
| 3 | url: sentiment-based-on-political-bias.html | ||
| 4 | date: 2022-10-10 | ||
| 5 | draft: true | ||
| 6 | --- | ||
| 7 | |||
| 8 | I have been wondering for a long time what would sentiment differences look based on political leaning from popular publications. Is it the left that is more optimistic, center or the right. | ||
| 9 | |||
| 10 | > **Before people loose their minds**, I don't care about political stuff in the context of this post and this is data we are talking about and not my personal feelings about it. So, before saying anything have this in mind and let data speak for itself. | ||
| 11 | |||
| 12 | ## Preparing the data | ||
| 13 | |||
| 14 | The first step in getting stories from publications so we can start doing sentiment analysis on it. I have chosen to select 30 publications. 10 from left leaning publications, 10 from centre and 10 from right leaning ones. | ||
| 15 | |||
| 16 | To find out leaning of a publication I will defer to AllSides website which provide a [Media Bias Ratings](https://www.allsides.com/media-bias/ratings). | ||
| 17 | |||
| 18 |  | ||
| 19 | |||
| 20 | The chart above is taken from AllSides and demonstrates political leaning of publications. This data changes over time and AllSides have made the revisions publicly available on their website. | ||
| 21 | |||
| 22 | - [Learn more about Version 6](https://www.allsides.com/blog/new-allsides-media-bias-chart-version-6-updated-ratings-npr-newsmax-and-more) | ||
| 23 | - [Learn more about Version 5](https://www.allsides.com/blog/new-allsides-media-bias-chart-version-42) | ||
| 24 | - [Learn about Version 4](https://www.allsides.com/blog/new-allsides-media-bias-chart-announcing-version-4) | ||
| 25 | - [Learn about Version 3](https://www.allsides.com/blog/new-allsides-media-bias-chart-version-3) | ||
| 26 | - [Learn about Version 2](https://www.allsides.com/blog/new-allsides-media-bias-chart-version-2-updated-media-bias-ratings) | ||
| 27 | - [Learn about Version 1.1](https://www.allsides.com/blog/updated-allsides-media-bias-chart-version-11) | ||
| 28 | - [Learn about Version 1](https://www.allsides.com/blog/introducing-allsides-media-bias-chart) | ||
| 29 | |||
| 30 | |||
| 31 | They categorise political bias AllSides came up with is: | ||
| 32 | |||
| 33 | TODO: CREATE A HORIZONTAL ARRAY STYLE OF CHART IMAGE | ||
| 34 | |||
| 35 | - Left, | ||
| 36 | - Lean Left, | ||
| 37 | - Center, | ||
| 38 | - Lean Right, | ||
| 39 | - Right. | ||
| 40 | |||
| 41 | I will group Left and Lean Left together. And the same goes for Lean Right and Right. So we end up with three groups [Left, Center, Right]. | ||
| 42 | |||
| 43 | The list I have ended up with contains these publications: | ||
| 44 | |||
| 45 | - Left political bias: | ||
| 46 | - BuzzFeed News (https://www.buzzfeednews.com) | ||
| 47 | - CNN (https://cnn.com) | ||
| 48 | - Daily Beast (https://www.thedailybeast.com) | ||
| 49 | - HuffPost (https://www.huffpost.com) | ||
| 50 | - The Intercept (https://theintercept.com) | ||
| 51 | - Vox (https://www.vox.com) | ||
| 52 | - Slate (https://slate.com) | ||
| 53 | - The New Yorker (https://www.newyorker.com) | ||
| 54 | - MSNBC (https://www.msnbc.com) | ||
| 55 | - New York Times News (https://www.nytimes.com) | ||
| 56 | - Center political "bias": | ||
| 57 | - Axios (https://www.axios.com) | ||
| 58 | - BBC (https://www.bbc.com) | ||
| 59 | - News Week (https://www.newsweek.com) | ||
| 60 | - Reuters (https://www.reuters.com) | ||
| 61 | - RealClear Politics (https://www.realclearpolitics.com) | ||
| 62 | - The Hill (https://thehill.com) | ||
| 63 | - The Wall Street Journal News(https://www.wsj.com) | ||
| 64 | - Associated Press News (https://apnews.com) | ||
| 65 | - CNET (https://www.cnet.com) | ||
| 66 | - Forbes (https://www.forbes.com) | ||
| 67 | - Right political bias: | ||
| 68 | - The American Spectator (https://spectator.org) | ||
| 69 | - Breitbart News (http://www.breitbart.com) | ||
| 70 | - The Blaze (https://www.theblaze.com) | ||
| 71 | - Daily Caller (http://dailycaller.com) | ||
| 72 | - Daily Mail (https://www.dailymail.co.uk) | ||
| 73 | - The Daily Wire (https://www.dailywire.com) | ||
| 74 | - Fox News (https://www.foxnews.com) | ||
| 75 | - The Federalist (https://thefederalist.com) | ||
| 76 | - New York Post Opinion (https://nypost.com/opinion/) | ||
| 77 | - OANN (https://www.oann.com) | ||
| 78 | |||
| 79 | |||
| 80 | |||
| 81 | |||
| 82 | |||
| 83 | |||
| 84 | |||
diff --git a/content/posts/2022-10-11-handling-massive-worlds-in-godot.md b/content/posts/2022-10-11-handling-massive-worlds-in-godot.md deleted file mode 100644 index 0fa30e8..0000000 --- a/content/posts/2022-10-11-handling-massive-worlds-in-godot.md +++ /dev/null | |||
| @@ -1,82 +0,0 @@ | |||
| 1 | --- | ||
| 2 | title: Handling big worlds in Godot by splitting and lazy loading chunks of it | ||
| 3 | url: handling-big-worlds-in-godot.html | ||
| 4 | date: 2022-10-11 | ||
| 5 | draft: true | ||
| 6 | --- | ||
| 7 | |||
| 8 | Because these examples are exported from **Godot to WebAssembly** and the packaging produces **large files**, you will need to **click to lazy load them** | ||
| 9 | |||
| 10 | I have seen a couple of examples on the net, but never really a comprehensive guide how this would be achieved. My solution is nowhere perfect, but it will get you started. This code is also not optimized, so buyer beware. | ||
| 11 | |||
| 12 | For the sake of simplicity, I will keep the terrain plain. I have been working on a terrain generation tool in my spare time, but due to the other obligations, that project was put on the back burner. If you however interested in it you can check it out on my personal Git repository [https://git.mitjafelicijan.com/village-creator.git/](https://git.mitjafelicijan.com/village-creator.git/). | ||
| 13 | |||
| 14 |  | ||
| 15 | |||
| 16 | It's using a node system to generate a terrain mesh, and it's utilizing cellular automata for special effects like sand erosion and wind erosion, etc. Example of using cellular automata rule in an image below. | ||
| 17 | |||
| 18 |  | ||
| 19 | |||
| 20 | As I mentioned previously, still far away from being useful. Always, enough about that. Let’s move on to the topic of this post. | ||
| 21 | |||
| 22 | ## Handling lazy loading in 2D world | ||
| 23 | |||
| 24 | To simplify things, we will try doing in 2D world first. It makes for a simpler exercise and eliminates a lot of complexity that comes with additional axis. | ||
| 25 | |||
| 26 | ### Player movement | ||
| 27 | |||
| 28 | First, we need to take care of player movement. I will not go into many details here, since there are plenty of good tutorials on this topic on the interwebs. Suffice it to say, I created a [KinematicBody2D](https://docs.godotengine.org/en/stable/classes/class_kinematicbody2d.html) node that gives us goodies like `move_and_slide` and added input maps for [move_up, move_down, move_right, move_left] movement. | ||
| 29 | |||
| 30 | ```gdscript | ||
| 31 | # Player2D.gd | ||
| 32 | |||
| 33 | extends KinematicBody2D | ||
| 34 | |||
| 35 | # Exported variables. | ||
| 36 | export var speed = 300 | ||
| 37 | |||
| 38 | # Utility variables for later use. | ||
| 39 | # Can be ignored for now. | ||
| 40 | export var player_scale = 1 | ||
| 41 | export var camera_zoom = 1 | ||
| 42 | |||
| 43 | # Internal variables. | ||
| 44 | var velocity = Vector2.ZERO | ||
| 45 | |||
| 46 | func _ready(): | ||
| 47 | # Can be ignored for now. | ||
| 48 | $Model.scale = Vector2(player_scale, player_scale) | ||
| 49 | $Camera.zoom = Vector2(camera_zoom, camera_zoom) | ||
| 50 | |||
| 51 | # Executes on every physics frame (60, 144, etc). | ||
| 52 | # This game has vsync enabled. | ||
| 53 | func _physics_process(delta): | ||
| 54 | handle_player_movement() | ||
| 55 | |||
| 56 | # Handles player movement. | ||
| 57 | func handle_player_movement(): | ||
| 58 | velocity = Vector2.ZERO | ||
| 59 | if Input.is_action_pressed('move_right'): | ||
| 60 | velocity.x += 1 | ||
| 61 | if Input.is_action_pressed('move_left'): | ||
| 62 | velocity.x -= 1 | ||
| 63 | if Input.is_action_pressed('move_down'): | ||
| 64 | velocity.y += 1 | ||
| 65 | if Input.is_action_pressed('move_up'): | ||
| 66 | velocity.y -= 1 | ||
| 67 | |||
| 68 | # Make sure diagonal movement isn't faster. | ||
| 69 | # Therefore vector needs to be normalized. | ||
| 70 | velocity = velocity.normalized() * speed | ||
| 71 | velocity = move_and_slide(velocity) | ||
| 72 | ``` | ||
| 73 | |||
| 74 | [Read more about vector normalization.](https://www.fundza.com/vectors/normalize/) | ||
| 75 | |||
| 76 | `$Model` is just a sprite loaded and positioned into the scene. For the background, I again loaded just a normal sprite and positioned it to center. This makes it easier to test if the movement is working properly. Background will be removed when we will start dynamically loading the world. | ||
| 77 | |||
| 78 | <video src="/assets/godot-dynamic-tile-loading/2d-player-movement.webm" controls></video> | ||
| 79 | |||
| 80 | Code for player movement can be [downloaded from my Git server](https://git.mitjafelicijan.com/big-worlds-godot.git/snapshot/big-worlds-godot-55bcad79c11bd67e8268925d7edbf571aa31e3bf.zip). | ||
| 81 | |||
| 82 | <!--<div class="ll-iframe w-full h-80" data-src="/assets/godot-dynamic-tile-loading/example1/"></div>--> | ||
diff --git a/content/posts/2022-10-16-that-sound-that-machine-makes-when-struggling.md b/content/posts/2022-10-16-that-sound-that-machine-makes-when-struggling.md index dccf6b4..2739764 100644 --- a/content/posts/2022-10-16-that-sound-that-machine-makes-when-struggling.md +++ b/content/posts/2022-10-16-that-sound-that-machine-makes-when-struggling.md | |||
| @@ -1,44 +1,64 @@ | |||
| 1 | --- | 1 | --- |
| 2 | title: Microsoundtrack — That sound that machine makes when struggling | 2 | title: Microsoundtrack — That sound that machine makes when struggling |
| 3 | url: that-sound-that-machine-makes-when-struggling.html | 3 | url: that-sound-that-machine-makes-when-struggling.html |
| 4 | date: 2022-10-16 | 4 | date: 2022-10-16T12:00:00+02:00 |
| 5 | draft: false | 5 | draft: false |
| 6 | --- | 6 | --- |
| 7 | 7 | ||
| 8 | A couple of months ago, I got an idea about micro soundtracks. In this concept, you are the observer, director, and audience in this tiny movies. | 8 | A couple of months ago, I got an idea about micro soundtracks. In this concept, |
| 9 | you are the observer, director, and audience in this tiny movies. | ||
| 9 | 10 | ||
| 10 | What you do is to attempt to imagine what would be happening around you based on a title of the song and let the song help you fill the void in your story. | 11 | What you do is to attempt to imagine what would be happening around you based |
| 12 | on a title of the song and let the song help you fill the void in your story. | ||
| 11 | 13 | ||
| 12 | I made these songs is Logic Pro X. Every year or so I do this kind of thing and make a couple of songs similar to this. But this is the first time I am posting about it. | 14 | I made these songs is Logic Pro X. Every year or so I do this kind of thing |
| 15 | and make a couple of songs similar to this. But this is the first time I am | ||
| 16 | posting about it. | ||
| 13 | 17 | ||
| 14 | You can listen to the whole set on [Youtube](https://www.youtube.com/watch?v=_5oXBhSmF3c) or scroll down the page and there are embedded players for each song. | 18 | You can listen to the whole set on [Youtube](https://www.youtube.com/watch?v=_5oXBhSmF3c) |
| 19 | or scroll down the page and there are embedded players for each song. | ||
| 15 | 20 | ||
| 16 | ## A bunch of inter-dimensional people with loud clocks | 21 | ## A bunch of inter-dimensional people with loud clocks |
| 17 | 22 | ||
| 18 | A group of inter-dimensional people are going up and down the elevator with you while having loud clocks around their necks. Each clock ticks on a different frequency. A lot of other sounds are getting drawn into your dimension, resulting in a strange merging of dimensions. | 23 | A group of inter-dimensional people are going up and down the elevator with |
| 24 | you while having loud clocks around their necks. Each clock ticks on a different | ||
| 25 | frequency. A lot of other sounds are getting drawn into your dimension, | ||
| 26 | resulting in a strange merging of dimensions. | ||
| 19 | 27 | ||
| 20 | <iframe style="border: 0; width: 100%; height: 42px;" src="https://bandcamp.com/EmbeddedPlayer/album=3913808801/size=small/bgcol=ffffff/linkcol=0687f5/track=1349272965/transparent=true/" seamless title="Bandcamp"><a href="https://mitjafelicijan.bandcamp.com/album/that-sound-that-machine-makes-when-struggling">That sound that machine makes when struggling by Mitja Felicijan</a></iframe> | 28 | <iframe style="border: 0; width: 100%; height: 42px;" src="https://bandcamp.com/EmbeddedPlayer/album=3913808801/size=small/bgcol=ffffff/linkcol=0687f5/track=1349272965/transparent=true/" seamless title="Bandcamp"><a href="https://mitjafelicijan.bandcamp.com/album/that-sound-that-machine-makes-when-struggling">That sound that machine makes when struggling by Mitja Felicijan</a></iframe> |
| 21 | 29 | ||
| 22 | ## Two black holes conversing about the weather | 30 | ## Two black holes conversing about the weather |
| 23 | 31 | ||
| 24 | You are a traveler in a spaceship flying very close to two colliding black holes having a discussion about the weather while tearing each other apart. During all this your ship is getting pulled into the event horizon of both black holes, putting a lot of strain on your spaceship. | 32 | You are a traveler in a spaceship flying very close to two colliding black holes |
| 33 | having a discussion about the weather while tearing each other apart. During | ||
| 34 | all this your ship is getting pulled into the event horizon of both black | ||
| 35 | holes, putting a lot of strain on your spaceship. | ||
| 25 | 36 | ||
| 26 | <iframe style="border: 0; width: 100%; height: 42px;" src="https://bandcamp.com/EmbeddedPlayer/album=3913808801/size=small/bgcol=ffffff/linkcol=0687f5/track=1756714200/transparent=true/" seamless title="Bandcamp"><a href="https://mitjafelicijan.bandcamp.com/album/that-sound-that-machine-makes-when-struggling">That sound that machine makes when struggling by Mitja Felicijan</a></iframe> | 37 | <iframe style="border: 0; width: 100%; height: 42px;" src="https://bandcamp.com/EmbeddedPlayer/album=3913808801/size=small/bgcol=ffffff/linkcol=0687f5/track=1756714200/transparent=true/" seamless title="Bandcamp"><a href="https://mitjafelicijan.bandcamp.com/album/that-sound-that-machine-makes-when-struggling">That sound that machine makes when struggling by Mitja Felicijan</a></iframe> |
| 27 | 38 | ||
| 28 | ## A planet where every organism is a plant | 39 | ## A planet where every organism is a plant |
| 29 | 40 | ||
| 30 | You land on a planet where every living organism is a plant and among those plants some of them are highly intelligent, and you were asked to make first contact with the native species. Your visit takes place in a giant cave where you are meeting these plants, and they are talking to you. | 41 | You land on a planet where every living organism is a plant and among those |
| 42 | plants some of them are highly intelligent, and you were asked to make first | ||
| 43 | contact with the native species. Your visit takes place in a giant cave where | ||
| 44 | you are meeting these plants, and they are talking to you. | ||
| 31 | 45 | ||
| 32 | <iframe style="border: 0; width: 100%; height: 42px;" src="https://bandcamp.com/EmbeddedPlayer/album=3913808801/size=small/bgcol=ffffff/linkcol=0687f5/track=3710973979/transparent=true/" seamless title="Bandcamp"><a href="https://mitjafelicijan.bandcamp.com/album/that-sound-that-machine-makes-when-struggling">That sound that machine makes when struggling by Mitja Felicijan</a></iframe> | 46 | <iframe style="border: 0; width: 100%; height: 42px;" src="https://bandcamp.com/EmbeddedPlayer/album=3913808801/size=small/bgcol=ffffff/linkcol=0687f5/track=3710973979/transparent=true/" seamless title="Bandcamp"><a href="https://mitjafelicijan.bandcamp.com/album/that-sound-that-machine-makes-when-struggling">That sound that machine makes when struggling by Mitja Felicijan</a></iframe> |
| 33 | 47 | ||
| 34 | ## Bio implants having a fit and reprogramming your brain | 48 | ## Bio implants having a fit and reprogramming your brain |
| 35 | 49 | ||
| 36 | In a distant future where everybody has bio implants, you have just received your first one, which happens to be a brain implant. Something goes wrong, and your implant is starting to misbehave, and you are experiencing brain malfunctions. You are on the streets at night a couple of hours after your procedure. You can feel your sanity breaking down. | 50 | In a distant future where everybody has bio implants, you have just received |
| 51 | your first one, which happens to be a brain implant. Something goes wrong, | ||
| 52 | and your implant is starting to misbehave, and you are experiencing brain | ||
| 53 | malfunctions. You are on the streets at night a couple of hours after your | ||
| 54 | procedure. You can feel your sanity breaking down. | ||
| 37 | 55 | ||
| 38 | <iframe style="border: 0; width: 100%; height: 42px;" src="https://bandcamp.com/EmbeddedPlayer/album=3913808801/size=small/bgcol=ffffff/linkcol=0687f5/track=1157430581/transparent=true/" seamless title="Bandcamp"><a href="https://mitjafelicijan.bandcamp.com/album/that-sound-that-machine-makes-when-struggling">That sound that machine makes when struggling by Mitja Felicijan</a></iframe> | 56 | <iframe style="border: 0; width: 100%; height: 42px;" src="https://bandcamp.com/EmbeddedPlayer/album=3913808801/size=small/bgcol=ffffff/linkcol=0687f5/track=1157430581/transparent=true/" seamless title="Bandcamp"><a href="https://mitjafelicijan.bandcamp.com/album/that-sound-that-machine-makes-when-struggling">That sound that machine makes when struggling by Mitja Felicijan</a></iframe> |
| 39 | 57 | ||
| 40 | ## Cow animation | 58 | ## Cow animation |
| 41 | 59 | ||
| 42 | I also made this little cow animation. Go into full screen to see the effects in more details. | 60 | I also made this little cow animation. Go into full screen to see the effects |
| 61 | in more details. | ||
| 43 | 62 | ||
| 44 | <video src="/assets/microsoundtrack/cow.m4v" controls loop></video> | 63 | <video src="/assets/microsoundtrack/cow.m4v" controls loop></video> |
| 64 | |||
diff --git a/content/posts/2023-01-26-trying-to-build-a-new-kind-of-terminal-emulator.md b/content/posts/2023-01-26-trying-to-build-a-new-kind-of-terminal-emulator.md index 03fcc59..4ec307f 100644 --- a/content/posts/2023-01-26-trying-to-build-a-new-kind-of-terminal-emulator.md +++ b/content/posts/2023-01-26-trying-to-build-a-new-kind-of-terminal-emulator.md | |||
| @@ -1,15 +1,36 @@ | |||
| 1 | --- | 1 | --- |
| 2 | title: Trying to build a New kind of terminal emulator for the modern age | 2 | title: Trying to build a New kind of terminal emulator for the modern age |
| 3 | url: trying-to-build-a-new-kind-of-terminal-emulator.html | 3 | url: trying-to-build-a-new-kind-of-terminal-emulator.html |
| 4 | date: 2023-01-26 | 4 | date: 2023-01-26T12:00:00+02:00 |
| 5 | draft: false | 5 | draft: false |
| 6 | --- | 6 | --- |
| 7 | 7 | ||
| 8 | Over the past few weeks, I have been really thinking about terminal emulators, how we interact with computers, the separation of text-based programs and GUI ones. To be perfectly honest, I got pissed off one evening when I was cleaning up files on my computer. Normally, I go into console and do `ncdu` and check where the junk is. Then I start deleting stuff. Without any discrimination, usually. But when it comes to screenshots, I have learned that it's good to keep them somewhere near if I need to refer to something that I was doing. I am an avid screenshot taker. So at that point I checked Pictures folder and also did a basic search `find . -type f -name "*.jpg"` for all the JPEG files in my home directory and immediately got pissed off. Why can’t I see thumbnails in my terminal? I know why, but why in the year of 2022 this is still a problem. I am used to traversing my disk via terminal. I am faster, and I am more comfortable this way. But when it comes to visualization, I then need to revert to GUI applications and again find the same file to see it. I know that programs like `feh` and `sxiv` are available, but I would just like to see the preview. Like [Jupyter notebook](https://jupyter.org/) or something similar. Just having it inline. Part of a result. | 8 | Over the past few weeks, I have been really thinking about terminal emulators, |
| 9 | 9 | how we interact with computers, the separation of text-based programs and GUI | |
| 10 | It also didn’t help that I was spending some time with the [Plan 9](https://plan9.io/plan9/) Operating system. More specifically [9FRONT](http://9front.org/). The way that [ACME editor](http://acme.cat-v.org/) handles text editing is just wonderful. Different and fresh somehow, even though it’s super old. | 10 | ones. To be perfectly honest, I got pissed off one evening when I was cleaning |
| 11 | 11 | up files on my computer. Normally, I go into console and do `ncdu` and check | |
| 12 | So, I went on a lookout for an interesting way of visualizing results of some query. I found these applications to be outstanding examples of how not to be a captive of a predetermined way of doing things. | 12 | where the junk is. Then I start deleting stuff. Without any discrimination, |
| 13 | usually. But when it comes to screenshots, I have learned that it's good to | ||
| 14 | keep them somewhere near if I need to refer to something that I was doing. I | ||
| 15 | am an avid screenshot taker. So at that point I checked Pictures folder and | ||
| 16 | also did a basic search `find . -type f -name "*.jpg"` for all the JPEG files | ||
| 17 | in my home directory and immediately got pissed off. Why can’t I see thumbnails | ||
| 18 | in my terminal? I know why, but why in the year of 2022 this is still a | ||
| 19 | problem. I am used to traversing my disk via terminal. I am faster, and I am | ||
| 20 | more comfortable this way. But when it comes to visualization, I then need to | ||
| 21 | revert to GUI applications and again find the same file to see it. I know that | ||
| 22 | programs like `feh` and `sxiv` are available, but I would just like to see the | ||
| 23 | preview. Like [Jupyter notebook](https://jupyter.org/) or something similar. | ||
| 24 | Just having it inline. Part of a result. | ||
| 25 | |||
| 26 | It also didn’t help that I was spending some time with the [Plan 9](https://plan9.io/plan9/) | ||
| 27 | Operating system. More specifically [9FRONT](http://9front.org/). The way | ||
| 28 | that [ACME editor](http://acme.cat-v.org/) handles text editing is just | ||
| 29 | wonderful. Different and fresh somehow, even though it’s super old. | ||
| 30 | |||
| 31 | So, I went on a lookout for an interesting way of visualizing results of some | ||
| 32 | query. I found these applications to be outstanding examples of how not to be | ||
| 33 | a captive of a predetermined way of doing things. | ||
| 13 | 34 | ||
| 14 | - [Wolfram Mathematica](https://www.wolfram.com/mathematica/) | 35 | - [Wolfram Mathematica](https://www.wolfram.com/mathematica/) |
| 15 | - [Jupyter notebooks](https://jupyter.org/) | 36 | - [Jupyter notebooks](https://jupyter.org/) |
| @@ -17,29 +38,57 @@ So, I went on a lookout for an interesting way of visualizing results of some qu | |||
| 17 | - [Temple OS](https://templeos.org/) | 38 | - [Temple OS](https://templeos.org/) |
| 18 | - [Emacs](https://www.gnu.org/software/emacs/) | 39 | - [Emacs](https://www.gnu.org/software/emacs/) |
| 19 | 40 | ||
| 20 | My idea is not as out there as ACME is, but it is a spin on the terminal emulators. I like the modes that Vi/Vim provides you with. I like the way the Emacs does its own `M-x` `M-c`. Furthermore, I really like how Mathematica and Jupyter present the data in a free flowing form. And I love how Temple OS is basically a C interpreter on some level. | 41 | My idea is not as out there as ACME is, but it is a spin on the terminal |
| 42 | emulators. I like the modes that Vi/Vim provides you with. I like the way | ||
| 43 | the Emacs does its own `M-x` `M-c`. Furthermore, I really like how Mathematica | ||
| 44 | and Jupyter present the data in a free flowing form. And I love how Temple OS | ||
| 45 | is basically a C interpreter on some level. | ||
| 21 | 46 | ||
| 22 | > **Note:** This is part 1 of the journey. Nowhere finished yet. I am just tinkering with this at the moment. This whole thing can easily spectacularly fail. | 47 | > **Note:** This is part 1 of the journey. Nowhere finished yet. I am just |
| 23 | > | 48 | > tinkering with this at the moment. This whole thing can easily spectacularly |
| 49 | > fail. | ||
| 24 | 50 | ||
| 25 | So I started. I knew that I wanted to have the couple of modes, but I didn’t like the repetition of keystrokes, so the only option was to have some sort of toggle and indicate to the user that they are in a special mode. Like Vi does for Normal and Visual mode. | 51 | So I started. I knew that I wanted to have the couple of modes, but I didn’t |
| 52 | like the repetition of keystrokes, so the only option was to have some sort of | ||
| 53 | toggle and indicate to the user that they are in a special mode. Like Vi does | ||
| 54 | for Normal and Visual mode. | ||
| 26 | 55 | ||
| 27 | These modes would for the first version be: | 56 | These modes would for the first version be: |
| 28 | 57 | ||
| 29 | - *Preview mode* (toggle with Ctrl + P) | 58 | - *Preview mode* (toggle with Ctrl + P) |
| 30 | - When this mode would be enabled, the `ls` command would try to find images from the results and display thumbnails from them in the terminal itself. No ASCII art. Proper images. In a grid! | 59 | - When this mode would be enabled, the `ls` command would try to find images |
| 60 | from the results and display thumbnails from them in the terminal itself. | ||
| 61 | No ASCII art. Proper images. In a grid! | ||
| 31 | - *Detach mode* (toggle with Ctrl + D) | 62 | - *Detach mode* (toggle with Ctrl + D) |
| 32 | - When this mode would be enabled, every command would open a new window and execute that command in it. This would be useful for starting `htop` in a separate window. | 63 | - When this mode would be enabled, every command would open a new window |
| 33 | 64 | and execute that command in it. This would be useful for starting `htop` | |
| 34 | The reason for having these modes togglable is to not ask for previews every time. You enable a mode and until you disable it, it behaves that way. Purely out of ergonomic reasons. | 65 | in a separate window. |
| 35 | 66 | ||
| 36 | I would like to treat every terminal I open as a session mentally. When I start using the terminal, I start digging deeper into the issue I am trying to resolve. And while I am doing this, I would like to open detached windows etc. A lot of these things can be done easily with something like [i3](https://i3wm.org/), but also that pull you out of the context of what you were doing. I would like to orchestrate everything from one single point. | 67 | The reason for having these modes togglable is to not ask for previews every |
| 37 | 68 | time. You enable a mode and until you disable it, it behaves that way. | |
| 38 | In planning for this project, I knew that I would need to use a language like C and a library such as [SDL2](https://www.libsdl.org/) in order to achieve the desired results. I had considered other options, but ultimately determined that [SDL2](https://www.libsdl.org/) was the best fit based on its capabilities and reputation in the programming community. | 69 | Purely out of ergonomic reasons. |
| 39 | 70 | ||
| 40 | At first, I thought the idea of a hardware accelerated terminal was a bit of a joke. It seemed like such a niche and unnecessary feature, especially given the fact that terminal emulators have been around for decades and have always relied on software rendering. But to be fair, [Alacritty](https://alacritty.org/) is doing the same thing. Well, they are doing a remarkable job at it. | 71 | I would like to treat every terminal I open as a session mentally. When I start |
| 41 | 72 | using the terminal, I start digging deeper into the issue I am trying to resolve. | |
| 42 | So, I embarked on a journey. Everything has to start somewhere. For me, it started with creating a window! It has to start somewhere. 🙂 | 73 | And while I am doing this, I would like to open detached windows etc. A lot of |
| 74 | these things can be done easily with something like [i3](https://i3wm.org/), | ||
| 75 | but also that pull you out of the context of what you were doing. I would | ||
| 76 | like to orchestrate everything from one single point. | ||
| 77 | |||
| 78 | In planning for this project, I knew that I would need to use a language like | ||
| 79 | C and a library such as [SDL2](https://www.libsdl.org/) in order to achieve | ||
| 80 | the desired results. I had considered other options, but ultimately determined | ||
| 81 | that [SDL2](https://www.libsdl.org/) was the best fit based on its capabilities | ||
| 82 | and reputation in the programming community. | ||
| 83 | |||
| 84 | At first, I thought the idea of a hardware accelerated terminal was a bit of | ||
| 85 | a joke. It seemed like such a niche and unnecessary feature, especially given | ||
| 86 | the fact that terminal emulators have been around for decades and have always | ||
| 87 | relied on software rendering. But to be fair, [Alacritty](https://alacritty.org/) | ||
| 88 | is doing the same thing. Well, they are doing a remarkable job at it. | ||
| 89 | |||
| 90 | So, I embarked on a journey. Everything has to start somewhere. For me, it | ||
| 91 | started with creating a window! It has to start somewhere. 🙂 | ||
| 43 | 92 | ||
| 44 | ```c | 93 | ```c |
| 45 | // Oh, Hi Mark! | 94 | // Oh, Hi Mark! |
| @@ -52,13 +101,28 @@ SDL_Window *window = SDL_CreateWindow( | |||
| 52 | 101 | ||
| 53 | I continued like this to get some text displayed on the screen. | 102 | I continued like this to get some text displayed on the screen. |
| 54 | 103 | ||
| 55 | I noted that [`TTF_RenderText_Solid`](https://wiki.libsdl.org/SDL_ttf/TTF_RenderText_Solid) rendered text really poorly. There were no antialiasing at all. In my wisdom, I never checked the documentation. Well, that was a fail. To uneducated like me: `TTF_RenderText_Solid` renders Latin1 text at fast quality to a new 8-bit surface. So, that's why the texts looked like shit. No wonder. | 104 | I noted that [`TTF_RenderText_Solid`](https://wiki.libsdl.org/SDL_ttf/TTF_RenderText_Solid) |
| 56 | 105 | rendered text really poorly. There were no antialiasing at all. In my wisdom, | |
| 57 | Remarks on `TTF_RenderText_Solid`: This function will allocate a new 8-bit, palettized surface. The surface's 0 pixel will be the colorkey, giving a transparent background. The 1 pixel will be set to the text color. | 106 | I never checked the documentation. Well, that was a fail. To uneducated like |
| 58 | 107 | me: `TTF_RenderText_Solid` renders Latin1 text at fast quality to a new 8-bit | |
| 59 | After I replaced it with [`TTF_RenderText_LCD`](https://wiki.libsdl.org/SDL_ttf/TTF_RenderText_LCD) which renders Latin1 text at LCD subpixel quality to a new ARGB surface, the text started looking good. Really make sure you read the documentation. It’s actually good. As a side note, you can find all the documentation regarding [SDL2 on their Wiki](https://wiki.libsdl.org/). | 108 | surface. So, that's why the texts looked like shit. No wonder. |
| 60 | 109 | ||
| 61 | After that was done, I started working on displaying other things like `Preview` and `Detach` modes. This wasn’t really that hard. In SDL2 you can check all the available events with `while (SDL_PollEvent(&event) > 0)` and have a bunch of switch statements to determine which key is currently being pressed. More about keys, [SDLKey](https://documentation.help/SDL/sdlkey.html) and mroe about pooling the events on [SDL_PollEvent](https://documentation.help/SDL/sdlpollevent.html). | 110 | Remarks on `TTF_RenderText_Solid`: This function will allocate a new 8-bit, |
| 111 | palettized surface. The surface's 0 pixel will be the colorkey, giving a | ||
| 112 | transparent background. The 1 pixel will be set to the text color. | ||
| 113 | |||
| 114 | After I replaced it with [`TTF_RenderText_LCD`](https://wiki.libsdl.org/SDL_ttf/TTF_RenderText_LCD) | ||
| 115 | which renders Latin1 text at LCD subpixel quality to a new ARGB surface, the | ||
| 116 | text started looking good. Really make sure you read the documentation. It’s | ||
| 117 | actually good. As a side note, you can find all the documentation regarding | ||
| 118 | [SDL2 on their Wiki](https://wiki.libsdl.org/). | ||
| 119 | |||
| 120 | After that was done, I started working on displaying other things like | ||
| 121 | `Preview` and `Detach` modes. This wasn’t really that hard. In SDL2 you can | ||
| 122 | check all the available events with `while (SDL_PollEvent(&event) > 0)` and | ||
| 123 | have a bunch of switch statements to determine which key is currently being | ||
| 124 | pressed. More about keys, [SDLKey](https://documentation.help/SDL/sdlkey.html) | ||
| 125 | and mroe about pooling the events on [SDL_PollEvent](https://documentation.help/SDL/sdlpollevent.html). | ||
| 62 | 126 | ||
| 63 | ```c | 127 | ```c |
| 64 | while (SDL_PollEvent(&event) > 0) | 128 | while (SDL_PollEvent(&event) > 0) |
| @@ -80,7 +144,9 @@ while (SDL_PollEvent(&event) > 0) | |||
| 80 | } | 144 | } |
| 81 | ``` | 145 | ``` |
| 82 | 146 | ||
| 83 | After that was somewhat working correctly, I started creating a struct that would hold all the commands and results and I call them Cells. Yes, I stole that naming idea from Jupyter. | 147 | After that was somewhat working correctly, I started creating a struct that |
| 148 | would hold all the commands and results and I call them Cells. Yes, I stole | ||
| 149 | that naming idea from Jupyter. | ||
| 84 | 150 | ||
| 85 | ```c | 151 | ```c |
| 86 | typedef struct | 152 | typedef struct |
| @@ -93,9 +159,13 @@ typedef struct | |||
| 93 | } Cell; | 159 | } Cell; |
| 94 | ``` | 160 | ``` |
| 95 | 161 | ||
| 96 | I am at a place now where I am starting to implement scrolling. This will for sure be fun to code. Memory management in C is super easy. 😂 | 162 | I am at a place now where I am starting to implement scrolling. This will for |
| 163 | sure be fun to code. Memory management in C is super easy. 😂 | ||
| 97 | 164 | ||
| 98 | I have also added a simple [INI file like configuration](https://en.wikipedia.org/wiki/INI_file) support. It is done in an [STB style of header](https://github.com/nothings/stb/blob/master/docs/stb_howto.txt) and maps to specific options supported by the terminal. It is not universal, and the code below demonstrates how I will use it in the future. | 165 | I have also added a simple [INI file like configuration](https://en.wikipedia.org/wiki/INI_file) |
| 166 | support. It is done in an [STB style of header](https://github.com/nothings/stb/blob/master/docs/stb_howto.txt) | ||
| 167 | and maps to specific options supported by the terminal. It is not universal, | ||
| 168 | and the code below demonstrates how I will use it in the future. | ||
| 99 | 169 | ||
| 100 | ```c | 170 | ```c |
| 101 | #ifndef CONFIG_H | 171 | #ifndef CONFIG_H |
| @@ -169,4 +239,8 @@ extern Config read_config_file(const char *filename) | |||
| 169 | #endif | 239 | #endif |
| 170 | ``` | 240 | ``` |
| 171 | 241 | ||
| 172 | This is as far as I managed to get for now. I have a daily job and this prohibits me to work on these things full time. But I should probably get back and finish this. At least have a simple version working out, so I can start testing it on my machines. Fingers crossed. 🕵️♂️ \ No newline at end of file | 242 | This is as far as I managed to get for now. I have a daily job and this |
| 243 | prohibits me to work on these things full time. But I should probably get | ||
| 244 | back and finish this. At least have a simple version working out, so I can | ||
| 245 | start testing it on my machines. Fingers crossed. 🕵️♂️ | ||
| 246 | |||
diff --git a/content/posts/2023-05-10-push-to-multiple-origins-at-once-in-git.md b/content/posts/2023-05-10-push-to-multiple-origins-at-once-in-git.md index 7d22950..3d07072 100644 --- a/content/posts/2023-05-10-push-to-multiple-origins-at-once-in-git.md +++ b/content/posts/2023-05-10-push-to-multiple-origins-at-once-in-git.md | |||
| @@ -1,18 +1,25 @@ | |||
| 1 | --- | 1 | --- |
| 2 | title: Push to multiple origins at once in Git | 2 | title: Push to multiple origins at once in Git |
| 3 | url: push-to-multiple-origins-at-once-in-git.html | 3 | url: push-to-multiple-origins-at-once-in-git.html |
| 4 | date: 2023-05-10 | 4 | date: 2023-05-10T12:00:00+02:00 |
| 5 | draft: false | 5 | draft: false |
| 6 | --- | 6 | --- |
| 7 | 7 | ||
| 8 | This is a quick one. I use my personal Git server as my main server, and I use GitHub only as a mirror. As a result, I constantly forget to push to GitHub. | 8 | This is a quick one. I use my personal Git server as my main server, and I use |
| 9 | GitHub only as a mirror. As a result, I constantly forget to push to GitHub. | ||
| 9 | 10 | ||
| 10 | To push to multiple origins at once in Git, you can create a custom Git alias or use a script to automate the process. Here's an example of how you can achieve this using a Git alias: | 11 | To push to multiple origins at once in Git, you can create a custom Git alias |
| 12 | or use a script to automate the process. Here's an example of how you can | ||
| 13 | achieve this using a Git alias: | ||
| 11 | 14 | ||
| 12 | ```sh | 15 | ```sh |
| 13 | git config --global alias.pushall '!sh -c "git remote | xargs -L1 git push --all"' | 16 | git config --global alias.pushall '!sh -c "git remote | xargs -L1 git push --all"' |
| 14 | ``` | 17 | ``` |
| 15 | 18 | ||
| 16 | This command creates a Git alias called `pushall` which, when executed, will push the changes to all the remote repositories associated with the current repository. To use it, simply run `git pushall` instead of `git push` when you want to push to all the remote repositories at once. | 19 | This command creates a Git alias called `pushall` which, when executed, will |
| 20 | push the changes to all the remote repositories associated with the current | ||
| 21 | repository. To use it, simply run `git pushall` instead of `git push` when | ||
| 22 | you want to push to all the remote repositories at once. | ||
| 17 | 23 | ||
| 18 | That's all, folks. | 24 | That's all, folks. |
| 25 | |||
diff --git a/content/posts/2023-05-16-rekindling-my-love-for-programming.md b/content/posts/2023-05-16-rekindling-my-love-for-programming.md index 1d1d08b..6b73bb1 100644 --- a/content/posts/2023-05-16-rekindling-my-love-for-programming.md +++ b/content/posts/2023-05-16-rekindling-my-love-for-programming.md | |||
| @@ -1,32 +1,76 @@ | |||
| 1 | --- | 1 | --- |
| 2 | title: Rekindling my love for programming and enjoying the act of creating | 2 | title: Rekindling my love for programming and enjoying the act of creating |
| 3 | url: rekindling-my-love-for-programming.html | 3 | url: rekindling-my-love-for-programming.html |
| 4 | date: 2023-05-16 | 4 | date: 2023-05-16T12:00:00+02:00 |
| 5 | draft: false | 5 | draft: false |
| 6 | --- | 6 | --- |
| 7 | 7 | ||
| 8 | Programming can be a challenging and rewarding experience, but sometimes it's easy to feel burnt out or disinterested. I have lost the passion for coding over the past couple of months and it looked like I will never enjoy the coding as much as I did. | 8 | Programming can be a challenging and rewarding experience, but sometimes it's |
| 9 | easy to feel burnt out or disinterested. I have lost the passion for coding | ||
| 10 | over the past couple of months and it looked like I will never enjoy the | ||
| 11 | coding as much as I did. | ||
| 9 | 12 | ||
| 10 | I was feeling burnt out with programming. I thought taking a break from it and focusing on other activities that I enjoy might be helpful. This way, I could come back to programming with a fresh perspective and renewed energy. I also thought about learning a new programming language or technology to keep things interesting and challenging. | 13 | I was feeling burnt out with programming. I thought taking a break from it |
| 14 | and focusing on other activities that I enjoy might be helpful. This way, I | ||
| 15 | could come back to programming with a fresh perspective and renewed energy. | ||
| 16 | I also thought about learning a new programming language or technology to | ||
| 17 | keep things interesting and challenging. | ||
| 11 | 18 | ||
| 12 | However, what I didn't realize was that learning a new language or technology wasn't going to solve the underlying issue. I needed to take a step back and re-evaluate why I had lost my passion for programming in the first place. This involved taking a deep look into what I was doing that resulted in this rut. | 19 | However, what I didn't realize was that learning a new language or technology |
| 20 | wasn't going to solve the underlying issue. I needed to take a step back and | ||
| 21 | re-evaluate why I had lost my passion for programming in the first place. | ||
| 22 | This involved taking a deep look into what I was doing that resulted in | ||
| 23 | this rut. | ||
| 13 | 24 | ||
| 14 | Sometimes, it's easy to get caught up in the hype of new technologies or languages, and we can feel like we're missing out if we're not constantly learning and experimenting. However, it's important to remember that the latest and greatest isn't always the best fit for our projects or our interests. Instead of constantly chasing the next big thing, it can be helpful to focus on what truly interests us and what we're passionate about. This can help us stay motivated and engaged with our work, rather than feeling like we're just going through the motions. | 25 | Sometimes, it's easy to get caught up in the hype of new technologies or |
| 26 | languages, and we can feel like we're missing out if we're not constantly | ||
| 27 | learning and experimenting. However, it's important to remember that the | ||
| 28 | latest and greatest isn't always the best fit for our projects or our | ||
| 29 | interests. Instead of constantly chasing the next big thing, it can be helpful | ||
| 30 | to focus on what truly interests us and what we're passionate about. This | ||
| 31 | can help us stay motivated and engaged with our work, rather than feeling | ||
| 32 | like we're just going through the motions. | ||
| 15 | 33 | ||
| 16 | I expressed that I had lost my passion for coding over the past couple of months, and I realized that the reason behind it was my tendency to spread myself too thin and not focus on completing interesting projects. In order to regain my passion for coding, I need to focus on projects that truly interest me and give me a sense of purpose and motivation. | 34 | I expressed that I had lost my passion for coding over the past couple of |
| 35 | months, and I realized that the reason behind it was my tendency to spread | ||
| 36 | myself too thin and not focus on completing interesting projects. In order | ||
| 37 | to regain my passion for coding, I need to focus on projects that truly | ||
| 38 | interest me and give me a sense of purpose and motivation. | ||
| 17 | 39 | ||
| 18 | Recently, I have been playing World of Warcraft more frequently and have become interested in developing addons for the game. | 40 | Recently, I have been playing World of Warcraft more frequently and have |
| 41 | become interested in developing addons for the game. | ||
| 19 | 42 | ||
| 20 | This quickly resulted in me creating three addons that improve the quality of life, and I subsequently developed a more useful add-on that encapsulates all the others I made. | 43 | This quickly resulted in me creating three addons that improve the quality |
| 44 | of life, and I subsequently developed a more useful add-on that encapsulates | ||
| 45 | all the others I made. | ||
| 21 | 46 | ||
| 22 | I found it interesting that this action sparked a new interest in me. Additionally, I discovered the Lua language, which reminded me that coding should be fun rather than just a struggle with a language. It should be pure, unadulterated fun. | 47 | I found it interesting that this action sparked a new interest in me. |
| 48 | Additionally, I discovered the Lua language, which reminded me that coding | ||
| 49 | should be fun rather than just a struggle with a language. It should be | ||
| 50 | pure, unadulterated fun. | ||
| 23 | 51 | ||
| 24 | I wasn't fighting the syntax, nor was I focused on finding the most optimal solution. I simply created things without the pressure of making them the best they could possibly be. | 52 | I wasn't fighting the syntax, nor was I focused on finding the most optimal |
| 53 | solution. I simply created things without the pressure of making them the | ||
| 54 | best they could possibly be. | ||
| 25 | 55 | ||
| 26 | This made me realize that I actually adore simple languages that get out of the way and let you express what you want to do. It forced me to rethink a lot about what I use and what I actually enjoy. | 56 | This made me realize that I actually adore simple languages that get out of |
| 57 | the way and let you express what you want to do. It forced me to rethink a | ||
| 58 | lot about what I use and what I actually enjoy. | ||
| 27 | 59 | ||
| 28 | I have decided to stick to the basics. For a scripting language, I will use Lua. For networking, I will use Golang. And for any special needs, I will rely on C. I do not require Rust, Nim, or Zig. This selection is more than sufficient for my needs. I have to stay true to this simplicity. There is something to the Occam's Razor. | 60 | I have decided to stick to the basics. For a scripting language, I will use |
| 61 | Lua. For networking, I will use Golang. And for any special needs, I will | ||
| 62 | rely on C. I do not require Rust, Nim, or Zig. This selection is more than | ||
| 63 | sufficient for my needs. I have to stay true to this simplicity. There is | ||
| 64 | something to the Occam's Razor. | ||
| 29 | 65 | ||
| 30 | I've been struggling with a lack of creativity lately, but now I'm experiencing a real change. I realized I needed to take a step back and stop actively trying to address the issue. I needed to stop worrying and overthinking it. I simply needed some time. Looking back, I don't think I've taken any significant time off in the last 10 years. | 66 | I've been struggling with a lack of creativity lately, but now I'm experiencing |
| 67 | a real change. I realized I needed to take a step back and stop actively trying | ||
| 68 | to address the issue. I needed to stop worrying and overthinking it. I simply | ||
| 69 | needed some time. Looking back, I don't think I've taken any significant time | ||
| 70 | off in the last 10 years. | ||
| 71 | |||
| 72 | Suddenly, I find myself with the energy and passion to complete multiple | ||
| 73 | small projects. It doesn't feel like a chore at all. Who knew I needed WoW | ||
| 74 | to kickstart everything. Inspiration really does come from the strangest | ||
| 75 | places. | ||
| 31 | 76 | ||
| 32 | Suddenly, I find myself with the energy and passion to complete multiple small projects. It doesn't feel like a chore at all. Who knew I needed WoW to kickstart everything. Inspiration really does come from the strangest places. | ||
diff --git a/content/posts/2023-05-22-crafting-stories-in-zed-editor.md b/content/posts/2023-05-22-crafting-stories-in-zed-editor.md index 9c04b1c..f5240da 100644 --- a/content/posts/2023-05-22-crafting-stories-in-zed-editor.md +++ b/content/posts/2023-05-22-crafting-stories-in-zed-editor.md | |||
| @@ -1,25 +1,41 @@ | |||
| 1 | --- | 1 | --- |
| 2 | title: From General Zod to Superman - Crafting Stories in Zed Editor | 2 | title: From General Zod to Superman - Crafting Stories in Zed Editor |
| 3 | url: crafting-stories-in-zed-editor.html | 3 | url: crafting-stories-in-zed-editor.html |
| 4 | date: 2023-05-22 | 4 | date: 2023-05-22T12:00:00+02:00 |
| 5 | draft: false | 5 | draft: false |
| 6 | --- | 6 | --- |
| 7 | 7 | ||
| 8 | Pretentious title! Good start! I have nothing to add to this discussion. I just like this editor and wanted to write something here that will remind me to use it again in a while when/if it becomes available for Linux. | 8 | Pretentious title! Good start! I have nothing to add to this discussion. I just |
| 9 | like this editor and wanted to write something here that will remind me to | ||
| 10 | use it again in a while when/if it becomes available for Linux. | ||
| 9 | 11 | ||
| 10 | **TLDR:** I think this code editor is very cool and has a massive potential. I hope they don’t mess up with adding a plugin ecosystem to it! | 12 | **TLDR:** I think this code editor is very cool and has a massive potential. |
| 13 | I hope they don’t mess up with adding a plugin ecosystem to it! | ||
| 11 | 14 | ||
| 12 | Out of morbid curiosity, I started using the [Zed editor](https://zed.dev/) on my Mac. Zed is a high-performance, multiplayer code editor developed by the creators of Atom and Tree-sitter. Written in Rust so it has to be blazingly fast! 😊 It's a joke, calm down. | 15 | Out of morbid curiosity, I started using the [Zed editor](https://zed.dev/) |
| 16 | on my Mac. Zed is a high-performance, multiplayer code editor developed by | ||
| 17 | the creators of Atom and Tree-sitter. Written in Rust so it has to be | ||
| 18 | blazingly fast! 😊 It's a joke, calm down. | ||
| 13 | 19 | ||
| 14 | Over the past year, I have switched between [Helix editor](https://helix-editor.com/) and [VS Code](https://code.visualstudio.com/), but for the last couple of months, I have been using Helix exclusively. | 20 | Over the past year, I have switched between [Helix editor](https://helix-editor.com/) |
| 21 | and [VS Code](https://code.visualstudio.com/), but for the last couple of | ||
| 22 | months, I have been using Helix exclusively. | ||
| 15 | 23 | ||
| 16 | I've been genuinely impressed by Zed. When you open a file, it automatically detects its type and downloads the corresponding [LSP (language server)](https://en.wikipedia.org/wiki/Language_Server_Protocol). The list of supported languages is not extensive, but it's still impressive. It's a great example of how to create a product that stays out of your way. | 24 | I've been genuinely impressed by Zed. When you open a file, it automatically |
| 25 | detects its type and downloads the corresponding [LSP (language server)](https://en.wikipedia.org/wiki/Language_Server_Protocol). | ||
| 26 | The list of supported languages is not extensive, but it's still impressive. | ||
| 27 | It's a great example of how to create a product that stays out of your way. | ||
| 17 | 28 | ||
| 18 |  | 29 |  |
| 19 | 30 | ||
| 20 | For C development it downloaded [clangd](https://clangd.llvm.org/) and setting up missing dependencies in code was rather easy. For this project I use [SDL2](https://www.libsdl.org/) for rendering terminal emulator. It’s a hobby project, don’t worry about it. | 31 | For C development it downloaded [clangd](https://clangd.llvm.org/) and setting |
| 32 | up missing dependencies in code was rather easy. For this project I use | ||
| 33 | [SDL2](https://www.libsdl.org/) for rendering terminal emulator. It’s a | ||
| 34 | hobby project, don’t worry about it. | ||
| 21 | 35 | ||
| 22 | If you are going to give this a try and you are using C, I suggest checking two files in the root of your project folder. If you don't have them, create them. | 36 | If you are going to give this a try and you are using C, I suggest checking |
| 37 | two files in the root of your project folder. If you don't have them, | ||
| 38 | create them. | ||
| 23 | 39 | ||
| 24 | **compile_flags.txt** | 40 | **compile_flags.txt** |
| 25 | 41 | ||
| @@ -28,7 +44,10 @@ If you are going to give this a try and you are using C, I suggest checking two | |||
| 28 | -I/opt/homebrew/include/SDL2 | 44 | -I/opt/homebrew/include/SDL2 |
| 29 | ``` | 45 | ``` |
| 30 | 46 | ||
| 31 | Easy way of checking what the appropriate includes for a specific library is to use `pkg-config` and in my case `pkg-config SDL2 --cflags-only-I`. But this is nothing new to C/C++ devs. Just a noter for people who are using Visual Studio. | 47 | Easy way of checking what the appropriate includes for a specific library is |
| 48 | to use `pkg-config` and in my case `pkg-config SDL2 --cflags-only-I`. But this | ||
| 49 | is nothing new to C/C++ devs. Just a noter for people who are using Visual | ||
| 50 | Studio. | ||
| 32 | 51 | ||
| 33 | **.clang-format** | 52 | **.clang-format** |
| 34 | 53 | ||
| @@ -39,21 +58,31 @@ BasedOnStyle: Mozilla | |||
| 39 | 58 | ||
| 40 | I prefer Mozilla coding style for C so you can set that up. | 59 | I prefer Mozilla coding style for C so you can set that up. |
| 41 | 60 | ||
| 42 | They really have something special here. Although there is no version available for Linux yet, I will stick to Helix. This impressive piece of engineering is, above all, an amazing example of craftsmanship. | 61 | They really have something special here. Although there is no version available |
| 62 | for Linux yet, I will stick to Helix. This impressive piece of engineering is, | ||
| 63 | above all, an amazing example of craftsmanship. | ||
| 43 | 64 | ||
| 44 | They have a bunch of amazing integrated functionalities like live desktop sharing, code sharing in a live coding session. There is a lot of pretentious marketing speak there but the product is still amazing! | 65 | They have a bunch of amazing integrated functionalities like live desktop |
| 66 | sharing, code sharing in a live coding session. There is a lot of pretentious | ||
| 67 | marketing speak there but the product is still amazing! | ||
| 45 | 68 | ||
| 46 | For me the speed and the simplicity of the product was the most impressive thing. You get that: it just works feeling. A rare thing in 2023. | 69 | For me the speed and the simplicity of the product was the most impressive |
| 70 | thing. You get that: it just works feeling. A rare thing in 2023. | ||
| 47 | 71 | ||
| 48 |  | 72 |  |
| 49 | 73 | ||
| 50 | 74 | They also managed to add [Github Copilot](https://github.com/features/copilot) | |
| 51 | They also managed to add [Github Copilot](https://github.com/features/copilot) in a non obtrusive way. To me, everything feels very intentional and specifically selected. It's minimal yet maximally effective. | 75 | in a non obtrusive way. To me, everything feels very intentional and |
| 76 | specifically selected. It's minimal yet maximally effective. | ||
| 52 | 77 | ||
| 53 | <video src="https://zed.dev/img/post/copilot/copilot-demo.webm" autoplay loop></video> | 78 | <video src="https://zed.dev/img/post/copilot/copilot-demo.webm" autoplay loop></video> |
| 54 | 79 | ||
| 55 | It is a perfect balance between VS Code, Jetbrains IDE’s and something like VIM or Helix. | 80 | It is a perfect balance between VS Code, Jetbrains IDE’s and something like |
| 81 | VIM or Helix. | ||
| 56 | 82 | ||
| 57 | I just hope they **DON’T** add plugin support and keep it like it is. They as a vendor should add stuff to it with great deliberation and thought. And this way the product will stay fast and focused. That’s my two cents. | 83 | I just hope they **DON’T** add plugin support and keep it like it is. They as a |
| 84 | vendor should add stuff to it with great deliberation and thought. And this | ||
| 85 | way the product will stay fast and focused. That’s my two cents. | ||
| 58 | 86 | ||
| 59 | Amazing job! | 87 | Amazing job! |
| 88 | |||
diff --git a/content/posts/2023-05-23-i-was-wrong-about-git-workflows.md b/content/posts/2023-05-23-i-was-wrong-about-git-workflows.md index eae7025..e1e45e8 100644 --- a/content/posts/2023-05-23-i-was-wrong-about-git-workflows.md +++ b/content/posts/2023-05-23-i-was-wrong-about-git-workflows.md | |||
| @@ -1,28 +1,72 @@ | |||
| 1 | --- | 1 | --- |
| 2 | title: I think I was completely wrong about Git workflows | 2 | title: I think I was completely wrong about Git workflows |
| 3 | url: i-was-wrong-about-git-workflows.html | 3 | url: i-was-wrong-about-git-workflows.html |
| 4 | date: 2023-05-23 | 4 | date: 2023-05-23T12:00:00+02:00 |
| 5 | draft: false | 5 | draft: false |
| 6 | type: posts | ||
| 7 | tags: [] | ||
| 6 | --- | 8 | --- |
| 7 | 9 | ||
| 8 | I have been using some approximation of [Git Flow](https://jeffkreeftmeijer.com/git-flow/) for years now and never really questioned it to be honest. When I create a repo I create develop branch and set it as default one and then merge to master from there. Seems reasonable enough. | 10 | I have been using some approximation of [Git Flow](https://jeffkreeftmeijer.com/git-flow/) |
| 11 | for years now and never really questioned it to be honest. When I create a repo | ||
| 12 | I create develop branch and set it as default one and then merge to master | ||
| 13 | from there. Seems reasonable enough. | ||
| 9 | 14 | ||
| 10 | One thing that I have learned is that long living branches are the devil. They always end up making a huge mess when they need to be merged eventually into master. So by that reason, what is the develop branch if not the longest living feature branch. And from my personal experience there was never a situation where I wasn’t sweating bullets when I had to merge develop back to master. | 15 | One thing that I have learned is that long living branches are the devil. |
| 16 | They always end up making a huge mess when they need to be merged eventually | ||
| 17 | into master. So by that reason, what is the develop branch if not the longest | ||
| 18 | living feature branch. And from my personal experience there was never a | ||
| 19 | situation where I wasn’t sweating bullets when I had to merge develop back | ||
| 20 | to master. | ||
| 11 | 21 | ||
| 12 | This realisation started to give me pause. So why the hell am I doing this, and is there a better way. Well the solution was always there. And it comes in a form of [git tags](https://git-scm.com/book/en/v2/Git-Basics-Tagging). | 22 | This realisation started to give me pause. So why the hell am I doing this, |
| 23 | and is there a better way. Well the solution was always there. And it comes | ||
| 24 | in a form of [git tags](https://git-scm.com/book/en/v2/Git-Basics-Tagging). | ||
| 13 | 25 | ||
| 14 | So what are git tags? Git tags are references to specific points in a Git repository's history. They are used to mark important milestones, such as releases or significant commits, making it easier to identify and access specific versions of a project. | 26 | So what are git tags? Git tags are references to specific points in a Git |
| 27 | repository's history. They are used to mark important milestones, such as | ||
| 28 | releases or significant commits, making it easier to identify and access | ||
| 29 | specific versions of a project. | ||
| 15 | 30 | ||
| 16 | Somehow we have all hijacked the meaning of the master branch that it has to be the most releasable version of code. And this is also where the confusing about versioning the software kicks in. Because master branch implicitly says that we are dealing with the rolling release type of a software. And by having a develop branch we are hacking around this confusion. With a separation of develop and master we lock functionalities into place and forcing a stable vs development version of the software. | 31 | Somehow we have all hijacked the meaning of the master branch that it has |
| 32 | to be the most releasable version of code. And this is also where the confusing | ||
| 33 | about versioning the software kicks in. Because master branch implicitly says | ||
| 34 | that we are dealing with the rolling release type of a software. And by having | ||
| 35 | a develop branch we are hacking around this confusion. With a separation of | ||
| 36 | develop and master we lock functionalities into place and forcing a stable | ||
| 37 | vs development version of the software. | ||
| 17 | 38 | ||
| 18 | But if that is true and the long living branches are the devil then why have develop at all. I think that most of this comes to how continuous integration is being done. There usually is no granular access to tags and CD software deploys what is present on a specific branch, may that be master for production and develop for staging. This is a gross simplification and by having this in place we have completely removed tagging as a viable option to create a fix point in software cycle that says, this is the production ready code. | 39 | But if that is true and the long living branches are the devil then why have |
| 40 | develop at all. I think that most of this comes to how continuous integration | ||
| 41 | is being done. There usually is no granular access to tags and CD software | ||
| 42 | deploys what is present on a specific branch, may that be master for production | ||
| 43 | and develop for staging. This is a gross simplification and by having this | ||
| 44 | in place we have completely removed tagging as a viable option to create a | ||
| 45 | fix point in software cycle that says, this is the production ready code. | ||
| 19 | 46 | ||
| 20 | One cool thing about tags are that you can checkout a specific tag. So they behave very similarly as branches in that regard. And you don’t have the overhead of having two mainstream branches. | 47 | One cool thing about tags are that you can checkout a specific tag. So they |
| 48 | behave very similarly as branches in that regard. And you don’t have the | ||
| 49 | overhead of having two mainstream branches. | ||
| 21 | 50 | ||
| 22 | So what is the solution? One approach is to use development workflow, where all changes are made on the smaller branches and continuously merged into master. Where the software is ready to be pushed to production you tag the master branch. This approach eliminates the need for long-lived branches and simplifies the development process. It also encourages developers to make small, incremental changes that can be tested and deployed quickly. However, this approach may not be suitable for all projects or teams that heavily rely on automated deployment based on branch names only. | 51 | So what is the solution? One approach is to use development workflow, where |
| 52 | all changes are made on the smaller branches and continuously merged into | ||
| 53 | master. Where the software is ready to be pushed to production you tag the | ||
| 54 | master branch. This approach eliminates the need for long-lived branches and | ||
| 55 | simplifies the development process. It also encourages developers to make | ||
| 56 | small, incremental changes that can be tested and deployed quickly. However, | ||
| 57 | this approach may not be suitable for all projects or teams that heavily rely | ||
| 58 | on automated deployment based on branch names only. | ||
| 23 | 59 | ||
| 24 | This also requires that developers always keep production in mind. No more living on an island of the develop branch. All your actions and code need to be ready to meet production standards on a much smaller timescale. | 60 | This also requires that developers always keep production in mind. No more |
| 61 | living on an island of the develop branch. All your actions and code need to | ||
| 62 | be ready to meet production standards on a much smaller timescale. | ||
| 25 | 63 | ||
| 26 | I think that we have complicated the workflow in an honest attempt to make things more streamlined but in the process of doing this, we have inadvertently made our lives much more complicated. | 64 | I think that we have complicated the workflow in an honest attempt to make |
| 65 | things more streamlined but in the process of doing this, we have inadvertently | ||
| 66 | made our lives much more complicated. | ||
| 67 | |||
| 68 | In conclusion, it's important to re-evaluate our workflows from time to time | ||
| 69 | to see if they still make sense and if there are better alternatives available. | ||
| 70 | Long-living branches can be problematic, and using tags to mark important | ||
| 71 | milestones can simplify the development process. | ||
| 27 | 72 | ||
| 28 | In conclusion, it's important to re-evaluate our workflows from time to time to see if they still make sense and if there are better alternatives available. Long-living branches can be problematic, and using tags to mark important milestones can simplify the development process. | ||
diff --git a/static/general/index.css b/static/general/index.css index 7af598d..834ed35 100644 --- a/static/general/index.css +++ b/static/general/index.css | |||
| @@ -1 +1 @@ | |||
| /*! tailwindcss v3.3.2 | MIT License | https://tailwindcss.com*/*,:after,:before{box-sizing:border-box;border:0 solid #e5e7eb}:after,:before{--tw-content:""}html{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;font-feature-settings:normal;font-variation-settings:normal}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:initial}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-size:100%;font-weight:inherit;line-height:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}[type=button],[type=reset],[type=submit],button{-webkit-appearance:button;background-color:initial;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:initial}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dd,dl,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}fieldset{margin:0}fieldset,legend{padding:0}menu,ol,ul{list-style:none;margin:0;padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}[role=button],button{cursor:pointer}:disabled{cursor:default}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]{display:none}*,::backdrop,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:#3b82f680;--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }.mx-auto{margin-left:auto;margin-right:auto}.my-12{margin-top:3rem;margin-bottom:3rem}.mb-1{margin-bottom:.25rem}.mb-10{margin-bottom:2.5rem}.mb-12{margin-bottom:3rem}.mb-2{margin-bottom:.5rem}.mb-4{margin-bottom:1rem}.mb-5{margin-bottom:1.25rem}.mb-6{margin-bottom:1.5rem}.mb-8{margin-bottom:2rem}.ml-6{margin-left:1.5rem}.mt-4{margin-top:1rem}.block{display:block}.flex{display:flex}.inline-flex{display:inline-flex}.contents{display:contents}.hidden{display:none}.h-full{height:100%}.w-full{width:100%}.flex-grow{flex-grow:1}.list-disc{list-style-type:disc}.flex-row{flex-direction:row}.flex-col{flex-direction:column}.items-center{align-items:center}.gap-1{gap:.25rem}.rounded{border-radius:.25rem}.border-0{border-width:0}.border-2{border-width:2px}.border-gray-100{--tw-border-opacity:1;border-color:rgb(243 244 246/var(--tw-border-opacity))}.bg-gray-100{--tw-bg-opacity:1;background-color:rgb(243 244 246/var(--tw-bg-opacity))}.bg-orange-600{--tw-bg-opacity:1;background-color:rgb(234 88 12/var(--tw-bg-opacity))}.px-1{padding-left:.25rem;padding-right:.25rem}.px-1\.5{padding-left:.375rem;padding-right:.375rem}.px-2{padding-left:.5rem;padding-right:.5rem}.px-3{padding-left:.75rem;padding-right:.75rem}.px-6{padding-left:1.5rem;padding-right:1.5rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.py-4{padding-top:1rem;padding-bottom:1rem}.pb-16{padding-bottom:4rem}.text-2xl{font-size:1.5rem;line-height:2rem}.text-4xl{font-size:2.25rem;line-height:2.5rem}.text-sm{font-size:.875rem;line-height:1.25rem}.text-xl{font-size:1.25rem;line-height:1.75rem}.text-xs{font-size:.75rem;line-height:1rem}.font-bold{font-weight:700}.font-medium{font-weight:500}.font-semibold{font-weight:600}.italic{font-style:italic}.leading-relaxed{line-height:1.625}.text-gray-400{--tw-text-opacity:1;color:rgb(156 163 175/var(--tw-text-opacity))}.text-gray-500{--tw-text-opacity:1;color:rgb(107 114 128/var(--tw-text-opacity))}.text-gray-600{--tw-text-opacity:1;color:rgb(75 85 99/var(--tw-text-opacity))}.text-white{--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity))}.underline{text-decoration-line:underline}.no-underline{text-decoration-line:none}.underline-offset-2{text-underline-offset:2px}*{cursor:url(/general/9front-cursor.png),auto}.container-blog{max-width:700px}::selection{--tw-bg-opacity:1;background-color:rgb(254 249 195/var(--tw-bg-opacity));--tw-text-opacity:1;color:rgb(0 0 0/var(--tw-text-opacity))}::-moz-selection{--tw-bg-opacity:1;background-color:rgb(254 249 195/var(--tw-bg-opacity));--tw-text-opacity:1;color:rgb(0 0 0/var(--tw-text-opacity))}a:hover{color:blue}article.single h2{margin-bottom:2rem}article.single h2,article.single.note h2{margin-top:2rem;font-size:1.5rem;line-height:2rem;font-weight:700;line-height:1.25}article.single.note h2{margin-bottom:.25rem}article.single h3{font-size:1.25rem}article.single h3,article.single h4{margin-bottom:1rem;margin-top:2rem;line-height:1.75rem;font-weight:700;line-height:1.25}article.single h4{font-size:1.125rem}article.single p{margin-bottom:1.25rem}article.single a{text-decoration-line:underline;text-underline-offset:2px}article.single a:hover{--tw-bg-opacity:1;background-color:rgb(254 249 195/var(--tw-bg-opacity))}article.single .content blockquote{background-image:url(/general/alert-light.svg);background-size:30px 30px;background-repeat:no-repeat;background-position:0 5px;margin-top:2rem;margin-bottom:2rem;padding-left:3rem}article.single .content blockquote p{margin-bottom:.5rem}article.single img{margin-top:2rem;margin-bottom:2rem;image-rendering:crisp-edges;image-rendering:-webkit-optimize-contrast}article.single img,article.single video{width:100%;border-radius:.25rem;--tw-bg-opacity:1!important;background-color:rgb(249 250 251/var(--tw-bg-opacity))!important}article.single audio{margin-bottom:1.5rem;width:100%}article.single code{background-color:rgb(254 249 195/var(--tw-bg-opacity))}article.single code,article.single.note code{border-radius:.25rem;--tw-bg-opacity:1;padding:.25rem .5rem;font-size:.75rem;line-height:1rem;font-weight:500}article.single.note code{background-color:rgb(243 244 246/var(--tw-bg-opacity))}article.single pre{margin-bottom:1.5rem;overflow-x:auto;border-radius:.25rem;--tw-bg-opacity:1!important;background-color:rgb(249 250 251/var(--tw-bg-opacity))!important;padding:1rem;font-size:.75rem;line-height:1rem}article.single pre code,article.single.note pre code{background:unset;padding:unset;line-height:1.625}article.single table{margin-bottom:1rem;width:100%;border-collapse:collapse;border-width:1px;--tw-border-opacity:1;border-color:rgb(0 0 0/var(--tw-border-opacity))}article.single table td,article.single table th,article.single table tr{border-width:1px;padding:.5rem 1rem;text-align:left}article.single .content ul{margin-bottom:1.5rem;list-style-type:disc;padding-left:1.5rem}@media (min-width:768px){article.single .content ul{padding-left:2.5rem}}article.single .content ol{margin-bottom:1.5rem;list-style-type:decimal;padding-left:2rem}@media (min-width:768px){article.single .content ol{padding-left:2.5rem}}article.single #TableOfContents{margin-bottom:2.5rem;margin-left:1rem;line-height:1.625}article.single #TableOfContents ul{list-style-type:decimal;padding-left:1rem}@media (min-width:768px){article.single #TableOfContents ul{padding-left:1.5rem}}article.single .katex-display{margin-top:2.5rem;margin-bottom:2.5rem}article.single .ll-iframe{border-radius:.25rem;--tw-bg-opacity:1;background-color:rgb(243 244 246/var(--tw-bg-opacity))}article.single .ll-iframe:before{display:flex;height:100%}@keyframes pulse{50%{opacity:.5}}article.single .ll-iframe:before{animation:pulse 2s cubic-bezier(.4,0,.6,1) infinite;cursor:pointer;align-items:center;justify-content:center;border-radius:.25rem;border-width:2px;--tw-border-opacity:1;border-color:rgb(209 213 219/var(--tw-border-opacity));font-size:.875rem;line-height:1.25rem;font-weight:500;content:"Click here to load resource…"}article.single .ll-iframe.empty:before{content:none}.hover\:bg-yellow-100:hover{--tw-bg-opacity:1;background-color:rgb(254 249 195/var(--tw-bg-opacity))}.hover\:text-gray-800:hover{--tw-text-opacity:1;color:rgb(31 41 55/var(--tw-text-opacity))}.hover\:underline:hover{text-decoration-line:underline}@media (min-width:768px){.md\:mb-0{margin-bottom:0}.md\:block{display:block}.md\:inline-block{display:inline-block}.md\:w-auto{width:auto}.md\:flex-row{flex-direction:row}.md\:p-0{padding:0}} \ No newline at end of file | /*! tailwindcss v3.3.2 | MIT License | https://tailwindcss.com*/*,:after,:before{box-sizing:border-box;border:0 solid #e5e7eb}:after,:before{--tw-content:""}html{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;font-feature-settings:normal;font-variation-settings:normal}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:initial}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-size:100%;font-weight:inherit;line-height:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}[type=button],[type=reset],[type=submit],button{-webkit-appearance:button;background-color:initial;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:initial}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dd,dl,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}fieldset{margin:0}fieldset,legend{padding:0}menu,ol,ul{list-style:none;margin:0;padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}[role=button],button{cursor:pointer}:disabled{cursor:default}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]{display:none}*,::backdrop,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:#3b82f680;--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }.mx-auto{margin-left:auto;margin-right:auto}.my-12{margin-top:3rem;margin-bottom:3rem}.mb-1{margin-bottom:.25rem}.mb-10{margin-bottom:2.5rem}.mb-12{margin-bottom:3rem}.mb-2{margin-bottom:.5rem}.mb-4{margin-bottom:1rem}.mb-5{margin-bottom:1.25rem}.mb-6{margin-bottom:1.5rem}.mb-8{margin-bottom:2rem}.ml-6{margin-left:1.5rem}.mt-4{margin-top:1rem}.block{display:block}.flex{display:flex}.inline-flex{display:inline-flex}.contents{display:contents}.hidden{display:none}.h-full{height:100%}.w-full{width:100%}.flex-grow{flex-grow:1}.list-disc{list-style-type:disc}.flex-row{flex-direction:row}.flex-col{flex-direction:column}.items-center{align-items:center}.gap-1{gap:.25rem}.rounded{border-radius:.25rem}.border-0{border-width:0}.border-2{border-width:2px}.border-gray-100{--tw-border-opacity:1;border-color:rgb(243 244 246/var(--tw-border-opacity))}.bg-gray-100{--tw-bg-opacity:1;background-color:rgb(243 244 246/var(--tw-bg-opacity))}.bg-orange-600{--tw-bg-opacity:1;background-color:rgb(234 88 12/var(--tw-bg-opacity))}.px-1{padding-left:.25rem;padding-right:.25rem}.px-1\.5{padding-left:.375rem;padding-right:.375rem}.px-2{padding-left:.5rem;padding-right:.5rem}.px-3{padding-left:.75rem;padding-right:.75rem}.px-6{padding-left:1.5rem;padding-right:1.5rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.py-4{padding-top:1rem;padding-bottom:1rem}.pb-16{padding-bottom:4rem}.text-2xl{font-size:1.5rem;line-height:2rem}.text-4xl{font-size:2.25rem;line-height:2.5rem}.text-sm{font-size:.875rem;line-height:1.25rem}.text-xl{font-size:1.25rem;line-height:1.75rem}.text-xs{font-size:.75rem;line-height:1rem}.font-bold{font-weight:700}.font-medium{font-weight:500}.font-semibold{font-weight:600}.italic{font-style:italic}.leading-relaxed{line-height:1.625}.text-gray-400{--tw-text-opacity:1;color:rgb(156 163 175/var(--tw-text-opacity))}.text-gray-500{--tw-text-opacity:1;color:rgb(107 114 128/var(--tw-text-opacity))}.text-gray-600{--tw-text-opacity:1;color:rgb(75 85 99/var(--tw-text-opacity))}.text-white{--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity))}.underline{text-decoration-line:underline}.no-underline{text-decoration-line:none}.underline-offset-2{text-underline-offset:2px}*{cursor:url(/general/9front-cursor.png),auto}.container-blog{max-width:700px}::selection{--tw-bg-opacity:1;background-color:rgb(254 249 195/var(--tw-bg-opacity));--tw-text-opacity:1;color:rgb(0 0 0/var(--tw-text-opacity))}::-moz-selection{--tw-bg-opacity:1;background-color:rgb(254 249 195/var(--tw-bg-opacity));--tw-text-opacity:1;color:rgb(0 0 0/var(--tw-text-opacity))}a:hover{color:blue}article.single h2{margin-bottom:2rem}article.single h2,article.single.note h2{margin-top:2rem;font-size:1.5rem;line-height:2rem;font-weight:700;line-height:1.25}article.single.note h2{margin-bottom:.25rem}article.single h3{font-size:1.25rem}article.single h3,article.single h4{margin-bottom:1rem;margin-top:2rem;line-height:1.75rem;font-weight:700;line-height:1.25}article.single h4{font-size:1.125rem}article.single p{margin-bottom:1.25rem}article.single a{text-decoration-line:underline;text-underline-offset:2px}article.single a:hover{--tw-bg-opacity:1;background-color:rgb(254 249 195/var(--tw-bg-opacity))}article.single .content blockquote{background-image:url(/general/alert-light.svg);background-size:30px 30px;background-repeat:no-repeat;background-position:0 5px;margin-top:2rem;margin-bottom:2rem;padding-left:3rem}article.single .content blockquote p{margin-bottom:.5rem}article.single img{margin-top:2rem;margin-bottom:2rem;image-rendering:crisp-edges;image-rendering:-webkit-optimize-contrast}article.single img,article.single video{width:100%;border-radius:.25rem;--tw-bg-opacity:1!important;background-color:rgb(249 250 251/var(--tw-bg-opacity))!important}article.single audio{margin-bottom:1.5rem;width:100%}article.single code{background-color:rgb(254 249 195/var(--tw-bg-opacity))}article.single code,article.single.note code{border-radius:.25rem;--tw-bg-opacity:1;padding:.25rem .5rem;font-size:.75rem;line-height:1rem;font-weight:500}article.single.note code{background-color:rgb(243 244 246/var(--tw-bg-opacity))}article.single pre{margin-bottom:1.5rem;overflow-x:auto;border-radius:.25rem;--tw-bg-opacity:1!important;background-color:rgb(249 250 251/var(--tw-bg-opacity))!important;padding:1rem;font-size:.75rem;line-height:1rem}article.single pre code,article.single.note pre code{background:unset;padding:unset;line-height:1.625}article.single table{margin-bottom:1rem;width:100%;border-collapse:collapse;border-width:1px;--tw-border-opacity:1;border-color:rgb(0 0 0/var(--tw-border-opacity))}article.single table td,article.single table th,article.single table tr{border-width:1px;padding:.5rem 1rem;text-align:left}article.single .content ul{margin-bottom:1.5rem;list-style-type:disc;padding-left:1.5rem}@media (min-width:768px){article.single .content ul{padding-left:2.5rem}}article.single .content ol{margin-bottom:1.5rem;list-style-type:decimal;padding-left:2rem}@media (min-width:768px){article.single .content ol{padding-left:2.5rem}}article.single #TableOfContents{margin-bottom:2.5rem;margin-left:1rem;line-height:1.625}article.single #TableOfContents ul{list-style-type:decimal;padding-left:1rem}@media (min-width:768px){article.single #TableOfContents ul{padding-left:1.5rem}}article.single .content ul ul{margin-bottom:auto}article.single .katex-display{margin-top:2.5rem;margin-bottom:2.5rem}article.single .ll-iframe{border-radius:.25rem;--tw-bg-opacity:1;background-color:rgb(243 244 246/var(--tw-bg-opacity))}article.single .ll-iframe:before{display:flex;height:100%}@keyframes pulse{50%{opacity:.5}}article.single .ll-iframe:before{animation:pulse 2s cubic-bezier(.4,0,.6,1) infinite;cursor:pointer;align-items:center;justify-content:center;border-radius:.25rem;border-width:2px;--tw-border-opacity:1;border-color:rgb(209 213 219/var(--tw-border-opacity));font-size:.875rem;line-height:1.25rem;font-weight:500;content:"Click here to load resource…"}article.single .ll-iframe.empty:before{content:none}.hover\:bg-yellow-100:hover{--tw-bg-opacity:1;background-color:rgb(254 249 195/var(--tw-bg-opacity))}.hover\:text-gray-800:hover{--tw-text-opacity:1;color:rgb(31 41 55/var(--tw-text-opacity))}.hover\:underline:hover{text-decoration-line:underline}@media (min-width:768px){.md\:mb-0{margin-bottom:0}.md\:block{display:block}.md\:inline-block{display:inline-block}.md\:w-auto{width:auto}.md\:flex-row{flex-direction:row}.md\:p-0{padding:0}} \ No newline at end of file | ||
diff --git a/static/notes/dcss-quickstart.pdf b/static/notes/dcss-quickstart.pdf new file mode 100644 index 0000000..1b70615 --- /dev/null +++ b/static/notes/dcss-quickstart.pdf | |||
| Binary files differ | |||
diff --git a/static/notes/dcss.jpg b/static/notes/dcss.jpg new file mode 100644 index 0000000..ffe7c6a --- /dev/null +++ b/static/notes/dcss.jpg | |||
| Binary files differ | |||
diff --git a/static/notes/dcss_manual.pdf b/static/notes/dcss_manual.pdf new file mode 100644 index 0000000..03cafd2 --- /dev/null +++ b/static/notes/dcss_manual.pdf | |||
| Binary files differ | |||
diff --git a/themes/simple/layouts/_default/single.html b/themes/simple/layouts/_default/single.html index ffa776f..4489601 100644 --- a/themes/simple/layouts/_default/single.html +++ b/themes/simple/layouts/_default/single.html | |||
| @@ -6,7 +6,7 @@ | |||
| 6 | <header class="mb-6"> | 6 | <header class="mb-6"> |
| 7 | <h1 itemtype="headline" class="text-4xl font-bold mb-4 leading-1 md:leading-2">{{ .Title }}</h1> | 7 | <h1 itemtype="headline" class="text-4xl font-bold mb-4 leading-1 md:leading-2">{{ .Title }}</h1> |
| 8 | 8 | ||
| 9 | {{ if in .Type "posts" }} | 9 | {{ if not (eq .Type "pages") }} |
| 10 | <time class="text-gray-400 font-medium text-sm">Published on {{ .Date.Format "Monday Jan 2, 2006" }}</time> | 10 | <time class="text-gray-400 font-medium text-sm">Published on {{ .Date.Format "Monday Jan 2, 2006" }}</time> |
| 11 | {{ end }} | 11 | {{ end }} |
| 12 | </header> | 12 | </header> |
| @@ -23,7 +23,7 @@ | |||
| 23 | </div> | 23 | </div> |
| 24 | </article> | 24 | </article> |
| 25 | 25 | ||
| 26 | {{ if in .Type "posts" }} | 26 | {{ if not (eq .Type "pages") }} |
| 27 | <hr class="border-2 border-gray-100 mb-10" /> | 27 | <hr class="border-2 border-gray-100 mb-10" /> |
| 28 | {{ end }} | 28 | {{ end }} |
| 29 | 29 | ||
| @@ -39,7 +39,7 @@ | |||
| 39 | {{ end }} | 39 | {{ end }} |
| 40 | 40 | ||
| 41 | <!-- Read more --> | 41 | <!-- Read more --> |
| 42 | {{ if in .Type "posts" }} | 42 | {{ if not (eq .Type "pages") }} |
| 43 | {{ partial "read-more.html" . }} | 43 | {{ partial "read-more.html" . }} |
| 44 | {{ end }} | 44 | {{ end }} |
| 45 | 45 | ||
| @@ -53,4 +53,4 @@ | |||
| 53 | {{ end }} | 53 | {{ end }} |
| 54 | 54 | ||
| 55 | </main> | 55 | </main> |
| 56 | {{ end }} \ No newline at end of file | 56 | {{ end }} |
diff --git a/themes/simple/static/css/tailwind.css b/themes/simple/static/css/tailwind.css index 53d8798..36e45e8 100644 --- a/themes/simple/static/css/tailwind.css +++ b/themes/simple/static/css/tailwind.css | |||
| @@ -127,6 +127,11 @@ article.single #TableOfContents ul { | |||
| 127 | @apply list-decimal pl-4 md:pl-6; | 127 | @apply list-decimal pl-4 md:pl-6; |
| 128 | } | 128 | } |
| 129 | 129 | ||
| 130 | /* Lists */ | ||
| 131 | article.single .content ul ul { | ||
| 132 | margin-bottom: auto; | ||
| 133 | } | ||
| 134 | |||
| 130 | /* Katex */ | 135 | /* Katex */ |
| 131 | article.single .katex-display { | 136 | article.single .katex-display { |
| 132 | @apply my-10; | 137 | @apply my-10; |
