Tuesday, March 29, 2011

My experience learning JAVA

 My experience learning JAVA
I want ya story since the first experience of learning Java. First I started from the read-read tutorial java from SUN website. I go one-one tutorial page, complete one page and click next, and so on. Thank God that time the internet connection quite cepet. Then there's the reason I'll not have to read from the site, I wrote all the copy that is in part tutorial with web copier httrack. The program was immediately wrote nyedot all the links that exist from the first page of the tutorial. Wah deh happy to read and read at home. 'd Be in the office or cafe. One day, I fit into the cafe say nyari fad but a format JAVA tutorials. Chm. File. Chm is compiled from html form-2 that. Turns out there, yes I've donlot ajah tuh file. The amount of responsibility not abysmal tens of mega, mega 63 if not wrong. Although long, but more cepet of httrack, which was not yet finished. Well, that file readable tuh. From that day on the basics of JAVA I began to understand. Just be sure the problem is, I sometimes have problems with Java classes that are difficult to remember. Also difficult if not know of certain classes including a package (package) what. Therefore I also need download rich files. Chm about APIs in JAVA. If I search on google pake keyword 'JAVA API filetype: chm'. Found! There is a file. I immediately wrote donlot tuh file. Well now if confused the names of the class, I live search aja there. At that time I still use notepad.exe editor for programming. Wuaannjrrroooooottt! Learning JAVA wealth of torture really use the editor's time. Idly I open a page from SUN JDK download first place, there were Netbeans version 4 beta. He said it was a sophisticated editor, wrote the file size is about 100 mega. Mad. Yes already, coincidentally cafe where I was pretty spead. I download now. finished two hours later. Download Then I installed it at home. Incidentally I download who've integrated with JDK 1.5. Oh, no editor very slow. Weight if proceed. My computer is Athlon XP 2100, RAM 256, loading about 20 seconds or more. Not crazy? But alas, this is more cepet of JBuilder X that I have ever bought. Quite helpful also, especially by default netbeans can make a GUI program that cute-cute. Code hell can already delicious, rich in VB and Delphi, if the class name already typed, then typed ('.'), point variable name and method automatically appear. The point is pretty good. Sometimes there is also a problem with netbeans. In addition to slow, if create a console program (under DOS so rich), can kompail and run, but if the programs that we make have / need input from the keyboard, just netbeans pass wrote, so the error. I think what so can? Then, if he's my senior reading regular use Eclipse. Can download at eclipse.org. I try tuh donlot eclipse. Pretty big too, it was version 2.0 so if not wrong. Donlot out, I try at home. Editor is faster than netbeans. Loading Affairs does the same, but fitted kodingnya, it feels really different. The disadvantage, by default (without plugins) the editor has not provided the module to create GUI. So, if you want to use the GUI I use netbeans, if I use eclipse console. Actually there are plugins for eclipse that point we'll be coding the GUI with ease. This GUI includes a GUI applet and regular (desktop application). His name Jigloo. Donlot just try it, but I forgot the link, search on google aja with the keyword 'jigloo + eclipse + plugin'. Method of installation can be read on the site developer. You need to read the installation method because it is not just a coffee into the plugins directory. Well after that I almost always use the eclipse. If you need examples of Java programs, you can search the website JAVAALMANAC. This web site explains about the book Java Almanac can be purchased at Amazon.com. Buy not an option for me, but the web site there are many pieces of program based on its packets. Also given the title to fit the problem. Anyway mantep lah. Ordinary, I immediately wrote donlot use httrack. Tuh get quite a lot. Then I compail oh html so. HLP. With the format. Hlp, I could nyari-2 specific topics with ease. The problem is I forget the software that I use to kompail these html files. So much had deh stories. Hehehe .... Instead of patronizing, but bwegi-2 experience.
READ MORE - My experience learning JAVA

Button-Button Vim command (linux)

Button-Button Vim command (linux)
Button-Button Vim command (linux) for linux users who still cloud may be confused how to use a text editor imaginable in linux terminal commands which are grouped category following:

categories: transfer mode
i move to insert mode (insert) a move to insert mode (add)
o moving to INSERT mode, and add a blank line below cursor
O moved to INSERT mode, and add a blank line above cursor

categories: navigation cursor
h, j, k, l left, down, up, right
w forward one word
W developed a next word (including whitespace)
b back one word
B backward one word (including whitespace)
e forward to the end of next word
E advanced to the end of next word (including whitespace)
ge back to the end of the previous word
GE retreated to the end of the previous word (including whitespace)
$ Moved to end of line
^ Move to the beginning of the line (without the blanks)
0 (zero) move to the beginning of the line (including null character) moved to the beginning of the file gg
G moved to end of file
G move to line
% Move to a specific position files, for example 50%, will move into the middle of the file
H moved to the top of the screen
M moved to the center of the screen
L moved to the bottom of the screen
CTRL-G show cursor position in the file
CTRL-U scroll up half a page
CTRL-D scroll down half page
CTRL-E scroll one row up
CTRL-Y scroll one line down
CTRL-B scroll one page up
CTRL-F scroll one page down
zz scroll so that the cursor is in the middle
Zt scroll so that the cursor is above the
ZB scroll so that the cursor is under


categories: search
f forward to the first encountered on a particular line
F back to the first encountered on a particular line
t advance to one character before the first encountered on a particular line
T back to one character one character before the first encountered on a particular line
% Moved to a pair of characters from the cursor position, eg position the cursor in the '(', will move the cursor to ')' partners / looking to the future? looking back n look again in the same direction
N search again in opposite directions * looking forward the same word at the cursor position
# Find the same words back at the cursor position

Category: delete
x delete the character at the cursor dd delete a line
A delete LINE BREAK, to join the line at the cursor with the next line

categories: undo and redo
u undo
CTRL-R redo

categories: save
ZZ save and exit
: W save
: Write save
: W filename save as
: Write save as filename

categories: exit
: Q quit without save if there is no change to the file
: Q! exit without save even when there are changes to the file

category: help
: Help see help
: Help subject see help on the subject
READ MORE - Button-Button Vim command (linux)

programmers unix machine

 
Time I get a pretty interesting article, and can increase our knowledge about what exactly 'Hacker' is ... whether Kevin Midnick & Captain Zap can be called as a hacker? For more details, maybe the following article can help us to find the answers. once again this is not a pure article of my writing, but I copy and paste through my teacher blog ..
happy reading

In recent years the term hacking is looming. The book is "thin", "instant" and use the title of "hacking" into the new terms of writing popular books on Indonesia. This is a dangerous game from the publishers (who authors) because the damage could get to our young generation. Creating a culture increasingly thick that science can be obtained by means fast, instant, even just with a capital of 20-50 pages thick book. To be sure hackers are not crackers, hackers build things, while crackers damage. Let's peel on the nature of these hackers and hacking activities.

Most of the literature mentions that the term and the hacker culture was first used in 1961 when MIT had the opportunity to enjoy the PDP-1 machine. DEC's first computer production has become a favorite toy, especially the MIT student who joined the Tech Model Railroad Club. They make programming tools, making a lot of programs, develop ethics, jargon and even PDP-1, which became a video-game machine earlier generations. Culture is then known to be a true hacker culture. The hackers in the Tech Model Railroad Club became the team's core research laboratory Artificial Intelligence (AI), MIT is a pioneer in AI research in the world today.

ARPAnet project developed by the U.S. Defense Department was not free from interference by hackers at MIT. ARPAnet was the one who brings together the hacker culture from the various "tribes", for example, from Stanford University and Carnegie Mellon University (CMU). MIT hackers eventually even managed to develop its own operating system called ITS (Incompatible Time-Sharing System) is legendary, tops-10 replaces the standard operating system produced by DEC for the PDP-10. ITS was originally built with the assembler, but later changed into the language LISP, functional programming language close to the world of Artificial Intelligence.

Another creation from the MIT hackers who is legendary is Emacs (Richard Stallman), a favorite editor who still used by many programmers unix machine to date. I know the first time Emacs when entering campus at Saitama University in 1995, I used to write all my college report, read email, web browsing, reading newsgroups and even Emacs, too.
From Bell Labs hacker named Ken Thompson who is assisted by another hacker named Dennis Ritchie C language with her to develop the Unix operating system. Collaboration Thomson and Ritchie is the force that is phenomenal, because Unix and C language is a potent formula for the development of variants of the Unix operating system from anywhere to date (BSD and System V where Linux included). Also note that in 1982, hackers from Stanford and Berkeley who led William (Bill) Joy established a company called Sun Microsystems.

Era 1984 commencement of the various episodes of rapid cracking known as raised by the press and journalists. Journalists began to mistakenly refer to computer crime and its deviation as a "hacking activities" where actor called a hacker.

A hacker is actually like Richard Stallman who fought with the Free Software Foundation and decades of dreaming to build a free operating system called the HURD. Linux Torvalds is a hacker also true for remaining committed to the development of the kernel Linux root until now. Contributors to the development of Linux and other open source software also is the real hackers.

Actors carding (misuse of credit cards), phreaking, and defacing is not a hacker, but they are a cracker. Legendary phrase from Eric S. Raymond in the article entitled how changed from a hacker, "hackers and crackers to build a lot of things ruin it." True hackers are a good programmer. Something very foolish when there are people or groups who claim to be hackers but did not understand how to program. Essential nature of a hacker is happy to share, not share the tool exploits, but the sharing of knowledge. True hacker is a writer who is able to understand and write articles in the mother language and English well. Hacker is a nerd who has an attitude (attitude), good base, which would respect others, respect the people who help him, and respect for people who have been given knowledge, means or opportunity.

It is not the nature of a hacker if given the trust holding the administration on a server instead use it for cracking activity. Or even then attack and destroy the server from within by making a mockery added to the owner of the server that has given him the opportunity. With forced me to say, so I've been there. So far I always support the movement of young people in cyberspace, I am pleased with their spirit. Hundreds of community I give the domain and hosting for free as a reward Struggle for wanting to share their knowledge to other friends in the homeland. Unfortunately there are crackers who claimed hackers (though do not have the attitude as a hacker) is toying with this opportunity. Once satisfied to make a dedicated server that contains hundreds of other community sites in the provider of server-shutdown due to phreaking activities she was doing, still of cursed me with titles that are not human. Am I cured? No I will still give the trust, server support and a free domain for cyber activists.

Hackers are not the ones with nicknames, screenname or handlename a funny, silly and stupid. Eric S. Raymond calls that hide the name, is actually just a naughty, silly behavior that characterize the crackers, warez d00dz, and the losers who did not dare to be responsible for his actions. Hacker is a reputation, they are proud of the work done and want a job that is associated with their real names. Hacker does not have the computer, because the concept of hacking is real learners, enthusiastic people to work and never give up because of failure. And the hackers could appear in the field of electronics, machinery, architecture, economics, politics, etc..

Straighten out the problem of understanding the hacker is a rescue project generation and repair the nation. And this could start by improving our educational curriculum so as to educate our students become real hackers. And let us together struggle to be a hacker who could benefit and who can fix this republic was triumphant.
READ MORE - programmers unix machine

Java Connection - MySQL

 Java Connection - MySQL
Basically it can be spelled a bit difficult to connect your MySQL with Java. Unlike other programming languages ​​(put it. NET or even PHP that provides easy interface in the affairs of connectivity), Java needs "a little" patience in the process of connectivity to the MySQL database.

To connect your database and displays with Java, there are several steps that must be followed carefully and in sequence, steps - steps are:
1. Detecting the JDBC driver
2. Making the connection between MySQL with Java
3. Doing sesuat with these connections!
4. Closing connection.

package test;

/**
 *
 * @loso - http://loso.com
 */
public class test {
     public static void main(String[] args) {
          try {
               Class.forName("com.mysql.jdbc.Driver").newInstance();
               System.out.println("Berhasil terhubung dengan MySQL");
          } catch (Exception E) {
               System.out.println("JDBC Driver error");
          }
     }
}


If the exit reading "Successfully connect to MySQL", then the connection between the Java with MySQL successfully. If still get out the words "JDBC Driver error", then the driver is not connected. Usually if I see errors like this, the best way is to uninstall the Java, NetBeans, and repeat from the beginning,, hehe
READ MORE - Java Connection - MySQL

J2ME itself is the technology of the Java programming language

J2ME itself is the technology of the Java programming language are in dedicated to mobile devices like mobile phones, Pocket PCs and what else yah. Just create a small device that is often taken anywhere that you know. J2ME is the same with programming using java itself, only in J2ME there is some functionality added and subtracted and are customized for mobile device programming.

Obviously to be able to create games in HP we have to get used to first use the programming with java, here I will not review the java programming language-maybe next time in a different post-I expect you already have knowledge of java before. Here I will only provide knowledge about the tools used in making Java programs on HP and concepts.

For tools I use IDE (Integrated Development Environment) NetBeans version 6 which can be downloaded for free here, select NetBeans Mobility Pack is included. So that we can lock write code without having to install try again.

After you install the NetBeans IDE, NetBeans run it immediately. To create a new project select File-New Project. Will appear as shown below.
Select MIDP Application and press Next. Next you will be brought to the Name and Location screen like below.


Input Project Name corresponding to the name of your project and remove the check in the Create Hello MIDlet. Press Next
 This is a screen to determine the target device with which you created the application. In line emulator Emulator Platform is a choice that you install on your computer, for now you just install the emulator default of your NetBeans. Once you feel the need to install emulators for specific platforms from other vendors such as Nokia, Sony Ericsson and Motorola you can change it here.

Device is a device emulator or HP who will you run on your computer, in running the program that you create. If later you install the emulator platform from another vendor you will be able to use HP's specific vendor.

Device Configuration and Profile are the specific capabilities of the device package that will you to target your application, for example I have a HP K608 that have CLDC 1.1 and MIDP specification 2.0 HP means I can run the program with a package that is on CLDC 1.1 and MIDP 2.0. For more information about the device you jadikat research target was the first to see the specifications HP or your target device.

To ease you understand, just imagine the old HP is MIDP 1.0, such as nokia 6015 and nokia is big with a slide that I forgot what the old HP brand and others. MIDP 2.0 new HP like the Nokia N70, N73, SE K600, SEW800 and others. Since MIDP 2.0 more a good idea to select MIDP 2.0 and CLDC 1.1 for our application this time.

Select Next and directly select Finish. Ready ready!

Actually in this NetBeans you can create applications with Visual MIDlet HP is in NetBeans, but to more deeply understand the concept of making an application in J2ME here I will not use the Visual MIDlet.

The concept of J2ME programs are as follows. In J2ME we have will make the main class derived from MIDlet class, main class derived from MIDlet is yag will be called the first time during our application running on HP, in the main class also there are 3 methods which will function as a triggering event from our HP. Like:

starApp (), method that is called when we first application of the road.
pauseApp () method that is called when the user hp pause our application.
destroyApp () method that is called when the user closes our application hp.

We start by creating a new classMIDlet for your project. Right-click your project in the project explore and select new-MIDlet, called the new class with name MIDletPertama. Last code your MIDlet file looks like below.


For the first time we will display the "Hello World J2ME" on the HP screen. There are two types of views within the MIDlet,

Low Level use the Canvas class

High Level use Form

Here we will use a form to facilitate you to understand the formation of the display in the MIDlet.

Notice the code above, frPertama is the object form which we will show in the layer, we give the title of Form is the "Title". Then append method is a method to add items on the Form, Item I want to add is the String "Hello World J2ME". Display statement is a statement to display the object fr First into the layer.

Select F11 to build the project and F6 to run the project.

Select the midlet who want to run and press launch in the emulator, then your emulator will display the form that you created, as shown below.


Congratulations, your program has been running well in the emulator, how to run on HP's real?

Log into your NetBeans project folder, open the folder dist
Transfer the jar file in your program to your HP channeled through Bluetooth, infrared or data cable
READ MORE - J2ME itself is the technology of the Java programming language

Monday, March 28, 2011

function to convert in order to save it to mysql

function to convert in order to save it to mysql

Here's one simple function which is often used to convert in order to save it to mysql and opposite, that is to display the date in the format we want, at this function that we want is dd / mm / yyyy (day / month / year).


// FUNGSI DATE CONVERT
function jin_date_sql($date){
$exp = explode('/',$date);
if(count($exp) == 3) {
$date = $exp[2].'-'.$exp[1].'-'.$exp[0];
}
return $date;
}

function jin_date_str($date){
$exp = explode('-',$date);
if(count($exp) == 3) {
$date = $exp[2].'/'.$exp[1].'/'.$exp[0];
}
return $date;
}


How to use are as follows.:
Convert from date DD / MM / YYYY to YYYY-MM-DD to insert into mysql database


$data_tanggal_form = "23/02/2009"; // DD/MM/YYYY
$data_tanggal_mysql = jin_date_sql($data_tanggal_form); // hasilnya: 2009-01-01 = YYYY-MM-DD


And the reverse, ie want to display.
Convert from date YYYY-MM-DD to DD / MM / YYYY to perform capture from mysql database

$data_tanggal_db = "2009-01-01"; // YYYY-MM-DD
$data_tanggal_tampil = jin_date_str($data_tanggal_db); // hasilnya: 23/02/2009 = DD/MM/YYYY
READ MORE - function to convert in order to save it to mysql

Sunday, March 27, 2011

Closure Properties and Applications Xiangjie PHP5.3

Closure Properties and Applications Xiangjie PHP5.3
In July this year, released a version of PHP 5.3 offers many new features, which is one feature that is more eye-catching to support closure; 51CTO has released "5.3 PHP syntax closure," the article is also a PHP developer Congratulations Coming.

After that, we can and writing wave Ruby, Javascript and so on "high-tech language" the same people who write the code so cold? Uh, actually, in many cases, they still can cause some side very problematic, the following has been slow.

Many languages ​​have provided a very elegant and beautiful to manipulate arrays. In the following example, will use the property closing and closing PHP5.3 other language features to show how "objective" iterative array operations.

Yi Zhu: Comparison of Mars, the original author, I do not know the language Groovy and Scala, so here I add the implementation of Javascript.

Instructions before you begin, this example just to clarify it, not considering other factors such as performance.

"Shop around"

Start with a simple example, there is the following array:

$ Nums = array (10, 20, 30, 40);

Need to find an array of more than 15 items. So, do not take into account the closure of this case, we can write:

n $ res = array (); foreach ($ nums as $ n) (if ($ 15) ($ res [] = n $;))

If language itself has the support of the closure, then this language can be written as Groovy ()

def res = nums.findAll (p. 15) or use the Scala language

val res = nums filter (_ 15) Yi Zhu: 1.6 Javascript will be as follows

var res = nums.filter (function (c) (re-c 15));

Because the operating cycle has been abstract and up, so you can see Groovy, Scala (and Javascript) simply use the statistics and his party can handle.

Of course, if you use PHP5.3 closure can be achieved

$ Res = array_filter ($ nums, function ($ v) (return $ v 15;));

PHP to use more characters from the Scala, but the previous example, less time and can read better.

Incidentally, the above PHP code is actually using the analysis of Lambda, not closing properly, this is not our focus today. PHP Closing Lambda complex and analytical information can be found here.

Now it seems to feel pretty good, then we can show the subject of increasing difficulty: to find all items greater than 15, then multiplied by 2 plus the role of the variable domain and return later.

Groovy implementation:

def x = 1def findAll res = nums (p. 15) .. collect (generate.sh this configuration data backup bin conf tmp svn log eshow_sitemap.html Maint sitemap.html 2 + x)

Scala's implementation:

val x = 1val res = nums filter (_ 15) map (conf config _ eshow_sitemap.html generate.sh data backup bin tmp svn log Maint sitemap.html 2 + x)

PHP implementation:

$ X = 1; array_map $ res = (function ($ v) use ($ x) (v return $ conf configuration data backup bin tmp svn log generate.sh eshow_sitemap.html Maint sitemap.html 2 + $ x;), array_filter ($ nums, function ($ v) (return $ v 15 ;)));

The quantity of light from the code, now looks different from PHP and other languages. First code literally leave them in addition to aesthetics, the PHP code above have additional questions.

For example, if you need to use a series of buttons rather than value for comparison, how? Yes, the code above will not be possible. Meanwhile, speaking from the perspective of linguistics, the code above is very difficult to read.

Return to Innocence, then back to the old ideas still have to solve the problem:

$ X = 1; $ res = array (); foreach ($ nums as $ n) (if ($ n 15) ($ res [] = $ backup bin conf config log n data Maint eshow_sitemap.html generate.sh tmp svn sitemap.html 2 + $ x;))

It is visible and very clear. But this time, you may be confused: "Still looking for the former operation is not an array?."

Yes, the real fun is yet to come. This time to play some of the advanced features of PHP, to get this seems to have a tendency to self-mutilation "stupid question."

ArrayObject - the array package

PHP has a standard library called SPL, which contains a class called ArrayObject, can provide "the same operation as the type of array" function, for example,

$ New = Res ArrayObject (array (10, 20, 30, 40)); foreach ($ res as $ v) (echo "$ vn";)

ArrayObject is the built-in class, so you can operate the same category as other types of packaging it.

Arr - wrapped in sugar coating

Now that we have the ArrayObject and closing of this feature, we can start trying to pack:

Arr class extends ArrayObject (static function create ($ array) (return new self ($ array);) function map ($ func) ($ res = new self (); foreach ($ this as $ k = $ v) ($ res [$ k] = $ func ($ k, $ v);) return $ res;) function filter ($ func) ($ res = new self (); foreach ($ this as $ k = $ v) (if ($ func ($ k, $ v)) ($ res [k] $ = $ v;)) return $ res;))

Well, everything was ready. The following rewrite of PHP code can solve the above problems, and the syntax seems "almost" a:

$ Res = Arr:: create ($ nums) - filter (function ($ k, $ v)

(Back $ v 15;)) - map (function ($ k, $ v)

(Return v $ conf bin configuration data backup generate.sh eshow_sitemap.html Maint sitemap.html tmp svn log 2;));

The above code with the different traditional ways first?, They can be recursive and the role of the establishment of a call chain, so you can add more such operations.

Meanwhile, the two parameters by the respective operating behind an array of key and value of their goods - $ k $ v in accordance with the appropriate keys and values. This allows us to use the key in the closure, which in traditional array_fliter PHP function is impossible to achieve.

Others have the added advantage that the API calls more consistent. PHP function using traditional surgery, they were probably the first argument is the closure of, or arrays, or array of some, whatever ... who knows?

Here is the complete source code Arr class also includes other useful functions (such as reducing and walking), in fact, its implementation and even the same code.

Game

In fact, this question difficult to answer - the need to code their own context and programmers, and many other factors. In fact, when I first saw the closure of the PHP implementation, I feel seem to back that old time Java, I built in the early use of anonymous class (anonymous inner class) to achieve closure. Of course, although this can be done, but it seems more useful. PHP itself is a true closure, but its implementation and the syntax that I am very confused.

Another feature of the language with the closure, they can be very convenient to call the closure and also has an elegant syntax. In the example above, the use of the traditional cycle of Scala to work, but you'll like this you? Meanwhile, from another aspect, it is stated that the subject of using PHP on top of the closure can be achieved, but in general you so write it?

Of course, the closing PHP in some cases may be a sharp knife (such as delays in implementation and transfer of resources), they are in the traditional iteration and array operations before they become difficult for some people. Do not despair Anyway, back to nature with the preparation of compatibility, refresh code and APIs are the most important.

Conclusion

Like all later with the same grammatical features (remember Java Generic And OOP features of PHP is not featured on the previous year), they need time to adapt and finally stable?. With the popularity of even the future of PHP5.3 PHP6 increase, more and more skills and characteristics I believe in the near future will gradually develop a smart programmer.

Return to the original article at the beginning of the subject, compared

$ Res = Arr:: create ($ nums)

- Filter (function ($ k, $ v) (return $ v 15;))

- Map (function ($ k, $ v) (return $ v bin conf data backup config generate.sh eshow_sitemap.html Maint sitemap.html tmp svn log 2;));

And

val res = nums filter (_ 15) map (conf config _ eshow_sitemap.html generate.sh data backup bin tmp svn log Maint sitemap.html 2)

The difference between the two. In the final analysis they only grammar, basically achieving the same solution to the problem. This application has a different programming language, nothing is more natural is better.
READ MORE - Closure Properties and Applications Xiangjie PHP5.3
 
THANK YOU FOR VISITING