Blog 1

Random Talk on Random Thoughts

Include Liquid Code Inside Octopress Codeblocks

| Comments |

Last night, I wrote a post on editing a Ruby plugin file and an Atom Feed XML file for removing redundant images in Atom Feeds.1 To show how to change the files, I put some codeblocks in my post.

Sample codeblock that contains Liquid codelink
1
2
3
4
5
6
{% codeblock Change the XML file as well lang:xml http://www.ewal.net/2012/09/08/octopress-customizations/#categories-in-the-atom-feed %}
<entry>
  <!-- other elements -->
  <content type="html"><![CDATA[{{ post.content | remove_linenumbers | remove_bigfig | expand_urls: site.url | cdata_escape }}]]></content>
</entry>
{% endcodeblock %}

However, I couldn’t generate the site. I tried HTML encoding the contents and surrounding them using a <pre> tag, instead of a {% codeblock %} tag, but this approach also failed.

My Settings for RSS (2)

| Comments |

Note: I don’t use Clapper’s image popup plugin anymore, so the settings below are now gone.

Background

Using the following plugin, I finished removing the repeating figures in my Atom Feed.1

Erv Walter's plugin with my modificationslink
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
module CustomLiquidFilters
  def remove_linenumbers(input)
    input.gsub(/\<td\ class="gutter"\>.+?\<\/td\>/m, ' ')
  end

  RegexMap = {
    /\<div\ class="caption"\>Click the image for a larger view.\<\/div\>/ => '',
    /\<div\ id="image-dialog-\d+".*?\>.+?\<\/div\>/m => '',
    /\<div\ class="illustration\ print"\>.+?\<\/div\>/m => '',
  }

  def remove_bigfig(input)
    RegexMap.each_pair {|k,v| input.gsub!(k, v)}
    input
  end
end

Liquid::Template.register_filter CustomLiquidFilters

Problem

How about category Atom Feeds?

It took me some time a find out that the file needed to be changed was source/_includes/custom/category_feed.xml. In that file, I tried to do the same modification like what I had already did in source/atom.xml.

My initial attempt to solve the problem in category feed pagelink
1
2
3
4
<entry>
  <!-- other elements -->
  <content type="html"><![CDATA[{{ post.content | remove_linenumbers | remove_bigfig | expand_urls: site.url | markdownify | cdata_escape }}]]></content>
</entry>

Then I generated the site without getting any errors. However, when I was previewing one of my category Atom Feeds, I found out that the above changes to the XML had did nothing—the popup images still appeared twice.

Upgrade PulseAudio in Ubuntu 12.04

| Comments |

Reason for the upgrade

This Sunday, I opened VLC to watch video, and ran into a “potential PulseAudio version problem”.

VLC error dialog showing a PulseAudio version problem

My clumsy way to fix the issue

Among the sites found with Google, I can only understand the instructions from a question on Ask Ubuntu.

I typed in the command word-by-word like this.

$ sudo add-apt-repository ppa:ubuntu:audio-dev/ppa

Then I got an error. I read Ubuntu Audio Development Team’s PPA on Launchpad to remind myself the command for adding PPAs. I saw that I didn’t include /ppa at the end, so I added it back and ran the command again. However, it failed again.

Finally, I discovered that I had made a silly mistake in the command in the command: the : between ubuntu and audio should be -.

Remove Octopress's Default Image Border

| Comments |

Background

Two days ago, when I was writing a post about viewing Octopress blogs over HTTPS, which is a secure and encrypted connection, I saw a Moziila Support page which contained inline icons. I attempted to include those tiny pictures into some paragraphs. However, the resulting appearance of those paragraphs wasn’t appealing—the white border surrounding the tiny icon didn’t look great. It would be better if it could be removed.

Use Lynx Browser

| Comments |

Why?

This morning, I saw a post on Search Engine People Blog, and decided to make a summary of it, so that I don’t have to think of the reasons for using Lynx when I’m asked for that next time.

Past usage

  • Lack of GUI web browsers like Firefox and Internet Explorer
  • Text browsers were capable of loading contents quickly, if there’s no connection problem.
  • The Internet wasn’t fast enought for extensive transmission of images and flash animations.

Present usage

  • “You really love text and hate images” :)
  • For marketing to search engines
    • See what SEOs see”: they use browsers similar to Lynx.

Remarks: Due to my laziness, reasons for search engines to use text browsers, instead of “a modern browser”, are omitted.

MathJax in Octopress via HTTPS

| Comments |

Problem

Some contents in Octopress blogs couldn’t be viewed via HTTPS1, for example, a Japanese blog.

fig1

This blog on last Saturday afternoon

  • The first category list item “$\rm \LaTeX$” on the right couldn’t be displayed

fig2

  • Using HTTP instead of HTTPS, I can see the blocked contents.

fig3

fig4

How can those blocked contents be displayed automatically?

Secure File Removal

| Comments |

GNU’s shred utility

The command for files and folders

For a single file, the command should be simple. For a directory, the following command can shred the files recursively.1

$ find <dir> -type f -exec shred {} \;

Effectiveness of shred in Ext3 and NTFS file systems

The cited part of shred’s manpage in the second answer interested me to read more about the utility. In Vim, I pressed K when the cursor is on the word shred, and opened the manpage, which claims that using it on an Ext3 partition is fine if the partition is in either the data=ordered (default) or data=writeback mode. How about an NTFS partition? At the bottom, it says that the info page has more information about the utility. I found the following section in the info page.

Please note that `shred’ relies on a very important assumption: that the file system overwrites data in place. This is the traditional way to do things, but many modern file system designs do not satisfy this assumption. Exceptions include:

  • Log-structured or journaled file systems, such as those supplied with AIX and Solaris, and JFS, ReiserFS, XFS, Ext3 (in `data=journal’ mode), BFS, NTFS, etc. when they are configured to journal data.

However, googling “shred ntfs effective”, I saw another post about the utility.2 Due to my limited IT knowledge, searching for the word “NTFS”, all I could understand was that “using shred on NTFS is fine”. I searched for the word “ext3”, and found Shane’s comment, which questioned Wayne Richardson’s advice.3

True solution: Encrypt the file system

I went back to the Unix Stack Exchange question and re-read the second solution. The feasible way is in the last line. I think many new GNU/Linux users who have read this answer won’t think of encrypting swap.