In Ubuntu, if you get:
Error: No word lists can be found for the language “en_US”.
when trying to start ispell (e.g., M-x ispell-buffer) from Emacs, then you need to install the aspell-en package:
sudo apt-get install aspell-en
In Ubuntu, if you get:
Error: No word lists can be found for the language “en_US”.
when trying to start ispell (e.g., M-x ispell-buffer) from Emacs, then you need to install the aspell-en package:
sudo apt-get install aspell-en
In Emacs, you can not only select by lines, but also by columns. If you select by columns, the selection is called a rectangle. You can use rectangles with the following shortcuts:
To insert sequential values into a container, you could use the iota function available in ext/numeric header. For example:
#include <ext/numeric>
#include <vector>
…
std::vector<int> v(5);
__gnu_cxx::iota(v.begin(), v.end(), 0);
v will contain {0, 1, 2, 3, 4}.
For more information see sgi documentation
In order to convert a string to HTML/XML entities you can use:
”.join(['&#%d;' % ord(ch) for ch in text])
For example if text=’mailto’ the output would be:
‘& #109;& #97;& #105;& #108;& #116;& #111;’
This might be useful in hiding email addresses in web pages.
In order to swap the Ctrl and Caps Lock keys in X11, you can add the following line in Section “InputDevice” of file /etc/X11/xorg.conf:
Option “XkbOptions” “ctrl:swapcaps”
If you woud like to keep the Ctrl where it is and make Caps Lock act as a Ctrl also, you can add:
Option “XkbOptions” “ctrl:nocaps”
In order to generate a large file of a set size you can use:
dd if=/dev/zero of=test100M.bin bs=100000000 count=1
where of is the output file and bs is its size in bytes.
In C++, if you declare a template class and you would like to have a friend function that has an argument of the current class type, you need to be careful when specifying the name of the template types. For example:
template <class T>
class A {
…
template <class T>
friend void b(A<T> a);
} ;
Will confuse the compiler, as you use the same template name, T, for the class template and the function template type. What you need to do, it to use a different name for the function template type:
template <class T>
class A {
…
template <class V>
friend void b(A<V> a);
} ;
Notice that I used T for the class template type and V for the function template type.
Sometimes you might need to redirect the output with sudo privileges. For example:
echo myhost.com > /etc/hostname
will give you the following error:
-bash: /etc/hostname: Permission denied
Unfortunately, using:
sudo echo myhost.com > /etc/hostname
will give the same error.
The solution is to start bash as sudo and then give the entire command to bash as input:
sudo bash -c “echo myhost.com > /etc/hostname”
To convert an std::string to upper case you can use the following:
#include <algorithm>
#include <string>
…
std::string data = “Abc”;
std::transform(data.begin(), data.end(),
data.begin(), ::toupper);
For converting to lower case, you need to replace ::toupper with ::tolower.
Here is a way to trim the white space from a string in Javascript:
replace(/^\s+|\s+$/g, ”)
By removing |\s+$ it will do a left trim only, and by removing ^\s+| it will do a right trim only (g is no longer necessary).