Tuesday, December 10, 2019

How to install pip and create virtualenv on Windows without administrative permission

Since Python 2.7.9, pip is released together with the Python. But I still cannot find it when our administrator installed the latest python on my PC. How to install pip, then create virtualenv on Windows without the administrative permission?
  1. Download get-pip.py.
  2. Run python get-pip.py --user. It will install pip locally.
  3. Install virtualenv by running python -m pip install --user virtualenv. This will install the package of virtualenv
  4. Run python -m virtualenv ENV to create a new virtual environment. ENV is a directory to place the new virtual environment.
  5. Activate the script by running ENV/Scripts/activate.bat.
Now you are in the new virtualenv that is isolated from the python that was used to create it.
You can then install python package by running pip install ... as usual.

Install brat on Ubuntu (Apache2)

Install brat

Install Apache2
Download and unzip the brat v1.3
Move the folder to /var/www/brat
In /var/www/brat run ‘./install’. Follow the instruction to set username, password and email.
In etc/apache2/sites-avialble/000-default.conf add









Alias /brat "/var/www/brat"
<Directory "/var/www/brat">
    Options +ExecCGI
    AddHandler cgi-script .cgi
    # AddHandler fastcgi-script fcgi
    AllowOverride Options Indexes FileInfo Limit
    AddType application/xhtml+xml .xhtml
    AddType font/ttf .ttf
</Directory>
Restart apache2:


sudo service apache2 reload

Enable FastCGI

Install fastcgi by running ‘sudo apt-get install libapache2-mod-fastcgi’
Change etc/apache2/sites-avialble/000-default.conf


 
# AddHandler cgi-script .cgi
AddHandler fastcgi-script fcgi

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.

How to use xRDP for remote access to Ubuntu

 
By | February 14, 201
 

Since the current desktop manager of Ubuntu does not work with xRDP, an alternative desktop manager needs to be installed. In this post, we will use XFCE.

Install xRDP and XFCE


sudo apt-get install xrdp xfce4 xfce4-terminal gnome-icon-theme-full tango-icon-theme

Configure xRDP

First, create an .xsession file in the home directory.

echo xfce4-session >~/.xsession
Then edit the startup file for xRDP /etc/xrdp/startwm.sh.








#!/bin/sh
 
if [ -r /etc/default/locale ]; then
  . /etc/default/locale
  export LANG LANGUAGE
fi
 
startxfce4

Restart xRDP


sudo service xrdp restart

Test xRDP

As an example, on Windows, start the Remote Desktop client (mstsc.exe) and enter the IP address of Ubuntu. Then you will see the login screen. After entering the Ubuntu username and password and click “OK”, a window will show the login process. Finally, you’ll have access to your Ubuntu machine.

Saturday, December 7, 2019

How to delete all .svn in a folder

By | September 20, 2013


If you need to remove all .svn folders in a project, run


find . -name ".svn" -exec rm -rf {} ;
 
or more precisely, run


find . -type d -name '.svn' -print -exec rm -rf {} ;
 
The script starts from the current directory and searches recursively to the sub-folders. This script also works on other names by replacing “.svn”. But if the name is too general especially if you use the regular expression, you may end up by deleting a bunch of folders/files you don’t want to. A safer way is to run find first to verify all found folders/files are really what you intend to remove.

How to convert video using MEncoder


By | September 26, 2013 
 
 MEncoder is a free command line video decoding, encoding, and filtering tool. As a by-product of MPlayer, it can convert all formats that Mplayer can understand.
  1. install mencoder
    sudo apt-get install mencode
    
  2. avi → mp4
    mencoder 1.avi -o 1.mp4 -oac copy -ovc lavc -lavcopts vcodec=mpeg1video -of mpeg
    
    • o: output file name.
    • oac: audio codecs for encoding. copy does not reencode but just copy compressed frames.
    • ovc: video codecs for encoding. lavc means using one of libavcodec’s video codecs.
    • lavcopts: libavcodec’s video codecs. Here we choose MPEG-1 video.
    • of: output container formats. mpeg means MPEG-1 and MPEG-2 PS.
  3. mov → avi
    mencoder -oac mp3lame -ovc x264 1.mov -o 1.avi
    
    • oac: mp3lame means encoding to VBR, ABR or CBR MP3 with LAME.
    • ovc: x264 means using x264, MPEG-4 Advanced Video Coding (AVC), AKA H.264 codec.

Install Source Code Pro on Ubuntu

By | September 28, 2013


Source code pro is a free set of monospace fonts created by Adobe. It is very suitable for text editors and terminal windows. The fonts are also available on various Google Web Fonts.
  1. download: https://sourceforge.net/projects/sourcecodepro.adobe/files/
  2. unzip file
  3. mkdir -p ~/.fonts
  4. move OpenType fonts (.otf) or TrueType files (.ttf) to ~/.fonts
  5. sudo fc-cache