Monday 30 October 2023

File upload / embed example

 Here's how we share a file on a blog.

Here's a file . Here' the link again 

 
  Linking a PDF document from Google Drive 

Select the PDF file you want to embed. 

Right click -> Preview -> More actions -> Open in a new window. 

Now click More actions -> Embed item. 

Copy the embed code and paste it on your blog post. Make sure the file is publicly available.

Code Sample

<iframe allow="autoplay" height="480" src="https://drive.google.com/file/d/10M0Ptz6Jw-ZIcRGvFhaqQ8MtKItyb2jP/preview" width="100%"> 

</iframe>

Automatic Backups in Linux

In an earlier post, a script for synchronizing data across different machines with the help of either a USB drive or a network was discussed. Here a different approach is presented (thanks to Resmi and Philip).

If one wants to backup only those files that were created/modified in the last 24 hrs, the following script can be used


#!/bin/bash
BACKUP_DIR=`date +%d‑%b‑%G`
mkdir ~/Desktop/$BACKUP_DIR
for file in `find $HOME -mtime 0 \! -wholename "*/.*"`
do 
cp -i $file ~/Desktop/$BACKUP_DIR
done

This will copy the files that were modified in the last 24 hrs from the user's home folder and sub-folders, except the hidden ones, to a folder on the Desktop named by current date, say 29-Feb-2012.

Tuesday 21 February 2012

Daily Backup Script for Linux Users

Those who know how rsync works, need not read the rest of this post!!


Those who are working in two different computers on a daily basis would find this script very useful for synchronizing the data across them. This can essentially be used as a simple backup solution instead of Dropbox or Ubuntu One if your machines are running Linux.


In all the following scenarios it is  assumed that

  • The files in the folder ~/Work or /home/username/Work is being synchronized to a USB drive or a remote location and vice versa.
  • The folder ~/bin exist in both the machines. If the folder ~/bin does not exist use the command mkdir ~/bin to create it. 
  • The path ~/bin is in the PATH environment variable. To check the path issue echo $PATH in the terminal. If it is not, adding the following in the either .profile or .bashrc would set it, next time you login.
          # set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
    PATH="$HOME/bin:$PATH"
fi
  • The script files are to be located in ~/bin.
Scenario 1: Synchronizing files to/from a USB drive 
The USB drive when connected usually gets mounted as /media/disk (or for example /media/TRANSCEND if the name/label of the drive is TRANSCEND). In the following the USB stick/Hard disk is labelled as F45TY and has a folder by name myscripts in it.


Create a file, say sync2pen in ~/bin with the following contents


#!/bin/sh
rsync -avz ~/Work /media/F45TY/
rsync -avz ~/Official/*.pdf /media/F45TY/Docs/
rsync -avz ~/bin/sync2* /media/F45TY/myscripts/


and set correct permissions by issuing chmod a+x sync2pen

The dissection of the script
The Shebang
#!/bin/sh
invokes the Bourne shell or a compatible shell. This is the standard starting line of a shell script.
rsync -avz ~/Work /media/F45TY/
Synchronizes all files in the folder/directory ~/Work to the folder Work in the USB drive.
rsync -avz ~/Official/*.pdf /media/F45TY/Docs/
Synchronizes all PDF files in the folder ~/Official to the folder Docs in the USB drive.
rsync -avz ~/bin/sync2* /media/F45TY/myscripts
Synchronizes all files starting with sync2 in the folder ~/bin to the folder myscripts in the USB drive. This line ensures that you have with you the latest script in all the machines/USB drives.

Now to sync the folders issue the command sync2pen in the terminal. It will list all files that were synced/copied to the destination.

To do the reverse, i. e., to sync files in the USB drive to the hard disk, (say, on the second machine) change the source and destination in the rsync commands

Create a file, say sync2disk in ~/bin with the following contents

#!/bin/sh
rsync -avz /media/F45TY/Work ~/
rsync -avz /media/F45TY/Docs/*.pdf ~/Official/
rsync -avz /media/F45TY/myscripts/sync2* ~/bin/

set correct permissions by issuing chmod a+x sync2disk and issue the command sync2disk in the terminal.


Alternately if you do not wish to create these sync scripts in ~/bin, you can keep it in any location and source the script when needed.

Note: If the USB drive is in FAT32/NTFS format (usually it is!) you might notice that every time the script is run, all the files are copied to destination irrespective of changes being made on them. This is due to the incompatibility of permissions in ext3/ext4 file-systems with FAT/NTFS file-systems. So it is better to use a USB drive with a Linux partition and syncing to it. GParted will help you to create/modify Linux partitions.

Scenario 2: Synchronizing files to/from a remote machine 
If you want to sync data between two machines connected by a network, the following will help you. In this example, the files in the local machine is synchronized with a remote machine with IP address 10.56.2.34 and the user vivek has access to it.

Create a file, say sync2remote in ~/bin with the following contents


#!/bin/sh
rsync -avz ~/Work vivek@10.56.2.34:/home/vivek/
rsync -avz ~/Official/*.pdf vivek@10.56.2.34:/home/vivek/Docs/
rsync -avz ~/bin/sync2* vivek@10.56.2.34:/home/vivek/myscripts/



and set correct permissions by issuing chmod a+x sync2remote

Now to sync the folders issue the command sync2remote in the terminal. On invocation it will ask for user's password in the remote machine 10.56.2.34.

To  synchronize files from the remote location, create a file, say sync4remote in ~/bin with the following contents

#!/bin/sh
rsync -avz vivek@10.56.2.34:/home/vivek/Work ~/
rsync -avz vivek@10.56.2.34:/home/vivek/Docs/*.pdf ~/Official/
rsync -avz vivek@10.56.2.34:/home/vivek/myscripts/sync2* ~/bin/

set correct permissions by issuing chmod a+x sync4remote and issue the command sync4remote in the terminal.

Note: If hostname of remote machine is known, one can use hostname instead of IP addresses in the scripts sync2remote and sync4remote. Also username vivek can be avoided if both machines have same username in them.

Corrections/suggestions are welcome.

Thursday 10 November 2011

QDP is for everyone.

My sisters in work, Marykutty James and Jincy Devasia, who are X-ray astronomers, have been using QDP tool in the HEASOFT package for generating plots in their publications (Click their names to see their publications). As I was in need of plotting a number of data files, having very similar data, reached one of them to learn QDP.

QDP comes bundled with FTOOLS package from The High Energy Astrophysics Science Archive Research Center (HEASARC). As didn't have an installation of FTOOLS or HEASOFT, thought I would need to generate the plots on the workstation in our lab. But, thank God, it can be installed even if one do not have HEASOFT installed.

QDP (the Quick and Dandy Plotter) is basically a program that reads ASCII files and then calls PLT, an interactive plotting program that is designed to be used by scientists analyzing data. You can get it from http://wwwastro.msfc.nasa.gov/qdp/. Installation instructions and quick help on PLT/QDP are also included in the webpage. Note that, this is not a GUI based plotting program and works probably in linux only.

Sunday 6 November 2011

Latest R and RKWard


Yesterday I got the latest version of R (version 2.14.0 (Great Pumpkin, 2011-10-31)). Later in the day when I opened my favourite R GUI RKWard, it said that it cannot start the R backend.



On reaching the RKWard's sourceforge page, it is seen that my version of RKWard (ver 0.5.4) cannot support R-2.14.0 and I have to add an Inofficial Ubuntu repository to my system's software sources.

As I have been using the CRAN version of R on Ubuntu 10.04 LTS (Lucid Lynx), added the following two lines to the system's software sources.
deb http://ppa.launchpad.net/rkward-devel/rkward-stable-cran/ubuntu lucid main
deb-src http://ppa.launchpad.net/rkward-devel/rkward-stable-cran/ubuntu lucid main
If you have R from default Ubuntu servers, you may need to add the following line to your system's software sources for the latest RKWard.
deb http://ppa.launchpad.net/rkward-devel/rkward-stable/ubuntu lucid main
deb-src http://ppa.launchpad.net/rkward-devel/rkward-stable/ubuntu lucid main
Then I updated the Ubuntu package list and upgraded the rkward package. Now my RKWard is at version 0.5.7 and working perfectly.

More details of latest RKWard binaries can be found here.
If you like the sources, check this page instead.

UPDATE: To rJava/JGR users
You would need to reinstall  JavaGD, iplots, JGR, proto, Deducer packages
Inside R, do the following
install.packages("JavaGD")
install.packages("iplots")
install.packages("JGR")
install.packages("proto")
install.packages("Deducer")
In between if you encounter the following error

configure: error: Cannot compile a simple JNI program. See config.log for details.
you need to reconfigure the Java installation. In the linux terminal issue the following
sudo R CMD javareconf

Sunday 5 June 2011

Google Scribe : Helps you to produce better documents

Google Scribe is an online tool that helps you write better documents. Using information from what you have already typed in a document, Google Scribe's text completion service provides related word or phrase completion suggestions.
It also checks your documents  for incorrect phrases, punctuations, and other errors like misspellings. In addition to saving keystrokes, Google Scribe's suggestions indicate correct or popular phrases to use.

For using Google Scribe visit http://scribe.googlelabs.com/. Detailed help is available at http://scribe.googlelabs.com/static/help.html

The Google Scribe Bookmarklet enables use of Google Scribe anywhere, on any web page. Drag this Google Scribe Bookmarklet to Bookmarks toolbar (or Favorites toolbar depending on your browser). To use Google Scribe on a web page, click on the Google Scribe Bookmarklet. Google Scribe will then enable itself on the active text field on the webpage. Enabled text fields display the icon at top end corner of the active field.

Google Chrome users can use the Google Scribe as an extension to access Google Scribe on any web page. Using the Google Scribe extension is more convenient than using the Google Scribe Bookmarklet - you won't have to click on the Bookmarklet to load Google Scribe.

Google Scribe is supported on PC, Linux, or Macintosh (Mac) and Google Chrome, Firefox 3.5+, Internet Explorer 8+, Safari 5+ browsers.

Mendeley : Bibliography Management Tool

Mendeley is a bibliography management tool and  academic social network that can help you organize your research, collaborate with others online, and discover the latest research. If you have a collection (small or large) of PDF documents, Mendeley can be of great help to you. Especially if you have collection of journal articles and you are planning to write an article or thesis.

Mendeley is available free, as a web service as well as a desktop application -- Mendeley Desktop (Windows/Linux/Mac). It depends on Internet connectivity for account management and retrieval of bibliographic information of the PDFs in your collection.

You can add PDFs to Mendeley Desktop by clicking the Add Document button on the far left of the application toolbar. Alternatively, you can drag and drop PDFs into the content pane. Mendeley will then attempt to detect the document details (bibliographic data or meta data).

Any documents whose details Mendeley is uncertain about will be added to the Needs Review collection for manual verification. You may use Mendeley’s Document details lookup (CrossRef, PubMed, and ArXiv) or Google Scholar Search to complete missing document details.

To lookup document details from CrossRef (DOI), PubMed (PMID), and ArXiv. Just fill in the available document ID in the respective field and click the magnifying glass icon next to it to get the details of the document. These fields are located in the Details tab.

One can import references with a single click from a good number of services/websites including arXiv, NASA ADS, ScienceDirect, Google Scholar, ISI Web of Knowledge, JSTOR, Nature, PubMed, Scirus, SpringerLink, Wiley InterScience, etc.

You can access the details of your collection through the web interface from anywhere in the world and share/collaborate with friends in similar fields of research. It also allows you to store your PDFs online.

You can search for the contents of PDFs in your collection and can annotate/ comment on a part of the document. You can also share your files with your friends.

Once you have made your collection, you can use Mendely to properly insert citations in your journal article or thesis. It includes a number of Bibliographic styles used by nearly all major publishers across the globe. Mendeley plug-in easily integrates with MS Word / OpenOffice inserting citations and generating a bibliography. It also provides means to generate a BibTeX file that can be used in documents typeset in TeX/LaTeX.

More details of usage and feature of Mendeley is available at http://www.mendeley.com. Most of the contents of this post are taken from the Getting Started Guide / FAQ given in the website.