Blog 1

Random Talk on Random Thoughts

Awk Column Alignment

| Comments |

Background

I use Google’s PageSpeed Insights to check if the images on this blog are optimised. Recently, it reported that two images in An Invalid Claim by the Government could be resized and compressed. I did so, and then the file size of the files were displayed using ls -lh.

[owner@localhost ~/octopress/source/images/posts/W3CInvalid]$ ls -lh
total 312K
-rw-rw-r-- 1 owner owner  32K Apr  9 12:20 cedb1-300.png
-rw-rw-r-- 1 owner owner 132K Mar 27 14:32 cedb1.png
-rw-rw-r-- 1 owner owner  32K Apr  9 12:20 cedb2-300.png
-rw-rw-r-- 1 owner owner  83K Apr  9 12:20 cedb2.png

Problem

To remove the first four column, one uses awk to do this. (I assume that the current working directory is the same as above.)

$ ls -lh | awk '{print $5 $6 $7 $8 $9}'

32KApr912:20cedb1-300.png
132KMar2714:32cedb1.png
32KApr912:20cedb2-300.png
83KApr912:20cedb2.png

How can one properly align the columns?

Loop Through an Array Having Only One Element in Bash

| Comments |

Background

To find out a way to loop through all elements in an array consisting of more than one element, it’s easy.

$ for f in {"hello","world"}; do echo $f; done
hello
world

Problem

When I try to take away the second element in the above array so that it becomes an array consisting in one single element, then I get {hello} instead of hello.

$ for f in {"hello"}; do echo $f; done
{hello}

How can one get back an output consistent with the case of arrays consisting of multiple elements?

COM Surrogate Problem

| Comments |

A few days ago, I saw this dialog box on M$ Win* 7. Occupied by my maths, I won’t do anything for this technical problem. You may perform a Google search for “COM Surrogate has stopped working” in order to know more about this problem.

</source> COM Surrogate has stopped working

Oneline Perl

| Comments |

Motivation

Knowing some regular expressions in Vim, I hope to apply these concepts to Perl so that I can search and replace some simple strings directly in base without having to open the editor.

As a Vim user, the class of special characters in Perl is more natural than that of sed.

Problem

In the previous post, the list of Git commit messages containing the string “HTTPS” is the main focus. However, the alignment of this list isn’t good: in the column representing the day, the data can be either one or two digit. Though I can still extract information with awk '{print $[col_num]}', it’s better to fix the alignment.

$ git log -2 --grep="HTTPS" --pretty="%h %cd %s"
7400582 Sun Mar 20 20:19:47 2016 +0800 Updated my Rakefile with HTTPS
b6f4f1f Mon Feb 8 00:45:02 2016 +0800 A new article about Flair, Octopress and HTTPS

Searching Git Commit Messages

| Comments |

Problem

The solution for the problem posed in the title is pretty simple. For instance, I want to find all Git commits whose commit message contains “HTTPS”.1

$ git log -2 --grep="HTTPS"
commit 7400582e268f4a5b776269cf0cc08c04886a4769
Author: Vincent Tam <fake@live.hk>
Date:   Sun Mar 20 20:19:47 2016 +0800

    Updated my Rakefile with HTTPS

commit b6f4f1fc872affc1107b330042d7b43b45e60595
Author: Vincent Tam <fake@live.hk>
Date:   Mon Feb 8 00:45:02 2016 +0800

    A new article about Flair, Octopress and HTTPS

However, I think that the output isn’t compact enough. I would like to display the following information.

<short SHA1> <commit time> <commit message title>

$\ell^\infty$ Is Not Separable

| Comments |

Background

This Wednesday, I read a proof about the non-separability of $\ell^\infty$ spaces. To simplify things, I assume that it’s defined on sequences.

\[ L^\infty \triangleq \{ (x_n)_{n \in \N} \mid \exists\,M \ge 0 \text{ such that } \forall\,n \in \N, \abs{x_n} \le M \} \]

I have written down the uncountable set (see Cantor’s diagonal argument)

\[ D \triangleq \{ (x_n)_{n \in \N} \mid \forall\,n \in \N, x_n=\pm1 \} \]

in my notes. I understand

\[ B(x,1) \cap B(y,1) = \varnothing \quad \forall \, x,y \in D \text{ with } x \ne y. \]

Problem

Then, my teacher said that the reason for the non-separability of $\ell^\infty$ was like the Pigeon-Hole Principle. I got puzzled when I was revising the proof. In fact, in the above equation, an element in a dense set $C$ can be found in each open ball $B(x,1)$. Since the open balls $B(x,1)$ are disjoint, $C$ has uncountably many elements. Hence, $\ell^\infty$ is non-separable.

One knows that if a space is separable, we can’t insert a non-separable subspace into it. The above property of $\ell^\infty$ serves as a concrete example of this fact.

It’s easy to show that a space having a Schauder basis is separable. Thus, we can conclude that $\ell^\infty$ don’t possess any Schauder basis.

In fact, we have a more direct approach to the absence of Schauder basis in $\ell^\infty$. This will be discussed in my next post.

Gems on Which TLDR Pages Depend

| Comments |

Tonight, I’ve installed TLDR pages by typing gem install tldrb since I don’t have npm installed.

Here’s a list of gems actually fetched.

  1. bales-0.1.2
  2. unf-0.2.0.beta2
  3. domain_name-0.5.20160310
  4. http-cookie-1.0.2
  5. mime-types-2.99.1
  6. netrc-0.11.0
  7. rest-client-1.8.0
  8. tldrb-0.0.2

An Invalid Claim by the Government

| Comments |

I have viewed the Chinese version of the homepage of the Commerce and Economic Development Bureau. I clicked on the validation icon for HTML 4.01 at the lower right-hand corner.

</source> home page of gov webpage

To my surprise, an error was produced.

</source> W3C validator shows error

Lacking time to write an email with good grammar to the authories, I am waiting for someone to notice this error and I am looking forward to seeing that this problem will be rectified.

To know more about the usage of the W3C validation icons, you may go to the FAQ for the validation service.

Missing OS (2)

| Comments |

I saw a similar error again. After pressing any key, the M$ Win* logo appeared. I don’t think that I’ll find out anything about this error since I’ve other things to do.

</source> No operating system found