Codeigniter help site

by Noman Muhammad

http://www.phpeveryday.com/articles/CodeIgniter-Introduction-to-CodeIgniter-Framework-P146.html http://www.developertutorials.com/tutorials/php/rapid-application-development-with-codeigniter-8-02-17/page4.html
http://opinionatedcoder.wordpress.com/2008/05/19/codeigniter-tutorial-part-2-htaccess/
http://godbit.com/article/introduction-to-code-igniter
http://godbit.com/article/introduction-to-code-igniter-part-2
http://godbit.com/article/introduction-to-code-igniter-part-3
http://afruj.wordpress.com/2008/05/02/some-codeigniter-tutorial-links/
http://www.tomcode.com/inside/codeigniter/userauth/test/
CodeIgniter AJAX With jQuery
CodeIgniter AJAX With jQuery-2
http://www.codeigniterdirectory.com/
http://remysharp.com/2008/03/25/codeigniter/
http://www.alexajax.com
CI and set_checkbox()
CI and set_checkbox()
http://codeextinguisher.com/index.php/documentation
http://michaelwales.com/tutorials/codeigniter-ajax-with-jquery/

Codeigniter and Jquery
http://www.mrforbes.com/wordpress/2007/05/13/a-quick-code-igniter-and-jquery-ajax-tutorial/
http://littlebrain.org/2008/05/27/codeigniter-and-ajax-using-jquery-tutorial/
http://www.alexajax.com/feedback
http://codeigniter.com/wiki/AJAX_for_CodeIgniter/
http://blog.heuristicdesign.co.uk/archives/2008/02/01/code-igniter-authentication-with-erkana-auth/
http://codeigniter.com/wiki/Special:Categories
http://codeigniter.com/wiki/FreakAuth/
http://afruj.wordpress.com/2008/07/15/more-information-on-codeigniter/
CI templating
http://maestric.com/en/doc/php/codeigniter_template

Free Php Photo Gallery: SelectaPix Image Gallery

by Noman Muhammad

Last week i googling for a Php photo gallery and found many. I try some of them and at last use SelectaPix Image Gallery. It seems very handy and useful to me as it is database supported. Though the instructions are very easy to implement, i found some error when i run the Gallery. It may be for that the config file is not included everywhere correctly. Then i add this line

include('includes/config.php');
to Two files (classes/top_cat.php and classes/sub_cat.php).
I add lightbox Javascript to modify the full image view. Lightbox is a simple, unobtrusive script used to overlay images on the current page. According to the instruction of lightbox Javascript keep the folders in appropriate place and then modify classes/sub_cat.php file to bring lightbox in action :D

SelectaPix Image Gallery with lightbox.

Job scheduler in RoR

by Noman Muhammad

BackgroundRb is a Ruby job server and scheduler. In this post i'll create a simple RoR project in which using backgrounDRb we will fetch data from database and logged them in the log file.

1) pre-requisites: two gem => chronic, packet [in my case the current version of packet doesn't work, so i download the packet version: 0.1.5 from rubyforge and then manually install it]
(*) install chronic :
~# sudo gem install chronic
(*) install packet :
~# sudo gem install /path/to/your/directory/packet-0.1.5.gem

2) download backgrounDRb from http://github.com/gnufied/backgroundrb/tree/master and extract the .tar/.zip file and rename the folder backgroundrb. Store this folder in projects_name/vendor/plugins

3) now setup backgrounDRb
~# rake backgroundrb:setup

4) now create your own worker class
~# ./script/generate worker fetcher
---- here fetcher is the worker name, this command will create fetcher_worker.rb file in /libs/worker folder. my fetcher_worker.rb is as follows:
----------------------------------------------------------------------------------------------

class FetcherWorker < BackgrounDRb::MetaWorker
set_worker_name :fetcher_worker

def create(args = nil)
#this method is called, when worker is loaded for the first time
logger.info "Created feeds worker"
end

def update()
logger.info "Hello UPDATE"
@posts = Post.find(:all)

for post in @posts
logger.info post.name
end
end
end

---------------------------------------------------------------------------------------

Implementing live validation in Ruby on Rails

by Noman Muhammad

LiveValidation is a small open source javascript library for making client-side validation quick, easy, and powerful. livevalidation plugin is used to integrate Javascript library LiveValidation to the Rails application. LiveValidation implements client-side form validation. To see livevalidation in action ( !!! ) we have to install it in our rails project. Then use Rails validation helpers to validate our models and use Rails form helpers to create our forms.

here is the example steps how i make it live in my project. [i use Netbeans 6.0 to build my app]

1. create a new project
2. run Rake Task to create the db
3. generate scaffold with this parameter in the [Model Name:] text field

Blog title:string body:text
4. now, download livevalidation plugin from github
5. unzip the downloaded zip folder and rename the folder 'livevalidation'
6. store 'livevalidation' folder in the "\vendor\plugins\" folder. [i.e. \vendor\plugins\livevalidation]
7. now install Javascript and CSS with this Rake task
$ rake livevalidation:install

8. add these lines in /views/layout/blogs.html.erb
<%= javascript_include_tag :defaults, 'live_validation' %>
<%= stylesheet_link_tag 'live_validation' %>
9. now add validations to the model
validates_presence_of :title
10. now start the server and go to http://localhost:3000/blogs/new
11. when you leave title textfield without entering any value, you will get an error in RED and when you type something in that field you will get a thnx :) . so its working

Ruby on Rails installation in Ubuntu

by Noman Muhammad

i'm using Ubuntu 8.10. here is the steps how i install RoR in ubuntu. i get this instruction from Ubuntu Community documentation. I just mention here the steps that i do to install RoR.

1. at first open the terminal and to get Ruby run this command

sudo apt-get install ruby-full build-essential
this command also install a web server named 'WEBrick'

2. Now to download and install ruby gems we to run the following command one after another
wget http://rubyforge.org/frs/download.php/45905/rubygems-1.3.1.tgz
tar xzvf rubygems-1.3.1.tgz
cd rubygems-1.3.1
sudo ruby setup.rb
sudo ln -s /usr/bin/gem1.8 /usr/bin/gem
sudo gem update --system
this will install Rubygems 1.3.1

3. then we install RAILS as gem
sudo gem install rails
4. so, RoR is installed in Ubuntu.

5. now we will install MySQL database and it's connector
sudo apt-get install mysql-server mysql-client
sudo apt-get install libmysql-ruby libmysqlclient-dev
sudo gem install mysql
6. now to create a new rails application run this command
rails /home/www/test_app -d mysql
this will create a new applicaton named 'test_app' in '/home/www' directory

7. now to run the application do the following
$cd /home/www/test_app
$ruby script/server

then go to open the browser and go to 'http://0.0.0.0:3000'. new application will respond

AutoCompleter example in Ruby on rails

by Noman Muhammad

in Ruby on Rails adding auto complete textbox is pretty simple. here is a simple example of it ...
in this example there will be 2 tables in DB. Customers table & Messages table. In the Customers table customer name and address will be saved. In the Messages table customer name and message to that customer will be saved. In the message form if we start typing the customer name, the name of the customers will be shown and we can select a particular customer name. that all. so lets start ...

Here i use Netbeans 6.0 as IDE

1. first create a new rails project.
2. run Rake Task to create the db
3. generate scaffold with this parameter in the [Model Name:] text field

Customer name:string address:text
4. run Migrate Database to create the customers table
5. now run this project
6. in the browser go to http://localhost:3000/customers and add some customers name and address
7. now generate another scaffold with this parameter in the [Model Name:] text field
Message to:string body:text
8. run Migrate Database to create the messages table
9. now the plugin Auto_complete have to be downloaded
10. download auto_complete plugins from github
11. unzip the downloaded zip folder and rename the folder 'auto_complete'
11. store 'auto_complete' folder in the "\vendor\plugins\" folder. [i.e. \vendor\plugins\auto_complete]
12. now, open the file 'messages.html.erb' from \app\views\layouts and add the following line before tag
<%= javascript_include_tag :defaults %>
13. now, open the file 'new.html.erb' from app\views\messages and change this line
<%= f.text_field :to %>
to
<%= text_field_with_auto_complete 'message', 'to',{}, :skip_style => false  %>
14. open MessageController and add this line
skip_before_filter :verify_authenticity_token, :only => [:auto_complete_for_message_to]
after this
class MessagesController < ApplicationController

15. add this new function in this controller:
def auto_complete_for_message_to()
user_name = params[:message][:to]
@customers = Customer.find(:all , :conditions=>"name like '%"+user_name.downcase+"%'")
render :partial => 'username'
end

16. now create a new partial file in app\views\messages and name it _username.html.erb
17. paste this code in this partial file
<ul class="allusers"><% for customer in @customers do %><li class="thisuser"><div class="useremail"><%=h customer.name %></div><div class="username"><span class="informal"><%=h customer.address %></span></div></li><% end %></ul>

18. now restart server and in the browser go to http://localhost:3000/messages and now in the to field start typing u'll see some name coming from DB.
19. so its woking !!!!!!!!!!!!!!!!!!!!!!!!!!!

New font install in Ubuntu

by Noman Muhammad

we sometimes need to install new font in Ubuntu. To do so first download the desired truetype font(.ttf) and save it in ur harddisk. Then copy the .ttf file to truetype folder of the Ubuntu by running this command in the terminal >

sudo cp /location_of_the_downloaded_font/downloaded_font.ttf /usr/share/fonts/truetype

then run this command in the terminal
sudo fc-cache -f

using VIM in ubuntu

by Noman Muhammad

in Ubuntu we often have to use vim(text editor) to edit different type of files. here is some command to get familiar with this editor ... type the following on the terminal

vim file_name

to start editing press [Insert] button ... then u can edit the file as usually
to finish editing press [Esc] button
then press [Shift] button + [:] button
if u want to save what u do then press [x] button
or
if u want not to save the changed items then press [q] button + [!] button
then to exit press [Enter] button

actually there are lots of commands to run ... but this are i frequently use .....

to know ins & outs of vim visit this

Change MAC address in Ubuntu temporarily

by Noman Muhammad

i have to change my MAC address in Ubuntu for temporary basis. so i do the following in the terminal:

ifconfig eth0 down
ifconfig eth0 hw ether 01:02:03:04:05:06
ifconfig eth0 up
first command will down the network, then 2nd command change my MAC [ 01:02:03:04:05:06 is replaced by my desired MAC address] and then 3rd one again up my network.
to see the change type ifconfig in the terminal and press Enter. changed MAC address will be shown ...
simple ..... huh ;)

but remember there may be easier solution then that i dont know :(

Is there any one click php-mysql installer in Ubuntu??

by Noman Muhammad

I dont find any xampp or wamp like installer for Ubuntu. But run the following command in the terminal and get things done ... :) wow

sudo apt-get install apache2 php5 mysql-client-5.0 mysql-server-5.0 libapache2- mod-php5 libapache2-mod-auth-mysql php5-mysql php5-cli


then from terminal connect to mysql or in the browser type "http://localhost/" and get
It Works!

u can also install PhpMyAdmin in the same way or from Synaptic Package manager.

Ruby on rails installation on Windows

by Noman Muhammad

a. First, let's check to see if you already have Ruby installed. Bring up a command prompt and and type ruby -v. If Ruby responds, and if it shows a version number at or above 1.8.2 then type gem --version. If you don.t get an error, skip to step 3. Otherwise, we.ll install a fresh Ruby.
b. If Ruby is not installed, then download an installation package from rubyinstaller.rubyforge.org. Follow the download link, and run the resulting installer. This is an exe like ruby186-25.exe and will be installed in a single click. You may as well install everything . It's a very small package, and you'll get RubyGems as well alongwith this package. Please check Release Notes for more detail.
c. With RubyGems loaded, you can install all of Rails and its dependencies through the command line:

C:\> gem install rails --include-dependencies
Keeping Rails Up-to-Date:
Assuming you installed Rails using RubyGems, keeping up-to-date is relatively easy. Issue the following command:
C:\> gem update rails
This will automatically update your Rails installation. The next time you restart your application it will pick up this latest version of Rails. While giving this command, make sure you are connected to the internet.

Installation Verification
You can verify if everything is setup according to your requirements or not. Use the following command to create a demo project.
C:\> rails demo
This will generate a demo rail project, we will discuss about it later. Currently we have to check if envrionment is setup or not. Now next use the following command to run WEBrick web server on your machine.

C:\> cd demo
C:\demo> ruby script/server
=> Rails application started on http://0.0.0.0:3000
=> Ctrl-C to shutdown server; call with --help for options
[2007-02-26 09:16:43] INFO WEBrick 1.3.1
[2007-02-26 09:16:43] INFO ruby 1.8.2 (2004-08-24)...
[2007-02-26 09:16:43] INFO WEBrick::HTTPServer-start:pid=2836...
....
Now open your browser and type the following address text box.
http://localhost:3000

new comer in the blog world

by Noman Muhammad

Hello everyone

start my journey on knowledge sharing world. This is 9th Feb' 09. So its a historic day for me. isn't it? ... :D