আমি যে উদাহরণ গুলো দেখাব তাতে আমি সম্পুর্ণ কোড দেখাব না।jQuery র কোড গুলো আপনাকে আবশ্যই এর ভেতর tag দিয়ে লেখতে হবে।
Javascript এ যারা window.onload() function নিয়ে কাজ করেছেন তারা হয়ত খেয়াল করেছেন, এর মাধ্যমে কল করা কোন ফাংশন তখনই execute হয় যখন page এর সব object ও content load হয় ।মানে হচ্ছে কোন image যদি কোন কারণে লোড না হতে পারে তাহলে আপনার onload() এর দ্বারা যে ফাংশন কল করা হয়েছে তা আর execute হবে না।jquery তে .ready() function অনেকটা onload এর মত।difference হল এটাতে কোন page এর dom object গুলো যদি jquery হাতে পায় তাহলেই সে তার কাজ শুরু করে দেয় ।আর dom কে আপনি html এর বড় ভাই-ই বলতে পারেন তাই এগুলো একটু তাড়াতাড়ি-ই load হয় ।কারন,আপনি যদি আমাকে বলেন,তাহলে আমি বলব একটি page এ h1 নামের কোন element থাকলে সেটা লোড হতে যদি কোন সমস্যা না হয় তাহলে dom load হতেও কোন সমস্যা হওয়ার কথা না।
আর একটা জিনিস হল ready() function টি আপনার যতবার দরকার ততবার-ই কল করতে পারবেন ।
মাঝে মাঝে $(document).ready() ; কে “ $(); “ দিয়ে replace করে shortcut-এ

$ (function(){ your code here });

লেখা হয়।
চলুন এখন jQuery function গুলোর দিকে নজর দেই
jQuery( html ) / $(html):
ধরুন আপনি চাচ্ছেন user কে তার action এর উপর depend করে কোন লেখা দেখাবেন,যেমন

$(document).ready(
function(){
$("

Hello

").appendTo("body");
}
);

এখনই কোন action define করলাম না বুঝার সুবিধার জন্য।এই কোডটি আপনার page এ একটা Hello লেখা দেখাবে।এখানে যা হল,তা হচ্ছে
আমরা $(এখানে html code লেখেছি) পরে তা appendeTo() দিয়ে html body তে add করেছি ।যদিও আপনি html source code দেখলে Hello লেখা খুজে পাবেন না। পরে action assign করলে আরও ভালো করে এ জিনিসটি বুঝবেন আর এর কাজটা দেখবেন কত মজার।
চলুন এটাতে একটা action assign করি

$("

Hello

").appendTo("body").click(function(){$(this).text(“jQuery”)});

এখানে আমি যা করতে চাচ্ছি তা হল Hello লেখাটিতে যখন কেউ click করবে তখন একটা function কাজ করুক,এবং ‘this’ means->

এর মধ্যেই

“jQuery লেখাটা দেখাও,যেখানে Hello লেখাটা আছে এবং আমরা এ কাজটি করছি .text() এর মাধ্যমে।দেখলেনত কত মজার।এভাবে আরও কিছুদুর এগুলে আপনি নিজেই user এর এক click এ পুরো page এর চেহারা বদলে দিতে পারবেন।এখানে text() এর কাজ নিয়ে আমরা পরে বিস্তারিত বলব।

আমি এই টিউটরিয়ালটা first টিউটরিয়ালটা-r সাথেই লিখেছিলাম। খালি copy-paste করার বাকি ছিল। করব করব বলে করা হয়ে উঠে নাই।আজ করে ফেললাম।

you can find similar post in
beacoder
if you have any question you are welcome…

And HAVE A GOOD PROGRAMMING

somedays ago one of my friends just ask me that did i know how to connect oracle with netbeans ide?I said yes i know.And i have told some about it and i think that will help him,and also i think why don’t i share this topic in my blog,then the others can know it too.So here it goes..

open your ide. then you will see like this

1

go to databases, then right click on it.
and go to “new connection”

2

after that

3

in the name field select  “new driver”

4

now you will see something like this:

5

now click on add button and give it the location of  your oracle driver file
for mine it was:
…oracle/product/10.1.0/db_2/jdbc/lib/ojdbc14.jar
after adding this jar file your netbeans will automatically do the rest of the work for you.
Now Driver class:oracle.jdbc.OracleDriver
then look at your database url,it will be look like
“jdbc:oracle:*1:*2:*3:*4″

Now in no.
*1:
try first giving
oci8
if it don’t work with your driver then try
thin
*2:
@localhost
*3:
port number of your server
if you don’t know in which port is your server is active
then see java-oracle
tutorial.After getting the port number write it to in “*3″
*4:
in here you have to put session id[SID] from server.If you don’t know the [SID] then you can get it by following above tutorial

For me it was..
“jdbc:oracle:thin:@localhost:1521:orcl”

Now you have to give the username and password,for which user do you want to connect.
[remember the username and password is for ur database user
e.g like "system","manager" is a user ]
for me i have another user ’saiful103a’ beside system so i give
user:saiful103a
pass:saiful103a
now connect with ur given username
and see the power of netbeans over oracle..
connect

And that’s it

And HAVE A GOOD PROGRAMMING

কিছুদিন আগে আমি jQuery নিয়ে ঘাটাঘাটি করেছিলাম। হঠাৎ মনে হলো যা শিখলাম তা শেয়ার করছি না কেন? এটা করলেত আমারই লাভ
।সোজা কথায় বলতে গেলে আমি চাচ্ছি আমার সীমিত knowledge আমি সবার সাথে শেয়ার করতে।আমার বলার মাঝে কোন ভুল থাকলে তা অবশ্যই শুধরে দিবেন।তাহলে চলুন শুরু করি।

সোজা ভাষায় jQuery আর কিছুই না,javascript দিয়ে তৈরি একটা বিশাল library।মানে আপনি যদি javascript এ নিজেকে বস মনে করেন তাহলে আপনি নিজেই এরকম একটা library বানাতে পারবেন।বিশাল এ কারনে যে এটা এখন শুধু john resig এর না।এটার popularity এতই,যে এটাকে develop করার জন্য সবাই কাজ করে যাচ্ছে।ohhh, sorry আমি কি বলছি আপনাদের? john resig এই library টি তৈরী করেছেন।

যা হোক কথা বেশি বলা ভাল না। চলুন code-এ যাই।
প্রথম কাজ -ত library টা download করা।এটা আপনি কষ্ট করে http://jquery.com থেকে download করে নিন। latest টাই download কইরেন।

এখন আপনার htm file -এ অন্য সব js file এর মত import koren.

$(document).ready(
function(){
$(document.body).css( "background", "black" );
}
);

এখন প্রথম ” $ ” -র কথা বলি।আসলে এটা দিয়ে jQuery কে বলে দেয়া হচ্ছে কার উপর কাজ বা function effect ফেলতে হবে।
আপনাকে এটা দিয়েই করতে হবে এমন কোন কথা নাই।কারন মাঝে মাঝে আপনি হয়ত আরো library import করবেন,যেখানে “$” use করতে হবে ঐ library-r জন্য, তখন আপনি কি করবেন? এ সময় আপনি শুধু jquery কে বলে দিন তুমি “$” নিয়ে কোন রকম গন্ডগোল করবানা । এর জন্য অবশ্য নিচের মত একটি line আপনাকে সবার উপর লেখতে হবে।


jQuery.noConflict();

এরপর jquery import করে যেখানে “$” use করতেন, সেখানে লেখুন “jQuery”।

এখন first কোডটি দেখুন। এখানে আমি jquery কে বলছি তুমি document যখন ready হবে তখন এর body র background color black করে দাও। কিন্তু javascript ত এরকম কিছু করতে পারে না? তাহলে?একটা question হতে পারে এটা নিয়ে।এটার উত্তর হলো, css পারে।আমরা css -এ কিভাবে body background color দেই?

BODY { background-color:black; }

আর আমরা ঠিক এ কাজটি-ই করেছি উপরে .css() এর মাধ্যমে। javascript dom এর মাধ্যমে আপনি নিজেও এ কাজটি করতে পারেন।jquery ও এই dom এর মাধ্যমে এ কাজটি করেছে।এটাকে আসলে বলা হয় “Document Object Model”।আপনি যদি এটা ভাল পারেন তাহলেই বলা যায় আপনি “javascript ninja”।এটা আসলে বিশাল আলোচনার বিষয়।
আমি আর ওদিকে যাচ্ছি না।
আমার পরে .css() এর আর-ও কাজ দেখব।

আজ এখানেই শেষ করলাম।
And “HAVE A GOOD PROGRAMMING”

————
আমি এই পোষটটা অনেকদিন আগে লিখেছিলাম ।আপনি অরিজিনাল পোষটটা ইচছা করলে নিচের ঠিকানায় দেখতে পারেন।
হঠাৎ মনে হলো নিজের বলগে এটা কপি পেষট মেরে দিই।আর বলগটা আর একটু rich করি।
and just trying to you know what i mean….
http://forum.beacoder.com/viewtopic.php?f=51&t=64&start=0

You’ve already seen a post about captcha.If not i encourage you to see it.Thuough it is pretty simple captcha script.If you try to run that script you will notice that it is not like others where they have different type of background color,different type of font,noise.So in this post i will try to figure that.

First make a file name “captcha.php

now paste

<?php

session_start();

function captcha($length) {

// generate a totally random string using md5
$rd = md5(rand(0, 999));

// We don't need a 32 character long string so we trim it down to 5 because md5 will return a long string
$code = substr($rd, 15, $length);

// Set the session to store the security code
$_SESSION["captcha"] = $code;

// Set the image width and height
$width = 200;
$height = 50;

// Create the image resource
$image = imagecreate($width, $height);

// Random RGB colours
$rgb1 = rand(0, 255);
$rgb2 = rand(0, 255);
$rgb3 = rand(0, 255);

$background = imagecolorallocate($image, $rgb1, $rgb2, $rgb3);
$text = imagecolorallocate($image, ($rgb1 - 60), ($rgb2 - 60), ($rgb3 - 60));

// Make the background colour
imagefill($image, 0, 0, $background);
for ($i = 0; $i < 10; $i++) {
$rx1 = rand(0,$width);
$rx2 = rand(0,$width);
$ry1 = rand(0,$height);
$ry2 = rand(0,$height);
$rcVal = rand(0,255);
$rc1 = imagecolorallocate($image,
rand(0,255),
rand(0,255),
rand(100,255));
//giving noise
imageline ($image, $rx1, $ry1, $rx2, $ry2, $rc1);
}

// Add randomly generated string in the image
for($i = 1; $i <= $length; $i++) {
$counter = rand(1, 2);

if ($counter == 1) {
$angle = rand(0, 45);
}
if ($counter == 2) {
$angle = rand(315, 360);
}

imagettftext($image, rand(14, 20), $angle, ($i * 25), 30, $text, "font/LucidaBrightDemiItalic.ttf", substr($code, ($i - 1), 1));
}

// Add a border
imagerectangle($image, 0, 0, $width - 1, $height - 1, $text);

// Tell the browser what kind of file is come in
header("Content-Type: image/png");

// Output the newly created image in jpeg format
imagepng($image);

// Free up resources
imagedestroy($image);
}

?>

this code into that file.

You see “LucidaBrightDemiItalic.ttf”.I have this font in font directory.You can use ur font.And that will be your font style of captcha.But remember you have to put font file in the directory or Sub-directory where your php file will stay.

Now include this file in any other php file and make a call with


captcha(4);

here 4 is the number of character you want to show.You can give your length of string.Here we use session to store the captcha string in $_SESSION global array.Since we have to use this later, to check whether the user submit the data or not.So that’s it.
And “Have a good programming

java oracle connection

July 16, 2009

Tomorrow i was trying to connect my java program with oracle server.It was not easy for me to do this.Since i’m a new learner.I google it about half an hour.I read every page that seems to me helpful.Then i finally got the solution.If i describe you,you will be astonished and will say to yourself it is nothing at all.Then let go…

Check your configuration with mine:
OS: Windows Xp
JDK Version: JDK1.6
IDE: Any ide or compiler will work
Oracle:10g

open ur ide or compiler. now create a new project ‘database’.When you will give ur project name meantime you have to notice that anywhere there is a option that have classpath or not.If there is open your classpath settings.Now add a new class.Locate this class to

…oracle/product/10.1.0/db_2/jdbc/lib/ojdbc14.jar

If you you don’t have ojdbc14.jar then ojdbc[].jar can work for you.Try it.Or you can download it.From oracle website.

ok,now we locate a class that can connect our jdk with oracle.

If you know in which port your oracle server is active then ok,if not
open you command prompt in your windows
now type lsnrctl status
what have you seen.From results you will find

Listening Endpoints Summary…
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(PIPENAME=\\.\pipe\EXTPROC0ipc)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=myhostname)(PORT=1521)))

now we need the name of SID
Now open your sql+ window from oracle
type
show parameter db_name

you will get a value [for me it was oracl]

this.So PORT=1521 is your port no.
Now,In your project creat a new file named ‘database.java’


import java.sql.*;

public class database
{
public static void main(String[] args)
{
DB db = new DB();
Connection conn=db.dbConnect(
"jdbc:oracle:oci:@localhost:1521:oracl", "username", "pasword");
}

}

class DB
{
public DB() {}

public Connection dbConnect(String db_connect_string,
String db_userid, String db_password)
{
try
{
DriverManager.registerDriver(
new oracle.jdbc.OracleDriver());

Connection conn = DriverManager.getConnection(
db_connect_string, db_userid, db_password);

System.out.println("Connection Successful");
return conn;

}
catch (Exception e)
{
e.printStackTrace();
return null;
}
}
};

And that’s it.And it is definitely worked for me.Hope,will work for you too.Have a nice programming.

Starting oracle..

July 11, 2009

This semester we are going to do a course named ‘Database System’.Under this course we have to do a database[oracle] lab course.Yes, i was waiting for this course when i first understand what can be done with database.Though i am familiar with mysql but oracle is oracle not mysql.Though my mysql concept will help me to understand.Like, we are going to do sql in first step.And i’ve already completed the half of sql part.Though yet we do not started our lab.And it’s not that so hard.I am loving it.I will post if i came to know new things in it.

learning……

July 8, 2009

I’ve already learned many things after i’ve started blogging.Though some of them i understood but many of them i don’t.Many of them was not just only knowing things ,because those need to examine in a remote server where i always try to find things in my local server.I’ve tried for few free hosting space but they don’t have those things that i need.Though i have tried one.But what happened ,after a few days it blocked my account.what am i gonna do now.Now i have to try, to buy some hosting space for me.

Somedays ago i’ve found a php captcha script from one of my php boss bhaia.But i don’t understand why his script does not work in my local server.But whatever i’ve made one of my own with the help of his script.
You can say it,2nd version of his script for me.

here what i’ve got.

<?php
$im = imagecreate(60, 30);
$RandomStr = md5(microtime());

$ResultStr = substr($RandomStr,0,5);
$bg = imagecolorallocate($im, 200, 255, 255);
$textcolor = imagecolorallocate($im, 200, 0, 255);
imagestring($im, 5, 6, 6, $ResultStr, $textcolor);

header("Content-type: image/jpg");
imagejpeg($im);
?>

now name it captcha.php
now if you want to use it in a form or somwhere else you just write this:

<img src="captcha.php"/>

done

sometimes we need to import data from other site though we don’t know when we need to use their data from their site,will this site alive or dead?We can fix this problem via a php function called fsockopen,now i have a script that can work for you to understand more precisely

<?php

$up = @fsockopen("www.wordpress.com", 80, $errno, $errstr, 30);
if($up)
{
echo "WordPress is Alive";
}
else
{
echo "Sorry this site is not available now";
}
?>

that’s it. Now check it out.

here is some interesting php code i have found from many of my resources,where i often goes for help like forums,blogs and others.This script helps you to make ur url tiny when you need to make ur url safe from bad guys.And also you can get ur real url using this script.Here it is

<?php
/* This function send a
request to http://tinyurl.com/api-create.php with your real
url and return a tiny new url
*/

function tiny_url($url){
return file_get_contents("http://tinyurl.com/api-create.php?url=" . $url);
}
$real_url = "http://www.yoururl.com/index.php";
$new_url=tiny_url($real_url);//now echo it if want to see
echo $new_url;

/* you can also expand this
url to real url by using
*/

function real_url($tiny)
{
$real = get_headers($tiny,1);
return $real;
}
$tiny="http://tinyurl.com/l9vmcf";// you just place here what you've got in $new_url

$real_one=real_url($tiny);

echo $real_one['Location'];
?>