Blog 1

Random Talk on Random Thoughts

Jekyll Serve Error (2)

| Comments |

Background

Same as the previous post in this series, except that I ran this command from M$ Win* 10.

Problem

Similar to the previous post.

Owner@Owner-PC MINGW64 /c/github/blog2 (gh-pages)
$ jekyll serve
WARN: Unresolved specs during Gem::Specification.reset:
      pygments.rb (~> 0.6.0)
      jekyll-watch (~> 1.1)
WARN: Clearing out unresolved specs.
Please report a bug if this causes problems.
C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.7.2/lib/bundler/resolver.rb:35
7:in `resolve': Could not find gem 'jekyll (~> 3.1) x64-mingw32' in the gems ava
ilable on this machine. (Bundler::GemNotFound)
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.7.2/lib/bundler/r
esolver.rb:164:in `start'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.7.2/lib/bundler/r
esolver.rb:129:in `resolve'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.7.2/lib/bundler/d
efinition.rb:193:in `resolve'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.7.2/lib/bundler/d
efinition.rb:132:in `specs'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.7.2/lib/bundler/d
efinition.rb:177:in `specs_for'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.7.2/lib/bundler/d
efinition.rb:166:in `requested_specs'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.7.2/lib/bundler/e
nvironment.rb:18:in `requested_specs'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.7.2/lib/bundler/r
untime.rb:13:in `setup'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.7.2/lib/bundler.r
b:121:in `setup'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/jekyll-2.5.3/lib/jekyll/plu
gin_manager.rb:37:in `require_from_bundler'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/jekyll-2.5.3/bin/jekyll:16:
in `<top (required)>'
        from C:/Ruby200-x64/bin/jekyll:23:in `load'
        from C:/Ruby200-x64/bin/jekyll:23:in `<main>'

Website Preview in Mobile Devices

| Comments |

Goal

To know the page layout of a website, notably my blogs, on mobile devices before publishing it.

Preview this blog on a smartphone

Problem

I used ifconfig to check the IP address of my desktop where the preview site was hosted. It’s 192.168.1.5. When I typed in this address followed by a colon and the port number 4000, then the browser said “connection timeout” after loading for a while.

Connection timeout

My Host File Edited

| Comments |

Background

A preview of a blog is often needed before it’s published.

Problem

However, it is possible that one doesn’t like to type localhost in the address bar, and would like to have other names.

Solution

The idea is in Local Setup – edit your hosts file in How to test localhost from any device on your network written by Wes Bos. On *nix, the file path is still the same as on OSX, but many users would rather use Vim for editing /etc/hosts. One may even use sed with the -i flag and the sudo privilege in order to directly manipulate this file.

  • sudo sed -i "3i127.0.0.1\tblogtest.com" /etc/hosts for insertion of “127.0.0.1        blogtest.com” before the third line.
  • sudo sed -i "3c127.0.0.1\tblogtest.com" /etc/hosts for changing the third line to “127.0.0.1        blogtest.com”.

Note that the tab is escaped as \t in these two commands.

Jekyll Serve Error

| Comments |

Background

I updated the Jekyll-Bootstrap source code for Blog 2.

Problem

Then, I wanted to preview it.

[owner@localhost ~/blog2]$ jekyll serve
/home/owner/.rvm/gems/ruby-2.1.2@global/gems/bundler-1.6.5/lib/bundler/resolver.
rb:357:in `resolve': Could not find gem 'jekyll (~> 3.1) ruby' in the gems avail
able on this machine. (Bundler::GemNotFound)
        from /home/owner/.rvm/gems/ruby-2.1.2@global/gems/bundler-1.6.5/lib/bund
ler/resolver.rb:164:in `start'
        from /home/owner/.rvm/gems/ruby-2.1.2@global/gems/bundler-1.6.5/lib/bund
ler/resolver.rb:129:in `resolve'
        from /home/owner/.rvm/gems/ruby-2.1.2@global/gems/bundler-1.6.5/lib/bund
ler/definition.rb:203:in `resolve'
        from /home/owner/.rvm/gems/ruby-2.1.2@global/gems/bundler-1.6.5/lib/bund
ler/definition.rb:133:in `specs'
        from /home/owner/.rvm/gems/ruby-2.1.2@global/gems/bundler-1.6.5/lib/bund
ler/definition.rb:178:in `specs_for'
        from /home/owner/.rvm/gems/ruby-2.1.2@global/gems/bundler-1.6.5/lib/bund
ler/definition.rb:167:in `requested_specs'
        from /home/owner/.rvm/gems/ruby-2.1.2@global/gems/bundler-1.6.5/lib/bund
ler/environment.rb:18:in `requested_specs'
        from /home/owner/.rvm/gems/ruby-2.1.2@global/gems/bundler-1.6.5/lib/bund
ler/runtime.rb:13:in `setup'
        from /home/owner/.rvm/gems/ruby-2.1.2@global/gems/bundler-1.6.5/lib/bund
ler.rb:120:in `setup'
        from /home/owner/.rvm/gems/ruby-2.1.2/gems/jekyll-2.5.3/lib/jekyll/plugi
n_manager.rb:37:in `require_from_bundler'
        from /home/owner/.rvm/gems/ruby-2.1.2/gems/jekyll-2.5.3/bin/jekyll:16:in
 `<top (required)>'
        from /home/owner/.rvm/gems/ruby-2.1.2/bin/jekyll:23:in `load'
        from /home/owner/.rvm/gems/ruby-2.1.2/bin/jekyll:23:in `<main>'
        from /home/owner/.rvm/gems/ruby-2.1.2/bin/ruby_executable_hooks:15:in `e
val'
        from /home/owner/.rvm/gems/ruby-2.1.2/bin/ruby_executable_hooks:15:in `<
main>'

How can it be previewed?

Fixed Jekyll-Bootstrap Asset Path (2)

| Comments |

Background

I attempted to manually fix a problem in the first post in this series half a year ago.

Problem

I have just updated the Jekyll source code for Blog 2.

[owner@localhost ~/blog2]$ git pull jekyll master
remote: Counting objects: 37, done.
remote: Total 37 (delta 10), reused 10 (delta 10), pack-reused 27
Unpacking objects: 100% (37/37), done.
From github.com:plusjade/jekyll-bootstrap
 * branch            master     -> FETCH_HEAD
   3a34785..8193869  master     -> jekyll/master
Removing sitemap.txt
Auto-merging _includes/JB/setup
CONFLICT (content): Merge conflict in _includes/JB/setup
Auto-merging _config.yml
Automatic merge failed; fix conflicts and then commit the result.

How to repair this failed merge?

Restore Corrupt Git Repository

| Comments |

Background

I hadn’t used Vim on my GNU/Linux desktop for a month. When I used it again, an error message was shown on the screen.

[owner@localhost ~]$ vi
Error detected while processing
/home/owner/.vim/bundle/nerdtree/plugin/NERD_tree.vim:
line  153:
E117: Unknown function: nerdtree#ui_glue#setupCommands
Error detected while processing function nerdtree#postSourceActions:
line    2:
E117: Unknown function: nerdtree#ui_glue#createDefaultBindings
Press ENTER or type command to continue

Since I was occupied with another blog, thinking that the problem would be quickly fixed by an update of the NERD tree, a Vim plugin for showing a file tree in a sidebar, I didn’t want to find out the cause.

Problem

During this Vundle update, an exclamation mark with red background was displayed on the LHS of the item Plugin 'scrooloose/nerdtree' in the list contained in the status bar. I then checked Vundle’s update log.

[2016-08-12 15:18:40] Plugin scrooloose/nerdtree
[2016-08-12 15:18:40] $ cd '/home/owner/.vim/bundle/nerdtree' && git pull && git submodule update --init --recursive
[2016-08-12 15:18:40] > error: object file .git/objects/2e/2b649232d6ae4d02d74793e5da0ee08480ad8d is empty
[2016-08-12 15:18:40] > error: object file .git/objects/2e/2b649232d6ae4d02d74793e5da0ee08480ad8d is empty
[2016-08-12 15:18:40] > fatal: loose object 2e2b649232d6ae4d02d74793e5da0ee08480ad8d (stored in .git/objects/2e/2b649232d6ae4d02d74793e5da0ee08480ad8d) is corrupt
[2016-08-12 15:18:40] > fatal: The remote end hung up unexpectedly
[2016-08-12 15:18:40] > 

While I was trying to update this plugin manually by typing in Git commands in bash, the electricity supply of my desktop went off suddenly. After it had been switched on again, I tried typing in the commands again, and I got the same error.

How can the Git repository be restored to its previous state, so that it’s intact?

$\rm \LaTeX$ French Letter Template

| Comments |

I just include the files here for future references. Since the code are universal, I assume that the source file and the linked PDF file below are in public domain, despite the CC-BY-SA licence at the bottom of this page.

Sample French $\rm \LaTeX$ letter (ltr.tex) download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
\documentclass[12pt]{lettre}
\usepackage{fontspec}
\usepackage[frenchb]{babel}

\begin{document}
\begin{letter}{
    Nom de destinataire \\
    4, boulevard de la Paix, \\
    12345 Nom de ville
}

  \name{Votre NOM}
  \address{
    Votre NOM\\
    23, rue à votre ville \\
    23456 Nom de votre ville
  }
  \lieu{Votre ville}
  \telephone{01 02 03 04 05}
  \nofax

  \def\concname{Objet :~}
  \conc{Saisir votre objet}
  \opening{Madame, Monsieur,}

  Un exemple d'une lettre $\rm \LaTeX$ faite par \LaTeX.  Le faux
  texte ci-dessous est généré par le plugin Lorem Ipsum pour Vim.

% lorem{{{
  Curabitur eget nisi at lectus placerat gravida. Vivamus nulla. Donec
  luctus. Sed quis tellus. Quisque lobortis faucibus mi. Aenean vitae
  risus ut arcu malesuada ornare. Maecenas.

  Amet, rhoncus in, ipsum. Mauris rhoncus, lacus eu convallis sagittis,
  quam magna placerat est, vitae imperdiet mauris arcu ac dui. In ac
  urna non justo posuere mattis. Suspendisse egestas bibendum nulla. In
  erat nunc, posuere sed, auctor quis, pulvinar quis, mi. Mauris at est.
  Phasellus lacinia eros in arcu. Maecenas lobortis, tellus vel gravida
  tincidunt, elit erat suscipit arcu, in varius erat risus vel magna.
  Fusce nec ante quis dolor vestibulum bibendum. Pellentesque sit amet
  urna.
% lorem}}}

  \closing{Veuillez d'agréer, Madame, Monsieur, mes salutations les
  meilleures.}

\end{letter}
\end{document}

You may view the output PDF before downloading the above sample.

Writting Letter With Bibliography

| Comments |

Background

Recently, I need to write letters. Get the formatting for addressee and sender automatically done, I choose $\rm \LaTeX$. I cite a book in my letter, and try to add a bibliography at the end of the letter.

Problem

During the compilation for the following letter, an error was thrown.

A failed $\rm \LaTeX$ letter (noltrbib.tex) download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
\documentclass[12pt]{lettre}
\usepackage{fontspec}
\usepackage[frenchb]{babel}
\usepackage[backend=biber]{biblatex}
\addbibresource{ltrbib.bib}
\usepackage{csquotes}

\begin{document}
\begin{letter}{
    Nom de destinataire \\
    4, boulevard de la Paix, \\
    12345 Nom de ville
}

  \name{Votre NOM}
  \address{
    Votre NOM\\
    23, rue à votre ville \\
    23456 Nom de votre ville
  }
  \lieu{Votre ville}
  \telephone{01 02 03 04 05}
  \nofax

  \def\concname{Objet :~}
  \conc{Saisir votre objet}
  \opening{Madame, Monsieur,}

  Un exemple de citation dans un document $\rm \LaTeX$.  \cite{serre}
  Le faux texte ci-dessous est généré par le plugin Lorem Ipsum pour
  Vim.

% lorem{{{
  Curabitur eget nisi at lectus placerat gravida. Vivamus nulla. Donec
  luctus. Sed quis tellus. Quisque lobortis faucibus mi. Aenean vitae
  risus ut arcu malesuada ornare. Maecenas.

  Amet, rhoncus in, ipsum. Mauris rhoncus, lacus eu convallis sagittis,
  quam magna placerat est, vitae imperdiet mauris arcu ac dui. In ac
  urna non justo posuere mattis. Suspendisse egestas bibendum nulla. In
  erat nunc, posuere sed, auctor quis, pulvinar quis, mi. Mauris at est.
  Phasellus lacinia eros in arcu. Maecenas lobortis, tellus vel gravida
  tincidunt, elit erat suscipit arcu, in varius erat risus vel magna.
  Fusce nec ante quis dolor vestibulum bibendum. Pellentesque sit amet
  urna.
% lorem}}}

  \closing{Veuillez d'agréer, Madame, Monsieur, mes salutations les
  meilleures.}

  \printbibliography
\end{letter}
\end{document}
A sample Bib$\rm \LaTeX$ file (ltrbib.bib) download
1
2
3
4
5
6
7
8
9
@BOOK{serre,
    author = {Serre, J. P.},
    title = {Cours d'arithmétique},
    publisher = {Presse Universitaire de France},
    year = {1970},
    edition = {1ère ed.},
    address = {Paris, France},
    pages = {103--106},
}

Here’s my compilation procedure.

$ xelatex noltrbib.tex
$ biber noltrbib
$ xelatex noltrbib.tex
This is XeTeX, Version 3.1415926-2.5-0.9999.3 (TeX Live 2013/Debian)
 restricted \write18 enabled.
...
! Undefined control sequence.
\\blx@head@bibliography [#1]->\section 
                                       *{#1}\markboth {\MakeUppercase {#1}}{...
l.52 \end
         {letter}
?
...

I type <Enter> at ?, and get a PDF that seems OK. You may read the log file for this file to know more about this error. However, each time I use $\rm \LaTeX$-Suite to compile the document inside Vim, a quickfix window pops up. This is quite inconvenient: I need to use <C-w>k to switch to the original buffer or ZQ to close the quickfix window. Therefore, I am motivated to find out a solution for this error.

I-Search and Reverse I-Search

| Comments |

One knows that long commands can be retrieved by <C-r>. If the search fails, one may cancel it by <C-g>. However, how can one search forward through the command history instead of backword?

The answer is simple: add stty -ixon to your BASHRC.