Zlib is a popular open-source compression library used by many software applications to compress and decompress data. While it can be installed in Ubuntu using the apt package manager, you may need to install it from the source code if the version available in the Ubuntu repositories is outdated or if you need to customize
Read more
Tag: Tutorial
How to add Chinese input method to Unbuntu 18.04?
Posted onHow to add Chinese input method, such as Pinyin, to Unbuntu 18.04? To input Chinese, first install an input method framework. Here, we use fcitx. Then you need to input the Pinyin input method. You may use fcitx-sunpinyin. Put them all together $ sudo apt-get install fcitx fcitx-sunpinyin After that, set the default input method
Read more
Thunderbird Addons to Make Thunderbird Easier to Use
Posted onThunderbird is powerful and feature rich. But different users have different needs and it is not feasible to include all features into the base software, where a plugin system shines. Thunderbird, similar to Firefox from Mozilla, supports addons/plugins and has a large ecosystems. Here, we will introduce several addons to Thunderbird that make Thunderbird easier
Read more
How to test a file or directory exists in Go?
Posted onHow to test a path (a file or directory exists) in golang? In Bash, the [ -e ] tests can test whether a file or a directory exist. What are the corresponding Go ways for the test? You can use the `os.Stat()` and `os.IsNotExist()` standard libraries functions together to test whether a file or a
Read more
How to convert a string to lower case in Python?
Posted onHow to convert a string to lower case in Python? For example: “Abc” -> “abc” “BBB” -> “bbb” “abc” -> “abc” You can use the string.lower() method of Python: string.lower(s) Return a copy of s, but with upper case letters converted to lower case. Example: $ python Python 2.7.5 (default, Apr 11 2018, 07:36:10) [GCC
Read more
How to filter bbpress content in WordPress
Posted onIn WordPress, we can filter the post content by adding a filter to the_content: add_filter('the_content', 'inline_markdown_pre_process_shortcode2', 7); But how to filter the content for bbpress contents? bbpress topic and reply (they are separated) content have their own filters: bbp_get_topic_content and bbp_get_reply_content. For example, add_filter(‘bbp_get_topic_content’, ‘my_plugin_custom_bbp_function’); add_filter(‘bbp_get_reply_content’, ‘my_plugin_custom_bbp_function’); function my_plugin_custom_bbp_function($content) { return ‘my_plugin_custom_bbp_function processed: ‘.$content; }
Call a Function by Its Name as a String in PHP
Posted onIn PHP, it is possible to call a function by its name as a string. This can be useful when the name of the function is not known until runtime, or when the name of the function is stored in a variable or retrieved from a database or other external source. To call a function
Read more
How to open a port in iptables?
Posted onHow to open a port, say 3389, in iptables to allow incoming traffics to it? There are several cases for this question: ipv4 or ipv6 or both, TCP or UDP or both and which interface? For simplicity, I give commands to allow all (ipv4 and ipv6, TCP and UDP from all interfaces) using port 3389
Read more
How to Add a File Based Swap for Linux
Posted onWe may want to add some swap space for a Linux box while only find that all disk space is partitioned and mounted. Some partition has large available free space. For such cases, we may not want to change the partition allocation. The solution may be to add a file based swap for Linux as
Read more
How to divert connection or packet before routing decision entering the default
Posted onbefore the packets ports (443) entering the firewall i would like to divert incoming packet of server (443) to input chain goes to FORWARD chain<br> so thats the incoming packets 100.43.xx.xx –sport 443 are send it to FORWARD instead of input chain<br> how to configure this in OUTPUT,FORWARD,POST AND PREROUTING CHAIN and this is my
Read more
How to check whether a file of a given path is a block device in Python?
Posted onHow to check and test whether a file of a given path is a block device in Python? This can be Linux specific. You can use the os.stat() function to get the stat of the path. Then use the stat.S_ISBLK() function against the stat’s .st_mode to test whether it is a block device. An example:
Read more
How to get the full path and directory of a Python script itself?
Posted onIn a Python script, how to get the full path and directory of the Python script itself? To get the path of the current file (the script itself), you can use __file__. To resolve any symbolic links in the path, you can use os.path.realpath(). Putting them together, you can do os.path.realpath(__file__) to get the full
Read more
How to test a file or directory exists in C++?
Posted onHow to test a path (a file or directory exists) in C++? In Bash, the [ -f ] and [ -d ] tests can test whether a file or a directory exist. What are the corresponding C++ ways for these tests? To test whether a file or dir (a path) exists, you may call stat()
Read more
How to turn off WiFi and bluetooth easily in iOS 11?
Posted onThe WiFi and bluetooth icons in iOS 11’s control center only disconnect the WiFi and Bluetooth connection being used while leave the WiFi and bluetooth enabled. This costs power. In the Settings app, the WiFi and bluetooth can be disabled totally. But the steps are tedious. How to rurn off WiFi and bluetooth easily in
Read more
How to improve video rendering quality in MPlayer
Posted onMPlayer has lots options for video rendering and filtering. Any suggestions on good MPlayer options that improve video rendering quality nicely? My ~/.mplayer/config is as follows with 2 profiles: [fast] vf=eq2 [default] vf=hqdn3d vo=gl:yuv=3:lscale=5:cscale=5 ao=pulse The default one gives good video quality by using the hqdn3d video filter while the CPU usage is high. If
Read more
How to decode a quoted URL in Python?
Posted onHow to decode a quoted URL in Python? For example, an quoted URL as follows https://www.example.com/tag/%E9%93%B6%E8%A1%8C/ should be decoded to https://www.example.com/tag/银行/ In Python 3, we can use `urllib.parse_plus()` (for URL only). One example is as follows. $ python3 Python 3.6.8 (default, Oct 7 2019, 12:59:55) [GCC 8.3.0] on linux Type “help”, “copyright”, “credits” or “license”
Read more
How to configure /dev/shm size of Linux?
Posted on/dev/shm is a nice in memory disk on Linux. The default size seems half of the physical memory’s size. How to configure shm size of Linux? And what’s the consequence? To change the configuration for /dev/shm, add one line to /etc/fstab as follows. tmpfs /dev/shm tmpfs defaults,size=8g 0 0 Here, the /dev/shm size is configured
Read more
How to produce a patch file for a specific git commit?
Posted onHow to produce a patch file for a specific git commit so that the changes in that commit can be emailed/sent? git show 550a38b52 generate a quite close content while it is not exactly a patch. You can use this command git format-patch -1 550a38b52 It will generate a file like 0001-<commit-title>.patch in the current
Read more
How to exclude a package from a specific repository only in yum?
Posted onThis post https://www.systutorials.com/1661/making-dnf-yum-not-update-certain-packages/ introduces how to exclude a package from yum. But is it possible to exclude a package from a specific repository only? For example, a repository R1 I am using contains an updated version of gdb while I don’t want to use the gdb from it as I trust the version (although older)
Read more
How to clean the commit history of a repository?
Posted onHow to clean the commit history of a repository in both of my locally cloned copy and the copy on the git server so that only the files after the last commit are left? git works in branches. Here, we assume removing the history of the master branch. One solution is doing as follows. Rename
Read more