Saturday, August 8, 2020

Install Python 3 virtualenv on Ubuntu (Goolge Cloud)

This one is workable for me.

# Step 1: Update your repositories
$ sudo apt-get update
 
# Step 2: Install pip for Python 3
$ sudo apt-get python3-dev
$ sudo apt install python3-pip
 
# Step 3: Use pip to install virtualenv (no sudo)
$ pip3 install virtualenv
 
# Step 4: Create your Python 3 virtual environment
$ python3 -m virtualenv -p python3 env3
 
# Step 5: Activate the new Python 3 environment.
$ source env3/bin/activate
 
# you can make sure you are now working with Python 3
$ python --version


Saturday, August 1, 2020

Solve Google Chrome "Aw Snap! STATUS_INVALID_IMAGE_HASH" crashes

  1. Open regedit application
  2. Create HKLM\Software\Policies\Google\Chrome, it does not exist.
  3. Create a new  "DWORD 32 bit value" named "RendererCodeIntegrityEnabled"
  4. Set the value to 0x00000000(0)
  5. Reopen Chrome

Thursday, July 16, 2020

Set up Google Cloud VM

Setup up ssh

https://cloud.google.com/compute/docs/instances/adding-removing-ssh-keys

Note:
$ ssh-keygen -t rsa -f ~/.ssh/[KEY_FILENAME] -C [USERNAME]


Set [USERNAME] for the same user.

Change root password

$ sudo passwd


Change user password

$ sudo passwd [USERNAME]

Install zsh

https://ohmyz.sh/

Graphical user interface (GUI) for Google Compute Engine instance

https://medium.com/google-cloud/linux-gui-on-the-google-cloud-platform-800719ab27c5
https://medium.com/google-cloud/graphical-user-interface-gui-for-google-compute-engine-instance-78fccda09e5c
https://help.realvnc.com/hc/en-us/articles/360003474792-Why-does-VNC-Server-in-Virtual-Mode-on-Linux-appear-to-hang-show-a-gray-screen-or-not-start-at-all-#using-vnc-5-x-or-vnc-connect-6-0-6-1-or-on-a-different-version-of-linux--0-1

Steps:
1. sudo apt install xfce xfce4-goodies vnc4server
2. change .vnc/xstartup to

#!/bin/sh
DESKTOP_SESSION=xfce
export DESKTOP_SESSION
startxfce4
vncserver-virtual -kill $DISPLAY


3. start vncserver
$ vncserver

4. stop vncserver
$ vncserver -kill :1

5. set firewall on Google VM by adding a rule with tag "vnc-server": https://console.cloud.google.com/networking/firewalls/list?_ga=2.140666673.226794997.1594947656-1741100383.1594947656&project=covid-19-283520&folder=&organizationId=
6. add "vnc-server" in "Network tag" in the VM instance
7. On local machine, install RealVNC

Wednesday, December 18, 2019

How to use Docker, GPU on Linux


Ubuntu 18.04

1. Install Docker: https://docs.docker.com/install/

$ sudo apt install docker.io

2. Install NVIDIA docker support: https://github.com/NVIDIA/nvidia-docker

# Add the package repositories
$ distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
$ curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add -
$ curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list
$ sudo apt-get update && sudo apt-get install -y nvidia-container-toolkit
$ sudo systemctl restart docker


3. Grant permission

$ sudo setfacl -m user:pengy6:rw /var/run/docker.sock

4. Download a TensorFlow Docker image

$ docker pull tensorflow/tensorflow:1.15.0-gpu
$ docker pull pytorch/pytorch

5. Start a TensorFlow Docker container

$ docker run -it --rm pytorch/pytorch bash

6. Mount local folder (in order)

$ docker run --mount type=bind,source=source,target=target  -it --rm pytorch/pytorch bash

Tuesday, December 10, 2019

Using Bibtex in MS Word 2015 (Mac OS)

BibTeX is a reference management software for formatting lists of references. It makes it easy to cite sources in a consistent manner. However, BibTex is typically used together with the LaTeX document preparation system.

On the other hand, Microsoft Word is still the most commonly used text editor and used in the group to share documents. Thus, I use BibTex to manage the bibliography and use MS Word to write documents.

One of the most famous reference manager software integrated into Word is EndNote, but unfortunately it is a very expensive and not open-source software. In Windows OS, there is a awesome plug-in called “Bib4Word”, but it is not usable in Max OS.

This post will describe how to use BibTex in MS Word in Mac for free.

To organize BibTex, I am using JabRef, which is an open-source and free reference manager. Please follow the following steps:
  1. In JabRef, export the bibliography in MS Word 2008 xml format
  2. Name the file Sources.xml (case sensitive)
  3. In Mac OS with MS Word 2015, go to ~/Library/Containers/com.microsoft.word/Data/Library/Application Support/Microsoft/Office.
  4. Rename the original Sources.xml file to Sources.xml.bak
  5. Copy the generated Sources.xml in this folder
  6. Restart MS Word.
Now you can choose citations from the list.

Build FreeRDP with smartcard on Ubuntu

Compilation instruction

Besides the suggested base dependencies, also install libpcsclite-dev



sudo apt install libpcsclite-dev
cmake -DWITH_PCSC=ON -DWITH_SSE2=ON .
 
Then follow the Build section in the compilation instruction.

Java data structure to use C implementation of word2vec

Data structure to use C implementation of word2vec. https://github.com/yfpeng/pengyifan-word2vec

Getting started






<dependency>
  <groupid>com.pengyifan.word2vec</groupid>
  <artifactid>pengyifan-word2vec</artifactid>
  <version>0.0.1</version>
</dependency>`
or
















<repositories>
    <repository>
        <id>oss-sonatype</id>
        <name>oss-sonatype</name>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
</repositories>
...
<dependency>
  <groupid>com.pengyifan.word2vec</groupid>
  <artifactid>pengyifan-word2vec</artifactid>
  <version>0.0.1-SNAPSHOT</version>
</dependency>

Webpage

The official word2vec webpage is available with all up-to-date instructions and code.