Sekai 🌐 πŸ—Ί

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

Insensitive Laptop Touchpad

Log of my Ubuntu Tweak config

Problem

The touchpad on my new Ubuntu 18.04 LTS laptop was frozen. Toogling πŸ–± with <Fn>-<F4> didn’t worked.

Attempt

  1. Logout: didn’t work at all
  2. Reboot: worked most of the time

Partial solution

After changing the Mouse Click Emulation in Keyboard & Mouse in Ubuntu Tweak from the default “Fingers” (2 fingers for right click; 3 fingers for middle click) to “Area” (Right/middle click determined by clicked area), one might have to wait for next reboot.

[Read More]

Juno Installation 2019

Log of system-wide config

Goal

To install Juno for convenient development in Julia.

Problem

After Juno installation, I received the following error.

Juno error

Analysis

From the error message, the system had tried to find an executable file julia, which would then be executed by the shell /bin/sh. Nonetheless, it’s absent from the system’s environment $PATH, so Juno couldn’t find it.

I’ve only changed my $PATH in ZSHRC, which is user-specific.

Solution

This Stack Overflow question about $PATH setting on *nix has provided various solution. As I was in a hurry to get Julia run on Juno, I’ve taken the advice from the best answer. I prefer creating a separate shortcut under /usr/bin, rather than editing system-wide config files.

[Read More]
Juno  Atom  Julia 

Conditional Batch File Editing

Adopted Mmark for Math Posts

Problem

During the adoption of Mmark for math posts on this blog, I had to insert markup: mmark at the last line of front matter of the source file of each math post.

Seek help

I separated this into two SO questions

  1. Sed conditional match and execute command with offset, and
  2. A question about AWK multiple line recognition.

Solution

From #1., I learnt the use of variables in AWK scripts. From #2, some users explained how these variables can be used for multi-line regex search.

[Read More]
awk  sed  Mmark 

My Intended Trigo Answer

The Math.SE question $2\cos(2x) - 2\sin(x) = 0$ has attracted several answers from high-rep users.

I am expanding @rhombic’s comment into an answer.

$$ \begin{aligned} 2\cos(2x)-2\sin(x)&=0 \\ 2 - 4\sin^2(x)-2\sin(x)&=0 \\ 2\sin^2(x)+\sin(x) - 1&=0 \\ (2 \sin(x) - 1)(\sin(x) +1) &= 0 \\ \sin(x) = \frac12 \text{ or } \sin(x) &= -1 \\ x = \frac{\pi}{6}, \frac{5\pi}{6} \text{ (rejected) or } & \frac{3\pi}{2} \text{ (rejected)} \end{aligned} $$

Improved Integration of Hugo and $\KaTeX$

Problem

There’s no custom $\KaTeX$ macro in local preview since I’ve merged some recent commits from the upstream of this blog’s theme, in particular, Beautiful Hugo’s pull requests #246 and #255, which allowed self-hosting the theme’s static JS, CSS and font files. This self-hosted option is particularly useful in case of slow response from Cloudflare’s CDN.

hugo local preview no KaTeX macro

public Hugo blog KaTeX auto-renderer error

Even they do appear on the public GitLab site, the final rendered Markdown + $\TeX$ code would be succumb to syntax errors due to their absence in the preview process.

[Read More]
KaTeX  Mmark  Hugo 

JavaScript Copy Button

Goal

To create a copy button for my Math.SE comment template in order to save the trouble of copying and pasting.

My first attempt

I put the boilerplate inside a Markdown codeblock to prevent them from getting interpreted by Hugo’s Markdown parser. Under each codeblock, I placed the copy button.

Comment boilerplate goes here ...

Another comment boilerplate goes here ...

My page’s original layout

$(document).ready(function() {
  $('.copyBtn').click(function() {
    copy($(this).prev().children())
j  });
});

function copy(selector) {
  var screenTop = $(document).scrollTop();
  var $temp = $("<div>");
  $("body").append($temp);
  $temp.attr("contenteditable", true)
       .html($(selector).html()).select()
       .on("focus", function() { document.execCommand('selectAll',false,null) })
       .focus();
  document.execCommand("copy");
  $temp.remove();
  $('html, body').scrollTop(screenTop);
}

static/js/copyBtn.js at Git tag copyBtn0

[Read More]

My Dual Answer

Update: The question has been reopened.

I intended to answer κΉ€μ’…ν˜„’s problem on Math.SE. However, the programs in the question body aren’t typeset in MathJax. As a result, I downvoted and closed this question because found it unclear. From the proposed dual, it seems that I shouldn’t interpret the primal as a linear program. Anyways, without further clarifications from OP, I found no reason to look at this further. Here’s my intended answer:

[Read More]

Finite Population Sampling without Replacement

Personal note of finite population sampling

First moment

Population: $ \Omega = \{ x_1, \dots, x_N \} $
Collection of $n$-samples: $\mathcal{S} = \{ s \in \Omega^n \mid \forall i,j \in s, i \ne j \} $
Collection of $n$-samples containing $x$: $ \mathcal{S}_x = \{ s \in \mathcal{S} \mid x \in s \} $
Observe that $ |\mathcal{S}_x| = \binom{N-1}{n-1} $.
Let population mean be zero. $\mu = 0$, i.e. $ \sum_{i = 1}^N x_i = 0 $
Fix an order for $\mathcal{S}$: $ \mathcal{S} = \{ s_1, s_2, \dots, s_{|\mathcal{S}|} \} $.
$j$-th $n$-sample mean $ m_j = \frac1n \sum_{x \in \mathcal{S}_j} x $
Remark: I don’t use $ \sum s_j $ as in $ \cup \mathcal{T} $ in topology to avoid misreading the $n$-sample $ s_j $ as an element.
mean of $n$-sample mean $ m = \frac{1}{|\mathcal{S}|} \sum_{s_j \in \mathcal{S}} m_j $

[Read More]

Replacing Deprecated Hugo Syntax in Blog Theme

Fixing Beautiful Hugo issue #261

Problem

Since the recent Hugo upgrade to v0.55.3, the following messages popped up after each local site regeneration with hugo server.

WARN 2019/04/24 18:07:00 Page's .URL is deprecated and will be removed in a futu
re release. Use .Permalink or .RelPermalink. If what you want is the front matte
r URL value, use .Params.url.
WARN 2019/04/24 18:07:00 Page's .Hugo is deprecated and will be removed in a fut
ure release. Use the global hugo function.
WARN 2019/04/24 18:07:00 Page's .RSSLink is deprecated and will be removed in a 
future release. Use the Output Format's link, e.g. something like: 
    {{ with .OutputFormats.Get "RSS" }}{{ .RelPermalink }}{{ end }}.
Total in 136 ms

GitLab’s online runner also gave the same type of warnings. This was reported in Beautiful Hugo issue #261.

[Read More]

Julia Rcall Installation

Rcall.jl build failure due to missing dependencies

Problem

During the installation of RCall.jl, the package wasn’t successfully built due to a missing variable $R_HOME.

$ julia -q
julia> Pkg.add("RCall")
 Resolving package versions...
 Installed WinReg ─ v0.3.1
 Installed RCall ── v0.13.2
  Updating `~/.julia/environments/v1.0/Project.toml`
  [6f49c342] + RCall v0.13.2
  Updating `~/.julia/environments/v1.0/Manifest.toml`
  [6f49c342] + RCall v0.13.2
  [1b915085] + WinReg v0.3.1
  Building RCall β†’ `~/.julia/packages/RCall/ffM0W/deps/build.log`
β”Œ Error: Error building `RCall`:
β”‚ ERROR: LoadError: R_HOME is not a directory.
β”‚ Stacktrace:
β”‚  [1] error(::String) at ./error.jl:33
β”‚  [2] top-level scope at logging.jl:322
β”‚  [3] top-level scope at /home/vin100/.julia/packages/RCall/ffM0W/deps/build.jl
:19
β”‚  [4] include at ./boot.jl:317 [inlined]
β”‚  [5] include_relative(::Module, ::String) at ./loading.jl:1041
β”‚  [6] include(::Module, ::String) at ./sysimg.jl:29
β”‚  [7] include(::String) at ./client.jl:388
β”‚  [8] top-level scope at none:0
β”‚ in expression starting at /home/vin100/.julia/packages/RCall/ffM0W/deps/build.
jl:10
β”” @ Pkg.Operations /buildworkjr/worker/package_linux64/build/usr/share/julia/std
lib/v1.0/pkg/src/operations.jl:1069

Discussion

It took me a few minutes to realise that the cause of this error is the absence of R. I referred to CRAN’s installation instructions for Ubuntu and added

[Read More]
Julia  RCall  R