Thursday, November 29, 2018

การใช้งาน LaTeX ภาษาไทย

สามารถทำการติดตั้ง LaTeX ที่รองรับภาษาไทยได้ดังนี้

สมมติว่าใช้ Debian

ติดตั้ง LaTeX และ Thai Font ดังนี้:

  $ sudo apt-get install texlive-xetex
  $ sudo apt-get install fonts-thai-tlwg

สร้างไฟล์ LaTeX แบบนี้:

"""
\documentclass[a4paper]{article}

% [begin] required settings from
% http://thaitug.daytag.org/wordpress/?p=1947
\usepackage{fontspec}
\usepackage{polyglossia}
\usepackage[Latin,Thai]{ucharclasses}
\defaultfontfeatures{Mapping=tex-text}
\setdefaultlanguage{thai}
\setotherlanguage{english}
\newfontfamily{\thaifont}[Scale=MatchUppercase,Mapping=tex-text]{Norasi:script=thai}
\setTransitionTo{Thai}{\thaifont}
\setTransitionFrom{Thai}{\normalfont}
\XeTeXlinebreaklocale “th_TH”
\XeTeXlinebreakskip = 0pt plus 1pt
\linespread{1.5}
% [end] required settings from ...
...
"""

คอมไพล์ไฟล์ให้เป็น pdf แบบนี้:

  $ xelatex foo.tex
  $ xelatex foo.tex
  $ xelatex foo.tex

loop through list of filenames which contain space characters in bash

"""
#!/bin/bash
SAVEIFS=$IFS
IFS=$(echo -en "\n\b")
for f in *
do
  echo "$f"
done
IFS=$SAVEIFS
"""

Monday, October 8, 2018

how to save and restore session with vim

  • open vi, do anything you want to do
  • :mksession!
  • quite vi
  • open vi again and load the saved session with:
  • :so Session.vim


Saturday, September 22, 2018

intermittent disconnection with mysql

max connections
max open files limit
limit_nofile limitnofile

http://vswsystems.com/mysql-buffered-warning-changed-limits-max_connections-214-requested-800/

Thursday, September 20, 2018

libreoffice calc function to format value into date string

TEXT(C2,"yyyy-mm-dd")

Friday, August 10, 2018

how to convert text file into png using imagemagick

# disable policy "path" at /etc/ImageMagick-6/policy.xml

then

convert -trim +repage -font FreeMono -size 1200x1200 -border 2 \
-pointsize 18 label:@trip_itinerary trip_itinerary.png

You may want to adjust the number 1200x1200 to be something bigger as needed which depends on the size of your input text file (trip_itinerary in this example).

Wednesday, May 16, 2018

how to manually boot linux installed on a harddisk using live cd

- boot a linux live cd
- press C on the grub screen to enter grub console
- ls
- ls (hd1,msdos3)/boot/grub
- ls (hd1,msdos3)/home
- set root=(hd1,msdos3)
- ls -l (hd1,msdos3)
- linux /boot/vmlinuz [tab] root=UUID=...
- initrd /boot/initrd [tab]
- boot

reference:
  • https://askubuntu.com/questions/516535/how-can-i-use-the-installer-to-manually-boot-into-a-system-without-grub-installe

Wednesday, May 9, 2018

How to reset Windows 7 password

Change into the Windows/System32/config directory.

sudo chntpw SAM
sudo chntpw -l SAM
sudo chntpw -u "USER NAME" SAM


https://www.techrepublic.com/blog/tr-dojo/reset-windows-passwords-with-the-help-of-linux/

Tuesday, May 8, 2018