Generate random password on Linux terminal

Jan 21, 2017
This just a log for me (& may be others) to remind me how to generate random passwords on Linux terminal. pwgen is a useful command which can generate both pronounceable and secure passwords. There a few other creative ways to generate random text/password on linux terminal, but pwgen is specially designed for the task and is the most handy. The usage is quite simple:
pwgen [ OPTIONS ] [ pw_length ] [ num_pw ] By default, pwgen generates pronounceable passwords. For secure password use -s option. The pwgen man page describes more options. Here are some example outputs:

Generate 6 random (pronounceable) passwords of length 20. $ pwgen 20 6 fei7hohS9co6ahkua2ei chaiFoo2eaLedei9Oosi Ainuu5eehie5ae1eecae co6quahbaiPahSh1good fah6Daer7geepae0teef queeLahl9us7sushawie
Generate 6 random (secure) passwords of length 20. $ pwgen -s 20 6 PTbQ8Nc8gIJ5sHrKM0gS pMI8R8KK0MrnCd4UCEhe 25KcqpYiQTOFYf7PHwoN ztClxu7CQiOOVPgNJFHa yKnc1obXyXLvmPmLAVWA L1fMNHRRHiC2MNWS6j2Z
Generate 6 random passwords of length 20 with special characters. $ pwgen -y 20 6 EN5eb2eyuz2ohNgir}ei yah>l9ainohWah8afaiJ Jue-dah3quoo8wee9foh ul)eoWie3Ees;aeh(ees pheehie+Zanahw~eiP5g dath5oozaht0fei&F4Xi
Generate 6 random (secure) passwords of length 20 with special characters. $ pwgen -s -y 20 6 JSt]pL1UV)`u>Rz%;]Ei yx-sWF#pm_ci?(w|D0pd [#W%%E%oP7vQ~U%?#L<9 :~Y:Z?LH''aHH&A$zJ4w zZ5vZH+ABm!k;S_b^#cb c"zpT6l1HI_"ENSuNAkw
Lastly, here is the pwgen help text: $ pwgen --help Usage: pwgen [ OPTIONS ] [ pw_length ] [ num_pw ] Options supported by pwgen: -c or --capitalize Include at least one capital letter in the password -A or --no-capitalize Don't include capital letters in the password -n or --numerals Include at least one number in the password -0 or --no-numerals Don't include numbers in the password -y or --symbols Include at least one special symbol in the password -s or --secure Generate completely random passwords -B or --ambiguous Don't include ambiguous characters in the password -h or --help Print a help message -H or --sha1=path/to/file[#seed] Use sha1 hash of given file as a (not so) random generator -C Print the generated passwords in columns -1 Don't print the generated passwords in columns -v or --no-vowels Do not use any vowels so as to avoid accidental nasty words
Read more ...

TeamViewer initctl start fail on Linux

Sep 11, 2015
Tested on: Linux Mint 17.1 Rebecca (Ubuntu 14.04.1 LTS) with TeamViewer 10.0.46203

TeamViewer is great! But it keeps a daemon running in background, which may not be very desirable for occasional users. The daemon can be disabled by running: $ teamviewer daemon disable tee: /opt/teamviewer/logfiles/install_teamviewerd.log: Permission denied Fri Sep 11 14:12:42 PDT 2015 Action: Removing ... initctl stop teamviewerd initctl: Unknown instance: fail rm: cannot remove ‘/etc/init/teamviewerd.conf’: Permission denied initctl: Rejected send message, 1 matched rules; type="method_call", sender=":1.113" (uid=1000 pid=22111 comm="initctl reload-configuration ") interface="com.ubuntu.Upstart0_6" member="ReloadConfiguration" error name="(unset)" requested_reply="0" destination="com.ubuntu.Upstart" (uid=0 pid=1 comm="/sbin/init") OK, using sudo seems to do the trick: $ sudo teamviewer daemon disable Fri Sep 11 14:14:55 PDT 2015 Action: Removing ... initctl stop teamviewerd initctl: Unknown instance: fail wine: /home/username/.config/teamviewer10 is not owned by you
After disabling daemon, TeamViewer shows following error message when started, which is expected. However, the daemon fails to start when the command is executed:

$ sudo teamviewer daemon start initctl start teamviewerd initctl: Unknown job: teamviewerd fail $ sudo teamviewer --daemon start initctl start teamviewerd initctl: Unknown job: teamviewerd fail initctl is not aware of teamviewerd, probably because /etc/init/teamviewerd.conf was deleted during the daemon disable command (see above). Reinstalling teamviewer makes it work, but that's not the best solution.

After looking into some more details, following command can be used to start the daemon (open TeamViewer as usual after this and Ctrl-C to kill the daemon): $ sudo /opt/teamviewer/tv_bin/teamviewerd -f
For reference, initial content of /etc/init/teamviewerd.conf can be found in /opt/teamviewer/tv_bin/script/teamviewerd.DEB.conf, which can also be modified and copied to correct location. Also see this Github discussion and this blog post for more details.
Read more ...

tikz.sty not found

May 12, 2015
Tested on: Linux Mint 17.1 Rebecca (Ubuntu 14.04 LTS - Trusty Tahr)

This error with pdflatex has been mystery to me for a long time. Surprisingly, it is not easy to find a clear solution online.
ERROR: LaTeX Error: File `tikz.sty' not found. --- TeX said --- Type X to quit or <RETURN> to proceed, or enter new name. (Default extension: sty)

Solution

sudo apt-get install texlive-pictures pgf
Installation of the package pgf is the most important bit! Without pgf LaTeX will keep complaining that tikz.sty is missing. This solution was also proposed in a comment on stackexchange:

... The pgf package, as I keep forgetting and remembering every year, is independently installed from the pictures (which includes tikz but it's not loaded unless pgf is present) extras, the common, and the main tex on 'ix systems.


Read more ...

Connecting to USC Secure Wireless on Linux

Dec 23, 2014
Tested on: Ubuntu 14.04, Linux Mint 17, Linux Mint 17.1

USC (Univ. of Southern California) updated its wireless service to have an encrypted and faster connection available to USC faculty, staff, and students with name 'USC Secure Wireless'. Unfortunately for students like me, USC did not document how to use Linux computers with this service.

Following configuration has worked for me to connect to USC Secure Wireless during past couple of months. The basic idea is to use 'WAP2' or 'WAP Enterprise' security and use Protected EAP (PEAP) authentication along with GTC as secondary authentication. Same idea works on Android phones as well.

Create a new connection by right-clicking on 'Network connection' icon in notification area and choosing 'Edit Connections...' It will pop a 'Network connection' window. Click on the 'Add' button on the right side and choose 'Wi-Fi' as connection type. Then follow the settings described in the images below (click on the images to enlarge them). Note that the USC-id must be entered without @usc.edu.



And here is how the connection information looks like after being connected to USC Secure wireless.



Read more ...

A simple approach to reference and PDF management

Sep 5, 2014

Managing references and citations is essential for academic publishing and reproducible research. However, managing large volume of references and citations over years is no easy task! A number of softwares have been developed specially for the task and been discussed many times. In this post I will briefly describe my own approach, which I have been using over 4-5 years now, to manage references, notes and corresponding files including PDFs. In particular, my approach aims to be:

  • Scalable - Manage hundreds of references and related files; It should be easy to add new reference/notes and should require no/little maintenance.
  • Easy formatting - References should be accurate and should be able to handle different character encoding, accents and should adapt to any reference-style based on the publisher specification.
  • Portable - Easy synchronization of whole setup (files, notes etc.) to a new computer/laptop/device.
  • Searchable - Search through titles, authors, previous notes etc.
  • Cross Platform - Same method should work across different operating systems (Linux, Windows, Mac) with no/minimal changes.
  • Work offline - Because Internet access is never as reliable as one wants it to be (also see 'Portable' above).
  • Free and Open - "Free as in beer" and, preferably, as "free speech" as well (no proprietary format). Being "open" also make it possible to port the data to some-other format/method, if required.

Note that the described method relies on BibTeX, mainly because it can achieve all the above goals and because BibTeX (& LaTeX) is de facto standard for writing in my discipline (Engineering). Use of BibTeX also makes bibliography dead simple in LaTeX - absolutely no export/import required! If BibTeX is not acceptable, skip to last section below for some alternatives.

Approach

The approach itself is fairly simple and is motivate by The Unix philosophy of small tools. The approach has three components:

  1. A directory on our computer/device, say with name "papers", which will contain all the files related to the references. Basically, this directory is the self-contained repository of all our information.
  2. JabRef for managing the BibTeX (.bib) file which manages all information, and
  3. A file synchronization tool, like Dropbox or Unison, to synchronize the papers directory to other devices, if required.

So, basically we save our files (PDFs etc.) in a directory, open/read/edit the files using our favorite software, add/edit the reference information via JabRef, and sync to other devices using our favorite sync-software. (In theory one could also use any other BibTeX manager, but JabRef is absolutely the best BibTeX manager I know.) For ease of file management, we can create 2-3 sub-directories to organize files, but it is completely optional as JabRef allows more advanced categorization. The image on right shows a sample directory structure. reference.bib is the BibTeX file which contains all the information related to references and lies at the heart of this approach. The sub-directories contain PDF and other files related to references. In my approach, I use one single .bib file for managing all reference, which in my experience works in a much better unified-way than multiple .bib files.

Next, I will outline some bare-minimum steps to get started with this approach. However, feel free to explore JabRef options and make your own customizations.

Setup

  1. Create a papers directory with 1-2 relevant sub-directories. Optionally, throw in few PDF files of your references in sub-directories. Avoid spaces in file and directory names; use underscore instead.
  2. Download and install latest version of JabRef for your platform.
  3. Open JabRef and create new database (File->New database). Save database as a reference.bib in papers directory.
  4. In JabRef, go to the menu Options->Preferences and set following:
    • In Files tab, check "Open last edited databases at startup" and "Backup old file when saving".
    • In External programs tab, check "Allow file links relative to each bib file's location" and "Use the bib file location as primary file directory"
  5. Optionally, setup your synchronization/backup for the papers directory.

Adding references

This step is the most important step, as we want our reference to be accurate. Let us assume that we have read this paper from Einstein and have saved a copy of the PDF file in appropriate sub-directory. Next, we would want to add it to our refernce list and add some notes from our reading. The idea here is that we will be very careful with all the details while adding the references the first time and then we can use it confidently life-long (almost) without any changes. If you are entirely new with JabRef then go through this short tutorial to familiarize yourself.

  • Open reference.bib using JabRef. Go to BibTeX->New entry and then select Article from entry type dialog.
  • Fill in the details of the paper starting from "Required fields" tab. You need not fill in all the fields in other tabs. You can find more about fields in BibTeX Help and wikibooks.
  • You can also copy-paste the details of field from the paper, publisher website, or listing on Google Scholar. But make sure that the details are correct. For example, the author details of the Einstein paper is wrong on Google Scholar!
  • While selecting Bibtexkey be sure that it is unique as you would never want to change it in future (Bibtexkey is the key which would refer from LaTeX). I typically follow the format: firstAuthorLastName_year_four_word_paper_summary for my Bibtexkey (& PDF filenames).
  • To link the PDF (or any other file), go to "General" tab and add the link to file. You can add as many files as you want to an entry. This allows easy access to the files from JabRef. See help section for more details and options.
  • You can also add your review of the paper in "Review" tab. I prefer adding some "Keywords" and write my notes in "Comment" in "General" tab. Also, I prefer to use my favorite 3rd party tools to annotate/highlight the PDF itself.
  • JabRef also supports groups (which are somewhat similar to labels in Gmail) and marking for more advanced categorization. However, I never felt any need of such categorization because the search in JabRef works well and use of keywords pretty much categorizes all the references.

While adding new entries, JabRef will autocomplete author names and words and can also autogenerate Bibtexkey. Once you have added enough references, you can directly link to the reference.bib from LaTeX file for bibiliography. You can also put the .bib file in some sort of version control for enhanced security and control. I prefer to create weekly backup of the entire papers directory to external hard-drive for peace of mind.

Cross-platform

JabRef is written in Java which makes it cross-platform by design. I frequently use it on desktops (Linux, Windows and Mac). The method also works well with portable android devices with RefMaster. Basically, RefMaster replaces JabRef on andriod and it supports Dropbox integration. There should be similar apps for managing BibTeX on iOS platform.

Drawbacks

The only feature which I miss in this approach is the ability to search inside the linked files when searching in JabRef. However, it is not a show stopper, especially in presence of various desktop search tools.

Also, this approach will not parse your computer for PDF files and auto-magically generate "correct" references. This method is geared towards accuracy and, in my experience, the auto-magical metadata extraction from PDF do not work well frequently and have rather large error rate. Careful verification of reference data while entering data is important and fruitful in long run.

Another drawback could be the steep learning curve required for getting comfortable with LaTeX (& BibTeX). It is assumed that people from my discipline (Engineering) are already using or will be using LaTeX. See next section for alternatives.

Alternatives

If LaTeX (& BibTeX) is not your cup of tea then following are some alternatives (but one should consider why should they not use LaTeX and who else uses LaTeX). I ended up with JabRef because most of the following did not had upto-the-mark BibTeX management, atleast by my taste, when I was trying them.

  • Mendeley is a good alternative and specially works well with office documents and can search inside linked PDFs.
  • citeulike is an online service and works well for collecting references while browsing over internet.
  • Zotero used to be a browser-plugin which offers good features, but I never tried it seriously. The standalone version came much later but looks good.

There are several other softwares which can be used for refernce management. Here is a popularity context of different softwares and here is an irony post comparing them. Everyone has their own preferences and a solution may not be the 'best' solution for everyone. The described approach works for me and could be helpful to others.



Read more ...

Moving remote Git repository

Jul 11, 2014
It is surprising that most of the search results related to moving Git repository is targeted towards moving repositories to github.com and alike. I was trying to move my git repository from, say, server1.edu to server2.edu. These servers are Linux servers and are accessible via SSH. However, using the common set of instructions i.e. git clone --bare followed by git push --mirror kept throwing me following error: $ git push -v --mirror ssh://server2.edu:/home/user/Repo.git Pushing to ssh://server2.edu:/home/user/Repo.git fatal: '/home/user/Repo.git' does not appear to be a git repository fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. Some posts suggested to first initialize a git repository on server. This sounded odd to me as per my understanding, all we need is SSH access to the server in order to setup as a remote Git repository.

And it turns out that the answer is very simple and is actually explained on Git documentation. Just perform a local --bare clone of the repository then scp or rsync it to server and update origin of the repository. Thats it! All push/pull would work as expected after that with new server. Here are steps I followed (notice server1 and server2 in the commands): # Check current remotes $ cd /home/user/Repo $ git remote -v origin user@server1.edu:/home/user/Repo.git (fetch) origin user@server1.edu:/home/user/Repo.git (push) # Temporary --bare clone in /tmp $ cd /tmp $ git clone --bare file:///home/user/Repo Cloning into bare repository 'Repo.git'... remote: Counting objects: 4389, done. remote: Compressing objects: 100% (4349/4349), done. remote: Total 4389 (delta 3138), reused 3 (delta 0) Receiving objects: 100% (4389/4389), 45.46 MiB | 15.28 MiB/s, done. Resolving deltas: 100% (3138/3138), done. Checking connectivity... done. # Transfer the new bare repository to new server using scp or rsync $ scp -r Repo.git user@server2.edu:/home/user # Update origin url in local repository $ cd /home/user/Repo $ git remote set-url origin user@server2.edu:/home/user/Repo.git # Check the updated remotes $ git remote -v origin user@server2.edu:/home/user/Repo.git (fetch) origin user@server2.edu:/home/user/Repo.git (push) # Delete the temporary clone in /tmp $ rm -rf /tmp/Repo.git
Read more ...

Matlab's cryptic error messages

May 17, 2014
Sometimes MATLAB's error messages can be very cryptic and misleading. Following are examples of error messages which I encountered while trying to solve \(\mathbf{A}x=b\) in least square sense using MATLAB's lsqr function. %% Error 1 Error using iterapp (line 60) user supplied function ==> @(x,transp_flag)transform_X(x,transp_flag, ...) failed with the following error: Not enough input arguments. Error in lsqr (line 180) u = u - iterapp('mtimes',afun,atype,afcnstr,x,varargin{:},'notransp'); %% Error 2 Error using * MTIMES is not supported for one sparse input and one single input. Error in iterapp (line 29) y = afun * x; Error in lsqr (line 180) u = u - iterapp('mtimes',afun,atype,afcnstr,x,varargin{:},'notransp'); For an experienced MATLAB user, error 2 may be easier to locate because of the message: "Error using *". However, when I was actually working, I got error 1 which said "Not enough input arguments". It took me sometime to figure out that both the errors were related to mismatching datatypes in input parameters. Both the situations were actually identical, except that in first case I was using function handle Afun in place of matrix representation of \(\mathbf{A}\). Here are the actual statements which raised errors: x = lsqr(Afun, b, 1e-9, 100, [], [], x0); % Raises Error 1 x = lsqr(A, b, 1e-9, 100, [], [], x0); % Raises Error 2
And here is the code snippet for Error 2 above. The code can be modified easily to create function handle Afun (see Example 2 here). Notice the statement x0 = single(rand(size(b))*5); in the code snippet which changes the datatype and causes error. n = 50; on = ones(n,1); A = spdiags([-2*on 4*on -on],-1:1,n,n); b = sum(A,2); x0 = single(rand(size(b))*5); x = lsqr(A,b,1e-9,100,[],[],x0);
The take-away message: Always check datatypes when MATLAB's error messages don't make sense!
Read more ...

LaTeX to word document

Jan 24, 2014
Tested on: Linux Mint 13 (Ubuntu 12.04), Microsoft Office 2010, LibreOffice 3

It is common to typeset scientific documents in  \(\LaTeX\). However, few people may like to still read and edit the document in word processors like Microsoft word (.doc or .docx)or LibreOffice (.odt). Here are quick (& dirty) steps to produce reasonably looking "office" documents from .tex files. The idea is to exploit HTML output as intermediate format which is readable by word processors. This ideas is shown below and has been explored and reported widely.
.tex.html.docx
  1. Convert \(\LaTeX\) to .html: There are various ways to achieve this, but htlatex from TeX4ht worked best for me. First install TeX4ht and then then run following on the \(\LaTeX\) document. Note that htlatex runs latex three times before calling TeX4ht programs and it would write out all the outputs in the same directory as the .tex file (see below for handling PDF images). The generated files would include one .html file (paper.html for command shown below). $ sudo apt-get install tex4ht $ htlatex paper.tex
  2. PDF images: If the .tex file uses PDF files as images, then htlatex (or latex) may not be able to go along with correct conversion. Some discussions on Stack Exchange were very help for this issue and provided the solution. First create a configuration file, say myxhtml.cfg, with following content: \Preamble{xhtml} \Configure{graphics*} {pdf} {\Needs{"convert \csname Gin@base\endcsname.pdf \csname Gin@base\endcsname.png"}% \Picture[pict]{\csname Gin@base\endcsname.png}% \special{t4ht+@File: \csname Gin@base\endcsname.png} } \begin{document} \EndPreamble Then run htlatex as shown below. Note that the .tex file should use correct extension for every included image (or else use \DeclareGraphicsExtensions{.pdf}). $ htlatex paper.tex myxhtml
  3. Fix HTML: Sometimes TeX4ht will not write out clean html files i.e. the html tags may not be aligned properly. This may prevent html to import into word processors. Online editors like Fix My Html and HTML Tidy Online did the trick for me. Use the .html file generated by htlatex as input to these online editors and save the fixed html file for next step.
  4. Import HTML in word processor: Usually most word processors would support importing HTML files. If that does not work (like in my case), you can just open the HTML file in a browser then copy-paste the whole page into the word processor (check if your word processor also supports Paste Special for formatted text. It everything works out then you should be able to just save the pasted document in .doc, .docx or .odt format. 
The above set of steps produced good looking single column document for me with correct bibiliography references. The math equations are embedded as images in the documents, which may not be optimal but the process works for reviewing and editing the text by someone who prefers word processors.
Read more ...

Parent directories in tar archives

Jan 3, 2014
Tested on: Linux Mint 13 Maya (based on Ubuntu 12.04 LTS)

It is common to see full directory tree or . (dot) in tar archives. Sometimes, it may be unnecessary hassle to remove all parent directories after extracting or to look for the extracted file which merged with other files in extracted directory. In some situations, it may be desirable to create a tar archive with top directory (with informative name). There has been many discussion about the same. Here is quick summary with an example for future reference.

Test setup

We will create a test directory with some files in it with following commands (outputs are also shown): $ mkdir -p /tmp/path/to/test/dir_archive $ touch /tmp/path/to/test/dir_archive/file{1..10} $ ls /tmp/path/to/test/dir_archive/ file1 file10 file2 file3 file4 file5 file6 file7 file8 file9 $ tar --version tar (GNU tar) 1.26 Copyright (C) 2011 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Written by John Gilmore and Jay Fenlason.

Full parent directory

Following command creates tar archive with full parent directory structure as shown by --list command. $ tar -caf /tmp/test.tar.gz /tmp/path/to/test/dir_archive $ tar --list -af /tmp/test.tar.gz tmp/path/to/test/dir_archive/ tmp/path/to/test/dir_archive/file3 tmp/path/to/test/dir_archive/file10 tmp/path/to/test/dir_archive/file1 tmp/path/to/test/dir_archive/file8 tmp/path/to/test/dir_archive/file4 tmp/path/to/test/dir_archive/file2 tmp/path/to/test/dir_archive/file7 tmp/path/to/test/dir_archive/file5 tmp/path/to/test/dir_archive/file6 tmp/path/to/test/dir_archive/file9

Dot (.) as parent directory

Following command creates tar archive with dot (.) as parent directory. Note that the tar command ends in a dot (.). $ tar --directory /tmp/path/to/test/dir_archive -caf /tmp/test.tar.gz . $ tar --list -af /tmp/test.tar.gz ./ ./file3 ./file10 ./file1 ./file8 ./file4 ./file2 ./file7 ./file5 ./file6 ./file9

Directory name as parent directory

The trick to get dir_archive as parent directory in tar archive is to use --directory to change directory to one level up as shown below. Note location of dir_archive in the command. $ tar --directory /tmp/path/to/test -caf /tmp/test.tar.gz dir_archive $ tar --list -af /tmp/test.tar.gz dir_archive/ dir_archive/file3 dir_archive/file10 dir_archive/file1 dir_archive/file8 dir_archive/file4 dir_archive/file2 dir_archive/file7 dir_archive/file5 dir_archive/file6 dir_archive/file9
Some more notes about tar command:
  • Above commands can be combined with used along with exclude directive to by using --exclude='dir_archive/dir_exclude' after the --directory option.
  • Do not mix absolute and relative path in tar command for pathname and exclude option. --directory is an exception and can be absolute path while others paths can be defined relative to it.
Read more ...

BibTeX hacks

Dec 27, 2013
Sometimes \(\LaTeX\) compilation can give fairly unhelpful error messages like these: ! Missing $ inserted. $ l.190 ... pp. 225--236, 10.1007/978-3-642-31340-0_19 18. [Online]. ? If these error message are in .bbl file, when you are using BibTeX (.bib file) for bibliography then it is possible that these error messages are result of some special characters in your .bib file. I have seen it frequently that some DOI links contain some special characters. Following are some ways to get around these issues so that resulting document is rendered correctly.
  • Escape underscore (_) with a backslash (\). In the above example, the original DOI url was 10.1007/978-3-642-31340-0_19 which was resulting into errors. Escaping the underscore with backslash fixed the issue for me: 10.1007/978-3-642-31340-0\_19 (notice a backslash before _19 near the end).
  • Sometimes DOI urls would contain less-than (<) and greater-than (>) character. These characters do not result into errors during compilation but would be rendered incorrectly. Escaping these characters with backslash generally does not work and often result into errors similar to that shown near the top of the post. An example (fake) DOI url is 2/3<80::AID-HBM2>3.0 which was rendering upside down question mark and exclamation marks (probably because of issues with font encoding). I found that putting < in math mode helps to resolve this issue, i.e. replace with $<$ and $>$ so that new DOI url looks like 2/3$<$80::AID-HBM2$>$3.0.
  • Changing font encoding by adding following lines in \(\LaTeX\) preamble can also help to resolve above issue with < and >, as discussed here. \usepackage[T1]{fontenc} \usepackage{lmodern}
  • \(\LaTeX\) provides means to describe special characters like accents or umlauts using a special notation as described in following table hot-linked from official homepage. In addition, also check out this really great answer on stackexchange about accented letters.

Read more ...

Useful LaTeX tricks

Aug 3, 2013

\(\LaTeX\) word count

It can get difficult to keep track of accurate number of words in a \(\LaTeX\) document. TeXcount is a script for counting words in text and math equations in LaTeX documents. It can also generate very detailed html output with color-coded words types. TeXcount is part of Tex live and can be installed by installing texlive-extra-utils from Ubuntu repository. TeXcount also has a web interface. $ texcount document.tex FILE: document.tex Words in text: 6462 Words in headers: 48 Words in float captions: 274 Number of headers: 19 Number of floats: 4 Number of math inlines: 204 Number of math displayed: 8 texcount -v -html document.tex > word_count.html

\(\LaTeX\) diff

Usual diff programs may not do a great job of diffing two \(\LaTeX\) documents. Following are some of the alternative ways:
  • Use wdiff with colordiff, similar to this stackexchange question: wdiff -n old.tex new.tex | colordiff | less -R
  • Use latexdiff to determine differences and create a new LaTeX document with markup differences between two latex files. latexdiff can be found in Ubuntu repository and detailed description of usage can be found here. An example with beautifully typeset document is given below. latexdiff draft.tex revision.tex > diff.tex
  • Another alternative could be to follow a simple guideline: Always start a new sentence in a new line and do not put any line-breaks in till the sentence ends. This allows traditional diff/merge programs like meld etc to work in a much better way.

\(\LaTeX\) and git

It is useful to use a version control system, like git, with \(\LaTeX\) documents. Here are some useful tips while working with git:
  • Check git + LaTeX workflow for some great tips.
  • Use latexdiff (also see above) in smarter way:
    • latexdiff <(git show checksumHash:file.tex) file.tex > diff.tex
    • Git-latexdiff can also be used for more advanced operations, like documents involving multiple .texfiles.
    • Check stackexchange discussion for more solutions.

\(\LaTeX\) on blogspot.com

MathJax is awesome. It is very easy to install and get \(\LaTeX\) equations working. \[ J_\alpha(x) = \sum\limits_{m=0}^\infty \frac{(-1)^m}{m! \, \Gamma(m + \alpha + 1)}{\left({\frac{x}{2}}\right)}^{2 m + \alpha} \]
Read more ...

Git cheat sheet

Jul 10, 2013

Git overview: Operation and File lifecycle

Image are hotlinked from Pro Git book, written by Scott Chacon.


Some of the commands listed here may use alias and/or configuration defined in ~/.gitconfig (see near the end of the post).

General operations

  • Help with git: git --help # List available git commands git help <command> # More details about a specific command git <command> --help # More details about a specific command
  • Display status of (local) repository: git status git st # Abbreviated using ~/.gitconfig git status -sb # Shorter output git status -uno # Hide details of untracked files
  • Adding files to staging area: git add --dry-run <file1> <file2...fileN> # Dry run. No change in repository git add -n <file1> <file2...fileN> # Abbreviated flag for dry run git add <file1> <file2...fileN> # Add files to staging area git add *.m *.txt # Also supports wildcards
  • Commit changes with message: git commit -m 'message' # Commit ONLY staged files git commit -a -m 'message' # Commit ALL changes, including unstaged files git ci 'message' # Abbreviated using ~/.gitconfig

Compare and inspect

  • Changes in working directory: git diff --color # Colored diff git diff --stat # Show diffstat git diff --ignore-all-space # Ignore all whitespace git diff -w # Abbreviated --ignore-all-space git diff --ignore-space-changes # Ignore change in amount of whitespace git diff -b # Abbreviated --ignore-space-changes git diff -w --color-words # Colored word diff (rather than line diff) ignoring whitespace git diff --cached # Show changes in staged files git diff --staged # Same as --cached
  • Inspect changes:
    (gitk is a tcl/tk based gui; Beginner tutorial) gitk --all # Browse all branches in local repository git log --oneline --graph # Inspect repository with summary of changes git log --oneline --graph --stat # Inspect repository with diffstats git whatchanged --oneline --graph # Similar to git log git lg # Abbreviated using ~/.gitconfig git show <commit> # Shows details of changes in commit
  • Inspect changes beyond file renames:
    (Take care with renames: NEVER commit renames and modifications in the same commit. Check these as well.) git log --oneline --follow <filename> # Summary of changes git log --follow -p <filename> # Detailed changes gitk <filename> # Detailed changes using gitk

Branching

  • Pro Git book has an excellent chapter on Branching and Merging.
  • When typing in the name of a branch in following commands, try using TAB for auto-completion. It works most of the times.
  • git branch # List local branches git branch -a # List all local and remote branches git checkout <branch_name> # Switch to other existing branch git checkout -b <branch_name> # Create a branch and switch to it git branch -d <branch name> # Delete a branch
  • Compare branches: (order of branches matter) git diff <branch1>..<branch2> git diff --stat <branch1>..<branch2> # Generate diffstat git diff --name-status <branch1>..<branch2> # Short diff with only name and status git diff <branch1> <branch2> <filename> # Show differences only for a file git difftool <branch1> <branch2> <filename> # Use (external) diff tool
  • Compare directories (branches/commits): (requires git version >=1.7.10) git difftool --dir-diff <commit1>..<commit2> git difftool --dir-diff <commit1> git difftool --dir-diff <branch1> git difftool --dir-diff <branch1>..<branch2>
  • Remote branches & its management
    A very good and detailed description of remote branch management can be found in Pro Git book. # Pushing to remote git push origin localBranch # Pushes localBranch to origin git push -u origin localBranch # Pushes/sets association of localBranch to origin git push origin localBranch:remoteBranchName # Pushes localBranch to origin/remoteBranchName git push -u origin localBranch:remoteBranchName # Similar effect to -u above # Tracking or defining association. Also see this. git branch -u origin/remoteBranchName # Associates current branch to origin/remoteBranchName git branch -u origin/remoteBranchName localBranch # Associates localBranch to origin/remoteBranchName # Checking out from remote git fetch origin && git checkout remoteBranchName # Checkout origin/remoteBranchName git checkout -b localBranch origin/remoteBranchName # Checkout origin/remoteBranchName to localBranch git pull # Works after checking out or associating. # Deleting remote branch git push origin :remoteBranchName # Deletes origin/remoteBranchName git push origin --delete remoteBranchName # Deletes origin/remoteBranchName # Prune stale branch. See git remote branch deleted but still appears in 'branch -a' git remote prune origin # Removes all stale branches git fetch -p # Fetches from origin and prunes all stale branches # Show details of branch tracking information git remote -v show origin git branch -vv -a

Merge conflicts

Good read about three-way merge in git: Painless Merge... and Three way git... Here is a summary:
  • Use git mergetool with meld. See ~/.gitconfig below. Mergetool would go through the conflicting files and create various new files with different file extensions so that it can use following command with meld (see git source code for more details). meld --output $MERGED $LOCAL $BASE $REMOTE
  • $LOCAL: Contents of the file on the current branch. This is presented in Left-most column in meld.
  • $REMOTE: Contents of the file to be merged. Right-most column in meld.
  • $BASE: Common base of the merge OR half-finished merge where things started to fail. It is shown in middle column in meld. This is column which you would want to edit.
  • $MERGED: File to which meld would write the merge resolution. It is not shown in meld. However, when $BASE is saved after editing, the output is written to $MERGED. Usually, $MERGED does not have any special extension like above files.
  • Mergetool creates *.orig backup files while resolving merges. These are safe to remove once a file has been merged.

Tagging

  • Create/Delete tags (Also see Pro Git book) git tag -a v1.4 -m 'my version 1.4' # Creates annotated tag to current commit git tag -a v1.4 -m 'my version 1.4 <checksum> # Adds tag to an older commit git tag -d <tag_name> # Deletes a tag
  • List tags git tag -l # Lists tags in alphabetical order git tag # Lists tags in alphabetical order git tag -l -n1 # Lists tags along with annotation git tag -l <pattern> # Lists tags in matching a pattern git tag -l v13* # Lists tags starting with v13 git log --tags --simplify-by-decoration --pretty="%d" # Lists tags in chronological order git tl # Abbreviated by ~/.gitconfig git show <tag_name> # Show details of a tags
  • Remote tags git ls-remote --tags origin # List all tags on origin git push origin <tag_name> # Push a tag to origin git push origin --tags # Push all tags to origin git push origin :refs/tags/<tag_name> # Delete a tag on origin

Others:

  • Revert changes (excellent examples in git-reset documentation) git reset # Undo all add. Retains all changes in working tree git reset --hard # Undo add all. Discards all changes in working tree git reset HEAD <file_name> # Undo add one file. Retains all changes in working tree git reset --soft HEAD^ # Undo last commit. Retains all changes in working tree uncommitted (un-stage) all changes including files and folders:


~/.gitconfig

git difftool falls back to git mergetool config variables when the difftool equivalents have not been defined. If a merge resolution program is not specified, git mergetool will use the configuration variable merge.tool. [core] editor = emacs autocrlf = input [merge] tool = meld [alias] ci = commit -a -m st = status -sb rb = rebase lg = log --graph --all --format=format:'%C(auto)%h (%cd)%C(reset)%C(bold red)%d%C(reset) %C(bold green)%s%C(reset) %C(bold white)- %cn%C(reset)' --abbrev-commit --date=short df = diff -w --color-words dft = difftool -y tl = log --tags --simplify-by-decoration --format=format:'%C(auto)%h (%cd) -%C(reset)%C(bold red)%d%C(reset) %C(bold white)- %cn%C(reset)' --date=short --author-date-order [color] ui = true [color "status"] added = yellow changed = red untracked = cyan [push] default = current

Other great Git references:
Read more ...

Dropbox Bug?

Mar 10, 2013
UPDATE: This is an expected behavior of dropbox. See relevant discussion at Dropbox Forums.

It seems that there is a dropbox bug which may affect the recovery of deleted files and folders in this specific situation. I will try to document and elaborate my observations in this post. In short, dropbox seems to be not able to recover a deleted folder if a new file with exact same name is replaced at the exact same location as the deleted folder. I am a free user of dropbox and I am not sure whether this is one of the free features. I found this particular problem 7-8 months back & I could recover the files from my personal backup, which is separate and independent from dropbox.

Here are the steps to reproduce the results. (I did backup all the data, so nothing was lost in reality. This is just a demonstration.) Here, I am going to delete a folder named 'Image Fun' from my dropbox which has some more files and folders in it. The goal is to check, if I can recover those files and folders inside the folder Image Fun.
  1. Make sure Dropbox is running. (I am using Linux Mint 13)
  2. Delete the folder Image Fun, with some files and folders.
  3. Create a file with name Image Fun (no extensions) somewhere outside the Dropbox folder and then copy the file to the location of original Image Fun folder.
  4. Log on to dropbox.com website and hit "Show deleted files". I can not see any folder which has been deleted & has name Image Fun. Though, I can see the file I created with the exact same name (among normal files, not deleted files).
  5. Navigate to "Events" link on the left on dropbox website. This is the part where it gets interesting. I could see the notification which says that I deleted Image Fun and other 45 files in that folder. See the screenshot below. Now when I click on Image Fun, I am taken to home page where it highlighted the new Image Fun file.

  6. Clicking on "output" link in events page (output was a folder inside the delete folder) showed a message in red saying "The folder /Image Fun/output is deleted" (screenshot below).

  7. When I clicked on "45 more files" in the events page, it showed me a page where all the files were listed, but I could not click on any of them in order to recover. 

  8. But, when I clicked on link "a1.jpg" in events page (where it said "You deleted a1.jpg and 45 more files"), I was taken to a page where I can actually see the older version of that particular file - a1.jpg. Clicking on version 0 shows the correct original file. 
  9. You must have noticed the "Restore" button on a1.jpg link (above screenshot). When I clicked on it, something unexpected happened. The file which I created, with name Image Fun, was actually removed with the folder Image Fun and a1.jpg was restored in the folder. Now I could navigate to the folder and even see deleted files. This could be one way to recover the file. But I would count it as very unreliable method. It relies on finding and clicking on one particular file's deleted link and then recovering it. That particular link may actually get lost if many other files in other locations were also deleted. Events page after the recovery looks like this:

Hopefully, this will help to fix or address the issue I mentioned. It is probably an expected behavior. See relevant discussion at Dropbox Forums.
Read more ...

gs (GhostScript) cheat sheet

Aug 28, 2012
Cheat-sheet for versatile interpreter GhostScript. It can be used to tweak, convert, produce high quality Postscript and PDF files.

Convert postscript (ps) to pdf:

gs -q -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=fileout.pdf filein.ps

Merge ps and/or pdf:

gs -q -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=fileout.pdf filein1.ps filein2.pdf filein3.pdf

Extract page(s) from a ps or a pdf document:

gs -q -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -dFirstPage=3 -dLastPage=3 -sOutputFile=fileout.pdf filein.ps

Embed fonts in a pdf:

gs -q -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=fileout.pdf -dPDFSETTINGS=/prepress -dEmbedAllFonts=true -dSubsetFonts=true -dCompatibilityLevel=1.6 filein.pdf

Convert images to pdf:

Check this post. Or else use ImageMagic's convert.

PDF optimization options

-dPDFSETTINGS=/screen (screen-view-only quality, 72 dpi images) -dPDFSETTINGS=/ebook (low quality, 150 dpi images) -dPDFSETTINGS=/printer (high quality, 300 dpi images) -dPDFSETTINGS=/prepress (high quality, color preserving, 300 dpi imgs) -dPDFSETTINGS=/default (almost identical to /screen)

Paper size options

-sPAPERSIZE=letter -sPAPERSIZE=a4 -dDEVICEWIDTHPOINTS=w -dDEVICEHEIGHTPOINTS=h (point=1/72 of an inch) -dFIXEDMEDIA (force paper size over the PostScript defined size) -gWIDTHxHEIGHT (page size in pixels)

Output devices:

-sDEVICE=pdfwrite -sDEVICE=ps2write -sDEVICE=png16m (24-bit RGB color) -sDEVICE=pnggray (grayscale) -sDEVICE=pngmono (black-and-white) -sDEVICE=pngalpha (32-bit RGBA color) -sDEVICE=jpeg (color JPEG) -sDEVICE=jpeggray (grayscale JPEG) -sDEVICE=epswrite (encapsulated postscript) -sDEVICE=txtwrite (text output, UTF-8) Check -sOutputFile below, for separate images for each page of a multi-page document. Tiff, PNM and many more formats are supported. Check details in Ghostscript output devices.

Help & list of available devices:

gs -h

Other options

-dNOPAUSE (no pause after page) -dBATCH (exit after last file) -sOutputFile=ABC-%03d.pgm (produces 'ABC-001.pgm'..'ABC-010.pgm'..) -dEmbedAllFonts=true -dSubsetFonts=true (Embeds only the characters used in document) -dCompatibilityLevel=1.4 (Adobe's PDF specifications, >=1.4 for font embedding, =1.6 for OpenType font embedding) -dCompressPages=true (compress page content) -dFirstPage=pagenumber -dLastPage=pagenumber -dAutoRotatePages=/PageByPage (or /All or /None) -rXRESxYRES (XRES & YRES in pixels/inch) -rRES (same XRES & YRES, affects images and fonts converted to bitmaps) -sPDFPassword=password More details & defaults on ps2pdf documentation.
Adobe® PDF Creation Settings - Used by GhostScript.
GhostScript Documentation.

Read more ...

Cheat Sheets

Jul 21, 2012
Cheat sheets in this blog are not static posts and they keep getting updates from time to time. Here is the list of cheat sheet (from this blog) for different applications:

Some other useful cheat sheet resources: 

Read more ...

Where did my disk space go?

May 11, 2012
Have you ever noticed missing disk space on newly bought hard disks? Here are some possible reasons:
  1. Unit confusion: The most common confusion in between GB/GiB or MB/MiB.
  2. Reserved space in linux partitions.
  3. Filesystem overheads.

Unit Confusion

Many people have questions like: Why my 1 TB hard disk shows only 930 GB? This is purely a confusion of units and bases used when words like 'kilo', 'mega' etc. are used. Following table, from AskUbuntu, explains the situation. Prefix Bytes Prefix Bytes 1 Byte = (2^10)^0 = 1 1 Byte = (10^3)^0 = 1 1 Kibibyte(KiB) = (2^10)^1 = 1024 1 Kilobyte(KB) = (10^3)^1 = 1000 1 Mebibyte(MiB) = (2^10)^2 = 1048576 1 Megabyte(MB) = (10^3)^2 = 1000000 1 Gibibyte(GiB) = (2^10)^3 = 1073741824 1 Gigabyte(GB) = (10^3)^3 = 1000000000 1 Tebibyte(TiB) = (2^10)^4 = 1099511627776 1 Terabyte(TB) = (10^3)^4 = 1000000000000 Many softwares and operating systems often calculate size in GiB and put GB when they are displaying it. This becomes even worse because most of the harddisks are labelled with actual GBs and hence when numbers are reported in GiB, it creates the confusion. Online calculators like this can help to remove the confusion. NIST states very interesting historical reason of this confusing prefix:

Once upon a time, computer professionals noticed that 210 was very nearly equal to 1000 and started using the SI prefix "kilo" to mean 1024. That worked well enough for a decade or two because everybody who talked kilobytes knew that the term implied 1024 bytes. But, almost overnight a much more numerous "everybody" bought computers, and the trade computer professionals needed to talk to physicists and engineers and even to ordinary people, most of whom know that a kilometer is 1000 meters and a kilogram is 1000 grams.
Then data storage for gigabytes, and even terabytes, became practical, and the storage devices were not constructed on binary trees, which meant that, for many practical purposes, binary arithmetic was less convenient than decimal arithmetic. The result is that today "everybody" does not "know" what a megabyte is. When discussing computer memory, most manufacturers use megabyte to mean 220 = 1 048 576 bytes, but the manufacturers of computer storage devices usually use the term to mean 1 000 000 bytes. Some designers of local area networks have used megabit per second to mean 1 048 576 bit/s, but all telecommunications engineers use it to mean 106 bit/s. And if two definitions of the megabyte are not enough, a third megabyte of 1 024 000 bytes is the megabyte used to format the familiar 90 mm (3 1/2 inch), "1.44 MB" diskette. The confusion is real, as is the potential for incompatibility in standards and in implemented systems.

Reserved space

While formatting Linux partitions like ext2/ext3/ext4, 5% of the drive's total space is reserved for the super-user (root) so that the operating system can still write to the disk even if it is full. This space is wasted if the drive is being used solely for data storage especially on large partitions. The details of the reserved space can be seen by running following command (replace sda1 by your drive name)sudo tune2fs -l /dev/sda1 The reserved space can be decreased to 1% of the drive's total space by running following command. To completely remove this reserved space replace 1 by 0. sudo tune2fs -m 1 /dev/sda1 As explained in Ubuntu Documentation, using this command does not change any existing data on the drive. You can use it on a drive which already contains data. This should be left to 5% on drives containing filesystem /, /var, /tmp in order to avoid any problems.

Filesystem overheads

Journaling file systems like ext2/ext3/ext4/NTFS used file tables for managing the filesystem. These tables take up lots of space (2-3% of drive size). Different file system allocates space to these tables differently. For example ext4 allocates all its space during the format itself, which shows up as used disk space. Where as NTFS allocates it when more files are written to disk.

The exact details are more complicated than this handy wavy explanation. Many forum posts has discussed this issue.

Read more ...

Wireless power management in Ubuntu

Feb 15, 2012
Tested on: Ubuntu 11.04 (natty)

I have been experiencing extremely slow network connection whenever my laptop has been on battery. Speedtest results showed a 50 fold speed reduction when my laptop was on battery. I speculated that lower speed has to do with power-management, which reduces network speed in order to save battery. Ubuntu, like other operating systems, also has power management options installed by default. There is a frontend/GUI for Power Management preferences. But I could not find any thing related to wireless or Wi-Fi in the GUI. Looking around on internet, I found many pages. Here is a log of the things I found.
  • Confirming the behaviour: In order to make sure that power-management is the culprit of the slow network access run following command both when on power and when on battery.iwconfig The output should look like following: wlan0 IEEE 802.11bgn ESSID:"USC Wireless" Mode:Managed Frequency:2.462 GHz Access Point: 00:00:00:00:00:00 Bit Rate=65 Mb/s Tx-Power=15 dBm Retry long limit:7 RTS thr:off Fragment thr:off Power Management:on Link Quality=68/70 Signal level=-42 dBm Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0 Tx excessive retries:27329 Invalid misc:204 Missed beacon:0 Notice line five of the output. If it says anything other than Power Management:off while on battery, then it could be power management which is slowing down then network. Check power argument in iwconfig man page for other possible options.

  • Temporarily disable the power-management: While on battery, run following command (replace wlan0 with your Ethernet name) sudo iwconfig wlan0 power off This will only affect the wireless settings of power management. and should change the output of previous command to Power Management:off and most-likely revert the network speed to usual speed. However, on restarting the system the power management will be enabled.

  • Permanently disable power-management for wireless: If you do not want to keep running the above command each time you restart you laptop, create a file /etc/pm/power.d/wireless with following content: #!/bin/sh /sbin/iwconfig wlan0 power off Make the file executable by running following command:sudo chmod +x /etc/pm/power.d/wireless This new file will override the default wireless script run by power management and will also make sure that wireless power management is turned off. The above trick is taken from Ubuntu Documentation (Check few lines before the example). It says:

    When you run pm-powersave it combines the scripts in these two directories and executes them in sorted order. If both directories contain a script with the same name, the one in /etc/pm/power.d/ has a higher precedence and only this one will be executed. Therefore to disable a script from /usr/lib/pm-utils/power.d/ simply create an empty file in /etc/pm/power.d/ with the same name and without the execute bit set.


Read more ...

vsftpd behind router/firewall

Jan 28, 2012
Tested on: Ubuntu 11.04 (natty)

This is how I got vsftpd server work behind a router. If you are getting errors like "Server sent passive reply with unroutable address. Using server address instead." or "500 illegal port command" on list (ls) command, this post might help. Setting passive mode configuration correctly is the trick.

Please note that this may not be the perfect solution or even worse - not very secure. Read vsftpd.conf manual before applying any changes.

Make sure port 20, 21 and few more ports, for example 4242-4252, are being forwarded to the server. We will need these extra ports for passive mode - set pasv_min_port and pasv_max_port accordingly in the configuration file. Add following to /etc/vsftpd.conf . connect_from_port_20=YES pasv_enable=YES pasv_addr_resolve=YES pasv_address=myaddress.dyndns.com pasv_min_port=4242 pasv_max_port=4252 Set pasv_address to your domain name. You can use dyndns for dynamic ip-address. vsftpd will convert your domain name to ip address when vsftpd server starts. Note that if your ip address changes after vsftpd has started it will not update the ip-address. There has been some attempt to the solve it.
Here are some more configurations with comments: # Only allow FTP access to users listed in file /etc/vsftpd.userlist # Other users will not have ftp access userlist_enable=YES userlist_deny=NO userlist_file=/etc/vsftpd.userlist # Disable delete commands cmds_denied=DELE,RMD # Verbose logging log_ftp_protocol=YES # You may restrict local users to their home directories. See FAQ for # the possible risks in this before using chroot_local_user chroot_local_user=YES
For more security, you can also modify the login-shell of a dummy ftp user to something like /bin/false - which does not exist. Use following command sudo usermod -s /bin/false <username> In order to make this work you have to add /bin/false to the file /etc/shells. Or else vsftpd will generate login error when the user logs in using ftp.
Read more ...

Encryption + Dropbox + Android

Dec 24, 2011
Dropbox is a great application which syncs data across different computers and devices. This makes Dropbox ideal for syncing important, & often sensitive, information across devices. Saving sensitive information on cloud makes me feel uncomfortable and cranky. This is log of softwares/apps required for encrypting data. Explicit goals are:
  1. Data should never be saved to disk unencrypted.
  2. Encrypted data should be readable, even without internet access, on Windows, Linux, & Android devices.
  3. Encryption algorithm should be well known standard algorithm. Open source programs are preferable.
Following are some of the possible solutions with some notes. Not all of them achieve all the goals mentioned above.

EncFS provides encrypted filesystem in user space. It allows mounting an encrypted folder to a user defined location. Cryptonite is an android app which supports mounting of encrypted EncFS. Unfortunately, I found Cryponite to be buggy and the android app did not work out well for me. EncFS is definitely among perfect solutions for "desktop-only" systems.

BoxCryptor comes very close (and probably is heavily inspired by EncFS). It has been developed with tight integration with dropbox. It uses very popular AES-256 standard. Unfortunately its Android app requires internet connection to read the encrypted folder. Another drawback is the tight integration with dropbox. The Android app requires dropbox credentials to access data. I feel uncomfortable to give the dropbox credentials to any place other than dropbox itself.

enotes is the perfect solution for individual text files. So, each encrypted file is an independent text file and hence each individual file has to be encrypted/decrypted seperately. This can be advantage or disadvantage depending on the purpose. It also has an Android app: Encrypted Notepad. It uses AES-128 encryption and is good enough for me. The software is written in Java and hence is cross platform. Similar apps: Secret safe Lite, NoteCipher, OpenNoteSecure.

APG is an Android app which aims to provide a OpenPGP implementation. It uses public-private key or pass-phrase for encryption. But it saves unencrypted data to disk. Another app Encryption Manager Lite works in very similar fashion but with AES encryption. Similar apps: File Encrypter, Pattern Encrypt (Cool idea to use patterns for passwords).

PS: There are numerous desktop applications which can be used to encrypt/decrypt data using standard algorithms like AES. When accessing files on android device is not an issue, then any of these can be a solution. TrueCrypt is worth a mention in this category for its simple interface and powerful features. EncFS, as mentioned above, may also be suitable for some systems.


Read more ...

xpdf & X resource

Aug 7, 2011
Tested on: Ubuntu 11.04

xpdf man page is not very detailed in terms of possible values for X resource file. Following are the places where xpdf settings can be specified:
  • Ubuntu X resource file: ~/.Xresources The exact files being read can be found by looking into /etc/gdm/Xsession. My settings in ~/.Xresources # xpdf settings xpdf.geometry: 1280x1024 xpdf.initialZoom: width Run following for immediate effect: xrdb -nocpp -merge ~/.Xresources
  • xpdfrc can be found at ~/.xpdfrc and at /etc/xpdf/xpdfrc. My ~/.xpdfrc file: include /etc/xpdf/xpdfrc initialZoom width
Read more ...