21 Feb

How to download Coursera materials with use of Python

Install coursera-dl by Dirk Gorissen:

python-pip install coursera-dl

Make a folder to store files:

mkdir -p ./courses/comnetworks-2012-001

Run:

coursera-dl -u y [email protected] -p your_password ./courses/comnetworks-2012-001 comnetworks-2012-001

Enjoy.

If you want to check if there are new materials you should run the same command. coursera-dl is smart enough to skip files you already have:

- Downloading resources for 2-6 Link Layer Overview (0414)
- "2-readings.pdf" already exists, skipping
- "2-6-link-overview-ink.pdf" already exists, skipping
- "2 - 6 - 2-6 Link Layer Overview (0414).txt" already exists, skipping
- "2 - 6 - 2-6 Link Layer Overview (0414).srt" already exists, skipping
- "2 - 6 - 2-6 Link Layer Overview (0414).mp4" already exists, skipping
17 Feb

How to put Apache web site into the maintenance mode

This is how you can add put you webisite working under Apache web server into the maintenance mode. Note that you need to have mod_rewrite enabled.

RewriteEngine On
RewriteCond %{DOCUMENT_ROOT}/maintenance.html -f
RewriteCond %{REQUEST_FILENAME} !/maintenance.html
RewriteRule ^.*$ /maintenance.html [L]

If the page maintenance.html exists all requests will be rewritten to it.

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

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