RSS Feed

Category Archives: computer

AAC audio file and ID3 tag


I just found that, if I have an AAC audio file (technically M4A), and if I added the ID3 tag 2 (aka ID3v2), then the audio file will failed to be converted by ffmpeg.

It can be either converted to mp3

  • using DeadBeef audio player, or
  • remove the ID3v2 tag then convert

So, how to add the metadata like ID3 tag? Use the Kid3 and add the Tag 3 (aka APE tag). This will not affect how ffmpeg to read the file.

Openbox + tint2


Previously I was using Xfce4. Then, because of the heavy working environment, I tried the lighter desktop environment, LXDE. But still, it has some limitations that made me choose to use Openbox window manager only.

Pros and cons of Xfce4

Xfce4 is lightweight comparing to GNOME or KDE. I like it, because of the conventional design like the task manager. Furthermore another thing I like is the “aerosnap” feature like Windows, which I can view the two windows side by side. However, when running Windows in VirtualBox and other applications, I can feel the obvious slowness in the computer. It is really reducing my working performance. That is why I decided to change to LXDE.

Pros and cons of LXDE

LXDE is lighter than Xfce4. So, running a lot of heavy applications does not slow down the computer like Xfce4. But there was one issue I faced. The LXDE pager (workspace) does not allow me to drag and drop the applications to move among the workspaces.

As a result, I decided to use something lighter than Xfce4 and I can drag and drop the applications among the workspaces easily.

Openbox and tint2

I had experienced Openbox with tint2 when I was using my old laptop. Openbox is nice and highly customisable. Tint2 allows me to set number of workspaces, and easily to move the applications to other workspaces. However, tint2 does not have applets or plugins like Xfce4 or LXDE.

There is one feature I need, that is to see CPU usage, so that I know whether there is any application causes high CPU usage. As a result, I installed Conky and display the CPU usage at the corner of the desktop.

Openbox + tint2

Openbox + tint2

Conky

For the Conky, the following is the conky.conf

conky.config = {
    alignment = 'bottom_right',
    background = false,
    border_width = 0,
    cpu_avg_samples = 2,
	default_color = 'white',
    default_outline_color = 'BBBBBB',
    default_shade_color = '444444',
    draw_borders = false,
    draw_graph_borders = false,
    draw_outline = false,
    draw_shades = false,
    use_xft = true,
    font = 'DejaVu Sans Mono:size=1', --by size 1 then only there will have no space after cpugraph
    gap_x = 0,
    gap_y = 2,
    minimum_height = 5,
	minimum_width = 5,
    net_avg_samples = 2,
    no_buffers = true,
    out_to_console = false,
    out_to_stderr = false,
    extra_newline = false,
    own_window = true,
    own_window_class = 'Conky',
    own_window_type = 'desktop',
	own_window_transparent = true,
	own_window_argb_visual = true,
	own_window_argb_value = 255,
    stippled_borders = 0,
    update_interval = 1.0,
    uppercase = false,
    use_spacer = 'none',
    show_graph_scale = false,
    show_graph_range = false,
	double_buffer = true,
	imlib_cache_size = 10,
}

conky.text = [[
	${cpugraph 27,40 000000 FFFFFF -l}
]]

Cloud9


Cloud9 is a web-based IDE good for collaboration and online development. You can store your large project on the remote server, and use any computer including netbook with a web browser to develop your system.

Now, the problem I faced when using C9 on my Chromium. Firstly, the address bar, tabs, and bookmarks occupy some space in the window. This results a non-editor look and feel. This makes me feel lacking of something. Secondly, the worst part is the shortcut key like Ctrl+W. By pressing this shortcut key, it will invoke the web browser closing window instead of the C9 shortcut key. Meaning, the shortcut key of the web browser has higher precedence than C9 itself.

I looked for the C9 official Chrome extension, namely Cloud9, but it just works like a bookmark. I tried also Cloud 9 IDE Shortcut. It works better than official Cloud9 Chrome extension. Yet, I need to enter my username and password for the first time. Another drawback is the missing of the window icons like minimize, maximize/restore, and close, and title bar, which results difficulty to resize and maximize/restore.

Looks for some solutions. The easiest way is to invoke

chromium --app=https://ide.c9.io/

Yay! Now I can use the shortcut keys and it looks like native text editor!

Chromium running C9 as app

Chromium running C9 as app

If you are serious, you can write the manifest.json to create the C9 web app, then you can have a custom icon instead of Chromium icon.

External HDD struggling


I have an HP 1T external HDD. It is dying. Sh*t!

So, I made my final struggling onto it. Though it is not 100% work as planned, I still have around 320G usable space.

Symptoms

Firstly, I found that some files cannot be deleted, I had no choice but plug out the USB cable manually. Try to chkdsk with Windows since it is NTFS partition, but the chkdsk stopped and no response during the progress. Then I know, these were the bad signs. So, have to avoid using it and get a new HDD, and move whatever files able to be moved.

Backup like sh*t

I use Linux instead of Windows, because copying out the files with Windows is damn slow. So, I have no choice but to use Linux. During copying from this pity HDD to the new HDD, the copying process will stop without warning, and the HDD failed to work. Worst, there was no way to cancel the operation, only solution to plug it out. I repeated this procedure approximately 60-70 times (heuristic guess only).

S.M.A.R.T

There is one thing I have to mention, that is S.M.A.R.T. I had enabled it on the external HDD, but it did not show any useful feature to SAVE my date.

NTFS

After copying out primary data and giving up some secondary data, I decided to re-format it as NTFS. Though I very dislike Windows, NTFS is still the main stream. NTFS and FAT32 are widely supported by the devices, for instance, LG video player. I also considered exFAT, but it is not as good as NTFS supported by Linux.

So, booted into Windows, plugged in the USB cable, format the disk without “Quick Format”, because I intended to have a thorough “chkdsk” scanning for bad sector.

Unfortunately, it was DAMN slow. To increase from 0% to 1% requires about 30 minutes. How am I going to live my following life?

Then I cancelled the format and gave up NTFS.

ext4

Since there was no more hope on NTFS, I planned to format as ext4. I run mkfs.ext4 with “-c” to check for bad blocks (something like bad sectors). But it failed. The hard disk failed to work until I re-plugged in the USB. I tried dmesg, found that there are a lot of errors like

usb 2-2: reset SuperSpeed USB device number 2 using xhci_hcd
usb 2-2: LPM exit latency is zeroed, disabling LPM.
blk_update_request: I/O error, dev sdb, sector 721688448

I concluded that it is not just bad sectors/blocks, but just failed to read the blocks.

badblocks

So, I assumed that mkfs.ext4 with “-c” or even fsck.ext4 will not solve my problem. Those bad sectors should never be accessed. So, I decided to give up those sectors, meaning, skip those factors from the partitions. This can be done by using fdisk or cfdisk, creating the partitions based on the “sector” unit instead of size. We can create the partition to occupy the bad sectors area, then create next partition after it, and then delete the partition that has bad sectors.

Then, the next question is how to find the bad sectors. mkfs.ext4 and fsck.ext4 cannot solve, because they are checking for the bad sectors thoroughly through the partition. The solution is to use “badblocks”.

There are two things have to know, i) sector and ii) block. They are different things. badblocks command can identify the bad blocks, but not the bad sectors. However, fdisk allows us to get the total number of the sectors.

Now, we can do some maths here. Let’s say you run the “fdisk -l”, and get this,

Disk /dev/sdb: 931.5 GiB, 1000204886016 bytes, 1953525168 sectors

The total number of the sectors of the hard disk is 1953525168.

Now, to get the total number of blocks, use “cat /proc/partitions”, you will get something like this,

major minor  #blocks  name

   8        0  976762584 sdb

So, that is the total number of blocks, 976762584. And you can do the calculation, 976762584*2 = 1953525168. So, 1 block = 2 sectors.

This is important information, because when we use the badblocks, the values are shown in block unit. But when we want to create partitions, we are using sector unit.

So, when we run the badblocks like

badblocks -v -s -o bad.txt /dev/sdb

It will show something like

Checking blocks 0 to 976762583

which is the first block (0) until the last block (976762584 -1).

Now, in case we stop/interrupt the badblocks, we can continue from any where we want. Or, we can just start from any block. For instance

badblocks -v -s -o bad.txt /dev/sdb 976762583 488381292

where the 976762583 is the last block we want to check, and 488381292 is the start block we want to check. (Please read the manual in detail.)

Result

So, based on these tools and information, finally I found that there is around 320G contiguous safe space. So, I create the partition for it, and finally format it at ext4. Since it is a dying hard disk, I will not use it to store primary data, but secondary data and secondary backup. (Secondary data is unimportant; secondary backup is the duplicated backup, not one and only one.)

Actual plan for the next stage

Unfortunately, because the hard disk has critical failure, I cannot implement the next stage.

In my expectation, the hard disk may have multiple large, contiguous, and safe space. For example, 0-25% from the beginning is safe, and 60-100% is safe. As a result, I can create 2 partitions for these space. This is what I actually want. If this really happen, then I can use the LVM so that I can combine both partitions as a logical volume, and finally mkfs on it.

But since it does not happen, I cannot test on the LVM.

 

Search song that plays on your computer (Linux)

Posted on

Since I am working as freelance developer, I spent most of my “otaku” time with Animenfo Radio. Now, when listening with some nice songs you like, and you would like to know what the song is, then you can use Shazam to detect it. But using Shazam requires you to turn on your volume and use your mobile phone to detect it.

What if, you are listening the songs with your ear-phone?

To make it work on your Linux computer,

  1. Listen to a music or song, make sure it is still playing
  2. Run pavucontrol (PulseAudio Volume Control), install it if you didn’t
  3. Open a music searching website such as Midomi (so far I only know this website)
  4. Click the recording button (make sure it starts recording), allow using microphone as prompted by the web browser
  5. Then you will see this in pavucontrol
  6. PulseAudio Volume Controller record audio

    PulseAudio Volume Controller record audio

  7. There are two options, one is “Built-in Audio Analog Stereo”, another is “Monitor of Built-in Audio Analog Stereo”. Choose the “Monitor” something will redirect your computer audio output to your computer recorder (input).
  8. Then, the website like Midomi will get what you are listening, and submit for a search!

Yeah! No Shazam, and you can search when you are listening with the ear-phone.

Technology that you must know


Linux, git, ssh, and Docker.

Linux is the most flexible OS kernel in the world right now. It is used in supercomputer, personal computer, server, embedded system like smart vacuum cleaner, mobile phone, smart TV, etc. Firstly because it is open source, everyone can study it, modify it, and redistribute it. Secondly, thanks to GPL (license). Because of GPL, anyone who use Linux need to open source their code. Those bossy people who knows Windows only and like to earn money without paying any efforts, and never understood programming and programmers, they will never understand the power of Linux and GPL.

git, like Linux, the main author is Mr. Torvalds. It is the most popular source code and revision management tool in the world right now. Those who only know GUI will never understand the power of text files. Those who don’t know what is open source are even more out of their topics.

SSH, with the advancement of cloud computing, you need to access to remote computer or server, SSH is your need!

[B]locking an SSH port for a Linux user is like taking a mouse away from a Windows user! (Powers, 2015)

Then lastly is Docker. It is an OS level virtualisation. The development environment and production environment always has a gap. Therefore, to develop a system in an environment as similar as the production is always a need. For the software level, we can use rbenv or rvm for Ruby, virtualenv for Python. However, if the production environment uses stable version of PHP and Apache, and your working computer is using the latest version of PHP and Apache, are you going to uninstall the latest version and install the stable version? If you have multiple projects, are you going to buy many computers for each of them? One of the solution is virtualisation using virtual machine like VirtualBox. But when we are using virtual machines, we need to reserve the memory and hard disk space to the virtual machines. And some of the hardware cannot be shared, but virtualised, like the graphic card and network card. However, if using container like Docker, it can access the hardware and share the OS libraries. You can also run the GUI application as it is running on the host computer. For those Windows users they will not understand, because Docker is based on Linux technology. However, you can still using Docker on Windows and Mac OS X.

Dell Vostro 5459 review and setup


Due to the changes of the career, I invested on Dell Vostro 5459, after a long survey. I chose it because it is compatible to Linux. The compatibility to Linux meaning that, all the hardware devices are accessible by Linux. Besides that, it has the NVIDIA graphic card, which allows me to use GPGPU to do my research and study. Moreover, I can play high quality 3D graphics games.

Ubuntu

So, the laptop I bought was pre-installed with Ubuntu. And, I was impressed by the Ubuntu first boot video, which can be found here.

Partition and bootloader

It is new laptop, thus the hard disk partitioning table is using GPT format instead of MBR format. And the laptop uses UEFI boot system by default. It will be very convenient to have multiboot with several OSes.

In order to do partitioning, I used my favourite tool, SystemRescueCD. But I failed to run the X11 window, due to the very new NVIDIA graphic card. (I believe I can run the X11 now.)

Before partitioning and formatting the hard disk, I checked the xorg.conf from the existing Ubuntu, believed that it can help me to figure out how to start X11 window in SystemRescueCD. Then I discovered that /etc/X11/xorg.conf does not exist. This is a very important point.

Consequently, I used the command-line interface to re-partitioning the hard disk. Because I was going to install Windows and Arch Linux on it.

Windows

Though I prefer Linux, Ubuntu not my primary OS. So, I have to install the Arch Linux. Before installing Arch Linux, due to the luxurious hardware specification, I intended to install Windows 7. The laptop does not have USB2.0, but only USB3.0, and I didn’t want to install Windows 7 through external DVD-ROM, because I didn’t want to burn Windows 7 to a DVD. As a result, Windows 7 with USB3.0 cannot be installed. Looking for the solution, extra drivers are required. Thus, I gave up Windows 7 and tried Windows 8.1. (Sorry, Windows 8 and 10 are not my favourite.)

Great. Windows 8.1 is not bad after installation. I came back to Windows drivers later, since Windows is my secondary OS, for the purpose of… gaming.

Arch Linux

Installing Arch Linux needs some skills, and Internet connection is very important. So, I installed all the packages based on the old laptop, just following the powerful Arch Linux Wiki.

NVIDIA

NVIDIA GeForce 930M is very troublesome. After installing Arch Linux, to fully utilise my graphic card, I decided to use NVIDIA driver instead of Nouveau.

However, nvidia-xconfig generated xorg.conf file does not work. I failed to run the X11 window as in the SystemRescueCD.

As a result, I removed the NVIDIA related section in the xorg.conf according to the Arch Linux forum here. And the pre-installed Ubuntu does not have the xorg.conf as well. After removing the file, X11 window works fine.

After running the Arch Linux and configuring my preferences, I found that some of the screensavers (from xscreensaver) showed the error message,

Xlib: extension "GLX" missing on display ":0"

So, I knew that there is something wrong with my Xorg configuration and the NVIDIA.

Keep doing the trial and error, then I discovered something called bumblebee. Actually I am still very confused with this bumblebee, only know that it is related to NVIDA Optimus. And, I also don’t know what the hell is NVIDIA Optimus, only know that it is something wonderful.

After installing bumblebee, then the nvidia-libgl package is replaced by mesa-libgl. And the xscreensaver did not show the error message above anymore.

Since installed bumblebee, I supposed I can use Optimus with optirun command. Running

optirun glxgears -info

I got the new error,

libGL error: No matching fbConfigs or visuals found
libGL error: failed to load driver: swrast
...

Then, I thought may be my NVIDIA is too new, so I tried to install nvidia-beta. But it did not solve the problem as well.

As a result, I tried nvidia-dkms. Yeah! It works. “optirun” works fine now.

Windows 8.1

I love Dell, because the drivers are available online. I just download all the important drivers, graphic card, sound card, WiFi drivers, etc. Then I booted into Windows 8.1, and installed all the drivers. I just wonder, Arch Linux can use the WiFi device immediately during the installation, but Windows cannot? That means, if I have Windows and WiFi only, but does not have the driver, then how can I download the drivers?

After installed all the drivers, then I booted into Arch Linux, but failed. Because I failed to mount the Windows partition in Linux after installing the drivers. Then I found that, it is because of the Fast Startup feature in Windows 8. (Solution is here, look for the Fast Startup.) Because Fast Startup causes the partition “not clean”, so that Linux cannot mount it.

After disabling the Fast Startup, then everything works fine now.

Data transfer

Transferring vast amount of data between computers is very time consuming. I previously used an external hard disk. But transferring data from a 500G laptop to a 1T laptop, using an external hard disk is not applicable, since I don’t have extra empty hard disk.

At the end, I used the ethernet cable to transfer the data. (This is what I learnt from my student previously.) In Linux, I used the Network Manager to share the wired connection. Then directly connect two laptops with a single ethernet cable, and router is not required. Ethernet cable is faster than WiFi, and I can transfer whatever data I want from A to B or vice versa.

But still, I have to use the SSH to mount the target laptop.

This is a time consuming process.

Hibernation and resume issue

Now the only problem is resume from hibernation in Arch Linux. The resuming from hibernation works inconsistently. I have tried to install Linux LTS version, but it is worse because I cannot use Fn key after booting in Linux LTS.

I am still figuring out how to solve this problem.