Renew Alienware Alpha R1 with Pop!_OS

Install Pop!_OS

Go to Pop!_OS website, download Pop!_OS ISO Image (NVIDIA), burn into a live USB stick. Currently the latest version is Pop!_OS 22.04 LTS. You have to use a USB keyboard, press F12 when start the computer, then install Pop!_OS.

The installation process is smooth forward without a single issue.

Change mouse to natural scrolling

In settings -> Mouse & Touchpad, check on Natural Scrolling. Yes, I’m a heavy macOS user.

Pasted image 20220605221345

Install Chrome and make it default browser

Open Pop!Shop, search “Chrome” and install it.

Then, change Default Application of Web to “Google Chrome”.

Pasted image 20220606012006

Install 1Password

1Password is a great app for store all the passwords and secrets, it can be run in macOS, Windows, Linux and Web Browser, really convenience.

Get 1Password for Linux of Ubuntu, download the .deb file, and just double click to install.

Activate online account and sync cloud drive

I linked Microsoft account to Pop OS, but One Drive is not there, have to install it seperatly.

Install rclone, rclone can sync plenty of cloud storage with local drive, including One Drive.

curl https://rclone.org/install.sh | sudo bash
rclone config
mkdir /home/kamus/OneDrive
rclone --vfs-cache-mode writes mount my-onedrive:/ /home/kamus/OneDrive/ --daemon

If you want to mount the cloud drive automatically with the system startup, create a systemd config file as /etc/systemd/system/rclonemount.service.

[Unit]  
Description=OneDrive(rclone)  
AssertPathIsDirectory=/home/kamus/OneDrive/  
After=network-online.target

[Service]  
Type=simple  
User=kamus  
Group=kamus  
ExecStart=/usr/bin/rclone --vfs-cache-mode writes mount my-onedrive:/ /home/kamus/OneDrive/ --config /home/kamus/.config/rclone/rclone.conf  
ExecStop=/usr/bin/fusermount -u /home/kamus/OneDrive/  
Restart=always  
RestartSec=10

[Install]  
WantedBy=default.target

Enable the service with systemctl.

sudo systemctl enable rclonemount.service

Now rclone will mount the drive automatically when system startup.

rclone is super powerful, please read manual for more options.

Install Chinese input method – Sogou

This is the most important and complicated job has to be done, I always envy the native English language user, they don’t have to do such things.

At first, should install fcitx input method system.

sudo apt-get install fcitx

Then from the language settings, change input method system to Fcitx.

Pasted image 20220605231555

Since Pop OS makes ibus as the default input method system, you have to remove this config file, just move it to any other directory.

sudo mv /etc/profile.d/pop-im-ibus.sh ~/

Restart the compuer, let fcitx loaded.

Downlaod the sogou input app from sogou website.

sudo dpkg -i sogoupinyin_4.0.1.2123_amd64.deb

Logout system and login again, done. The default hotkey of change input method is “Ctrl+Space”, that is great, the same as I used in macOS and Windows.

所以,现在我们可以使用中文输入法了。

Install Typora and Obsidian

Both are great apps, I use Typora as the default markdown file viewer, and write all the markdown files in Obsidian. I love both of them.

Obsidian is a free app can be installed from Pop!Shop.

The latest version of Typora is not free anymore, but absolutely deserve the price, it can also be installed from Pop!Shop, then open it and input your serial code.

After install Typora, you can install image uploader service – PicGo-Core just from Typora settings.

image-20220609034826011

Install Flameshot and set global hotkey

The oroginal screen capture of Pop OS sucks, Flameshot is a good choice to do the perfect job. To be sure installing flameshot by .deb format instead of flatpack in Pop!Shop.

I usally use Cmd+Shift+4 to capture screen in macOS, so I decide to set the same in Pop OS. By Settings > Keyboard > View and Customize Shortcuts > Custom shortcuts, add a new shortcuts as below.

Pasted image 20220605235747

Install WPS Office

WPS office is more comfotable than LibreOffice if you are familiar with Microsoft Office. Just install it from Pop!Shop.

image-20220609041204009

Beautify Terminal and fix openSSH issue

Change default shell to zsh.

$ sudo apt install zsh
$ chsh -s `which zsh`

Install zsh4humans to get a beautiful terminal expierience.

image-20220609181022408

Please check out this article I wrote to see the detail configuration steps, make sure you download the font with “Mono”, Pop OS terminal’s custom font setting will only show the fonts that is mono: Make a perfect terminal experience from zero in 3 steps

If you ssh to a remote server, got error as below.

❯ ssh -i /home/kamus/Downloads/id_rsa_mogdb_ecs_jumper -p 2222 kamus@121.36.15.2
Unable to negotiate with 121.36.15.2 port 2222: no matching host key type found. Their offer: ssh-rsa

You should add some lines into /etc/ssh/ssh_config files.

Host 121.36.15.2
HostKeyAlgorithms +ssh-rsa
PubkeyAcceptedKeyTypes +ssh-rsa

Use Mogeaver to access MogDB remotely

Mogeaver is the database GUI developer tool based on dbeaver, added MogDB compatible functions.

Mogeaver can be used on macOS, Linux and Windows, the Linux version is not including JRE runtime, so we have to install JRE manually before we can use Mogeaver.

$ sudo apt install default-jre
$ java -version
openjdk version "11.0.15" 2022-04-19
OpenJDK Runtime Environment (build 11.0.15+10-Ubuntu-0ubuntu0.22.04.1)
OpenJDK 64-Bit Server VM (build 11.0.15+10-Ubuntu-0ubuntu0.22.04.1, mixed mode, sharing)

Then downlaod the Mogeaver zip file, extract to any directory, double click “mogeaver” excutable file. Aha! That’s cool, right?

2022-06-09_14-22

Install wechat and wechat.work

$ wget -O- https://deepin-wine.i-m.dev/setup.sh | sh
$ sudo apt-get install com.qq.weixin.deepin
$ sudo apt-get install com.qq.weixin.work.deepin

If you want to try more wine apps made by Deepin, please check this web page.

Up to now, WeChat can run smoothly, but WeChat.work still cannot start normally. If there is a solution in the future, I will update the article.

Weixin.work needs more fix steps after installation. Please check out #277 and #205.

In summary we need to install some packages.

$ sudo apt install libjpeg62:i386 fonts-wqy-zenhei xfonts-wqy  

And modify /opt/apps/com.qq.weixin.work.deepin/files/run.sh to comment 2 lines as below.

#export WINEDLLPATH=/opt/$APPRUN_CMD/lib:/opt/$APPRUN_CMD/lib64
#export WINEPREDLL="$ARCHIVE_FILE_DIR/dlls"
image-20220610155246155

After so many years, to run WeChat and WeChat.work in Linux, still has to be running in a virtual Windows environment such as wine. I can’t help but feel resentment towards Tencent, such a huge enterprise, so many employees, they would like to create games to make money, instead of making even a little effort to create a native wechat client that supports the Linux. Please look at Slack or Discord.

Try to fix suspend issue

The default NVIDIA driver is nvidia-driver-510, when try to turn the computer into suspend mode, it will not wake up again, the fan will swing massively but the display keeps on black.

In Pop!shop – Installed tab, Install “nvidia-driver-470” and restart the machine.

Screenshot from 2022-06-05 22-07-51

But with no luck. Now this is the last unresolved issue that I met in Pop!OS.

Final

Pop!OS maybe is the best Linux desktop distro I’ve tried, compared to Ubuntu, Oracle Linux, Deepin and the popular Manjaro.

Python for the Oracle DBA on Mac OS X Lion (1)

作为一个技术人员,不学习一门编程语言,人生是不完整的。
是Shell是Perl还是Python,哪个简单哪个好用,哪个更适合Oracle DBA,这不是本文的范围,俗话说,萝卜青菜,各有所爱。

Mac OS X中自带Python(实际上也自带Shell和Perl),在Lion之后,由于64bit Oracle客户端无法在Mac中正常运行,导致一系列的麻烦。在Python中连接Oracle数据库,通常是使用cx_Oracle扩展模块。如果是Windows或者CentOS/Redhat/OEL Linux可以直接在cx-oracle.sourceforge.net下载相应的安装文件,但是对于Mac而言,却必须下载源码,自行编译。需要解决64bit问题和Oracle Instant Client配置问题。

文本大部分内容参考Andy Chan的Tutorial: How to Install Python Oracle Module “cx_Oracle” on Mac OS X Lion

在作一切操作之前,请先确认已经安装了XCode,并且安装了Command Line Tools,否则会在最后编译安装cx_Oracle的时候报错:unable to execute llvm-gcc-4.2: No such file or directory

1. 安装Oracle Instant Client,由于众所周知的64bit客户端在Mac OS X Lion中回发生“Segmentation fault: 11”的错误,因此必须下载32bit版本。
编译cx_Oracle需要下载如下图的两个安装文件,不过实际上我是除了Basic Lite之外都下载安装了。具体安装步骤及其它设置可以参看之前我的文章:How to use Oracle Instant Client in Mac OS X Lion

2. Oracle Instant Client的安装实际上就是解压,然后将生成的目录放在$PATH环境变量中,我将解压后的目录放在:/Applications/Utilities/instantclient,目录中的内容如下:

bogon:instantclient Kamus$ ls -l
total 204152
-rw-r--r--@  1 Kamus  staff       278 Apr  1  2009 BASIC_README
-rw-r--r--@  1 Kamus  staff       276 Apr  1  2009 JDBC_README
-rw-r--r--@  1 Kamus  staff       282 Apr  1  2009 SQLPLUS_README
drwxr-xr-x   3 Kamus  admin       102 Aug  9  2011 bin
-rw-r--r--@  1 Kamus  staff   1609607 Feb  2  2008 classes12.jar
-rwxr-xr-x@  1 Kamus  staff     30556 Apr  1  2009 genezi
-rwxr-xr-x@  1 Kamus  staff      1555 Aug  9  2011 glogin.sql
drwxr-xr-x  13 Kamus  admin       442 Jul 22 01:38 lib
lrwxr-xr-x   1 Kamus  admin        20 Jul 22 01:38 libclntsh.dylib -> libclntsh.dylib.10.1
-rwxr-xr-x@  1 Kamus  staff  21537536 Mar 31  2009 libclntsh.dylib.10.1
-rwxr-xr-x@  1 Kamus  staff     31788 Mar 25  2009 libheteroxa10.dylib
-rwxr-xr-x@  1 Kamus  staff     31788 Mar 25  2009 libheteroxa10.jnilib
-rwxr-xr-x@  1 Kamus  staff   1683924 Feb 11  2009 libnnz10.dylib
-rwxr-xr-x@  1 Kamus  staff   1142284 Feb 11  2009 libocci.dylib.10.1
-rwxr-xr-x@  1 Kamus  staff  72626824 Apr  1  2009 libociei.dylib
-rwxr-xr-x@  1 Kamus  staff    106184 Mar 25  2009 libocijdbc10.dylib
-rwxr-xr-x@  1 Kamus  staff    106184 Mar 25  2009 libocijdbc10.jnilib
-rwxr-xr-x@  1 Kamus  staff    933744 Mar 25  2009 libsqlplus.dylib
-rwxr-xr-x@  1 Kamus  staff   1442316 Feb 11  2009 libsqlplusic.dylib
drwxr-xr-x   3 Kamus  admin       102 Jul 30  2011 network
-rw-r--r--@  1 Kamus  staff   1555682 Feb  2  2008 ojdbc14.jar
-rw-r--r--@  1 Kamus  staff   1646178 Jan 23  2008 orai18n.jar
drwxr-xr-x@  7 Kamus  admin       238 Apr  1  2009 sdk
drwxr-xr-x   3 Kamus  admin       102 Aug  9  2011 sqlplus

其中需要注意的是:
1) libclntsh.dylib是需要手工创建的链接。

ln -s libclntsh.dylib.10.1 libclntsh.dylib

2) lib目录,在默认解压以后,没有该目录,需要手工创建,然后将所有lib*复制到该目录中。否则在安装cx_Oracle的时候会报错:无法找到正确的ORACLE_HOME。我的lib目录中文件列表如下:

bogon:instantclient Kamus$ ls -l lib
total 194656
lrwxr-xr-x  1 Kamus  admin        20 Jul 22 01:38 libclntsh.dylib -> libclntsh.dylib.10.1
-rwxr-xr-x@ 1 Kamus  admin  21537536 Jul 22 01:36 libclntsh.dylib.10.1
-rwxr-xr-x@ 1 Kamus  admin     31788 Jul 22 01:36 libheteroxa10.dylib
-rwxr-xr-x@ 1 Kamus  admin     31788 Jul 22 01:36 libheteroxa10.jnilib
-rwxr-xr-x@ 1 Kamus  admin   1683924 Jul 22 01:36 libnnz10.dylib
-rwxr-xr-x@ 1 Kamus  admin   1142284 Jul 22 01:36 libocci.dylib.10.1
-rwxr-xr-x@ 1 Kamus  admin  72626824 Jul 22 01:36 libociei.dylib
-rwxr-xr-x@ 1 Kamus  admin    106184 Jul 22 01:36 libocijdbc10.dylib
-rwxr-xr-x@ 1 Kamus  admin    106184 Jul 22 01:36 libocijdbc10.jnilib
-rwxr-xr-x@ 1 Kamus  admin    933744 Jul 22 01:36 libsqlplus.dylib
-rwxr-xr-x@ 1 Kamus  admin   1442316 Jul 22 01:36 libsqlplusic.dylib

3. 修改环境变量,将以下行添加到~/.bash_profile文件中。

export ORACLE_HOME=/Applications/Utilities/instantclient
export LD_LIBRARY_PATH=$ORACLE_HOME
export DYLD_LIBRARY_PATH=$ORACLE_HOME
export SQLPATH=$ORACLE_HOME
export PATH=$PATH:$ORACLE_HOME/bin
#for cx_Oracle,这是必须的,强制Python使用32位版本
export VERSIONER_PYTHON_PREFER_32_BIT=yes 

4. 启动新的Terminal窗口,先安装pip,pip是Python的包管理软件,使用pip可以方便地从网络上直接安装需要的Python模块。

sudo easy_install pip

5. 安装cx_Oracle

sudo pip install cx_Oracle

安装过程中产生的类似如下这些警告,可以忽略:

/Applications/Utilities/instantclient/sdk/include/nzt.h:2746: warning: function declaration isn’t a prototype
......
Connection.c:283: warning: implicit conversion shortens 64-bit value into a 32-bit value
......

最终显示如下信息表示安装成功:

Successfully installed cx-Oracle

6. 最后测试一下cx_Oracle是否工作正常。具体语法参看:cx_Oracle 5.1.2 documentation

bogon:~ Kamus$ python
Python 2.7.1 (r271:86832, Aug  5 2011, 03:30:24) 
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from cx_Oracle import connect
>>> conn=connect('kamus/oracle@www.enmotech.com:1521/orcl')
>>> curs = conn.cursor()
>>> curs.execute("select * from v$version")
<__builtin__.OracleCursor on >
>>> rows = curs.fetchall()
##以下报错是Python语法对于强制代码缩进的体现,如果for循环中的语句开头没有缩进,则会报错。
>>> for i in range(len(rows)):
... print rows[i][0]
  File "", line 2
    print rows[i][0]
        ^
IndentationError: expected an indented block 
##在print前增加两个空格即可
>>> for i in range(len(rows)):
...   print rows[i][0]
... 
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
PL/SQL Release 11.2.0.3.0 - Production
CORE	11.2.0.3.0	Production
TNS for Solaris: Version 11.2.0.3.0 - Production
NLSRTL Version 11.2.0.3.0 - Production

How to resolve setlocale warning in OEL6

默认安装的Oracle Enterprise Linux 6,在用户登录以后,通常会有以下警告:

Last login: Tue Jun 19 16:52:19 2012 from 192.168.2.1
-bash: warning: setlocale: LC_CTYPE: cannot change locale (UTF-8)

并且在执行oerr等命令的时候,也会先产生警告,比如:

$ oerr ora 10046
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
	LANGUAGE = (unset),
	LC_ALL = (unset),
	LC_CTYPE = "UTF-8",
	LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
10046, 00000, "enable SQL statement timing"
// *Cause:
// *Action:

其实也并不太影响使用,但是比较烦躁。

解决方法:

vi /etc/sysconfig/i18n

默认的内容可能是:

LANG="en_US.UTF-8"
SYSFONT="latarcyrheb-sun16"

需要添加一行LC_ALL的设置,如下:

LANG="en_US.UTF-8"
LC_ALL="en_US.UTF-8"
SYSFONT="latarcyrheb-sun16"

再重新登录,就一切OK了。

备注:为什么会有i18n这样古怪名字的配置文件,实际上i18n是internationalization的所写,表示从i到n之间有18个字母。