apt-get Behind a proxy server that requires authentication

Create a new file in the /etc/apt/apt.conf.d

for example: create the file 80proxy with

sudo nano /etc/apt/apt.conf.d/80proxy

and add the following lines to configure the proxy setting:

Acquire::http::Proxy "http://<username>:<password>@<proxy IP>:<port>";
Acquire::https::Proxy "http://<username>:<password>@<proxy IP>:<port>";
Acquire::ftp::Proxy "http://<username>:<password>@<proxy IP>:<port>";

OCR Text from PDF Document

Today, I had to convert a scanned 3-page PDF file back into a editable document. So, open source software to the rescue. I was able to complete the task with the help of:

  • tesseract — for OCR, and
  • imagemagick — for converting PDF pages to an image format that tesseract accepts.
  1. Installing the software

    sudo apt-get -y install tesseract-ocr imagemagick

  2. Convert PDF pages to image

    convert -density 300 -depth 8 scan.pdf[0] scan0.png
    convert -density 300 -depth 8 scan.pdf[1] scan1.png
    convert -density 300 -depth 8 scan.pdf[2] scan2.png

    convert is a member of the amagemagick tools. You can use it to convert between image formats as well as resize an image, blur, crop, despeckle, dither, draw on, flip, join, re-sample, and much more.

    Here, I’m only using two options:

    -density width
    to set the resolution of an image for rendering to devices. The default unit of measure is dots per inch. The default resolution is 72 dpi.

    -depth value
    to set the number of bits in a color sample within a pixel.

    The numbers between the brackets mark the page in the PDF document to be converted. Of course, as any programmer can tell you, you start counting at zero.

  3. OCR page images to text

    $ tesseract scan0.png scan0.txt
    Tesseract Open Source OCR Engine v3.02.01 with Leptonica
    $ tesseract scan1.png scan1.txt
    Tesseract Open Source OCR Engine v3.02.01 with Leptonica
    $ tesseract scan2.png scan2.txt
    Tesseract Open Source OCR Engine v3.02.01 with Leptonica

And then just copy the OCR text from the text files into a new document to clear up any typo and reformat the document.

dircolors for better ls listing

ls uses the environment variable LS_COLORS to determine the colors in which the filenames are to be displayed. This environment variable is usually set by a command in the .bashrc file like
eval 'dircolors some_path/dir_colors'
to create a customize .dircolors file, use the command

dircolors -p > .dircolors

and then edit the .dircolors file.

for example, change the color of execute permission to red with: EXEC 00;31

The comments in the generated .dircolors file already listed the color codes.
ISO 6429 color sequences are composed of sequences of numbers separated by semicolons. The most common codes are:

Attribute Codes:
00 none — to restore default color
01 bold — for brighter colors
04 underscore — for underlined text
05 blink — for flashing text
07 reverse — to reverse background and foreground colors
08 concealed — to hide text
Text Color Codes: Background Color Codes
30 for black foreground 40 for black background
31 for red foreground 41 for red background
32 for green foreground 42 for green background
33 for orange foreground 43 for brown background
34 for blue foreground 44 for blue background
35 for purple foreground 45 for purple background
36 for cyan foreground 46 for cyan background
37 for gray foreground 47 for gray background
Extra Text Color Codes: Extra Background Color Codes
90 dark gray 100 dark gray background
91 light red 101 light red background
92 light green 102 light green background
93 yellow 103 yellow background
94 light blue 104 light blue background
95 light purple 105 light purple background
96 turquoise 106 turquoise background
97 white 107 white background

Switch Keyboard Layout on Linux Mint 12 LXDE

I normally use the US-Dvorak keyboard layout, but for some typing in foreign languages, I like to switch back to the basic US keyboard layout. On other Linux distros it’s I had use the keyboard setting graphic user interface to set up the two US keyboard layouts, and then assign a key combination to switch between the two (personally, I like to hold down both the left and right shift-keys for the switch.)

However, on Linux Mint 12 LXDE, I could not find a graphic interface that would allow me to load the two keyboard layouts and assign the switch key combo.

Here’s what I found out about setting my desire layouts and hot-key the manual way:

Per session setting, at the command terminal use the setxkbmap command:

setxkbmap -layout "us,us" -variant "dvorak,basic" -option "grp:shifts_toggle" 

For a more permanent configuration, edit the /etc/default/keyboard file and change the XKB-variables: