I’m in the process of doing research for my computer science ph.d. project. Like many others, I’m using Google Scholar to find interesting papers for my research. Some papers are available through ACM and some through IEEE.
My university only has a subscription with ACM, not with IEEE, so it’s free (for me) to read an ACM paper, while I have to pay to read or even download a citation of an IEEE paper. When I asked the faculty why we don’t have an IEEE subscription, the answer was: Because it is really expensive. So what kind of papers do you think I’m looking at the most?
This makes me think: Will there eventually be a strong skew in the kinds of paper I’ll end up citing? Many citations of ACM papers, none or few of IEEE papers? For now the answer is a definite yes. When I’m snowballing on a keyword, I now tend to close browser tabs with IEEE papers more often than ACM papers.
I have no doubts. This is a problem for science!
Assuming a shapefile called mygeodata.shp, a database schema called public.mygeodata and a PostGIS enabled database called mygeodb.
shp2pgsql mygeodata -I public.mygeodata > mygeodata.sql psql -d mygeodb -f mygeodata.sql
This tip and many more can be read in Making Maps Fast.
tikZ and LaTeX
PGF/TikZ is a tandem of languages for producing vector graphics from a geometric/algebraic description. You can use this language inside tex files, to programmatically draw nice 2D and 3D graphics. Another package which some people prefer for 3D is asymptote.
Read the manual.
Tutorials for tikZ
For more information read one of the tutorials and the tikz resources page, which includes helpful tools etc.
There are tutorial videos online like this video. There are also tutorials on youtube like the following, but this does not cover 3D graphics unfortunately:
To learn how to make 3D stuff, start by looking at the examples below. If you can make sense of it…
tikZ 3D examples
Look at the 3D tikz example page for more 3D examples.
| [TEX] | |
| [TEX] |
Download sourcecode
Choose the appropriate sourcecode version by going to http://nodejs.org/#download.
wget http://nodejs.org/dist/v0.6.7/node-v0.6.7.tar.gz # or use curl
Install g++
I found that the g++ is needed to install node.js from sourcecode. Found a hint about installing g++ on Amazon Linux, which basically tells you to do this:
sudo yum install gcc-c++.x86_64
Install openssl
To get ssl support, you need to install openssl-devel.x86_64 which is not installed by default (only binary version). Alternately you can install without ssl support with ./configure –without-ssl. (thanks to my colleague Elias Löfgren for helping out here)
sudo yum install openssl-devel.x86_64
Install make
(thanks Daniel for pointing this out)
sudo yum install -y make.x86_64
Install Node.js
Now you can configure, make, install:
./configure make make install
Nagios looks at 1) return codes and 2) output to stdout. This is the hello world of Nagios plugins, written in Python:
check_helloworld.py:
#!/usr/bin/env python # optparse is Python 2.3 - 2.6, deprecated in 2.7 # For 2.7+ use http://docs.python.org/library/argparse.html#module-argparse from optparse import OptionParser # CONSTANTS FOR RETURN CODES UNDERSTOOD BY NAGIOS # Exit statuses recognized by Nagios UNKNOWN = -1 OK = 0 WARNING = 1 CRITICAL = 2 # TEMPLATE FOR READING PARAMETERS FROM COMMANDLINE parser = OptionParser() parser.add_option("-m", "--message", dest="message", default='Hello world', help="A message to print after OK - ") (options, args) = parser.parse_args() # RETURN OUTPUT TO NAGIOS # USING THE EXAMPLE -m PARAMETER PARSED FROM COMMANDLINE print 'OK - %s' % (options.message) raise SystemExit, OK
Define a command that uses this plugin:
define command { command_name check_hello_world command_line $USER1$/check_hello_world.py -m 'some message' }
Check a host or service using the command:
define service { use generic-service host_name some-host service_description Check using the hello world plugin (always returns OK) check_command check_hello_world }
In terminal you can write something like:
say 'hello world'Which will make your computer talk. To save the audio output to a file, use the -o option. A full example is:
say -o hello.aiff -v 'Alex' 'Hello, my name is Alex' open hello.aiff
This will say ‘Hello, my name is Alex’, in the voice of ‘Alex’ (other voice-options are ‘Bruce’, ‘Fred, ‘Kathy’, ‘Vicki’ and ‘Victoria’), and save the output to ‘hello.aiff’.
It seems there is no option for setting the speed (can be set in System preferences -> speech). See man say for all options. Interesting options include sending the output over the network.
My top seems to act a little strange (running Snow Leopard). It doesn’t respond to the key commands I’m used to, e.g. for sorting on Memory Usage etc. Nevertheless, this is how I found out (by chance really) how to kill a process from within top.
First start top using sudo:
sudo topPress shift + s. This will promt for a signal. Enter the word ‘kill’ (if not already selected). Hit enter. Now top prompts for a pid. Enter the pid of the process you want to expedite. Hit enter. Good bye process.
This is how I installed Django 1.3.1 on my Mac running Snow Leopard 10.6.8 with Python 2.7. This recipe uses pip and virtualevn (installation instructions included).
Installing pip
(skip if you have pip installed)
First make sure you have either setuptools or distribute installed. Please consult your operating system’s package manager or install it manually:
curl http://python-distribute.org/distribute_setup.py | python
Now install pip:
sudo curl https://raw.github.com/pypa/pip/master/contrib/get-pip.py | python
Install virtualenv
(skip if you have virtualenv already)
Install virtualenv:
pip install virtualenvInstall Django using pip and virtualenv
Create a directory for a new django project:
mkdir djangoproject cd djangoproject
Create a virtual environment in a subdirectory (I’m using name “venv”):
virtualenv venv --no-site-packagesActivate the virtual environment
cd venv source bin/activate which python
Install django in the virtual environment using pip:
pip install djangoThat’s it. You can test the installation (if no errors django was installed):
$ python >>> import django >>>
Now continue with the tutorial on the Django site (version 1.3): https://docs.djangoproject.com/en/1.3/intro/tutorial01/
Here’s a game I like to play. Select two wikipedia pages at random, and find a route from one to the other. I stated a theorem once that:
you can get from any page on wikipedia to the page on pollination in 7 steps or less. (it was actually another page, but let’s say it was pollination)
I devised a method for doing this using Google search. Let’s call the random page s, and the page you want to reach t, e.g. pollination. A given page on wikipedia has a set of incoming links (other pages linked to the page), and a set of outgoing links (other pages linked to by the page). Let’s call these two sets in[p] and out[p]. These two sets contain direct decendants and ancestors of p respectively.
|
|
|
Computing in[p] using google search
This is how to compute in[http://en.wikipedia.org/wiki/Pollination]. Type the following into the standard Google search page:
link:http://en.wikipedia.org/wiki/Pollination site:en.wikipedia.org (link)
Computing out[p]
This is trivial. To compute out[http://en.wikipedia.org/wiki/Ketchup] simply visit the page on Ketchup and look at the links.
Algorithm
The idea is to use BFS (breadth first search) simultaneously from s and t. Searching from s involves recursively computing out[p] to discover the set of decendants of s. Searching from t involves recursively computing in[p] to discover the set of ancestors of t. If there is a route from s to t, at some point the intersection between the decendants of s and the ancestors of t will be non-empty. This situation is illustrated by the green node:
Now, Google is a bit stingy with the requests, and do not allow requests made e.g. by curl. So for now the algorithm is run by hand.
Optimization using guided depth-first-search
One optimization when computing in[p], is to include a word that is very general or popular, e.g. the word “sex”. The idea is that the likelyhood that a given page p is both ancestor of t and a decendant of s, increases with the popularity of p. In this case the algorithm uses depth first to first explore paths going through popular pages.
As an example, the page on sex is a member of in[http://en.wikipedia.org/wiki/Pollination]. One of the reason that I chose Pollination to begin with…
This howto shows how to get Nagios up and running on an Amazon EC2 Instance using Apache web server to serve the Nagios UI. You could argue that a more light-weight web server would be better, but I’d argue that it doesn’t really matter. Performance is not a great issue for a few administrators looking at the Nagios UI.
Update 1: Use this installation guide for Fedora on Nagios.org instead.
Update 2: You can now get Nagios XI preinstalled AMI’s http://labs.nagios.com/2012/01/20/using-nagios-xi-in-amazon-ec2-cloud/
Step 1: Create an EC2 micro instance running Amazon Linux AMI (64 bit)
Step one is to get an Amazon Linux instance. I created a new Amazon Linux micro 64 bit instance and placed the instance in a security group called “monitoring”. You can use 32 bit if you want, but I’ve tested with 64 bit.
Next, open up ports 22 and 80 on the security group. Here I use the ec2 commandline tools, but you can also do it from the AWS Management Console:
ec2-authorize monitoring -p 22 ec2-authorize monitoring -p 80
Next log in to the instance using ssh
ssh -i path-to-pem-file ec2-user@your-ec2-instance
Step 2: Install Nagios software
Use yum to install nagios (at the time of writing this is version Nagios 3.2.3):
sudo yum install nagios nagios-plugins-all
Add nagios to run-level 3:
chkconfig --level 3 nagios on
Apache and PHP are used to serve the Nagios UI, but PHP is not installed by the yum command above. You can install PHP with yum:
sudo yum install php
Step 3: Add a user to Nagios
Add a Nagios user for logging into the Nagios UI. You can use this script:
#!/usr/bin/perl use strict; if ( @ARGV != 2 ){ print "usage:./htpasswd.pl <username> <password>\n"; } else { print $ARGV[0].":".crypt($ARGV[1],$ARGV[1])."\n"; }
Run it like this:
perl htpasswd.pl some_username some_passwordCopy-paste the output onto a new line of /etc/nagios/passwd, e.g. using vi
sudo vi /etc/nagios/passwd
Step 4: Configure Nagios
Enter your contact_name, alias and email address in the “contact” section of contacts.cfg:
sudo vi /etc/nagios/objects/contacts.cfg
Step 5: Start Nagios and log into the management application
Start Nagios:
sudo service nagios startVisit your new Nagios home page, e.g. at http://your-ec2-instance-id.compute.amazonaws.com/nagios/.
Final hints
See a list of all the plugins installed:
ls /usr/lib64/nagios/plugins/
Check the last 100 log messages from nagios:
sudo tail -n 100 /var/log/nagios/nagios.log
