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

To have a wide equation or content in a two-column document: LaTex and Lyx

% in header 
\usepackage{cuted}
\usepackage{flushend}
 
% in document
\begin{strip}
blalblal 
\end{strip} 
Posted in LaTex, Lyx | Leave a comment

Appendix decoration

Add the following lines at the end of LaTex or Lyx file

\appendix
\setcounter{figure}{0} 
\renewcommand\thefigure{A.\arabic{figure}} 
\begin{appendices}  
\include{AFPD-p9-Appendix}              
\end{appendices} 
Posted in LaTex, Lyx | Leave a comment