问:
Substring assignment
I have an assignment in school but I'm totally stuck.

My assignment:
Make a program that ask for a text and then write out the text several times. First with just one letter, then with two and so on. For example, if the user write "Thomas", your program should write out "T", "Th, "Tho, "Thom", and so on.

My hopeless attempt
I been trying to use "Substring" and a loop to make it work but I'm not sure I'm on the right path or not. Right now my code look like this:

```<code><head>
<meta charset= "UTF-8"/>
<title> assignment14 - Johan </title>

<script type="text/javascript">

var text= test.length;

for (i=0;i< test.length;i++)

function printit()
{
var str = test;
var res = str.substring (i, 2);
document.getElementById("test").innerHTML = res;
}

    </script>

</head>

<body>
<h1>Assignment 14</h1>
    <form name="f1">
    <input type="text" id="test" value="" />
    <input type="button" value="Hämta" onclick="printit(document.getElementById('test'))" />

    </form>

</body>
</code>```

Just need some kind of hint If I'm going in the right direction or not, should I use some other functions? Very thankful for help.

答:
Output several time using substring() method can be done as below, create a function which performs this task of extracting the user inputted string on button click using forloop and substring() method.

var intp = document.querySelector("input");
var btn = document.querySelector("button");
var dv = document.querySelector("div");
btn.onclick = function() {
  var b = intp.value;
  for (var i = 1; i <= b.length; i++) {
    var c = b.substring(0, i);
    dv.innerHTML += c + "
";
  }
}```
<pre class="snippet-code-css lang-css prettyprint-override"><code>div{
  width:400px;
  background:#111;
  color:yellow;
}</code>```

<input type="text">
<button>Click</button>

```

You have used a correct way for doing this, but as one of user suggest the start and end value of substring() was not correct.

Title: Substring assignment

Body:
I have an assignment in school but I'm totally stuck.

My assignment:
Make a program that ask for a text and then write out the text several times. First with just one letter, then with two and so on. For example, if the user write "Thomas", your program should write out "T", "Th, "Tho, "Thom", and so on.

My hopeless attempt
I been trying to use "Substring" and a loop to make it work but I'm not sure I'm on the right path or not. Right now my code look like this:

<meta charset= "UTF-8"/>
<title> assignment14 - Johan </title>

Assignment 14

    <form name="f1">
    <input type="text" id="test" value="" />
    <input type="button" value="Hämta" onclick="printit(document.getElementById('test'))" />

    </form>

Just need some kind of hint If I'm going in the right direction or not, should I use some other functions? Very thankful for help.

Body:
Output several time using substring() method can be done as below, create a function which performs this task of extracting the user inputted string on button click using forloop and substring() method.

var intp = document.querySelector("input");
var btn = document.querySelector("button");
var dv = document.querySelector("div");
btn.onclick = function() {
  var b = intp.value;
  for (var i = 1; i <= b.length; i++) {
    var c = b.substring(0, i);
    dv.innerHTML += c + "<br/>";
  }
}

div{
  width:400px;
  background:#111;
  color:yellow;
}

<input type="text">
<button>Click</button>
<br/><br/>
<div></div>

You have used a correct way for doing this, but as one of user suggest the start and end value of substring() was not correct.


来源: stackexchange

问:
how to write while loop for file in google shell to plus 3 for each line
enter image description here

hello, this is a file I created in google shell. I want to plus three for each line such as the first line will be 699 from 696. I tried to use "while read line; do c="line" c=c+3 "line"; done

答:
You can use the following script:

```<code>#!/bin/bash

while read -r line || [[ -n "$line" ]]; do
   echo $(($line+3));
done < "$1"
</code>```

After creating it you need to give execution permission to your user:

```<code>chmod u+x my_script.sh
</code>```

before calling it in the following way:

```<code>./my_script.sh file.in > file.out
</code>```

the result will be saved in the file.out.

Good luck!

TODO

Error management when you do have a line that is not a number, or contains other characters.

ContentLicense: CC BY-SA 3.0

Body:
You can use the following script:

#!/bin/bash

while read -r line || [[ -n "$line" ]]; do
   echo $(($line+3));
done < "$1"

After creating it you need to give execution permission to your user:

chmod u+x my_script.sh

before calling it in the following way:

./my_script.sh file.in > file.out

the result will be saved in the file.out.

Good luck!

TODO

Error management when you do have a line that is not a number, or contains other characters.


问:
Angular UI-Calendar TypeError: calendar.fullCalendar is not a function
I been trying to use Angular: ui-calendar with meteor, but get this error.

```<code>TypeError: calendar.fullCalendar is not a function
    at Scope.scope.initCalendar (calendar.js:265)
    at Object.fn (calendar.js:337)
    at Scope.$digest (angular.js:15896)
    at Scope.$apply (angular.js:16160)
    at bootstrapApply (angular.js:1679)
    at Object.invoke (angular.js:4523)
    at doBootstrap (angular.js:1677)
    at Object.bootstrap (angular.js:1697)
    at HTMLDocument.onReady (app.js:47)
    at fire (jquery.js:3143)
</code>```

In meteor packages i habe:

angular 1.2.3
angularui:ui-calendar

also tried to use the package inserted directly not using meteor add.
but using the calendar.js file (which is different)

Both get the same error.

Tried this: https://github.com/angular-ui/ui-calendar/issues/267

```<code>       scope.initCalendar = function () {
                if (!calendar) {
                    calendar = $(elm);
                }
                calendar.fullCalendar(options);
                if (attrs.calendar) {
                    uiCalendarConfig.calendars[attrs.calendar] = calendar;
                }
         };
</code>```

But is seems this fix doesnt work with meteor and angular-meteor.

Any ideas on how to fix this issue?

答:
You should check the initCalendar and destroyCalendar methods in angular-ui-calendar/src/calendar.js. If they're creating the element by using:

```<code>angular.element(elm).html('');
</code>```

Then you should replace it by:

```<code>$(elm).html('');
</code>```

Body:
I been trying to use Angular: ui-calendar with meteor, but get this error.

TypeError: calendar.fullCalendar is not a function
    at Scope.scope.initCalendar (calendar.js:265)
    at Object.fn (calendar.js:337)
    at Scope.$digest (angular.js:15896)
    at Scope.$apply (angular.js:16160)
    at bootstrapApply (angular.js:1679)
    at Object.invoke (angular.js:4523)
    at doBootstrap (angular.js:1677)
    at Object.bootstrap (angular.js:1697)
    at HTMLDocument.onReady (app.js:47)
    at fire (jquery.js:3143)

In meteor packages i habe:

angular 1.2.3
angularui:ui-calendar

also tried to use the package inserted directly not using meteor add.
but using the calendar.js file (which is different)

Both get the same error.

Tried this: https://github.com/angular-ui/ui-calendar/issues/267

       scope.initCalendar = function () {
                if (!calendar) {
                    calendar = $(elm);
                }
                calendar.fullCalendar(options);
                if (attrs.calendar) {
                    uiCalendarConfig.calendars[attrs.calendar] = calendar;
                }
         };

But is seems this fix doesnt work with meteor and angular-meteor.

Any ideas on how to fix this issue?

Body:
You should check the initCalendar and destroyCalendar methods in angular-ui-calendar/src/calendar.js. If they're creating the element by using:

angular.element(elm).html('');

Then you should replace it by:

$(elm).html('');


问:
How to use sum function in where clause in SQL Server?
I am new to SQL Server. I want to equal two columns using sum function. Please find the below query.

```<code>select top 1000
    o.orderamount, sum(oi.amount), oi.orderid
from
    orders o
inner join
    orderitem oi on o.orderid = oi.orderid
where
    orderamount = sum(oi.amount)
group by
    oi.orderid, orderamount
order by
    oi.orderid desc
</code>```

Whenever I execute this code, I get an error.

Please help me.

答:
You can just use HAVING:</p>

```<code>select  top 1000 o.orderamount, sum(oi.amount), oi.orderid
from orders o
inner join orderitem oi on o.orderid = oi.orderid
group by oi.orderid ,orderamount
HAVING orderamount = sum(oi.amount)
order by oi.orderid desc
</code>```

Body:
I am new to SQL Server. I want to equal two columns using sum function. Please find the below query.

select top 1000
    o.orderamount, sum(oi.amount), oi.orderid
from
    orders o
inner join
    orderitem oi on o.orderid = oi.orderid
where
    orderamount = sum(oi.amount)
group by
    oi.orderid, orderamount
order by
    oi.orderid desc

Whenever I execute this code, I get an error.

Please help me.

Body:
You can just use HAVING:

select  top 1000 o.orderamount, sum(oi.amount), oi.orderid
from orders o
inner join orderitem oi on o.orderid = oi.orderid
group by oi.orderid ,orderamount
HAVING orderamount = sum(oi.amount)
order by oi.orderid desc


问:
How to prevent page jumps when checkbox's state changes?
Example page.

When you scroll down the page until you can only see a little portion of the label (lightgreen/lightblue vertical rectangle), then click on the label to change the state of the checkbox. You then see the page jumps up in order to show the whole label.

How to prevent the jump from happening? I know setting CSS display: none on the input works, but that also hides the input from screen readers and is bad for Accessibility.

答:
Check this. Use visibility, the element will still in document.

How can I prevent the browser from scrolling on top of the page when clicking the checkbox?

ContentLicense: CC BY-SA 4.0


问:
Last line in console not overwrite
I want to overwrite the last line in the console for looping a specific row with changes.

For example:
I want to print to console
. then .. then ...

This my code for that:

```<code>int dot = 1;
    while (true)
    {
        switch (dot)
        {
            case 1:
                Console.SetCursorPosition(0, Console.CursorTop-1);
                Console.WriteLine(".");
                dot++;
                Thread.Sleep(500);
                break;
            case 2:
                Console.SetCursorPosition(0, Console.CursorTop -1);
                Console.WriteLine("..");
                dot++;
                Thread.Sleep(500);
                break;
            case 3:
                Console.SetCursorPosition(0, Console.CursorTop - 1);
                Console.WriteLine("...");
                dot = 1;
                Thread.Sleep(500);
                break;
        }
    }
}
</code>```

My problem is that after the first complete round(after it print the "..." in first time) it not print "." the console stay on "..."

I mean:

"." print

remove "." and print ".."

remove ".." and print "..."

now it stay "..." instead remove "..." and print ".".

Someone has idea why?

答:
Console.WriteLine automatically appends newline(\n) character at the end which results in the cursor jumping to next line.

You'll have to use Console.Write. It does not appends a new line character. But You'll have to put a \r at the end of your text to bring the cursor back to starting position.

So, Your Print Statement would look like

Console.Write(".  \r");

Console.Write(".. \r");

Console.Write("...\r");

Title: Last line in console not overwrite

Body:
I want to overwrite the last line in the console for looping a specific row with changes.

For example:
I want to print to console
. then .. then ...

This my code for that:

int dot = 1;
    while (true)
    {
        switch (dot)
        {
            case 1:
                Console.SetCursorPosition(0, Console.CursorTop-1);
                Console.WriteLine(".");
                dot++;
                Thread.Sleep(500);
                break;
            case 2:
                Console.SetCursorPosition(0, Console.CursorTop -1);
                Console.WriteLine("..");
                dot++;
                Thread.Sleep(500);
                break;
            case 3:
                Console.SetCursorPosition(0, Console.CursorTop - 1);
                Console.WriteLine("...");
                dot = 1;
                Thread.Sleep(500);
                break;
        }
    }
}

My problem is that after the first complete round(after it print the "..." in first time) it not print "." the console stay on "..."

I mean:

"." print

remove "." and print ".."

remove ".." and print "..."

now it stay "..." instead remove "..." and print ".".

Someone has idea why?


问:
Open a new post as intent - Facebook mobile
I am creating an app. It has a text box and an image box.Once the user filled those out, he clicks "make this a fb post" button. Then I want my app to open facebook mobile app as intent. New "ready to post" post should be created with the text and image. Is this possible to achieve. If yes, can you please let me know the way. If no, is there an alternative way.</p>

答:
Try this code  </p>

```<code>File filePath = getFileStreamPath("shareimage.jpg");  //optional. use your image path
         Intent shareIntent = new Intent();
         shareIntent.setAction(Intent.ACTION_SEND);
         shareIntent.putExtra(Intent.EXTRA_TEXT, _text);
         shareIntent.putExtra(Intent.EXTRA_STREAM,Uri.fromFile(new File(filePath)));  //optional//use this when you want to send an image
         shareIntent.setType("image/jpeg");
         shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
         startActivity(Intent.createChooser(shareIntent, "send"))
</code>```

<p>;</p>

Body:
Try this code

File filePath = getFileStreamPath("shareimage.jpg");  //optional. use your image path
         Intent shareIntent = new Intent();
         shareIntent.setAction(Intent.ACTION_SEND);
         shareIntent.putExtra(Intent.EXTRA_TEXT, _text);
         shareIntent.putExtra(Intent.EXTRA_STREAM,Uri.fromFile(new File(filePath)));  //optional//use this when you want to send an image
         shareIntent.setType("image/jpeg");
         shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
         startActivity(Intent.createChooser(shareIntent, "send"))

;


问:
Passing a particular selected item index from spinner causes app to crash, but works fine with other selected item indexes
My app crashes when a value called "Teacher" is selected from my spinner, passed through my method called getDatabasePassword() and login button is pressed.

BUT it works fine when a value called "Student" is selected from my spinner, passed through the same method called getDatabasePassword() and login button is pressed.

Details below:

I created 2 SQLite database tables each with the following columns

TEACHER

teacherId (integer primary key NOT NULL)

username (text NOT NULL)

password (text NOT NULL)

STUDENT

studentId (integer primary key NOT NULL)

username (text NOT NULL)

password (text NOT NULL)

And each of these have their own Java classes with the same named variables and appropriate getters/setters

In my Login Activity I have set an onClick method to my Login button as follows:

```<code>public view onClickLogin(View view){

   if (view.getId() == R.id.btnLogin){

       EditText usernameView = findViewById(R.id.usernameView);
       EditText passwordView = findViewById(R.id.passwordView);
       Spinner spinnerView = findViewById(R.id.spinnerView);  //Spinner that contains two items: "Teacher" and "Student"
       Button loginView = findViewById(R.id.loginView);

       String username = usernameView.getText().toString();
       String password = passwordView.getText().toString();
       String position = spinnerView.getSelectedItem().toString();

       String password_db = databaseHelper.getDatabasePassword(username, position);

       Toast toast = Toast.makeText(Activity_login.this, "username: " + username + ", password:  " + password + ", position: " + position;
       toast.show();
   }
}
</code>```

And I have narrowed down the line of code from above that causes my app to crash when "Teacher" is selected in my spinner:

```<code>String password_db = databaseHelper.getDatabasePassword(username, position);
</code>```

That method is in my Database Helper class:

```<code>public String getDatabasePassword(String username, String position){
   String table = "";
   String a, b;
   b = "Person not found."

   if (position.equals("Student"))
      table = "STUDENT";
   else if (position.equals("Teacher"))
      table = "TEACHER";

   db = this.getReadableDatabase();
   String query = "SELECT username, password FROM " + table;
   Cursor cursor = db.rawQuery(query, null);

   if (cursor.moveToFirst())
   {
      do {
         a = cursor.getString(0);
         if (a.equals(username)){
            b = cursor.getString(1);
            break;
         } while (cursor.moveToNext());
   }
   return b;
   }
}
</code>```

where db is SQLiteDatabase db;

I've already made sure that all my CREATE and INSERT queries and all other methods are working as intended and I've triple checked my spelling.  All my XML layouts and string values are spelled correctly as well.

As mentioned before, I've managed to narrow my problem down to this one function and I'm not sure why my app crashes when "Teacher" is selected then Login button is pressed but when "Student" is selected then Login button is pressed my app works just fine.

EDIT:  After checking my LogCat, I had the "No such table exist" error.  I had to uninstall and reinstall my APK build.

答:
Whenever you make any change in DB like created new table or add/edit any field/column in table,
either you have to uninstall and install your app again,
or you change DB version and in onUpgrade method just delete your all table and run onCreate method again,
Thanks</p>

Body:
My app crashes when a value called "Teacher" is selected from my spinner, passed through my method called getDatabasePassword() and login button is pressed.

BUT it works fine when a value called "Student" is selected from my spinner, passed through the same method called getDatabasePassword() and login button is pressed.

Details below:

I created 2 SQLite database tables each with the following columns

TEACHER

teacherId (integer primary key NOT NULL)

username (text NOT NULL)

password (text NOT NULL)

STUDENT

studentId (integer primary key NOT NULL)

username (text NOT NULL)

password (text NOT NULL)

And each of these have their own Java classes with the same named variables and appropriate getters/setters

In my Login Activity I have set an onClick method to my Login button as follows:

public view onClickLogin(View view){

   if (view.getId() == R.id.btnLogin){

       EditText usernameView = findViewById(R.id.usernameView);
       EditText passwordView = findViewById(R.id.passwordView);
       Spinner spinnerView = findViewById(R.id.spinnerView);  //Spinner that contains two items: "Teacher" and "Student"
       Button loginView = findViewById(R.id.loginView);

       String username = usernameView.getText().toString();
       String password = passwordView.getText().toString();
       String position = spinnerView.getSelectedItem().toString();

       String password_db = databaseHelper.getDatabasePassword(username, position);

       Toast toast = Toast.makeText(Activity_login.this, "username: " + username + ", password:  " + password + ", position: " + position;
       toast.show();
   }
}

And I have narrowed down the line of code from above that causes my app to crash when "Teacher" is selected in my spinner:

String password_db = databaseHelper.getDatabasePassword(username, position);

That method is in my Database Helper class:

public String getDatabasePassword(String username, String position){
   String table = "";
   String a, b;
   b = "Person not found."

   if (position.equals("Student"))
      table = "STUDENT";
   else if (position.equals("Teacher"))
      table = "TEACHER";

   db = this.getReadableDatabase();
   String query = "SELECT username, password FROM " + table;
   Cursor cursor = db.rawQuery(query, null);

   if (cursor.moveToFirst())
   {
      do {
         a = cursor.getString(0);
         if (a.equals(username)){
            b = cursor.getString(1);
            break;
         } while (cursor.moveToNext());
   }
   return b;
   }
}

where db is SQLiteDatabase db;

I've already made sure that all my CREATE and INSERT queries and all other methods are working as intended and I've triple checked my spelling.  All my XML layouts and string values are spelled correctly as well.

As mentioned before, I've managed to narrow my problem down to this one function and I'm not sure why my app crashes when "Teacher" is selected then Login button is pressed but when "Student" is selected then Login button is pressed my app works just fine.

EDIT:  After checking my LogCat, I had the "No such table exist" error.  I had to uninstall and reinstall my APK build.


答:
I recommend you to use Facebooks Share Dialog.
So you can achieve your goal in 1 step.</p>

Title: Open a new post as intent - Facebook mobile

Body: I am creating an app. It has a text box and an image box.Once the user filled those out, he clicks "make this a fb post" button. Then I want my app to open facebook mobile app as intent. New "ready to post" post should be created with the text and image. Is this possible to achieve. If yes, can you please let me know the way. If no, is there an alternative way.


问:
Finding smallest value for parameterised answer that satisfies condition
I want to find the smallest integer l that satisfies l^2 >= x, and mod(l,2)=0.

In the following example x=75, and hence l=10, since the previous even number doesn't fulfil the inequation: 8^2 <= 75 <= 10^2

I have tried this (ignoring the even-number requirement, which I can't to work):

```<code>syms l integer
eqn1 = l^2 >= 75;
% eqn2 = mod(l,2) == 0;
[sol_l, param, cond] = solve(eqn1, l, 'ReturnConditions', true);
</code>```

But this does not give me anything helpful directly:

```<code>sol_l =
k
param =
k
cond =
(75^(1/2) <= k | k <= -75^(1/2)) & in(k, 'integer')
</code>```

I would like to evaluate the conditions on the parameter and find the smallest value that satisfies the conditions.

Also, I would like to enforce the mod(l,2)=0 condition somehow, but I don't seem to get that work.

答:
I guess the easiest solution without employing the inequality and solve function would be to find the exact solution to your equation l^2 >= x, and then finding the next even integer. The code would look like this:

```<code>x = 75;

y = ceil(sqrt(x)); %Ceil finds the next bigger integer

if(~mod(y,2))   %If it's even, we got the solution
    sol = y;
else            %If not, get the next integer
    sol = y+1;
end
</code>```

The previous code gives the correct solution to the provided example (x = 75; sol = 10)

Body:
I want to find the smallest integer l that satisfies l^2 >= x, and mod(l,2)=0.

In the following example x=75, and hence l=10, since the previous even number doesn't fulfil the inequation: 8^2 <= 75 <= 10^2

I have tried this (ignoring the even-number requirement, which I can't to work):

syms l integer
eqn1 = l^2 >= 75;
% eqn2 = mod(l,2) == 0;
[sol_l, param, cond] = solve(eqn1, l, 'ReturnConditions', true);

But this does not give me anything helpful directly:

sol_l =
k
param =
k
cond =
(75^(1/2) <= k | k <= -75^(1/2)) & in(k, 'integer')

I would like to evaluate the conditions on the parameter and find the smallest value that satisfies the conditions.

Also, I would like to enforce the mod(l,2)=0 condition somehow, but I don't seem to get that work.

Body:
I guess the easiest solution without employing the inequality and solve function would be to find the exact solution to your equation l^2 >= x, and then finding the next even integer. The code would look like this:

x = 75;

y = ceil(sqrt(x)); %Ceil finds the next bigger integer

if(~mod(y,2))   %If it's even, we got the solution
    sol = y;
else            %If not, get the next integer
    sol = y+1;
end

The previous code gives the correct solution to the provided example (x = 75; sol = 10)


问:
creating data base tables from text file data
i have text files generated from another software about genes in human body, i need to insert them to a table and make the table as i need , i have 15 different text files that goes in to one table, as 15 different columns.

```<code>GFER = 3.58982863
BPIL1 = 3.58982863
BTBD1 = 4.51464898
BTBD2 = 4.40934218
RPLP1 = 3.57462687
PDHA1 = 4.19320066
LRRC7 = 4.50967385
HIGD1A = 4.46876727
</code>```

above shown is the data in the text file, gene name and the distances. i need to include this in a table, gene name in a separate column and distance in a separate column, this text file have 3500 lines and i have 14 text files of data, how can i enter this data to a table without manually inserting?any automated software or tool you know? please help me out!

regards,
Rangana

答:
i have done it, it may seems odd, but i'm adding here for some one to learn if it is valuable, i have opened those data files using open office spreadsheet, open office has this amazing features of separating the data file in to different columns. so i used them and separated my data files columns and saved it as a excel file(.xls) , then using the "sqlmaestro" as suggested by m.edmondson, using that software's importing data as an excel file feature i was able to achieve my task.

thank you all for your valuable answers, they surely add new things to my knowledge! thank you all once again!

ContentLicense: CC BY-SA 2.5

Body:
i have text files generated from another software about genes in human body, i need to insert them to a table and make the table as i need , i have 15 different text files that goes in to one table, as 15 different columns.

GFER = 3.58982863
BPIL1 = 3.58982863
BTBD1 = 4.51464898
BTBD2 = 4.40934218
RPLP1 = 3.57462687
PDHA1 = 4.19320066
LRRC7 = 4.50967385
HIGD1A = 4.46876727

above shown is the data in the text file, gene name and the distances. i need to include this in a table, gene name in a separate column and distance in a separate column, this text file have 3500 lines and i have 14 text files of data, how can i enter this data to a table without manually inserting?any automated software or tool you know? please help me out!

regards,
Rangana


问:
Find classes not implementing hashCode
I have a project with quite some classes and it provides different answer when I run with Debug compare to Run in Intellij. Correct answer, but different, in both cases.

I suspect that there is one or more classes not implementing hashCode that is the cause of the difference. We use hash-based collections in several places.

How can I easily find the classes that do not implement hashCode without resorting to go through them manually?

答:
You could try running it with a custom class loader the prints classes that do not override hashCode. Run with -Djava.system.class.loader=my.package.HashFindingLoader

```<code>package my.package;
import java.lang.reflect.Method;

public class HashFindingLoader extends ClassLoader {

    public HashFindingLoader(ClassLoader parent) {
        super(parent);
    }

    @Override
    public Class<?> loadClass(String name) throws ClassNotFoundException {
        Class<?> c = super.loadClass(name);

        //filters out librry classes, adjust as necessary
        if(!c.getPackage().getName().matches("^(java|sun).*")){
            Method hashCode;
            try {
                hashCode = c.getMethod("hashCode");
            } catch (NoSuchMethodException|SecurityException ex) {
               throw new RuntimeException(ex);
            }
            if (hashCode.getDeclaringClass().equals(Object.class)){
                System.out.printf("%s does not override hashCode%n", c);
            }
        }
        return c;
    }

}
</code>```

Title: Find classes not implementing hashCode

Body:
You could try running it with a custom class loader the prints classes that do not override hashCode. Run with -Djava.system.class.loader=my.package.HashFindingLoader

package my.package;
import java.lang.reflect.Method;

public class HashFindingLoader extends ClassLoader {

    public HashFindingLoader(ClassLoader parent) {
        super(parent);
    }

    @Override
    public Class<?> loadClass(String name) throws ClassNotFoundException {
        Class<?> c = super.loadClass(name);

        //filters out librry classes, adjust as necessary
        if(!c.getPackage().getName().matches("^(java|sun).*")){
            Method hashCode;
            try {
                hashCode = c.getMethod("hashCode");
            } catch (NoSuchMethodException|SecurityException ex) {
               throw new RuntimeException(ex);
            }
            if (hashCode.getDeclaringClass().equals(Object.class)){
                System.out.printf("%s does not override hashCode%n", c);
            }
        }
        return c;
    }

}


问:
Spring MongoTemplate upsert entire list
I have a list of objects which I want to insert into a collection. The mongoTemplate.insert(list); works fine but now I want to modify it to upsert(); as my list can contain duplicate objects which are already inserted into a collection. So what I want is insert entire list and on the go check if the item is already present in the collection then skip it else insert it.

答:
You need to create a unique index field of your object's id(if there is no unique constraint). So that it will make error while you try to insert using same id.

Using the unique constraint you insert array or using BulkInsert

For using insert you can set a flag continueOnError: true which can continue insertion whenever error found in case of error because of unique constraint while inserting existing id of object.

Title: Spring MongoTemplate upsert entire list


答:
You can use this :</p>

```<code>select  top 1000 o.orderamount, oi.amount, oi.orderid
from orders o
inner join (select orderid, sum(amount) amount from orderitem group by orderid) orderitem
oi on o.orderid = oi.orderid and orderamount = oi.amount
order by oi.orderid desc
</code>```

Title: How to use sum function in where clause in SQL Server?

Body:
You can use this :

select  top 1000 o.orderamount, oi.amount, oi.orderid
from orders o
inner join (select orderid, sum(amount) amount from orderitem group by orderid) orderitem
oi on o.orderid = oi.orderid and orderamount = oi.amount
order by oi.orderid desc


问:
How to find specific date from js array?
I have this array in my data.js file. And I want to find the specific date from other html file to data.js file using javascript.

For example:

Here is the date to search

var searchDate = '12-25-2017';

I want to search that date from data.js file ( Variable name : jpHolidays )and show in html or console.log().

I was googling and i didn't find how to find the specific date. Please help me.

```<code>var jpHolidays = {
     '01-01-2017' : '<span>お正月 <br> New Year\'s Day</span>',
     '01-02-2017' : '<span>お正月 <br> New Year\'s Day observed</span>',
     '01-09-2017' : '<span>成人の日 <br> Coming of Age Day</span>',
     '02-11-2017' : '<span>建国記念日 <br> National Foundation Day</span>',
     '03-20-2017' : '<span>春分の日 <br> Vernal Equinox Day</span>',
     '04-29-2017' : '<span>昭和の日 <br> Shōwa Day</span>',
     '05-03-2017' : '<span>憲法記念日 <br> Constitution Memorial Day</span>',
     '05-04-2017' : '<span>みどりの日 <br> Greenery Day</span>',
     '05-05-2017' : '<span>こどもの日 <br> Children\'s Day</span>',
     '07-17-2017' : '<span>海の日 <br> Marine Day / Ocean Day</span>',
     '08-11-2017' : '<span>山の日 <br> Mountain Day</span>',
     '09-18-2017' : '<span>敬老の日 <br> Respect for the Aged Day</span>',
     '09-23-2017' : '<span>秋分の日 <br> Autumnal Equinox Day</span>',
     '10-09-2017' : '<span>体育の日 <br> Health and Sports Day </span>',
     '11-03-2017' : '<span>文化の日 <br> Culture Day</span>',
     '11-23-2017' : '<span>勤労感謝の日 <br> Labour Thanksgiving Day </span>',
     '12-23-2017' : '<span>天皇誕生日 <br> The Emperor\'s Birthday</span>',
 };
</code>```

答:
A) Declare it as a global variable.

```<code>window.jpHolidays = {
     '01-01-2017' : '<span>お正月 <br> New Year\'s Day</span>',
     '01-02-2017' : '<span>お正月 <br> New Year\'s Day observed</span>',
     ...
};
</code>```

B) Load data.js file before the file that you will use.

So the global variable, jpHolidays, can be stored in window. Like below:

```<code><script src="data.js"></script>
<script src="yourFile.js"></script>
</code>```

C) Grab datas from window.jpHolidays

```<code>console.log(jpHolidays['01-01-2017']);
</code>```

Body:
I have this array in my data.js file. And I want to find the specific date from other html file to data.js file using javascript.

For example:

Here is the date to search

var searchDate = '12-25-2017';

I want to search that date from data.js file ( Variable name : jpHolidays )and show in html or console.log().

I was googling and i didn't find how to find the specific date. Please help me.

var jpHolidays = {
     '01-01-2017' : 'お正月
 New Year\'s Day',
     '01-02-2017' : 'お正月
 New Year\'s Day observed',
     '01-09-2017' : '成人の日
 Coming of Age Day',
     '02-11-2017' : '建国記念日
 National Foundation Day',
     '03-20-2017' : '春分の日
 Vernal Equinox Day',
     '04-29-2017' : '昭和の日
 Shōwa Day',
     '05-03-2017' : '憲法記念日
 Constitution Memorial Day',
     '05-04-2017' : 'みどりの日
 Greenery Day',
     '05-05-2017' : 'こどもの日
 Children\'s Day',
     '07-17-2017' : '海の日
 Marine Day / Ocean Day',
     '08-11-2017' : '山の日
 Mountain Day',
     '09-18-2017' : '敬老の日
 Respect for the Aged Day',
     '09-23-2017' : '秋分の日
 Autumnal Equinox Day',
     '10-09-2017' : '体育の日
 Health and Sports Day ',
     '11-03-2017' : '文化の日
 Culture Day',
     '11-23-2017' : '勤労感謝の日
 Labour Thanksgiving Day ',
     '12-23-2017' : '天皇誕生日
 The Emperor\'s Birthday',
 };

Body:
A) Declare it as a global variable.

window.jpHolidays = {
     '01-01-2017' : '<span>お正月 <br> New Year\'s Day</span>',
     '01-02-2017' : '<span>お正月 <br> New Year\'s Day observed</span>',
     ...
};

B) Load data.js file before the file that you will use.

So the global variable, jpHolidays, can be stored in window. Like below:

<script src="data.js"></script>
<script src="yourFile.js"></script>

C) Grab datas from window.jpHolidays

console.log(jpHolidays['01-01-2017']);


问:
How to pause a Javascript asynchronous function without setTimeout?
I have a function that checks the existence of token in the database. The problem is it takes some amount of time to return that bool value and I kinda need to pause the function so that the function realizes that the token has existed and run the query again.

const registerToken = dispatch => {
  var tokenExisted = null
  do {
    let token = generateRandomToken();
    firebase.database().ref(`/Token`).orderByChild("token").equalTo(token).once("value", snapshot => { // check whether token exists
      if (!snapshot.val()) {  // if token not exist
        token = false;
        // register token to firebase
      } else {
        token = true; // continue the loop to generate a new token and query again
      }
    })
  } while (tokenExisted === true);
}```

My setup is basically a do-while loop, when the function first gets call
tokenExisted = null, then a random 4 digit token will be generated and a query will be dispatched to firebase and verify it token has existed.

If token has existed, then tokenExisted = true. I expect it the assignment to be executed but the single threaded nature of Javascript will reach the end of the loop before the query return anything.

I figured to use setTimeout and periodically add some small amount of time whenever tokenExisted = null to kinda safe guard so that the function will always catch when query function returns anything.

Has anyone had a better approach to achieve the same thing?

答:
You might want to call the function itself recursively, as such.

```<code>const registerToken = dispatch => {
  let token = generateRandomToken();
  const tokenObjectRef = firebase.database().ref(`/Token`);

  tokenObjectRef.orderByChild("token").equalTo(token).once("value")
    .then(snapshot => {
      if (!snapshot.val()) {
        // success!
      } else {
        registerToken(dispatch) // call itself again
      }
    })
    .catch(error => {} ))
}
</code>```

The logic is that token will be refreshed during each new iteration, should the process fails and a new query is needed (if this is what you need).

Note: avoid using do-while in async logic. Plan carefully ahead as you might encounter lots of logic error and it is hard to trace.

Body:
I have a function that checks the existence of token in the database. The problem is it takes some amount of time to return that bool value and I kinda need to pause the function so that the function realizes that the token has existed and run the query again.

const registerToken = dispatch => {
  var tokenExisted = null
  do {
    let token = generateRandomToken();
    firebase.database().ref(`/Token`).orderByChild("token").equalTo(token).once("value", snapshot => { // check whether token exists
      if (!snapshot.val()) {  // if token not exist
        token = false;
        // register token to firebase
      } else {
        token = true; // continue the loop to generate a new token and query again
      }
    })
  } while (tokenExisted === true);
}

My setup is basically a do-while loop, when the function first gets call
tokenExisted = null, then a random 4 digit token will be generated and a query will be dispatched to firebase and verify it token has existed.

If token has existed, then tokenExisted = true. I expect it the assignment to be executed but the single threaded nature of Javascript will reach the end of the loop before the query return anything.

I figured to use setTimeout and periodically add some small amount of time whenever tokenExisted = null to kinda safe guard so that the function will always catch when query function returns anything.

Has anyone had a better approach to achieve the same thing?

Body:
You might want to call the function itself recursively, as such.

const registerToken = dispatch => {
  let token = generateRandomToken();
  const tokenObjectRef = firebase.database().ref(`/Token`);

  tokenObjectRef.orderByChild("token").equalTo(token).once("value")
    .then(snapshot => {
      if (!snapshot.val()) {
        // success!
      } else {
        registerToken(dispatch) // call itself again
      }
    })
    .catch(error => {} ))
}

The logic is that token will be refreshed during each new iteration, should the process fails and a new query is needed (if this is what you need).

Note: avoid using do-while in async logic. Plan carefully ahead as you might encounter lots of logic error and it is hard to trace.


问:
c# - Improve execution time when generating report
I have a program in visual studio 2010 where I have a function to generate report to crystal report. The query is supplied in one of my stored procedure to retrieve information from my database.

The issue I have when I click generate report, it takes a long time to return the result. I was wondering if anyone has suggestion on how to improve the execution time faster by optimizing the query in the stored procedure ?

Here is a snippet of the stored procedure:

```<code>IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[M_RPT_DailyIssuedVoucher]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'ALTER PROCEDURE [dbo].[M_RPT_DailyIssuedVoucher]
    @EventCode [varchar](8),
    @LocID [varchar](10),
    @Status [char](2),
    @DtFrom [datetime],
    @DtTo [datetime],
    @IssuedBy [nvarchar](128)
WITH EXECUTE AS CALLER
AS
SET NOCOUNT ON

Select SerialNo,
         CardID,
         CardHolder AS [Name],
         CardType,
         EventCode,
         IssueDate,
         IssueBy,
         ValidFromDate,
         ValidToDate,
         IssueLocationID,
         IssueComputerName,
         ManualIssueReason,
         [Status],
         Remarks,
         CancelReason
/*      '' CollectedStatus ='' +
            '' CASE''+
                '' WHEN LTRIM(RTRIM(CollectBy))<>'''''''' THEN ''''Y''''''+
                '' ELSE ''''N''''''+
            '' END'' +
*/
    FROM IssuedVoucher with (nolock)
    WHERE
(@EventCode = '''' OR (EventCode = @EventCode))
And(@IssuedBy = '''' OR (IssueBy= @IssuedBy))
AND (@LocID = '''' OR (IssueLocationID = @LocID))
AND (@Status = '''' OR (Status = @Status))
AND(@DtFrom IS NULL OR IssueDate >= @DtFrom )
AND (@DtTo IS NULL OR IssueDate <= @DtTo)

 ORDER BY SerialNo, EventCode
</code>```

Here is the query for create table for issuedvoucher :

```<code>IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[IssuedVoucher]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[IssuedVoucher](
    [BatchNo] [decimal](18, 0) NOT NULL,
    [SerialNo] [varchar](15) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
    [ManualIssueReason] [varchar](250) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
    [IssueLocationId] [varchar](8) COLLATE Latin1_General_CI_AS NULL,
    [IssueComputerName] [varchar](25) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
    [Remarks] [varchar](250) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
    [CardId] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
    [CardHolder] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
    [CardType] [varchar](5) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
    [EventCode] [varchar](8) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
    [PromotionBenefitCode] [varchar](8) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
    [ValidFromDate] [datetime] NOT NULL,
    [ValidToDate] [datetime] NOT NULL,
    [VisiblePoint] [decimal](18, 2) NOT NULL,
    [HiddenPoint] [decimal](18, 2) NOT NULL,
    [LoyaltyPoint] [decimal](18, 2) NOT NULL,
    [NNECash] [decimal](18, 0) NULL,
    [Status] [char](2) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
    [PrintStatus] [char](2) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
    [IssueDate] [datetime] NOT NULL,
    [IssueBy] [nvarchar](128) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
    [CollectDate] [datetime] NOT NULL,
    [CollectBY] [nvarchar](128) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
    [CollectLocationId] [varchar](10) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
    [CancelReason] [varchar](250) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
    [LastChangeBy] [nvarchar](128) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
    [LastChangeDate] [datetime] NOT NULL,
    [RecordVersion] [timestamp] NOT NULL,
    [AllotmentID] [decimal](18, 0) NOT NULL,
    [GuestType] [bit] NOT NULL,
    [CompanyID] [bigint] NULL,
    [DepartmentID] [smallint] NULL,
    [IDIssuedCountry] [nvarchar](50) COLLATE Latin1_General_CI_AS NULL,
    [EVoucherBatchNo] [decimal](18, 0) NULL,
    [EVoucherGuestNo] [decimal](18, 0) NULL,
    [EVoucherSerialNo] [varchar](50) COLLATE Latin1_General_CI_AS NULL,
    [Barcode] [varchar](50) COLLATE Latin1_General_CI_AS NULL,
    [Monetary] [bit] NOT NULL,
    [Discount] [bit] NOT NULL,
    [ConsiderationValue] [decimal](18, 2) NULL,
    [FaceValue] [decimal](18, 0) NULL,
    [IntercoRate] [decimal](18, 0) NULL,
    [SAPCostCentre] [varchar](10) COLLATE Latin1_General_CI_AS NULL,
    [SAPIONumber] [varchar](25) COLLATE Latin1_General_CI_AS NULL,
    [IsGift] [bit] NOT NULL,
    [PrintCount] [int] NOT NULL,
    [TaxInvoiceID] [decimal](18, 0) NULL,
    [IdentificationNumber] [varchar](50) COLLATE Latin1_General_CI_AS NULL,
    [IdentificationType] [varchar](5) COLLATE Latin1_General_CI_AS NULL,
    [CRMEntitlementMasterID] [nvarchar](20) COLLATE Latin1_General_CI_AS NULL,
    [DeductPointType] [smallint] NULL,
    [DeductCreditType] [smallint] NULL,
    [AwardPointType] [smallint] NULL,
    [AwardCreditType] [smallint] NULL,
    [AwardCreditValue] [decimal](18, 2) NULL,
    [deductPointvalue] [decimal](18, 2) NULL,
    [deductCreditvalue] [decimal](18, 2) NULL,
    [AwardPointvalue] [decimal](18, 2) NULL,
 CONSTRAINT [PK_IssuedVoucher2] PRIMARY KEY CLUSTERED
(
    [SerialNo] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = ON, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = OFF, FILLFACTOR = 80) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  Index [_dta_index_IssuedVoucher_18_1736445310__K1]    Script Date: 04/12/2017 3:39:19 PM ******/
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[IssuedVoucher]') AND name = N'_dta_index_IssuedVoucher_18_1736445310__K1')
CREATE NONCLUSTERED INDEX [_dta_index_IssuedVoucher_18_1736445310__K1] ON [dbo].[IssuedVoucher]
(
    [BatchNo] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = ON, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = OFF, FILLFACTOR = 80) ON [PRIMARY]
GO

SET ANSI_PADDING ON
GO

/****** Object:  Index [_dta_index_IssuedVoucher_18_1736445310__K2_K10_7_25_55]    Script Date: 04/12/2017 3:39:19 PM ******/
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[IssuedVoucher]') AND name = N'_dta_index_IssuedVoucher_18_1736445310__K2_K10_7_25_55')
CREATE NONCLUSTERED INDEX [_dta_index_IssuedVoucher_18_1736445310__K2_K10_7_25_55] ON [dbo].[IssuedVoucher]
(
    [SerialNo] ASC,
    [EventCode] ASC
)
INCLUDE (   [CardId],
    [CancelReason],
    [IdentificationNumber]) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = ON, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = OFF, FILLFACTOR = 80) ON [PRIMARY]
GO

SET ANSI_PADDING ON
GO

/****** Object:  Index [idx_CardID]    Script Date: 04/12/2017 3:39:19 PM ******/
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[IssuedVoucher]') AND name = N'idx_CardID')
CREATE NONCLUSTERED INDEX [idx_CardID] ON [dbo].[IssuedVoucher]
(
    [BatchNo] ASC,
    [CardId] ASC,
    [Status] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = ON, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = OFF, FILLFACTOR = 80) ON [PRIMARY]
GO

SET ANSI_PADDING ON
GO

/****** Object:  Index [IX_IssuedVoucher_1]    Script Date: 04/12/2017 3:39:19 PM ******/
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[IssuedVoucher]') AND name = N'IX_IssuedVoucher_1')
CREATE NONCLUSTERED INDEX [IX_IssuedVoucher_1] ON [dbo].[IssuedVoucher]
(
    [CardId] ASC,
    [CardType] ASC,
    [EventCode] ASC,
    [PromotionBenefitCode] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = ON, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = OFF, FILLFACTOR = 80) ON [PRIMARY]
GO

SET ANSI_PADDING ON
GO

/****** Object:  Index [RecordVoucher]    Script Date: 04/12/2017 3:39:19 PM ******/
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[IssuedVoucher]') AND name = N'RecordVoucher')
CREATE NONCLUSTERED INDEX [RecordVoucher] ON [dbo].[IssuedVoucher]
(
    [EVoucherSerialNo] ASC,
    [Barcode] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = OFF) ON [PRIMARY]
GO
</code>```

答:
In my experience, the WHERE operator might be the problem. I had a similar issue, not with a reporting engine, but rather with accessing information from a database.
Imo, the IS NULL is costing performance. I might be wrong though, since I am not a crack at database.
I solved my issue with rather excluding the IS NULL statements. After I got my collection of data, I generated a new collection in C# which includes such statements.</p>

Body:
I have a program in visual studio 2010 where I have a function to generate report to crystal report. The query is supplied in one of my stored procedure to retrieve information from my database.

The issue I have when I click generate report, it takes a long time to return the result. I was wondering if anyone has suggestion on how to improve the execution time faster by optimizing the query in the stored procedure ?

Here is a snippet of the stored procedure:

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[M_RPT_DailyIssuedVoucher]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'ALTER PROCEDURE [dbo].[M_RPT_DailyIssuedVoucher]
    @EventCode [varchar](8),
    @LocID [varchar](10),
    @Status [char](2),
    @DtFrom [datetime],
    @DtTo [datetime],
    @IssuedBy [nvarchar](128)
WITH EXECUTE AS CALLER
AS
SET NOCOUNT ON

Select SerialNo,
         CardID,
         CardHolder AS [Name],
         CardType,
         EventCode,
         IssueDate,
         IssueBy,
         ValidFromDate,
         ValidToDate,
         IssueLocationID,
         IssueComputerName,
         ManualIssueReason,
         [Status],
         Remarks,
         CancelReason
/*      '' CollectedStatus ='' +
            '' CASE''+
                '' WHEN LTRIM(RTRIM(CollectBy))<>'''''''' THEN ''''Y''''''+
                '' ELSE ''''N''''''+
            '' END'' +
*/
    FROM IssuedVoucher with (nolock)
    WHERE
(@EventCode = '''' OR (EventCode = @EventCode))
And(@IssuedBy = '''' OR (IssueBy= @IssuedBy))
AND (@LocID = '''' OR (IssueLocationID = @LocID))
AND (@Status = '''' OR (Status = @Status))
AND(@DtFrom IS NULL OR IssueDate >= @DtFrom )
AND (@DtTo IS NULL OR IssueDate <= @DtTo)

 ORDER BY SerialNo, EventCode

Here is the query for create table for issuedvoucher :

IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[IssuedVoucher]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[IssuedVoucher](
    [BatchNo] [decimal](18, 0) NOT NULL,
    [SerialNo] [varchar](15) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
    [ManualIssueReason] [varchar](250) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
    [IssueLocationId] [varchar](8) COLLATE Latin1_General_CI_AS NULL,
    [IssueComputerName] [varchar](25) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
    [Remarks] [varchar](250) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
    [CardId] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
    [CardHolder] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
    [CardType] [varchar](5) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
    [EventCode] [varchar](8) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
    [PromotionBenefitCode] [varchar](8) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
    [ValidFromDate] [datetime] NOT NULL,
    [ValidToDate] [datetime] NOT NULL,
    [VisiblePoint] [decimal](18, 2) NOT NULL,
    [HiddenPoint] [decimal](18, 2) NOT NULL,
    [LoyaltyPoint] [decimal](18, 2) NOT NULL,
    [NNECash] [decimal](18, 0) NULL,
    [Status] [char](2) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
    [PrintStatus] [char](2) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
    [IssueDate] [datetime] NOT NULL,
    [IssueBy] [nvarchar](128) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
    [CollectDate] [datetime] NOT NULL,
    [CollectBY] [nvarchar](128) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
    [CollectLocationId] [varchar](10) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
    [CancelReason] [varchar](250) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
    [LastChangeBy] [nvarchar](128) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
    [LastChangeDate] [datetime] NOT NULL,
    [RecordVersion] [timestamp] NOT NULL,
    [AllotmentID] [decimal](18, 0) NOT NULL,
    [GuestType] [bit] NOT NULL,
    [CompanyID] [bigint] NULL,
    [DepartmentID] [smallint] NULL,
    [IDIssuedCountry] [nvarchar](50) COLLATE Latin1_General_CI_AS NULL,
    [EVoucherBatchNo] [decimal](18, 0) NULL,
    [EVoucherGuestNo] [decimal](18, 0) NULL,
    [EVoucherSerialNo] [varchar](50) COLLATE Latin1_General_CI_AS NULL,
    [Barcode] [varchar](50) COLLATE Latin1_General_CI_AS NULL,
    [Monetary] [bit] NOT NULL,
    [Discount] [bit] NOT NULL,
    [ConsiderationValue] [decimal](18, 2) NULL,
    [FaceValue] [decimal](18, 0) NULL,
    [IntercoRate] [decimal](18, 0) NULL,
    [SAPCostCentre] [varchar](10) COLLATE Latin1_General_CI_AS NULL,
    [SAPIONumber] [varchar](25) COLLATE Latin1_General_CI_AS NULL,
    [IsGift] [bit] NOT NULL,
    [PrintCount] [int] NOT NULL,
    [TaxInvoiceID] [decimal](18, 0) NULL,
    [IdentificationNumber] [varchar](50) COLLATE Latin1_General_CI_AS NULL,
    [IdentificationType] [varchar](5) COLLATE Latin1_General_CI_AS NULL,
    [CRMEntitlementMasterID] [nvarchar](20) COLLATE Latin1_General_CI_AS NULL,
    [DeductPointType] [smallint] NULL,
    [DeductCreditType] [smallint] NULL,
    [AwardPointType] [smallint] NULL,
    [AwardCreditType] [smallint] NULL,
    [AwardCreditValue] [decimal](18, 2) NULL,
    [deductPointvalue] [decimal](18, 2) NULL,
    [deductCreditvalue] [decimal](18, 2) NULL,
    [AwardPointvalue] [decimal](18, 2) NULL,
 CONSTRAINT [PK_IssuedVoucher2] PRIMARY KEY CLUSTERED
(
    [SerialNo] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = ON, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = OFF, FILLFACTOR = 80) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  Index [_dta_index_IssuedVoucher_18_1736445310__K1]    Script Date: 04/12/2017 3:39:19 PM ******/
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[IssuedVoucher]') AND name = N'_dta_index_IssuedVoucher_18_1736445310__K1')
CREATE NONCLUSTERED INDEX [_dta_index_IssuedVoucher_18_1736445310__K1] ON [dbo].[IssuedVoucher]
(
    [BatchNo] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = ON, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = OFF, FILLFACTOR = 80) ON [PRIMARY]
GO

SET ANSI_PADDING ON
GO

/****** Object:  Index [_dta_index_IssuedVoucher_18_1736445310__K2_K10_7_25_55]    Script Date: 04/12/2017 3:39:19 PM ******/
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[IssuedVoucher]') AND name = N'_dta_index_IssuedVoucher_18_1736445310__K2_K10_7_25_55')
CREATE NONCLUSTERED INDEX [_dta_index_IssuedVoucher_18_1736445310__K2_K10_7_25_55] ON [dbo].[IssuedVoucher]
(
    [SerialNo] ASC,
    [EventCode] ASC
)
INCLUDE (   [CardId],
    [CancelReason],
    [IdentificationNumber]) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = ON, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = OFF, FILLFACTOR = 80) ON [PRIMARY]
GO

SET ANSI_PADDING ON
GO

/****** Object:  Index [idx_CardID]    Script Date: 04/12/2017 3:39:19 PM ******/
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[IssuedVoucher]') AND name = N'idx_CardID')
CREATE NONCLUSTERED INDEX [idx_CardID] ON [dbo].[IssuedVoucher]
(
    [BatchNo] ASC,
    [CardId] ASC,
    [Status] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = ON, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = OFF, FILLFACTOR = 80) ON [PRIMARY]
GO

SET ANSI_PADDING ON
GO

/****** Object:  Index [IX_IssuedVoucher_1]    Script Date: 04/12/2017 3:39:19 PM ******/
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[IssuedVoucher]') AND name = N'IX_IssuedVoucher_1')
CREATE NONCLUSTERED INDEX [IX_IssuedVoucher_1] ON [dbo].[IssuedVoucher]
(
    [CardId] ASC,
    [CardType] ASC,
    [EventCode] ASC,
    [PromotionBenefitCode] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = ON, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = OFF, FILLFACTOR = 80) ON [PRIMARY]
GO

SET ANSI_PADDING ON
GO

/****** Object:  Index [RecordVoucher]    Script Date: 04/12/2017 3:39:19 PM ******/
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[IssuedVoucher]') AND name = N'RecordVoucher')
CREATE NONCLUSTERED INDEX [RecordVoucher] ON [dbo].[IssuedVoucher]
(
    [EVoucherSerialNo] ASC,
    [Barcode] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = OFF) ON [PRIMARY]
GO


答:
This is not an array. This is a JS object. Here is how you can iterate the properties of an object

```<code>for (var day in jpHolidays) {

  if (jpHoldays.hasOwnProperty(day) && day === searchDate) {
     console.log(jpHolidays[day]);
  }

}
</code>```

It explains as - the for iterator takes you through all the properties of jpHolidays. You try to compare each property with your search string. The hasOwnProperty is to only consider the properties of the object - not the properties which it inherits prototypically.

Also, you can access the jpHolidays like jpHolidays[searchDate] as a direct approach.

This is a JS array a = [1, 2, 3];

This is an object a = {one: 1, two: 2, three: 3};

JS doesn't have associative arrays.

Title: How to find specific date from js array?

Body:
This is not an array. This is a JS object. Here is how you can iterate the properties of an object

for (var day in jpHolidays) {

  if (jpHoldays.hasOwnProperty(day) && day === searchDate) {
     console.log(jpHolidays[day]);
  }

}

It explains as - the for iterator takes you through all the properties of jpHolidays. You try to compare each property with your search string. The hasOwnProperty is to only consider the properties of the object - not the properties which it inherits prototypically.

Also, you can access the jpHolidays like jpHolidays[searchDate] as a direct approach.

This is a JS array a = [1, 2, 3];

This is an object a = {one: 1, two: 2, three: 3};

JS doesn't have associative arrays.


问:
Custom domains in multi tenant SaaS app hosted on Azure App Service
I have a web app hosted on Azure App Service under my domain app.example.com. Customers access their own content using the following paths:

```<code>app.example.com/customer1
app.example.com/customer2
etc..
</code>```

I have created a CNAME record for app.example.com -> myazureapp.azurewebsites.net. And that part works fine.

But I would also like to allow customers to use their own domains by telling them to set up a CNAME record with their DNS provider like:

```<code>app.customer1domain.net -> app.example.com
</code>```

I'm trying to figure out how to configure Azure to allow this kind of CNAME pointing. Will I have to configure each customer domain in Azure as a valid host header? If so, can this be automated?

In IIS I was able to pull this off by setting up a wildcard binding with just a simple *. How can I do this in Azure?

This document mentions what I'm trying to acheive, but not how (Under "Option 4 — Enabling Tenants to Use Custom Domains"):  https://msdn.microsoft.com/en-us/library/hh534477.aspx?f=255&MSPPError=-2147217396

答:
You can just add multiple hostname in Azure portal for your App.

Go to Azure portal > Your web app > custom domains > Add hostname

Just add multiple Hostname to your Web app. It works for all domain after adding them. The result looks like this:

Body:
I have a web app hosted on Azure App Service under my domain app.example.com. Customers access their own content using the following paths:

app.example.com/customer1
app.example.com/customer2
etc..

I have created a CNAME record for app.example.com -> myazureapp.azurewebsites.net. And that part works fine.

But I would also like to allow customers to use their own domains by telling them to set up a CNAME record with their DNS provider like:

app.customer1domain.net -> app.example.com

I'm trying to figure out how to configure Azure to allow this kind of CNAME pointing. Will I have to configure each customer domain in Azure as a valid host header? If so, can this be automated?

In IIS I was able to pull this off by setting up a wildcard binding with just a simple *. How can I do this in Azure?

This document mentions what I'm trying to acheive, but not how (Under "Option 4 — Enabling Tenants to Use Custom Domains"):  https://msdn.microsoft.com/en-us/library/hh534477.aspx?f=255&MSPPError=-2147217396


问:
Android shared Prefrence problem
HI all,

i want to ask can i save an array in shared prefrence(Default Shared Prefrence)...
if yes then pls help me to save the array in shared prefrence..
Any code would b great if available.

thanks in advance.

答:
All the primitive data types like booleans, floats, ints, longs, and strings are supported. </p>

<p>You can store all the values of the array in Key value format using a loop and later if you want to retrieve make use of HashMap.  </p>

Title: Android shared Prefrence problem

Body:
All the primitive data types like booleans, floats, ints, longs, and strings are supported.

You can store all the values of the array in Key value format using a loop and later if you want to retrieve make use of HashMap.


问:
Coloring the largest weakly connected component in a network
I am basically trying to color the largest weakly connected component. nw:weak-component-clusters is returning a list of all components present in the network. I want to color only the largest one. My code is coloring all of the components.</p>

```<code> let clusters nw:weak-component-clusters
 print length(clusters)
 show clusters
 show sort (clusters)
 foreach clusters [
   set color pink
 ]
</code>```

答:
You can use sort-by to sort your list of clusters by descending size and then ask the first one of these to change its color:

```<code>extensions [nw]

to setup
  clear-all
  create-turtles 100 [
    set color blue
    create-links-with n-of random 3 other turtles
  ]
  repeat 30 [ layout-spring turtles links 0.2 5 1 ]
  let clusters nw:weak-component-clusters
  ; sort by descending size of cluster:
  let sorted-clusters sort-by [ [c1 c2] -> count c1 > count c2 ] clusters
  ask first sorted-clusters [ set color pink ]
end
</code>```

Body:
I am basically trying to color the largest weakly connected component. nw:weak-component-clusters is returning a list of all components present in the network. I want to color only the largest one. My code is coloring all of the components.

 let clusters nw:weak-component-clusters
 print length(clusters)
 show clusters
 show sort (clusters)
 foreach clusters [
   set color pink
 ]

Body:
You can use sort-by to sort your list of clusters by descending size and then ask the first one of these to change its color:

extensions [nw]

to setup
  clear-all
  create-turtles 100 [
    set color blue
    create-links-with n-of random 3 other turtles
  ]
  repeat 30 [ layout-spring turtles links 0.2 5 1 ]
  let clusters nw:weak-component-clusters
  ; sort by descending size of cluster:
  let sorted-clusters sort-by [ [c1 c2] -> count c1 > count c2 ] clusters
  ask first sorted-clusters [ set color pink ]
end


问:
iOS Enterprise App: Distribute Over the air : Untrusted Enterprise Developer
I have uploaded my .ipa and manifest.plist to my server (say : https: // www.xxxxxxx . xom/app/). And I created a install page in that server.

In that install html page I have the  hyper link to download my app

```<code><a href="itms-services://?action=download-manifest&url=http s: // xxxxxxx.com/ios/manifest.plist">
Download My  iOS App
</a>
</code>```

If I try to install the app through this install page, the app get downloaded and installed. When I tap the app, it shows "untrusted Enterprise developer". And also I cant able to see "Profile and device management" in the setting app

Kindly help me how can i get rid of this "Untrusted Enterprise Developer"

Note:
I have already installed different certificate in my phone. Thats why It is not showing for my phone. But it is working in other iPhones

答: In general settings of your iphone you could see Device management. Move into the section and trust your enterprise developer account.</p>

Body:
I have uploaded my .ipa and manifest.plist to my server (say : https: // www.xxxxxxx . xom/app/). And I created a install page in that server.

In that install html page I have the  hyper link to download my app

Download My  iOS App

If I try to install the app through this install page, the app get downloaded and installed. When I tap the app, it shows "untrusted Enterprise developer". And also I cant able to see "Profile and device management" in the setting app

Kindly help me how can i get rid of this "Untrusted Enterprise Developer"

Note:
I have already installed different certificate in my phone. Thats why It is not showing for my phone. But it is working in other iPhones


问:
Trying to Display multiple image while uloading
I am trying to display multiple images while uploading on the screen but not getting idea how to do that.
Below is my code through which i can upload multiple image and can display one image but  i want to display multiple image at the same time on screen while clicking "btnUpload" button.
 .aspx

```<code><%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default4.aspx.cs" Inherits="Default4" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <asp:FileUpload ID="FileUpload1" runat="server" AllowMultiple="true" />
<asp:Button ID="btnUpload" Text="Upload" runat="server" OnClick ="UploadMultipleFiles" accept ="image/gif, image/jpeg" />
<hr />
<asp:Image ID="Image1" Visible = "false" runat="server" Height = "100" Width = "100" />
<asp:Label ID="lblSuccess" runat="server" ForeColor ="Green" />
    </div>
    </form>
</body>
</html>
</code>```

C# code

```<code> protected void UploadMultipleFiles(object sender, EventArgs e)
    {
        foreach (HttpPostedFile postedFile in FileUpload1.PostedFiles)
        {
            string fileName = Path.GetFileName(postedFile.FileName);
            postedFile.SaveAs(Server.MapPath("~/Uploads/") + fileName);
        }
        System.IO.Stream fs = FileUpload1.PostedFile.InputStream;
        System.IO.BinaryReader br = new System.IO.BinaryReader(fs);
        Byte[] bytes = br.ReadBytes((Int32)fs.Length);
        string base64String = Convert.ToBase64String(bytes, 0, bytes.Length);
        Image1.ImageUrl = "data:image/png;base64," + base64String;
        Image1.Visible = true;
        lblSuccess.Text = string.Format("{0} files have been uploaded successfully.", FileUpload1.PostedFiles.Count);
    }
</code>```

答:
You could use Repeater to show multiple Image controls

```<code><%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default4.aspx.cs" Inherits="Default4" %>
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <asp:FileUpload ID="FileUpload1" runat="server" AllowMultiple="true" />
            <asp:Button ID="btnUpload" Text="Upload" runat="server" OnClick="UploadMultipleFiles" accept="image/gif, image/jpeg" />
            <hr />
            <asp:Repeater ID="rptImages" ItemType="System.String" Visible="true" runat="server">
                <ItemTemplate>
                    <asp:Image runat="server" Height="100" Width="100" ImageUrl='<%#Item%>' />
                </ItemTemplate>
            </asp:Repeater>
            <asp:Label ID="lblSuccess" runat="server" ForeColor="Green" />
        </div>
    </form>
</body>
</html>
</code>```

The code behind

```<code>    protected void UploadMultipleFiles(object sender, EventArgs e)
    {
        var images = new List<string>();
        foreach (HttpPostedFile postedFile in FileUpload1.PostedFiles)
        {
            string fileName = Path.GetFileName(postedFile.FileName);
            postedFile.SaveAs(Server.MapPath("~/Uploads/") + fileName);

            var imageUrl = "data:image/png;base64," + GetBase64(postedFile.InputStream);
            images.Add(imageUrl);
        }

        rptImages.DataSource = images;
        rptImages.DataBind();
        lblSuccess.Text = string.Format("{0} files have been uploaded successfully.", FileUpload1.PostedFiles.Count);
    }

    private string GetBase64(System.IO.Stream fs)
    {
        System.IO.BinaryReader br = new System.IO.BinaryReader(fs);
        Byte[] bytes = br.ReadBytes((Int32)fs.Length);
        string base64String = Convert.ToBase64String(bytes, 0, bytes.Length);
        return base64String;
    }
</code>```

Body:
I am trying to display multiple images while uploading on the screen but not getting idea how to do that.
Below is my code through which i can upload multiple image and can display one image but  i want to display multiple image at the same time on screen while clicking "btnUpload" button.
 .aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default4.aspx.cs" Inherits="Default4" %>

<!DOCTYPE html>

    <title></title>

    <form id="form1" runat="server">

    <asp:FileUpload ID="FileUpload1" runat="server" AllowMultiple="true" />
<asp:Button ID="btnUpload" Text="Upload" runat="server" OnClick ="UploadMultipleFiles" accept ="image/gif, image/jpeg" />

<asp:Image ID="Image1" Visible = "false" runat="server" Height = "100" Width = "100" />
<asp:Label ID="lblSuccess" runat="server" ForeColor ="Green" />

    </form>

C# code

 protected void UploadMultipleFiles(object sender, EventArgs e)
    {
        foreach (HttpPostedFile postedFile in FileUpload1.PostedFiles)
        {
            string fileName = Path.GetFileName(postedFile.FileName);
            postedFile.SaveAs(Server.MapPath("~/Uploads/") + fileName);
        }
        System.IO.Stream fs = FileUpload1.PostedFile.InputStream;
        System.IO.BinaryReader br = new System.IO.BinaryReader(fs);
        Byte[] bytes = br.ReadBytes((Int32)fs.Length);
        string base64String = Convert.ToBase64String(bytes, 0, bytes.Length);
        Image1.ImageUrl = "data:image/png;base64," + base64String;
        Image1.Visible = true;
        lblSuccess.Text = string.Format("{0} files have been uploaded successfully.", FileUpload1.PostedFiles.Count);
    }

Body:
You could use Repeater to show multiple Image controls

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default4.aspx.cs" Inherits="Default4" %>
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <asp:FileUpload ID="FileUpload1" runat="server" AllowMultiple="true" />
            <asp:Button ID="btnUpload" Text="Upload" runat="server" OnClick="UploadMultipleFiles" accept="image/gif, image/jpeg" />
            <hr />
            <asp:Repeater ID="rptImages" ItemType="System.String" Visible="true" runat="server">
                <ItemTemplate>
                    <asp:Image runat="server" Height="100" Width="100" ImageUrl='<%#Item%>' />
                </ItemTemplate>
            </asp:Repeater>
            <asp:Label ID="lblSuccess" runat="server" ForeColor="Green" />
        </div>
    </form>
</body>
</html>

The code behind

    protected void UploadMultipleFiles(object sender, EventArgs e)
    {
        var images = new List<string>();
        foreach (HttpPostedFile postedFile in FileUpload1.PostedFiles)
        {
            string fileName = Path.GetFileName(postedFile.FileName);
            postedFile.SaveAs(Server.MapPath("~/Uploads/") + fileName);

            var imageUrl = "data:image/png;base64," + GetBase64(postedFile.InputStream);
            images.Add(imageUrl);
        }

        rptImages.DataSource = images;
        rptImages.DataBind();
        lblSuccess.Text = string.Format("{0} files have been uploaded successfully.", FileUpload1.PostedFiles.Count);
    }

    private string GetBase64(System.IO.Stream fs)
    {
        System.IO.BinaryReader br = new System.IO.BinaryReader(fs);
        Byte[] bytes = br.ReadBytes((Int32)fs.Length);
        string base64String = Convert.ToBase64String(bytes, 0, bytes.Length);
        return base64String;
    }


问:
Is it possible to preserve plus signs in PHP $_GET vars without encoding?
Say I request this URL:

http://mydomain.com/script.php?var=2+2

$_GET['var'] will now be: "2 2" where it should be "2+2"

Obviously I could encode the data before sending and then decode it, but I'm wondering if this is the only solution. I could also replace spaces with plus symbols, but I want to allow spaces as well. I simply want whatever characters were passed, without any url decoding or encoding going on. Thank you!

答: I just used urlencode() to - well - encode the URL and urldecode($_Get()) to make the string usable again.


问:
Azure ARM Template is caching the Custom script file
We are working on an Azure ARM Template which is creating an VM and running a Bashscript on startup using Custom script extension. It was working well for sometime but then suddenly it started caching the SH file. I added few commands which ended in some error, so I removed them but still I am getting same error.I tried deleting SH file from URI but still the error persisted.

Command which I added to my custom script was for creating a directory(mkdir) only.

Has anyone seen anything like this on Azure ??

答:
Yes, its not the template that's caching it, its the extensión that does that. You need to either delete the extensión from the VM before retrying or use the ForceUpdateTag` in the template.

Docs here.

ForceUpdateTag:

Specifies that the extension should be run again with the same public or protected settings. The value can be any string different from the current value. If forceUpdateTag is not changed, updates to public or protected settings would still be applied by the handler.

ps. Azure Powershell DSC extensión has the same behavior.


问:
Show background on text on Edittext separated by , or space tapping on it removes it from edittext view
I want something like this in Edittext . When I select some contact it shows up in Edittext with that light background and automatically separated .

This is what I made . I am trying to achieve something like above .

答:
This has generally been referred to as a "chips" UI. It is not built into the Android SDK, but there are third-party libraries that support it, such as:

ChipsLibrary

MaterialChipView

MaterialChipsInput


问:
PHP Security - Sanitize & Clean
I have a built a script around class.upload from http://www.verot.net/php_class_upload.htm

Basically what it is that all my images are stored on the server in a directory called /images/

The script I built basically takes some parameters from my website such as /xyzDir/tomnjerry.jpg?w=100&h=100&fill=1&color=fff

Then I have mod_rewrite which reads the file from /xyzDir/ into a php script which then translates the width and height and returns the image.

Lately I have noticed some idiots from Turkey trying to input weird characters into the parameters w= and h=

On my script I do check to make sure only integer is allowed in width and heigh and fill can be either 1 or 2 and color can only be certain values which i check via array.

I just want to see if there is anything else I should be doing in order to avoid getting hacked.

Thanks

答:
You should use intval() for ensuring that the width and height are integers

```<code>$width = intval($_GET['w']);
$height = intval($_GET['h']);
</code>```

You can do

```<code>$fill = $fill == 1 ? 1 : 2;
</code>```

Which is a ternary operator, so if it's anything apart from 1 it's going to be set to 2.

As for validation of hex, the rules of hex dictate that it must be in range of 0-9/A-F.

```<code>$color = preg_replace('/[^0-9a-f]/i', "", $_GET['color']);
</code>```

Hope that helps.
(It should be noted that my suggested code will perform the manipulation required to make it suitable for your page, rather than confirming that is is valid before hand)

Title: PHP Security - Sanitize & Clean

Body:
You should use intval() for ensuring that the width and height are integers

$width = intval($_GET['w']);
$height = intval($_GET['h']);

You can do

$fill = $fill == 1 ? 1 : 2;

Which is a ternary operator, so if it's anything apart from 1 it's going to be set to 2.

As for validation of hex, the rules of hex dictate that it must be in range of 0-9/A-F.

$color = preg_replace('/[^0-9a-f]/i', "", $_GET['color']);

Hope that helps.
(It should be noted that my suggested code will perform the manipulation required to make it suitable for your page, rather than confirming that is is valid before hand)


答:
jpHolidays is not an Array but an Object. You can access a particular value in that object by providing a key:

```<code>var result = jpHolidays[searchDate]
</code>```

If you want to check wether a specific key exists at all in the object use the 'in' operator:

```<code>if (searchDate in jpHolidays) { // ...
</code>```

Body:
jpHolidays is not an Array but an Object. You can access a particular value in that object by providing a key:

var result = jpHolidays[searchDate]

If you want to check wether a specific key exists at all in the object use the 'in' operator:

if (searchDate in jpHolidays) { // ...


问:
Javascriptexecutor is not working while running through safari webdriver
I want to perform a click using javascriptexecutor.

```<code>JavasciptExecutor jse=(JavascriptExecutor) webDriver;
jse.executescript("arguments[0].click();",webelement)
</code>```

While running from safari,it is showing "undefined is not a function<evaluating arguments[0].click "
Same works fine in chrome driver.

Am I need to add any capabilities while initiating webDriver?
I have already added capabilities.SetJavascriptEnabled(true). Still it is not working

答:
You have to set the capabilities of driver browserwise.

When running the testcases in safari browser set a global flag for browser. You can create a config file and add "safari" or "chrome" when running it through safari or chrome.

In your source initialize your driver for safari like below :

```<code> if (browser.equals("safari")) {
        SafariOptions safariOptions = new SafariOptions();
        safariOptions.setUseCleanSession(true);
        safariOptions.setUseTechnologyPreview(true);
        driver = new SafariDriver(safariOptions);

    }
</code>```

Then navigate to your desired url. Here i am adding a sample source for your understanding.

```<code> driver.get("https://www.google.com");

 WebElement elem = driver.findElement(By.className("gb_P"));
 jse = (JavascriptExecutor)driver;
 jse.executeScript("arguments[0].click();", elem);
</code>```

Hope this will solve your issue. Feel free to comment here for more information.

Body:
I want to perform a click using javascriptexecutor.

JavasciptExecutor jse=(JavascriptExecutor) webDriver;
jse.executescript("arguments[0].click();",webelement)

While running from safari,it is showing "undefined is not a function<evaluating arguments[0].click "
Same works fine in chrome driver.

Am I need to add any capabilities while initiating webDriver?
I have already added capabilities.SetJavascriptEnabled(true). Still it is not working

Body:
You have to set the capabilities of driver browserwise.

When running the testcases in safari browser set a global flag for browser. You can create a config file and add "safari" or "chrome" when running it through safari or chrome.

In your source initialize your driver for safari like below :

 if (browser.equals("safari")) {
        SafariOptions safariOptions = new SafariOptions();
        safariOptions.setUseCleanSession(true);
        safariOptions.setUseTechnologyPreview(true);
        driver = new SafariDriver(safariOptions);

    }

Then navigate to your desired url. Here i am adding a sample source for your understanding.

 driver.get("https://www.google.com");

 WebElement elem = driver.findElement(By.className("gb_P"));
 jse = (JavascriptExecutor)driver;
 jse.executeScript("arguments[0].click();", elem);

Hope this will solve your issue. Feel free to comment here for more information.


问:
Cannot send multiple form data to routes in Node.js using req.body
I am trying to modify data in a database based off an administrator making changes to a table in a form. My problem is for the save button below I need to send five pieces of information to update:
1. word
2. replacement
3. replacementMethod
4. active
5. id

I can do this easily if it were just one piece of data as the req.body object is allowed one key-value pair (name and value). In fact, I did this with the delete button and it works fine by sending the primary key and then deleting the row.

For the save button I thought the solution would be to just pass in the "this" object. However accessing any properties even in the router.post function shows up as undefined or I get { data: '[object Object]' } where I can't seem to access the object data. I have tried many many different ways and console.log printouts and searched the internet to no avail. Can someone show me the right way to do this? I've spent half a day on this and not gotten anywhere. Thank you.

```<code><table>
<tr>
    <th>Banned Word</th>
    <th>Replacement</th>
    <th>Replacement Method</th>
    <th>Active</th>
    <th>Remove Word</th>
    <th>Save Changes</th>
</tr>
{{#each bannedwords}}
<tr>
    <td contenteditable='true'>{{this.word}}</td>
    <td contenteditable='true'>{{this.replacement}}</td>

    {{#ifCond this.replacementMethod 0}}
        <td class='select'>
            <select>
                <option value="0" selected>Replacement</option>
                <option value="1">Stars</option>
                <option value="2">Grawlix</option>
            </select>
        </td>
    {{/ifCond}}

    {{#ifCond this.replacementMethod 1}}
        <td class='select'>
            <select>
                <option value="0">Replacement</option>
                <option value="1" selected>Stars</option>
                <option value="2">Grawlix</option>
            </select>
        </td>
    {{/ifCond}}

    {{#ifCond this.replacementMethod 2}}

    <td align='center' class='select'>
            <select>
                <option value="0">Replacement</option>
                <option value="1">Stars</option>
                <option value="2" selected>Grawlix</option>
            </select>
    </td>
    {{/ifCond}}

    {{#if this.active includeZero=false}}
        <td><input type="checkbox" onclick="return true;" checked/></td>
    {{else}}
        <td><input type="checkbox" onclick="return true;" /></td>
    {{/if}}
    <td><button formmethod="POST" formaction="/deleteWord" type="Delete" name="word" value="{{this.word}}"  class="btn btn-primary">Delete</button></td>
    <td><button formmethod="POST" formaction="/modifyWord" type="Save" name="data" value="{{this}}" class="btn btn-primary">Save</button></td>
</tr>
   {{/each}}
</table>
</code>```

In my routes index.js I have:

```<code>router.post('/modifyWord',isAdminMiddleware(), function(req, res, next){
modifyBannedWord(req);
res.redirect('/admin');
});
</code>```

And finally:

```<code>function modifyBannedWord(req){
const db = require('../db.js');
var temp = req.body;
db.query('UPDATE from badwords set word = ?,  replacement = ?, replacementMethod = ?, active = ?  , WHERE id = ?' , [temp.data.word , temp.data.replacement, temp.data.replacementMethod, temp.data.active, temp.data.id], function(err, results){
});
}
</code>```

As an aside, the modifyBannedWord function may not be correct (i.e var temp = req.body) . I've changed it so many times I can't remember which way it's suppose to be but nonetheless I'm stuck.

答:
You'll have to name the select tags like this

```<code><select name="somename"></select>
</code>```

And in your route

```<code>var somevar = req.body.somename;
</code>```

Body:
I am trying to modify data in a database based off an administrator making changes to a table in a form. My problem is for the save button below I need to send five pieces of information to update:
1. word
2. replacement
3. replacementMethod
4. active
5. id

I can do this easily if it were just one piece of data as the req.body object is allowed one key-value pair (name and value). In fact, I did this with the delete button and it works fine by sending the primary key and then deleting the row.

For the save button I thought the solution would be to just pass in the "this" object. However accessing any properties even in the router.post function shows up as undefined or I get { data: '[object Object]' } where I can't seem to access the object data. I have tried many many different ways and console.log printouts and searched the internet to no avail. Can someone show me the right way to do this? I've spent half a day on this and not gotten anywhere. Thank you.

    Banned Word
    Replacement
    Replacement Method
    Active
    Remove Word
    Save Changes

{{#each bannedwords}}

    {{this.word}}
    {{this.replacement}}

    {{#ifCond this.replacementMethod 0}}

            <select>
                <option value="0" selected>Replacement</option>
                <option value="1">Stars</option>
                <option value="2">Grawlix</option>
            </select>

    {{/ifCond}}

    {{#ifCond this.replacementMethod 1}}

            <select>
                <option value="0">Replacement</option>
                <option value="1" selected>Stars</option>
                <option value="2">Grawlix</option>
            </select>

    {{/ifCond}}

    {{#ifCond this.replacementMethod 2}}

            <select>
                <option value="0">Replacement</option>
                <option value="1">Stars</option>
                <option value="2" selected>Grawlix</option>
            </select>

    {{/ifCond}}

    {{#if this.active includeZero=false}}
        <input type="checkbox" onclick="return true;" checked/>
    {{else}}
        <input type="checkbox" onclick="return true;" />
    {{/if}}
    <button formmethod="POST" formaction="/deleteWord" type="Delete" name="word" value="{{this.word}}"  class="btn btn-primary">Delete</button>
    <button formmethod="POST" formaction="/modifyWord" type="Save" name="data" value="{{this}}" class="btn btn-primary">Save</button>

   {{/each}}

In my routes index.js I have:

router.post('/modifyWord',isAdminMiddleware(), function(req, res, next){
modifyBannedWord(req);
res.redirect('/admin');
});

And finally:

function modifyBannedWord(req){
const db = require('../db.js');
var temp = req.body;
db.query('UPDATE from badwords set word = ?,  replacement = ?, replacementMethod = ?, active = ?  , WHERE id = ?' , [temp.data.word , temp.data.replacement, temp.data.replacementMethod, temp.data.active, temp.data.id], function(err, results){
});
}

As an aside, the modifyBannedWord function may not be correct (i.e var temp = req.body) . I've changed it so many times I can't remember which way it's suppose to be but nonetheless I'm stuck.

Body:
You'll have to name the select tags like this

<select name="somename"></select>

And in your route

var somevar = req.body.somename;


问:
automatically populate table with dummy data in mysql
I have a MySQL table which I want to populate with some dummy data for testing (50+).

This table has a foreign key to another table so the dummy data must cross reference from that table but again be random i.e. can't all be the same foreign key.

It also has a date added field which I want to populate with a random date within a year span e.g. any date in the year 2010.

my table structure is:

```<code>id, customer_id, date_added, title, total_cost
</code>```

where id is the primary key, customer_id is the foreign key and date_added is the date field.

What is the best way of doing this?  I'd prefer to do it directly in MySQL but if not my site is running on Python so a way of doing this in that would do.

答:
For testing business rules, I actually prefer carefully thought out data over random data. Either from excel->csv->db or manually created insert statements.

One row for each boundary condition, say:

Customer without orders

One Customer with zero total cost

One customer with foreign characters in the name (because I always forget to deal with it)

One customer with max length name

One Customer with shit loads of orders (to make sure that the GUI still looks nice)

It makes it really easy to run regression tests because you "know" what the data should look like.

For performance testing, you can do pretty good with random data as long as the data distribution is realistic (which affects the usefulness of indexes). If you have very advanced requirements, your best bet is to use some software built for this purpose.

But often you can generate all the data you need from one single table of integers and clever use of built-in functions:

rand() -> Generate random number.

mod()  -> Used to create repeating sequences (1,2,3,1,2,3)

lpad() and rpad() -> For padding strings to specified lengths

Body:
I have a MySQL table which I want to populate with some dummy data for testing (50+).

This table has a foreign key to another table so the dummy data must cross reference from that table but again be random i.e. can't all be the same foreign key.

It also has a date added field which I want to populate with a random date within a year span e.g. any date in the year 2010.

my table structure is:

id, customer_id, date_added, title, total_cost

where id is the primary key, customer_id is the foreign key and date_added is the date field.

What is the best way of doing this?  I'd prefer to do it directly in MySQL but if not my site is running on Python so a way of doing this in that would do.


问:
netbeans mysql syntax Error at line 1 and no error in mysql query browser
Hi I have a netbeans problem, I am Updating my database with a couple queries, only one runs the second query is giving a syntax problem when the query runs perfectly in mysql query browser. here is the code in netbeans:

```<code>try{

    String Query = "select nr,linkid,transdate,amount,type from astpay"
                + "where type = 'all' or 'cash';";
        Statement ps = test.createStatement();
        ResultSet rs = ps.executeQuery(Query);
        //if there are payments that fit the criteria
        if(rs.next()){
        //while loop to generatepremuim for the cash payments
            while(rs.next()){
                System.out.println("Now to generate the premuim for the cash payments...");
                Query = "insert into astpay" +
                   "(linkid,branchno,transdate,amount,refno,month,year,type)" +
                   "select a.linkid,a.branchno, a.transdate, a.amount, a.refno, a.month,a.year, p.paytype" +
                   "from astpay a, astpaytype p" +
                   "where(a.type ='all' or a.type ='cash' or a.type ='debit')" +
                   "and p.paytype = 'prem';";
               ps = test.createStatement();
               ps.execute(Query);

        }
        }else{
            System.out.println("There was a an error generating the Premuims for Cash payments....");

        }
   }catch(SQLException exp){
    System.err.println("Failed to execute the statement!");
    System.err.println(exp.getMessage());

   }
</code>```

}

here is the mysql code for the same string which runs in mysql query browser:

```<code>`insert into astpay (linkid,branchno,transdate,amount,refno,month,year,type) select a.linkid,a.branchno, a.transdate, a.amount, a.refno, a.month,a.year, p.paytype from astpay a, astpaytype p where (a.type = 'all' or a.type ='cash' or a.type = 'debit') and p.paytype = 'prem';`
</code>```

here is the error returned in netbeans:

```<code>Failed to execute the statement!You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '= 'all' or 'cash'' at line 1
</code>```

here

I have tried a lot of things to get it to work and I do not know where I went wrong. I am hoping someone else may be able to help, which will be greatly appreciated.

答:
Use ps.executeUpdate instead of ps.execute. And add a join beetween tables astpay and astpaytype (or use explicit cross join if you it is that you want)

Your error :

change

```<code>where type = 'all' or 'cash'
</code>```

to

```<code>where type = 'all' or type = 'cash'
</code>```

or

```<code>where type in ('all' ,'cash')
</code>```

Your second error : add space before where :

```<code> Query = "insert into astpay" +
                   "(linkid,branchno,transdate,amount,refno,month,year,type)" +
                   "select a.linkid,a.branchno, a.transdate, a.amount, a.refno, a.month,a.year, p.paytype" +
                   "from astpay a, astpaytype p" +
                   " where(a.type ='all' or a.type ='cash' or a.type ='debit')" +
                   " and p.paytype = 'prem';";
</code>```

your code produce "...from astpay a, astpaytype pwhere(a.type ='all' or ..."

Body:
Hi I have a netbeans problem, I am Updating my database with a couple queries, only one runs the second query is giving a syntax problem when the query runs perfectly in mysql query browser. here is the code in netbeans:

try{

    String Query = "select nr,linkid,transdate,amount,type from astpay"
                + "where type = 'all' or 'cash';";
        Statement ps = test.createStatement();
        ResultSet rs = ps.executeQuery(Query);
        //if there are payments that fit the criteria
        if(rs.next()){
        //while loop to generatepremuim for the cash payments
            while(rs.next()){
                System.out.println("Now to generate the premuim for the cash payments...");
                Query = "insert into astpay" +
                   "(linkid,branchno,transdate,amount,refno,month,year,type)" +
                   "select a.linkid,a.branchno, a.transdate, a.amount, a.refno, a.month,a.year, p.paytype" +
                   "from astpay a, astpaytype p" +
                   "where(a.type ='all' or a.type ='cash' or a.type ='debit')" +
                   "and p.paytype = 'prem';";
               ps = test.createStatement();
               ps.execute(Query);

        }
        }else{
            System.out.println("There was a an error generating the Premuims for Cash payments....");

        }
   }catch(SQLException exp){
    System.err.println("Failed to execute the statement!");
    System.err.println(exp.getMessage());

   }

}

here is the mysql code for the same string which runs in mysql query browser:

`insert into astpay (linkid,branchno,transdate,amount,refno,month,year,type) select a.linkid,a.branchno, a.transdate, a.amount, a.refno, a.month,a.year, p.paytype from astpay a, astpaytype p where (a.type = 'all' or a.type ='cash' or a.type = 'debit') and p.paytype = 'prem';`

here is the error returned in netbeans:

Failed to execute the statement!You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '= 'all' or 'cash'' at line 1

here

I have tried a lot of things to get it to work and I do not know where I went wrong. I am hoping someone else may be able to help, which will be greatly appreciated.

Body:
Use ps.executeUpdate instead of ps.execute. And add a join beetween tables astpay and astpaytype (or use explicit cross join if you it is that you want)

Your error :

change

where type = 'all' or 'cash'

to

where type = 'all' or type = 'cash'

or

where type in ('all' ,'cash')

Your second error : add space before where :

 Query = "insert into astpay" +
                   "(linkid,branchno,transdate,amount,refno,month,year,type)" +
                   "select a.linkid,a.branchno, a.transdate, a.amount, a.refno, a.month,a.year, p.paytype" +
                   "from astpay a, astpaytype p" +
                   " where(a.type ='all' or a.type ='cash' or a.type ='debit')" +
                   " and p.paytype = 'prem';";

your code produce "...from astpay a, astpaytype pwhere(a.type ='all' or ..."


答:
You can simply access the object (not array) directly:

var jpHolidays = {
     '01-01-2017' : 'お正月
 New Year\'s Day',
     '01-02-2017' : 'お正月
 New Year\'s Day observed',
     '01-09-2017' : '成人の日
 Coming of Age Day',
     '02-11-2017' : '建国記念日
 National Foundation Day',
     '03-20-2017' : '春分の日
 Vernal Equinox Day',
     '04-29-2017' : '昭和の日
 Shōwa Day',
     '05-03-2017' : '憲法記念日
 Constitution Memorial Day',
     '05-04-2017' : 'みどりの日
 Greenery Day',
     '05-05-2017' : 'こどもの日
 Children\'s Day',
     '07-17-2017' : '海の日
 Marine Day / Ocean Day',
     '08-11-2017' : '山の日
 Mountain Day',
     '09-18-2017' : '敬老の日
 Respect for the Aged Day',
     '09-23-2017' : '秋分の日
 Autumnal Equinox Day',
     '10-09-2017' : '体育の日
 Health and Sports Day ',
     '11-03-2017' : '文化の日
 Culture Day',
     '11-23-2017' : '勤労感謝の日
 Labour Thanksgiving Day ',
     '12-23-2017' : '天皇誕生日
 The Emperor\'s Birthday',
 };
searchDate = '12-23-2017';
document.write(jpHolidays[searchDate]);```

Body:
I have this array in my data.js file. And I want to find the specific date from other html file to data.js file using javascript.

For example:

Here is the date to search

var searchDate = '12-25-2017';

I want to search that date from data.js file ( Variable name : jpHolidays )and show in html or console.log().

I was googling and i didn't find how to find the specific date. Please help me.

var jpHolidays = {
     '01-01-2017' : 'お正月
 New Year\'s Day',
     '01-02-2017' : 'お正月
 New Year\'s Day observed',
     '01-09-2017' : '成人の日
 Coming of Age Day',
     '02-11-2017' : '建国記念日
 National Foundation Day',
     '03-20-2017' : '春分の日
 Vernal Equinox Day',
     '04-29-2017' : '昭和の日
 Shōwa Day',
     '05-03-2017' : '憲法記念日
 Constitution Memorial Day',
     '05-04-2017' : 'みどりの日
 Greenery Day',
     '05-05-2017' : 'こどもの日
 Children\'s Day',
     '07-17-2017' : '海の日
 Marine Day / Ocean Day',
     '08-11-2017' : '山の日
 Mountain Day',
     '09-18-2017' : '敬老の日
 Respect for the Aged Day',
     '09-23-2017' : '秋分の日
 Autumnal Equinox Day',
     '10-09-2017' : '体育の日
 Health and Sports Day ',
     '11-03-2017' : '文化の日
 Culture Day',
     '11-23-2017' : '勤労感謝の日
 Labour Thanksgiving Day ',
     '12-23-2017' : '天皇誕生日
 The Emperor\'s Birthday',
 };

Body:
You can simply access the object (not array) directly:

var jpHolidays = {
     '01-01-2017' : '<span>お正月 <br> New Year\'s Day</span>',
     '01-02-2017' : '<span>お正月 <br> New Year\'s Day observed</span>',
     '01-09-2017' : '<span>成人の日 <br> Coming of Age Day</span>',
     '02-11-2017' : '<span>建国記念日 <br> National Foundation Day</span>',
     '03-20-2017' : '<span>春分の日 <br> Vernal Equinox Day</span>',
     '04-29-2017' : '<span>昭和の日 <br> Shōwa Day</span>',
     '05-03-2017' : '<span>憲法記念日 <br> Constitution Memorial Day</span>',
     '05-04-2017' : '<span>みどりの日 <br> Greenery Day</span>',
     '05-05-2017' : '<span>こどもの日 <br> Children\'s Day</span>',
     '07-17-2017' : '<span>海の日 <br> Marine Day / Ocean Day</span>',
     '08-11-2017' : '<span>山の日 <br> Mountain Day</span>',
     '09-18-2017' : '<span>敬老の日 <br> Respect for the Aged Day</span>',
     '09-23-2017' : '<span>秋分の日 <br> Autumnal Equinox Day</span>',
     '10-09-2017' : '<span>体育の日 <br> Health and Sports Day </span>',
     '11-03-2017' : '<span>文化の日 <br> Culture Day</span>',
     '11-23-2017' : '<span>勤労感謝の日 <br> Labour Thanksgiving Day </span>',
     '12-23-2017' : '<span>天皇誕生日 <br> The Emperor\'s Birthday</span>',
 };
searchDate = '12-23-2017';
document.write(jpHolidays[searchDate]);