Wednesday, December 26, 2012

how to defuse a fork bomb

Defusing a fork bomb can be done in three steps:
  1. find the process name of the bomb, say procForkBomb
  2. stop (freeze) the bomb processes: killall -STOP procForkBomb, and
  3. terminate them: killall -KILL procForkBomb
Wiki provides more details.

how to prevent fork bomb

One way is to limit the maximum number of processes that a single user may own or system may allow.

On FreeBSD, this can be achieved by configuring kernel parameters: kern.maxprocperuid and/or kern.maxproc. It can be done by:
  1. set  respective limit in /boot/loader.conf (or, /etc/login.conf), or
  2. configure dynamically through command sysctl
On Linux, it can be done by configuring the parameter: max. number of processes (nproc), which is in /etc/security/limits.conf.


error: generic array creation

Java does not support arrays of generic classes. A way to workaround is to use a class that implements java.util.List (ordered collection, or sequence). ArrayList is a good choice. Here is an example:

Let Vertex<E> be some generic class (on type E).
Java doesn't support:
Vertex<String> vertex = new Vertex<String>[10];


A workaround could be:
ArrayList<Vertex<String>> vertex = new ArrayList<Vertex<String>>();



Tuesday, December 25, 2012

x forwarding through ssh

X forwarding needs to be enabled on both server and client sides.

On server side:
  1. edit the sshd configuration file  (/etc/ssh/sshd_config):
    X11Forwarding yes
  2. restart the sshd

Client side using ssh connect to the server:
ssh -X server


hooray

It works!

[django + mezzanine + apache2 + wsgi] on fedora 17 and ubuntu 12.04

how to:
  1. collect static files for mezzanine
    python manage.py collectstatic
  2. put static and template files under the mezzaine application directory
  3. configure mod_wsgi (conf.d/wsgi.conf) for apache2
    there are examples on site of djangoproject:
    https://docs.djangoproject.com/en/1.4/howto/deployment/wsgi/modwsgi/

in the beginning

Dec. 26, 2012