Instead of poluting your otherwise pristine aliases file, include larger files using this syntax:
all_users: ":include:/filename"
This will allow you to email all_users@localhost and get all the users in the referenced file.
aliasesconfigurationmailmtasendmailserversyntax
Use the form ::type to ensure that a value is cast to the proper type:
SELECT * FROM table WHERE column = 5::bigint;
In this case, column is indexed and is a bigint. The index will not be used if the query planner doesn't encounter a value of the index type. Note: this only applies in PostgreSQL 7.x.
gotchaindexperformancepostgresqlsqlsyntaxtypes
If you like working with a dark background and enjoy syntax highlighting but hate the navy blue on black, try putting the following line in your ~/.vimrc:
set background=dark
backgroundconfigurationeditorshighlightingsyntaxvimvimrc
Apparently Python only recognizes a doc string a litteral string placed after a function definition, meaning it won't accept an interpolated string, or even 'a'+'b', for whatever reason. For example:
>>> def doc(): ... '''Useful info. Note: %s''' % 'You'll never see this.' ... print doc.__doc__ >>> doc() None
To work around this you must explicitly set __doc__. Example:
>>> def doc(): ... doc.__doc__ = '''Useful info. Note: %s''' % 'Bacon is yummy!' ... print doc.__doc__ >>> doc() Useful info. Note: Bacon is yummy!
docstringpythonsemanticsstringssyntax
You can eliminate matches on queries based on the name of the site. For example, to search on all sites except experts-exchange.com, use the following hyphen-prefixed site string:
-site:experts-exchange.com "outer join"
Conversely, you can search only on a specified site by omitting the hyphen prefix:
site:debian.org "network install"
googlesyntax
It is possible to order by an array element as follows:
SELECT * FROM (SELECT ARRAY[1, 2, 3] AS foo) sub ORDER BY foo[1];
arrayobscurepostgresqlsqlsyntax
To make print suppress its usual trailing newline, add a comma to the end of the statement:
print "Foo", print "Foo %s" % (bar),
languagesprintprogrammingpythonsyntaxtrailing-newline
Sometimes it's necessary to access raw post data. The easiest way to do this is by opening the php://input stream:
$fp = fopen('php://input', 'r');
httpiolanguagesphppostprogrammingsyntax
Remove duplicate elements from a list:
newList = dict([(item, 1) for item in oldList]).keys()
Or, if you have Python 2.3 or newer, you can use a Set object to collapse your list:
import sets newList = list(sets.Set(oldList))
dataimportlanguagesprogrammingpythonsetsyntax
If you're having to match lines that start with # you can avoid using an expression if you do something like this:
foreach ($lines as $line) {
if ($line{0} != '#') {
// We have a non-comment, print it.
echo $line . '<br />';
}
}
foreachlanguagesphpprogrammingsyntax
Given an array @slobber, replace all the CR-LF with CR:
foreach (@slobber) {
s/\015\012$/\n/; print;
}
dosforeachlanguagesline-endingsperlprogrammingsyntaxunix
If you're on a dark background terminal, the hightlighting after searching in vim can be maddening. To turn it off for the session, type :set nohls.
backgroundcommandeditorshighlightingsyntaxvim
If you want to search for synonyms, use a tilde (~) in your search string. For example:
breakfast ~nutrition
googlesyntax
If you would like to have syntax highlighting on a file that would otherwise not have any highlighting at all, you can symlink the file to the appropriate extension and open it:
$ ln -s example.lxp example.html $ vi example.html # opened with pretty highlighting
*Note: This should be used sparingly and you should clean up your symlinks.
commandseditorshighlightingshellsymlinksyntaxvi