jueves, 19 de enero de 2017

SSH Master and slave connections

If you connect often to a server and you need to do simultaneously various tasks (e.g. get files by SFTP or using scp). It is possible to authenticate only one time and use the first session as a tunnel for all the subsequent connections.

Create the file ~/.ssh/config or edit the file by appending these two lines
ControlMaster auto
ControlPath ~/.ssh/control:%h:%p:%r

Now, after the first connection requiring authentication, all the following ones will use the first one as a tunnel and do not require authentication.

The master connection can not be closed until all the slave connections are closed.

Source http://unix.stackexchange.com/questions/2857/ssh-easily-copy-file-to-local-system

jueves, 12 de enero de 2017

Add custom resolution to xrandr

Sometimes xrandr does not show one of the resolutions that is accepted by both the graphic card and the connected screen. If that is the case, it is still possible to add manually the required resolutions by using the following steps:

First we need to calculate the VESA Coordinated Video Timing modes for the required resolution. For example, for a monitor 1680x1050 and 60Hz
cvt 1680 1050 60
This will output the following
# 1680x1050 59.95 Hz (CVT 1.76MA) hsync: 65.29 kHz; pclk: 146.25 MHz
Modeline "1680x1050_60.00"  146.25  1680 1784 1960 2240  1050 1053 1059 1089 -hsync +vsync
Now we add the specified CVT to xrandr. Using the previous example
sudo xrandr --newmode "1680x1050_60.00"  146.25  1680 1784 1960 2240  1050 1053 1059 1089 -hsync +vsync
This will create a Virtual screen in xrandr. Now it is possible to add this resolution to any of the screens listen in xrandr. For example to add this resolution to VGA1
sudo xrandr --addmode VGA1 1680x1050_60.00
Finally, to assign this resolution to the screen VGA1 we can run
xrandr --output VGA1 --mode 1680x1050_60.00
source : http://askubuntu.com/questions/377937/how-to-set-a-custom-resolution

jueves, 5 de enero de 2017

Add context menu to Thunar

This are the simple steps to add a context menu when clicking with the rigth button of the mouse in the selected file.
  1. Go to edit -> Configure custom actions...
  2. In the menu click on Add a new custom action.
  3. Give it a Name that will be shown in the context menu
  4. A Description
  5. Write the Command to run (e.g. convert %F %F.png) where %F means the selected files
  6. Go to the tab Appearance Conditions and choose the type of files that you want this context menu to appear (e.g. in the previous example we should choose Image Files)
  7. Click OK and Close


I uploaded a video with all these steps in YouTube:


See a more detailed explanation here: http://pclosmag.com/html/issues/201008/page10.html

jueves, 17 de marzo de 2016

SSD usage in Linux

This are some essential points to consider if you want to use an SSD hard drive in a Linux system.


1. Get enough RAM
2. Avoid using SWAP

If you want to use the option of hibernating, then set the swapines to zero. But try to avoid hibernation.

echo -e "vm.swappiness=0" | sudo tee -a /etc/sysctl.conf

3. Disable acces time logging

in your /etc/fstab file add the option "noatime" in every partition of your SSD drive. For example, change every “errors=remount-ro” to “noatime,errors=remount-ro”

4. Run fstrim every day

It will prevent your SSD from slowing down. You can use cron to run this program automatically in the background every day.

echo -e "#\x21/bin/sh\\nfstrim -v /" | sudo tee /etc/cron.daily/trim
sudo chmod +x /etc/cron.daily/trim

5. Monitor your SSD using S.M.A.R.T.

Check once in a while that the Media_Wearout_Indicator value of your SSD is not lower than 10 (it starts with a value of 100).

sudo smartctl -data -A /dev/sda

source: https://www.leaseweb.com/labs/2013/07/5-crucial-optimizations-for-ssd-usage-in-ubuntu-linux/

martes, 15 de marzo de 2016

DeepDream through all the layers of GoogleNet

Video depicting all the layers of a deep nerual network. The Convolutional Neural Network has been pretrained with ImageNet. The first input image is a picture of myself and at every step the image is zoomed with a ratio of 0.05. At every step the actual input image (frame) is forwarded to the actual hidden layer. The error is set to be the same representation in order to maximize all its activations. Then, a backward pass is computed to modify the input image. After 100 iterations of zooming in one layer, the next layer is used. See more in my Aalto personal web-page 

miércoles, 1 de abril de 2015

Glossary and acronyms with LaTeX



My template to create glossaries in LaTeX with a description and an associated acronym.  I substitute every term "EEE" by the new glossary term and the term "Expanded" by the expanded version (e.g. EEE -> NYC, Expanded -> New York City).

%%% define the acronym and use the %see= option
\newglossaryentry{EEE}{
  type=\acronymtype,
  name={EEE\glsadd{EEEg}},
  description={Expanded},
  descriptionplural={\glsentrydesc{EEE}s},
  first={\glsentrydesc{EEE} (EEE)\glsadd{EEEg}},
  firstplural={\glsentrydescplural{EEE} (\glsentryplural{EEE})\glsadd{EEEg}},
  %see=[Glossary:]{EEEg}
}

\newglossaryentry{EEEg}{
  name={EEE},
  description={TODO: description}
}
Be careful with the plural of the terms, as in this template it only adds an 's' at the end of the description and acronym, in special cases just modify the fields accordingly.

I store all the glossary terms in a file named glossary.tex in a separated folder 00_frontmatter
You need to load the package glossaries at the beginning of the file. I added some options for the table of contents and something else.
\usepackage[toc,seeautonumberlist,acronym]{glossaries}
 
Then, I add this lines in the preamble of the file (before the \begin{document})
%% GLOSSARY
\makeglossaries
\loadglsentries[main]{00_frontmatter/glossary}

Inside the document where I want to print the acronyms:
\printglossary[type=\acronymtype]

 Finally, at the end of the document I print the glossary with:
\printglossary[type=main]

jueves, 26 de marzo de 2015

LaTeX apalike citation style

If you tried the apalike citation format you realized that LaTeX is not able to break the citations into two lines. In this case, LaTex just extends the citation from the margins (expecting that you print in the margins of your publication).

(Image from the original source linked below)

This problem can be solved with the package Natbib created by Patrick Daly. Natbib has additional options but in my case -- in order to simplify thing -- I just loaded the package with the option of square brackets []:

\usepackage[square]{natbib}

And changed all the \cite commands by \citep (see other formats in the wikibooks). Instead of changing the hundreds of citations that I wrote in my thesis, I opted to rename the cite command to citep:

\renewcommand{\cite}{\citep}

The bibliography style should remain unchanged:

\bibliographystyle{apalike}

source: http://tex.stackexchange.com/questions/437/line-breaking-or-hyphenation-of-references-in-apalike/447#447