How to add compiling time in Lyx/LaTex

Include this package in the header part,

\usepackage{datetime2}

within

\date{created on Sun Feb 13 10:00:15 AM HST 2022, last modified on \DTMnow}

Posted in Uncategorized | Leave a comment

How to convert mp4 to text using command line in Ubuntu

Convert a mp4 file into wav file

ffmpeg -i file.mp4 -ar 16000 -ac 1 file.wav

convert the wav file into a text file

pocketsphinx_continuous -infile file.wav 2> pocketsphinx.log > myspeech.txt

Posted in Uncategorized | Leave a comment

How to trim a mp4 file in Ubuntu

The following command is to trim “INPUT.mp4” from start time 00:00:00 for a total play duration of 01:33:00, and save it as “OUTPUT.mp4“. No matter what the INPUT.mp4 file size is, this command is done almost immediately.

ffmpeg -ss 00:00:00 -i INPUT.mp4 -t 01:33:00 -vcodec copy -acodec copy OUTPUT.mp4

Posted in Uncategorized | Tagged , | Leave a comment

How to use GitHub

https://guides.github.com/activities/hello-world/

Posted in Uncategorized | Leave a comment

LaTex/Lyx customized template store and use

mkdir  ~/usr/share/texlive/texmf/
cd 
ln -s  ~/usr/share/texlive/texmf/  ~/texmf
cd texmf
mkdir -p latex
# put all the necessary .bst .sty files  inn this directory
# to update TeX information
cd ~/texmf
sudo texhash

# for Lyx
# go to Tools -> Reconfigure
# this will take more than 10 seconds
# close Lyx application and restart it.
Posted in Uncategorized | Leave a comment

How to remove “Reference” section name in LaTex

\renewcommand\refname{}
Posted in Uncategorized | Leave a comment

awk – calculation of sums of rows and columns

awk command in a bash script

#!/bin/bash 
myfile="myfile.dat"
cat $myfile
echo

echo -e "\nRow sum: method 1"
awk 'BEGIN{j=1;}{
for (i=1; i<=NF; i++) 
rowsum[j]+=$i; 
j++;
};
END{
for (k in rowsum)
print "the sum of row "k" is " rowsum[k];
}' $myfile

echo -e "\nColumn sum: method 1"
awk 'BEGIN{;}{
for (i=1; i<=NF;i++) 
colsum[i]+=$i;}; 
END{
for (k in colsum) print "the sum of column "k" is " colsum[k];
}' $myfile

 

mydata.dat file

124 127 130
112 142 135
175 158 245
118 231 147
Posted in Uncategorized | Leave a comment

How to generate a unique directory for each run using Makefile

DIR_ID := $(shell date +"d%Y%m%dt%H%M%Sm%3N")
# this command will provide a directory name 
# having a format of d20201214t234015m289
# which contains date(YYYYMMDD) after the first "d"
# time (hhmmss) after "t" and millisecond (NNN) after "m".
# The millisecond is added not to have same directory names. 

all:
	@echo $(DIR_ID)
	mkdir -p $(DIR_ID)

In command line, one can execute to have 10 different directories in sequence.

$ for i in $(seq 1 10); do echo $i; make ; done

Posted in Uncategorized | Leave a comment

Emacs scroll-step

;; elisp code for Emacs to scroll every line

(setq scroll-step            1
      scroll-conservatively  100000)

Posted in Uncategorized | Leave a comment

elisp functions to change word cases backward in Emacs

(defun ask-upcase-word-backward ( ) 
         "Description: upcase-word-backward" 
         (interactive) (upcase-word -1))
(defun ask-downcase-word-backward ( ) 
         "Description: downcase-word-backward" 
         (interactive) (downcase-word -1))
(defun ask-cap-word-backward ( ) 
         "Description: capitalize-word-backward" 
         (interactive) (capitalize-word -1))
(global-set-key (kbd "s-u") 'ask-upcase-word-backward)
(global-set-key (kbd "s-c") 'ask-cap-word-backward)
(global-set-key (kbd "s-l") 'ask-downcase-word-backward)

;; s- means pressing "super-key" of a window symbol. 

Posted in elisp, emacs | Leave a comment