Blog 1

Random Talk on Random Thoughts

My Scanner and Ubuntu 14.04

| Comments |

Background

  • Scanning and printing works fine in my Ubuntu 12.04 desktop.
  • I’ve upgraded to Ubuntu 14.04 LTS yesterday.1

Problem

When I used Simple Scan, Ubuntu’s GUI tool for scanning documents, I encountered an error—the program couldn’t detect my scanner.

Simple Scan didn't detect my scanner

How can I scan images from my scanner in Ubuntu?

Install Ruby Again! (2)

| Comments |

I installed Ruby 2.1.2 so as to build Octopress on top of it. Luckily, the installation was successful.

Installed Ruby 2.1.2 in the terminal

This afternoon, I tried running rake on Ruby 2.1.2. Unluckily, I failed.

Upgraded Ubuntu

| Comments |

I’ve upgraded Ubuntu to 14.04 LTS.

tty1 of Ubuntu 14.04

In the first reboot, I saw a few errors. Since then, usual things like web browsers and terminal have run smoothly, except the tool tip text of the Firefox icon in the Unity desktop environment.

At first, the time wasn’t synchronized with the Internet, though it had been set to “Automatically from the Internet” in “Time & Date” in “Systems Settings”. After an hour or so, it’ll be fine.

However, the display of monospaced fonts in some places is strange. For example, when I view the source code of a web page in Chromium, the font isn’ monospaced.

HTML source code viewed inside Chrome

I won’t try to fix the problem since I think that metric spaces are more interesting than technical problems.


(Last edited on AUG 17, 2014)

I have now worked out a solution to this problem. Refer to Ubuntu 14.04 Monospaced Font Family for details.

Ubuntu Distribution Upgrade to 14.04

| Comments |

Screenshot of the GUI upgrade manager

I’m upgrading my Ubuntu 12.04 LTS to 14.04 LTS. I hope the process will go smoothly. However, I saw something like this.

File descriptor 46 (pipe:[31349]) leaked on lvs invocation. Parent PID 20708: /bin/sh

As not a IT student, I probably won’t find the cause for it for the next few years.

Error Bound of the Fixed Point of Contraction Mappings

| Comments |

This afternoon, I read the proof of Banach fixed-point theorem in Wikipedia.1 It’s said that

\begin{equation} d(x^*,x_n) \le \frac{q^n}{1 - q} d(x_1,x_0). \label{eq:inf_err} \end{equation}

In the proofs for the lemmas, I could only find something like $x_k$ inside the brackets, but not $x^$. Thus, I *couldn’t figure out how one can derive inequality \eqref{eq:inf_err} from an inequality derived in the proof of Lemma 2.

\begin{equation} d(x_m,x_n) \le \frac{q^n}{1 - q} d(x_1,x_0), \text{ where } m > n. \label{eq:finite_err} \end{equation}

I googled for some notes, and found one which told me to take the limit of the L.H.S. of inequality \eqref{eq:finite_err} as $m \to \infty$.2 After looking at Corollary 2.4 in the PDF file in footnote #2 for a while, I know what I’ve missed.

If $\left\{ p_k \right\}$ converges to $p$,

\begin{equation} \lim_{k \to \infty} d(p_k,q) = d(p,q) = d\left(\lim_{k \to \infty} p_k,q \right) \label{eq:dist_limit} \end{equation}

That’s why I wrote the previous post.

With equation \eqref{eq:dist_limit}, I can now derive \eqref{eq:inf_err} from \eqref{eq:finite_err}.

$\because \lim\limits_{k \to \infty} x_k = x_*$

\[ \begin{aligned} d(x^*,x_n) =& d\left( \lim_{k \to \infty} x_k,x_n\right) \\ =& \lim_{k \to \infty} d(x_k,x_n) \\ \le& \lim_{k \to \infty} \frac{q^n}{1 - q} d(x_1,x_0) \qquad \text{(by \eqref{eq:finite_err})} \\ =& \frac{q^n}{1 - q} d(x_1,x_0) \end{aligned} \]

  1. Banach fixed-point theorem. (2014, July 15). In Wikipedia, The Free Encyclopedia. Retrieved 17:34, August 10, 2014, from http://en.wikipedia.org/w/index.php?title=Banach_fixed-point_theorem&oldid=617083697 

  2. Conrad, K. (2014). The contraction mapping theorem. Expository paper. University of Connecticut, College of Liberal Arts and Sciences, Department of Mathematics. Retrieved August 10,2014, from http://www.math.uconn.edu/~kconrad/blurbs/analysis/contraction.pdf 

Limit of Distances in Metric Spaces

| Comments |

Let $X$ be a metric space and $q \in X$. Suppose that sequence $\left\{ p_k \right\}$ in $X$ converges to a point $p$ in $X$. Then, $\left\{ d(p_k,q) \right\}$ converges to $d(p,q)$.

\begin{align} & \therefore \forall \varepsilon \exists N \forall k (k \ge N \implies d(p_k,p) < \varepsilon) \label{eq2} \\ & \abs{d(p_k,q) - d(p,q)} < \varepsilon \\ & \iff d(p_k,q) - d(p,q) < \varepsilon \land d(p,q) - d(p_k,q) < \varepsilon \notag \\ & d(p_k,q) - d(p,q) \le d(p,p_k) \iff d(p_k,q) \le d(p,q) + d(p,p_k) \label{eq4} \\ & d(p,q) - d(p_k,q) \le d(p,p_k) \iff d(p,q) \le d(p_k,q) + d(p,p_k) \label{eq5} \end{align}

\eqref{eq4}, and \eqref{eq5} follows from the Triangular Inequality. Apply \eqref{eq2} to \eqref{eq4} and \eqref{eq5} to finish the proof. Q.E.D.

Remark: Quantifications similar to \eqref{eq2} can be found in Wikipedia’s entry for uniform continuity.

Double Hyphens in Git Checkout

| Comments |

While I was writing my previous post, I made a link to a Git cheatsheet. In the list, I saw a wrong command.

git checkout – <file>

It is incorrect to use an en-dash in the above command, instead of a double hyphen --. I’ll illustrate this with an example below. Assume that the current file is ~/octopress.

$ cat >> Gemfile
bullshxt
$ git diff
diff --git a/Gemfile b/Gemfile
index 4d028d3..a1718ff 100644
    --- a/Gemfile
    +++ b/Gemfile
@@ -20,3 +20,4 @@ group :development do
 end
 
 gem 'sinatra', '~> 1.4.2'
+bullshxt

...

$ git checkout  Gemfile
error: pathspec '—' did not match any file(s) known to git.

$ git checkout -- Gemfile  # correct command

Double Hyphens in Git Diff

| Comments |

Two months ago, I wrote my first list of Git commands, and said that I didn’t know how to use Git commands to view the changes.1

Now, I can understand how one can “use ‘--’ to separate paths from revisions [or branches]”.

Fixing Embedded Gists in Octopress

| Comments |

Background

Octopress’s default plugins for including code snippets/blocks enable users to share code. This is good for open source technologies. Without intelligent and generous users of open source tools, I won’t be able to

  1. show images which can be enlarged with a click;1
  2. display a category list of Octopress posts;2
  3. find out how to include contents rendered by Mathjax (e.g. $\rm \LaTeX$) in the category list;3
  4. figure out a way to remove the line numbers and repeating figures in the RSS (category) feeds;4
  5. embed SVG images that support zooming, panning and dragging.5

While I was writing my previous post, which was about a basic pandoc template for generating a $\rm \LaTeX$ PDF file, I would like to include a Gist in my post.

Some users will say that Octopress’s default fuctionality {% include_code %} can highlight the code.

Why does one think of embedding a Gist in Octopress?

Rationale

To easily modify the embedded code block.

  • Octopress’s default plugins: rake generate is slow, especially when there’s a lot of contents. (say, more than a hundred posts)

  • Embedded Gist: {% gist gist_id [<file>] %} is responsible for embedding the code snippet for <file>—changing the contents of the Gist for <file> doesn’t change this piece of Jekyll code. Moreover, posting code to Gist is quite fast if you have Gist.vim plugin installed in Vim.6

Problem

However, if one uses Gist instead of Octopress’s default plugins for sharing code, one will see that the line numbers aren’t in the right position.

A Gist that does not look good

My Pandoc Template (1)

| Comments |

The last post about pandoc was written four months ago. Last week, I slightly changed the pandoc template default.latex on jgm/pandoc-templates so that users can easily create $\rm \LaTeX$ documents with

  • 1-inch margin; and
  • one-half (or double) spacing.

The following command can create a PDF using the template.

$ pandoc src.mkd --template=my_template1.latex -o out.pdf

I hope that more people will use pandoc and write in Markdown.