Blog 1

Random Talk on Random Thoughts

Non-breaking Spaces

| Comments |

Why use them?

This evening, when I was writing a post about an ImageMagick command that I’ve learnt, I used the unit “pixel” to describe the dimensions of an image.1 In a measurement, the quantity and the unit should be separated by a non-breaking space for the sake of readability.2

5 ImageMagick Command Line Examples–part 1

| Comments |

In the second example, the command only produces one image. In the past, without knowing the use of +[x-pos]+[y-pos], I got more than one image, and needed to delete them except the desired one.1

When I wrote a post about screendump, I took a screenshot of TTY1 so as to prove that the text that followed the screenshot was really contents in TTY1.2 The width and height of the screenshot was 1280 px and 1024 px respectively. I then used my old way to crop it to an image with width 520 px and height 230 px, and got similar error message described in ImageMagick’s examples.3.


  1. In “ImageMagick commands learnt” in Basic Use of Aptitude, I got four images because I didn’t append +0+0 after 640x512

  2. There’s an image cropped with ImageMagick in “Usage” in Record Linux Terminal.

    $ convert src.png -crop 512x225+0+0 tty1.png
    

  3. In “The Missed Image (from a bad crop)” in Examples of ImageMagick Usage (version 6)

Kramdown's Markdown Attributes

| Comments |

While writing a post about purging old Linux kernels, I made use of fancybox’s plugin to show a popup window which contains some HTML elements.1

Original container for popup contentsView raw
1
2
3
4
5
6
7
8
9
10
<div id="list1" class="noscr">
<p>The <strong>bolded</strong> lines represent the packages that are
going to be completely removed.</p>
<!-- omitted a pre tag -->
</div>

<div id="list2" class="noscr">
<p>There's <em>no</em> lines beginning with <code>rc</code>.</p>
<!-- omitted a pre tag -->
</div>

I tried writing Markdown code inside these <div> containers, but the Markdown code failed to be changed to HTML. As a result, not being familiar with much of the Markdown syntax specified by kramdown, I simply write HTML inside these <div> elements.

Fancybox is great, but if I need to give up Markdown, then what’s the point of overcoming so many technical problems related to Octopress? Without Markdown and Vim, blogging will be incredibly difficult for me. For the former, when compared with HTML, it’s much easier to read and write; for the latter, it offers an efficient text editing experience.

Therefore, this afternoon, I browsed kramdown Syntax in kramdown’s official website, and found out that the markdown="1" attribute can solve this problem.2

Current container for popup contentsView raw
1
2
3
4
5
6
7
8
9
10
<div id="list1" class="noscr" markdown="1">
The **bolded** lines represent the packages that are going to be
completely removed.
<!-- omitted a pre tag -->
</div>

<div id="list2" class="noscr" markdown="1">
There's *no* lines beginning with `rc`.
<!-- omitted a pre tag -->
</div>

  1. Completely Remove Linux Kernels in Blog 1. 

  2. HTML Blocks in kramdown Syntax

Record Linux Terminal

| Comments |

Why?

With detailed output from the terminal, other users can understand the problem better. This helps them come up with a solution to the problem.

Why don’t we use > and >> to capture the standard output?

Using screendump, one can record the commands and their output at one time; using [cmd] > output.txt, output.txt only consists of the output of [cmd], but not what he/she has typed. (i.e. [cmd]) The commands are often complicated and more than one line in length—copying and pasting text from the terminal are thus more difficult. Therefore, screendump is useful.

Why don’t we use fbgrab or fbcat to get a screenshot of the terminal?

The goal is to let other know what’s in the terminal. A screenshot of the terminal is easy to make. However, its file size is much greater than the screen capture made of text. Bitmaps don’t look good when one zooms in on them with a great magnification. Therefore, to achieve the same goal, one may use text instead of images.1

Completely Remove Linux Kernels

| Comments |

Background

I issued the following command and then rebooted the machine.

$ sudo aptitude remove linux-headers-3.2.0-67-generic-pae \
> linux-image-3.2.0-67-generic-pae linux-headers-3.13.0-33-generic \
> linux-image-3.13.0-33-generic linux-image-extra-3.13.0-33-generic

Problem

I checked the list of installed packages, and the above removed package was still there, though in the status of rc.1

How can that package disappear from the list?

Test Embedded Fancybox Inline Element

| Comments |

Why?

It’s because I’ve some code block/console input/output which have more than 80 characters and their width can’t be reduced. For example, in GNU ddrescue—A Powerful Data Recovery Tool, there’s a <pre> tag which is very wide. There’s a scrollbar at the bottom, but it’s hard to see.

fig1

fig2

fig3

fig4

fig5

fig6

fig7

Result

You may view the console message, which has 160 columns. It’s so wide that putting it into a popup dialog can help.

   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   s   create a new empty Sun disklabel
   t   change a partition's system id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit
   x   extra functionality (experts only)
Command (m for help): l
 0  Empty            c  FAT32 LBA       1e  Hidd FAT16 LBA  52  CP/M            80  Minix <1.4a     9f  BSD/OS          bf  Solaris         eb  BeOS fs
 1  FAT12            e  FAT16 LBA       24  NEC DOS         53  OnTrackDM6 Aux3 81  Minix >1.4b     a0  Thinkpad hib    c1  DRDOS/2 FAT12   ee  GPT
 2  XENIX root       f  Extended LBA    39  Plan 9          54  OnTrack DM6     82  Linux swap      a5  FreeBSD         c4  DRDOS/2 smFAT16 ef  EFI FAT
 3  XENIX usr       10  OPUS            3c  PMagic recovery 55  EZ Drive        83  Linux           a6  OpenBSD         c6  DRDOS/2 FAT16   f0  Lnx/PA-RISC bt
 4  Small FAT16     11  Hidden FAT12    40  Venix 80286     56  Golden Bow      84  OS/2 hidden C:  a7  NeXTSTEP        c7  Syrinx          f1  SpeedStor
 5  Extended        12  Compaq diag     41  PPC PReP Boot   5c  Priam Edisk     85  Linux extended  a8  Darwin UFS      da  Non-FS data     f2  DOS secondary
 6  FAT16           14  Hidd Sm FAT16   42  SFS             61  SpeedStor       86  NTFS volume set a9  NetBSD          db  CP/M / CTOS     f4  SpeedStor
 7  HPFS/NTFS       16  Hidd FAT16      4d  QNX4.x          63  GNU HURD/SysV   87  NTFS volume set ab  Darwin boot     de  Dell Utility    fd  Lnx RAID auto
 8  AIX             17  Hidd HPFS/NTFS  4e  QNX4.x 2nd part 64  Netware 286     88  Linux plaintext b7  BSDI fs         df  BootIt          fe  LANstep
 9  AIX bootable    18  AST SmartSleep  4f  QNX4.x 3rd part 65  Netware 386     8e  Linux LVM       b8  BSDI swap       e1  DOS access      ff  XENIX BBT
 a  OS/2 boot mgr   1b  Hidd FAT32      50  OnTrack DM      70  DiskSec MltBoot 93  Amoeba          bb  Boot Wizard Hid e3  DOS R/O
 b  FAT32           1c  Hidd FAT32 LBA  51  OnTrackDM6 Aux1 75  PC/IX           94  Amoeba BBT      be  Solaris boot    e4  SpeedStor
Command (m for help): x
Expert command (m for help): m
Command action
   b   move beginning of data in a partition
   c   change number of cylinders
   e   list extended partitions
   f   fix partition order
   g   create an IRIX (SGI) partition table
   h   change number of heads
   m   print this menu
   p   print the partition table
   q   quit without saving changes
   r   return to the main menu
   s   change number of sectors/track
   v   verify the partition table
   w   write table to disk and exit
Expert command (m for help): q
root@ubuntu:~# ddrescue -r1 -n -S -v /dev/sdf1 /dev/sda5 backup1.log
ddrescue: Output file exists and is not a regular file.
ddrescue: Use `--force' if you really want to overwrite it, but be
ddrescue: aware that all existing data in output file will be lost.
Try `ddrescue --help' for more information.
root@ubuntu:~# ls
root@ubuntu:~# ddrescue -r1 -n -S -f -v /dev/sdf1 /dev/sda5 backup1.log


About to copy 3999 MBytes from /dev/sdf1 to /dev/sda5
    Starting positions: infile = 0 B,  outfile = 0 B
    Copy block size: 128 sectors
Sector size: 512  bytes
Max retries: 1
Direct: no    Sparse: yes    Split: no    Truncate: no

Press Ctrl-C to interrupt
Initial status (read from logfile)
rescued:         0 B,  errsize:       0 B,  errors:       0
Current status
rescued:   377286 kB,  errsize:    4096 B,  current rate:    2686 kB/s
rescued:   594792 kB,  errsize:   12288 B,  current rate:    1179 kB/s
   ipos:   594804 kB,   errors:       2,    average rate:     389 kB/s
   opos:   594804 kB,     time from last successful read:       0 s
Copying non-tried blocks...

Unluckily, I can’t do anything about the horizontal scrollbar at the bottom.

Custom JavaScripts in the Head of Octopress Pages

| Comments |

When I set up Blog 1 for MathJax and fancybox, I included some custom code in source/_includes/custom/head.html. I moved them to source/javascripts/MathJaxLocal.js and source/javascripts/FancyBoxLocal.js because I don’t like JavaScript code inside HTML files.1

In the past, I put those code in source/_includes/custom/head.html because of Felix Chern’s post.2 However, there’s another better way.3 Why is it better? It saves thousands of lines of code. Apart from that, it’s a way to separate the behaviour of a document from the contents.4

git-diff --stat


An Error in Printing Equations in Chrome

| Comments |

This afternoon, I found that when I preview the print layout of the posts in Chrome, some Mathjax block equations enclosed with \begin{equation} weren’t displayed properly. I think it should be due to my settings in sass/custom/_print.scss because the contents in Mathjax’s official demo can be rendered properly in the print preview.1 Therefore, I deleted some obsolete lines of code in that SCSS file .2 Actually, since it takes time for loading MathJax, if I open the print preview before the block equations are ready, then I will see the source code of those equations.


  1. Refer to A Test of Equation Numbering in MathJax Example Pages for details. 

  2. Commit 48b131c