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.