12 Feb

Quick rsync server setup on Linux box

This goes to your /etc/rsyncd.conf:

log file = /var/log/rsyncd.log
transfer logging = true

[home]
path = /home/
uid = apache
gid = apache
read only = no
list = yes
comment = home
auth users = web
secrets file = /etc/rsyncd.passwords
hosts allow = 192.168.1.1/32
hosts deny = 0.0.0.0/0

To launch run:

rsync --daemon

/etc/rsyncd.passwords is plain text file with passwords in format:

username:password

For example,

tales:P@ssW0Rd

Using it:

rsync -av  /home/ [email protected]::home/

To test add –dry-run option. It will not make any changes. This is it.

11 Feb

How to make world better place by doing (almost) nothing

BOINCManagerWell, here’s an answer: volunteer computing.
How does it work? To participate you have to install client software which called BOINC (download page). Choose the version for your operation system and install. After it’s done you need to choose the project you want to participate in. Here are few examples.

SETI@home. The most famous distributed computing project. SETI stand for Search for Extra-Terrestrial Intelligence Home. Let's finally find them.

Einstein@Home. This project goal is searching through data for evidence of continuous gravitational-wave sources. Hosted by University of Wisconsin–Milwaukee and the Max Planck Institute for Gravitational Physics.

LHC@home. The project aim is to improve Large Hadron Collider (big deal, you know).

MilkyWay@Home  aims to generate 3d dynamic models of stellar streams in the immediate vicinity of Milky Way galaxy.

After you register your new project BOINC will download small portions of tasks to compute and it will start working on them. After the tasks are done BOINC will upload the results back to the project’s servers. You will get scores for each project.

BOINC should not use  too much resources from you computer. You can set it to work at night only, for istance. By the way, it shipped with nice screen saver.

Let’s make world better with BOINC and distributed computing!

10 Feb

How to change ‘Home’ link text in WordPress

If you need to change you ‘Home’ link text in your WordPress installation just put these lines to your theme’s function.php:

function change_home($menu_text) {
return preg_replace('/>Home</', '>Blog<', $menu_text, 1);
}
add_filter('wp_page_menu','change_home');

Change ‘Blog’ to whatever you need. The solution was found here.

07 Feb

Tag Clouds in Python

One of the most beautiful things about Python is a plenty of third-party libraries (which Lua world unfortunately lacks). Creating tag cloud in Python is quite easy. Firstly, we need to install required packages. I run Fedora 18.

yum install python-pip.noarch
yum install pygame
yum install simplejson

Now you an install pytagcloud. (NB: do not use easy_install, pip is the right way to go).

python-pip install -U pytagcloud

Now we are ready to create our first tag cloud image:

from pytagcloud import create_tag_image, make_tags
from pytagcloud.lang.counter import get_tag_counts

TEXT = '''
You know the day destroys the night
Night divides the day
Tried to run
Tried to hide
Break on through to the other side
Break on through to the other side
Break on through to the other side, yeah

We chased our pleasures here
Dug our treasures there
But can you still recall
The time we cried
Break on through to the other side
Break on through to the other side
Yeah!
C'mon, yeah
Everybody loves my baby
Everybody loves my baby
She get
She get
She get
She get high
I found an island in your arms
Country in your eyes
Arms that chain us
Eyes that lie
Break on through to the other side
Break on through to the other side
Break on through, oww!
Oh, yeah!
Made the scene
Week to week
Day to day
Hour to hour
The gate is straight
Deep and wide
Break on through to the other side
Break on through to the other side
Break on through
Break on through
Break on through
Break on through
Yeah, yeah, yeah, yeah
Yeah, yeah, yeah, yeah, yeah'''

tags = make_tags(get_tag_counts(TEXT), maxsize=150)

create_tag_image(tags, 'cloud_large.png', size=(900, 600))

After you run this script you should have file ‘cloud_large.png’ in your current directory.
Here is mine:

cloud_large5

Python is great.

07 Feb

trac deployment with gunicorn and systemd in Fedora 17

gunicorn installation:

yum install python-gunicorn.noarch

Put systemd unit file to /lib/systemd/system/gunicorn-trac.service:

[Unit]
Description=gunicorn-trac

[Service]
ExecStart=/usr/bin/gunicorn -D -n gunicorn-trac -w5 tracwsgi:application -b 127.0.0.1:8000 --access-logfile /home/trac/log/access.log --error-logfile /home/trac/log/error.log
Type=forking
User=trac
Group=trac
Restart=always
StandardOutput=syslog
StandardError=syslog
WorkingDirectory = /home/trac/

[Install]
WantedBy=multi-user.target

Enabling, starting:

systemctl enable gunicorn-trac
systemctl start gunicorn-trac

Checking:

[root@moonstation ~]# netstat -lpn | grep gun
tcp 0 0 127.0.0.1:8000 0.0.0.0:* LISTEN 1034/gunicorn: maste
[root@moonstation ~]#

Everything seems fine. Now we can proceed with nginx setup as frontend to trac.

05 Feb

How to disable versions expose in PHP and webservers (nginx, Apache)

By default PHP exposes it’s version:

curl -vi localhost
< HTTP/1.1 200 OK
< Server: nginx/1.0.15
< Date: Fri, 01 Feb 2013 23:19:48 GMT
< Content-Type: text/html
< Transfer-Encoding: chunked
< Connection: keep-alive
< Keep-Alive: timeout=64
< X-Powered-By: PHP/5.4.8

As you can see just by running GET requst you are able to get nginx and PHP version on the server:

Server: nginx/1.0.15
X-Powered-By: PHP/5.4.8

To disable it modify your /etc/php.ini file:

expose_php = Off

As well as nginx’ http section:

server_tokens off;

And if you use Apache:

ServerTokens Prod