You HAVE to love the elegance of unix and the utilities contained therein:
awk '{ sum += $1; } END { print sum; }'
Popularity: 60%
You HAVE to love the elegance of unix and the utilities contained therein:
awk '{ sum += $1; } END { print sum; }'
Popularity: 60%
You have tuned your PostgreSQL database, and you, of course, turned off query logging, but a problem has cropped up. How can you see the activity on your database at any slice of time?
Like me, you have probably turned on command stats to view pg_stat_activity, but that gives you only moment in time. You could use ethereal to capture the Postgres queriy packets, but then what? What if you don’t have X installed? tcpdump you say? What do you do with the dump?
Enter pgqueryspy.
Simply type pgqueryspy 2000 db0 to capture the next 2000 packets to the server named ‘db0′. pgqueryspy then prints out the queries that it intercepts in the packet stream for your consumption on the command line. It even tosses those pesky “BEGIN” and “END” queries for you.
Not too terribly invasive, no load on your database, and you find out NOW what is happening with your database. Code is available here: pgqueryspy.c.
I accept NO RESPONSIBILITY FOR YOUR USE OF THIS CODE. It could toss your database/network/server/grandma out the window. YMMV, caveat emptor, etc, etc.
I am putting this code out here for two reasons:
UPDATE: Forgot to give credit for the help. Thanks to Kris, as well as the libpcap packet capture tutorial.
Popularity: 53%
Fairy simple, and I even tested it for you
private String stripPredicatesFromXPath(String xpath) {
if (xpath == null) {
return xpath;
}
Pattern pattern = Pattern.compile("\\x5B[^\\x5B\\x5D]*\\x5D");
Matcher matcher = pattern.matcher(xpath);
String result = matcher.replaceAll("");
return result;
}
Popularity: 44%
curl -O http://www.monkey.org/~provos/libevent-1.1a.tar.gz
tar zxf libevent-1.1a.tar.gz
cd libevent-1.1a
./configure
make
make install
cd ..
mv libevent-1.1a.tar.gz ../installed/
curl -O http://www.danga.com/memcached/dist/memcached-1.1.12.tar.gz
tar zxf memcached-1.1.12.tar.gz
cd memcached-1.1.12
./configure
make
make install
mv memcached-1.1.12.tar.gz ../installed
Then add /usr/local/lib to LD_LIBRARY_PATH in your .bash_profile
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
export LD_LIBRARY_PATH
Then test:
memcached -m 512 -u nobody -vv
Popularity: 55%
svn propset svn:ignore *.pyc dirname
or
svn propedit svn:ignore dirname
Popularity: 63%
/etc/init.d/cups stop
chkconfig --level 2345 cups off/etc/init.d/iptables restartssh-keygen -t dsa
vi ~/.ssh/auhtorized_keys2
chmod 600 ~/.ssh/authorized_keys2Popularity: 33%
I gave up on the code compiling ever again (tried for 3 months with latest from CVS), and just download the version from the Apple website here.
Popularity: 25%
initdb -D /var/lib/pgsql/data --locale=en_US.utf8 -E UTF8
Popularity: 20%
Working with Shelby today, he had written an XSLT that created a SQL script, with embedded search and replace statements (he was calculating parent ids on the fly). So, now we have a SQL script that contains commands to run. So, something like this:
sed -e "`grep SED: test.txt | awk -F" " '{print $2}'`" < test.txt | grep -v SED:
And the file modifies itself. This is why Unix will live forever! GUIs be damned, full command line speed ahead…
Popularity: 18%
vi /etc/exports
add lines like:
/data1/sessions 192.168.0.0/255.255.0.0(rw) 10.0.0.0/255.0.0.0(rw)
vi /etc/hosts.allow
add lines like:
portmap: 192.168.0.0/255.255.0.0, 10.0.0.0/255.0.0.0
/etc/init.d/nfsd start
vi /etc/fstab, adding the following line:
nfshostname:/data1/sessions /mnt nfs rw,hard,intr 0 0
make sure to mkdir /mnt/sessions, or it won’t work. To do it manually, just:
mount nfshostname:/data1/sessions /mnt/sessions
Popularity: 68%
vi /etc/named.conf (adding master zone for newdomain.com)
cp /var/named/example.org.hosts /var/named/newdomain.com.hosts
vi /var/named/newdomain.com.hosts
kill -HUP pid-of-named
Popularity: 27%
I needed IMAP support in PHP4, so I attempted to compile it in using the instructions here. I kept getting the error:
checking whether IMAP works... no
configure: error: build test failed. Please check the config.log for details.
In my configure.log, I was seeing this:
configure:43918: undefined reference to `auth_gssapi_valid'
collect2: ld returned 1 exit status
The problem was that I was trying to use imap2004e. When I found and download imap2001c as an rpm, and installed it, everything went fine. Just logging this for future frustrated sysadmins without a solution.
Popularity: 22%
I was in the need this morning to set some MySQL variables without taking the database server down. This is possible, if you can find the right piece of documentation to tell you how. The proper documentation would be this: 4.3.4 Using Options to Set Program Variables.
Note that not all options can be set. The list of allowed variables to be set this way is listed here: 5.3.3.1 Dynamic System Variables.
Popularity: 25%
Alex tells me that this is the current best way to bold ordered list items (the actual list item numbers, not the data in the list item):
And the css:
And here is an example:
And without it:
Popularity: 22%
Ever find yourself needing to make a quick call to some WSDL service out there? Do it with PHP next time, and find out how easy it is!
Just download the latest copy of NuSOAP, and type up a PHP file something like:
// include the SOAP classes
require_once(’nusoap.php’);
$client = new soapclient(’http://example.com/url/to/some/valid.wsdl’, True);
$err = $client->getError();
if ($err) {
// Display the error
echo ‘client construction error: ‘ . $err ;
} else {
$answer = $client->call(’someSOAPMethod’,
array(
‘param1′=>’foo’
,’param2′=>’bar’));
$err = $client->getError();
if ($err) {
// Display the error
echo ‘Call error: ‘ . $err;
print_r($client->response);
print_r($client->getDebug());
} else {
print_r($answer);
}
}
?>
It couldn’t be easier. NuSOAP reads and parses the WSDL, configures your method call and params with the correct schema types, and makes the call. The response comes back as an associative array. This is how WS-* should be
Popularity: 34%
From the documentation:
Popularity: 25%
Even if the machines are on different operating systems, this is dead easy. On the source machine, simply ‘dump’ the repository:
Then login to the new machine, and set up the new repo:
That’s all there is to it. Then you can of course delete the dump files, the .tgz files, and even the source repo if you are brave.
Popularity: 96%
(Adapted to my needs from the original at http://www.apache-ssl.org/#FAQ)
First, you create the cert:
Then, you edit the site config, adding the following lines:
Then, you restart apache, while crossing your fingers:
Popularity: 25%
So, you’re running MySQL on Windows, and would really like to see a log of all of the queries the server is processing? Simple, just find your my.ini file, open it in a text editor, and add the following line in the [mysqld] section:
Then restart the mysql service, and every query will be logged in a file called hostname.log in the MySql\data directory.
For you unix types, starting the mysqld daemon with the ‘–log’ parameter will create the file ‘hostname.log’ in the $MYSQL_HOME/data directory.
Popularity: 29%
Using the wsadmin tool is easy, if you know which documentation to dig through
I distilled it down to a one liner, for those that like that sort of thing:
Simple, once you know where to look, and actually succeed in finding it. I have found that IBM’s documentation usually contains what you need, you just can’t find it.
Popularity: 20%