Sunday, June 19, 2016

How to mount NTFS filesystem on OS X

I have a Dell backup drive and would like to backup some of my files on OS X to it. But unfortunately it is formatted as NTFS, by default it is mounted read only on OS X.

Searching around, I found someone mention about the NTFS-3G, that is the tool I am using for Linux. It seems the fastest access is NTFS for Mac from Tuxera.com, it is also the sponsor of the open source project NTFS-3G. At first, I try to see if I could order it, but it has a price tag of $36.33, well, if it were below the $10 mark I will buy it, this price is a little pricy.

Next I try to find if any ntfs-3g binary package is available, the latest I could find is from 2010, a little bit out dated. Then I came across this OSXFuse's project wiki about NTFS-3G. I install the latest 3.4 OSXFUSE. Then the package manager "Homebrew".

Follow the procedure from the wiki, I issue the command

brew install homebrew/fuse/ntfs-3g
Then it starts to download and compiling ... After a few minutes, I got ntfs-3g install.

Then I try the commands from a command shell.

mkdir /Volumes/ntfs 
ntfs-3g /dev/disk1s1 /Volumes/ntfs
Hooray, I got a writable NTFS disk mounted! I did not try to replace the system's mount_ntfs for automount NTFS to read/write. The current form works for me.

PS. Of course, in order to compile all related programs, you need to have Xcode installed.

Thursday, March 24, 2016

Google's hterm: HTML5 terminal emulator

Google's hterm is a nice terminal emulator. I would like to use the hterm part only and do some remote telnet session test (I used libtelnet for the back-end server). But I encountered some usage problems.

First, you could not build a functional hterm script with the github repository, you will need to checkout the full repository from https://chromium.googlesource.com/apps/libapps/ and build from their.

Second, the embedded document is lagging. After following the description in the document, the terminal could be displayed without problem, but there is no input at all. The call back function register to the io.onVTKeystroke() never get called. After digging through other part of the libapps repository for hterm's usage, I found term.installKeyboard() function of the hterm terminal instance need to be called after the term.decorate() call. After that input event could be received.

Third, I haven't found a way to make it acknowledge IME input. Cut and paste utf8 encoded characters causing it to output escaped utf8 stream (utf8 encoded of an utf8 stream).

Friday, November 13, 2015

Running i3 under HiDPI display

I recently got a MacbookPro (early 2015) with retina display for work.  I installed a fresh Slackware64-current on to it with rEFInd as the boot loader.  The process was quite smooth, I used a USB boot image then network install (with a thunderbolt gigabyte adapter).  Some devices/functions are not fully functional but usable for me. Console font is using the kernel built in SUN12x22 font with kernel option "fbcon:font=SUN12x22".

Since this laptop has a 2560x1600 on a 13" display, roughly 227DI, my old setting for i3 did not work well, although I already using xft font for status bar display.  After a few search, I found out xorg server always set DPI 96, that is a bad move in my opinion, as it makes previous valid DPI calculation wrong and still wrong for those cases that the calculation is wrong.  And I have to add a line
xrandr --fbmm 286x179
in .xinitrc file in order to let i3 pick up the correct DPI setting.  OK, now the i3 status bar display fine.  The default dmenu I initially installed does not support xft font, so it looks really small.  Luckily there is a dmenu2 which merged the xft patched.  Remove the old dmenu package and install the dmenu2 package, then add the font parameter to the dmenu_run command in i3's config Latest dmenu works with xft font now. Everything works fine.

I have the following settings in my .Xresources file.
Xft.dpi : 227
Xft.antialias: false
Xft.rgba: rgb

URxvt.scrollstyle: xterm
URxvt.background: black
URxvt.foreground: gray
URxvt.preeditType: Root
URxvt.scrollBar_right: true
URxvt.jumpScroll: true
URxvt.perl-ext-common:  tabbed
URxvt.tabbed.tabbar-fg: 2
URxvt.tabbed.tabbar-bg: 0
URxvt.tabbed.tab-fg:    3
URxvt.tabbed.tab-bg:    0
URxvt.termName: rxvt
URxvt.geometry: 83x27
urxvt.font: xft:DejaVuSansMono:size=8

Xpdf*fontList: -adobe-helvetica-bold-r-normal--0-0-0-0-p-0-iso8859-1
Xpdf.initialZoom: 200

Xcursor.size: 64

With the following, the width should be $((11*COLUMNS+13)) pixels;
! in contrast, the fixed = 6x13 bitmap font is typically used on a
! low-definition screen, giving a width of $((6*COLUMNS+13)) pixels.
XTerm*faceName:  Monospace
XTerm*faceSize:  10
! For xterm menus. This font is large enough, but a bit ugly.
XTerm*font:  -adobe-helvetica-bold-r-normal--0-0-0-0-p-0-iso8859-1
My default terminal is rxvt-unicode, so it works fine. You may notice I have turn antialias off, the font looks sharp, you may see zigzag when looking really close, but for 227DPI, it's very clear without it already.  Most of the document on line regarding GTK+3's HiDPI support is by setting
export GDK_SCALE=2
export GDK_DPI_SCALE=05
I found the program behave a little strange when this kind of scaling in effect.  Font is a little blur than none scale one. For the Gnat Programing Studio (GPS), with the scaling effect, the menu display strangely:
compare with the one without scaling:
I am not sure whether its GTK3' fault or GPS's fault.  I would hope for a GDK_IMAGE_SCALE and only scale image, maybe that will work better.


P.S. After upgrade to kernel 4.4, all the special keys (fn+Fx) works as expected (with pommed-light)

Thursday, October 1, 2015

Using mutool to repair a PDF file that has corrupted xref table

Someone send me a PDF and I could not opened it on my Nexus 5 with Adobe's PDF reader (It suits me the best for a PDF viewer in the android phone).  But both XPDF and muPDF under Linux could opened it with some error message saying the xref table is corrupted and try to rebuild it. 

How could I repair the pdf file?  The first tool comes in my mind is pdftk, it failed to read the corrupted file and give exception.  Then I try pdf2ps, it failed either. 

Google shows me some one saying mutool from muPDF could repair it.  I have using muPDF for some time, it is the default PDF viewer in my Slackware desktop.  But I never take attention to the little tools come along with it, after man mutool, the following command save me:
mutool clean corrupted.pdf clean.pdf
The repaired PDF file is in clean.pdf.

P.S. muPDF does not come with Slackware, but it has a SlackBuild script.  For Windows user, muPDF provide windows version too.

Thursday, September 24, 2015

gnatpp could not align exception declaration properly

I normally use the GNAT Pretty-Printer gnatpp to format my Ada code.  The output of it is not perfect but acceptable and make my code look consistent.

It has a small alignment bug, for exception declaration, it could not handle it properly.  For this specification align_test.ads:
package Align_Test is
    Index: Integer;
    Number_Test : Integer;

    Bad_File : exception;
    Bad_Argument : exception;
end Align_Test;
gnatpp -r align_test.ads will produce:
package Align_Test is
   Index       : Integer;
   Number_Test : Integer;

   Bad_File : exception;
   Bad_Argument : exception;
end Align_Test;
I have to manually align the declaration and add specific comments to fence it from gnatpp to change my alignment in future. 
package Align_Test is
   Index       : Integer;
   Number_Test : Integer;

   --!pp off
   Bad_File     : exception;
   Bad_Argument : exception;
   --!pp on
end Align_Test;
It does not look good, but acceptable.  Wish next version of gnatpp could solve this problem.

P.S. Hooray, today (May. 19, 2016) AdaCore fixed the alignment problem. It will properly show up in GNAT GPL 2016.

Wednesday, September 16, 2015

Where/when is my next laptop purchase

My fastest computer in my home right now is a MacBook from 2009.  It's hard disk has been replaced by a SSD and runs smoothly with the latest OS X and Slackware with some minor glitches (web-camera not working, occasionally system have USB bus error, result in non usable system without keyboard, have to reboot back to OS X to fix it).  I have been searching for my next laptop for some time, but still don't find a perfect one that suites my particular requirements:
  • With 13"/14" screen resolution must be high DPI, the higher the better, minimum 3200x1800.
  • Must have optical digital sound output, be it dedicated TOSLINK connector or combo with head phone jack (this has been standard for MacBook for years).
  • Be lightweight and have longer battery life (>= 8 hours)
  • Must be Linux friendly.
Actually, Dell's XPS 13 almost meets the requirement, except for the optical digital sound output.  Apple's MacBook Pro comes close but it is not Linux friendly, and screen resolution is lower than Dell's.  All of Lenovo's offers lack optical digital sound output, X1 carbon does not have high resolution screen, Yoga Pro does not have enough CPU power.

Maybe I should wait one or two more years, then Intel's new 3D XPoint maybe used for storage, oh my, maybe I will never buy a new one ... ...

Tuesday, September 15, 2015

Microsoft is downloading Windows 10 to your machine 'just in case'

Oh, Microsoft is doing his "smart" again. Now it will silently download Windows 10 image to your machine regardless you want it or not.

News from Inquirer confirmed it with Microsoft.

It is time to turn off automatically update if you still want to keep running it, or better wipe it out with a Linux distribution (Slackware, should you ask for recommendation). ^_^