Sunday, October 4, 2009
ruby and rails resources
Ruby-Language
Ruby Documentation
Ruby Support
Magazines:
The Rubyist
Rails Magazine
Code and Style:
Code and Style
Projects:
RubyGems
Rake
News:
Ruby Flow
Ruby Inside
Rails Inside
Videos:
Rails Casts
Ruby Libraries
Blogs:
Dave Thomas
Chad Fowler
Jim Weirich
Jamis Buck
Nathaniel Talbott
http://blog.grayproductions.net/
http://tim.theenchanter.com/
http://www.randquist.us/blog/
http://yehudakatz.com/
http://atmos.org/
http://squeejee.com/blog
http://blog.herdingtigers.com/
http://www.copiousfreetime.org/
http://blog.josephwilk.net/
http://evan.tiggerpalace.com/
http://satishtalim.com/
http://martinfowler.com/
http://www.chadfowler.com/
http://tomcopeland.blogs.com/
http://richkilmer.blogs.com/
James Golick
http://www.skorks.com/
http://blogs.thoughtworks.com/
http://testing.thoughtworks.com/
http://agileassessments.thoughtworks.com/
Wednesday, September 2, 2009
adding ruby gem sources
ERROR: could not find gem GEM_NAME locally or in a repository
then probably you might have missed the gem source if the name of gem is correct.
You can add a gem source link using command-
gem sources -a source_link
To view existing gem sources-
gem sources
Few gems sources-
http://gems.rubyforge.org/
http://gems.github.com
Monday, August 31, 2009
installing memcached on CentOS
This is a step by step guide to installing memcached from source on CentOS. The version of CentOS that I am using is CentOS release 5.2 (Final); to find what version you are using:
cat /etc/redhat-release
First, install the dependency libevent:
cd /usr/local/src
curl -O http://monkey.org/~provos/libevent-1.4.9-stable.tar.gz
tar xzvf libevent-1.4.9-stable.tar.gz
cd libevent-1.4.9-stable
./configure --prefix=/usr/local
make
make install
Next, install memcached:
cd /usr/local/src
curl -O http://www.danga.com/memcached/dist/memcached-1.2.6.tar.gz
tar xzvf memcached-1.2.6.tar.gz
cd memcached-1.2.6
LDFLAGS='-Wl,--rpath /usr/local/lib' ./configure --prefix=/usr/local
make
make install
Verify that memcached starts:
memcached -u root -d
If there were no errors, make sure it is running:
ps aux | grep memcached
And finally, to stop memcached:
pkill memcached
These instructions prevent the following errors:
memcached: error while loading shared libraries: libevent-1.4.so.2:
cannot open shared object file: No such file or directory
configure: error: libevent is required
If it's already installed, specify its path using --with-libevent=/dir/
Saturday, August 29, 2009
top ten useful linux commands
1. List command
ls -a
// lists all
ls -l
// lists all files including hidden files like .htaccess
ls -l | more
// shows in paged format with pipe
2. Untarring the uploaded tar.gz files
This command is the most important command and often regularly used to uncompress files..
tar -xzf filename.tar.g
How to dump/Import tar.gz (zipped) file into MySQL database
SSH command to restore/import gzipped large databases to mysql on the fly with just one single command. This is so useful as large databases can only be imported to mysql this way! Remember to upload the database dump before you issue this command
gunzip <>
3. Installing packages
Installing softwares in linux the most basic and you will need to know this command very well .
yum install
// for centos and redhat
apt-get install
// for debian/ubuntu
4. To look for memory usage
top
// shows the memory, cpu load and other processes running
free
// shows the memory usage of linux
5. To see the disk usage.
df -h
// shows the disk usage and outputs the disk usage left
6. To view running processes
ps aux
// shows the running processes and its ID. You can use this ID to kill the process later.
ps aux | grep "process_name" [eg. ruby script/server]
//To see specific process
kill -9 pid
// to kill the process
7. Deleting all files within a folder
This perhaps is one of the most sought after command to delete all subfiles and subfolders in linux with just one command in a fly.
rm -Rf /my/path
// this deletes all files. so be careful!
8. Edit a file in easy way!
I love nano command. Its just so easy to edit a file with menu options and save changes. You can easily search for specific text inside the file with the nano editor.
nano /file/path
// text editor to edit files
9. Changing Permissions and Ownership
whats there in linux without permissions and ownership
chmod -R 755 /folder/path
// this recursively changes all files and folders of the path.
chown pbu /file/name
//changes the ownership of filename
chgrp mygrp /file/name
//changes the group to new one
If you dont know how to interpret the 755 or number like permissions here is an easy way to remember
Ex: 755 means rwxr-xr-x
7 -> rwx (for owner)
5 -> r-x (non writable for group)
5 -> r-x (non writable for world)
First we consider '7' in 755 as it is made up of 3 bit binary. To construct 7 we need to construct 111(which is 4+2+1 in decimal).
5 -> 101 ( which is 4+0+1)
5 -> 101 (which is 4+0+1)
Remember 755 is the decimal of the binary and it is always made up of 4+2+1.
10. To find out what ports are open
Finding which ports are open and closed are so important in terms of security point of your server. You might want to close unwanted services using different ports.
netstat -nap --tcp
// lists connections and what ports are open.
OR
nmap fuser localhost
// easy command
Install firewall to block unwanted ports running on your PC or in server.
FAQs
How do i change root password?
Just login as root or su root and type passwd, you will be asked for new password.
> passwd
// Be CAREFUL! If you forget your new password, you will lock yourself
I am installing a firewall in my linux server? How do i know which ports to block and to open?
When installing firewall be sure to block all unwanted open ports. A comprehensive collection of ports and services run at that port can be found here
Here is the short of ports which needs to be kept open for listening.
Common ports
21 => FTP
22 => SSH
25 => SMTP Mail Transfer
43 => WHOIS service
53 => name server (DNS)
80 => HTTP (Web server)
110 => POP protocol (for email)
143 => IMAP Protocol (for email)
443 => SSL for HTTP
Cpanel => 2077,2078,2082,2083,2086,2087,2089,2095,2096,3306, 6666.
Plesk => 8443
Webmin => 10000
If you have root permissions, you can login to your server control panel like this...
https://ipaddress:2087/
// for cpanel
https://ipaddress:8443/
// for plesk
Hope my ports compilation should be helpful for beginners who use linux.
investigating port on Windows XP and Linux
How to Investigate a port in Windows XP
If you find anything suspicious going on in your computer, you can investigate a port in your PC with windows xp task manager program. Many worms, viruses and trojans mailiciously download harmful scripts to your computer using different ports that you may not know. The best way to protect your PC from such worms and trojans is by using a firewall. You can use comodo firewall which can be downloaded free of charge.To investigate a port and see what programs are using, can be done easily in 2 steps
1. Go to Start > Run > command
2. At the command prompt type netstat -noa
3. Look for connections with LISTENING and ESTABLISHED. Note that port numbers will be identified in the form of 127.0.0.1:1092 (IP address followed by colon is the port number). In this case 1092 is the port.
4. Note the PID (process id) for that port and this process id corresponds to program using it.
5. Next we will find out that PID with windows task manager program.
6. Go to ALT+CTRL+DEL then press task manager button. You will see the processes listed and the memory.
Note: By default with task manager it will not show the PID of the processes. You have to enable it from the options menu.
Should you find the running process to be suspicious just end the process.
Tip: Use a firewall like ZoneAlarm or Comodo Firewall (both are free) to block suspicious programs running on your PC.
How to Investigate a Port in Linux
It is very easy to investigate a port and kill that process in your linux server or box.- First find the ports that are active and listening to.
- Note the port and the process ID (PID)
- Find which processes is running based on that PID
- If you find anything suspicious, kill that process.
// lists both TCP and UDP connections (listening and established)
// this command tells which program is running this process id
pidof
// alternate command
Friday, August 28, 2009
Thursday, August 27, 2009
using rails environment specific commands
For mongrel/Else
mongrel_rails start -e production/ ruby script/server -e production
For rake command:
rake [task] RAILS_ENV=production
For ruby console:
ruby script/console production
Tuesday, August 25, 2009
why rails is majestic rails?
* MVC/AGILE architecture: Ruby on Rails is based on the MVC (Model View Controller) architecture that enables the data to be separated from presentation. It's an agile web development framework.
* Database Access Library: Ruby on Rails includes a database access library - Active Record - that simplifies data handling in databases. Active Record automatically maps tables to classes and rows to objects.
* Libraries for common tasks: Ruby on Rails includes a host of libraries that simplify the coding of common programming tasks such as form validations, sessions management, etc.
* AJAX Library: An extensive library of AJAX functions is provided in the Rails framework. Ruby code can be used to generate AJAX code. The associated java scripting required for AJX gets generated automatically.
* Convention over configuration: Ruby on Rails does not have any XML configuration files. It includes simple programming conventions that can be used to specify the configuration parameters.
* Customized URL: Custom or Search Engine Friendly URLs can be developed using the Ruby on Rails framework.
* Debugging: Detailed error logs are provided, making it easier to debug applications.
* Components: Components can be used to store reusable code. Components can be included to modularize templates.
* DRY: Don't Repeat Yourself. You will get it when you actually write the rails code.