Skip to content

SysTutorials

  • Tutorials
  • Linux
  • Linux Manuals
  • Systems
  • Programming
  • Software
  • Subscribe
  • Search
SysTutorials

  • QA | Tutorial

    Call a Function by Its Name as a String in PHP

    ByQ A Apr 8, 2018Mar 26, 2023

    In 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 Call a Function by Its Name as a String in PHPContinue

  • Linux | Programming | Software | Tutorial

    Handling Sparse Files on Linux

    ByEric Ma Apr 5, 2018Nov 21, 2019

    Sparse files are common in Linux/Unix and are also supported by Windows (e.g. NTFS) and macOSes (e.g. HFS+). Sparse files uses storage efficiently when the files have a lot of holes (contiguous ranges of bytes having the value of zero) by storing only metadata for the holes instead of using real disk blocks. They are…

    Read More Handling Sparse Files on LinuxContinue

  • QA | Tutorial

    gdb like step by step debugger for Python

    ByQ A Apr 4, 2018Nov 22, 2019

    Any good debugger for Python that is like gdb so that the code can be executed step by step for debugging purpose? You might check pdb. You can debug a program such as prog.py by invoking it through pdb: python -m pdb prog.py Common gdb commands can be found in pdb: (Pdb) h Documented commands…

    Read More gdb like step by step debugger for PythonContinue

  • QA | Tutorial

    How to open a port in iptables?

    ByQ A Apr 4, 2018Mar 30, 2026

    How 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 open a port in iptables?Continue

  • Linux | Tutorial

    How to Add a File Based Swap for Linux

    ByEric Ma Apr 3, 2018Nov 21, 2019

    We 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 Add a File Based Swap for LinuxContinue

  • QA | Tutorial

    How to divert connection or packet before routing decision entering the default

    ByQ A Apr 2, 2018Nov 22, 2019

    before 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 divert connection or packet before routing decision entering the defaultContinue

  • QA | Tutorial

    How to check whether a file of a given path is a block device in Python?

    ByQ A Apr 2, 2018Nov 22, 2019

    How 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 check whether a file of a given path is a block device in Python?Continue

  • QA | Tutorial

    How to get the full path and directory of a Python script itself?

    ByQ A Apr 1, 2018Nov 22, 2019

    In 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 get the full path and directory of a Python script itself?Continue

  • QA | Tutorial

    How to test a file or directory exists in C++?

    ByQ A Apr 1, 2018Nov 22, 2019

    How 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 test a file or directory exists in C++?Continue

  • QA | Tutorial

    How to turn off WiFi and bluetooth easily in iOS 11?

    ByQ A Apr 1, 2018Nov 22, 2019

    The 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 turn off WiFi and bluetooth easily in iOS 11?Continue

  • QA | Tutorial

    How to improve video rendering quality in MPlayer

    ByQ A Apr 1, 2018Oct 9, 2020

    MPlayer 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 improve video rendering quality in MPlayerContinue

  • Tutorial

    How to decode a quoted URL in Python?

    ByEric Ma Apr 1, 2018Mar 30, 2026

    How 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 decode a quoted URL in Python?Continue

  • QA | Tutorial

    How to configure /dev/shm size of Linux?

    ByQ A Apr 1, 2018Nov 22, 2019

    /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 configure /dev/shm size of Linux?Continue

  • QA | Tutorial

    How to produce a patch file for a specific git commit?

    ByEric Ma Mar 30, 2018Nov 22, 2019

    How 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 produce a patch file for a specific git commit?Continue

  • QA | Tutorial

    How to exclude a package from a specific repository only in yum?

    ByQ A Mar 29, 2018Nov 22, 2019

    This 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 exclude a package from a specific repository only in yum?Continue

  • QA | Tutorial

    How to clean the commit history of a repository?

    ByQ A Mar 28, 2018Nov 22, 2019

    How 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 How to clean the commit history of a repository?Continue

  • QA | Tutorial

    How to escape the XML CData section ending sequence `]]>`?

    ByQ A Mar 26, 2018Nov 22, 2019

    How to escape the XML CData section ending sequence ]]>? The ]]> sequence itself may be part of the content in a CData section. One solution is to split the ]]> token into 2 CData sections. <![CDATA[to split the ]]]]><![CDATA[> token ]]>

    Read More How to escape the XML CData section ending sequence `]]>`?Continue

  • QA

    How to resize a virtual disk of KVM

    ByWeiwei Jia Mar 24, 2018Jan 7, 2020

    I test it for qcow2 format. Other formats are TBA. qemu-img resize kvm1.qcow2 +20G cp kvm1.qcow2 kvm1-orig.qcow2 virt-resize –expand /dev/sda1 kvm1-orig.qcow2 kvm1.qcow2 Reference: https://fatmin.com/2016/12/20/how-to-resize-a-qcow2-image-and-filesystem-with-virt-resize/ I test it for qcow2 format. Other formats are TBA. qemu-img resize kvm1.qcow2 +20G cp kvm1.qcow2 kvm1-orig.qcow2 virt-resize –expand /dev/sda1 kvm1-orig.qcow2 kvm1.qcow2 Reference: https://fatmin.com/2016/12/20/how-to-resize-a-qcow2-image-and-filesystem-with-virt-resize/

    Read More How to resize a virtual disk of KVMContinue

  • QA | Tutorial

    How to create a file if not exist and open it in read and write modes in C++?

    ByQ A Mar 24, 2018Nov 21, 2019

    How to create a file if not exist and open it in read and write modes in C++? For example, I would like open a fstream on /tmp/cache to be able to read it and append to it. If the file does not exist yet, create one. A simple code like std::fstream fs(“/tmp/cache”, std::ios::in |…

    Read More How to create a file if not exist and open it in read and write modes in C++?Continue

  • Tutorial

    How to test whether a file exists and is a block special file in Python on Linux?

    ByQ A Mar 24, 2018Aug 9, 2020

    Bash has a -b test to test whether a file exists and is a block special file. -b file True if file exists and is a block special file. How to do this in Python? Python’s stat module provides the similar functions for the C standard APIs and macros underlining such as stat() and S_ISBLK()….

    Read More How to test whether a file exists and is a block special file in Python on Linux?Continue

Page navigation

Previous PagePrevious 1 … 7 8 9 10 11 … 70 Next PageNext

© 2026 SysTutorials

  • Tutorials
  • Linux
  • Linux Manuals
  • Systems
  • Programming
  • Software
  • Subscribe
  • Search