Skip to content

SysTutorials

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

  • QA

    How to not use concrete types in lambda function parameters in C++11?

    ByEric Ma Mar 24, 2018Nov 21, 2019

    C++11 requires that lambda function parameters be declared with concrete types. This is sometimes annoying. auto is really nice, especially when the type is complex like std::vector<std::string>::iterator is quite long to type. I know C++14 allows auto in lambda functions. But how to not use concrete types in lambda function parameters in C++11? In C++11,…

    Read More How to not use concrete types in lambda function parameters in C++11?Continue

  • Programming | QA | Tutorial

    Checking Whether a String Starts with Another String in C++

    ByEric Ma Mar 24, 2018May 1, 2023

    In many text processing tasks, we often need to check if a given string starts with a specific substring. In this article, we will demonstrate how to achieve this using the std::string::compare() function from the C++ Standard Library. The compare() function has several overloads, but the one of interest for our purpose is: int compare(size_type…

    Read More Checking Whether a String Starts with Another String in C++Continue

  • Tutorial

    How to escape special characters in a Bash string in Linux?

    ByQ A Mar 24, 2018Aug 9, 2020

    The problem is with ssh that makes a quoted string to more than one if there are spaces. For example, ssh user@host cmd “my string” The cmd on host will be executed like cmd my string rather than cmd “my string” It will only work if the string is escaped like ssh user@host cmd my…

    Read More How to escape special characters in a Bash string in Linux?Continue

  • Programming | QA | Tutorial

    `readlink -m` equivalent function in Python to get canonical file name

    ByQ A Mar 24, 2018Oct 9, 2020

    readlink -m can get canonical file name by resolving every symlinks in every component of the given path recursively. In Python, the os.readlink() function does not do so. Any equivalent function in Python to the readlink -m command line? Specifically, it does: canonicalize by following every symlink in every component of the given name recursively,…

    Read More `readlink -m` equivalent function in Python to get canonical file nameContinue

  • QA | Tutorial

    How to generate a password in Shell on Linux?

    ByQ A Mar 24, 2018Nov 21, 2019

    Admins usually need to generate some passwords for others, such as when creating a new user in a Linux system. How to generate a password in Shell on Linux? Several possible and short methods. Here, we generate a password of length 8. Using pwgen: $ pwgen 8 1 dao3PaW9 Password based on base64 (note that…

    Read More How to generate a password in Shell on Linux?Continue

  • Tutorial

    How to split and iterate a string separated by a specific character in C++?

    ByEric Ma Mar 24, 2018Aug 9, 2020

    How to split and iterate a string separated by a specific character in C++? For example, “a string separated by space” by ‘ ‘=> [“a”, “string”, “separated”, “by”, “space”] and “a,string,separated,by,comma” by ‘,’ => [“a”, “string”, “separated”, “by”, “comma”] C++ standard library’s getline() function can be used to build a function. getline() can accept a…

    Read More How to split and iterate a string separated by a specific character in C++?Continue

  • QA

    Hiding Private IP from Email Headers in Thunderbird

    ByEric Ma Mar 24, 2018Sep 18, 2021

    It seems Thunderbird sends out my private/lan IP to the SMTP server. For example, in an Email sent out by Thunderbird, the header contains Received: from [192.168.1.2] (example.com [1.2.3.4]) by mail.example.com (Postfix) with ESMTPSA id 92CD297DEA; It is fine that the SMTP server records the public IP (1.2.3.4) as it is what it sees. But…

    Read More Hiding Private IP from Email Headers in ThunderbirdContinue

  • QA

    How to make Vim indent C++11 lambdas correctly?

    ByEric Ma Mar 24, 2018Nov 21, 2019

    Vim seems not indent C++11 lambas very well. How to make Vim indent C++11 lambdas correctly? For this following program, Vim indents it as #include <iostream> #include <string> #include <vector> #include <algorithm> int main () { std::vector<std::string> strs({“one”, “two”}); std::vector<std::string> newstrs; std::transform(strs.begin(), strs.end(), std::back_inserter(newstrs), [](const std::string& s) -> std::string { if (s == “one”) {…

    Read More How to make Vim indent C++11 lambdas correctly?Continue

  • QA

    How to operator[] access element in a const map in C++?

    ByEric Ma Mar 24, 2018Nov 21, 2019

    How to operator[] access element in a const map in C++? For example, the compiler will report error on this piece of code: #include <iostream> #include <string> #include <map> std::int64_t count(const std::map<std::string, std::int64_t>& map) { return map[“one”] + map[“two”]; } int main () { std::map<std::string, std::int64_t> map = { {“one”, 1}, {“two”, 2} }; std::cout…

    Read More How to operator[] access element in a const map in C++?Continue

  • QA

    How to enable Email address auto completion in Evolution?

    ByEric Ma Mar 24, 2018Nov 21, 2019

    Does Evolution support automatic email address filling/completing in the “To” or “CC” fields which is commonly seen in other Email clients such as Thunderbird. Is is possible and how to enable Email address auto completion in Evolution? Evolution supports the contact autocompletion. To enable it, do as follows in Evolution. In Evolution Preferences dialog, in…

    Read More How to enable Email address auto completion in Evolution?Continue

  • QA

    Making Evolution Not Wrap Lines in Composed Emails

    ByEric Ma Mar 24, 2018Sep 18, 2021

    Evolution seems wrap long lines automatically in “Plain Text” mode. How to make Evolution not wrap lines in composed Emails? Evolution does not have (so far) “Flowing Text” mode where “the text is soft broken at the composer edge, but those soft breaks aren’t translated to hard breaks when the mail is sent” ( Reference:…

    Read More Making Evolution Not Wrap Lines in Composed EmailsContinue

  • QA

    How to list start and end sectors of a partition by parted in Linux?

    ByEric Ma Mar 24, 2018Nov 21, 2019

    How to list start and end of a partition by the sectors in parted on Linux? The default behavior seems be listing the start and end by bytes in parted. # parted /dev/sdc print Model: Innostor IS888 ext. HDD (scsi) Disk /dev/sdc: 2000GB Sector size (logical/physical): 512B/512B Partition Table: gpt Disk Flags: Number Start End…

    Read More How to list start and end sectors of a partition by parted in Linux?Continue

  • QA

    How to apply the Email sort order to all folders in Evolution?

    ByEric Ma Mar 24, 2018Nov 21, 2019

    Evolution’s default Email sort order is not very convenient, at least to me. How to apply the settings of sort order for a folder to all folders in Evolution? Manually setting the email sort order for each dir is tedious. Evolution has a function to “apply the same view settings to all folder” so that…

    Read More How to apply the Email sort order to all folders in Evolution?Continue

  • QA

    Why I cannot login remote server with its root

    ByWeiwei Jia Mar 24, 2018Jan 7, 2020

    # ssh root@192.168.122.96 root@192.168.122.96’s password: Permission denied, please try again. Do according to [1]. NOTE: on Ubuntu, remember to restart ssh service like this “sudo restart ssh”. [1] https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/v2v_guide/preparation_before_the_p2v_migration-enable_root_login_over_ssh

    Read More Why I cannot login remote server with its rootContinue

  • QA

    How to search history commands very effectively in bash shell command line?

    ByWeiwei Jia Mar 24, 2018Jan 7, 2020

    How to search history commands very effectively in bash shell command line? Just enter CTRL+r The function of above is: (reverse-i-search)`’: It is very fast and efficient.

    Read More How to search history commands very effectively in bash shell command line?Continue

  • Programming | QA | Tutorial

    How to iterate all dirs and files in a dir in C++?

    ByDavid Yang Mar 24, 2018Oct 9, 2020

    How to iterate all dirs and files in a dir in C++? To open a dir, we can use opendir() to open a directory stream. DIR *opendir(const char *name); Then we can use readdir() to iterate the directory stream. struct dirent *readdir(DIR *dirp); Here is an example C++ program using these 2 library functions. #include…

    Read More How to iterate all dirs and files in a dir in C++?Continue

  • QA

    How to check CPU working frequency in iOS on iPhone?

    ByEric Ma Mar 24, 2018Nov 21, 2019

    How to check CPU working frequency in iOS on iPhone, such as my iPhone 6? The Litum Info Lite free app (Litum Info full version app) can show you the info of CPU including its frequency. The CPU frequency: You can find the CPU info page from the menu:

    Read More How to check CPU working frequency in iOS on iPhone?Continue

  • Software | Tutorial

    How to unignore some files or dirs in git?

    ByEric Ma Mar 24, 2018Nov 24, 2019

    I set up rules to ignore all files under git by adding a .gitignore like * But how to unignore some files or dirs in git? For example unignore all files under ./bin/tool1/ under the git repository. You can use patterns with ! as the prefix to “unignore” files. From gitignore man page: An optional prefix “!”…

    Read More How to unignore some files or dirs in git?Continue

  • Programming | QA | Tutorial

    How to get a path’s mtime in C++ on Linux?

    ByEric Ma Mar 24, 2018Oct 9, 2020

    How to get a path’s mtime in C++ on Linux? The path can be a file or a dir. You may call the standard library function lstat() for the file or dir under the path. int lstat(const char *pathname, struct stat *statbuf); From the returned stat struct, there is a field st_mtim which is the…

    Read More How to get a path’s mtime in C++ on Linux?Continue

  • Programming | Tutorial

    How to remove newline characters from a string in C++?

    ByEric Ma Mar 24, 2018Feb 20, 2020

    How to remove newline characters from a string in C++? For example, a string like line 1 line 3 line 4 should be converted to line 1line 3line 4 Method 1: use `erase()` and `remove()` In short, use this code snippet: input.erase(std::remove(input.begin(), input.end(), ‘\n’), input.end()); std::remove() shifts all elements that are equal to the value…

    Read More How to remove newline characters from a string in C++?Continue

Page navigation

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

© 2026 SysTutorials

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