When i input numeric , it also detect it as incorrect format
function checkAge(form) /* for age validation */
{
var eobj=document.getElementById('ageerror');
var age = form.age.value;
var oR =/[0-9,.]+/;
eobj.innerHTML='';
if (age == '') {
error='Error: Age cannot be blank!';
form.age.focus();
}
else if (!oR.test(age))
{
error='Incorrect format!'
}
if (error)
{
form.age.focus();
eobj.innerHTML=error;
return false;
}
}
var oR =/[0-9,.]+/;
else if (!oR.test(age))
something error at this part?
hopefully someone can help me solve the problem,thx!
Monday, 2 September 2013
SubScreen Enhancement in MM01
SubScreen Enhancement in MM01
I have added two fields in the subscreen of MM01 and has also appended the
same structure in MARA table.
But on clicking the Save Button, the content of that subscreen is not
getting saved to the MARA table.
What should i do..???
I have added two fields in the subscreen of MM01 and has also appended the
same structure in MARA table.
But on clicking the Save Button, the content of that subscreen is not
getting saved to the MARA table.
What should i do..???
Algorithm for calculating all intersects and disjoints for an indefinite number of sets
Algorithm for calculating all intersects and disjoints for an indefinite
number of sets
Recently I had to develop a nieve recursive algorithm for the set problem
outlined below, but would now like to know what the formal
description/name of the problem is and whether there's an algorithm that
allows the problem to be solved more efficiently (I suspect there is).
I know there are separate algorithms for finding intersects and disjoints,
but I haven't recognized any that cover this problem as a whole.
The problem:
To take an indefinite number of sets and return one set for each intersect
and non-intersect of all the sets.
For example, given 4 sets as input A,B,C,D:
A {1,14,2,10,13,12,8,9}
B {2,3,14,15,11,13,9}
C {13,10,4,15,5,6,12,11}
D {7,8,9,13,11,6,12}
The result should be the following 13 sets:
{1,14},{2},{3},{4,15},{5},{6},{7},{8},{9},{10},{11},{12},{13}
The algorithm I developed was nieve in that it compared all set
permutations recursively (I wanted to be able to implement this relatively
easily in XSLT 2.0) until no further intersects were found.
Some context, I needed to perform this operation to describe how multiple
versions of a tree modify the original tree, at each point on the tree.
The 'tree' is actually an XML document.
number of sets
Recently I had to develop a nieve recursive algorithm for the set problem
outlined below, but would now like to know what the formal
description/name of the problem is and whether there's an algorithm that
allows the problem to be solved more efficiently (I suspect there is).
I know there are separate algorithms for finding intersects and disjoints,
but I haven't recognized any that cover this problem as a whole.
The problem:
To take an indefinite number of sets and return one set for each intersect
and non-intersect of all the sets.
For example, given 4 sets as input A,B,C,D:
A {1,14,2,10,13,12,8,9}
B {2,3,14,15,11,13,9}
C {13,10,4,15,5,6,12,11}
D {7,8,9,13,11,6,12}
The result should be the following 13 sets:
{1,14},{2},{3},{4,15},{5},{6},{7},{8},{9},{10},{11},{12},{13}
The algorithm I developed was nieve in that it compared all set
permutations recursively (I wanted to be able to implement this relatively
easily in XSLT 2.0) until no further intersects were found.
Some context, I needed to perform this operation to describe how multiple
versions of a tree modify the original tree, at each point on the tree.
The 'tree' is actually an XML document.
Sunday, 1 September 2013
Thymeleaf page if condition checking possible?
Thymeleaf page if condition checking possible?
Thymeleaf html page if checking is possible?
how to check this condition in thymeleaf..
i tried this but not working
<tr th:each="s : ${patterns}">
<h3><p th:text="${s.questionPattern}" /></h3>
<tr th:each="q : ${questions}">
<!--This checking is possible ? -->
<div th:if="${#s.questionPattern != q.questionPattern.questionPattern}">
<p><input type="text" th:text="${q.questionName}" /></div>
</p>
</tr>
</tr>
i know this is not the right way
if u know the answer please share..
Thymeleaf html page if checking is possible?
how to check this condition in thymeleaf..
i tried this but not working
<tr th:each="s : ${patterns}">
<h3><p th:text="${s.questionPattern}" /></h3>
<tr th:each="q : ${questions}">
<!--This checking is possible ? -->
<div th:if="${#s.questionPattern != q.questionPattern.questionPattern}">
<p><input type="text" th:text="${q.questionName}" /></div>
</p>
</tr>
</tr>
i know this is not the right way
if u know the answer please share..
How to update the azimuth with the rotation matrix from gyroscope?
How to update the azimuth with the rotation matrix from gyroscope?
Suppose I have my current orientation as (azimuth, pitch, roll). Now I
wish to update my orientation with the gyroscope. According to the codes
given by the Android development web, I can obtain the so-called
deltaRotationMatrix as follows:
// Create a constant to convert nanoseconds to seconds.
private static final float NS2S = 1.0f / 1000000000.0f;
private final float[] deltaRotationVector = new float[4]();
private float timestamp;
public void onSensorChanged(SensorEvent event) {
// This timestep's delta rotation to be multiplied by the current rotation
// after computing it from the gyro sample data.
if (timestamp != 0) {
final float dT = (event.timestamp - timestamp) * NS2S;
// Axis of the rotation sample, not normalized yet.
float axisX = event.values[0];
float axisY = event.values[1];
float axisZ = event.values[2];
// Calculate the angular speed of the sample
float omegaMagnitude = sqrt(axisX*axisX + axisY*axisY + axisZ*axisZ);
// Normalize the rotation vector if it's big enough to get the axis
// (that is, EPSILON should represent your maximum allowable margin of
error)
if (omegaMagnitude > EPSILON) {
axisX /= omegaMagnitude;
axisY /= omegaMagnitude;
axisZ /= omegaMagnitude;
}
// Integrate around this axis with the angular speed by the timestep
// in order to get a delta rotation from this sample over the timestep
// We will convert this axis-angle representation of the delta rotation
// into a quaternion before turning it into the rotation matrix.
float thetaOverTwo = omegaMagnitude * dT / 2.0f;
float sinThetaOverTwo = sin(thetaOverTwo);
float cosThetaOverTwo = cos(thetaOverTwo);
deltaRotationVector[0] = sinThetaOverTwo * axisX;
deltaRotationVector[1] = sinThetaOverTwo * axisY;
deltaRotationVector[2] = sinThetaOverTwo * axisZ;
deltaRotationVector[3] = cosThetaOverTwo;
}
timestamp = event.timestamp;
float[] deltaRotationMatrix = new float[9];
SensorManager.getRotationMatrixFromVector(deltaRotationMatrix,
deltaRotationVector);
// User code should concatenate the delta rotation we computed with
the current rotation
// in order to get the updated rotation.
// rotationCurrent = rotationCurrent * deltaRotationMatrix;
}
}
How should I proceed with this snippet so as to update my orientation?
Suppose I have my current orientation as (azimuth, pitch, roll). Now I
wish to update my orientation with the gyroscope. According to the codes
given by the Android development web, I can obtain the so-called
deltaRotationMatrix as follows:
// Create a constant to convert nanoseconds to seconds.
private static final float NS2S = 1.0f / 1000000000.0f;
private final float[] deltaRotationVector = new float[4]();
private float timestamp;
public void onSensorChanged(SensorEvent event) {
// This timestep's delta rotation to be multiplied by the current rotation
// after computing it from the gyro sample data.
if (timestamp != 0) {
final float dT = (event.timestamp - timestamp) * NS2S;
// Axis of the rotation sample, not normalized yet.
float axisX = event.values[0];
float axisY = event.values[1];
float axisZ = event.values[2];
// Calculate the angular speed of the sample
float omegaMagnitude = sqrt(axisX*axisX + axisY*axisY + axisZ*axisZ);
// Normalize the rotation vector if it's big enough to get the axis
// (that is, EPSILON should represent your maximum allowable margin of
error)
if (omegaMagnitude > EPSILON) {
axisX /= omegaMagnitude;
axisY /= omegaMagnitude;
axisZ /= omegaMagnitude;
}
// Integrate around this axis with the angular speed by the timestep
// in order to get a delta rotation from this sample over the timestep
// We will convert this axis-angle representation of the delta rotation
// into a quaternion before turning it into the rotation matrix.
float thetaOverTwo = omegaMagnitude * dT / 2.0f;
float sinThetaOverTwo = sin(thetaOverTwo);
float cosThetaOverTwo = cos(thetaOverTwo);
deltaRotationVector[0] = sinThetaOverTwo * axisX;
deltaRotationVector[1] = sinThetaOverTwo * axisY;
deltaRotationVector[2] = sinThetaOverTwo * axisZ;
deltaRotationVector[3] = cosThetaOverTwo;
}
timestamp = event.timestamp;
float[] deltaRotationMatrix = new float[9];
SensorManager.getRotationMatrixFromVector(deltaRotationMatrix,
deltaRotationVector);
// User code should concatenate the delta rotation we computed with
the current rotation
// in order to get the updated rotation.
// rotationCurrent = rotationCurrent * deltaRotationMatrix;
}
}
How should I proceed with this snippet so as to update my orientation?
ZF2 Language system not work on local server
ZF2 Language system not work on local server
I have no idea why on local wamp server that system not work, and on VPS
server that work. I have installed intl extensionsint for php.
That is my translator config:
'translator' => array(
'locale' => 'en_US',
'translation_file_patterns' => array(
array(
'type' => 'gettext',
'base_dir' => __DIR__ . '/../language',
'pattern' => '%s.mo',
),
array(
'type' => 'gettext',
'base_dir' => __DIR__ . '/../../Donation/language',
'pattern' => '%s.mo',
),
),
),
and boostrap on Module.php file of application module
public function onBootstrap(MvcEvent $e)
{
$eventManager = $e->getApplication()->getEventManager();
$serviceManager = $e->getApplication()->getServiceManager();
$eventManager->attach('dispatch', array($this, 'setLayout'));
$moduleRouteListener = new ModuleRouteListener();
$moduleRouteListener->attach($eventManager);
//LANGUAGE
$validatorTranslator = new \Zend\Mvc\I18n\Translator();
$sessionLang = new SessionContainer('language');
$HelperPluginManager = new HelperPluginManager();
$translator = $serviceManager->get('translator');
$validatorTranslator->addTranslationFile('phparray', __DIR__ .
'/language/validator/pl_PL.php', 'default', 'pl_PL');
$validatorTranslator->addTranslationFile('phparray', __DIR__ .
'/language/validator/en_US.php', 'default', 'en_US');
AbstractValidator::setDefaultTranslator($validatorTranslator);
AbstractValidator::setMessageLength(500);
$HelperPluginManager->injectTranslator($validatorTranslator);
$http = isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ?
substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2) : 'en';
$lang = $sessionLang->lang ? $sessionLang->lang : $http;
switch($lang){
case 'pl':
$validatorTranslator->setLocale("pl_PL");
$translator->setLocale("pl_PL");
date_default_timezone_set("Etc/GMT+1");
break;
default:
$validatorTranslator->setLocale("en_US");
$translator->setLocale("en_US");
date_default_timezone_set("Etc/GMT");
}
}
I have no idea why on local wamp server that system not work, and on VPS
server that work. I have installed intl extensionsint for php.
That is my translator config:
'translator' => array(
'locale' => 'en_US',
'translation_file_patterns' => array(
array(
'type' => 'gettext',
'base_dir' => __DIR__ . '/../language',
'pattern' => '%s.mo',
),
array(
'type' => 'gettext',
'base_dir' => __DIR__ . '/../../Donation/language',
'pattern' => '%s.mo',
),
),
),
and boostrap on Module.php file of application module
public function onBootstrap(MvcEvent $e)
{
$eventManager = $e->getApplication()->getEventManager();
$serviceManager = $e->getApplication()->getServiceManager();
$eventManager->attach('dispatch', array($this, 'setLayout'));
$moduleRouteListener = new ModuleRouteListener();
$moduleRouteListener->attach($eventManager);
//LANGUAGE
$validatorTranslator = new \Zend\Mvc\I18n\Translator();
$sessionLang = new SessionContainer('language');
$HelperPluginManager = new HelperPluginManager();
$translator = $serviceManager->get('translator');
$validatorTranslator->addTranslationFile('phparray', __DIR__ .
'/language/validator/pl_PL.php', 'default', 'pl_PL');
$validatorTranslator->addTranslationFile('phparray', __DIR__ .
'/language/validator/en_US.php', 'default', 'en_US');
AbstractValidator::setDefaultTranslator($validatorTranslator);
AbstractValidator::setMessageLength(500);
$HelperPluginManager->injectTranslator($validatorTranslator);
$http = isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ?
substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2) : 'en';
$lang = $sessionLang->lang ? $sessionLang->lang : $http;
switch($lang){
case 'pl':
$validatorTranslator->setLocale("pl_PL");
$translator->setLocale("pl_PL");
date_default_timezone_set("Etc/GMT+1");
break;
default:
$validatorTranslator->setLocale("en_US");
$translator->setLocale("en_US");
date_default_timezone_set("Etc/GMT");
}
}
Parallel for loops in java
Parallel for loops in java
When I use one loop from one to million it takes less time then when i use
multiple threads dividing the loop counter in threads. my code is
class Looper implements Runnable {
private int start;
private int end;
private long time;
private long time1;
public Looper(int start, int end,long time1){
this.start = start;
this.end = end;
time=System.nanoTime();
this.time1=time1;
}
@Override
public void run() {
for(int i=start; i<end; i++){
System.out.println(" index : " + i) ;
}
time=System.nanoTime()-time;
System.out.println("Time taken by this thread is :"+time/100000 + "
and by loop was"+ time1/100000 );
}
}
public class DevideWork {
public static void main(String[] args){
long time=System.nanoTime();
for(int i=0;i<1000000;i++){
System.out.println(" index :"+i);
}
time=System.nanoTime()-time;
Thread looper1 = new Thread(new Looper(1,250000,time));
Thread looper2 = new Thread (new Looper(250001,500000,time));
Thread looper3 = new Thread(new Looper(500001,750000,time));
Thread looper4 = new Thread (new Looper(750001,1000000,time));
looper1.start();
looper2.start();
looper3.start();
looper4.start();
// System.out.println("Time taken is:"+ (System.currentTimeMillis()-time));
}
}
When I use one loop from one to million it takes less time then when i use
multiple threads dividing the loop counter in threads. my code is
class Looper implements Runnable {
private int start;
private int end;
private long time;
private long time1;
public Looper(int start, int end,long time1){
this.start = start;
this.end = end;
time=System.nanoTime();
this.time1=time1;
}
@Override
public void run() {
for(int i=start; i<end; i++){
System.out.println(" index : " + i) ;
}
time=System.nanoTime()-time;
System.out.println("Time taken by this thread is :"+time/100000 + "
and by loop was"+ time1/100000 );
}
}
public class DevideWork {
public static void main(String[] args){
long time=System.nanoTime();
for(int i=0;i<1000000;i++){
System.out.println(" index :"+i);
}
time=System.nanoTime()-time;
Thread looper1 = new Thread(new Looper(1,250000,time));
Thread looper2 = new Thread (new Looper(250001,500000,time));
Thread looper3 = new Thread(new Looper(500001,750000,time));
Thread looper4 = new Thread (new Looper(750001,1000000,time));
looper1.start();
looper2.start();
looper3.start();
looper4.start();
// System.out.println("Time taken is:"+ (System.currentTimeMillis()-time));
}
}
Subscribe to:
Posts (Atom)