To install RMagic gem for graphic operations in fedora os follow the below instructions
open terminal by Application -> System Tools -> Terminal
login as root by giving command su
#su
#password: enter root password
goto ruby path
#cd usr/lib/ruby
issue the below command
[root@localhost ruby]gem install rmagick --no-rdoc --no-ri
you should see the below message if successfully installed RMagic gem
Building native extensions. This could take a while...
Successfully installed rmagick-2.12.2
1 gem installed
To see the gem in your local gems list issue the below command
[root@localhost ruby]# gem list --local
*** LOCAL GEMS ***
actionmailer (2.3.4)
-------------------
-------------------
Rmagic(2.12.2)
------------------
etc.,
For Windows users
c:\> gem install rmagick-2.0.0-x86-mswin32.gem
Bydefault gem install will look for the particular gem name in rubyforge site.
You can also mention the path for git repository if the gem is available in github.
Wednesday, December 30, 2009
Installing RMagic in fedora
Thursday, December 24, 2009
Rails error: initialize_without_backlog': Address already in use - bind(2)
If you already start the server one one application, stop it for that application and run for the new application you want.
Good Luck -:)
Wednesday, December 23, 2009
Item Stock Availability check for oscommerce
display on each product relating to the availability of the item.
Two messages can be set, one for in-stock and another for out of stock.
Includes convenient admin tool to add and modify the messages
menu on the product edit page. Allows you to include the actual
stock quantity in the message.
donwload this addon from below url
http://addons.oscommerce.com/info/4948
Userfull admin features in oscommerce
Manage administrators
Manage Administrators including add new admin, or edit / delte admin information.
Manage customers
View and manage the customers registered to the site
Manage orders
Process and Manage orders made by customers
Categories, subcatagories and products
Managing all categories, subcategories and products in the site. Site admin can add/ edit or delete catgories, subcategories and products.
Product Attributes
Managing all product attributes like color, price etc.,
Product Reviews
View the statistics of each product reviewed by customer
Multilanguage
Site was entirely in multilanguage. Admin can manage the content for each locationization.
Reports
View the reports of products viewed, products purchased
Send Emails
Sending emails to customers
Monday, December 21, 2009
Wednesday, December 16, 2009
PHP sending emails with gmail smtp to prevent spam mails
1 | Download PHPMailer from http://phpmailer.sourceforge.net |
2 | Extract to folder phpmailer |
3 | Create a file email.php |
4 | Paste this code and change the values in blue as you need (I modified the sample code given on the PHPMailer homepage) require("phpmailer/class.phpmailer.php"); |
5 | Open the file class.smtp.php in phpmailer directory |
6 | Paste this code $host = "ssl://smtp.gmail.com"; $port = 465; before the line 104 #connect to the smtp server Hint: Search for #connect |
7 | Open this page in browser and it will send the email using GMail. |
Hint: When you want to email the details from a form, set the variables using the form variables. eg. $mail->Username=$_POST['email'] |
Thursday, November 26, 2009
Jquery datagrid for rails applications
Rails Developement Standards
Never put log files or database.yml file into subversion.
Use either Postrgres, Oracle or Mysql for your db.
Session data should be stored in the database
Migrations should NOT contain any db specific SQL.
Use Rspec for testing. Rspec is available as plugin
Application must have Unit and Functional tests.
All application gems should be installed in RAILS_ROOT/vendor/gems folder
Always freeze rails, ( Fix For rails freeze gems )
If your application uses CAS authentication, use the ucb_rails_security plugin
Controller Methods should be no longer than 5-8 lines of code. If you find your self with really large controller methods you are probably violating the following standard.
Application domain logic should go into the model, NOT in the controller or view.
Try to limit each controller's actions to: index, new, create, edit, update, destroy. This is not always possible. However, if you notice that a given controller has more than 10 methods, it probably time to refactor.
Preventing open a new window for each folder in linux
2. Go to the "Edit" menu and choose "Preferences."
3. Click on the "Behavior" tab.
4. Put a check in the box marked "Always open in browser windows
Sending Tons of emails from your Ruby on Rails Application
Ruby on Rails Easy roles plugin
cd yourappname
ruby script/plugin install git://github.com/platform45/easy_roles.git
Now the plugin is installed in your vendor/plugins folder
Below is the Basic Setup process you need to do after plugin installed successfully
Add the following to your enviroment.rb in the rails initializer block
config.gem 'easy_roles', :source => 'http://gemcutter.org'
Add a "roles" column to your users model, and set the default value to "--- []". Please note you can call this column anything you like, I like to use the name "roles" for meaning full.
For users table migration table add below
t.string :roles, :default => "--- []"
Then you need to add "easy_roles :column_name" and some logic to your model.
class User < ActiveRecord::Base
# Serialize roles as an array
serialize :roles, Array
# Create an empty roles array on create
before_validation_on_create :make_default_roles
# Convenience method, is user an admin?
def admin?
has_role?("admin")
end
# Checks to see if a user has requested role
def has_role?(role)
roles.include?(role)
end
# Add a role to a user
def add_role(role)
self.roles << role
end
# Remove a role from a user
def remove_role(role)
self.roles.delete(role)
end
# Clear all users roles
def clear_roles
self.roles = []
end
private
def make_default_roles
clear_roles if roles.nil?
end
end
And thats it.
The above model gives you the options like below in controllers
@user = User.first
@user.add_role 'admin'
@user.save!
@user.has_role? 'admin'
=> true
@user.admin?
=> true
@user.remove_role 'admin'
@user.save!
@user.admin?
=> false
Usage
Easy roles extends your model, and adds a few methods needed for basic role authorization.
adding a role to a user
add_role 'role'
removing a role from a user
remove_role 'role'
check to see if a user has a certain role
has_role? 'role'
# or
is_role? # role being anything you like, for example 'is_admin?' or 'is_awesome?'
== Examples
@user = User.first
@user.add_role 'admin'
@user.is_admin?
=> true
@user.has_role? 'admin'
=> true
@user.is_awesome?
=> false
@user.add_role 'awesome'
@user.is_awesome?
=> true
@user.remove_role 'admin'
@user.is_admin?
=> false
etc etc
== Protecting controllers
There are many ways to implement views for specific roles, so I did not specifically supply one. Here's an example on what you could do:
class ApplicationController < ActionController::Base
def admin_required
unless current_user && current_user.is_admin?
flash[:error] = "Sorry, you don't have access to that."
redirect_to root_url and return false
end
end
end
Then in your AdminsController or any controller that you only want admins to view:
class AdminsController < ApplicationController
before_filter :admin_required
end
class MarksController < ApplicationController
before_filter :admin_required, :only => :create, :update
end
check out more information at
http://blog.platform45.com/2009/10/05/howto-basic-roles-for-users for implementation
World's Famous IDE eclipse's support for PHP
If you already installed eclipse in your system then you have to update it for php support. To do so follow the below steps
1. Open the eclipse IDE
2. Then goto menu Help -> Software updates
There you see Two main tabs Installed softwares and Available softwares. If phpeclipse is not there in installed softwares list then check in Available softwares list. If not avaliable there also Then click on Add site and enter below url.
http://update.phpeclipse.net/update/stable/1.2.x
Then that eclipse's update url is added to available softwares list. Check that module and click install. It will take few minutes and install phpeclipse and PDT (PHP Development Tools) to your existing eclipse IDE.
After installed successfully Goto menu Window -> open perspective
and select PHP to start working on PHP Projects.
The process is same to enable any other technologies support in eclipse for developing applications.
If you are not installed eclipse IDE in your system then you can directly install it from the official website http://www.eclipse.org/
Tuesday, November 24, 2009
File permissions in Linux
By using chown command through terminal you can give file permissions to the users in linux operating systems without login as root. By default you are not able to access some folders in the linux os due to the security reasons. But sometimes you need to access some folders. Ex: If you want to run php files you need to place the files in the folder called /var/www/html but other than root account no one have write permission to this folder.
So if you want to enable write permissions to that folder for your account simply
open the terminal as
# applications > system tools > Terminal
enter su in the terminal to login as root
#su
it will ask you the root password, give the root password
then run the below command
#chown username /var/www/html/
Now you have the write permissions to that folder.
Flash Plugin for Firefox in Fedora11 OS
http://labs.adobe.com/downloads/flashplayer10.html
and download the linux version tar file uncompress the tar file and Copy the file libflashplayer.so in to the folder /usr/lib/mozilla/plugins.
That's it you just need to restart the firefox by File -> Exit and see your firefox is now enabled with flash support.
Tuesday, November 17, 2009
Youtube clone
Friday, November 6, 2009
Googlemap show Directions between two places
var map;
var directionsPanel;
var directions;
function initialize() {
map = new GMap2(document.getElementById("map_canvas"));
map.setCenter(new GLatLng(42.351505,-71.094455),12);
directionsPanel = document.getElementById("route");
directions = new GDirections(map, directionsPanel);
directions.load("from:kakinada,india to:Kurnool,india");
}
Place the two divs in html body with ids map_convas, route
Call onload="initialize()" onunload="GUnload()" in body tag.
directions.load("from:kakinada,india to:Kurnool,india");
here you you can also place lat,long pairs in place of from and two address
Some usefull sites for Ruby on Rails newbies
study all activerecord, actionview and actioncontroller classes
Ex: classes -> active record::call backs
which explains what action done before or after creating a record in database or before deleting a record from one table what needs to done in other tables etc
Ruby hashes. Means associatinve arrays in php. Each values is associated with one key like $array=new array(‘color’ => ‘whilte’ , ‘Height’ => ‘6 feet’)
http://www.rubyonrailsexamples.com/category/ruby-hash/
Validation classes and lot more
http://apidock.com/rails/ActiveRecord/Validations/ClassMethods
http://apidock.com/rails/ActiveRecord/Base
All methods and available for active record like save update delete etc
*********************************
Find Some things to look at
http://www.palmcoder.net/?p=265
Tutorials
Rails ajax (Implementing remote call is very easy in RoR)
http://onlamp.com/onlamp/2005/06/09/rails_ajax.html
Link_to_remote with passing textbox value as a parameter
http://onlamp.com/onlamp/2005/06/09/rails_ajax.html
Forum
http://railsforum.com
Check username availablility
http://railsforum.com/viewtopic.php?id=22828
Gems
http://ariejan.net/gems/
http://www.digitalmediaminute.com/article/1816/top-ruby-on-rails-tutorials
Testing
http://www.tutorialspoint.com/ruby-on-rails-2.1/rails-unit-testing.htm
Ruby on Rails Easy Deployment
http://b.lesseverything.com/2008/8/25/comparing-php-to-ruby-on-rails
Pagination gem for Ruby on Rails
1. rake gems:install
2. gem sources -a http://gems.github.com
3. gem install mislav-will_paginate
For the first time to install gems package run step 1. If you already run this command no need to run again. step 2 is to append the gems to your rails. Step 3 will install the will_paginate gem to your application.
Usage:
After installed gem successfully follow the below steps to enable pagination to your models.
1. In your config\environment.rb file add
Rails::initializer.run do |config|
config.gem 'mislav-will_paginate', :version => '~> 2.2.3', :lib => 'will_paginate', :source => 'http://gems.github.com'
end
2. rake gems:install
3. In your model, mention how many records display per page
def self.per_page
5
end
4. In your controller, replace
@yourmodels = Yourmodel.find
with
@yourmodels = Yourmodel.paginate :page => params[:page], :order => 'created_at DESC'
5. In your index view, add below to see the pagination
<%= will_paginate @models %>
see http://localhost:3000/models
-----------------------End-------------------------------------------
Thursday, September 17, 2009
Cupcake A forum plugin for cakephp
Download: http://www.milesj.me/resources/script/forum-plugin
Demo: http://www.milesj.me/forum
Wednesday, September 9, 2009
Sobi2 Plugin
See All About Sobi2
PHP Dynamic Timezones Setting
date_default_timezone_set('Timezone')
here 'Timezone' is the string for example for setting Indian Standard Time it is "Asia/Calcutta", for Los Angels it is "America/Los_Angeles" etc
Ex: date_default_timezone_set('Asia/Calcutta')
Checkout the timezones list at php.net
Tuesday, August 4, 2009
Friday, July 17, 2009
Geolocalization to get lattitude and longitude values
Copy paste options are not working in dreamweaver
The solution that i got from somewhere was to basically clear the configurations for dreamweaver.
C:\Documents and Settings\
To acertain if this is the case, you can simply test it by moving the configuration folder to somewhere else. If it still doesnt work, simply put it back.
Now my dreamweaver works fine again without having to reinstall it.
Encoding and Decoding the strings in PHP
Ex code:
';
$encode=base64_encode($str);
echo 'Encoded : ',$encode,'
';
echo 'Decoded : ',base64_decode($encode);
?>
How to clear file upload field value using js
But we can do it simply as below.
First take that file field in div or any other container tags like span etc.,
and in js give that div's innerHTML as input type="file" name="img". So new file upload element is created within that div.
Thursday, July 16, 2009
About Joomla module
Example: “online friends” is one module which can be placed in different pages at what ever position we want.
There are so many modules available freely at http://extensions.joomla.org/
You can develop your own module for any of specific purpose and call it in all pages or some of the pages you want.