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.

Advertisements

Best ever programmer text editor: Emacs


I was using jEdit. And once willing to change to, so called modern text editor, Atom Text Editor. Then I did some comparisons among the text editors. At the end, now my primary text editor for coding is Emacs.

Emacs requires some time to learn and practise. But at the end, I love it too much. It is so powerful, no other text editor to compare with it. But the primary usage is for coding.

What are the advantages? It has various powerful addons (packages). It is highly customisable. It can work in command-line, that means you can use it over the SSH. (But normally I use Vim instead.) Like Vim, it can browse a directory. It can also perform diff and merge (but I use meld usually). It can work with gdb for debugging. It has syntax highlighting on different languages. It can perform different indentation based on various languages. Syntax highlighting can work on web development which combines JavaScript, CSS, HTML, and even PHP (using “web mode”). It can save the opened files as a project, so that you can work on multiple projects. It can split the views vertically and horizontally, basically unlimited splits. If you want, you can play Tetris in it. It can be used as window manager too.

There are several modes that are interesting. I suggest to know these modes:

  • dired – Directory browsing
  • ibuffer – List and manage opened files
  • eshell – Emacs shell, like bash
  • ielm – Inferior Emacs Lisp Mode. Interactive Lisp environment
  • w3m – w3m web browser, requires package installation.
  • eww – Default web browser in Emacs, but I found it is difficult to use compared to w3m

Customising Emacs to fit your pattern requires some time.

Just share my .emacs file,

(custom-set-variables
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(buffers-menu-max-size 10)
 '(column-number-mode 1)
 '(ediff-split-window-function (quote split-window-horizontally))
 '(inhibit-startup-screen t)
 '(show-paren-mode t)
 '(tool-bar-mode nil))
(custom-set-faces
 ;; custom-set-faces was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(default ((t (:family "DejaVu Sans Mono" :foundry "unknown" :slant normal :weight normal :height 113 :width normal)))))


;; Emacs default setting
(desktop-save-mode 1)
(global-linum-mode 1)
(savehist-mode 1)
(global-auto-revert-mode t)
(setq column-number-mode 1)
(delete-selection-mode 1)

(setq backup-inhibited t)
(setq auto-save-default nil)
(setq mouse-drag-copy-region nil)


(setq-default indent-tabs-mode nil) ;;Disable indent tabs globally
;;Create my own function
(defun my-toggle-tab ()
  (interactive)
  (if (default-value indent-tabs-mode)
      (progn
        (message "Space indent")
        (setq indent-tabs-mode nil)
        )
    (progn
      (message "Tab indent")
      (setq indent-tabs-mode t)
      )
    )
  )
(global-set-key (kbd "C-x C-t") 'my-toggle-tab)


;; Very annoying that override the content with delete word http://stackoverflow.com/questions/6133799/delete-a-word-without-adding-it-to-the-kill-ring-in-emacs
(defun backward-delete-word (arg)
  "Delete characters backward until encountering the beginning of a word.
With argument ARG, do this that many times."
  (interactive "p")
  (delete-region (point) (progn (backward-word arg) (point))))
(global-set-key (kbd "<M-backspace>") 'backward-delete-word)



;; Change font for Chinese characters
(set-fontset-font t 'han (font-spec :family "WenQuanYi Zen Hei Mono"))



;; mouse from http://www.emacswiki.org/emacs/SmoothScrolling
(setq mouse-wheel-scroll-amount '(4 ((shift) . 1))) ;; one line at a time
(setq mouse-wheel-progressive-speed nil) ;; don't accelerate scrolling
(setq mouse-wheel-follow-mouse 't) ;; scroll window under mouse
(setq scroll-step 1) ;; keyboard scroll one line at a time

;; Delete whitespace when save
(add-hook 'before-save-hook 'delete-trailing-whitespace)


;; White space mode
(global-whitespace-mode 1)
(autoload 'whitespace-global-mode "whitespace"
  "Toggle whitespace visualization." t
  (setq whitespace-style (quote (face spaces tabs space-mark tab-mark)))
  )
(autoload 'whitespace-toggle-options "whitespace"
  "Toggle load `whitespace-mode' options." t)


;; Add MELPA
(require 'package)
(add-to-list 'package-archives
	     '("melpa" . "https://melpa.org/packages/"))
(when (< emacs-major-version 24)
  (add-to-list 'package-archives '("gnu" . "http://elpa.gnu.org/packages/")))
(package-initialize)


;;Recent file
(require 'recentf)
(recentf-mode 1)
(setq recentf-max-menu-items 15)
(global-set-key (kbd "C-x C-r") 'recentf-open-files)


;; Load undo-tree and set the undo/redo hotkey
(require 'undo-tree)
(global-undo-tree-mode 1)
(global-set-key (kbd "C-z") 'undo-tree-undo)
(global-set-key (kbd "C-S-z") 'undo-tree-redo)



;; Smooth scroll
(require 'smooth-scroll)
(smooth-scroll-mode 1)


;; Enable auto-complete
(require 'auto-complete)
(global-auto-complete-mode 1)


;; Enable hideshowvis to fold and expand the code
;;(require 'hideshowvis)
;;(hideshowvis-minor-mode 1)


;; Make web-mode to indent with 2 spaces, https://emacs.stackexchange.com/questions/2355/make-web-mode-always-indent-with-spaces
(require 'web-mode)
(defun my-web-mode-hook ()
  "Hooks for Web mode."
  (setq indent-tabs-mode nil)
  (setq tab-width 4)
  (setq web-mode-markup-indent-offset 2)
  (setq web-mode-css-indent-offset 2)
  (setq web-mode-code-indent-offset 2)
  (setq web-mode-style-padding 0)
  (setq web-mode-script-padding 0)
  (setq web-mode-enable-css-colorization t)
)
(add-hook 'web-mode-hook  'my-web-mode-hook)



;; Disable csharp-mode tab
(require 'csharp-mode)
(defun my-csharp-mode-fn ()
  "function that runs when csharp-mode is initialized for a buffer."
  (turn-on-auto-revert-mode)
  (setq indent-tabs-mode nil)
)
(add-hook  'csharp-mode-hook 'my-csharp-mode-fn t)


;;Auto js2-mode
(autoload 'js2-mode "js2-mode.el" nil t)
(add-to-list 'auto-mode-alist '("\\.js$" . js2-mode))


;;HTML
(autoload 'web-mode "web-mode.el" nil t)
(add-to-list 'auto-mode-alist '("\\.html$" . web-mode))
;; (add-to-list 'auto-mode-alist '("\\.php$" . web-mode))

(autoload 'pkgbuild-mode "pkgbuild-mode.el" "PKGBUILD mode." t)
(setq auto-mode-alist (append '(("/PKGBUILD$" . pkgbuild-mode)) auto-mode-alist))

(require 'w3m-load)
(setq w3m-default-display-inline-images t)


(require 'desktop+) ;;Use the desktop+

;; (autoload 'php-mode "php-mode.el" "Php mode." t)
;; (setq auto-mode-alist (append '(("/*.\.php[345]?$" . php-mode)) auto-mode-alist))
;; (autoload 'python-mode "python-mode.el" "Python mode." t)
;; (setq auto-mode-alist (append '(("/*.\.py$" . python-mode)) auto-mode-alist))

It would be better if you learn Emacs from the beginning and try to adapt the default key bindings (hotkeys). Because, if you replace some of the hotkeys with the ones you are used to, you may miss the default key binding power. No more Ctrl+X, C, or V for cut, copy, and paste. Just learn Emacs and customise it.

One more thing, I was looking for folding (collapse and expand) feature. But failed to find one. Yet, just use the key binding C-M-p and C-M-n are enough to fit my demand.

The following is the video which I screencasted with SimpleScreenRecorder and edited by Blender.

Ubuntu with BCM43228


 

My campus lab has the Dell desktops. I am not sure the model, but the network devices are Broadcom BCM43228. As a result, after installation of the Ubuntu (they were not installed by me), Ubuntu cannot get WiFi connection to online.

Since my student mentioned that Windows can use the ethernet cable to share the wireless network, I asked him to help to share the wireless network from Windows on the other Dell desktop, and connect to the target Dell desktop.

This step works.

Next, I followed this Q and A post, just followed exactly all the commands there. Then reboot.

Yes! It works. Now, my students can test Ubuntu.

Xfce4 Power Manager, NVIDIA, Nouveau backlight issue


Recently I move back to use my (around) 4 years old laptop, HP Pavilion dv3. It has NVIDIA graphic card. But since I (re-)installed Arch Linux 64 bit on it, I failed to run the X11 with the proprietary NVIDIA driver. As a result, I used the Nouveau module instead. Then, I tried several times and finally successfully run the X11 with NVIDIA driver.

To use the Nouveau module, in the mkinitcpio.conf, we have to add in “nouveau” module, then build the initramfs (refer to wiki page). And use the “Xorg -configure” to generate the xorg.conf.

But in order to use the NVIDIA driver, firstly, has to identify the NVIDIA graphic card and download the related drivers. Secondly, since I am using 64 bit, but also running 32 bit packages, so I have to install all the corresponding lib32 NVIDIA packages. Moreover, the nvidia*-libgl are conflicted to mesa-libgl, which is used by Nouveau. After installing NVIDIA, use “nvidia-xconfig” to generate the xorg.conf.

We can also disable the splash screen (logo) when starting the X11, by adding

Options "NoLogo" "1"

in the “Device” section in the xorg.conf.

Then after using the NVIDIA, I face a serious problem, that is the xrandr (in fact I am usign ARandR) cannot change the screen resolution. This is troublesome as I need to make the changes towards the projector (2nd screen) frequently, such as two screens (left screen and right screen), laptop only (disable the projector), or clone (both laptop and the projector share the same screen). With the NVIDIA, xrandr cannot detect other resolutions, consequently I cannot make clone of the screen. So, I decided to use back Nouveau.

However, I have another serious problem with Nouveau module, that is, adjusting the backlight brightness (screen brightness). When I use xbacklight, it shows

No outputs have backlight property

I cannot adjust the backlight brightness using the usual keyboard key with Xfce4 Power Manager. Some forums stated that adding “acpi_backlight=xxxx” to the kernel parameter. But none of them works.

In my /sys/class/backlight, there are acpi_video0 and nv_backlight. Actually, I can change the backlight by echo the value to the acpi_video0/brightness, with “su”. Yet the nv_backlight does not show any effect.

I found that, I can use the keyboard key to adjust the brightness before start the Xfce4. Once the Xfce4 started (with Power Manager), the brightness change takes no effect. And the changes of the brightness is affecting the nv_backlight/brightness. So, I concluded that it is actually fixable by fixing the Xfce4 Power Manager.

As a result, I patched the Xfce4 Power Manager by editing the source code, to remove the “nv_backlight” from the priority. Install this patched package, restart the Xfce4, and now, it works!

Facebook chat list


I am not a Facebook fervent user. I use it because of some of my friends are using it.

So, if you want to enable your “available to chat” status to your group of close friends or special group of friends,

  1. Go to Friends an create a list that you want to chat with.
  2. After creating the list, add your close friends.
  3. Now, turn on the Chat.
  4. Go to Chat Options > Advanced Settings
  5. Choose “Turn off chat for all friends except…”, and add in your target chat.
Custom chat list in Facebook
Custom chat list in Facebook

Then, if you are using Pidgin, you can use chat with your Facebook friends by following this instruction.

LibreOffice Writer table tips


Preface

LibreOffice Writer is better than Microsoft Word. If you are a web developer, you should understand that there are class and style. Using LibreOffice is tended to using class-like style, instead of direct formatting, which causes a lot of inconsistent, troublesome, and time consuming modification throughout the word processing. And this is happened when the newbies are using Microsoft Word to create templates for the advanced user like me, and causes me full of trouble as being tortured.

The worst thing in Microsoft Word is the Numbering format. Microsoft Word sets the numbering format as properties of a paragraph. But LO Writer differentiates the paragraph style, character style, frame style, page style, and the list style. Thus, it is much more easier to use the list style in LO Writer.

I admit that LibreOffice Writer still has some limitations comparing to some features of Microsoft Word, but for the styles and formatting, it is much more easier than using Microsoft Word.

Now, let me go into the tips of the table in LO Writer. The LO version I am using is 5.0.

Table at the same line of paragraph

In Writer, unlike image, table by default cannot anchor as character. Therefore, it cannot have some text at the left or right of a table. This can be solved by using frame.

Table in the paragraph line
Table in the paragraph line

So, create a frame and set the properties,

  1. Type > Anchor as character
  2. Type > Vertical Top to Row (depend on your preference)
  3. Wrap > Spacing four sides to zero
  4. Borders > Set no border
  5. Insert table inside the frame.

Remove/add the empty line after table

As the image above, you can see within the frame, there is an empty line after the table. This line, you cannot delete or “backspace”. So, in order to solve this, at the last cell of the table, press Ctrl+Shift+Del will delete the empty line. In order to add the empty line, Alt+Enter.

Vertical text in the table

To create a vertical text, it has to create a new style (it can be based on the Table Contents). Then at the new style properties,

  • Position > Rotation / Scaling > 90 degrees or 270 degrees (based on your preference)

After creating this style, just select the content of the cell you want to have a vertical align, apply the created style, than it will work.

Vertical text in the table
Vertical text in the table

There are several things have to take note when using the style to rotate the text. The image above shows two different ways to rotate the text. The left bottom cell is using the method mentioned above, the right bottom cell is using the following method,

  1. Select the text in the cell, and go to Table Properties,
  2. Text Flow > Text orientation >Vertical

By using the Text Flow method, we cannot change the rotation direction as shown in the left bottom cell. But using this way, we can change the alignment and indent easily. When we choose align to the centre, the text will be centre as usual.

However, using the Style method, it is quite confusing. When using Style, if we align the text to centre, it is based on the view of the table, instead of make the text centre itself.

Centre text problem
Centre text problem

As the image above, the first cell has the following properties

  • Table Properties > Text Flow > Alignment > Top
  • Paragraph Properties > Alignment > Options > Centre

The second cell has the same properties as above.

In order to make our text at the left cell start from the left bottom corner, then we have to set

  • Table Properties > Text Flow > Alignment > Bottom
  • Paragraph Properties > Alignment > Options > Left
Align the table
Align the table (they left and bottom).

Padding in a specific cell or customise a cell

As the image above, we want to adjust the left cell of the text, so that the text and the bottom border has some spacing, this have to customise the cell specifically. However, LO Writer does not show any clue for you to edit the properties of a cell, and it only shows you “Table Properties”.

It is actually possible to customise a certain cell.

  1. Select a cell by highlight the content inside,librlibr then hold and move the cursor to next cell. We will discover that the cells are highlighted, instead of the text within.
  2. Since there are two cells being selected, we move our mouse back to the original cell. And we will get something like this,
Select a cell
Select a cell

Now, the cell can be edited with Table Properties (which is actually selected cell properties).

 

So, these are a few tips which are useful to manage the table in the Writer.

Folders and file naming habits that are useful


I would like to share some of my computer management habits regarding the folder name. Unlike my friends or colleagues, I seldom put the files in the Desktop folder. Because I prefer that my computer desktop is always clean (yet physically, my desktop is messy).

Therefore, there are several folders appeared in my computer, and these folders can be appeared in any other folders.

Firstly, “temp” is my most favourite folder. Any temporary documents or files, that are not very important, they are saved here. The “temp” folder is also appeared in my Download folder. Furthermore, when necessary, “temp2”, “temp3”, and so on will be created. These folders, if they are deleted, normally will not cause any catastrophic effect.

Secondly, “backup” folder. When doing the development, some of the files, I need to backup, I will renamed them suffix with date, then move to the “backup” folder. I do not use version control software, since most of my developments are individual project.

Thirdly, “unsorted” folder. I adopt this concept from Firefox bookmark. In Firefox, all the bookmarks that are not put inside any folder, they are automatically put in Unsorted Bookmarks. I use this folder when, some of the files or documents especially articles that are quite important, but I not yet decided where to put, then I will put them all in the “unsorted” folder. It is not a “misc” (miscellaneous) folder, but just a not yet organized folder. I may (or may not) organize the files in future.

Fourthly, “archive” folder. I adopt this concept from email management recently. There are some files or documents, can be deleted, but they are still worthy to be kept in the computer. And, they are not organized, then I will put them into the “archive” folder.

Finally, “1”, “2”, “3”, …, folders. These folders, I use them to put my favourite files such as photos, movies, songs, etc. The worst movies or songs that I do not like, but still want to keep in my computer, I will use “9” folder. Then the best one is the “1”, followed by “2”. So that, it is easy for me to know which files are important. Moreover, the best of the best files will reside in “0” folder.

As a conclusion, ordering these folders according to the importance: 0, 1, 2, … > backup > unsorted > archived > temp.

Previously, I used the some folders such as “new”. This actually doesn’t many any sense, because there is no way to let me know how new is the “new” folder.

Besides that, there are some file naming habits I am using. Adding date at the end of the file name, such as myfile20150419.docx. This is useful if the file is frequently updated and older content has to be preserved. So that, the file edited yesterday is myfile20150418.docx. By reading the filename, I can know how latest the file is. (Though the word processing software such as LibreOffice Writer allows to save the older version in the file, but this will also increase the file size, and also has the difficulty to compare two files, thus I am using this file naming style.)

Recently, because of reading journal articles, I renamed the PDF files with a keyword at the end. I adopt this style based on the “tagging” (or “labelling”). Normally, we organize our files into the relevant folders already. Yet, the folder itself is not sufficient to give the “brief description” of the file. As a result, I add a keyword to the file name.

Organize the files properly, will reduce the time to search the file. Some users may install the desktop search software such as Google Desktop Search. However, because I used EncFS to encrypt my files, search indexing is troublesome.