Thursday, February 06, 2020

Automounting google-drive-ocamlfuse: getting Google Drive to appear as a Linux folder

This is well documented elsewhere, but just for clarity, here are my settings, that work. I.e., the Google drive appears automatically mounted after a fresh boot.

1. Install google-drive-ocamlfuse

2. Line in /etc/fstab (all one line):
gdfuse#default  /home/dom/GoogleDriveUofA    fuse    uid=1000,gid=1000,allow_other,user,_netdev     0       0

3. Contents of executable /usr/bin/gdfuse
#!/bin/bash
su dom -l -c "google-drive-ocamlfuse -label $1 $*"
exit 0

Friday, May 03, 2019

Cyavana and the motif of the tormented meditator

Years ago I wrote an article called "The Spikes in the Ears of the Ascetic."  I examined a story that occurs in early Buddhist and Jain texts, and is illustrated on the cave walls in Ajanta and in early Pala and Jaina manuscripts.
The story tells of an ascetic who is absorbed in meditation while walking.  Village lads (pāṃśupiśācas "dust-goblins" in some versions) pelt the ascetic with mud or worse.  Eventually they drive spikes into his ears.  Nothing disturbs the meditation.  But later, on waking, the sage curses the naughty boys.
It is only this year that I have discovered that the earliest version of the story occurs in the Śatapathabrāhmaṇa (thanks to my student Faried Nasir, who wrote an essay on Cyavana). 

The tale of Cyavana, SB 4.1.5 contains the antecedent of the "spikes in the ears" theme.  In the SB, Śaryāta the Mānava, while wandering, has a clan of juniors who pelt Cyavana with clods believing him to be something valueless (verses 2, 5):

4.1.5.[2] śaryāto ha vā idam mānavo grāmeṇa cacāra | sa tadeva prativeśo niviviśe tasya kumārāḥ krīḍanta imaṃ jīrṇiṃ kṛtyārūpam anarthyam manyamānā loṣṭair vipipiṣuḥ

4.1.5.[3] sa śāryātebhyaścukrodha | tebhyo 'saṃjñāṃ cakāra pitaiva putreṇa yuyudhe bhrātā bhrātrā

4.1.5.[4] śaryāto ha vā īkṣāṃ cakre | yatkimakaraṃ tasmād idam āpadīti sa gopālāṃś cāvipālāṃś ca saṃhvayitavā uvāca

4.1.5.[5] sa hovāca | ko vo 'dyeva kiṃcid adrākṣīd iti te hocuḥ puruṣa evāyaṃ jīrṇiḥ kṛtyārūpaḥ śete tam anarthyam manyamānāḥ kumārā loṣṭair vyapikṣanniti sa vidāṃ cakāra sa vai cyavana iti

References

Eggeling, Julius. 1882–1900. The Śatapatha-Brāhmaṇa According to the Text of the Mādhyandina School. The Sacred Books of the East. Oxford: The Clarendon Press.

Leslie, Julia. 2003. Authority and Meaning in Indian Religions. Hinduism and the Case of Valmiki. Aldershot: Ashgate. doi:10.4324/9781315198439. Pages 130 et passim.

Wujastyk, Dominik. 1984. "The Spikes in the Ears of the Ascetic: An Illustrated Tale in Buddhism and Jainism." Oriental Art 2: 189–94.
 





Tuesday, April 30, 2019

Linux Mint 19.1 Cinnamon and display flickering

When I upgraded to Linux Mint 19.1 with Cinnamon, I encountered a problem that my screen flickered immediately after logging in.  Others encountered the same problem (here).
I found that the solution proposed there, i.e., to delete the line
CLUTTER_PAINT=disable-clipped-redraws:disable-culling
from the file
/etc/environment
worked for me.  Logging out and back in after that change gave me a stable display.

Saturday, November 17, 2018

APN problem and mobile data

Returning from a trip abroad, my Canadian Public Mobile service stopped providing mobile data.  The problem was that the APN parameters for Public Mobile had been erased. And the "edit" and "add" options for APNs was now disabled.  Only entries for TELUS and Koodoo appeared, and neither were suitable.
I found this solution,
and it worked.

NB: on the phone
  • turn "USB tethering" off
  • enable developer mode (system/aboutphone/7 taps) and switch on USB debugging
  • make sure you use a good USB cable 
 

Wednesday, October 17, 2018

Counting on base sixteen and four, as seen in the introductions to some early Bengali printed books

/o
//o
///o
|o
|/o
|//o
|///o
||o
||/o
||//o
||///o
|||o
|||/o
|||//o
|||///o
1J
1/o
1//o
1///o
1|o
1|/o
1|//o
1|///o
1||o
1||/o
1||//o
1||///o
1|||o
1|||/o
1|||//o
1|||///o
2J
2/o
2//o
2///o

Friday, August 31, 2018

Medical e-texts available from the National Institute for Indian Medical Heritage, Hyderabad

It is not easy to find these books at the NIIMH website, so here are the links:
  • Carakasaṃhitā
  • Suśrutasaṃhitā
  • Mādhavanidānam
  • Nighaṇṭavaḥ (including   
    • abhidhānamañjarī 
    • abhidhānaratnamālā 
    • amarakōśa 
    • aṣṭāṅganighaṇṭu 
    • kaiyadēvanighaṇṭu 
    • camatkāranighaṇṭu 
    • dravyaguṇasaṅgraha    
    • dhanvantarinighaṇṭu 
    • nighaṇṭuśēṣa 
    • paryāyaratnamālā 
    • bhāvaprakāśanighaṇṭu 
    • madanapālanighaṇṭu 
    • madanādinighaṇṭu 
    • mādhavadravyaguṇa 
    • rājanighaṇṭu 
    • rājavallabhanighaṇṭu 
    • laghunighaṇṭu 
    • śabdacandrikā 
    • śivakōṣa 
    • sarasvatīnighaṇṭu 
    • siddhamantra 
    • siddhasāranighaṇṭu 
    • sōḍhalanighaṇṭu 
    • sauśrutanighaṇṭu and 
    • hr̥dayadīpakanighaṇṭu)

A melancholy reflection from the online documentation:

...  किन्तु वर्तमान वैज्ञानिक युग में संस्कृत भाषा के प्रति पाठकों की अत्यल्प रुचि के कारण ...
"But in this scientific age there is little inclination towards reading in the Sanskrit language, and therefore ..."

Thursday, August 23, 2018

Fetching multiple files from an internet site as a batch job


Sometimes one encounters a website that displays a book or manuscript page-by-page as individual jpeg files.  But what you need for your research is to have a single PDF of the item, so that you can move about it easily, and consult it offline.

There are several quick ways of getting these images as a batch job: here's one.   

  • First you have to identify the URL of one of the images.  I use Firefox, so I 
    • first bring up a page that displays the first folio of the MS. 
    • Then I press ctrl+I to get the "page info" (or Firefox menu Tools/Page Info).  
    • Then I select "Media" on the top line of the Info window.  
    • Then scroll down to the graphics file of the whole page, right click and ctrl+c to copy the URL.

      You now have a URL that looks like this:

      http://awebsite.net/uploads/manuscripts/miscellaneous/sometext/001.jpg

There may be a more direct way of getting this URL, but this is good enough for me.

The next bit is the nice bit.  Drop to the command line and use the utility "curl".  Here's the syntax ($ is my command prompt):

$ curl -O http://awebsite.net/uploads/manuscripts/miscellaneous/sometext/[001-268].jpg
  • Hit "enter" and several hundred jpeg files will be transferred to your directory.  It takes a couple of minutes, depending on your bandwidth.
    The bit in square brackets, "[001-268]" is curl's syntax for "please fetch 001.jpg, 002.jpg, ... 267.jpg, and 268.jpg".  Curl is one of the few tools with this simple ability to fetch lots of different files with a single simple command.

To convert them to a single PDF, I use ImageMagick:

$ convert *.jpg Hayanaratna.pdf
and wait for ten seconds.

(I was taught about curl by Patrick McAllister - thanks Patrick!)

A quite different approach is to use wget to fetch a whole website in a single gulp.   That's what I use for GRETIL, for example, so that I have the whole archive on my hard drive.

Monday, July 09, 2018

Tweaking the Thinkpad's TrackPoint settings in Linux Mint 19

With the update to Linux Mint 19 Cinnamon, the sliders controlling the trackpoint's accelleration and speed on my Thinkpad T560 and T500 don't work any more.  I expect it will get fixed soon.  Meanwhile, as root I  can manually edit the parameters in the filesin the directory
  • /sys/devices/platform/i8042/serio1/serio2
The above directory is found by
  • find /sys/devices/platform/i8042 -name name | xargs grep -Fl TrackPoint | sed 's/\/input\/input[0-9]*\/name$//'
Settings are reset at reboot.  :-(

I like sensitivity 125 and speed 80 on the T560; 190 and 90, inertia 10, on the T500.

Update


I found this solution (X1 parameters) that automates everything and survives reboot :-)

Another update, March 2020

Lalufu at github said,
You can also use xinput to modify the libinput values directly:
Run xinput to show the pointers the system knows about. If you have a ThinkPad you should see something along the lines of TPPS/2 IBM TrackPoint or similar.
xinput --set-prop "TPPS/2 IBM TrackPoint" "libinput Accel Speed" -0.5
will modify the pointer speed. Play around with the value to see what you like. If you want this to survive a reboot you can stick this in .bash_profile.

Friday, June 08, 2018

nice historiographical point

From a review of a history book:

"Written more in the tradition of Burckhardt and Braudel than Marx and Hobsbawm, the book is an exercise in seeing rather than storytelling."

Tuesday, May 08, 2018

Photo of Prof. Robert Charles Zaehner

Photos of Prof. Robert Charles Zaehner are rare.  One was published in his obituary in the journal Iran 13 (1975):



Tuesday, May 01, 2018

Etymology is not Lexicography

To find the meaning of a word, one must examine many sentences and then think about the use of that word in many contexts. 
 
See Franklin Edgerton, "Etymology and Interpretation," Proceedings of the American Philosophical Society, 1938 , 705-14.  http://www.jstor.org/stable/984947

Tuesday, April 17, 2018

Improving PDFs

I sometimes  do some processing on PDFs if I think they are important, or I want to read them more conveniently.  I was trying to explain my techniques to my students, recently, and I realized that I use a mixture of tools that are not at all obvious or easy to explain to someone not familiar with Unix.
So I'm going to write down here what I do, so that at least the information is available in one place.  I assume a general knowledge of Linux and an ability to work with command-line commands.

If I receive a PDF that is a scanned book, with 1 PDF page = one book opening, I want to chop it up so that 1 PDF page = 1 book page.
  • make a working directory
  • use pdftk to unpack the PDF into one file per page:
    > pdftk foobar.pdf burst
  • I now have a directory full of one-page PDFs.  Nice.
  • convert them into jpegs using pdf2jpegs, a shell script that I wrote that contains this text:
    #!/bin/bash
    # convert a directory full of pdfs into jpegs
    for i in *.pdf; do pdftoppm -jpeg -r 400 "$i" >"$i.jpg"; done
  • I now have a directory full of jpegs, one jpeg per page.
  • Start the utility scan-tailor and use it to
    • separate left and right pages into separate files
    • straighten the pages
    • select the text area of each page
    • create a margin around the text
    • finally, write out the resulting new pages
     
  • I now have a directory (../out) full of TIFF files, one page per file, smart.
  •  Combine the TIFFs into a single PDF using my shell script tiffs2pdf:
    #!/bin/bash
    # Create a PDF file from all the .tiff files in the current directory.
    # The argument provides the name of the output file (with .pdf appended).
    echo "Created a PDF from a directory full of .tif files"
    echo "Single argument - the filename of the output PDF (no .pdf extension)"
    tiffcp *.tif "/tmp/${1}.tiff"
    tiff2pdf "/tmp/${1}.tiff" > "${1}.pdf"
    echo "Created ${1}.pdf"
    rm "/tmp/${1}.tiff"
    echo "Removed temporary file /tmp/${1}.tiff"

    # thanks to http://ubuntuforums.org/showthread.php?t=155628
     
  • I now have a nice PDF that has one smart page per PDF page. 
  • If I want it OCRed, then I usually use Adobe Acrobat, a commercial program. But if I'm uploading to Archive.org, that isn't necessary because Archive.org does the OCR work using Abbyy.


That's all, folks!

Sunday, February 04, 2018

My personal protest withdrawal from USA academic conferences

I regret to say that I am cancelling my visit to this year's USA conferences.  Several USA conferences are among my favourite academic gatherings, and I will sorely miss the occasions.  I have made this difficult decision for political and personal reasons.

Like many, I am deeply dismayed by the statements and policies of current USA governance.  The statements and decisions that have been issued from the USA government over the last year, including the disgracefully vulgar, racist statements just last month, have been increasingly repellent.

I have been torn about whether to travel to the USA to work with and support all my liberal, educated, humanitarian friends there, or whether to take a moral stand to treat the USA as a pariah State.  I still do not feel certain about this matter.  Perhaps it is better to go to the USA and support my embattled friends and colleagues?  Last year, after soul-searching, I went to the American Oriental Society conference in LA.   But after a year of thinking about these issues, I have decided that I will take a different stand at this time, and stay away

My thinking on these issues was nudged forward decisively by a recent report that I heard on the BBC World Service from an Indian lady journalist who described the surprise, compulsory biometric facial scanning that she was subjected to at Dulles, on attempting to exit from the USA.  She was told that it was mandatory for non-USA citizens and that she could be detained in the USA if she did not comply.  The USA's Department of Homeland Security has recently introduced this biometric face-scanning technology at many airports for departing passengers (see here). The technology has been shown to be deeply flawed technically, morally and legally (see NY Times report of Dec 21, and the Georgetown University Law School report).  Amongst other profound problems, the software over-targets women and people with dark skin colour, producing 4% of false-positives in these cases.  As the Georgetown report finds,

Innocent people may be pulled from the line at the boarding gate and subjected to manual fingerprinting at higher rates as a result of their complexion or gender.
The technology being compulsorily applied to all non-USA citizens is demeaning, invasive and violates an individual's right to privacy.
USA Immigration already has assumed the right to require all social media passwords and to review up to five years of past social media postings, and copy all data from mobile phones or laptops [1, 2, etc. etc.].  This again violates individual privacy rights.  It also requires individuals to violate the terms of their contracts with service providers who require login details not to be shared.  In the case of university staff such as myself, it also violates the University's terms of use of my laptop, that contains or may refer to private information concerning my students.  I am required by the University of Alberta to keep my laptop and phone encrypted and I may not share the data with anyone outside the University.

Canada recently agreed, under Bill C-23, that the USA immigration authorities can arrest people while still in Canada, when they go through the USA immigration process while still at Canadian ports (1, 2, 3, etc. etc.).

I am a British Citizen and a European Citizen living as a resident in Canada.  I have no criminal record, nor any specific reason to expect difficulty entering  or leaving the USA.  While I am ashamed by the need to assert it, I am a white, Caucasian, male university professor.  From the point of view of USA governance, I am almost as good as a Norwegian.  But I am acutely aware that many good people in the USA, or entering and leaving the USA, including now my Indian friends, do not have the same automatic advantages of skin colour, gender or citizenship.  Families are being split up, people are being forced to travel to war-torn countries or otherwise being denied the American promise of safety symbolized since 1875 by the Statue of Liberty.  All international travellers are routinely being subjected to threatening, invasive and demeaning procedures.

For all these reasons, I have decided that I wish protest the USA governance and USA immigration policies and procedures.  This is done both in solidarity with my friends, and also as a matter of personal choice, because I do not wish to expose myself personally to the USA immigration service's demeaning and threatening procedures.


I am extremly uncertain about this decision. Perhaps all the above reasons should rather drive me to visit my colleagues in the USA and offer them friendship and collegiality in difficult times. I don't know what the right answer is. Last year, I had many of the same misgivings, but I decided to visit the USA. On this occasion I'm taking the opposite decision, and staying away.

I apologize to my friends in the USA and I look forward to happier times.  I only hope my protest contributes in a small way to encouraging good people in the USA to vote wisely and to lobby their representatives energetically.

Saturday, August 19, 2017

Mini edition environment for LaTeX

When writing an article or book using the LaTeX document preparation system, Indologists sometimes want to have a śloka or two printed on the page with some text-critical notes.  A famous example of this kind of layout is Wilhelm Rao's 1977 edition of the Vākyapadīya that edits the whole text this way, in each verse having its own mini-critical-edition format.

Here is a simple way to get this kind of layout in LaTeX.  I create a new environment called "miniedition":

\newenvironment{miniedition}
    {\begin{quote}
    \addtolength{\textwidth}{-\rightmargin} % width of the quote env.
    \begin{minipage}{\textwidth}
    \itshape 
    \let\footnoterule\relax}
    {\end{minipage}
    \end{quote}}

This puts a minipage environment inside a quote environment, switches on italics and switches off the footnote rule.  It's pretty simple.  The clever bit is done by the minipage environment itself, that makes footnotes inside its own box, not at the bottom of the page.  The footnote numbers are lowercase alphabetical counters, to avoid confusion with footnotes outside the environment.
Here's how you would use it, and the result:

\begin{miniedition}
pāraṃparyād \emph{ṛte ’pi}\footnote{N: \emph{upataṃ}?} svayam 
\emph{anubhavanād}\footnote{My conjecture; both manuscripts are one syllable 
short. K: 
\emph{anubhavad}; N: \emph{anubhavād}.} granthajārthasya samyak\\
pūrṇābdīyaṃ phalaṃ sadgrahagaṇitavidāṃ \emph{aṃhrireṇoḥ}\footnote{N: 
\emph{aṅghri-}, 
with identical meaning.} \emph{prasādāt}\footnote{N: \emph{prasādaḥ}.}||
\end{miniedition}

Output (with added text before and after:

The miniedition text is indented left and right, and followed immediately by the critical notes.  The footnotes at the bottom of the page are a separate series.  In both the main body text and the miniedition, you just use \footnote{} for your notes; LaTeX does the right thing by itself according to context. 
The miniedition environment does not break across pages, it is meant for for short fragments of text, one or two ślokas. 
This example is taken from Gansten 2017.

Monday, July 24, 2017

Biblatex, citations and bibliography sorting

"I want to sort in-text citations by year, but bibliography by name."  So begins one of the questions at a Stackexchange.  That's just what I want too.

I want to put multiple references in a \cite{} command without caring about their sequence, and have them automatically print in year-order.  Then, I want my bibliography to be ordinary, i.e., printed in author-date order.

The discussion at the above site is tricky, but the answer by moewe works.

In a nutshell here's what you actually do:
\begin{document}
\usepackage[sorting=ynt,sortcites=true]{biblatex}
\AtBeginDocument{\assignrefcontextentries[]{*}}
\begin{document}
Hello world!\footcites{ref1,ref3,ref0,ref4}
\newrefcontext[sorting=nyt]
\printbibliography

\end{document}
This will print your footnoted citations in ascending order of year, and your bibliography in ascending order of author.

Saturday, June 17, 2017

Expanded Devanāgarī font comparison

In 2012 I posted a comparison of some Devanāgarī fonts that were around at the time.


Here's an update, with some more fonts and more concise TeX code:

\documentclass{article}
\usepackage{polyglossia}
\defaultfontfeatures{Script=Devanagari,Language=Sanskrit}
\newfontfamily\eng{TeX Gyre Pagella}

% set up a font, print its name, and typeset the test text:
\newcommand{\FontTrial}[1]{ %
    \setmainfont[Mapping=RomDev]{#1}
    \renewfontfamily\eng{#1}
    % print the font name:
    {\eng #1} \TestText }

\newcommand{\TestText}{ = शक्ति, kārtsnyam ṣaṭtriṃśad;
{\addfontfeatures{Language=Hindi} Hindī =
        शक्ति कार्त्स्न्यम्}\par}

\begin{document}

\FontTrial{FreeSerif}
\FontTrial{FreeSans}
\FontTrial{Sanskrit 2003}

\setmainfont[FakeStretch=1.08,Mapping=RomDev]{Sanskrit 2003}
\renewfontfamily\eng[FakeStretch=1.08,Language=English]{Sanskrit 2003}
{\eng Sanskrit 2003+} \TestText

\FontTrial{Nakula}
\FontTrial{Sahadeva}
\FontTrial{Murty Hindi}
\FontTrial{Murty Sanskrit}
\FontTrial{Shobhika}
% ... etcetera

\end{document}

Output:


Lessons learned:
  • Only Sanskrit 2003, Murty Sanskrit, Chandas, Uttara, Siddhanta, and Shobhika do a full conjunct consonant in ṣaṭtriṃśad.  The others fake it with a virāma.
  • Akshar Unicode's "prasanna" has a lazy horizontal conjunct.
  • Free Sans and Free Serif are the only fonts that distinguish Sanskrit and Hindi (see kārtsnyam).
  • Nakula, Sahadeva, Murty Hindi, Shobhika, Annapurna, Akshar Unicode, Kalimati, and Santipur do a lazy, horizontal conjunct consonant in kārtsnyam.
  • There's a special issue affecting FreeSans and FreeSerif.  I described this in a post in 2012.  The publicly distributed version of the fonts fails to make some important conjunct consonants, like त्रि and प्र correctly.  Unfortunately this issue has not changed in the intervening five years. The examples shown here use a fresh compilation of the fonts, based on downloading and compiling the development version at the Savannah repository (June 2017).  (Here's a link to my compiled fonts.)  This Savannah development version works better for  Devanagari, but has problems elsewhere, according to their author Stevan White.

Thursday, June 15, 2017

Preserve the Mess

Many years ago, I attended a Digital Humanities conference, Toronto 1989 I think it was, and heard a paper by Jocelyn Small about using digital tools to manage large datasets.  She was talking about images, but her ideas applied to any data.

One of her key slogans was, "Preserve the Mess."  This approach is now completely normalized by Google search, Google Mail, etc., and we all take it for granted.  But it's worth remembering that this was a major conceptual breakthrough.

Before this approach, everyone thought that the way to find stuff was to use subject indexes.  And subject indexing is expensive, difficult, subjective and structurally imperfect.  What subject headings would you use for the Mahābhārata, for example? I think most people would agree that it is difficult to impossible to arrive at a simple statement of the subject matter of the Mbh that is actually worth having.  Of course, we can all play nothing-buttery, "the Mbh is nothing but a family quarrel," but that's not a serious approach to the problem.  If we pervade the epic with our keywords and subject index terms, we are trying to make the text more accurate than it is, and our exercise is culture-bound and subjective.

"Preserving the mess" means that we leave the data alone.  Rather, we put the intelligence and power into our tools for accessing the data.  We use fuzzy-matching, pattern recognition, machine learning, but all applied to the raw data which is not itself manipulated or changed.

A published version of Small's ideas appeared in 1991:

As she says, p. 52,
Thus Principle Number One is Aristotelian: "Do not make your datum more accurate than it is. This principle may be rephrased as, "Preserve the Mess."

Tuesday, June 13, 2017

Del latitude xinput settings

See https://askubuntu.com/questions/688270/mouse-speed-too-fast

Put the following commands in a file (foobar.sh), make the file executable (chmod +x foobar.sh), and then run it.

#!/bin/sh
xinput --set-prop "AlpsPS/2 ALPS DualPoint Stick" "Device Accel Constant Deceleration" 8
xinput --set-prop "AlpsPS/2 ALPS DualPoint Stick" "Device Accel Velocity Scaling" .8
xinput --set-prop "AlpsPS/2 ALPS DualPoint Stick" "Device Accel Adaptive Deceleration" 8


You can run this command on startup from the Startup Applications menu.

Friday, June 09, 2017

Lining or Oldstyle numerals in math typesetting?

The classic work,


has the following remarks in paragraph 95, p. 63:
Relative size of numerals in tables.-- André says on this point: "In certain numerical tables, as those of
 Schrön, all numerals are of the same height. In certain other tables, as those of Lalande, of Callet, of Houël, of Dupuis, they have unequal heights: the 7 and 9 are prolonged downward; 3, 4, 5, 6 and 8 extend upward; while 1 and 2 do not reach above nor below the central body of the writing.... The unequal numerals, by their very inequality, render the long train of numerals easier to read; numerals of uniform height are less legible." (D. André, Des notations mathématiques (Paris, 1909), p .9).