27 May 2015

Setup WinEdt to Use Cygwin/TeX Live

1. Scenario

I have installed Cygwin, and included TeX Live so that I can compile LaTeX files in Cygwin.
Then I install WinEdt 9, and to save hard disk space, I would like to configure WinEdt such that it can (re-)use Cygwin/Tex Live.

2. Configuration

2.1. Edit System Environment Vaiables to include Path to Cygwin Executables

Skip this step if you have included the path to Cygwin executables.
  1. In Windows 8.1, press [Windows Key] + [Q], type "variables", and select "Edit the system environment variables" from the list. (For other Windows versions, try to find "System Properties", then select "Environment Variables...".)
  2. Under System variables, select "Path" variable, click "Edit...". Append ";C:\cygwin\bin" to the value.
  3. Click 'Ok' three times to complete.

2.2. Configure WinEdt 9

  1. Select Options > Configurations > TeX Live. This tells WinEdt 9 to make use of TeX Live.
  2. Go to Options > Execution Modes.
  3. Select TeX System tab.
  4. Modify the following fields
    • TeX Root: C:\cygwin
    • TeX Bin: C:\cygwin\bin
    • TeX Help: C:\cygwin\usr\share\texmf-dist\doc
  5. Select TeX Options tab.
  6. Modify the following fields
    • Default PDFTeXify Engine: pdftex.exe -fmt=latex -output-format=pdf

3. Bonus

Can use Sumatra PDF, which synchronizes well with WinEdt and TeX Live.

18 January 2013

BASH: Single-Quotes inside a Single-Quoted String

In bash, to escape some characters for the command-line arguments properly, you can use single quotes. E.g.,
$ file 'Some # Weird File Name.odt'
But how about the single quote characters? There are several methods. I found the following ways most convenient.

(1) Replace ' with '\''

Break out of the quoted string, and escape the single quote alone.
 $ file 'My wife'\''s file.txt'
(2) Replace ' with '"'"'

Same idea, but different way of escaping the single quote.
$ file 'My wife'"'"'s file.txt'
So, in Python, you can use:
s = string.replace("'", "'\"'\"'")
or in PHP,
s = str_replace("'", "'\"'\"'", string);

17 January 2013

MPlayer & MEncoder: Manipulating Audio Channels

MPlayer provides powerful controls to manipulate different audio channels.

During playback,

  • ( and ) keys: Adjust audio balance in favor of left/right channel.
  • # key: Cycle through the available audio tracks.
You can add, remove, route, or copy audio channels with the -af channels=nch[:nr:from1:to1:from2:to2:from3:to3:...] option. For example, if there are 2 channels, and you want to copy channel 0 to channel 1 (and thus abandon the original channel 1), you can use -af channels=2:2:0:0:0:1.

You can even mix the channels with specified proportions with the -af pan=... option. Unfortunately, the suboptions are naturally much more complicated. Basically you can specify a 2D matrix to indicate the amount of each source channel that will be mixed to the destination channel.

References: