Sunday, September 29, 2013

Installing Ruby + Rails on Windows 8 x64

1. Download and install Rubyinstaller (Ruby 2.0.0-p247 (x64) for me, you can try another version) from http://rubyinstaller.org/downloads/
2. Download and install Ruby Dev Kit (DevKit-mingw64-64-4.7.2-20130224-1432-sfx.exe for me) from http://rubyinstaller.org/downloads/

You can type in cmd or in cmd for ruby command "ruby --version" to check your ruby version.
Also you can check already installed gems by typing: "gem list --local" or "gem list --local rails" to check if rails already installed (for me it wasn't).

NB! You may need to configure your RubyDevKit to run "gem install rails". First of all you need to cd in command prompt to your rubydevkit root; then you need to run those cmds:
ruby dk.rb init
ruby dk.rb install

3. In cmd (or cmd for ruby) type "gem install rails"

After rails was installed, we need to install Sqlite 3 (the most difficult part of installation ^^), because rails use it as a default db engine. The problem is that we need to compile sqlite from source codes manually.
Now we will be using instructions, that was written by "paulwis" in this topic  https://github.com/luislavena/sqlite3-ruby/issues/82.
Also thanks to this topic: http://stackoverflow.com/questions/15480381/how-do-i-install-sqlite3-for-ruby-on-windows

4. Download source files of SQLite (sqlite-autoconf-3080002.tar.gz) and extract it somwhere ("C:/Sqlite/src/" for example.)
5. Open msys.bat file from RubyDevKit folder and change location using "cd" command to your sqlite source dir (for me it was "cd /C:/Sqlite/src/")
6. Run command "./configure"
7. Run command "make"
8. Run command "make install"
9. Now you need to install sqlite gem. Run command
"gem install sqlite3 --platform=ruby -- --with-sqlite3-include=[path\to\sqlite3.h] --with-sqlite3-lib=[path\to\sqlite3.o]"
for me it was:
"gem install sqlite3 --platform=ruby -- --with-sqlite3-include=/C:/Sqlite/src --with-sqlite3-lib=/C:/Sqlite/src/.libs/"
10. By the end you can check Gemfile.lock (in your rails application), if your version is correct. Make sure, that sqlite points to right version of ruby. Sometimes it needs to be changed for example from "sqlite3 (1.3.7-x86-mingw32)" to "sqlite3 (1.3.7-x64-mingw32)" or "sqlite3 (1.3.7)".

Now we can check our rails application. If it was not created yet, open command prompt or cmd for ruby, run "cd" to your applications folder (it can be any folder you prefer, f.e. "C:/MyRailsApps/" so you will run in cmd "cd C:/MyRailsApps/"). After run "rails new Hello_world" to create your Hello_world app. Than "cd Hello_world" and run "rails server". If all was ok, you can look at your app here: http://localhost:3000

Wednesday, September 18, 2013

MySQL некоторые правила оптимизации

Engine:
InnoDB / XtraDB
Настройки:
  • query_cache_size = Размер кэша для запросов. Дать как можно больше оперативной памяти (серверные машины 50-75%, обычные компьютеры 25-50%)
  • innodb_log_file_size = 128/256Mb
  • innodb_log_buffer_suze = 4Mb
  • innodb_flush_log_at_trx_commit = 2 (Данные пишутся в буфер и записываются каждую секунду на диск.)
  • innodb_thread_concurrency=8
  • innodb_flush_method=O_DIRECT (Avoid double buffering)
  • innodb_file_per_table (Не ставить, если очень много таблиц)
http://mysql-tuner.pl
http://tuning-primer.sh
http://maatkit.org

link: http://www.youtube.com/watch?v=2FPvuhRGKV0

Sunday, September 15, 2013

Linux Apache Mysql Php (LAMP) + phpmyadmin

sudo apt-get update
sudo apt-get install apache2
sudo apt-get install mysql-server libapache2-mod-auth-mysql php5-mysql
sudo mysql_install_db -> activate mysql
sudo /usr/bin/mysql_secure_installation -> installation of mysql
sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt
sudo vim /etc/apache2/mods-enabled/dir.conf -> add index.php after DirectoryIndex
apt-cache search php5- -> all php5 extensions
sudo apt-get install php5-curl php5-gd -> install extensions

sudo apt-get install phpmyadmiin
sudo vim /etc/apache2/apache2.conf -> add line Include /etc/phpmyadmin/apache.conf
sudo service apache2 restart


source files: /var/www

Friday, September 13, 2013

Ubuntu server terminal cmds

ls / ll - list
pwd - current directory
cd ~ ; cd / change dir to root or home
cp <file> <new_file> - copy file
mv <file> <new_file_name> - rename file
rm <file> remove (rm -Rf *)

скрытые файлы в линукс - это файлы, которые начинаются с точки(.)
--help флаг документации
Короткие флаги устанавливаются с одной чертой и могут ставится под ряд (-l, -la)
Длинные флаги (более 1 символа) устанавливаются с двумя черточками --help

-rwxrwxrwx root root = -rwx / rwx / rwx root (владелец) root (группа)
1-ые 3 rwx- права для владельца фаила
2-ые 3 rwx- права для пользователей группы
3-ие 3 rwx- права для всех остальных польз.

r - читать
w - удалять, переименовать и т.д.
x - запустить фаил

  1. 4 = r (Read)
  2. 2 = w (Write)
  3. 1 = x (eXecute)

sudo su root - сменить пользователя на root

cat ~/.bashrc - vyvodit ves' fail bashrc v terminal
cat ~/.bashrc | grep "alias" - vyvodit tolko stroki, svjazannye so slovom "alias"
cat ~/.bashrc |
vim ~/.bashrc - otkryvaet fail v tekstovom redaktore vim
vim: :q! - vyxod bez soxranenija, :wq vqxod s soxraneniem
source ~/.bashrc - perezagruzka faila (chtoby deistvija vstupili v silu)

http://oliverdavies.co.uk/blog/2011/10/install-and-configure-subversion-svn-server-ubuntu

Wednesday, September 11, 2013

SVN

svn commit --message "Message"

svn revert <file> - Возвращает фаил к исходному состоянию текущей ревизии.

svn status

svn diff

{

svn diff — сравнить рабочие файлы с последней ревизией,

svn diff index.html — сравнить локальный файл index.html с последней ревизией этого файла в репозитории,

svn diff -r 9 — сравнить все локальные файлы с ревизией номер 9,

svn diff -r 9 index.html — сравнить локальный файл index.html с ревизией номер 9,

svn diff -r 8:9 index.html — сравнить файл index.html ревизии 9 с этим же файлом, но ревизии 8 в репозитории.

}

svn log -r 1:5

" -r == --revision "

svn add --force <directory>

svn update


Trunk - девелопмент, обычная полоса разработки.
Branch - ответвление, точная копия проекта на момент ревизии Н, поддаётся изменениям как и транк.
Tag - ответвление, точная копия проекта на момент ревизии Н, НЕ поддаётся изменениям.


svn copy (URL сервера)/(имя проекта)/trunk (URL сервера)/(имя проекта)/branches/(имя ветки) -m "Комментарий"
svn copy (URL сервера)/(имя проекта)/trunk (URL сервера)/(имя проекта)/tags/(имя тега) -m "Комментарий"


cd .../branches/r001/

svn diff -r 11:12 https://subversion.assembla.com/svn/andys-project/trunk -> 11 rev. брэнч (сравниваем брэнч с последним коммитом на транке)

svn merge -r 11:12 https://subversion.assembla.com/svn/andys-project/trunk -> Вносим изменения в ветку, соответствующие последней ревизии транка

svn commit -m "Merge"





https://subversion.assembla.com/svn/andys-project/

Источник: http://svnhowto.com

Wednesday, September 4, 2013

Starting selenium server

1. Download latest Java SE from http://java.sun.com/ and install
2. Download latest version of Selenium RC from and extract
3. Create a folder named Selenium at C:\Program Files\Java\jdk1.6.0_03\bin
4. Copy all files under Selenium-server-0.9.2 which you will find in the extracted folder and paste in the newly created folder
5. From Command prompt run the following commands:
cd \
cd C:\PROGRA~1\Java\jdk1.7.0_21\bin
java -jar .\Selenium\selenium-server-standalone-2.35.0.jar -interactive
 
If you see the following messages at the end of the console, you are quite confirm that the Selenium server is running fine:
Entering interactive mode... type Selenium commands here (e.g: cmd=open&1=http:/
/www.yahoo.com)