2013年11月10日日曜日
Daemon Thread ["http-bio-8080"-exec-2] (Suspended (exception RuntimeException)) on Eclipse for Tomcat 7
Developing Tomcat application on Eclipse IDE, and if you are facing the problem that RuntimeException keep poping out and you can't get rid of it without stopping the server. Based on stackoverflow's answer, it can be easily solved by uncheck the option in Preferences.
2013年9月29日日曜日
How to inject javascript in android webview like chrome javascript console
I have migrated to new blog. Click the link below to redirect.
http://edisonthk.wordpress.com/2013/09/29/how-to-inject-javascript-in-android-webview-like-chrome-javascript-console/
http://edisonthk.wordpress.com/2013/09/29/how-to-inject-javascript-in-android-webview-like-chrome-javascript-console/
2013年9月23日月曜日
Simple introduction about what is Ruby on Rails
CodeProject
I begin to learn ruby on rails since begin of this August. I found out that ruby on rails is awesome, it speed up all my works and make it simple to maintain. So, I wrote this article to introduce about how awesome rails is.
Back to our topic, what is ruby on rails? Web application development framework with ruby language. For more details, you can do some searching on what is ruby on rails, there are many sources you can found on internet.
To install rails on your windows or mac PC. There is a quick way to install it by download rails installer and install it.
To install rails on linux os such as ubuntu, debian might needs a little bit more works then windows and mac. There are sources on internet, check it out.
Rails, will do it automatically for you.
By typing a few commands for it, rails will do it for you. Here’s the commands.
On first command, create new project and name it "NewProject". Second command create table name item and columns of name, price and description. Third command create directory for html file, ruby file and routes. Fourth command to startup database and last command to startup the server.
Everything will be setup within 1 minutes. It means, you can begin your programming after 1 minutes. Cool right!
Go to http://localhost:3000 and you will see the welcome message of rails.
To check with the project generated, go to http://localhost:3000/items
The page is blank. This is because all you have generated is database, system and routes. There will nothing to show unless html code is written.
How to use it? By a few simple command
First create a new project. In this case, named NewProject
Then, generate scaffold with following command and startup server.
Here’s the result generated by scaffold. Check it out
Instead of blank project, scaffold will generate a template for us to make a quick way to start.
I begin to learn ruby on rails since begin of this August. I found out that ruby on rails is awesome, it speed up all my works and make it simple to maintain. So, I wrote this article to introduce about how awesome rails is.
Back to our topic, what is ruby on rails? Web application development framework with ruby language. For more details, you can do some searching on what is ruby on rails, there are many sources you can found on internet.
Installation
It is always easier to be understood by running up the things.To install rails on your windows or mac PC. There is a quick way to install it by download rails installer and install it.
To install rails on linux os such as ubuntu, debian might needs a little bit more works then windows and mac. There are sources on internet, check it out.
To begin a new project
Before getting start to develop a new web application. You need to setup database, directory of your new project, .htaccess to control the traffic. Maybe you will spent almost half an hours to one hours to setup all those things. But …Rails, will do it automatically for you.
By typing a few commands for it, rails will do it for you. Here’s the commands.
rails new MyProject cd MyProject rails generate model Item name:string price:integer description:text rails generate controller items index new create show edit update destroy rake db:migrate rails server
On first command, create new project and name it "NewProject". Second command create table name item and columns of name, price and description. Third command create directory for html file, ruby file and routes. Fourth command to startup database and last command to startup the server.
Everything will be setup within 1 minutes. It means, you can begin your programming after 1 minutes. Cool right!
Go to http://localhost:3000 and you will see the welcome message of rails.
To check with the project generated, go to http://localhost:3000/items
The page is blank. This is because all you have generated is database, system and routes. There will nothing to show unless html code is written.
Scaffold
A powerful tool that prepared by rails called Scaffold. Scaffold will generate everything including database, simple system code, traffic, html layout code. It means, you can begin to coding from half way instead of blank file.How to use it? By a few simple command
First create a new project. In this case, named NewProject
rails new NewProject
Then, generate scaffold with following command and startup server.
rails generate scaffold item name:string price:integer description:text rake db:migrate rails server
Here’s the result generated by scaffold. Check it out
Instead of blank project, scaffold will generate a template for us to make a quick way to start.
End
It is the end of the article, do you think that ruby on rails is awesome?2013年9月14日土曜日
Event prevent default is not working
If you are working on key action with jquery and having problems on event.preventDefault is not working. Let’s me explain something simple to you.
event.preventDefault
As given example on docs, it shows us how it works on click action. For instances, prevent default action of anchor request the given url when clicked, action of submit button clicked to submit the form.So far so good.
bind.( “keydown” , function( event ){ return false; } );
preventDefault is good but when it comes to key action such as enter key on submit form and tab key on switching the focus of input element. It lose it effects. You will found out that enter key are still performing default action and others key as well.So… what is the solution? Adding return false on handler. Snippets below shows an simple example on this solution.
$(document).bind('keydown', function(e){
return false;
});
It’s works right!
What happens if you want only ‘enter’ key to be prevent default action. Here’s the solution.
$(document).bind('keydown', function(e){
var keyPressed = ('which' in e) ? e.which : e.keyCode;
if( keyPressed == 13){
return false;
}else{
return true;
}
});
Enter keycode is 13. Return true on event handler will allow the key to continue with default action and return false will stop event handler from continue to default action.
It’s still not working
There are a few quite common mistake make by people, especially for me. Either you too?
- Errors inside the handler function
If there is errors (exp. syntax errors) occured inside the handler function, default action will be carry out even though there is return false in handler function. Don’t tried to ignore the errors that shows on your browser, it might be the core of your problems.
- Mess up with JQuery instances and native Javascript instances
What does it means? Check it out with the differences at following codes.
$("ul").children("li")[0].html("");
$("ul").children("li")[0].innerHTML = "";
It is quite tricky problems, html() is jquery properties and innerHTML is javascript properties. But on this case, children(“li”) returns native javascript element array, so there is no method for html(“”) in returned element array. So, second code is the correct answer.
If you have do some checking by Object.keys( $(“ul”).children(“li”)[0] ); you will found out that the properties is different from jquery properties.
Conclusions
High level language doesn’t means you don’t have to understand the basic of it. Understanding basic sometimes will be the helper on solving problems.
Good luck
2013年9月6日金曜日
How to open select input method option menu programmatically on Android
Here's the snippets for Android to open the select input method option menu programmatically.
InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
if (mgr != null) {
mgr.showInputMethodPicker();
}
2013年8月29日木曜日
Install ruby on rails for Aptana Studio 3 on Windows
I spent almost half of my day to install ruby on rails on my Windows PC. After a long fighting on installing, I found an EASY way for windows. Could be said as DAMN EASY.
What you need to do is download the latest version from Rails installer site and run it. Don’t need to download Ruby Installer, as it is included inside Rails installer. What you need to do is waiting until it’s done.
After installed, you can test it by open command prompt and go to whatever testing directory and type
rails new TestApps cd TestApps rails server
Then, open browser and go to http://localhost:3000 .If you are able to see the page. Congratulation, you are done with ruby on rails install.
Last things is to download Aptana Studio 3.
Caution here, make sure you install rails first instead of Aptana studio. Otherwise, you have to configure the path for rails on Aptana studio.
If you received error "Unable to find 'rdebug-ide' binary script. May need to install 'ruby-debug-ide' gem, or may need to add your gem executable directory to your PATH", when debug ruby in Aptana studio.
Install ruby-debug-ide by following command
gem install ruby-debug-ide
Then, restart your Aptana studio. You should be able to debug ruby file.
Okay! Hope you are already in coding. Thank you for reading.
2013年8月21日水曜日
Crop Images into pieces for java applet
By using CropImageFilter class, images can be cropped easily with few lines. According to Java docs, parameter of CropImageFilter constructor is
First, load the image from folder. Here's is the method I prepared.
For eclipse IDE, I put my images file inside the src/img package.
After load the image, let's say "image_want_chop.png" is loaded and chop it with following code.
Thank you for reading.
CropImageFilter(int x, int y, int w, int h)
First, load the image from folder. Here's is the method I prepared.
private Image loadImage(String img){
return getImage(app.getDocumentBase(),"img/"+img);
}
For eclipse IDE, I put my images file inside the src/img package.
After load the image, let's say "image_want_chop.png" is loaded and chop it with following code.
Image originalImage = loadImage("image_want_chop.png");
ImageFilter imageFilter = new CropImageFilter(x,y,width,height);
Image choppedImage = createImage(new FilteredImageSource(originalImage.getSource(),
imageFilter ));
Thank you for reading.
登録:
投稿 (Atom)


