If git complains about "server certificate verification failed", see https://stackoverflow.com/questions/21181231/server-certificate-verification-failed-cafile-etc-ssl-certs-ca-certificates-c
When developing stuff, configuring systems, or simply working with computers, I come across obstacles that can be solved easily once you know the solution. But finding the solution can take ages. In this blog, I am collecting the solutions for some of the technical problems that I encounter.
Wednesday, September 12, 2018
Thursday, August 25, 2016
Renaming branches in git
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
(source)
Tuesday, June 21, 2016
[Ubuntu] Install missing LaTeX packages
Here is a script that installs missing LaTeX packages.
#!/bin/bash
EMPHASISCOLOR="\e[7m"
RESETEMPHASIS="\e[27m"
DEFAULTCOLOR="\e[39m"
GREENCOLOR="\e[32m"
LIGHGRAYCOLOR="\e[37m"
BLUECOLOR="\e[34m"
YELLOWCOLOR="\e[93m"
echo -e "************************************************************************"
echo -e "* LaTeX Package Installer"
echo -e "************************************************************************"
printf "* Checking dependencies....... "
# check if required programs are installed
hash apt-file 2>/dev/null || { echo >&2 "false\nI require apt-file but it's not installed. Aborting."; exit 1; }
echo -e "${GREENCOLOR}ok${DEFAULTCOLOR}"
printf "* Packet name................. "
if [ -z "$1" ]; then
echo -e "${YELLOWCOLOR}Please provide a packet name as argument$DEFAULTCOLOR";
exit 1
else
PACKETNAME=$1;
echo -e "${GREENCOLOR}$PACKETNAME$DEFAULTCOLOR";
fi
RESULT=`apt-file -x search "/${PACKETNAME}$"`
# if package is found, result is
# texlive-latex-extra: /usr/share/texlive/texmf-dist/tex/latex/preprint/balance.sty
# otherwise, result is empty
# exit code from apt-file is 0 in either case
IFS=':' read -a myarray <<< "$RESULT"
APTPACKAGE=${myarray[0]}
printf "* Result...................... "
if [[ $RESULT ]]; then
echo -e "${GREENCOLOR}$APTPACKAGE$DEFAULTCOLOR";
else
echo -e "${YELLOWCOLOR}no apt package found$DEFAULTCOLOR";
exit 0
fi
echo "* Installing APT package...... "
sudo apt-get install $APTPACKAGE
echo -e "************************************************************************"
exit 0
#!/bin/bash
EMPHASISCOLOR="\e[7m"
RESETEMPHASIS="\e[27m"
DEFAULTCOLOR="\e[39m"
GREENCOLOR="\e[32m"
LIGHGRAYCOLOR="\e[37m"
BLUECOLOR="\e[34m"
YELLOWCOLOR="\e[93m"
echo -e "************************************************************************"
echo -e "* LaTeX Package Installer"
echo -e "************************************************************************"
printf "* Checking dependencies....... "
# check if required programs are installed
hash apt-file 2>/dev/null || { echo >&2 "false\nI require apt-file but it's not installed. Aborting."; exit 1; }
echo -e "${GREENCOLOR}ok${DEFAULTCOLOR}"
printf "* Packet name................. "
if [ -z "$1" ]; then
echo -e "${YELLOWCOLOR}Please provide a packet name as argument$DEFAULTCOLOR";
exit 1
else
PACKETNAME=$1;
echo -e "${GREENCOLOR}$PACKETNAME$DEFAULTCOLOR";
fi
RESULT=`apt-file -x search "/${PACKETNAME}$"`
# if package is found, result is
# texlive-latex-extra: /usr/share/texlive/texmf-dist/tex/latex/preprint/balance.sty
# otherwise, result is empty
# exit code from apt-file is 0 in either case
IFS=':' read -a myarray <<< "$RESULT"
APTPACKAGE=${myarray[0]}
printf "* Result...................... "
if [[ $RESULT ]]; then
echo -e "${GREENCOLOR}$APTPACKAGE$DEFAULTCOLOR";
else
echo -e "${YELLOWCOLOR}no apt package found$DEFAULTCOLOR";
exit 0
fi
echo "* Installing APT package...... "
sudo apt-get install $APTPACKAGE
echo -e "************************************************************************"
exit 0
Wednesday, June 15, 2016
Calculating statistics on the output EasyPMD's Copy/Paste Detector
Here is a shell script that computes the number of duplicate code segments and the total number of copied lines based on the output of EasyPMD's Copy/Paste Detector. This output is structured by segments starting with:
Found a x line (y tokens) duplication in the following files:
The script extracts these lines and sums up the occurrences and number of lines.
#!/bin/bash
if [[ $# -eq 0 ]] ; then
echo 'Please specify a file name.'
exit 0
fi
# Extract strings like:
# Found a X line (Y tokens) duplication in the following files:
cat $1 | grep Found > tmp.txt
# define counters
sum_lines=0
occurrences=0
# parse temp file and extract # of lines
while read line
do
tmp=(`echo $line | tr ' ' ' '`)
lines=${tmp[2]}
sum_lines=`expr $sum_lines + $lines`
occurrences=`expr $occurrences + 1`
done < tmp.txt
rm tmp.txt
echo "$occurrences code duplicates, $sum_lines lines in total."
Found a x line (y tokens) duplication in the following files:
The script extracts these lines and sums up the occurrences and number of lines.
#!/bin/bash
if [[ $# -eq 0 ]] ; then
echo 'Please specify a file name.'
exit 0
fi
# Extract strings like:
# Found a X line (Y tokens) duplication in the following files:
cat $1 | grep Found > tmp.txt
# define counters
sum_lines=0
occurrences=0
# parse temp file and extract # of lines
while read line
do
tmp=(`echo $line | tr ' ' ' '`)
lines=${tmp[2]}
sum_lines=`expr $sum_lines + $lines`
occurrences=`expr $occurrences + 1`
done < tmp.txt
rm tmp.txt
echo "$occurrences code duplicates, $sum_lines lines in total."
Wednesday, May 18, 2016
Disabling the right button field on the Thinkpad T440 trackpad
Thursday, March 10, 2016
Make Virtualbox guests use the host's VPN connection
In my home office my guest OS in Virtualbox was not able to use its host's VPN connection. As shown here, VBoxManage can do the trick:
VBoxManage list vms
VBoxManage modifyvm <uuid here> --natdnshostresolver1 on
Thursday, December 10, 2015
Subscribe to:
Posts (Atom)