Thursday, January 9, 2014

Мэтью Арнольд "Доверья океан..."

Доверья океан
Когда-то полон был и, брег земли обвив,
Как пояс радужный, в спокойствии лежал
Но нынче слышу я
Лишь долгий грустный стон да ропщущий отлив
Гонимый сквозь туман
Порывом бурь, разбитый о края
Житейских голых скал.

Дозволь нам, о любовь,
Друг другу верным быть. Ведь этот мир, что рос
Пред нами, как страна исполнившихся грез,-
Так многолик, прекрасен он и нов,-
Не знает, в сущности, ни света, ни страстей,
Ни мира, ни тепла, ни чувств, ни состраданья,
И в нем мы бродим, как по полю брани,
Хранящему следы смятенья, бегств, смертей,
Где полчища слепцов сошлись в борьбе своей

Thursday, December 5, 2013

Без автора "Одиноким людям не спится..."

Одиноким людям не спится.
Им до жути скучно ночами.
Таким людям однажды не спиться бы,
Вы по ним
Никогда
Не скучали.

Они сходят с ума ежедневно.
Одиночки
От жизни устали.
Они пишут стихи, но, наверное,
Вы Такое
Читать бы
Не стали.

Они замкнуты,
Словом ранены.
Им страшно кого-то любить.
Они чешут душевные ссадины.
Они жаждут
Кого-то
Забыть.

Saturday, November 23, 2013

LAMP: Creating virtual hosts and resolving 500 Internal server error

This guide expects, that you already have web server on your machine.

1. Copy file /etc/apache2/sites-available/default and rename it to your host name. (for example testweb.net. Also your web application must be in /var/www/testweb.net/ directory.) Dont forget to add permissions to your web application directory using
sudo chmod -R 755 /var/www/testweb.net/ For development you can use 777, but it is still not the best practice.
sudo cp /etc/apache2/sites-available/default /etc/apache2/sites-available/testweb.net

2. Configure testweb.net file
gksudo gedit /etc/apache2/sites-available/testweb.net

This command will open testweb.net file in gedit text editor.

ServerName testweb.net
<VirtualHost *:80>
 ServerAdmin admin@mail.com
 ServerName testweb.net
 ServerAlias www.testweb.net
 [...]

DocumentRoot /var/www/testweb.net
I'm using my own hosts configuration file:
    ServerNametestweb.net
    ServerAlias www.testweb.net

    DocumentRoot /var/www/testweb.net
    <Directory /var/www/testweb.net>
        # enable the .htaccess rewrites
        AllowOverride All
        Order allow,deny
        Allow from All
    </Directory>

    ErrorLog /var/log/apache2/project_error.log
    CustomLog /var/log/apache2/project_access.log combined
</VirtualHost>

3. Activate your host

sudo a2ensite testweb.net

4. Edit /etc/hosts
gksudo gedit /etc/hosts
Add this line to hosts file:

127.0.0.1    testweb.net

5. Now you need to restart your apache service.
sudo service apache2 restart
Voila, your virtual host is now available!

What should you do, if you have 500 Internal Server Error? 

This problem might be caused by .htaccess file in your project root dir. First of all, check your logs (/var/log/apache2/) and try to access your site by this link: localhost/testweb.net. But for me it was not enough, so I found this solution (not sure what this command do, so run it on your own risk T_T)

sudo a2enmod rewrite
sudo service apache2 restart

Here you can read about 500 error solving: http://askubuntu.com/questions/148246/apache2-htaccess

This resource was really helpful: https://www.digitalocean.com/community/articles/how-to-set-up-apache-virtual-hosts-on-ubuntu-12-04-lts

P.S. YEAH, I know, there are LOTS of english mistakes, sorry for that :(

Thursday, November 14, 2013

SVN resolving problem: "containing working copy admin area is missing"

For an instance, we're having this error: "some/folder/.svn containing working copy admin area is missing".

There are lots of solutions here: http://stackoverflow.com/questions/1394076/how-to-fix-containing-working-copy-admin-area-is-missing-in-svn, but here's the one, that worked for me (not the most elegant, I suppose, but it worked):

1. Remove the conflicted folder (if there are some uncommited files, we need to back them up)
cd /your/project/root
sudo rm -rf some/folder
svn up
2. Commit your changes!

Wednesday, November 13, 2013

Setting up permissions on Ubuntu for /var/www (web server)

In ubuntu all web projects are in /var/www folder, so you need to set up permissions on writing files, as by default this folder belongs to root user.

1. First of all you need to ensure, that your current user belongs to www-data group. Adding user to www-data group:

sudo adduser username www-data

You can find your username by typing this command:

whoami

2. Next we need to change /var/www folder owner and owner group:

sudo chown username:www-data -R /var/www

3. Next we need to change /var/www permissions to 755 (777 not recommended due security reasons)

sudo chmod 755 -R /var/www
sudo chmod g+s -R /var/www

Information from: http://askubuntu.com/questions/162866/correct-permissions-for-var-www-and-wordpress

Wednesday, November 6, 2013

Ruby: exceptions

raise "Exception message" // this will throw RuntimeError exception with message "Exception message"

begin
  10/0 // This will raise an DivisionByZero exception
rescue DivisionByZero
  puts "Devision by zero exception"
end
Creating custom exception:
class CustomException > StandardError
end

Ruby: OOP (privacy)

Methods are public by default in Ruby.

class Test

  def public_m
  end

  private
  def private_m
  end

  // Again private method, because all methods after private keyword will be private
  def private_m_2
  end

end
Modules are containers for methods and constants.

module MyModule
  // Call it: MyModule::MOD_CONSTANT
  MOD_CONSTANT = "Module constat"

  // Call it: MyModule.my_method
  def my_method
  end
end
Require module by typing require 'MyModule', so it will be available in whole file (Module.my_method)

Include module to class, so it will be available inside class and all the methods can be called without module name:


class SimpleClass
  include MyModule // Without '
  def m
    my_method
  end
end
Infromation from: www.codeacademy.com