Feeds:
Posts
Comments

Posts Tagged ‘Programming’


On a previous post I described how to change the LaTeX options of the Cadabra notebook.

I collaborate with a colleague, who uses the standard cadabra installation. Therefore, If I write a Cadabra notebook, he needs to pullback the personalised notebook to the standard one. The pullback script can be downloaded here!!!

Author: Oscar Castillo-Felisola

Created: 2014-02-18 Tue 20:20

Emacs 24.3.1 (Org mode 8.2.5h)

Validate

Advertisements

Read Full Post »


Just by playing around with CADABRA, I found out the existence of a super-useful LaTeX package, called breqn, which allows to break long equations at the edge of the page… like the wraping feature of most text editors.

However, when one manipulates really long expressions, I’d like to break these long equations through the page. I’m still looking for this feature… in that case I can improve even more the behaviour of cadabra‘s notebook, when compiling it to LaTeX.

Any suggestions???

Cheers!

Read Full Post »


Goal: a cadabra notebook more LaTeX friendly.

  1. I run a Debian system. Don’t know why, but the original source code in the git repo didn’t work!!!What did I do? I downloaded the code from the Debian repository.
    $ sudo apt-get build-dep cadabra # Install all dependences
    $ mkdir -p ~/Software # Create a folder to download the source
    $ cd ~/Software # Move to the folder
    $ apt-get source cadabra # Download the source code (from Debian)
  2. On the cadabra folder created through the last command line, I looked for the window.cc file and open it
    $ emacs cadabra-1.29/gui/window.cc &
  3. On the window.cc file I changed:
    • The LaTeX package color by the improved xcolor, by changing the string
      << "\\usepackage[usenames]{color}\n"

      by

      << "\\usepackage{xcolor}\n"
    • I added the LaTeX package listings, which improves the verbatim properties (among other things). Right after the mentioned xcolor line, I added the following
      << "\\usepackage{listings}\n"
      << "\\lstset{\n"
      << "  basicstyle=\\small\\color{blue}\\ttfamily,\n"
      << "  breaklines=true,\n"
      << "  columns=fullflexible,\n"
      << "  commentstyle=\\color{gray!60},\n"
      << "  morecomment=[l]{\\%\\%},\n}"

      This allows the Cadabra code to break at the end of the line instead of going out of the page, when compiled to LaTeX (similar to what breqn does on equations).

    • Now, I changed on the DataCell::c_input: case,1 the strings {\\color[named]{Blue}\\begin{verbatim}\n by \\begin{lstlisting}\n, and \n\\end{verbatim}}\n by \n\\end{lstlisting}\n.Far below, the lines with the code if(ln=="{\\color[named]{Blue}\\begin{verbatim}") { should be changed to if(ln=="\\begin{lstlisting}") {, as well as else if(ln=="\\end{verbatim}}") { should be changed to else if(ln=="\\end{lstlisting}") {.
    • Save all the changes
  4. Finally, time to compile
    $ ./configure
    $ make
    $ sudo make install
  5. If your compilation/installation went through, and you try to open an old cadabra notebook (a notebook created with the original cadabra code), the program will complain that the file is not compatible… but I created a small script to transform the old files into new files! Download it here!!USAGE:
    $ ./transf_cadabra oldfile.cnb newfile.cnb

Footnotes:

1This is located a few lines below the lines where the LaTeX preamble is defined

Author: Oscar Castillo-Felisola

Created: 2014-02-18 Tue 10:09

Emacs 24.3.1 (Org mode 8.2.5h)

Validate

Read Full Post »


Yesterday I started to edit an old \LaTeX  file, and it happened that in my set of definitions I changed a bold math-operator with no arguments \df, by a math-operator with one argument (which happens to by the following word) \de{#1}.

The problem

The issue now is that I should go all over the text finding the \df command and replaced by \de{#1}. But note that the is a delimiter with the curly bracket!

The solution

A while ago I found a page called , and I learn about emacs’ macro, i.e., a set of rules you define and then can be applied recursively.

How is it done?

A short explanation is given at .

In my case I follow that rules below:

  • Press F3 to start recording the macro.
  • Look for the initial command and change it by the other using M-% \df (press enter) \de{ (press enter)
  • Move the cursor forward until the end of the next word using the command M-f
  • In that cursor place close the curly bracket }
  • Finish the recording of the macro by pressing F4.

Finally, to apply the macro use F4 to apply it once, M-4 F4 to apply it 4 times or M-0 F4 to apply it until it fails.

Read Full Post »


The lsusb command lists the USB devices of the computer.

Example:

$ lsusb 
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 002 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 001 Device 003: ID 2232:1029  
Bus 002 Device 003: ID 8087:07da Intel Corp. 
Bus 003 Device 002: ID 0458:003a KYE Systems Corp. (Mouse Systems) NetScroll+ Mini Traveler / Genius NetScroll 120

As most commands in Linux, it has some flags, which I’ll explain below. But first, let’s explain a little bit those numbers.

  • Bus: In computer architecture, a bus is a subsystem that transfers data between components inside a computer, or between computers
  • Device: is the specific device number
  • Vendor: The vendor ID is the first (octal) number after the ID label
  • Product: The product ID is the second (octal) number after the ID label, placed after the colon :
  • Description: If available, the final part is a brief description of the product

Options (or flags)

 $ lsusb -v

It is the verbose mode. The detailed information of the devices is shown.

 $ lsusb -t

The devices information is shown as a tree.

 $ lsusb -s 001:

Show the device(s) whose Bus number is 001. In the above output, there are 3 of these.

 $ lsusb -s 001

Show the device(s) whose device number is 001. In the above output, there are 4 of these.

 $ lsusb -s 001:002

Show the device whose Bus and Device number are 001 and 002 respectively.

In the three previous examples the flag s can be changes by d, if one’d like to specify the Vendor and Product ID respectively.

Cheers.

DOX

Read Full Post »


WARNING: The following is a PERSONAL brief of part of the second chapter of the book How Linux Works: what every superuser should know by Brian Ward

Linix device files are in the /dev directory. A device can be identified using the ls -l command.

An extract of the output from the command line ls -l /dev is shown below,

crw-rw----+ 1 root cdrom    21,   1 Sep  6 01:23 sg1
lrwxrwxrwx  1 root root           8 Sep  6 01:23 shm -> /run/shm
crw-------  1 root root     10, 231 Sep  6 01:23 snapshot
drwxr-xr-x  3 root root         220 Sep  6 01:23 snd
brw-rw----+ 1 root cdrom    11,   0 Sep  6 01:23 sr0
srw-rw-rw-  1 root root           0 Sep  6 01:23 log
prw-r--r--  1 root root           0 Sep  6 01:23 gpmdata

The first column is a code which indicates the type of ‘file’ (the first character) and permissions (the other nine characters).

If the first character is b, c, p, or s, then the file is a device. These letters stand for block, character, pipe, and socket, respectively:

  • block: Programs access data in a block device in.
  • character: Character devices work with data streams.
  • pipe: are like character devices, but there is another process at the other end of the I/O stream instead of a kernel driver.
  • socket: are special-purpose I/O files offering a type of network interface.

The numbers before the dates in the first two lines of the previous listing are the major and minor device numbers that help the kernel identify the device.

DOX

Read Full Post »


The wc command is a word counter, but counts bytes, letter or lines as well.

Usage

 $ wc [OPTION] ... [FILE] ...

Examples

 $ wc -l file

Counts the number of lines in file.

 $ wc -w file

Counts the number of words in file.

 $ wc -m file

Counts the number of characters in file.

 $ wc -c file

Counts the number of bytes in file.

 $ wc -L file

Prints the lenght of the longest line in file.

DOX

Read Full Post »

Older Posts »