cat /home/sudoman/.ssh/id_rsa.pub | ssh auditgroupkg@85.115.208.83 'cat >> ~/.ssh/authorized_keys'
Posted in Ruby on Rails | No Comments »
cat /home/sudoman/.ssh/id_rsa.pub | ssh auditgroupkg@85.115.208.83 'cat >> ~/.ssh/authorized_keys'
Posted in Ruby on Rails | No Comments »
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:sun-java-community-team/sun-java6
sudo apt-get update
sudo apt-get install sun-java6-jdk
Posted in Linux/Ubuntu | No Comments »
Переходим в папку /tmp, и качаем естественно redis, в данном случае stable версия 2.4.8, но вы всегда можете пройти по этой ссылке и скачать послед версию.
cd /tmp wget http://redis.googlecode.com/files/redis-2.4.8.tar.gz tar -zxf redis-2.2.4.tar.gz cd redis-2.2.4 make sudo make install
Сейчас бинарки должны у вас наход-ся в /usr/local/bin
wget https://github.com/ijonas/dotfiles/raw/master/etc/init.d/redis-server wget https://github.com/ijonas/dotfiles/raw/master/etc/redis.conf sudo mv redis-server /etc/init.d/redis-server sudo chmod +x /etc/init.d/redis-server sudo mv redis.conf /etc/redis.conf
Создаем пользователя:
sudo mkdir -p /var/lib/redis sudo mkdir -p /var/log/redis sudo useradd --system --home-dir /var/lib/redis redis sudo chown redis.redis /var/lib/redis sudo chown redis.redis /var/log/redis
sudo update-rc.d redis-server defaults
Запускаем сам Redis
sudo /etc/init.d/redis-server start
Posted in Linux/Ubuntu | Tagged Redis, Ubuntu | No Comments »
Recently i was working in my cms where i was creating contact_us form, and today i want to share it with you, so lets start.
First open your Gemfile and paste
gem "galetahub-simple_captcha", :require => "simple_captcha"
And run rails g simple_captcha it’ll generate all needed files for the captcha
Second create controller:
rails g controller contact new
class ContactController < ApplicationController include SimpleCaptcha::ControllerHelpers
def index end
def new @message = Message.new end
def create
@message = Message.new(params[:message]) if @message.save && simple_captcha_valid? redirect_to(root_path, :notice => "Message was successfully sent.") else flash.now.alert = "Required fields or secret code was invalid!" render :new end
end
end
As you can see below, we use simple_captcha_valid? to check whether the numbers were correctly added. and also we include include SimpleCaptcha::ControllerHelpers module.
Third create mailer:
rails g mailer notifier
class Notifier < ActionMailer::Base
def notification(message)
@message = message
mail(
to: "sudoman@namba.kg",
from: message.email,
subject: message.subject
)
end
end
Fourth, open file in /views/notifier/notification.html.erb and paste it. It’ll be shown to the user which will be responsible for the mails
<p><strong>Sender name: </strong><%= @message.name %></p> <p><strong>Sender email: </strong><%= @message.email %></p>
<p><strong>Message: </strong><%= @message.body %></p>
Fifth, added this file mailer.rb under the /config/initializers/
ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
:enable_starttls_auto => true,
:address => 'smtp.gmail.com',
:port => 587,
:domain => "testkg.com",
:user_name => 'test@gmail.com',
:password => 'myverysecretpassword',
:authentication => 'plain',
}
And finally lets add our form under the /views/contact/new.html.erb
<%= form_for @message, :url => {:action => "create"}, :html => {:method => :post} do |f| %>
<%= error_messages_for @message %>
<p> <%= f.label :name %><br/> <%= f.text_field :name %> </p>
<p> <%= f.label :email %><br/> <%= f.email_field :email %> </p>
<p> <%= f.label :subject %><br/> <%= f.text_field :subject %> </p>
<p> <%= f.label :body %><br/> <%= f.text_area :body, :rows => "3x3" %> </p>
<%= show_simple_captcha %>
<%= f.submit "Send" %>
<% end %>
As you can see below, show_simple_captcha helper of that gem which ‘ll generate all needed stuffs for captcha.
That’s it. I hope it can help to someone
Posted in Ruby on Rails | Tagged captcha, contact us form, rails, view | No Comments »
В последнее время Coffescript стал набирать абороты, и стали появляться разного рода проекты в гитхабе.
Что такое Coffescript ? Это совсем новый язык программирования, транслируемый в JavaScript. Он добавляет синтаксический сахар в духе Ruby, Python и Haskell для того, чтобы улучшить читаемость кода и уменьшить его размер. В среднем для выполнения одинаковых действий на CoffeeScript требуется в 2 раза меньше строк, чем JavaScript. JavaScript код, который скомпилируется из CoffeeScript полностью проходит проверку JavaScript Lint.
Итак, давайте сегодня поставим его в Ubuntu!
Сначала обновим систему:
$ sudo apt-get update
Потом установим нужные нам пакеты:
$ sudo apt-get install git-core curl build-essential openssl libssl-dev
Ставим сам Nod.js
$ git clone https://github.com/joyent/node.git && cd node
Запускаем инсталлятор
$ ./configure
$ make
$ sudo make install
$ cd
Ставим npm
$ curl http://npmjs.org/install.sh | sudo sh
И наконецто сам CoffeeScript
$ sudo npm install -g coffee-script
Posted in Ruby on Rails | No Comments »
Taglist: Exuberant ctags (http://ctags.sf.net) not found in PATH. Plugin is not loaded.
чтоб избавиться от этого нужно просто скопировать вот это ctags-5.8.tar.gz,
потом распоковать архив, ./configure
и добавить в ~/.vimrc файл
e.g. Windows:
let Tlist_Ctags_Cmd = ‘d:\tools\ctags.exe’
Unix:
let Tlist_Ctags_Cmd = ‘/usr/local/bin/ctags’
Posted in Linux/Ubuntu, Ruby on Rails | No Comments »
Вы Ruby, RoR разработчик, который хочет ускорить свой speed ? То тогда vim это то что надо!
Для начало давайте пройдем этап установки!
$ sudo apt-get install vim-common vim-runtime vim-gnome vimtutor
Кстати про vimtutor по подробней можете прочитать тут: Vimtutor
Теперь, когда Vim установлен, давайте установим Vim Ruby, который даст вам подсветку синтаксиса и другие интересные функции Ruby. При запуске vim-ruby-install.rb, оно создаст вам папку в корневой директории.
Вы стопудово столкнетесь с проблемой с при установке гема vim-ruby
Поэтому предлагаю вот что:
Для начала убедитесь что у вас установлен Git:
$ git clone http://github.com/vim-ruby/vim-ruby.git
$ cd vim-ruby/
$ rake package
$ gem install etc/package/vim-ruby-2011.04.07
$ ls -l
$ ruby vim-ruby-install.rb
1) /home/toast/.vim
2) /usr/share/vim/vimfiles
Выбираем 1, все, гем - vim-ruby установлен
Теперь давайте создадим файл .vimrc в дом. директории и вставьте
set nocompatible
syntax on
filetype plugin indent on
set mouse=a
runtime! macros/matchit.vim
augroup myfiletypes
autocmd! autocmd FileType ruby,eruby,yaml set ai sw=2 sts=2 et
augroup END
Теперь настройки: Ctrl+N -> Next Tab, Ctrl+P -> Prev Tab Ctrl+T -> New tab
set showtabline=2
set tabpagemax=15
nnoremap <silent> <C-n> :tabnext<CR>
nnoremap <silent> <C-p> :tabprevious<CR>
nnoremap <silent> <C-t> :tabnew<CR>
Теперь наконецто настал момент истины!
$ /.vim git://github.com/tpope/vim-rails.git
vim :helptags ~/.vim/doc
Все! теперь создайте какой нибудь проект на рельсах:
и например наберите в vim:
:Rmodel user
оно откроет вам модель user чтоб просмотреть все фитчи Rails-vim пройдите по этой ссылке
И конечно не забывайте о:
:help rails
Posted in Ruby on Rails | 2 Comments »
Steps to download, compile, and install are as follows. Note: Replace 0.9.8e with your version number:
Downloading OpenSSL:
Run the command below,
wget http://www.openssl.org/source/openssl-0.9.8e.tar.gz
Also, download the MD5 hash to verify the integrity of the downloaded file. In the same folder, where you downloaded the OpenSSL file, do the following:
wget http://www.openssl.org/source/openssl-0.9.8e.tar.gz.md5
md5sum openssl-0.9.8e.tar.gz
cat openssl-0.9.8e.tar.gz.md5
The last two commands (above) generate two strings of alpha-numeric characters. Check to see if both strings are identical or not. If not, repeat the steps above from «Downloading OpenSSL». If yes, your file has been downloaded properly. Please note that if you are using openssl for a highly secure/critical setup (or for any other reason) then you should also check the PGP signatures (not covered in this tutorial for simplicity).
Extracting files from the downloaded package:
tar -xvzf openssl-0.9.8e.tar.gz
Now, enter the directory where the package is extracted.
cd openssl-0.9.8e
Configuring OpenSSL:
./config —prefix=/usr/local/openssl —openssldir=/usr/local/openssl
Replace «/usr/local/openssl» above with the directory path where you want to copy the files and folders. Note: check for any error message.
make
Note: check for any error message.
Installing OpenSSL:
As root (for privileges on destination directory), run the following.
With sudo,
sudo make install
Without sudo,
make install
Note: check for any error messages.
Thats it. OpenSSL has been successfully installed.
Please feel free to use the comments form below if you have any questions or need more explanation on anything.
Posted in Linux/Ubuntu | Tagged how to openssl in Ubuntu | No Comments »
By default, MySQL database server remote access disabled for security reasons. However, some time you need to provide the remote access to database server from home or from web server.
Solution1
Step # 1: Login over ssh
First, login over ssh to remote MySQL database server
Step # 2: Enable networking
Once connected you need edit the mysql configuration file my.cfg using text editor such as vi.
In Debian Linux file is located at /etc/mysql/my.cnf
# vi /etc/my.cnf
Step # 3: Once file open, locate line that read as [mysqld]
Make sure line skip-networking is commented (or remove line) and add following line
bind-address=YOUR-SERVER-IP
For example, if your MySQL server IP is 172.20.5.2 then entire block should be look like as follows:
[mysqld]
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
language = /usr/share/mysql/English
bind-address = 172.20.5.2
# skip-networking
….
..
….
Where,
bind-address : IP address to bind to.
skip-networking : Don’t listen for TCP/IP connections at all. All interaction with mysqld must be made via Unix sockets. This option is highly recommended for systems where only local requests are allowed. Since you need to allow remote connection this line should removed from file or put it in comment state.
Step# 4 Save and Close the file.
Restart your mysql service to take change in effect
# /etc/init.d/mysql restart
Step # 5 Grant access to remote IP address
# mysql -u root –p mysql
Grant access to new database
If you want to add new database called foo for user bar and remote IP 162.54.10.20 then you need to type following commands at mysql> prompt:
mysql> CREATE DATABASE foo;
mysql> GRANT ALL ON foo.* TO bar@’162.54.10.20′ IDENTIFIED BY ‘PASSWORD’;
Grant access to existing database
Let us assume that you are always making connection from remote IP called 162.54.10.20 for database called webdb for user webadmin then you need to grant access to this IP address. At mysql> prompt type following command for existing database:
mysql> update db set Host=’162.54.10.20′ where Db=’webdb’;
mysql> update user set Host=’162.54.10.20′ where user=’webadmin’;
Step # 5: Logout of MySQL
Type exit command to logout mysql
mysql> exit
Step # 6: Test it
From remote system type command
$ mysql -u webadmin –h 172.20.5.2 –p
You can also use telnet to connect to port 3306 for testing purpose
$ telnet 172.20.5.2 3306
Solution 2
All you need to do is specify remote mysql host with –h option. For example to connect remote mysql server called server.test.com you need to type command as follows
$ mysql –u ruchi –h server.test.com -p
OR if you with to use MySQL server ip address (172.20.1.101)
Posted in Ruby on Rails | Tagged mysql-rails, remote mysql server | No Comments »
LAMP (Linux, Apache, MySQL and PHP) is an open source Web development platform that uses Linux as operating system, Apache as the Web server, MySQL as the relational database management system and PHP as the object-oriented scripting language.
We did show you in our previous post how to install LAMP in Ubuntu 10.04 with one command using tasksel command. It is a software installation application that is an integral part of the Debian installer and works under Ubuntu Linux too. It groups some packages by tasks and offers the user an easy way to install the packages for that task. It provides the same functionality as using conventional meta-packages. in Maverick this command dosn`t come by default, so we need to install it first before to perform the LAMP installation.
Open terminal and Type the command :install it first with
sudo apt-get install tasksel
Now to install LAMP, type the taskel command in terminal :
sudo tasksel
And select LAMP Server:
![]()
During the installation you will be asked to insert the mysql root password
![]()
Now check if php is working :
$sudo vi /var/www/info.php
and add
<?php phpinfo();?>#sudo /etc/init.d/apache2 restart
http://ip/info.php or http://localhost/info.php
Php is installed.To full manage your lamp Server database, install phpmyadmin
sudo apt-get install phpmyadmin
To login to phpmyadmin, open browser and type :
http://ip/phpmyadmin or http://localhost/phpmyadmin
Posted in PHP | No Comments »