From 2a778912251874f9b808f82e61244efcd12210aa Mon Sep 17 00:00:00 2001 From: Akshay Date: Thu, 16 Apr 2020 13:40:50 +0530 Subject: rerender with pandoc --- docs/posts/WPA_woes/index.html | 68 ++--- docs/posts/bash_harder_with_vim/index.html | 92 +++--- docs/posts/bye_bye_BDFs/index.html | 51 ++-- docs/posts/call_to_ARMs/index.html | 115 +++----- docs/posts/color_conundrum/index.html | 66 ++--- docs/posts/font_size_fallacies/index.html | 131 +++------ .../index.html | 49 ++-- docs/posts/hold_position!/index.html | 47 ++-- docs/posts/my_setup/index.html | 54 ++-- docs/posts/onivim_sucks/index.html | 54 ++-- docs/posts/pixel_art_in_GIMP/index.html | 197 +++++-------- docs/posts/rapid_refactoring_with_vim/index.html | 312 +++++++++------------ docs/posts/static_sites_with_bash/index.html | 148 ++++++---- docs/posts/termux_tandem/index.html | 72 +++-- 14 files changed, 667 insertions(+), 789 deletions(-) (limited to 'docs/posts') diff --git a/docs/posts/WPA_woes/index.html b/docs/posts/WPA_woes/index.html index e329df6..f3fcfcf 100644 --- a/docs/posts/WPA_woes/index.html +++ b/docs/posts/WPA_woes/index.html @@ -37,48 +37,52 @@ WPA Woes
-

I finally got around to installing Void GNU/Linux on my main -computer. Rolling release, non-systemd, need I say more?

- -

As with all GNU/Linux distributions, wireless networks had -me in a fix. If you can see this post, it means I've managed -to get online. It turns out, wpa_supplicant was detecting the -wrong interface by default (does it ever select the right -one?). Let us fix that:

- -
$ sudo rm -r /var/service/wpa_supplicant
-$ sudo killall dhcpcd
-
- + + + + + + + WPA_woes + + + + +

I finally got around to installing Void GNU/Linux on my main computer. Rolling release, non-systemd, need I say more?

+

As with all GNU/Linux distributions, wireless networks had me in a fix. If you can see this post, it means I’ve managed to get online. It turns out, wpa_supplicant was detecting the wrong interface by default (does it ever select the right one?). Let us fix that:

+
$ sudo rm -r /var/service/wpa_supplicant
+$ sudo killall dhcpcd

What is the right interface though?

-
$ iw dev
    ...
    Interface wlp2s0
-   ...
-
- -

Aha! Let us run wpa_supplicant on that interface, as a -background process:

- -
$ sudo wpa_supplicant -B -i wlp2s0 -c /etc/wpa_supplicant/wpa_supplicant.conf
+   ...
+

Aha! Let us run wpa_supplicant on that interface, as a background process:

+
$ sudo wpa_supplicant -B -i wlp2s0 -c /etc/wpa_supplicant/wpa_supplicant.conf
 $ sudo dhcpcd -B wlp2s0
 $ ping google.com
-PING ...
-
- +PING ...

Yay! Make those changes perpetual by enabling the service:

-
------------------------------------------------------
-# Add these to /etc/wpa_supplicant/wpa_supplicant.conf
-OPTS="-B"
-WPA_INTERFACE="wlp2s0"
+# Add these to /etc/wpa_supplicant/wpa_supplicant.conf
+OPTS="-B"
+WPA_INTERFACE="wlp2s0"
 ------------------------------------------------------
-$ sudo ln -s /etc/sv/wpa_supplicant /var/service/
-$ sudo ln -s /etc/sv/dhcpcd /var/service/
+$ sudo ln -s /etc/sv/wpa_supplicant /var/service/
+$ sudo ln -s /etc/sv/dhcpcd /var/service/
 $ sudo sv restart wpa_supplicant
-$ sudo sv restart dhcpcd
-
+$ sudo sv restart dhcpcd + +
diff --git a/docs/posts/bash_harder_with_vim/index.html b/docs/posts/bash_harder_with_vim/index.html index 396fcfa..17c066a 100644 --- a/docs/posts/bash_harder_with_vim/index.html +++ b/docs/posts/bash_harder_with_vim/index.html @@ -37,60 +37,62 @@ Bash Harder With Vim
-

Bash is tricky, don't let your editor get in your way. Here's a couple of neat -additions you could make to your vimrc for a better shell programming -experience.

- -

Man pages inside vim

- -

Source this script to get started:

- -
runtime ftplugin/man.vim
-
- -

Now, you can open manpages inside vim with :Man! It adds nicer syntax highlighting -and the ability to jump around with Ctrl-] and Ctrl-T.

- + + + + + + + bash_harder_with_vim + + + + +

Bash is tricky, don’t let your editor get in your way. Here’s a couple of neat additions you could make to your vimrc for a better shell programming experience.

+

Man pages inside vim

+

Source this script to get started:

+
runtime ftplugin/man.vim
+

Now, you can open manpages inside vim with :Man! It adds nicer syntax highlighting and the ability to jump around with Ctrl-] and Ctrl-T.

By default, the manpage is opened in a horizontal split, I prefer using a new tab:

- -
let g:ft_man_open_mode = 'tab'
-
- -

Scratchpad to test your commands

- -

I often test my sed substitutions, here is -a sample from the script used to generate this site:

- +
let g:ft_man_open_mode = 'tab'
+

Scratchpad to test your commands

+

I often test my sed substitutions, here is a sample from the script used to generate this site:

# a substitution to convert snake_case to Title Case With Spaces
-echo "$1" | sed -E -e "s/\..+$//g"  -e "s/_(.)/ \u\1/g" -e "s/^(.)/\u\1/g"
-
- +echo "$1" | sed -E -e "s/\..+$//g" -e "s/_(.)/ \u\1/g" -e "s/^(.)/\u\1/g"

Instead of dropping into a new shell, just test it out directly from vim!

- +
yy
+ +
q:p
+
syntax off            # previously run commands
 edit index.html       # in a buffer!
 w | so %
-!echo "new_post.md" | sed -E -e "s/\..+$//g"  --snip--
-^--- note the use of '!'
-
-
  • Hit enter with the cursor on the line containing your command!

    - +!echo "new_post.md" | sed -E -e "s/\..+$//g" --snip-- +^--- note the use of '!' +
      +
    • Hit enter with the cursor on the line containing your command!
    • +
    $ vim
     New Post         # output
    -Press ENTER or type command to continue
    -
  • - +Press ENTER or type command to continue + +
    diff --git a/docs/posts/bye_bye_BDFs/index.html b/docs/posts/bye_bye_BDFs/index.html index ad7243d..d7b7e46 100644 --- a/docs/posts/bye_bye_BDFs/index.html +++ b/docs/posts/bye_bye_BDFs/index.html @@ -37,31 +37,34 @@ Bye Bye BDFs
    -

    Glyph Bitmap Distribution Format is no more, as the creators of -Pango, one of the most widely used text rendering -libraries, -announced -their plans for Pango 1.44.

    - -

    Until recently, Pango used FreeType to draw fonts. They will be moving over -to Harfbuzz, an evolution of FreeType.

    - + + + + + + + bye_bye_BDFs + + + + +

    Glyph Bitmap Distribution Format is no more, as the creators of Pango, one of the most widely used text rendering libraries, announced their plans for Pango 1.44.

    +

    Until recently, Pango used FreeType to draw fonts. They will be moving over to Harfbuzz, an evolution of FreeType.

    Why?

    - -

    In short, FreeType was hard to work with. It required complex logic, and -provided no advantage over Harfbuzz (other than being able to fetch -opentype metrics with ease).

    - -

    Upgrading to Pango v1.44 will break your GTK applications (if you use a -bdf/pcf bitmap font). Harfbuzz does support bitmap-only OpenType fonts, -otbs. Convert your existing fonts over to otbs using -FontForge. It is to be noted that applications -such as xterm and rxvt use xft (X FreeType) to render fonts, and will -remain unaffected by the update.

    - -

    Both scientifica and -curie will soon ship with bitmap-only -OpenType font formats.

    +

    In short, FreeType was hard to work with. It required complex logic, and provided no advantage over Harfbuzz (other than being able to fetch opentype metrics with ease).

    +

    Upgrading to Pango v1.44 will break your GTK applications (if you use a bdf/pcf bitmap font). Harfbuzz does support bitmap-only OpenType fonts, otbs. Convert your existing fonts over to otbs using FontForge. It is to be noted that applications such as xterm and rxvt use xft (X FreeType) to render fonts, and will remain unaffected by the update.

    +

    Both scientifica and curie will soon ship with bitmap-only OpenType font formats.

    + +
    diff --git a/docs/posts/call_to_ARMs/index.html b/docs/posts/call_to_ARMs/index.html index 3f759e4..578a8b7 100644 --- a/docs/posts/call_to_ARMs/index.html +++ b/docs/posts/call_to_ARMs/index.html @@ -37,88 +37,59 @@ Call To ARMs
    -

    My 4th semester involves ARM programming. And proprietary -tooling (Keil C). But we don't do that here.

    - -

    Building

    - -

    Assembling and linking ARM binaries on non-ARM architecture -devices is fairly trivial. I went along with the GNU cross -bare metal toolchain binutils, which provides arm-as and -arm-ld (among a bunch of other utils that I don't care -about for now).

    - + + + + + + + call_to_ARMs + + + + +

    My 4th semester involves ARM programming. And proprietary tooling (Keil C). But we don’t do that here.

    +

    Building

    +

    Assembling and linking ARM binaries on non-ARM architecture devices is fairly trivial. I went along with the GNU cross bare metal toolchain binutils, which provides arm-as and arm-ld (among a bunch of other utils that I don’t care about for now).

    Assemble .s files with:

    - -
    arm-none-eabi-as main.s -g -march=armv8.1-a -o main.out
    -
    - -

    The -g flag generates extra debugging information that -gdb picks up. The -march option establishes target -architecture.

    - +
    arm-none-eabi-as main.s -g -march=armv8.1-a -o main.out
    +

    The -g flag generates extra debugging information that gdb picks up. The -march option establishes target architecture.

    Link .o files with:

    - -
    arm-none-eabi-ld main.out -o main
    -
    - -

    Running (and Debugging)

    - -

    Things get interesting here. gdb on your x86 machine -cannot read nor execute binaries compiled for ARM. So, we -simulate an ARM processor using qemu. Now qemu allows you -to run gdbserver on startup. Connecting our local gdb -instance to gdbserver gives us a view into the program’s -execution. Easy!

    - -

    Run qemu, with gdbserver on port 1234, with our ARM -binary, main:

    - -
    qemu-arm -singlestep -g 1234 main
    -
    - -

    Start up gdb on your machine, and connect to qemu’s -gdbserver:

    - +
    arm-none-eabi-ld main.out -o main
    +

    Running (and Debugging)

    +

    Things get interesting here. gdb on your x86 machine cannot read nor execute binaries compiled for ARM. So, we simulate an ARM processor using qemu. Now qemu allows you to run gdbserver on startup. Connecting our local gdb instance to gdbserver gives us a view into the program’s execution. Easy!

    +

    Run qemu, with gdbserver on port 1234, with our ARM binary, main:

    +
    qemu-arm -singlestep -g 1234 main
    +

    Start up gdb on your machine, and connect to qemu’s gdbserver:

    (gdb) set architecture armv8-a
     (gdb) target remote localhost:1234
     (gdb) file main
    -Reading symbols from main...  # yay!
    -
    - -

    GDB Enhanced

    - -

    gdb is cool, but it's not nearly as comfortable as well -fleshed out emulators/IDEs like Keil. Watching registers, -CPSR and memory chunks update is pretty fun.

    - -

    I came across gdb's TUI mode (hit C-x C-a or type tui -enable at the prompt). TUI mode is a godsend. It highlights -the current line of execution, shows you disassembly -outputs, updated registers, active breakpoints and more.

    - +Reading symbols from main... # yay! +

    GDB Enhanced

    +

    gdb is cool, but it’s not nearly as comfortable as well fleshed out emulators/IDEs like Keil. Watching registers, CPSR and memory chunks update is pretty fun.

    +

    I came across gdb’s TUI mode (hit C-x C-a or type tui enable at the prompt). TUI mode is a godsend. It highlights the current line of execution, shows you disassembly outputs, updated registers, active breakpoints and more.

    But, it is an absolute eyesore.

    - -

    Say hello to GEF! “GDB -Enhanced Features” teaches our old dog some cool new tricks. -Here are some additions that made my ARM debugging -experience loads better:

    - +

    Say hello to GEF! “GDB Enhanced Features” teaches our old dog some cool new tricks. Here are some additions that made my ARM debugging experience loads better:

    - -

    And it's pretty! See for yourself:

    - -

    gef.png

    - -

    Editing

    - -

    Vim, with syntax off because it -dosen't handle GNU ARM syntax too well.

    +

    And it’s pretty! See for yourself:

    +

    +

    Editing

    +

    Vim, with syntax off because it dosen’t handle GNU ARM syntax too well.

    + +
    diff --git a/docs/posts/color_conundrum/index.html b/docs/posts/color_conundrum/index.html index 2001226..f732fd0 100644 --- a/docs/posts/color_conundrum/index.html +++ b/docs/posts/color_conundrum/index.html @@ -37,42 +37,36 @@ Color Conundrum
    -

    This piece aims to highlight (pun intended) some of the -reasons behind my color -free editor setup.

    - -

    Imagine highlighting an entire book because all of it is -important. That is exactly what (most) syntax highlighting -does. It is difficult for the human eye to filter out noise -in rainbow barf. Use color to draw attention, not diverge -it.

    - -

    At the same time, a book devoid of color is boring! What -is the takeaway from this 10 line paragraph? What are the -technical terms used?

    - -

    Prose and code are certainly different, but the fickle -minded human eye is the same. The eye constantly looks for a -frame of reference, a focal point. It grows tired when it -can't find one.

    - -

    The following comparison does a better job of explaining -(none, ample and over-the-top highlighting, from left to -right):

    - -

    hi.png

    - -

    Without highlighting (far left), it is hard to differentiate -between comments and code! The florid color scheme (far -right) is no good either, it contains too many attention -grabbers. The center sample is a healthy balance of both. -Function calls and constants stand out, and repetitive -keywords and other noise (let, as) are mildly dimmed -out. Comments and non-code text (sign column, status text) -are dimmed further.

    - -

    I'll stop myself before I rant about color contrast and -combinations.

    + + + + + + + color_conundrum + + + + +

    This piece aims to highlight (pun intended) some of the reasons behind my color free editor setup.

    +

    Imagine highlighting an entire book because all of it is important. That is exactly what (most) syntax highlighting does. It is difficult for the human eye to filter out noise in rainbow barf. Use color to draw attention, not diverge it.

    +

    At the same time, a book devoid of color is boring! What is the takeaway from this 10 line paragraph? What are the technical terms used?

    +

    Prose and code are certainly different, but the fickle minded human eye is the same. The eye constantly looks for a frame of reference, a focal point. It grows tired when it can’t find one.

    +

    The following comparison does a better job of explaining (none, ample and over-the-top highlighting, from left to right):

    +

    +

    Without highlighting (far left), it is hard to differentiate between comments and code! The florid color scheme (far right) is no good either, it contains too many attention grabbers. The center sample is a healthy balance of both. Function calls and constants stand out, and repetitive keywords and other noise (let, as) are mildly dimmed out. Comments and non-code text (sign column, status text) are dimmed further.

    +

    I’ll stop myself before I rant about color contrast and combinations.

    + +
    diff --git a/docs/posts/font_size_fallacies/index.html b/docs/posts/font_size_fallacies/index.html index 804dea2..f8bffad 100644 --- a/docs/posts/font_size_fallacies/index.html +++ b/docs/posts/font_size_fallacies/index.html @@ -37,99 +37,58 @@ Font Size Fallacies
    -

    I am not an expert with fonts, but I do have some -experience 1, and common sense. This post aims to debunk some -misconceptions about font sizes!

    - -

    11 px on your display is probably not 11 px on my display. -Let's do some quick math. I have two displays, 1366x768 @ -21” and another with 1920x1080 @ 13”, call them A and -B for now.

    - -

    Display A has 1,049,088 pixels. A pixel is a square, of -side say, s cm. The total area covered by my 21” display -is about 1,066 cm2 (41x26). Thus,

    - + + + + + + + font_size_fallacies + + + + +

    I am not an expert with fonts, but I do have some experience 1, and common sense. This post aims to debunk some misconceptions about font sizes!

    +

    11 px on your display is probably not 11 px on my display. Let’s do some quick math. I have two displays, 1366x768 @ 21" and another with 1920x1080 @ 13", call them A and B for now.

    +

    Display A has 1,049,088 pixels. A pixel is a square, of side say, s cm. The total area covered by my 21" display is about 1,066 cm^2 (41x26). Thus,

    Display A
    -Dimensions: 1366x768 @ 21" (41x26 sq. cm)
    +Dimensions: 1366x768 @ 21" (41x26 sq. cm)
     1,049,088 s^2 = 1066
    -            s = 0.0318 cm (side of a pixel on Display A)
    -
    - -

    Bear with me, as I repeat the number crunching for Display -B:

    - + s = 0.0318 cm (side of a pixel on Display A) +

    Bear with me, as I repeat the number crunching for Display B:

    Display B
    -Dimensions: 1920x1080 @ 13" (29.5x16.5 sq. cm)
    +Dimensions: 1920x1080 @ 13" (29.5x16.5 sq. cm)
     2,073,600 s^2 = 486.75
    -            s = 0.0153 cm (side of a pixel on Display B)
    -
    - -

    The width of a pixel on Display A is double the width of a -pixel on Display B. The area occupied by a pixel on Display -A is 4 times the area occupied by a pixel on Display B.

    - + s = 0.0153 cm (side of a pixel on Display B) +

    The width of a pixel on Display A is double the width of a pixel on Display B. The area occupied by a pixel on Display A is 4 times the area occupied by a pixel on Display B.

    The size of a pixel varies from display to display!

    - -

    A 5x11 bitmap font on Display A would be around 4 mm tall -whereas the same bitmap font on Display B would be around -1.9 mm tall. A 11 px tall character on B is visually -equivalent to a 5 px character on A. When you view a -screenshot of Display A on Display B, the contents are -shrunk down by a factor of 2!

    - -

    So screen resolution is not enough, how else do we measure -size? Pixel Density! Keen readers will realize that the 5th -grade math problem we solved up there showcases pixel -density, or, pixels per cm (PPCM). Usually we deal with -pixels per inch (PPI).

    - -

    Note: PPI is not to be confused with DPI 2 (dots -per inch). DPI is defined for printers.

    - -

    In our example, A is a 75 ppi display and B is around -165 ppi 3. A low ppi display appears to be -‘pixelated’, because the pixels are more prominent, much -like Display A. A higher ppi usually means you can view -larger images and render crispier fonts. The average desktop -display can stuff 100-200 pixels per inch. Smart phones -usually fall into the 400-600 ppi (XXXHDPI) category. The -human eye fails to differentiate detail past 300 ppi.

    - -

    So … streaming an 8K video on a 60” TV provides the same -clarity as a HD video on a smart phone?

    - -

    Absolutely. Well, clarity is subjective, but the amount of -detail you can discern on mobile displays has always been -limited. Salty consumers of the Xperia 1 4 will say -otherwise.

    - -

    Maybe I will talk about font rendering in another post, but -thats all for now. Don't judge a font size by its -screenshot.

    - -
    -
    +

    A 5x11 bitmap font on Display A would be around 4 mm tall whereas the same bitmap font on Display B would be around 1.9 mm tall. A 11 px tall character on B is visually equivalent to a 5 px character on A. When you view a screenshot of Display A on Display B, the contents are shrunk down by a factor of 2!

    +

    So screen resolution is not enough, how else do we measure size? Pixel Density! Keen readers will realize that the 5^th grade math problem we solved up there showcases pixel density, or, pixels per cm (PPCM). Usually we deal with pixels per inch (PPI).

    +

    Note: PPI is not to be confused with DPI 2 (dots per inch). DPI is defined for printers.

    +

    In our example, A is a 75 ppi display and B is around 165 ppi 3. A low ppi display appears to be ‘pixelated’, because the pixels are more prominent, much like Display A. A higher ppi usually means you can view larger images and render crispier fonts. The average desktop display can stuff 100-200 pixels per inch. Smart phones usually fall into the 400-600 ppi (XXXHDPI) category. The human eye fails to differentiate detail past 300 ppi.

    +

    So … streaming an 8K video on a 60" TV provides the same clarity as a HD video on a smart phone?

    +

    Absolutely. Well, clarity is subjective, but the amount of detail you can discern on mobile displays has always been limited. Salty consumers of the Xperia 1 4 will say otherwise.

    +

    Maybe I will talk about font rendering in another post, but thats all for now. Don’t judge a font size by its screenshot.

    +
    +
      - -
    1. -

      https://github.com/nerdypepper/scientifica 

      -
    2. - -
    3. -

      https://en.wikipedia.org/wiki/Dots_per_inch 

      -
    4. - -
    5. -

      https://www.sven.de/dpi/ 

      -
    6. - -
    7. -

      https://en.wikipedia.org/wiki/Sony_Xperia_1 

      -
    8. - +
    9. https://github.com/nerdypepper/scientifica↩︎

    10. +
    11. https://en.wikipedia.org/wiki/Dots_per_inch↩︎

    12. +
    13. https://www.sven.de/dpi/↩︎

    14. +
    15. https://en.wikipedia.org/wiki/Sony_Xperia_1↩︎

    -
    + + +
    diff --git a/docs/posts/get_better_at_yanking_and_putting_in_vim/index.html b/docs/posts/get_better_at_yanking_and_putting_in_vim/index.html index d4e8fb4..6536f6d 100644 --- a/docs/posts/get_better_at_yanking_and_putting_in_vim/index.html +++ b/docs/posts/get_better_at_yanking_and_putting_in_vim/index.html @@ -37,28 +37,45 @@ Get Better At Yanking And Putting In Vim
    -
      + + + + + + + get_better_at_yanking_and_putting_in_vim + + + + +

      a couple of nifty tricks to help you copy-paste better:

      +
      1. reselecting previously selected text (i use this to fix botched selections):

        - -
        gv  " :h gv for more
        -    " you can use `o` in visual mode to go to the `Other` end of the selection
        -    " use a motion to fix the selection
        -
      2. +
        gv  " :h gv for more
        +    " you can use `o` in visual mode to go to the `Other` end of the selection
        +    " use a motion to fix the selection
      3. reselecting previously yanked text:

        -
        `[v`]
        -`[         " marks the beginning of the previously yanked text   :h `[
        -`]         " marks the end                                       :h `]
        - v         " visual select everything in between
        +`[         " marks the beginning of the previously yanked text   :h `[
        +`]         " marks the end                                       :h `]
        + v         " visual select everything in between
         
        -nnoremap gb `[v`]    " "a quick map to perform the above
        -
      4. +nnoremap gb `[v`] " "a quick map to perform the above
      5. pasting and indenting text (in one go):

        - -
        ]p   " put (p) and adjust indent to current line
        -]P   " put the text before the cursor (P) and adjust indent to current line
        -
      6. +
        ]p   " put (p) and adjust indent to current line
        +]P   " put the text before the cursor (P) and adjust indent to current line
      + +
    diff --git a/docs/posts/hold_position!/index.html b/docs/posts/hold_position!/index.html index 58851c5..b14d41a 100644 --- a/docs/posts/hold_position!/index.html +++ b/docs/posts/hold_position!/index.html @@ -37,27 +37,36 @@ Hold Position!
    -

    Often times, when I run a vim command that makes “big” changes to a file (a -macro or a :vimgrep command) I lose my original position and feel disoriented.

    - + + + + + + + hold_position! + + + + +

    Often times, when I run a vim command that makes “big” changes to a file (a macro or a :vimgrep command) I lose my original position and feel disoriented.

    Save position with winsaveview()!

    - -

    The winsaveview() command returns a Dictionary that contains information -about the view of the current window. This includes the cursor line number, -cursor coloumn, the top most line in the window and a couple of other values, -none of which concern us.

    - -

    Before running our command (one that jumps around the buffer, a lot), we save -our view, and restore it once its done, with winrestview.

    - +

    The winsaveview() command returns a Dictionary that contains information about the view of the current window. This includes the cursor line number, cursor coloumn, the top most line in the window and a couple of other values, none of which concern us.

    +

    Before running our command (one that jumps around the buffer, a lot), we save our view, and restore it once its done, with winrestview.

    let view = winsaveview()
    -s/\s\+$//gc              " find and (confirm) replace trailing blanks
    -winrestview(view)        " restore our original view!
    -
    - -

    It might seem a little overkill in the above example, just use `` (double -backticks) instead, but it comes in handy when you run your file through -heavier filtering.

    +s/\s\+$//gc " find and (confirm) replace trailing blanks +winrestview(view) " restore our original view! +

    It might seem a little overkill in the above example, just use `` (double backticks) instead, but it comes in handy when you run your file through heavier filtering.

    + +
    diff --git a/docs/posts/my_setup/index.html b/docs/posts/my_setup/index.html index c3812ec..aaad548 100644 --- a/docs/posts/my_setup/index.html +++ b/docs/posts/my_setup/index.html @@ -37,32 +37,34 @@ My Setup
    -

    Decided to do one of these because everyone does one of -these.

    - -

    scrot

    - -

    My entire setup is managed with GNU stow, making it easier -to replicate on fresh installations. You can find my -configuration files on GitHub.

    - -

    I run Void Linux (glibc) on my -HP Envy 13” (2018). -To keep things simple, I run a raw X session with 2bwm as my -window manager, along with dunst (notification daemon) and -Sam's compton -(compositor) fork.

    - -

    I am a fan of GNU tools, so I use bash as my shell, and -coreutils to manage files, archives, strings, paths etc. I -edit files with vim, chat with weechat, listen to music -with cmus, monitor processes with htop, manage sessions -with tmux, read pdfs in zathura. I rarely ever leave -the comfort of my terminal emulator, urxvt.

    - -

    Most of my academic typesetting is done with TeX, and -compiled with xelatex. Other fun documents are made with -GIMP :).

    + + + + + + + my_setup + + + + +

    Decided to do one of these because everyone does one of these.

    +

    +

    My entire setup is managed with GNU stow, making it easier to replicate on fresh installations. You can find my configuration files on GitHub.

    +

    I run Void Linux (glibc) on my HP Envy 13" (2018). To keep things simple, I run a raw X session with 2bwm as my window manager, along with dunst (notification daemon) and Sam’s compton (compositor) fork.

    +

    I am a fan of GNU tools, so I use bash as my shell, and coreutils to manage files, archives, strings, paths etc. I edit files with vim, chat with weechat, listen to music with cmus, monitor processes with htop, manage sessions with tmux, read pdfs in zathura. I rarely ever leave the comfort of my terminal emulator, urxvt.

    +

    Most of my academic typesetting is done with TeX, and compiled with xelatex. Other fun documents are made with GIMP :).

    + +
    diff --git a/docs/posts/onivim_sucks/index.html b/docs/posts/onivim_sucks/index.html index c2c6ffe..9635c8c 100644 --- a/docs/posts/onivim_sucks/index.html +++ b/docs/posts/onivim_sucks/index.html @@ -37,33 +37,33 @@ Onivim Sucks
    -

    Onivim is a ‘modern modal editor’, combining fancy -interface and language features with vim-style modal editing. What's wrong you -ask?

    - -

    Apart from buggy syntax highlighting, -broken scrolling and -others, -Onivim is proprietary software. It is licensed under a commercial -end user agreement license, -which prohibits redistribution in both object code and source code formats.

    - -

    Onivim's core editor logic (bits that belong to vim), have been separated from -the interface, into libvim. libvim is -licensed under MIT, which means, this ‘extension’ of vim is perfectly in -adherence to vim's license text! -Outrun Labs are exploiting this loophole (distributing vim as a library) to -commercialize Onivim.

    - -

    Onivim's source code is available on GitHub. -They do mention that the source code trickles down to the -oni2-mit repository, which (not yet) contains -MIT-licensed code, 18 months after each commit to the original repository.

    - -

    Want to contribute to Onivim? Don't. They make a profit out of your contributions. -Currently, Onivim is priced at $19.99, ‘pre-alpha’ pricing which is 80% off the -final price! If you are on the lookout for an editor, I would suggest using -Vim, charity ware that actually works, and costs $100 lesser.

    + + + + + + + onivim_sucks + + + + +

    Onivim is a ‘modern modal editor’, combining fancy interface and language features with vim-style modal editing. What’s wrong you ask?

    +

    Apart from buggy syntax highlighting, broken scrolling and others, Onivim is proprietary software. It is licensed under a commercial end user agreement license, which prohibits redistribution in both object code and source code formats.

    +

    Onivim’s core editor logic (bits that belong to vim), have been separated from the interface, into libvim. libvim is licensed under MIT, which means, this ‘extension’ of vim is perfectly in adherence to vim’s license text! Outrun Labs are exploiting this loophole (distributing vim as a library) to commercialize Onivim.

    +

    Onivim’s source code is available on GitHub. They do mention that the source code trickles down to the oni2-mit repository, which (not yet) contains MIT-licensed code, 18 months after each commit to the original repository.

    +

    Want to contribute to Onivim? Don’t. They make a profit out of your contributions. Currently, Onivim is priced at $19.99, ‘pre-alpha’ pricing which is 80% off the final price! If you are on the lookout for an editor, I would suggest using Vim, charity ware that actually works, and costs $100 lesser.

    + +
    diff --git a/docs/posts/pixel_art_in_GIMP/index.html b/docs/posts/pixel_art_in_GIMP/index.html index 5caa446..7bd1eed 100644 --- a/docs/posts/pixel_art_in_GIMP/index.html +++ b/docs/posts/pixel_art_in_GIMP/index.html @@ -37,146 +37,77 @@ Pixel Art In GIMP
    -

    I've always been an admirer of pixel art, because of it’s -simplicity and it's resemblance to bitmap font design. -Recently, I decided to take the dive and make some art of my -own.

    - -

    I used GIMP because I am fairly familiar with it. Aseprite -seems to be the editor of choice for animated pixel art -though.

    - -

    Setting up the canvas

    - -

    Picking a canvas size is daunting. Too small, and you won’t -be able to fit in enough detail to make a legible piece. Too -big and you've got too many pixels to work with!

    - -

    I would suggest starting out with anywhere between 100x100 -and 200x200. Here’s a sample -configuration.

    - -

    Sometimes I use a 10x10 grid, View > Show Grid and Edit > -Preferences > Default Grid > Spacing, but that can get -jarring, so I throw down a couple of guides, drag right or -down from the left or top gutters for vertical and -horizontal guides respectively.

    - -

    Choosing a Brush

    - -

    The most important part of our setup is the brush. Use the -Pencil Tool (n on the keyboard) for hard edge drawings. -Here's a small comparison if you don't know the difference -between a hard edge and a soft edge:

    - -

    hard edge vs soft edge

    - -

    I turn the size down all the way to 1 ([ on the keyboard). -Set Dynamics off. Here’s a -sample brush configuration.

    - -

    Laying down the pixels!

    - -

    With the boring stuff out of the way, we can start with our -piece. I usually follow a three step process:

    - + + + + + + + pixel_art_in_GIMP + + + + +

    I’ve always been an admirer of pixel art, because of it’s simplicity and it’s resemblance to bitmap font design. Recently, I decided to take the dive and make some art of my own.

    +

    I used GIMP because I am fairly familiar with it. Aseprite seems to be the editor of choice for animated pixel art though.

    +

    Setting up the canvas

    +

    Picking a canvas size is daunting. Too small, and you won’t be able to fit in enough detail to make a legible piece. Too big and you’ve got too many pixels to work with!

    +

    I would suggest starting out with anywhere between 100x100 and 200x200. Here’s a sample configuration.

    +

    Sometimes I use a 10x10 grid, View > Show Grid and Edit > Preferences > Default Grid > Spacing, but that can get jarring, so I throw down a couple of guides, drag right or down from the left or top gutters for vertical and horizontal guides respectively.

    +

    Choosing a Brush

    +

    The most important part of our setup is the brush. Use the Pencil Tool (n on the keyboard) for hard edge drawings. Here’s a small comparison if you don’t know the difference between a hard edge and a soft edge:

    +
    +
    Hard edge vs Soft Edge
    +
    +

    I turn the size down all the way to 1 ([ on the keyboard). Set Dynamics off. Here’s a sample brush configuration.

    +

    Laying down the pixels!

    +

    With the boring stuff out of the way, we can start with our piece. I usually follow a three step process:

    - -

    But this process is better explained with an example: an -onigiri. Let us start off with a 100x100 canvas.

    - -

    Drawing the outline

    - -

    For the most part, our figure will be symmetric. If you are -on GIMP 2.10+, you can take advantage of the Symmetry -Painting feature. Go ahead and enable vertical symmetry, -Window > Dockable Dialogs > Symmetry Painting and -Symmetry Painting > Symmetry > Mirror > Vertical.

    - -

    If you are running an older version of GIMP, draw in the -left side, duplicate the layer, flip it horizontally, and -merge it with the original.

    - +

    But this process is better explained with an example: an onigiri. Let us start off with a 100x100 canvas.

    +

    Drawing the outline

    +

    For the most part, our figure will be symmetric. If you are on GIMP 2.10+, you can take advantage of the Symmetry Painting feature. Go ahead and enable vertical symmetry, Window > Dockable Dialogs > Symmetry Painting and Symmetry Painting > Symmetry > Mirror > Vertical.

    +

    If you are running an older version of GIMP, draw in the left side, duplicate the layer, flip it horizontally, and merge it with the original.

    Your outline might look something like this:

    - -

    rice_outline

    - -

    Go ahead and fill it in with the fill tool (Shift + b on -the keyboard), add in some seaweed as well, preferably on a -different layer. You can toggle symmetry on and off to save -yourself some time.

    - -

    with_seaweed

    - -

    Shadows

    - -

    For now, let us focus on the shadows on the object itself, -we'll come back to the shadows cast by the object on the -surface later.

    - -

    Shadows on any surface always follow the shape of the -surface. A spherical onigiri would have a circular shadow:

    - -

    riceball_shadow

    - +

    +

    Go ahead and fill it in with the fill tool (Shift + b on the keyboard), add in some seaweed as well, preferably on a different layer. You can toggle symmetry on and off to save yourself some time.

    +

    +

    Shadows

    +

    For now, let us focus on the shadows on the object itself, we’ll come back to the shadows cast by the object on the surface later.

    +

    Shadows on any surface always follow the shape of the surface. A spherical onigiri would have a circular shadow:

    +

    A couple of noticeable changes:

    - -

    Layers: The layer containing the seaweed has been hidden.
    -Color: The color of the shadow is just a slightly -lighter version of the original object (reduce the Value on -the HSV scale).
    -Area: The shadow does not go all the way (notice the bottom -edges).

    - -

    The shadow does not go all the way because we will be -filling in that area with another, darker shadow! An image -might explain better:

    - -

    shadow_all

    - -

    To emulate soft lights, reduce the value by 2 to 3 points -every iteration. Notice how area 1 is much larger than -area 4. This is because an onigiri resembles a bottom -heavy oblate spheroid, a sphere that is slightly fatter -around the lower bottom, and areas 1 and 2 catch more -light than areas 3 and 4.

    - -

    Do the same with the seaweed. The seaweed, being a smaller, -flatter object, doesn't cast much of a shadow, so stop with -1 or 2 iterations of the gradient:

    - -

    shadow_weed

    - -

    We're getting there!

    - -

    Highlights

    - -

    This step handles the details on the strongly illuminated -portions of the object. Seaweed is a bit glossy, lighten the -edges to make it seem shiny. The rice is not as shiny, but -it does form an uneven surface. Add in some shadows to -promote the idea of rice grains. Here is the finished -result:

    - -

    highlights

    - -

    Finishing Touches

    - -

    Some color correction and a e s t h e t i c Japanese text -later, our piece is complete!

    - -

    small_onigiri

    - -

    Hold on, why is it so tiny? Well, that's because our canvas -was 100x100, head over to Image > Scale Image, set -Quality > Interpolation to None and scale it up to -700x700, et voilà!

    - -

    big_onigiri

    +

    Layers: The layer containing the seaweed has been hidden.
    +Color: The color of the shadow is just a slightly lighter version of the original object (reduce the Value on the HSV scale).
    +Area: The shadow does not go all the way (notice the bottom edges).

    +

    The shadow does not go all the way because we will be filling in that area with another, darker shadow! An image might explain better:

    +

    +

    To emulate soft lights, reduce the value by 2 to 3 points every iteration. Notice how area 1 is much larger than area 4. This is because an onigiri resembles a bottom heavy oblate spheroid, a sphere that is slightly fatter around the lower bottom, and areas 1 and 2 catch more light than areas 3 and 4.

    +

    Do the same with the seaweed. The seaweed, being a smaller, flatter object, doesn’t cast much of a shadow, so stop with 1 or 2 iterations of the gradient:

    +

    +

    We’re getting there!

    +

    Highlights

    +

    This step handles the details on the strongly illuminated portions of the object. Seaweed is a bit glossy, lighten the edges to make it seem shiny. The rice is not as shiny, but it does form an uneven surface. Add in some shadows to promote the idea of rice grains. Here is the finished result:

    +

    +

    Finishing Touches

    +

    Some color correction and a e s t h e t i c Japanese text later, our piece is complete!

    +

    +

    Hold on, why is it so tiny? Well, that’s because our canvas was 100x100, head over to Image > Scale Image, set Quality > Interpolation to None and scale it up to 700x700, et voilà!

    +

    + +
    diff --git a/docs/posts/rapid_refactoring_with_vim/index.html b/docs/posts/rapid_refactoring_with_vim/index.html index a309066..36d06fc 100644 --- a/docs/posts/rapid_refactoring_with_vim/index.html +++ b/docs/posts/rapid_refactoring_with_vim/index.html @@ -37,207 +37,161 @@ Rapid Refactoring With Vim
    -

    Last weekend, I was tasked with refactoring the 96 unit -tests on -ruma-events -to use strictly typed json objects using serde_json::json! -instead of raw strings. It was rather painless thanks to -vim :)

    - -

    Here's a small sample of what had to be done (note the lines -prefixed with the arrow):

    - -
    → use serde_json::{from_str};
    -  
    -  #[test]
    -  fn deserialize() {
    -    assert_eq!(
    -→       from_str::<Action>(r#"{"set_tweak": "highlight"}"#),
    -        Action::SetTweak(Tweak::Highlight { value: true })
    -        );
    -  }
    -
    - + + + + + + + rapid_refactoring_with_vim + + + + +

    Last weekend, I was tasked with refactoring the 96 unit tests on ruma-events to use strictly typed json objects using serde_json::json! instead of raw strings. It was rather painless thanks to vim :)

    +

    Here’s a small sample of what had to be done (note the lines prefixed with the arrow):

    +
    use serde_json::{from_str};
    +  
    +  #[test]
    +  fn deserialize() {
    +    assert_eq!(
    +from_str::<Action>(r#"{"set_tweak": "highlight"}"#),
    +        Action::SetTweak(Tweak::Highlight { value: true })
    +        );
    +  }

    had to be converted to:

    - -
    → use serde_json::{from_value};
    -  
    -  #[test]
    -  fn deserialize() {
    -    assert_eq!(
    -→       from_value::<Action>(json!({"set_tweak": "highlight"})),
    -        Action::SetTweak(Tweak::Highlight { value: true })
    -        );
    -  }
    -
    - -

    The arglist

    - -

    For the initial pass, I decided to handle imports, this was -a simple find and replace operation, done to all the files -containing tests. Luckily, modules (and therefore files) -containing tests in Rust are annotated with the -#[cfg(test)] attribute. I opened all such files:

    - -
    # `grep -l pattern files` lists all the files
    -#  matching the pattern
    -
    -vim $(grep -l 'cfg\(test\)' ./**/*.rs)
    -
    -# expands to something like:
    -vim push_rules.rs room/member.rs key/verification/lib.rs
    -
    - -

    Starting vim with more than one file at the shell prompt -populates the arglist. Hit :args to see the list of -files currently ready to edit. The square [brackets] -indicate the current file. Navigate through the arglist -with :next and :prev. I use tpope's vim-unimpaired -1, which adds ]a and [a, mapped to :next and -:prev.

    - -

    All that's left to do is the find and replace, for which we -will be using vim's argdo, applying a substitution to -every file in the arglist:

    - -
    :argdo s/from_str/from_value/g
    -
    - -

    The quickfix list

    - -

    Next up, replacing r#" ... "# with json!( ... ). I -couldn't search and replace that trivially, so I went with a -macro call 2 instead, starting with the cursor on -‘r’, represented by the caret, in my attempt to breakdown -the process:

    - -
    BUFFER:    r#" ... "#;
    +
    use serde_json::{from_value};
    +  
    +  #[test]
    +  fn deserialize() {
    +    assert_eq!(
    +from_value::<Action>(json!({"set_tweak": "highlight"})),
    +        Action::SetTweak(Tweak::Highlight { value: true })
    +        );
    +  }
    +

    The arglist

    +

    For the initial pass, I decided to handle imports, this was a simple find and replace operation, done to all the files containing tests. Luckily, modules (and therefore files) containing tests in Rust are annotated with the #[cfg(test)] attribute. I opened all such files:

    +
    # `grep -l pattern files` lists all the files
    +#  matching the pattern
    +
    +vim $(grep -l 'cfg\(test\)' ./**/*.rs)
    +
    +# expands to something like:
    +vim push_rules.rs room/member.rs key/verification/lib.rs
    +

    Starting vim with more than one file at the shell prompt populates the arglist. Hit :args to see the list of files currently ready to edit. The square [brackets] indicate the current file. Navigate through the arglist with :next and :prev. I use tpope’s vim-unimpaired 1, which adds ]a and [a, mapped to :next and :prev.

    +

    All that’s left to do is the find and replace, for which we will be using vim’s argdo, applying a substitution to every file in the arglist:

    +
    :argdo s/from_str/from_value/g
    +

    The quickfix list

    +

    Next up, replacing r#" ... "# with json!( ... ). I couldn’t search and replace that trivially, so I went with a macro call 2 instead, starting with the cursor on ‘r’, represented by the caret, in my attempt to breakdown the process:

    +
    BUFFER:    r#" ... "#;
                ^
     
     ACTION:    vllsjson!(
     
    -BUFFER     json!( ... "#;
    +BUFFER     json!( ... "#;
                     ^
     
    -ACTION:    <esc>$F#
    +ACTION:    <esc>$F#
     
    -BUFFER:    json!( ... "#;
    +BUFFER:    json!( ... "#;
                            ^
     
    -ACTION:    vhs)<esc>
    -
    -BUFFER:    json!( ... );
    -
    - -

    Here's the recorded 3 macro in all its glory: -vllsjson!(<esc>$F#vhs)<esc>.

    - -

    Great! So now we just go ahead, find every occurrence of -r# and apply the macro right? Unfortunately, there were -more than a few occurrences of raw strings that had to stay -raw strings. Enter, the quickfix list.

    - -

    The idea behind the quickfix list is to jump from one -position in a file to another (maybe in a different file), -much like how the arglist lets you jump from one file to -another.

    - -

    One of the easiest ways to populate this list with a bunch -of positions is to use vimgrep:

    +ACTION: vhs)<esc> +BUFFER: json!( ... );
    +

    Here’s the recorded 3 macro in all its glory: vllsjson!(<esc>$F#vhs)<esc>.

    +

    Great! So now we just go ahead, find every occurrence of r# and apply the macro right? Unfortunately, there were more than a few occurrences of raw strings that had to stay raw strings. Enter, the quickfix list.

    +

    The idea behind the quickfix list is to jump from one position in a file to another (maybe in a different file), much like how the arglist lets you jump from one file to another.

    +

    One of the easiest ways to populate this list with a bunch of positions is to use vimgrep:

    # basic usage
     :vimgrep pattern files
     
     # search for raw strings
    -:vimgrep 'r#' ./**/*.rs
    -
    - -

    Like :next and :prev, you can navigate the quickfix list -with :cnext and :cprev. Every time you move up or down -the list, vim indicates your index:

    - -
    (1 of 131): r#"{"set_tweak": "highlight"}"#;
    -
    - -

    And just like argdo, you can cdo to apply commands to -every match in the quickfix list:

    - -
    :cdo norm! @q
    -
    - -

    But, I had to manually pick out matches, and it involved -some button mashing.

    - -

    External Filtering

    - -

    Some code reviews later, I was asked to format all the json -inside the json! macro. All you have to do is pass a -visual selection through a pretty json printer. Select the -range to be formatted in visual mode, and hit :, you will -notice the command line displaying what seems to be -gibberish:

    - -
    :'<,'>
    -
    - -

    '< and '> are marks 4. More -specifically, they are marks that vim sets automatically -every time you make a visual selection, denoting the start -and end of the selection.

    - +:vimgrep 'r#' ./**/*.rs +

    Like :next and :prev, you can navigate the quickfix list with :cnext and :cprev. Every time you move up or down the list, vim indicates your index:

    +
    (1 of 131): r#"{"set_tweak": "highlight"}"#;
    +

    And just like argdo, you can cdo to apply commands to every match in the quickfix list:

    +
    :cdo norm! @q
    +

    But, I had to manually pick out matches, and it involved some button mashing.

    +

    External Filtering

    +

    Some code reviews later, I was asked to format all the json inside the json! macro. All you have to do is pass a visual selection through a pretty json printer. Select the range to be formatted in visual mode, and hit :, you will notice the command line displaying what seems to be gibberish:

    +
    :'<,'>
    +

    '< and '> are marks 4. More specifically, they are marks that vim sets automatically every time you make a visual selection, denoting the start and end of the selection.

    A range is one or more line specifiers separated by a ,:

    -
    :1,7       lines 1 through 7
     :32        just line 32
     :.         the current line
     :.,$       the current line to the last line
    -:'a,'b     mark 'a' to mark 'b'
    -
    - -

    Most : commands can be prefixed by ranges. :help -usr_10.txt for more on that.

    - -

    Alright, lets pass json through python -m json.tool, a -json formatter that accepts stdin (note the use of ! to -make use of an external program):

    - -
    :'<,'>!python -m json.tool
    -
    - -

    Unfortunately that didn't quite work for me because the -range included some non-json text as well, a mix of regex -and macros helped fix that. I think you get the drift.

    - -

    Another fun filter I use from time to time is :!sort, to -sort css attributes, or :!uniq to remove repeated imports.

    - -
    -
    +:'a,'b mark 'a' to mark 'b' +

    Most : commands can be prefixed by ranges. :help usr_10.txt for more on that.

    +

    Alright, lets pass json through python -m json.tool, a json formatter that accepts stdin (note the use of ! to make use of an external program):

    +
    :'<,'>!python -m json.tool
    +

    Unfortunately that didn’t quite work for me because the range included some non-json text as well, a mix of regex and macros helped fix that. I think you get the drift.

    +

    Another fun filter I use from time to time is :!sort, to sort css attributes, or :!uniq to remove repeated imports.

    +
    +
      - -
    1. -

      https://github.com/tpope/vim-unimpaired -It also handles various other mappings, ]q and [q to -navigate the quickfix list for example 

      -
    2. - -
    3. -

      :help recording 

      -
    4. - -
    5. -

      When I'm recording a macro, I prefer starting out by -storing it in register q, and then copying it over to -another register if it works as intended. I think of qq as -‘quick record’. 

      -
    6. - -
    7. -

      :help mark-motions 

      -
    8. - +
    9. https://github.com/tpope/vim-unimpaired It also handles various other mappings, ]q and [q to navigate the quickfix list for example↩︎

    10. +
    11. :help recording↩︎

    12. +
    13. When I’m recording a macro, I prefer starting out by storing it in register q, and then copying it over to another register if it works as intended. I think of qq as ‘quick record’.↩︎

    14. +
    15. :help mark-motions↩︎

    -
    + + +
    diff --git a/docs/posts/static_sites_with_bash/index.html b/docs/posts/static_sites_with_bash/index.html index 1919cea..fff53dc 100644 --- a/docs/posts/static_sites_with_bash/index.html +++ b/docs/posts/static_sites_with_bash/index.html @@ -37,61 +37,99 @@ Static Sites With Bash
    -

    After going through a bunch of static site generators -(pelican, -hugo, -vite), I decided to roll -my own. If you are more of the ‘show me the code’ kinda guy, -here you go.

    - -

    Text formatting

    - -

    I chose to write in markdown, and convert -to html with lowdown.

    - -

    Directory structure

    - -

    I host my site on GitHub pages, so -docs/ has to be the entry point. Markdown formatted posts -go into posts/, get converted into html, and end up in -docs/index.html, something like this:

    - -
    posts=$(ls -t ./posts)     # chronological order!
    -for f in $posts; do
    -    file="./posts/"$f      # `ls` mangled our file paths
    -    echo "generating post $file"
    -
    -    html=$(lowdown "$file")
    -    echo -e "html" >> docs/index.html
    -done
    -
    - -

    Assets

    - -

    Most static site generators recommend dropping image -assets into the site source itself. That does have it’s -merits, but I prefer hosting images separately:

    - -
    # strip file extension
    -ext="${1##*.}"
    -
    -# generate a random file name
    -id=$( cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 2 | head -n 1 )
    -id="$id.$ext"
    -
    -# copy to my file host
    -scp -P 443 "$1" emerald:files/"$id" 
    -echo "https://u.peppe.rs/$id"
    -
    - -

    Templating

    - -

    generate.sh -brings the above bits and pieces together (with some extra -cruft to avoid javascript). It uses sed to produce nice -titles from the file names (removes underscores, -title-case), and date(1) to add the date to each post -listing!

    + + + + + + + static_sites_with_bash + + + + +

    After going through a bunch of static site generators (pelican, hugo, vite), I decided to roll my own. If you are more of the ‘show me the code’ kinda guy, here you go.

    +

    Text formatting

    +

    I chose to write in markdown, and convert to html with lowdown.

    +

    Directory structure

    +

    I host my site on GitHub pages, so docs/ has to be the entry point. Markdown formatted posts go into posts/, get converted into html, and end up in docs/index.html, something like this:

    +
    posts=$(ls -t ./posts)     # chronological order!
    +for f in $posts; do
    +    file="./posts/"$f      # `ls` mangled our file paths
    +    echo "generating post $file"
    +
    +    html=$(lowdown "$file")
    +    echo -e "html" >> docs/index.html
    +done
    +

    Assets

    +

    Most static site generators recommend dropping image assets into the site source itself. That does have it’s merits, but I prefer hosting images separately:

    +
    # strip file extension
    +ext="${1##*.}"
    +
    +# generate a random file name
    +id=$( cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 2 | head -n 1 )
    +id="$id.$ext"
    +
    +# copy to my file host
    +scp -P 443 "$1" emerald:files/"$id" 
    +echo "https://u.peppe.rs/$id"
    +

    Templating

    +

    generate.sh brings the above bits and pieces together (with some extra cruft to avoid javascript). It uses sed to produce nice titles from the file names (removes underscores, title-case), and date(1) to add the date to each post listing!

    + +
    diff --git a/docs/posts/termux_tandem/index.html b/docs/posts/termux_tandem/index.html index 972f0e2..a2aba29 100644 --- a/docs/posts/termux_tandem/index.html +++ b/docs/posts/termux_tandem/index.html @@ -37,52 +37,46 @@ Termux Tandem
    -

    I learnt about termux from a friend on IRC recently. -It looked super gimmicky to me at first, but it eventually -proved to be useful. Here's what I use it for:

    - + + + + + + + termux_tandem + + + + +

    I learnt about termux from a friend on IRC recently. It looked super gimmicky to me at first, but it eventually proved to be useful. Here’s what I use it for:

    rsync

    - -

    Ever since I degoogled my android device, syncing files -between my phone and my PC has always been a pain. I’m -looking at you MTP. But, with termux and sshd all set up, -it's as simple as:

    - +

    Ever since I degoogled my android device, syncing files between my phone and my PC has always been a pain. I’m looking at you MTP. But, with termux and sshd all set up, it’s as simple as:

    $ arp
     Address         HWtype  HWad ...
     192.168.43.187  ether   d0:0 ...
     
    -$ rsync -avz 192.168.43.187:~/frogs ~/pics/frogs
    -
    - -

    ssh & tmux

    - -

    My phone doubles as a secondary view into my main machine -with ssh and tmux. When I am away from my PC (read: -sitting across the room), I check build status and IRC -messages by sshing into a tmux session running the said -build or weechat.

    - -

    file uploads

    - -

    Not being able to access my (ssh-only) file host was -crippling. With a bash instance on my phone, I just copied -over my ssh keys, and popped in a file upload script (a -glorified scp). Now I just have to figure out a way to -clean up these file names …

    - -
    ~/storage/pictures/ $ ls
    +$ rsync -avz 192.168.43.187:~/frogs ~/pics/frogs
    +

    ssh & tmux

    +

    My phone doubles as a secondary view into my main machine with ssh and tmux. When I am away from my PC (read: sitting across the room), I check build status and IRC messages by sshing into a tmux session running the said build or weechat.

    +

    file uploads

    +

    Not being able to access my (ssh-only) file host was crippling. With a bash instance on my phone, I just copied over my ssh keys, and popped in a file upload script (a glorified scp). Now I just have to figure out a way to clean up these file names …

    +
    ~/storage/pictures/ $ ls
     02muf5g7b2i41.jpg  7alt3cwg77841.jpg  cl4bsrge7id11.png
    -mtZabXG.jpg        p8d5c584f2841.jpg  vjUxGjq.jpg
    -
    - +mtZabXG.jpg p8d5c584f2841.jpg vjUxGjq.jpg

    cmus

    - -

    Alright, I don't really listen to music via cmus, but I -did use it a couple times when my default music player was -acting up. cmus is a viable option:

    - -

    cmus.png

    +

    Alright, I don’t really listen to music via cmus, but I did use it a couple times when my default music player was acting up. cmus is a viable option:

    +

    + +
    -- cgit v1.2.3