How to know the size of ram memory

To know the size of ram memory, you must run the following command:

grep MemTotal /proc/meminfo

You can get more information with the following command:

cat /proc/meminfo
Posted in linux | Leave a comment

How to know the size of a Postgres database

If you want to know the size of a Postgres database on disk, we must run the following sql command:

SELECT pg_database.datname,  
       pg_size_pretty(pg_database_size(pg_database.datname)) AS size  
  FROM pg_database;
Posted in linux | Leave a comment

Export Postgres table to csv file with headers

To export a Postgres table to a csv file with headers you must log into the shell of Postgres and execute something like this:

\COPY my_table to 'filename.csv' csv header 

Where my_table is the table I want to export and filename.csv is the exported file.

Posted in R | Leave a comment

How to install SQLite on Ubuntu

To install SQLite on Ubuntu, you must run the following command in a terminal:

sudo apt-get install sqlite3 libsqlite3-dev
Posted in linux | Leave a comment

How to execute R file in batch mode

To execute an R file in batch mode, you must open a terminal and run the following code:

R CMD BATCH infile & 

Where infile is a text file with R code.

Posted in linux, R | Leave a comment

How to show the toolbox in gimp

When I use gimp in some occasions the main toolbox (the one with painting tools) has disappeared. There are two solutions:

1) Go to the menu Windows -> Recently Closed Docks

2) Go to Edit -> Preferences in the Window Management section, and press the Reset Saved Window Positions to Default Values button as it is shown in the below image.


Posted in linux | Leave a comment

How to create a shutdown user

To create a shutdown user, first of all we create the user with the following command:

adduser shutdown

When the command is run, the password must be provided along with other information. After that the following lines must be added to the file /etc/sudoers

## user shutdown is allowed to execute shutdown command
shutdown ALL=NOPASSWD: /sbin/shutdown
Posted in linux | Leave a comment

Allowing .htaccess files in Apache 2

If you need to allow .htaccess files in the virtual hosts of Apache 2, you must change the following code in the file /etc/apache2/apache2.conf.

<Directory /var/www/>
        Options Indexes FollowSymLinks
        AllowOverride None        
        Require all granted

The directive “AllowOverride None” must be changed by “AllowOverride All”.

Posted in linux | Leave a comment

How to generate Latex tables code from an R object

The R package xtable can generate LaTeX code from R objects like matrices, data frames and so on. The following code produces the corresponding latex table code for a matrix with 2 rows and 10 columns.

set.seed(1234) # for reproducibility purpose
xtable(matrix(rnorm(20), ncol=10))

In the below web page you can see many examples using the library xtable.


Posted in R | Leave a comment

How to fix the error “W: Failed to fetch…”

Recently when I run the command

sudo apt-get update 

I got the following error:

“Failed to fetch Unable to find expected entry ‘main/binary-i386/Packages’ in Release file (Wrong sources.list entry or malformed file) Some index files failed to download. They have been ignored, or old ones used instead.”

The reason of this error is because 32-Bit Chrome builds has been discontinued. To fix this problem we must edit the file:

sudo vi /etc/apt/sources.list.d/google-chrome.list

And modify the file as follows

deb [arch=amd64] stable main

Posted in linux | 2 Comments