Sekai 🌐 πŸ—Ί

Sekai (δΈ–η•Œ) is the kanji for “the world”. That’s a great word because of the scale that it designates.

Icon in Hugo Navbar

Motivation

The original navbar in words took up half of the horizontal spaces of the viewport. I couldn’t add new items like “Tags” to display the tag list.

Work

Thanks to the pre field in Hugo Menus, one can easily add the icon as an HTML element by some editing on the template file.

{{ range .Site.Menus.main.ByWeight }}
  {{ if .HasChildren }}
    <li class="navlinks-container">
      {{ if .Pre }}
        <a class="navlinks-parent" title="{{ .Name }}">{{ .Pre }}</a>
      {{ else }}
        <a class="navlinks-parent">{{ .Name }}</a>
      {{ end }}
      <div class="navlinks-children">
        {{ range .Children }}
          {{ if .Pre }}
            <a title="{{ .Name }}" href="{{ .URL | relLangURL }}">{{ .Pre }}</a>
          {{ else }}
            <a href="{{ .URL  | relLangURL }}">{{ .Name }}</a>
          {{ end }}
        {{ end }}
      </div>
    </li>
  {{ else }}
    <li>
      {{ if .Pre }}
        <a title="{{ .Name }}" href="{{ .URL | relLangURL }}">{{ .Pre }}</a>
      {{ else }}
        <a href="{{ .URL | relLangURL }}">{{ .Name }}</a>
      {{ end }}
    </li>
  {{ end }}
{{ end }}
Hugo  icons  navbar 

Network Interface Name Detection in Conky

Once-off Conky config for network graphs

When one changes connection type (say, from ethernet to Wi-Fi), the interface name changes (e.g. eth0 β†’ wlan1). To avoid changing Conky config file all the time, here’s a little Lua function for finding the network interface name.

function findInterface()
    local handle = io.popen('ip a | grep "state UP" | cut -d: -f2 | tr -d " "')
    local result = handle:read('*a'):gsub('\n$','')
    handle:close()
    return result
end
  1. ip a gives everything about connection info. Each entry looks like

     3: wlp3s0f0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    
  2. Grep the “state UP” and extract the second field, using : as a delimiter. Trim off the spaces around.

    [Read More]
Conky  Lua 

Staticman Script in Pure JS

Staticman without jQuery

The official Staticman script sample depends on jQuery. I have been using jQuery in my Staticman script for nested comments for more than six months.

Recently, in the new release of Hugo Swift Theme, in which I’m a collaborator, one has removed all jQuery methods at commit f137efa4. Here’s the structure of the script:

  1. auxiliary functions like elem, elems, pushClass, deleteClass, etc.
  2. A self-executing function comments()
    • some necessary local variables
    • handleForm() consisting merely of an event listener handling form submission.
      • formToJSON(form) for converting the comment form to a JSON string.
      • fetch(url, {...}).then(...).catch(...) for submitting a sever request and handling its response. It calls showModal(...) and it contains resetForm().
    • a conditional form ? handleForm(form) : false; to execute the above method provided the existence of the comment form.
    • closeModal() and showModal() for closing and showing the modal respectively.
    • a conditional containsClass(body, show) ? closeModal() : false;.
    • a self-executing toogleForm() function. Nesting a self-executing function inside another one limits the namespace of variables. Even though there’s no new variable defined inside this function, there’s a need to wrap it with parenthesis () because toggleForm() is not called elsewhere, unlike toggleMenu(). If the if(button){...} statement comes out directly, we will not know that it’s doing.

Staticman With Introduction Theme

Goal

To port Huginn’s Staticman integration to Introduction.

Difficulties

I’ve used some class names from Minimal Mistakes since the modals in the original code clashes with Introduction’s mobile responsive card display for projects. If I had know the practice of prepending a CSS class to avoid overiding the CSS properties of other components of a web site, I wouldn’t have mixed this Jekyll theme with my template for nested comments.

Due to my existing work on my SASS file for Staticman + Introduction, I had decided to continue working with the class names in this SASS file. Changing the CSS class names in the JS script was easier than doing so in the SASS file since I was more familiar with the former.

[Read More]

CPU Temperature Display in Conky

Background

I’m using Conky for monitoring the system. After a system upgrade, the CPU temperatures were gone. Conky’s standard error showed the following.

Conky: can't open '/sys/class/hwmon/hwmon0/temp3_input': No such file or
directory please check your device or remove this var from Conky...

Source of message: https://bbs.archlinux.org/viewtopic.php?id=82231

An easy fix would be to adjust the following lines in .conkyrc according to the number N in /sys/class/hwmon/hwmonN containing the file temp3_input. (You may adjust the number 3 according to the number of CPU of your device.) The number of CPU can be found using grep -c ^processor /proc/cpuinfo.

[Read More]
Conky  CPU  Linux 

Animated GIF Screenshots on Ubuntu

Background

I’ve to take screenshots to demonstrate Conky’s visual output.

animated GIF screenshot taken by Byzanz

I’ve chosen Byzanz after reading this answer on Ask Ubuntu.

Peek is more user-friendly, but I prefer CLI’s precision. That’s feasible thanks to a comment mentioning xwininfo.

After typing xwininfo, click on the target window. Switching to adjacent workplace is possible.

$ xwininfo
xwininfo: Please select the window about which you
          would like information by clicking the
          mouse in that window.

xwininfo: Window id: 0x1c0000a "Desktop"

  Absolute upper-left X:  0
  Absolute upper-left Y:  0
  Relative upper-left X:  0
  Relative upper-left Y:  0
  Width: 1920
  Height: 1080
  Depth: 32
  Visual: 0x1a7
  Visual Class: TrueColor
  Border width: 0
  Class: InputOutput
  Colormap: 0x1c00009 (not installed)
  Bit Gravity State: NorthWestGravity
  Window Gravity State: NorthWestGravity
  Backing Store State: NotUseful
  Save Under State: no
  Map State: IsViewable
  Override Redirect State: no
  Corners:  +0+0  -0+0  -0-0  +0-0
  -geometry 1920x1080+0+0

The --x and --y parameters below correspond to the absolute upper-left position of the window.

[Read More]

More Static Nested Comments

Background

I’ve made nested comment support for Beautiful Hugo, which I’ve ported to other Hugo themes like Introduction, Hyde-hyde, etc.

Problem I

Some of those Hugo themes that I worked with did show the HTML form, but the CSS styles were gone on the GitLab Pages.

Reason I

This is due to the lack of resources/_gen/ in the indexed repo for themes making use of assets/.

Solution I

  1. Check that you have the required prerequisites. For example, Introduction requires autoprefixer and postcss-cli.
  2. Update submodule for the theme in the directory holding the source code of the static site.
  3. Type hugo [server] so that the resources are locally generated.
  4. Push the repo.

Problem II

The approach in my linked blog post is too complicated. It makes use of a mix of JavaScript and Hugo template. This can be hard to comprehend and port, since the file structure for JavaScripts isn’t the same in different themes. It’s better to make the internal referencing for nested comment display entirely in Hugo.

[Read More]

Huginn Theme With Staticman

Goal

To provide Staticman support to the Hugo theme Huginn.

Motivation

A Framagit user tried using the public GitLab instance but failed. Finally, he removed Staticman from his site and his Hugo theme.

If I had been notified, I would have explained that that was due to the constraint of gitlabBaseUrl, which could only take one GitLab instance.

In response to demand for Staticman from Framagit users, I set up another GitLab instance of Staticman API and forked some Hugo/Jekyll repo under the project page Staticman et GitLab Pages.

[Read More]

Right PATH to Linux

Roles of various config files

Background

Updated $\LaTeX$ version

From this $\TeX$-SE question about tlmgr, we see some advantages of installing $\TeX$Live directly from the official site:

  1. avoid errors due to outdated version of $\TeX$Live supplied by the OS’s package manager
  2. easier to manage packages with tlmgr.
  3. enjoy the newer version of $\TeX$Live not yet available in your current GNU/Linux version.

The installation took about 30 minutes and 5G in the disk. I’ve chosen a local installation as this didn’t require sudo privileges. The whole process went smooth and the system displayed a message about setting

[Read More]
Linux 

Package Versioning for Julia Projects

Resolved GLM installation error

Update: Thanks to JuliaRegistries/General#647, the version cap of the package Distributions has now been removed, so that one can directly install the package GLM along with Distributions v0.19.2.

Background

I’m reading the book Statistics with Julia, which makes use of GLM.

Problem

I encountered the following error, which I posted in the issue GLM.jl#311.

(v1.1) pkg> add GLM
 Resolving package versions...
ERROR: Unsatisfiable requirements detected for package GLM [38e38edf]:
 GLM [38e38edf] log:
 β”œβ”€possible versions are: [0.2.0-0.2.5, 0.3.0-0.3.2, 0.4.0-0.4.8, 0.5.0-0.5.6, 0
.6.0-0.6.1, 0.7.0, 0.8.0-0.8.1, 0.9.0, 0.10.0-0.10.1, 0.11.0, 1.0.0-1.0.2, 1.1.0
-1.1.1] or uninstalled
 β”œβ”€restricted to versions * by an explicit requirement, leaving only versions [0
.2.0-0.2.5, 0.3.0-0.3.2, 0.4.0-0.4.8, 0.5.0-0.5.6, 0.6.0-0.6.1, 0.7.0, 0.8.0-0.8
.1, 0.9.0, 0.10.0-0.10.1, 0.11.0, 1.0.0-1.0.2, 1.1.0-1.1.1]
 β”œβ”€restricted by compatibility requirements with DataFrames [a93c6f00] to versio
ns: [0.4.0-0.4.8, 0.5.0-0.5.6, 0.6.0-0.6.1, 0.7.0, 0.8.0-0.8.1, 0.9.0, 0.10.0-0.
10.1, 0.11.0, 1.0.0-1.0.2, 1.1.0-1.1.1] or uninstalled, leaving only versions: [
0.4.0-0.4.8, 0.5.0-0.5.6, 0.6.0-0.6.1, 0.7.0, 0.8.0-0.8.1, 0.9.0, 0.10.0-0.10.1,
 0.11.0, 1.0.0-1.0.2, 1.1.0-1.1.1]
 β”‚ └─DataFrames [a93c6f00] log:
 β”‚   β”œβ”€possible versions are: [0.1.0, 0.2.0-0.2.5, 0.3.0-0.3.16, 0.4.0-0.4.3, 0.
5.0-0.5.12, 0.6.0-0.6.11, 0.7.0-0.7.8, 0.8.0-0.8.5, 0.9.0-0.9.1, 0.10.0-0.10.1, 
0.11.0-0.11.7, 0.12.0, 0.13.0-0.13.1, 0.14.0-0.14.1, 0.15.0-0.15.2, 0.16.0, 0.17
.0-0.17.1, 0.18.0-0.18.2] or uninstalled
 β”‚   └─restricted to versions 0.18.2 by an explicit requirement, leaving only ve
rsions 0.18.2
 β”œβ”€restricted by compatibility requirements with StatsBase [2913bbd2] to version
s: [0.11.0, 1.0.0-1.0.2, 1.1.0-1.1.1] or uninstalled, leaving only versions: [0.
11.0, 1.0.0-1.0.2, 1.1.0-1.1.1]
 β”‚ └─StatsBase [2913bbd2] log:
 β”‚   β”œβ”€possible versions are: [0.1.0, 0.2.0-0.2.1, 0.2.3-0.2.10, 0.3.0-0.3.13, 0
.4.0-0.4.4, 0.5.0-0.5.3, 0.6.0-0.6.16, 0.7.0-0.7.4, 0.8.0-0.8.3, 0.9.0, 0.10.0, 
0.11.0-0.11.1, 0.12.0, 0.13.0-0.13.1, 0.14.0-0.14.1, 0.15.0, 0.16.0-0.16.1, 0.17
.0, 0.18.0, 0.19.0-0.19.5, 0.20.0-0.20.1, 0.22.0, 0.23.0-0.23.1, 0.24.0, 0.25.0,
 0.26.0, 0.27.0, 0.28.0-0.28.1, 0.29.0, 0.30.0] or uninstalled
 β”‚   └─restricted to versions 0.30.0 by an explicit requirement, leaving only ve
rsions 0.30.0
 └─restricted by compatibility requirements with Distributions [31c24e10] to ver
sions: uninstalled β€” no versions left
   └─Distributions [31c24e10] log:
     β”œβ”€possible versions are: [0.1.0-0.1.4, 0.2.0-0.2.13, 0.3.0, 0.6.4-0.6.7, 0.
7.0-0.7.6, 0.8.0-0.8.10, 0.9.0, 0.10.0-0.10.2, 0.11.0-0.11.1, 0.12.0-0.12.5, 0.1
3.0, 0.14.0-0.14.2, 0.15.0, 0.16.0-0.16.4, 0.17.0, 0.18.0, 0.19.1-0.19.2] or uni
nstalled
     └─restricted to versions 0.19.2 by an explicit requirement, leaving only ve
rsions 0.19.2

Discussion

Although the packages StatsBase and DataFrames appear in the above error message, the cause of this problem was actually the package Distributions.

[Read More]
Julia  GLM