Tuesday, January 16, 2018

Command psql of PostgreSQL Complains about Encoding

I have a PostgreSQL database instance configured to use UTF-8. When I connects to it using psql on Windows, it complains with the following,

foopgdb => select * from bar;
ERROR:  character with byte sequence 0xe2 0x86 0x92 in encoding "UTF8" has no 
equivalent in encoding "WIN1252"
foopgdb =>

It turns out that we can inform psql the encoding and select proper encoding table when we run psql as follows in a Windows Command Prompt window,

SET PGCLIENTENCODING=utf-8
chcp 65001

The explanation about PGCLIENTENCODING is in the PostgreSQL documentation while that of chcp at Microsoft Technet. The reference to the code page 65001 is at this MSDN page.

Tuesday, January 9, 2018

Higher Education: Articles on Ideological Diversity on Campuses

I happened to come cross a few articles on the topic of ideological diversity on college and university campuses. This topic interests me.

Nicholas Kristof writes at the New York Times,
"Universities are the bedrock of progressive values, but the one kind of diversity that universities disregard is ideological and religious. We’re fine with people who don’t look like us, as long as they think like us."
In parallel, Fredrik deBoer argues at the Los Angles Times,
"But academics are at fault, too, because we’ve pushed mainstream conservatism out of our institutions. Sociologists Neil Gross and Solon Simmons have found that about half of professors identify as liberal, versus only 14% who identify as Republican. (At the time of their study, in 2006, only a fifth of American adults described themselves as liberal.)
......
In my network of professional academics, almost no one recognizes that our lopsided liberalism presents a threat to academia itself."
and suggests that,

"Our public universities are under massive pressure and at immense risk, and those who should be defenders of public universities still don’t understand that they’ve created the conditions for their destruction."




Sunday, November 19, 2017

Use Long Path or Filename in Windows 10

Microsoft Windows used to have a limit on the length of path or filename. The MSDN article "Naming Files, Paths, and Namespaces" is an in-depth discussion about this topic. Since the roll-out of .Net 4.6.2, long path names exceeding the MAX_PATH, or 255 characters are now permitted as discussed in this MSDN blog post "More on new .NET path handling".


To enable this feature, you can simply set the following Windows Registry DWORD to 1.

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem\LongPathsEnabled For Windows 10 Professional Edition and Enterprise Edition, you can also configure it with the Group Policy editor (gpedit.msc). The setting is under the Administrate Templates, System, File System, and Enable Win32 Long Paths.

Friday, October 6, 2017

Get Rid Of Eclipse Warning Messages on JavaFX API

When I was writing a Java program with JavaFX API, Eclipse complained loudly although the application runs smoothly since JavaFX is part of Java 8. The warning messages are very annoying. An example message is as follows,

Access restriction: The type 'Application' is not API (restriction on required 
library 'C:\Applications\Java\jdk1.8.0_144\jre\lib\ext\jfxrt.jar')

Since a picture is worth 1000 words, below is a screen shot showing the messages,




To get rid of the messages, the easiest way, perhaps, is to install the e(fx)clipse plugin for Eclipse.  To install it, one may follow the steps below,

  1. Start Eclipse. The rest of steps are operations on Eclipse.
  2. Select "Help" from the menu
  3. Select "Install New Software"
  4. On the "Available Software" pop-up window, select "All available sites" for the "Work with:" field.
  5. Type "e(fx)clipse" as the filter text or/and check "e(fx)clipse" under "General Purpose Tools" 
  6. Select "Next" or "Finish" to install it.  Following the instruction to accept the license term and restart Eclipse


After Eclipse restarts, the warning messages should go away.



Wednesday, September 27, 2017

Bhyve Exited to UEFI Shell

I have a FreeNAS host where I run a few Bhyve virtual machine (VM) instances. Upon upgrading FreeNAS, I found some VMs did not boot successfully. It turns out that the VMs exited to UEFI Shell, and complained that it could not locate some efi file. The solution that works for me is discussed in this post.

To summarize, I followed the two steps procedure as described in the post:
  1. Boot the VM into the guest operating system, in my case, CentOS 7, by (1) exiting the UEFI shell, (2) entering UEFI "Boot Maintenance Manager"; (3) choosing "Boot From File", and (4) browsing the directory and locating grubx64.efi under the folder named after the operating system, in my case, centos/grubx64.efi
  2. Copy the efi file to BOOT/BOOTX64.EFI

Monday, September 4, 2017

Firewall Blocked Github: Connection refused

When I am at work, I encountered the following error while attempting to access Github,

ssh: connect to host github.com port 22: Connection refused
This could be the result that the corporate firewall blocked the SSH service (TCP port 22). In this case, we can inform the ssh client to use port 443 instead according to this Stack Overflow post. To do this, we add the following configuration for the ssh client,

cat >> ~/.ssh/config << END

Host github.com
  Hostname ssh.github.com
  Port 443

END
For me to use ssh to connect to Github, the Github official documentation turns out to be very helpful.

Tuesday, August 29, 2017

Running Out-dated JNLP Program

When attempted to launch the remote control JNLP Web Start program from a computer server, I encountered an error:

Unsigned application requesting unrestricted access to system
The following resource is signed with a weak signature algorithm MD5withRSA and is treated
as unsigned: http://192.168.1.5:80/Java/release/Win64.jar

The screen shot is also included,


The error is the result that Java has updated and the MD5withRSA should not be used any more. One work around is to temporary enable the MD5withRSA. One may change the Java security configuration by editing the java.security file. In my case, the file is C:\Program Files\Java\jre1.8.0_141\lib\security\java.security. You will find a line that disables a few algorithms, such as,

jdk.jar.disabledAlgorithms=MD2, MD5, RSA keySize < 1024

We can now simply comment out the line by adding a # at the beginning the line. The line should become,

#jdk.jar.disabledAlgorithms=MD2, MD5, RSA keySize < 1024
In addition, you may need to launch the Java Console, and add the site, in my case, http://192.168.1.5 in the "Exception Site List".