Wednesday, April 23, 2014

Only Numeric Values ​​in Form Fields With JavaScript

Hi everyone! 

We use form fields almost in every web project. This fields often are different. For example, password field's type is password, text's type textfield. If you want users to sign up, you should develop e-mail fields on it. so, you have to confirm values of e-mail fields. In this article, we will create a textfield for only numeric values.
First, we create HTML form:

input name="" type="text" onChange="isNumeric(this)"

The code given above is a textfield in the HTML file. As you have seen, there is a onChange function, isNumeric. Let's do this JavaScript function:
function isNumeric(v) {
    var isNum = /^[0-9-'.']*$/;
    if (!isNum.test(v.value)) {
        alert('Only Numeric Values Dude!');
        v.value = v.value.replace(/[^0-9-'.']/g,"");
    }
}

When you run this page, you will see an alert on the screen if you write some string values.

Tuesday, April 22, 2014

Word Cloud Generation Using Google Webmaster Tools Data and R

In this blog entry, we generate a word cloud graphics of our blog, stdioe, using the keyword data in Google Webmaster Tools. In webmaster tools site, when you follow

Google Index -> Content keyword

you get the keywords with their frequencies. This data set can be saved in csv format using the button "Download this table".

The csv data for our blog was like this:


One can load this file and generate a word cloud graphics using R, and our code is shown below:


require("wordcloud")
 
mydata <- read.csv("data.csv", sep=";", header=TRUE)
 
png("stdioe_cloud.png",width=1024, height=768)
wordcloud(words=mydata$Keyword, freq=mydata$Occurrences,scale=c(10,1))
dev.off()


The generated output is:




Here is the stdioe's search query keywords cloud:




Monday, April 21, 2014

How to Install and Use The TinyMCE Editor

Hi! TinyMCE is an advanced text editor for web project. It looks like Microsoft Office Word tools. Additionally The TinyMCE is the most popular advanced text editor in the world. In this article, we are going to download this editor and do an example.
You can download it from the official web site. Recent version 4.0.21: TinyMCE. If you want to try online how to work on this, you can see this page: Try Online
After downloading, just create a form.html HTML file given below and work on any internet browser:
We try on it and:
We can set editor preferences up. What we need is tinymce.init. For example, let's set width and height of the textarea element:
tinymce.init({
    width: 800,
    height: 500,
    selector: "textarea"
 });
I advise you to use TinyMCE like this:
tinymce.init({
    width: 800,
    height: 500,
    selector: "textarea",
    theme: "modern",
    plugins: [
        "advlist autolink lists link image charmap print preview hr anchor pagebreak",
        "searchreplace wordcount visualblocks visualchars code fullscreen",
        "insertdatetime media nonbreaking save table contextmenu directionality",
        "emoticons template paste textcolor moxiemanager"
    ],
    toolbar1: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image",
    toolbar2: "print preview media | forecolor backcolor emoticons | sizeselect | bold italic | fontselect |  fontsizeselect",
    image_advtab: true,
});

Matrix Inversion with RCaller 2.2

Here is the example of passing a double[][] matrix from Java to R, making R calculate the inverse of this matrix and handling the result in Java. Note that code is current for 2.2 version of RCaller.


RCaller caller = new RCaller(); 
Globals.detect_current_rscript(); 
caller.setRscriptExecutable(Globals.Rscript_current); 

RCode code = new RCode(); 
double[][] matrix = new double[][]{{6, 4}, {9, 8}};

code.addDoubleMatrix("x", matrix); 
code.addRCode("s<-solve font="" x="">); 

caller.setRCode(code); 

caller.runAndReturnResult("s"); 

double[][] inverse = caller.getParser().getAsDoubleMatrix("s"
                                       matrix.length, matrix[0].length); 
        
for (int i = 0; i < inverse.length; i++) {
    for (int j = 0; j < inverse[0].length; j++) {
        System.out.print( inverse[i][j] + " ");
    System.out.println();
} 
 

Fuzuli for Java Online Interpreter

JFuzuli, Java version of Fuzuli interpreter, is now the main implementation of Fuzuli Programming Language. There is always a gossip on the efficiency of C and C++ over Java and people who starts to writing computer programs are encouraged to make a decision between them but not the Java. However, when you don't do things correctly, C and C++ are the worst programming languages in means of efficiency. Allocating memory and garbage collection are important issues and should be handled by user or other third party libraries but not by the language itself. As not being a computer scientist, my both C++ and Java codes include algorithmic errors and my Java codes run faster than the code written in C++. I can confess that is my fault! But it is not false to say that a big portion of programmers does not either write the correct code and their C++ code does not reach its maximum efficiency. Finally, our Java implementation is faster than the C++ version.

Lets try our online interpreter! Fuzuli is a little bit Lisp, Scheme, C and Java! Try it, learn it and join the development team. The link for the online interpreter is http://fuzuliproject.org/index.php?node=tryonline

The screenshot of the online algorithm is given below.


Sunday, April 20, 2014

Hello world application with Google Dart


Google Dart

Dart is a new programming language developed by Google, which has a similar syntax with Java and Javascript. Dart is targeted directly for the web, however, console based applications can also be written as well as it is compilable into Javascript. Google's web browser Chromium is able to run Dart codes directly but there is not an available add-on for other browsers such as Firefox and Internet Explorer. Dart SDK supports compiling Dart to Javascript, that is, any browser will run Dart code without knowing that the original code is written Dart. The community will determine whether the language will be a standard for web based application, instead using Javascript.

In this blog entry, we will show writing a basic Dart Web Application which can be considered as a "Hello World" but it is a little bit complicated. This application will create a textbox and a button. When user writes her name and after clicks the button, the program pop ups a message box.

When a new application is created in Dart Editor, you will see something like this:



Lets change the html file. Put a textbox and command button:



Clear the Dart Code:



Fill main method. Here we handle the input element using variable name. name.onclick.listen method defines
the event handler.



Complete the code


In the screen capture above, name and say are global variables and they are defined at the top of the code. They are accessable in both main() and button_click(). The body of the method button_click() is such like its counterparts written in both Java or Javascript. Lets run the code:




Have a nice read!


Thursday, April 17, 2014

Beautiful Graphics of Flightgear 3

Here is the some screen captures of my last flight on Flightgear 3.0.
Flightgear is an open source flight simulator game which is mainly compiled for Windows, Linux and Macintosh. It is free and avaliable for downloading at site Flightgear Official Web Site




























Saturday, April 12, 2014

RCaller 2.2.0 has just been released

We have just uploaded the new compiled jar file of latest Rcaller, the simple library for calling R from within Java.

We plan to clean recently reported bugs, but the most important one was having some errors about the R package Runiversal, which is required by the library for generating XML files. The basic issue underlying this problem was the package storing policy of R which depends on the user that installed the package.

In the most recent version 2.2, users do not need to pre-install the R package Runiversal. Simply add RCaller-2.2.0-SNAPSHOT.jar to your classpath and go!

The download link of the compiled library is here [Google Driver Link]

The library is tested in a pc with Ubuntu OS installed and the usual test scenarios are success in all cases. The library has not been tested on Windows machines. 

Please use the link of Google code page at http://code.google.com/p/rcaller/issues/list and enter your problems in issues part and do not hesitate to contribute our library.