Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts

Friday, October 13, 2023

xdotool workaround for opening an email in conversation view in thunderbird 115.3.1

With a recent update of Thunderbird, I've noticed that when I open an
email with conversation view (with Ctrol+Shift+O), the messages are
not properly sorted anymore. I had to click the sort-by-date menu and
sort-by-thread menu, respectively, every time.
 

I've written a script to automate that boring process as you can see below.

#!/usr/bin/bash

xdotool mousemove 500 500
xdotool click 1
xdotool key ctrl+shift+o
sleep 1
xdotool key --delay 100 alt+v s e
sleep 1
xdotool key ctrl+shift+o
sleep 1
xdotool key --delay 100 alt+v s t
sleep 1
xdotool key 0x002a
xdotool mousemove 500 335

I store this script in dom0 and name it xdo-thread. I map this script
with F5 key. Now, every time I want to see the messages in
conversation view, I simply press F5. 


There's one tricky part I'd like to point out. The line "xdotool click 1" is a trick. Without it, we can't use "xdotool key". I'm not sure what the reason is yet. Maybe it's about window focus.

Monday, May 8, 2023

How to enter unicode character in Linux?

You can enter unicode character in Linux by:

    Ctrl + Shift + u

follows by the unicode number, e.g., 1F43E for the Paw Prints character.

Tuesday, May 25, 2021

VirtualBox Running Slow - Windows 10 - Power Mode: High Performance

 Windows 10 Guest running on Debian Host


Very slow all of a sudden


This time I could fix it by setting Windows 10's Power Mode to be High Performance
This started happening for me too, after the Win 10 1803 update. Super annoying.

But I found that Windows 10 Pro users can lock in the power plan using Group Policy Editor

First set the power plan, but don't reboot right away.
To do this, run CMD prompt as admin
In the command prompt, type powercfg –restoredefaultschemes and press Enter.
Go to Control Panel > Power Options and select "High Performance" from Control Panel > Power Options, but do not reboot the PC yet.
Make whatever custom changes you want to your High Performance plan using Change plan settings > Change advanced power settings, but still do not reboot the PC yet

Now from the taskbar search type gpedit.msc and run as admin
This opens Group Policy Editor
Navigate to Computer Configuration -> Administrative Templates -> System -> Power Management
In the right hand pane double click on "Select an active power plan"
In the window that pops up select "Enabled"
This will allow you to then select "High Performance" from the drop down menu
Select Apply and OK to close out
Now reboot the PC.

Now when you go to Control Panel > Power Options it will say "Some settings are managed by your system administrator", with the options below that grayed out. But you should be able to see below that it's set at High Performance, even though the option to change settings will be grayed out as it's now handled by Group Policy Editor.

If you don't do the first part of these instructions which include setting your plan before using Group Policy Editor, then Group Policy Editor will just set whatever the default is for High Performance. This may not include all the power options you want. So be sure to set the power plan options first before using Group Policy Editor to lock in the changes



 

Ref:

  • https://silicophilic.com/virtualbox-running-slow/
  • https://answers.microsoft.com/en-us/windows/forum/windows_10-other_settings-winpc/windows-power-plan-will-not-changewindows10/254d2a4e-7fda-4e2b-bf98-acef8e6e0eb1

Sunday, August 2, 2020

OCR on Linux

How to grep text from an image file

`sudo apt-get install tesseract-ocr`

`sudo dnf install tesseract`

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
"""

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

Saturday, November 23, 2013

Saturday, June 8, 2013

split multi pages pdf into mutiple jpeg files

convert -quality 100 -density 300x300 multi_pages.pdf single%d.jpg

Sunday, May 12, 2013

debian 7.0 64-bit and firefox

If you want to install Firefox (32-bit) on Debian 7.0 (64-bit), you have to install the 2 packages:
  • ia32-libs
  • ia32-libs-gtk

Tuesday, April 30, 2013

debian start-stop-daemon issue

Fresh installed debian, you may find empty (exit 0;) /sbin/start-stop-daemon file which causes you be unable to start sshd, for example.  To resolve this:

apt-get install --reinstall dpkg

Friday, April 26, 2013

how to change default kernel selection at boot time - linux

สุดท้ายแก้ไขไปพลางด้วยการ vi /etc/default/grub ใส่ DEFAULT="1>2" ตามด้วย update-grub ใช้ kernel 3.5.0-26 ไปก่อนดีกั่ว

Friday, April 19, 2013

how to record desktop screen in linux

ffmpeg -f x11grab  -s 1680x1050 -r 25 -i :0.0 -sameq live_streaming_issue.mpg

Tuesday, April 16, 2013

how to limit number of connections to server per second with iptables

# 2 hits per second per ip address

iptables -A INPUT -p tcp --dport 80 -i eth0 -m state --state NEW -m recent --set
iptables -A INPUT -p tcp --dport 80 -i eth0 -m state --state NEW -m recent --update --seconds 1 --hitcount 2 -j DROP

iptables -A INPUT -p tcp --dport 443 -i eth0 -m state --state NEW -m recent --set
iptables -A INPUT -p tcp --dport 443 -i eth0 -m state --state NEW -m recent --update --seconds 1 --hitcount 2 -j DROP


Sunday, March 31, 2013

how to change your dm-crypt passphrase

  1. Assuming your encrypted partition is /dev/sda5 (crypttab would say sda5_crypt)
  2. add new key: cryptsetup luksAddKey /dev/sda5
  3. reboot and test
  4. remove old key: cryptsetup luksRemoveKey /dev/sda5

Reference


Saturday, March 23, 2013

how to limit number of connections to our server per period of time with iptables

sample - allow 2 hits once every 3 seconds

iptables -A INPUT -p tcp --dport 80 -i eth0 -m state --state NEW -m recent --set
iptables -A INPUT -p tcp --dport 80 -i eth0 -m state --state NEW -m recent --update --seconds 3 --hitcount 2 -j DROP

Wednesday, February 27, 2013

debian fresh install can't start services under /etc/init.d

If for any reason you can't start any services under /etc/init.d after a fresh installation of debian, you may try "apt-get install --reinstall dpkg"

Saturday, February 9, 2013

how to mount samba fs to directory in linux


mount //some_server/share /home/grml/smbfs/share -o "user=share,password=****,uid=grml,gid=grml"

but if your password is complex (e.g. contains special characters), better use -o "credentials=/path/to/credential"

credential file format is:

username
password

On Debian 7.0, you will need to "apt-get install cifs-utils" first to get mount.cifs.