Archive

Archive for December, 2009

Java – Tips

December 31, 2009 Leave a comment

Interface:
============

// when we say interface we dont use function brackets;
public interface MainCar {

//
int shamun(int a);

}

// when we say “Implements” we add function brackets
public class A implements MainCar {

int shamun(int a){
// more…..
}
}

public interface groupInterface extends interface1,interface2 {
double E = 2.33;
void newMore(int i);
}

Inheritance:
============
When you want to create a new class and there is already a class that includes
some of the code that you want, you can derive your new class from the existing
class. In doing this, you can resuse the fields and methods of the existing
class without having to write
(and debug !) them yourself.

An Example of Inheritance
Here is the sample code for a possible implementation of a Bicycle class that was presented in the Classes and Objects lesson:

public class Bicycle {

// the Bicycle class has three fields
public int cadence;
public int gear;
public int speed;

// the Bicycle class has one constructor
public Bicycle(int startCadence, int startSpeed, int startGear) {
gear = startGear;
cadence = startCadence;
speed = startSpeed;
}

// the Bicycle class has four methods
public void setCadence(int newValue) {
cadence = newValue;
}

public void setGear(int newValue) {
gear = newValue;
}

public void applyBrake(int decrement) {
speed -= decrement;
}

public void speedUp(int increment) {
speed += increment;
}

}

A class declaration for a MountainBike class that is a subclass of Bicycle might look like this:

public class MountainBike extends Bicycle {

// the MountainBike subclass adds one field
public int seatHeight;

// the MountainBike subclass has one constructor
public MountainBike(int startHeight, int startCadence, int startSpeed, int startGear) {
super(startCadence, startSpeed, startGear);
seatHeight = startHeight;
}

// the MountainBike subclass adds one method
public void setHeight(int newValue) {
seatHeight = newValue;
}

}

MountainBike inherits all the fields and methods of Bicycle and adds the field seatHeight and a method to set it. Except for the constructor, it is as if you had written a new MountainBike class entirely from scratch, with four fields and five methods. However, you didn’t have to do all the work. This would be especially valuable if the methods in the Bicycle class were complex and had taken substantial time to debug.

Polymorphism:

Advertisements
Categories: Java Tags:

Linux – security

December 30, 2009 Leave a comment

Please dont use those info, for bad use, its a educational reason listed here. I am not responsible if anything you did or went wrong. You are not allowed to use this info, its my private notes. Thank you

1. Stress tool/Memory overflow

http://www.unicornscan.org/

http://httpd.apache.org/docs/2.0/programs/ab.html

– multi-threaded python script , urllib2

2. Aircrack

Hardware required for software to support (comview supported adapters)

– We can scan the WEp/WAP protocol

– And decode the code

3.

Categories: centOS, Fedora 12, Ubuntu, Unix/Linux Tags:

Java – Frameworks

December 29, 2009 Leave a comment

Java Tree

o— java SE (standard edition)
o———- desktop/workstation/server
o— java EE
(enterprise edition)
o— java ME (micro edition)
o———- MIDP/CLDC/JSR

Like other languages we have also frameworks and groups

1. Apache Tomcat
2. Jboss

– jboss (Red Hat) is a group which has sub items like

Product features (wiki)

its competitors or similars are

a. BEA Weblogic (oracle staffs)

b. IBM WebSphere

2. Liferay

– is a portal, jsp/servlet with predefined modules

Categories: centOS, Fedora 12, Java Tags:

Oracle VS MySQL

December 23, 2009 Leave a comment

Oracle VS MySQL – [ 1990 till 2010 this report, will not maintain for next decades]

Top 6 Points:    Oracle/with Mysql and almost others
———————————————————————————————————————————————————–

1. JVM :  http://projectkenai.com/projects/mysql-jvm/pages/Home

2. storage safety

3. data lose 99%

4. lots of features

5. RAC (allowing others to share)

6. ASM (is oracle's logical volume manager)

Inquery:

Q. Mysql and Oracle what is the biggest fair?

A. oracle is a database, mysql is a pimped excel sheet collection, PL/SQL is a language that runs inside the database (like the JAVA stuff, too), Ruby/PHP/GTK runs outside the database.

LET CONSIDER: from database it runs, did you mean if oracle processid id = 2244, plSQL runs from 2244 process id or new thread id ?
no, i the language is interpreted and executed by the database system
stored procedures, functions, java packages
they run inside the database system
no i don’t mean “oracle comes with a JRE”
i mean “oracle integrated a JVM into the database system itself”

pump mass data into your mysql server, all CPUs at 100%, mass storage IO at maximum, several hundert MB/s
then pull the cables
do you really think your database survives this?
no, i give up for that.
with oracle i only lost data one time, a hardware bug from a RAID controller that injected wrong data/didn’t complete write operations
for the rest… nothing. power outs, subsystem failures, etc etc etc
no data loss
okay, needs some percent of luck, too, but in general… you start the instance, it recovers as much as it can, and goes online
if it can’t recover to a consistent status, it won’t open the database
if you can open it (without hacks), you can be sure it’s consistent (regardless physical block failures and stuff, that’s another story)
(i mean “if you can open it after a crash”)

Q. in which case its pimped excel sheet compared to Oracle, size of data? like wirehouse data vs bank ?

A. how often can you push the power button of a mysql server, until you’re unsure if the data is still consistent?

the concept is completely different, mysql is just a file editor with SQL interface. oracle is that, too, but that’s just one part of it

Q. in short if i think, what made it so powerfull from xyz DBMS ? its engine or the storange or the features it allows to solve problems?

A. *storage
yes. if you need a guestbook on your homepage, you don’t need oracle. if you need a database system, you need oracle, db2, sql server, maybe postgres and with mysql you have to fight against things like read locks

(which is a design decision for the database engine, so it’s unfair to mention that, admitted)
most typical mysql applications from the LAMP area just use the database as simplified storage
without the need for relational logic

Q. What is RAC?

RAC is a pretty oracle-uniqe feature
several database systems accessing one database
i’m not against mysql, don’t get me wrong
i use it, too
but there where it belongs to
in the low power area where dataloss isn’t a catastrophic problem
i checked the logs for one of our most important databases. the service itself (it’s a RAC) was available for 100% during the last 4 years
RAC is a pretty oracle-uniqe feature

Q. What more?
well, there are many features. personally i like RMAN and datapump. it’s not “god”
it’s… oracle. the average oracle tool is crap, but the core product (database) is great
but as always: everything depends on the situation and the needs

well, for a bigger company there are only a few choices on the market
plus postgres/enterprisedb, depending on the project
but mysql in a company with important data.. uhmmmmmaybe not.

Q. Whats your experience in oracle?
for the capacity and stuff: i definitely don’t run the biggest database in world, but my biggest machine operates oracle with about 100G database memory and a 40 terabyte ASM diskgroup. it’s not an everyday system, but such things are no phantasy
(the datafiles just take 10 tera for the moment, so the DB is 10T only)
i wouldn’t even think about using anything else than Oracle or DB2 for that
alone the fact that a MySQL would operate on top of a filesystem of such a size… uh

Other staff to attack oracle/mysql server for study:

devcon: to find windows interface ids
http://www.wlanbook.com/enable-disable-wireless-card-command-line/
Backtrack 4 (linux and ) wifi tools: aircrack/airdump
http://wirelessdefence.org/Contents/Aircrack-ng_WinAircrack.htm

Categories: MySQL, Oracle Tags:

JavaScript – iframe inline, iframe freehand, iframe src freedom

December 20, 2009 Leave a comment

IFRAME , you want to use, and it doesnt work, using .src?  It works how you want it to work, check following.

case ‘Duplicates’:{

// [ Putting ] — Headings
$( ‘a.databaseB’ ).html( ‘(Duplicates)’ );
// [ load and progress bar show ] – xhtml/css
myAjax(‘include/add_edit_del.php?model=ajax_loginput’, ‘oper=search&about=Duplicates’);
// [ load a largest 40,000 lines of tables ] – xhtml/css and SQL database
var db = myAjaxReturn(‘include/add_edit_del.php?model=ajax_duplicates’, ‘oper=search&about=Databases’);
// [ Also i want some ajax events attached ] – pure javascript my class and libraries.
_html = ”;

/**
* The meat of IFRAME
*/
// [ { This is what you are looking for } ] — IE5 till IE8 and FF,Chrome,Opera works for me
var frame = ‘<iframe frameborder=”1″ width=”100%” height=”400px” id=”companiesframe” name=”companiesframe” src=”javascript: \’\’;” > ‘;
// [ Place where i want to put the iframe visible] — I use iframe for performance and dealing largest displays.
$(‘#database_b’).empty().append( frame) ;

// [ Now it doesnt work! ] – so i confirm the element initialized mannually
$(‘#companiesframe’).load(function(){
try {
// [ Now plain xhtml/css/js simply copy and past] — done!
$(this).contents().find(‘body’).html( db );
}catch(e){
// if anything happens. Lets rock here…
}
});
// End of the Meat.

// — Thanks
// — Shamun
// — follow me: https://shamuntoha.wordpress.com

}break;

Categories: HTML, JavaScript, PHP Tags:

JavaScript – go back, go back detection, ajax go back

December 11, 2009 Leave a comment

Completely bogus when something was saying back you cant, Here how i did, using 100% ajax boot methods.

Difficulties was:

a) visitors comes to localhost/index.php

b) visitors is routed to localhost/index.php?g=1

c) visitors is now completely ajax module, onclick menus he gets contents.

d) visitors need to go back, when apply go back it goes to point A). localhost/index.php

Note: This is not the common ajax we use, b is itself a ajax for whole index.php?g=1 , c is the sub ajax sections

Solved as:

folder tree:

= shamun
– js/jquery.history.js
– js/global.js
– include/home.php
– include/menu_button_3_contents.php

– index.php

1. This plugin is used, i didn’t write it, because of time limitation, many thanks to mikage sawatari. (i will modify on this plugin for my own uses).

Download: http://dpaste.de/hSgZ/

2. A fix ajax binding function, where you can load ajax sub pages. In my case it was two route, so i splited the href link to two different location. in other case it may contain only one:

function myAjaxReturn(url,_datastr){
return $.ajax({
type    : “POST”,
url     : url,
data    : _datastr,
async : false,
success : function(msg){
// this is the sub page url, “include/page33.php”;
url = url.split(“/”);
if ( url[1]==’main.php’){
$save  = $(‘#jQuery_history’);  // to avoid error
$(document.body).empty().prepend($save).append(msg);
}else{
$(‘#alltable’).empty().append(msg);
}
}
}).responseText;
}

3. Now you apply on click buttons or div or td or anything:

// 1. Basic ajax would be like this but to have history, we will not use those methods.

// $(‘#alltable’).html(”).load(‘include/link_mijnaccount.php’);

$(“#home”).click ( function () {

// So this is the ajax method that basically we use, without history management

$.historyLoad(‘include/home.php’);

// just to avoid wrong window.location.href return false; });

// 1. Basic ajax would be like this but to have history, we will not use those methods.

// $(‘#alltable’).html(”).load(‘include/link_mijnaccount.php’);

$(“#menu_button_3”).click ( function () {

// So this is the ajax method that basically we use, without history management

$.historyLoad(‘include/menu_button_3_contents.php’);

// just to avoid wrong window.location.href

return false;

});


Categories: Ajax, JavaScript Tags:

Solaris – How to admin tool

December 2, 2009 Leave a comment

Ping http://www.google.com: unknown host

# cp /etc/nsswitch.dns /etc/nsswitch.conf
# init 6

System hostname (unknown)
# echo “shamun@” > /etc/nodename
# reboot system
you will shell like this: shamun@# {cursor }

In Solaris 10, you can use Solaris Management Console (GUI):

#/usr/sadm/bin/smc &
#smc

# /usr/sadm/bin/smc edit &
http://docs.sun.com/app/docs/doc/819-2379/smcover-17?a=view

Configure the executeable paht. for shell use

# pkg-get
pkg-get: not found
# echo $PATH
/usr/sbin:/usr/bin:/usr/openwin/bin:/usr/ucb
# PATH=/opt/csw/bin:/usr/sbin:/usr/bin:/usr/openwin/bin:/usr/ucb
# export PATH
# echo $PATH
/opt/csw/bin:/usr/sbin:/usr/bin:/usr/openwin/bin:/usr/ucb
#

Install the latest firefox

Download from: http://hub.opensolaris.org/bin/view/Community+Group+desktop/development
# bzip2 -d firefox-3.5.5.en-US.solaris-10-fcs-i386.tar.bz2
# ls
firefox-3.5.5.en-US.solaris-10-fcs-i386.tar  okok1.png
# tar xvf firefox-3.5.5.en-US.solaris-10-fcs-i386.tar
# cd firefox
# ./firefox

KDE Desktop:

# pkgutil -a kde_gcc
# pkgutil -i kde_gcc

Other commands

#auths

#profiles

http://docs.sun.com/app/docs/doc/816-5166/6mbb1kps6?a=expand

http://docs.sun.com/app/docs/doc/816-5166/6mbb1kq87?a=expand

http://docs.sun.com/app/docs/doc/816-5166/6mbb1kqk9?a=expand

Categories: Solaris Tags: