Showing posts with label utilities. Show all posts
Showing posts with label utilities. Show all posts

Wednesday, April 25, 2012

Java: convert List<String> to a join()d string


Javascript has Array.join()




js>["Bill","Bob","Steve"].join(" and ")
Bill and Bob and Steve

Is it good to have "Utils&rdquo; class in your software project?


Usually, during software development, there are all sorts of utility functions I need. Like zipped file, extract zip file, launching Web Browser, get scaled image...

Tuesday, January 31, 2012

wired output of the combination of $.each and jQuery.inArray function


My complete code:




jQuery.extend({

combinationCheck: function (p1position) {

var Combination = [1, 2, 3, 4, 5, 6, 7, 8];
Combination[0] = [1, 2, 3];
Combination[1] = [4, 5, 6];
Combination[2] = [7, 8, 9];
Combination[3] = [1, 4, 7];
Combination[4] = [2, 5, 8];
Combination[5] = [4, 6, 8];
Combination[6] = [1, 5, 9];
Combination[7] = [3, 5, 7];


$.each(p1position, function (index, value) {

var num = value;

if ($.inArray(String(value), Combination[1]) != '-1') {
alert("there");
}
else {
alert("not there");
}

});
});

wired output of the combination of $.each and jQuery.inArray function


My complete code:




jQuery.extend({

combinationCheck: function (p1position) {

var Combination = [1, 2, 3, 4, 5, 6, 7, 8];
Combination[0] = [1, 2, 3];
Combination[1] = [4, 5, 6];
Combination[2] = [7, 8, 9];
Combination[3] = [1, 4, 7];
Combination[4] = [2, 5, 8];
Combination[5] = [4, 6, 8];
Combination[6] = [1, 5, 9];
Combination[7] = [3, 5, 7];


$.each(p1position, function (index, value) {

var num = value;

if ($.inArray(String(value), Combination[1]) != '-1') {
alert("there");
}
else {
alert("not there");
}

});
});