问:
How do I prevent a commit using pre-commit and hg incoming?
Sometimes developers on my team forget to pull in other developer's changesets before committing their own (admittedly, I do this as well). For a week long project there could be dozens of changes in the tree that the new commit skips over. When trying to push, hg aborts with the new remote head message then they pull and merge in all those new commits. What I'm looking for is an easy way to test if there are any new changes before someone commits and if there are to prevent the commit from happening. Ideally, there would be a clear message stating why the commit failed.

This seems like it should be very easy for a hook to accomplish but the pre-commit hook will continue on a status code of 0 and hg incoming will return 1 when there are no changes. All I need to do is invert the status of the hg incoming command but I can't find the syntax to do it. Most of the search results that I've found dive right into writing python hooks but that seems like overkill for such a simple problem.

I'm looking for something like this:

```<code>[hooks]
pre-commit != hg incoming
or
pre-commit = hg incoming == 0
</code>```

I'm not sure where the message would go, either.

答:
On Windows you can use this command to check for incoming changes:

```<code>[hooks]
pre-commit.checkNew = CMD /V /C "hg incoming & IF !ErrorLevel! EQU 0 (Exit 1) Else (Exit 0)"
</code>```

If new changes are found it will cancel the commit and you will need to pull (and possibly merge) the new changes.

Body:
Sometimes developers on my team forget to pull in other developer's changesets before committing their own (admittedly, I do this as well). For a week long project there could be dozens of changes in the tree that the new commit skips over. When trying to push, hg aborts with the new remote head message then they pull and merge in all those new commits. What I'm looking for is an easy way to test if there are any new changes before someone commits and if there are to prevent the commit from happening. Ideally, there would be a clear message stating why the commit failed.

This seems like it should be very easy for a hook to accomplish but the pre-commit hook will continue on a status code of 0 and hg incoming will return 1 when there are no changes. All I need to do is invert the status of the hg incoming command but I can't find the syntax to do it. Most of the search results that I've found dive right into writing python hooks but that seems like overkill for such a simple problem.

I'm looking for something like this:

[hooks]
pre-commit != hg incoming
or
pre-commit = hg incoming == 0

I'm not sure where the message would go, either.

Body:
On Windows you can use this command to check for incoming changes:

[hooks]
pre-commit.checkNew = CMD /V /C "hg incoming & IF !ErrorLevel! EQU 0 (Exit 1) Else (Exit 0)"

If new changes are found it will cancel the commit and you will need to pull (and possibly merge) the new changes.


来源: stackexchange

问:
System.out.print is overlapping the questions why?
My problem is when i run the program it runs all the System.out.print right but when i run
it for the second student some of it overlaps like so:

```<code>"Enter the second student's name: Enter the student's score: "
</code>```

instead of

```<code>"Enter the second students's name: "

"Enter the student's score: "
</code>```

I also can not input data into the System.out.print method of the second student

My main code where the error is:

```<code>System.out.print("Enter the first student's name: ");
name = reader.nextLine();
student1.setName(name);
for (int i = 1; i <= 3; i++){
    System.out.print("Enter the students's score: ");
    score = reader.nextInt();
    student1.setScore(i, score);
}

System.out.print("Enter the second student's name: "); //overlaps(stays on same line)
//also wont let me enter data here
name = reader.nextLine();
student2.setName(name);
for (int i = 1; i <= 3; i++){
    System.out.print("Enter the students's score: "); //program skips to here to input
//data
    score = reader.nextInt();
    student2.setScore(i, score);
}
</code>```

the part that deals with the error from the class is as follows

```<code>public void setName(String nm){
    name = nm;
}
</code>```

答:
Try inserting:

```<code>reader.nextLine();
</code>```

...before

```<code>System.out.print("Enter the second student's name: ");
</code>```

.nextInt() doesn't swallow the newline from your input, so the next call to nextLine() just gets the newline character and returns you an empty string - and the program continues, printing the next line of output.

ContentLicense: CC BY-SA 2.5

Body:
My problem is when i run the program it runs all the System.out.print right but when i run
it for the second student some of it overlaps like so:

"Enter the second student's name: Enter the student's score: "

instead of

"Enter the second students's name: "

"Enter the student's score: "

I also can not input data into the System.out.print method of the second student

My main code where the error is:

System.out.print("Enter the first student's name: ");
name = reader.nextLine();
student1.setName(name);
for (int i = 1; i <= 3; i++){
    System.out.print("Enter the students's score: ");
    score = reader.nextInt();
    student1.setScore(i, score);
}

System.out.print("Enter the second student's name: "); //overlaps(stays on same line)
//also wont let me enter data here
name = reader.nextLine();
student2.setName(name);
for (int i = 1; i <= 3; i++){
    System.out.print("Enter the students's score: "); //program skips to here to input
//data
    score = reader.nextInt();
    student2.setScore(i, score);
}

the part that deals with the error from the class is as follows

public void setName(String nm){
    name = nm;
}

Body:
Try inserting:

reader.nextLine();

...before

System.out.print("Enter the second student's name: ");

.nextInt() doesn't swallow the newline from your input, so the next call to nextLine() just gets the newline character and returns you an empty string - and the program continues, printing the next line of output.


问:
Substitute FROM ISNULL in where clause in ms sql server
We used Stored Procedure on our Queries. Some of our field got NULL value, so for us to get this value we Put the conversion of ISNULL inside the WHERE condition but per checking it affects the Process of our strodproc based on the SQL performance tool.

Ex.

```<code>SELECT * FROM tblInfo
WHERE ISNULL(fldInfo,'') <> ''
</code>```

tblInfo

```<code>fldinfo
NULL
30
NULL
20
</code>```

Query

```<code>SELECT * FROM tblinfo WHERE fldinfo NOT IN (30,20) - different result
SELECT * FROM tblinfo WHERE ISNULL(fldinfo,'') NOT IN (30,20) - Correct
</code>```

Result

Any other Substitute process of script we can use so that we can get the value but not affecting the performance of the query.

答:
COALESCE is one option that you can try. It behaves in the same way. However the differences between performance has to be evaluated by you with some test

Some differences between ISNULL and COALESCE are outlined here:
SQL - Difference between COALESCE and ISNULL?

EDIT: Based on the tests done by multiple people and by theory, ISNULL seems to be a better option over COALESCE

Which is quicker COALESCE OR ISNULL?

ContentLicense: CC BY-SA 3.0

Body:
We used Stored Procedure on our Queries. Some of our field got NULL value, so for us to get this value we Put the conversion of ISNULL inside the WHERE condition but per checking it affects the Process of our strodproc based on the SQL performance tool.

Ex.

SELECT * FROM tblInfo
WHERE ISNULL(fldInfo,'') <> ''

tblInfo

fldinfo
NULL
30
NULL
20

Query

SELECT * FROM tblinfo WHERE fldinfo NOT IN (30,20) - different result
SELECT * FROM tblinfo WHERE ISNULL(fldinfo,'') NOT IN (30,20) - Correct

Result

Any other Substitute process of script we can use so that we can get the value but not affecting the performance of the query.


问:
Is there a way to see the value of a variable as the program is running?
I'd like to see what value a variable is holding AS the program is running.

I remember Scott Hanselman blogging about something like a Variable Viewbox, but I can't seem to find the post.

I'd like to view the variable AS the program is running it's loop. Inside of Visual Studio.

答:
You can specify a tracepoint, which is like a breakpoint but outputs a message instead of stopping the debugger.

http://msdn.microsoft.com/en-us/library/232dxah7.aspx

OwnerDisplayName: delete

LastEditorDisplayName: delete


问:
How to prevent Unicode characters from rendering as emoji in HTML from JavaScript?
I'm finding Unicode for special characters from FileFormat.Info's search.

Some characters are rendering as the classic black-and-white glyphs, such as ⚠ (warning sign, \u26A0 or ⚠). These are preferable, since I can apply CSS styles (such as color) to them.

Others are rendering as newer cartoony emoji, such as ⌛ (hourglass, \u231B or ⌛). These are not preferable, since I cannot fully style them.

It appears that the browser is making this change, since I'm able to see the hourglass glyph on Mac Firefox, just not Mac Chrome nor Mac Safari.

Is there a way to force browsers to display the older (flat monotone) versions to display?

Update: It seems (from comments below) there is a text presentation selector, FE0E, available to enforce text-vs-emoji. The selector is concatenated as a suffix without space onto the character's code, such as ⌛ for HTML hex or \u231B\uFE0E for JS. However, it is simply not honored by all browsers (eg Chrome and Edge).

答: For me on OSX the solution was to set font-family to EmojiSymbols

OwnerDisplayName: anon

ContentLicense: CC BY-SA 4.0


问:
Get 1 result in first column of the table and get all the results in the second column of the table
I have tables like these:

users

```<code>   id   |   firstname   |   lastname   |   date
--------------------------------------------------
   1    |   paul        |   sy         |   date

   2    |   james       |   curry      |   date

   3    |   kevin       |   leonard    |   date
</code>```

docs_list

```<code>   id   |   user_id   |   url   |   title   |   date
-------------------------------------------------------
   1    |      1      |   url   |   title   |   date
   2    |      2      |   url   |   title   |   date
   3    |      1      |   url   |   title   |   date
</code>```

I want to get 1 result of firstname and lastname and all of the results of  url and title based on where the users.id and docs_list.user_id is equal to the id given ORDER BY docs_list.date DESC.

So this is how I query it:

```<code>SELECT users.first, users.last, docs_list.urlcode, docs_list.title

FROM users

INNER JOIN docs_list

ON users.id = docs_list.user_id

WHERE docs_list.user_id = {$value}

ORDER BY docs_list.date DESC
</code>```

Problem is that, I got so many firstname and lastname results (equal to how many rows I have in the docs_list result). I only need 1 firstname and lastname.

So how can I do it?

答:
I assume that you want to do a clean presentation on web page which is without duplicate first names and last names? If that is the case I think you need to separate presentation from data retrieve. (Or you can retrieve your data separately)
From my point of view, you cannot use "group by" because it will cause you to lose other data such as url and other non-duplicate fields.</p>

Body:
I have tables like these:

users

   id   |   firstname   |   lastname   |   date
--------------------------------------------------
   1    |   paul        |   sy         |   date

   2    |   james       |   curry      |   date

   3    |   kevin       |   leonard    |   date

docs_list

   id   |   user_id   |   url   |   title   |   date
-------------------------------------------------------
   1    |      1      |   url   |   title   |   date
   2    |      2      |   url   |   title   |   date
   3    |      1      |   url   |   title   |   date

I want to get 1 result of firstname and lastname and all of the results of  url and title based on where the users.id and docs_list.user_id is equal to the id given ORDER BY docs_list.date DESC.

So this is how I query it:

SELECT users.first, users.last, docs_list.urlcode, docs_list.title

FROM users

INNER JOIN docs_list

ON users.id = docs_list.user_id

WHERE docs_list.user_id = {$value}

ORDER BY docs_list.date DESC

Problem is that, I got so many firstname and lastname results (equal to how many rows I have in the docs_list result). I only need 1 firstname and lastname.

So how can I do it?


问:
Botman.io Facebook Template error
I have copied and pasted the example from the document, with the bunch of includes at the top:

```<code>use Mpociot\BotMan\Facebook\GenericTemplate;
use Mpociot\BotMan\Facebook\ListTemplate;
use Mpociot\BotMan\Facebook\ButtonTemplate;
use Mpociot\BotMan\Facebook\ElementButton;
use Mpociot\BotMan\Facebook\Element;

$botman->reply(ButtonTemplate::create('Do you want to know more about BotMan?')
                ->addButton(ElementButton::create('Tell me more')->type('postback')->payload('tellmemore'))
                ->addButton(ElementButton::create('Show me the docs')->url('http://botman.io/'))
            );
</code>```

but it gave me error:

```<code>  [ErrorException]
  Object of class Mpociot\BotMan\Facebook\ButtonTemplate could not be convert
  ed to string
</code>```

Any clue?

答: Found the cause; The Console Driver is not handling the Facebook Template; Hopefully will fix in the future release. This works on Facebook Messager though.</p>

Title: Botman.io Facebook Template error

Body:
I have copied and pasted the example from the document, with the bunch of includes at the top:

use Mpociot\BotMan\Facebook\GenericTemplate;
use Mpociot\BotMan\Facebook\ListTemplate;
use Mpociot\BotMan\Facebook\ButtonTemplate;
use Mpociot\BotMan\Facebook\ElementButton;
use Mpociot\BotMan\Facebook\Element;

$botman->reply(ButtonTemplate::create('Do you want to know more about BotMan?')
                ->addButton(ElementButton::create('Tell me more')->type('postback')->payload('tellmemore'))
                ->addButton(ElementButton::create('Show me the docs')->url('http://botman.io/'))
            );

but it gave me error:

  [ErrorException]
  Object of class Mpociot\BotMan\Facebook\ButtonTemplate could not be convert
  ed to string

Any clue?


问:
Is it possible to declare a scanner variable inside a method in Java to read keyboard input?
```<code>final int MAX_ROUNDS = 5;
String name1,name1;

Scanner keyboard = new Scanner(System.in);
System.out.println("Please enter player1 name: ");
name1 = keyboard.nextLine();
System.out.println("Please enter player2 name: ");
name2 = keyboard.nextLine();
Player player1 = new Player(name1);
Player player2 = new Player(name2);

Dealer dealer = new Dealer();

    for(int count = 1; count <=MAX_ROUNDS; count++)
    {
        System.out.println("------------------");
        System.out.ptintf("Round : %d",count);
        dealer.rollDice();
        player1.makeGuess();
        player2.makeGuess();
        roundResults();
</code>```

excerpt from the makeGuess method which belongs to the  Player class.

```<code>public void makeGuess()
{
Scanner keyboard = new Scanner(System.in)

System.out.printf("Please guess 'even' or 'odd' "+
        "%s.", name);
String answer = keyboard.nextLine();

        if(answer.equalsIgnoreCase("even")
            guess = "Cho (even)";
        else
            guess = "Han (odd);
  }
</code>```

I am not being prompted anything when the method executes I cannot understand why I did not include everything for the program. was just wondering if anyone eye balling this code could see something obvious otherwise, i will just take out the guess submission.

答: Have you tried to print out name1, name2, etc. variables that get their values from the scanner to see if it is working? Try doing that immediately after setting their value to be keyboard.nextLine(). This should then give you a better idea of where the problem lies. </p>

Body:
final int MAX_ROUNDS = 5;
String name1,name1;

Scanner keyboard = new Scanner(System.in);
System.out.println("Please enter player1 name: ");
name1 = keyboard.nextLine();
System.out.println("Please enter player2 name: ");
name2 = keyboard.nextLine();
Player player1 = new Player(name1);
Player player2 = new Player(name2);

Dealer dealer = new Dealer();

    for(int count = 1; count <=MAX_ROUNDS; count++)
    {
        System.out.println("------------------");
        System.out.ptintf("Round : %d",count);
        dealer.rollDice();
        player1.makeGuess();
        player2.makeGuess();
        roundResults();

excerpt from the makeGuess method which belongs to the  Player class.

public void makeGuess()
{
Scanner keyboard = new Scanner(System.in)

System.out.printf("Please guess 'even' or 'odd' "+
        "%s.", name);
String answer = keyboard.nextLine();

        if(answer.equalsIgnoreCase("even")
            guess = "Cho (even)";
        else
            guess = "Han (odd);
  }

I am not being prompted anything when the method executes I cannot understand why I did not include everything for the program. was just wondering if anyone eye balling this code could see something obvious otherwise, i will just take out the guess submission.


问:
Should the hover event be disabled once a link is clicked?
As I was working on the link styling for this page component-header I noticed that the hover event was not triggering.  I then opened the page up in incognito mode, and the link :hover styling renders.

So the browser (Both Chrome and Firefox) remember that you have visited a certain link (Regardless of whether it's a new tab), and after that the browser does not trigger the hover event.

I was expecting that event to be triggered regardless of whether the link has been visited or not.  I do expect the :visited style to be displayed once the link is visited, but if the mouse hovers, I would just naturally expect that the :hover style be triggered.

I filed a bug report with Chrome for this I'm just wondering whether I should follow up on it or whether the current behavior is there for a good reason?

It seems like we should not have to remember the right order for Pseudo selectors, although the clever tip offered by @kapreski makes it very easy.

答:
just to add a tip to the accepted answer that makes remembering the order of the four selectors a bit easier, just think of "love (lv) hate (ha)"</p>

```<code>  a:link
  a:visited
  a:hover
  a:active
</code>```

Body:
just to add a tip to the accepted answer that makes remembering the order of the four selectors a bit easier, just think of "love (lv) hate (ha)"

  a:link
  a:visited
  a:hover
  a:active


问:
Increment value in one text file and write text to another
I have a HTML script of which contains a form, this form submits a Name value to a PHP script. In this PHP script I open two different text files, first file is to get the number inside and then increment it by 1. The other file is to open and then write the newly incremented number along with the Name value from the Post.
The first file of which only has a number inside starts on "0" and this is where I am having issues. When running the code, nothing happens, the form is submitted perfectly and the PHP script is called. But the only value inside the two different text files is "0" in both of them. Instead it should have "1" in the "amount.txt" file and "Text to appear:  1 Other text: Name" in the "textContent.txt" file.

I am not completely sure where I am wrong, to me it seems theoretically correct.

Underneath here is the PHP part, which is the part that isn't working.

```<code>$nam = $_POST['Name'];

$pastAmount = (int)file_get_contents('/user/site/amount.txt');
$fileOpen1 = '/user/site/amount.txt';
$newAmount = $pastAmount++;
file_put_contents($fileOpen1, $newAmount);

$fileOpen2 = '/user/site/textContent.txt';

$fileWrite2 = fopen($fileOpen2 , 'a');
$ordTxt = 'Text to appear:  ' + $newAmount + 'Other text: ' + $nam;
fwrite($fileWrite2, $ordTxt . PHP_EOL);
fclose($fileWrite2);
</code>```

答:
First of all, errors in your code:

$newAmount = $pastAmount++; => This will assign $pastAmount's value and then increment the value which is not what you're aiming for.

$ordTxt = 'Text to appear:  ' + $newAmount + 'Other text: ' + $nam; => Concatenation in PHP is done with a . and not a +

Correct code:

```<code>$nam = $_POST['Name'];

$pastAmount = (int)file_get_contents('/user/site/amount.txt');
$fileOpen1 = '/user/site/amount.txt';
$newAmount = $pastAmount + 1;
// or
// $newAmount = ++$pastAmount;

file_put_contents($fileOpen1, $newAmount);

$fileOpen2 = '/user/site/textContent.txt';

$fileWrite2 = fopen($fileOpen2 , 'a');
$ordTxt = 'Text to appear:  ' . $newAmount . 'Other text: ' . $nam;
fwrite($fileWrite2, $ordTxt . PHP_EOL);
fclose($fileWrite2);
</code>```

Body:
I have a HTML script of which contains a form, this form submits a Name value to a PHP script. In this PHP script I open two different text files, first file is to get the number inside and then increment it by 1. The other file is to open and then write the newly incremented number along with the Name value from the Post.
The first file of which only has a number inside starts on "0" and this is where I am having issues. When running the code, nothing happens, the form is submitted perfectly and the PHP script is called. But the only value inside the two different text files is "0" in both of them. Instead it should have "1" in the "amount.txt" file and "Text to appear:  1 Other text: Name" in the "textContent.txt" file.

I am not completely sure where I am wrong, to me it seems theoretically correct.

Underneath here is the PHP part, which is the part that isn't working.

$nam = $_POST['Name'];

$pastAmount = (int)file_get_contents('/user/site/amount.txt');
$fileOpen1 = '/user/site/amount.txt';
$newAmount = $pastAmount++;
file_put_contents($fileOpen1, $newAmount);

$fileOpen2 = '/user/site/textContent.txt';

$fileWrite2 = fopen($fileOpen2 , 'a');
$ordTxt = 'Text to appear:  ' + $newAmount + 'Other text: ' + $nam;
fwrite($fileWrite2, $ordTxt . PHP_EOL);
fclose($fileWrite2);

Body:
First of all, errors in your code:

$newAmount = $pastAmount++; => This will assign $pastAmount's value and then increment the value which is not what you're aiming for.

$ordTxt = 'Text to appear:  ' + $newAmount + 'Other text: ' + $nam; => Concatenation in PHP is done with a . and not a +

Correct code:

$nam = $_POST['Name'];

$pastAmount = (int)file_get_contents('/user/site/amount.txt');
$fileOpen1 = '/user/site/amount.txt';
$newAmount = $pastAmount + 1;
// or
// $newAmount = ++$pastAmount;

file_put_contents($fileOpen1, $newAmount);

$fileOpen2 = '/user/site/textContent.txt';

$fileWrite2 = fopen($fileOpen2 , 'a');
$ordTxt = 'Text to appear:  ' . $newAmount . 'Other text: ' . $nam;
fwrite($fileWrite2, $ordTxt . PHP_EOL);
fclose($fileWrite2);


问:
Print msg to the console from GUI app - C#
Hi
I want to print some messages when I'm running C# GUI app on Visual Studio. It's like debugging. So I tried it, but not worked. console.writeline() didn't work or It may work, but I couldn't see the messages. Anyone knows about this? give me a solution if you know.
Thank you.</p>

答: You can also run the app as a console app and then you'd have a console window as well as the form - simply change the setting in the Project Properties.</p>


问:
How do I make JSON.NET ignore object relationships?
I'm working on an Entity Framework project. I want to serialize a bunch of entity class instances. I've bound these together into a container class:

```<code>public class Pseudocontext
{
    public List<Widget> widgets;
    public List<Thing> things;
</code>```

Etcetera... it is an instance of this class that I'm attempting to serialize. I want JSON.NET to serialize the members of each entity class instance that are actually columns in the underlying database. I do not want it to even attempt to serialize object references.

In particular, my entity classes have virtual members that allow me to write C# code that navigates all my inter-entity relationships without worrying about actual key values, joins, etc., and I want JSON.NET to ignore the associated parts of my entity classes.

On the surface, there seems to be a JSON.NET configuration option that does exactly what I'm talking about:

```<code>JsonSerializer serializer = new JsonSerializer();
serializer.PreserveReferencesHandling = PreserveReferencesHandling.None;
</code>```

Unfortunately, JSON.NET seems to be ignoring the second statement above.

I actually found a web page (http://json.codeplex.com/workitem/24608) where someone else brought the same issue to the attention of James Newton-King himself, and his response (in its entirety) was "Write a custom contract resolver."

As inadequate as I find that response to be, I have been attempting to follow its guidance. I would very much like to be able to write a "contract resolver" that ignored everything except primitive types, strings, DateTime objects, and my own Pseudocontext class along with the Lists it contains directly. If someone has an example of something that at least resembles that, it might be all I need. This is what I came up with on my own:

```<code>public class WhatDecadeIsItAgain : DefaultContractResolver
{
    protected override JsonContract CreateContract(Type objectType)
    {
        JsonContract contract = base.CreateContract(objectType);
        if (objectType.IsPrimitive || objectType == typeof(DateTime) || objectType == typeof(string)
            || objectType == typeof(Pseudocontext) || objectType.Name.Contains("List"))
        {
            contract.Converter = base.CreateContract(objectType).Converter;
        }
        else
        {
            contract.Converter = myDefaultConverter;
        }
        return contract;
    }
    private static GeeThisSureTakesALotOfClassesConverter myDefaultConverter = new GeeThisSureTakesALotOfClassesConverter();
}

public class GeeThisSureTakesALotOfClassesConverter : Newtonsoft.Json.Converters.CustomCreationConverter<object>
{
    public override object Create(Type objectType)
    {
        return null;
    }
}
</code>```

When I attempt to use the above (by setting serializer.ContractResolver to an instance of WhatDecadeIsItAgain prior to serialization), I get OutOfMemory errors during serialization that indicate that JSON.NET is encountering reference loops that never terminate (in spite of my efforts to make JSON.NET just ignore object references).

I feel like my "custom contract resolver" may be wrong. As shown above, it's built around the premise that I should return the default "contract" for the types I do want to serialize, and a "contract" that simply returns "null" for all other types.

I have no idea how correct these assumptions are, though, and it's not easy to tell. The JSON.NET design is very much based on implementation inheritance, method overriding, etc.; I'm not much of an OOP guy, and I find that sort of design to be pretty obscure. Were there a "custom contract resolver" interface that I could implement, Visual Studio 2012 would be able to stub out the required methods very quickly, and I imagine I'd have little trouble filling the stubs in with real logic.

I'd have no problem writing, for example, a method that returns "true" if I want to serialize an object of a supplied type and "false" otherwise. Perhaps I'm missing something, but I've found no such method to override, nor have I been able to find the hypothetical interface (ICustomContractResolver ?) that would tell me what I'm actually supposed to be doing in the last code snippet inserted above.

Also, I realize that there are JSON.NET attributes ([JsonIgnore]?) that are designed to deal with situations like this. I can't really use that approach, since I'm using "model first". Unless I decide to tear up my entire project architecture, my entity classes will be automatically generated, and they will not contain JsonIgnore attributes, nor do I feel comfortable editing the automated classes to contain these attributes.

Incidentally, for a while I did have things set up to serialize object references, and I was just ignoring all the superfluous "$ref" and "$id" data that JSON.NET was returning in its serialization output. I've abandoned that approach for the moment at least, because (rather suddenly) serialization started taking an inordinate amount of time (~45 minutes to get ~5 MB of JSON).

I haven't been able to tie that sudden change in performance back to anything specific that I did. If anything, the volume of data in my database is lower now than it was when serialization was actually completing in reasonable time. But I'd be more than happy with a return to the status quo ante (in which I was just having to ignore "$ref", "$id", etc.) if that could be achieved.

At this point, I'm also open to the prospect of using some other JSON library, or a different strategy altogether. I feel like I could just use StringBuilder, System.Reflection, etc. and come of with my own, homemade solution... but isn't JSON.NET supposed to be able to handle this sort of thing pretty easily??

答: An easier method is to modify your model T4 template (.tt) to append [JsonIgnore] attributes to your navigation properties, which will just leave the primitive types as serializable.

Body:
I'm working on an Entity Framework project. I want to serialize a bunch of entity class instances. I've bound these together into a container class:

public class Pseudocontext
{
    public List<Widget> widgets;
    public List<Thing> things;

Etcetera... it is an instance of this class that I'm attempting to serialize. I want JSON.NET to serialize the members of each entity class instance that are actually columns in the underlying database. I do not want it to even attempt to serialize object references.

In particular, my entity classes have virtual members that allow me to write C# code that navigates all my inter-entity relationships without worrying about actual key values, joins, etc., and I want JSON.NET to ignore the associated parts of my entity classes.

On the surface, there seems to be a JSON.NET configuration option that does exactly what I'm talking about:

JsonSerializer serializer = new JsonSerializer();
serializer.PreserveReferencesHandling = PreserveReferencesHandling.None;

Unfortunately, JSON.NET seems to be ignoring the second statement above.

I actually found a web page (http://json.codeplex.com/workitem/24608) where someone else brought the same issue to the attention of James Newton-King himself, and his response (in its entirety) was "Write a custom contract resolver."

As inadequate as I find that response to be, I have been attempting to follow its guidance. I would very much like to be able to write a "contract resolver" that ignored everything except primitive types, strings, DateTime objects, and my own Pseudocontext class along with the Lists it contains directly. If someone has an example of something that at least resembles that, it might be all I need. This is what I came up with on my own:

public class WhatDecadeIsItAgain : DefaultContractResolver
{
    protected override JsonContract CreateContract(Type objectType)
    {
        JsonContract contract = base.CreateContract(objectType);
        if (objectType.IsPrimitive || objectType == typeof(DateTime) || objectType == typeof(string)
            || objectType == typeof(Pseudocontext) || objectType.Name.Contains("List"))
        {
            contract.Converter = base.CreateContract(objectType).Converter;
        }
        else
        {
            contract.Converter = myDefaultConverter;
        }
        return contract;
    }
    private static GeeThisSureTakesALotOfClassesConverter myDefaultConverter = new GeeThisSureTakesALotOfClassesConverter();
}

public class GeeThisSureTakesALotOfClassesConverter : Newtonsoft.Json.Converters.CustomCreationConverter<object>
{
    public override object Create(Type objectType)
    {
        return null;
    }
}

When I attempt to use the above (by setting serializer.ContractResolver to an instance of WhatDecadeIsItAgain prior to serialization), I get OutOfMemory errors during serialization that indicate that JSON.NET is encountering reference loops that never terminate (in spite of my efforts to make JSON.NET just ignore object references).

I feel like my "custom contract resolver" may be wrong. As shown above, it's built around the premise that I should return the default "contract" for the types I do want to serialize, and a "contract" that simply returns "null" for all other types.

I have no idea how correct these assumptions are, though, and it's not easy to tell. The JSON.NET design is very much based on implementation inheritance, method overriding, etc.; I'm not much of an OOP guy, and I find that sort of design to be pretty obscure. Were there a "custom contract resolver" interface that I could implement, Visual Studio 2012 would be able to stub out the required methods very quickly, and I imagine I'd have little trouble filling the stubs in with real logic.

I'd have no problem writing, for example, a method that returns "true" if I want to serialize an object of a supplied type and "false" otherwise. Perhaps I'm missing something, but I've found no such method to override, nor have I been able to find the hypothetical interface (ICustomContractResolver ?) that would tell me what I'm actually supposed to be doing in the last code snippet inserted above.

Also, I realize that there are JSON.NET attributes ([JsonIgnore]?) that are designed to deal with situations like this. I can't really use that approach, since I'm using "model first". Unless I decide to tear up my entire project architecture, my entity classes will be automatically generated, and they will not contain JsonIgnore attributes, nor do I feel comfortable editing the automated classes to contain these attributes.

Incidentally, for a while I did have things set up to serialize object references, and I was just ignoring all the superfluous "$ref" and "$id" data that JSON.NET was returning in its serialization output. I've abandoned that approach for the moment at least, because (rather suddenly) serialization started taking an inordinate amount of time (~45 minutes to get ~5 MB of JSON).

I haven't been able to tie that sudden change in performance back to anything specific that I did. If anything, the volume of data in my database is lower now than it was when serialization was actually completing in reasonable time. But I'd be more than happy with a return to the status quo ante (in which I was just having to ignore "$ref", "$id", etc.) if that could be achieved.

At this point, I'm also open to the prospect of using some other JSON library, or a different strategy altogether. I feel like I could just use StringBuilder, System.Reflection, etc. and come of with my own, homemade solution... but isn't JSON.NET supposed to be able to handle this sort of thing pretty easily??


问:
Uncheck box is other is selected with jQuery
I have a several checkboxes like this:

```<code><div class="col-sm-12">
        <div class="col-sm-4">
            <div class="checkbox checkbox-default">
                <input type="checkbox" name="RAT_RoomList[]" value="10">
                <label for="custome-checkbox1"># 11</label>
            </div>
        </div>
        <div class="col-sm-4">
            <div class="checkbox checkbox-default">
                <input type="checkbox" name="RAT_RoomList[]" value="11">
                <label for="custome-checkbox2"># 12</label>
            </div>
        </div>
        <div class="col-sm-4">
            <div class="checkbox checkbox-default">
                <input type="checkbox" name="RAT_RoomList[]" value="12">
                <label for="custome-checkbox3"># 13</label>
            </div>
        </div>
        <div class="col-sm-12">
            <div class="checkbox checkbox-default">
                <input type="checkbox" class="selectAll">
                <label for="custome-checkbox">Select all</label>
            </div>
        </div>
</div>
</code>```

How can unselect all other when the Select all is checked and how can I unselect Select All when one of the other checkboxes is checked?

Thanks.

答:
Here you go with the fiddle https://jsfiddle.net/Lt2k8wxL/

```<code>$('.selectAll').change(function() {
    if ($(this).is(':checked')){
        $('input[name="RAT_RoomList[]"]').prop('checked', false);
    }
});

$('input[name="RAT_RoomList[]"]').change(function(){
    if ($(this).is(':checked')){
        $('.selectAll').prop('checked', false);
    }
});
</code>```

I guess this is what you are looking for.

Body:
I have a several checkboxes like this:

                <input type="checkbox" name="RAT_RoomList[]" value="10">
                # 11

                <input type="checkbox" name="RAT_RoomList[]" value="11">
                # 12

                <input type="checkbox" name="RAT_RoomList[]" value="12">
                # 13

                <input type="checkbox" class="selectAll">
                Select all

How can unselect all other when the Select all is checked and how can I unselect Select All when one of the other checkboxes is checked?

Thanks.

Body:
Here you go with the fiddle https://jsfiddle.net/Lt2k8wxL/

$('.selectAll').change(function() {
    if ($(this).is(':checked')){
        $('input[name="RAT_RoomList[]"]').prop('checked', false);
    }
});

$('input[name="RAT_RoomList[]"]').change(function(){
    if ($(this).is(':checked')){
        $('.selectAll').prop('checked', false);
    }
});

I guess this is what you are looking for.


答:
No need for IIF. Simply check for NULL

```<code>WHERE fldinfo IS NOT NULL
</code>```

Or, of course, use IS NULL if you want rows where this condition is met

Title: Substitute FROM ISNULL in where clause in ms sql server

Body:
No need for IIF. Simply check for NULL

WHERE fldinfo IS NOT NULL

Or, of course, use IS NULL if you want rows where this condition is met


问:
Developing a website using remote server
I have been searching for a broad answer to this question for a while.

I am developing a website using wordpress and have a fair amount of css/html/php/js knowledge. In the past, I have made websites on my local machine and then registered them with a domain name.

This time, a friend has offered to help as he has experience with the marketing/business aspects of web development.

As I said, we are using wordpress, and I would like us both to be able to access the website as it would be viewed online, as well as the backend in order to make changes and complete development however we see fit.

I have considered a number of options for how to do this, but I would like some guidance and see what people recommend. I see my options as this:

(1) Meet up with him and host the wordpress site on the local IP to edit together.

(2) Enable port forwarding so that he can access the wordpress remotely and we can edit together.

(3) Load Ubuntu onto an old machine and host the website using DynDNS.

(4) Buy actual server space and host the website with the express intention of editing it remotely and later hosting it to a new domain.

(5) Using git or a repo system (this idea is not as good because he does not have experience with such a system and does not seem ideal for web hosting).

Which of these would seem ideal? If we ended up looking to build more sites, which of these options would be best?

Thanks! Also, if there is an old StackOverflow that answers this I would appreciate it.

答: Personally, I have used options 3 and 4 with great results. Being that I already have server space and it was not a problem to host it there. I'm not sure if this is relevant but I'm pretty sure GitHub is an option too. I've never used it but I think it would work for this.</p>


问:
Adding Serilog sub-logger to limit data going to log aggregator
I have a need to send data via a sub-logger that only includes specific contextual data.  In this case, I am pretty much wanting to ignore everything from the Message Template (except the text itself) and pass key contextual data already added by enrichers and PushContext statements.  This is mainly to create a dashboard view that stays consistant.

```<code>LevelSwitch = new LoggingLevelSwitch { MinimumLevel = LogLevelSerilog.Verbose };

Log.Logger = new LoggerConfiguration()
.MinimumLevel.ControlledBy(LevelSwitch)
.Enrich.With<CorrelationIdEnricher>()
.Enrich.With<ThreadIdEnricher>()
.Enrich.FromLogContext()
.WriteTo.Seq("http://localhost/Response")
// Filter to a sublogger for instrumentation...
.WriteTo.Logger(lc => lc.MinimumLevel.Information()
                        .WriteTo.Seq("http://localhost/Public")
                        .Filter.ByIncludingOnly(q => q.Properties.ContainsKey("Controller")
                                                    || q.Properties.ContainsKey("Action")
                                                    || q.Properties.ContainsKey("Class")
                                                    || q.Properties.ContainsKey("Method")
                                                    || q.Properties.ContainsKey("Organization")
                                                    || q.Properties.ContainsKey("OrganizationId")
                                                    || q.Properties.ContainsKey("CorrelationId")))
.CreateLogger();
</code>```

Any ideas why this is not sending any events to the sub-logger?  (Figured this out)

Any ideas why I am getting everything from the main logger (per level allowed)?  I expected the filter(s) to reduce the amount of data going to the sub-logger.  i.e.:  I want just the filtered data to go to the sub-logger.  Any added data should be stripped off of the log.

答: The outer logger would need to have at least the Information level enabled in order for this to work - if the LevelSwitch is set at Warning or Error, this would explain the absence of events reaching the sub-logger.

Body:
I have a need to send data via a sub-logger that only includes specific contextual data.  In this case, I am pretty much wanting to ignore everything from the Message Template (except the text itself) and pass key contextual data already added by enrichers and PushContext statements.  This is mainly to create a dashboard view that stays consistant.

LevelSwitch = new LoggingLevelSwitch { MinimumLevel = LogLevelSerilog.Verbose };

Log.Logger = new LoggerConfiguration()
.MinimumLevel.ControlledBy(LevelSwitch)
.Enrich.With<CorrelationIdEnricher>()
.Enrich.With<ThreadIdEnricher>()
.Enrich.FromLogContext()
.WriteTo.Seq("http://localhost/Response")
// Filter to a sublogger for instrumentation...
.WriteTo.Logger(lc => lc.MinimumLevel.Information()
                        .WriteTo.Seq("http://localhost/Public")
                        .Filter.ByIncludingOnly(q => q.Properties.ContainsKey("Controller")
                                                    || q.Properties.ContainsKey("Action")
                                                    || q.Properties.ContainsKey("Class")
                                                    || q.Properties.ContainsKey("Method")
                                                    || q.Properties.ContainsKey("Organization")
                                                    || q.Properties.ContainsKey("OrganizationId")
                                                    || q.Properties.ContainsKey("CorrelationId")))
.CreateLogger();

Any ideas why this is not sending any events to the sub-logger?  (Figured this out)

Any ideas why I am getting everything from the main logger (per level allowed)?  I expected the filter(s) to reduce the amount of data going to the sub-logger.  i.e.:  I want just the filtered data to go to the sub-logger.  Any added data should be stripped off of the log.


问:
Intermittent ORA-22288 error - command length incorrect
I have an intermittent problem with a web application that frequently has to open a file located on the database server as part of regular operations.  For the vast majority of the time, this functions without issue, however, at seemingly random times, the corresponding requests start returning HTTP 400 errors.  Bouncing the apache server addresses the issue for a time, but it invariably returns in a day or at most a week.

I added some logging to the relevant pl/sql code (no, don't run away! come back!), which I've listed below for reference:

```<code>declare
  bl_blob blob;
  bf_file bfile := bfilename(<directory that totally exists>, <file that totally exists>);
begin
  dbms_lob.createTemporary(bl_blob, true);
  dbms_lob.open(bf_file, dbms_lob.lob_readonly);
  dbms_lob.open(bl_blob, dbms_lob.lob_readwrite);
  dbms_lob.loadfromfile(bl_blob, bf_file, dbms_lob.getLength(bf_file));
  dbms_lob.close(bf_file);
  return bl_blob;
end;
</code>```

It turns out the 400 errors correspond to the following ORA-22288 error:

```<code>file or LOB operation FILEOPEN failed
The program issued a command but the command length is incorrect
</code>```

My question is, why would the operation suddenly, and repeatedly, start erroring out where previously the same file could be opened without issue?  The underlying file is never changed and only ever opened programmatically with read only permissions.

All the forum digging I've done so far has yielded mostly a slew of "turn it off and on" solutions, which...yeah.

Any help is greatly appreciated.

答:
You didn't note (or I don't see) your app server's framework but if you're fortunate enough to be running java on your app server, you can simplify your code considerably. I don't know if that will fix your problem but it will at least get rid of the need to know the length of the bfile.</p>

```<code>public void getFile (String oradir, String filename, String filesysdir) throws FileNotFoundException, IOException, SQLException, Exception {
    CallableStatement s = this.conn.prepareCall("select bfilename(?,?) from dual");
    s.setString(1, oradir);
    s.setString(2, filename);
    OracleResultSet r = (OracleResultSet) s.executeQuery();
    if (r.next())
        saveBFILE(r.getBFILE(1), filesysdir);
}

private void saveBFILE (BFILE b, String dir) throws FileNotFoundException, IOException, SQLException {
    b.openFile();
    InputStream s = b.getBinaryStream();
    InputStreamReader r = new InputStreamReader(s);
    String name = b.getName();
    String path = dir == null ? name : dir + '/' + name;
    System.out.println("creating " + name);
    FileOutputStream w = new FileOutputStream(new File(path));
    int nb;
    byte[] ba = new byte[4096];
    while ((nb = s.read(ba)) != -1)
        w.write(ba, 0, nb);
    w.close();
    b.closeFile();
}
</code>```

Body:
I have an intermittent problem with a web application that frequently has to open a file located on the database server as part of regular operations.  For the vast majority of the time, this functions without issue, however, at seemingly random times, the corresponding requests start returning HTTP 400 errors.  Bouncing the apache server addresses the issue for a time, but it invariably returns in a day or at most a week.

I added some logging to the relevant pl/sql code (no, don't run away! come back!), which I've listed below for reference:

declare
  bl_blob blob;
  bf_file bfile := bfilename(<directory that totally exists>, <file that totally exists>);
begin
  dbms_lob.createTemporary(bl_blob, true);
  dbms_lob.open(bf_file, dbms_lob.lob_readonly);
  dbms_lob.open(bl_blob, dbms_lob.lob_readwrite);
  dbms_lob.loadfromfile(bl_blob, bf_file, dbms_lob.getLength(bf_file));
  dbms_lob.close(bf_file);
  return bl_blob;
end;

It turns out the 400 errors correspond to the following ORA-22288 error:

file or LOB operation FILEOPEN failed
The program issued a command but the command length is incorrect

My question is, why would the operation suddenly, and repeatedly, start erroring out where previously the same file could be opened without issue?  The underlying file is never changed and only ever opened programmatically with read only permissions.

All the forum digging I've done so far has yielded mostly a slew of "turn it off and on" solutions, which...yeah.

Any help is greatly appreciated.

Body:
You didn't note (or I don't see) your app server's framework but if you're fortunate enough to be running java on your app server, you can simplify your code considerably. I don't know if that will fix your problem but it will at least get rid of the need to know the length of the bfile.

public void getFile (String oradir, String filename, String filesysdir) throws FileNotFoundException, IOException, SQLException, Exception {
    CallableStatement s = this.conn.prepareCall("select bfilename(?,?) from dual");
    s.setString(1, oradir);
    s.setString(2, filename);
    OracleResultSet r = (OracleResultSet) s.executeQuery();
    if (r.next())
        saveBFILE(r.getBFILE(1), filesysdir);
}

private void saveBFILE (BFILE b, String dir) throws FileNotFoundException, IOException, SQLException {
    b.openFile();
    InputStream s = b.getBinaryStream();
    InputStreamReader r = new InputStreamReader(s);
    String name = b.getName();
    String path = dir == null ? name : dir + '/' + name;
    System.out.println("creating " + name);
    FileOutputStream w = new FileOutputStream(new File(path));
    int nb;
    byte[] ba = new byte[4096];
    while ((nb = s.read(ba)) != -1)
        w.write(ba, 0, nb);
    w.close();
    b.closeFile();
}


问:
HTML Input Submit Button Won't Change Color
I have a form with a submit button that I'm trying to change the color to. This should be very simple, but my css isn't working and I can't figure out why.

The CSS:

```<code>input[type="submit"]{color: red;}
</code>```

Fiddle:
https://jsfiddle.net/zn7xrv60/

This is driving me nuts, any help would be appreciated.

答:
```<code>.login_content .container input[type="submit"] {
     background: red;
 }
</code>```

Body:
I have a form with a submit button that I'm trying to change the color to. This should be very simple, but my css isn't working and I can't figure out why.

The CSS:

input[type="submit"]{color: red;}

Fiddle:
https://jsfiddle.net/zn7xrv60/

This is driving me nuts, any help would be appreciated.


问:
How to add hashes to itself and remove duplicates in Ruby?
I have a hash:

```<code>h = { ["alpha"]=>[{  "bit"=>"100", "colour"=>"red"},
                  {   "id"=>"100", "colour"=>"red"},
                  { "value"=>"65", "colour"=>"red"}],
      ["beta"] =>[{   "id"=>"070", "colour"=>"black"},
                  {"value"=>"338", "colour"=>"black"}]
}
</code>```

I want to add hashes in values to itself and delete duplicated pairs from every item to get

```<code>h = { ["alpha"]=>[{"bit"=>"100", "id"=>"100", "value"=>"65", "colour"=>"red"}],
      ["beta"] =>[{"id"=>"070", "value"=>"338", "colour"=>"black"}]
}
</code>```

I tried so far converting hashes to array and remove duplicates but how to convert array to hash again? And I also think it is not effective and elegant solution. Any other ideas?

答:
This uses the form of Hash#merge to determine the values of keys that are present in both hashes being merged, which here is all keys.</p>

```<code>h.merge(h) { |_,arr| arr.reduce(&:merge) }
  #=> {["alpha"]=>{"bit"=>"100", "colour"=>"red", "id"=>"100", "value"=>"65"},
  #    ["beta"] =>{"id"=>"070", "colour"=>"black", "value"=>"338"}}
</code>```

Body:
I have a hash:

h = { ["alpha"]=>[{  "bit"=>"100", "colour"=>"red"},
                  {   "id"=>"100", "colour"=>"red"},
                  { "value"=>"65", "colour"=>"red"}],
      ["beta"] =>[{   "id"=>"070", "colour"=>"black"},
                  {"value"=>"338", "colour"=>"black"}]
}

I want to add hashes in values to itself and delete duplicated pairs from every item to get

h = { ["alpha"]=>[{"bit"=>"100", "id"=>"100", "value"=>"65", "colour"=>"red"}],
      ["beta"] =>[{"id"=>"070", "value"=>"338", "colour"=>"black"}]
}

I tried so far converting hashes to array and remove duplicates but how to convert array to hash again? And I also think it is not effective and elegant solution. Any other ideas?

Body:
This uses the form of Hash#merge to determine the values of keys that are present in both hashes being merged, which here is all keys.

h.merge(h) { |_,arr| arr.reduce(&:merge) }
  #=> {["alpha"]=>{"bit"=>"100", "colour"=>"red", "id"=>"100", "value"=>"65"},
  #    ["beta"] =>{"id"=>"070", "colour"=>"black", "value"=>"338"}}


答:
It seems there are two issues.

The first is what Tieson T mentioned in his comment.  Which is that your selector is being over written by a more specific selector.  This can be "fixed" by using "!important" which isn't a preferred, but is an easy way around an issue like this.

The other issue is that the submit button requires you to set the text-shadow.  Try this out:

```<code>input[type="submit"]
{
  color: red !important;
  text-shadow: 0px 0px 0px red !important;
}
</code>```

This CSS rule is what is causing you to have to override the text-shadow:

```<code>input{
    color: #f08200;
    text-shadow: 0px 0px 0px #000;
    -webkit-text-fill-color: transparent;
}
</code>```

So another option is to remove the text shadow property from this rule, and then you won't need it specified in the first rule.

UPDATE

As Chava G, pointed out in the comments another reason the color is not showing is because -webkit-text-fill-color is set to transparent.

Additionally, since the text shadow has no vertical or horizontal offset the shadow wouldn't be visible if the -webkit-text-fill-color was not transparent.

The input css rule above is a little "confused", it sets the "color" property which might imply you want the text a certain color, but then applies a text shadow that would be hidden behind the text.  Followed by that it makes the text itself transparent, so it's no longer hiding the shadow which is a different color than what was set for the "color" property.

Title: HTML Input Submit Button Won't Change Color

Body:
It seems there are two issues.

The first is what Tieson T mentioned in his comment.  Which is that your selector is being over written by a more specific selector.  This can be "fixed" by using "!important" which isn't a preferred, but is an easy way around an issue like this.

The other issue is that the submit button requires you to set the text-shadow.  Try this out:

input[type="submit"]
{
  color: red !important;
  text-shadow: 0px 0px 0px red !important;
}

This CSS rule is what is causing you to have to override the text-shadow:

input{
    color: #f08200;
    text-shadow: 0px 0px 0px #000;
    -webkit-text-fill-color: transparent;
}

So another option is to remove the text shadow property from this rule, and then you won't need it specified in the first rule.

UPDATE

As Chava G, pointed out in the comments another reason the color is not showing is because -webkit-text-fill-color is set to transparent.

Additionally, since the text shadow has no vertical or horizontal offset the shadow wouldn't be visible if the -webkit-text-fill-color was not transparent.

The input css rule above is a little "confused", it sets the "color" property which might imply you want the text a certain color, but then applies a text shadow that would be hidden behind the text.  Followed by that it makes the text itself transparent, so it's no longer hiding the shadow which is a different color than what was set for the "color" property.


问:
Python split not recognizing hyphen
I imported a table with the years that each coach served as the football coach. Some of the years listed look like this: "1903–1910, 1917, 1919"

I am aiming for [1903, 1904, 1905, 1906, 1907, 1908, 1909, 1910, 1917, 1919]

In my original DataFrame this list is an object.

I have tried:

x = "1903–1910, 1917, 1919"

x[0].split('-')

re.split(r'\s|-', x[0])

x[0].replace('-', ' ').split(' ')

I keep getting:

['1903–1910']

What am I doing wrong? Why isn't python finding the hyphen?

答:
The hyphen you see is not really a hyphen. It could be some other character, like an unicode en-dash which would look very similar.

Try to copy-paste the actual character into the split string.

Looking at the text you posted, here's the difference:

```<code>➜  ~ echo '1903–1910' | xxd
00000000: 3139 3033 e280 9331 3931 300a            1903...1910.
➜  ~ echo '1903-1910' | xxd
00000000: 3139 3033 2d31 3931 300a                 1903-1910.
</code>```

The character in the first case is: https://unicode-table.com/en/2013/

Title: Python split not recognizing hyphen

Body:
The hyphen you see is not really a hyphen. It could be some other character, like an unicode en-dash which would look very similar.

Try to copy-paste the actual character into the split string.

Looking at the text you posted, here's the difference:

➜  ~ echo '1903–1910' | xxd
00000000: 3139 3033 e280 9331 3931 300a            1903...1910.
➜  ~ echo '1903-1910' | xxd
00000000: 3139 3033 2d31 3931 300a                 1903-1910.

The character in the first case is: https://unicode-table.com/en/2013/


问:
Postgres Timestamp between not selecting records for function
Postgres 9.6

I have a function that utilizes a BETWEEN operator to select records which were created within a specified date range. This is an example of my structure and function

table

```<code>CREATE TABLE test.dated_records (
    dated_record_id int4 NOT NULL DEFAULT nextval('test.dated_record_dated_record_id_seq'::regclass),
    create_date timestamptz NOT NULL DEFAULT now(),
    update_date timestamptz NOT NULL DEFAULT now(),
    CONSTRAINT dated_record_pkey PRIMARY KEY (dated_record_id),
)
WITH (
    OIDS=FALSE
) ;
</code>```

function

```<code>  CREATE OR REPLACE FUNCTION test.list_date_records(_start_date timestamp with time zone, _end_date timestamp with time zone,)
 RETURNS TABLE(dated_record_id integer, create_date timestamptz,update_date timestamptz )
 LANGUAGE plpgsql
AS $function$
  BEGIN
        return QUERY EXECUTE
            $q$
                SELECT
                  dr.dated_record_id,
                  dr.create_date,
                  dr.update_date
                FROM test.dated_records dr
                WHERE dr.create_date BETWEEN $1 AND $2
                ORDER BY dr.create_date DESC
            $q$
            using _start_date, _end_date;
       return;
    END
$function$
</code>```

I have a record with a create_date of '2017-07-06 21:55:40.550468' and the logs are recording my parameters as

```<code>LOG:  execute <unnamed>:

                  SELECT * FROM test.list_date_records($1, $2);

DETAIL:  parameters: $1 = '2017-06-08 00:00:00', $2 = '2017-07-06 23:59:59'
</code>```

Yet i get nothing back. I've tried altering everything to plain TIMESTAMP and casting the create_date to DATE but nothing seems to work.

I'm sure it has something to with my timezone (I'm EST - New York) but I can't figure out what it is for the life of me.

I'm hoping that someone can point out what I'm doing wrong.

Thanks in advance.

答:
Here the solution:

Sample Data:

```<code>stackoverflow=# select * from test.dated_records ;

 dated_record_id |      create_date       |          update_date
--------------------+--------------------+--------------------------------
1 | 2017-06-08 00:00:00+07 | 2017-07-07 10:41:43.755836+07
2 | 2017-07-06 23:59:59+07 | 2017-07-07 10:41:43.828373+07
3 | 2017-08-06 23:59:59+07 | 2017-07-07 10:41:43.840404+07
4 | 2017-09-06 23:59:59+07 | 2017-07-07 10:41:43.851223+07

(4 rows)
</code>```

Function

```<code>CREATE OR REPLACE FUNCTION test.list_date_records(_start_date timestamp with time zone, _end_date timestamp with time zone)
 RETURNS TABLE (
 dated_record_id integer, -- same as selected column datatype
 create_date timestamptz, -- same as selected column datatype
 update_date timestamptz  -- same as selected column datatype
 )
 AS $function$
 BEGIN
        return QUERY EXECUTE
            $q$
                SELECT
                  dr.dated_record_id,
                  dr.create_date,
                  dr.update_date
                FROM test.dated_records dr
                WHERE dr.create_date BETWEEN $1 AND $2
                ORDER BY dr.create_date DESC
            $q$
            using _start_date, _end_date;
       return;
    END
$function$
LANGUAGE plpgsql
SECURITY DEFINER;
</code>```

Execute

```<code>stackoverflow=# SELECT * FROM test.list_date_records('2017-06-08 00:00:00', '2017-07-06 23:59:59');
 dated_record_id |      create_date       |          update_date
-----------------+------------------------+-------------------------------
               2 | 2017-07-06 23:59:59+07 | 2017-07-07 10:41:43.828373+07
               1 | 2017-06-08 00:00:00+07 | 2017-07-07 10:41:43.755836+07
(2 rows)
</code>```

Body:
Postgres 9.6

I have a function that utilizes a BETWEEN operator to select records which were created within a specified date range. This is an example of my structure and function

table

CREATE TABLE test.dated_records (
    dated_record_id int4 NOT NULL DEFAULT nextval('test.dated_record_dated_record_id_seq'::regclass),
    create_date timestamptz NOT NULL DEFAULT now(),
    update_date timestamptz NOT NULL DEFAULT now(),
    CONSTRAINT dated_record_pkey PRIMARY KEY (dated_record_id),
)
WITH (
    OIDS=FALSE
) ;

function

  CREATE OR REPLACE FUNCTION test.list_date_records(_start_date timestamp with time zone, _end_date timestamp with time zone,)
 RETURNS TABLE(dated_record_id integer, create_date timestamptz,update_date timestamptz )
 LANGUAGE plpgsql
AS $function$
  BEGIN
        return QUERY EXECUTE
            $q$
                SELECT
                  dr.dated_record_id,
                  dr.create_date,
                  dr.update_date
                FROM test.dated_records dr
                WHERE dr.create_date BETWEEN $1 AND $2
                ORDER BY dr.create_date DESC
            $q$
            using _start_date, _end_date;
       return;
    END
$function$

I have a record with a create_date of '2017-07-06 21:55:40.550468' and the logs are recording my parameters as

LOG:  execute <unnamed>:

                  SELECT * FROM test.list_date_records($1, $2);

DETAIL:  parameters: $1 = '2017-06-08 00:00:00', $2 = '2017-07-06 23:59:59'

Yet i get nothing back. I've tried altering everything to plain TIMESTAMP and casting the create_date to DATE but nothing seems to work.

I'm sure it has something to with my timezone (I'm EST - New York) but I can't figure out what it is for the life of me.

I'm hoping that someone can point out what I'm doing wrong.

Thanks in advance.

Body:
Here the solution:

Sample Data:

stackoverflow=# select * from test.dated_records ;

 dated_record_id |      create_date       |          update_date
--------------------+--------------------+--------------------------------
1 | 2017-06-08 00:00:00+07 | 2017-07-07 10:41:43.755836+07
2 | 2017-07-06 23:59:59+07 | 2017-07-07 10:41:43.828373+07
3 | 2017-08-06 23:59:59+07 | 2017-07-07 10:41:43.840404+07
4 | 2017-09-06 23:59:59+07 | 2017-07-07 10:41:43.851223+07

(4 rows)

Function

CREATE OR REPLACE FUNCTION test.list_date_records(_start_date timestamp with time zone, _end_date timestamp with time zone)
 RETURNS TABLE (
 dated_record_id integer, -- same as selected column datatype
 create_date timestamptz, -- same as selected column datatype
 update_date timestamptz  -- same as selected column datatype
 )
 AS $function$
 BEGIN
        return QUERY EXECUTE
            $q$
                SELECT
                  dr.dated_record_id,
                  dr.create_date,
                  dr.update_date
                FROM test.dated_records dr
                WHERE dr.create_date BETWEEN $1 AND $2
                ORDER BY dr.create_date DESC
            $q$
            using _start_date, _end_date;
       return;
    END
$function$
LANGUAGE plpgsql
SECURITY DEFINER;

Execute

stackoverflow=# SELECT * FROM test.list_date_records('2017-06-08 00:00:00', '2017-07-06 23:59:59');
 dated_record_id |      create_date       |          update_date
-----------------+------------------------+-------------------------------
               2 | 2017-07-06 23:59:59+07 | 2017-07-07 10:41:43.828373+07
               1 | 2017-06-08 00:00:00+07 | 2017-07-07 10:41:43.755836+07
(2 rows)


问:
WMI query to Read 'Microsoft-Windows-AppLocker/EXE and DLL' C#
I have created an agent to read windows event using WMI. I ma using the agent from last 3 years to collect events. It is used in a SEIM product. The query looks like

```<code>SELECT * FROM Win32_NTLogEvent where LogFile = 'System' or logFile='Active Directory Web Services'
</code>```

I am able to get the events properly. But Now I want to read apploacker events 'Microsoft-Windows-AppLocker/EXE and DLL' (Application and Security Logs -> Microsoft -> Windows -> AppLocker -> Exe And DLL).

I tried the below query but it returns zero record though I have 40+ records in it. I can see the record in event viewer.

```<code>SELECT * FROM Win32_NTLogEvent where LogFile = 'Microsoft-Windows-AppLocker/EXE and DLL'
</code>```

I have tried with "wbemtest" but no record with no error.

I am not sure if this can be achieved by any other way using WMI. I know Powershell has a cmdlet and through which I am able to read 'Microsoft-Windows-AppLocker/EXE and DLL' events. But I want to read it using WMI.

Any pointers will be highly appreciated.

Thanks in advance to all viewers.

答:
Depending on the PowerShell version, you could use the "Get-WinEvent" command to simplify what you're doing.

https://msdn.microsoft.com/en-us/powershell/reference/5.0/microsoft.powershell.diagnostics/get-winevent

Get-WinEvent -LogName "Microsoft-Windows-AppLocker/EXE and DLL"

Body:
I have created an agent to read windows event using WMI. I ma using the agent from last 3 years to collect events. It is used in a SEIM product. The query looks like

SELECT * FROM Win32_NTLogEvent where LogFile = 'System' or logFile='Active Directory Web Services'

I am able to get the events properly. But Now I want to read apploacker events 'Microsoft-Windows-AppLocker/EXE and DLL' (Application and Security Logs -> Microsoft -> Windows -> AppLocker -> Exe And DLL).

I tried the below query but it returns zero record though I have 40+ records in it. I can see the record in event viewer.

SELECT * FROM Win32_NTLogEvent where LogFile = 'Microsoft-Windows-AppLocker/EXE and DLL'

I have tried with "wbemtest" but no record with no error.

I am not sure if this can be achieved by any other way using WMI. I know Powershell has a cmdlet and through which I am able to read 'Microsoft-Windows-AppLocker/EXE and DLL' events. But I want to read it using WMI.

Any pointers will be highly appreciated.

Thanks in advance to all viewers.


问:
How to modify i in an R loop?
I have several large R objects saved as .RData files: "this.RData", "that.RData", "andTheOther.RData" and so on. I don't have enough memory, so I want to load each in a loop, extract some rows, and unload it. However, once I load(i), I need to strip the ".RData" part of (i) before I can do anything with objects "this", "that", "andTheOther". I want to do the opposite of what is described in How to iterate over file names in a R script? How can I do that? Thx

Edit: I omitted to mention the files are not in the working directory and have a filepath as well. I came across Getting filename without extension in R and file_path_sans_ext takes out the extension but the rest of the path is still there.

答:
A simple way to do this using would be to extract the base name from the filepaths with base::basename() and then remove the file extension with tools::file_path_sans_ext().

```<code>paths_to_files <- c("./path/to/this.RData", "./another/path/to/that.RData")

tools::file_path_sans_ext(
  basename(
    paths_to_files
  )
)

## Returns:
## [1] "this" "that"
</code>```

Title: How to modify i in an R loop?

Body:
A simple way to do this using would be to extract the base name from the filepaths with base::basename() and then remove the file extension with tools::file_path_sans_ext().

paths_to_files <- c("./path/to/this.RData", "./another/path/to/that.RData")

tools::file_path_sans_ext(
  basename(
    paths_to_files
  )
)

## Returns:
## [1] "this" "that"


问:
On linux ubuntu 16 32bit, DrPaulcarter assembly language tutorial, undefined reference error
I'm new in assembly language, so i am following Dr.Paul Carter's pcasm tutorial(
http://pacman128.github.io/pcasm/
).

Exactly pdf file(http://pacman128.github.io/static/pcasm-book.pdf) page-33, and book's page-23

From that site, i downloaded Linux Example (http://pacman128.github.io/static/linux-ex.zip)

and at the terminal i input

nasm -f coff first.asm

gcc -c driver.c

nasm -f coff asm_io.o

gcc -o first driver.o first.o asm_io.o

But it returned it

Where is problem?

(Screenshot's command -lc is no matter, if there is no -lc, it returned the same thing)

答: I found that error is from asm_io.asm. You should have to modify asm_io.asm or check define lines.


Title: Python split not recognizing hyphen

Body:
I imported a table with the years that each coach served as the football coach. Some of the years listed look like this: "1903–1910, 1917, 1919"

I am aiming for [1903, 1904, 1905, 1906, 1907, 1908, 1909, 1910, 1917, 1919]

In my original DataFrame this list is an object.

I have tried:

x = "1903–1910, 1917, 1919"

x[0].split('-')

re.split(r'\s|-', x[0])

x[0].replace('-', ' ').split(' ')

I keep getting:

['1903–1910']

What am I doing wrong? Why isn't python finding the hyphen?

Body:
Your character is not an hyfen, it's a dash:

>>> "–" == "-"
False
>>> x = "1903–1910, 1917, 1919"
>>> x.split("–")
['1903', '1910, 1917, 1919']


问:
How to prevent bad optimization of CROSS APPLY with Inline Table-Valued Function
I have an inline table valued function which runs a query on an OLE-DB linked server, defined as follows:

```<code> CREATE FUNCTION [dbo].[fnGetResultsForTag]
 (
    @elapsedTimeTag NVARCHAR(50)
 )
 RETURNS TABLE
 AS
 RETURN
 (
    SELECT tag, time, value
    FROM PI.piarchive..picount
    WHERE tag = @elapsedTimeTag
        AND filterexpr = QUOTENAME(@elapsedTimeTag, '''') + ' > NEXTVAL(' + QUOTENAME(@elapsedTimeTag, '''') + ', ''*'')'
        AND time BETWEEN (SELECT result FROM PI.pifunction..date WHERE arg1='t-20h') AND (SELECT result FROM PI.pifunction..date WHERE arg1='*')
        AND timestep = (SELECT result FROM PI.pifunction..time WHERE arg1='12h')
        AND calcbasis = 'EventWeighted'
 )
 GO
</code>```

It is called from a stored procedure like this:

```<code>SELECT results.*
FROM PI.pipoint..pipoint2 points
CROSS APPLY dbo.fnGetResultsForTag(points.tag) AS results
WHERE points.tag LIKE @TagPattern
ORDER BY time ASC, tag ASC
</code>```

MS documentation says that:

The APPLY operator works in the following way to produce the table source for the FROM clause:

Evaluates right_table_source against each row of the left_table_source to produce rowsets.

The values in the right_table_source depend on left_table_source. right_table_source can be represented approximately this way: TVF(left_table_source.row), where TVF is a table-valued function.

Combines the result sets that are produced for each row in the evaluation of right_table_source with the left_table_source by performing a UNION ALL operation.

The list of columns produced by the result of the APPLY operator is the set of columns from the left_table_source that is combined with the list of columns from the right_table_source.

That's exactly the behavior that I want. But it's not what SQL Server is actually doing.

What actually happens is that the SQL Server query optimizer is trying to optimize the TVF subqueries by running one SELECT FROM PI.piarchive..picount query on the remote server, without the tag = @elapsedTimeTag and filterexpr = <stuff> expressions in the WHERE clause, and then do a join within SQL Server to select only the data for the specified tags.

Unfortunately this is an incorrect optimization. The picount table is a view on an underlying database which contains thousands of tags. If the tag = @elapsedTimeTag filter criteria is not supplied to the remote server, the query times out. And the filterexpr=<stuff> criteria needs to match the same tagname as the tag criteria, in order to get the correct answers. So I really need to run one TVF remote subquery for each row in the left-hand table.

How do I hint/force SQL Server to actually run the table-valued function's query once for each row in the left-hand table of the CROSS APPLY, instead of what it's currently doing?

I have tried refactoring the outer query to explicitly select the tag list first, but it doesn't seem to help:

```<code>DECLARE @TagNames AS TABLE (tag NVARCHAR(50) NOT NULL)

INSERT INTO @TagNames
SELECT tag FROM PI.pipoint..pipoint2 WHERE tag LIKE @TagPattern

SELECT results.*
FROM @TagNames t
CROSS APPLY dbo.fnGetResultsForTag(t.tag) AS results
ORDER BY time ASC, tag ASC
</code>```

答:
Rewriting dbo.fnGetResultsForTag as a Multistatement Table Value Function (MTVF), instead of an Inline Table Value Function (ITVF), seems to have the desired effect of prohibiting this "optimization".

But it feels awkwardly like relying on an implementation detail, so I'm still interested in alternative solutions which explicitly instruct the query optimizer not to "flatten" the ITVF sub-queries.

Body:
I have an inline table valued function which runs a query on an OLE-DB linked server, defined as follows:

 CREATE FUNCTION [dbo].[fnGetResultsForTag]
 (
    @elapsedTimeTag NVARCHAR(50)
 )
 RETURNS TABLE
 AS
 RETURN
 (
    SELECT tag, time, value
    FROM PI.piarchive..picount
    WHERE tag = @elapsedTimeTag
        AND filterexpr = QUOTENAME(@elapsedTimeTag, '''') + ' > NEXTVAL(' + QUOTENAME(@elapsedTimeTag, '''') + ', ''*'')'
        AND time BETWEEN (SELECT result FROM PI.pifunction..date WHERE arg1='t-20h') AND (SELECT result FROM PI.pifunction..date WHERE arg1='*')
        AND timestep = (SELECT result FROM PI.pifunction..time WHERE arg1='12h')
        AND calcbasis = 'EventWeighted'
 )
 GO

It is called from a stored procedure like this:

SELECT results.*
FROM PI.pipoint..pipoint2 points
CROSS APPLY dbo.fnGetResultsForTag(points.tag) AS results
WHERE points.tag LIKE @TagPattern
ORDER BY time ASC, tag ASC

MS documentation says that:

The APPLY operator works in the following way to produce the table source for the FROM clause:

Evaluates right_table_source against each row of the left_table_source to produce rowsets.

The values in the right_table_source depend on left_table_source. right_table_source can be represented approximately this way: TVF(left_table_source.row), where TVF is a table-valued function.

Combines the result sets that are produced for each row in the evaluation of right_table_source with the left_table_source by performing a UNION ALL operation.

The list of columns produced by the result of the APPLY operator is the set of columns from the left_table_source that is combined with the list of columns from the right_table_source.

That's exactly the behavior that I want. But it's not what SQL Server is actually doing.

What actually happens is that the SQL Server query optimizer is trying to optimize the TVF subqueries by running one SELECT FROM PI.piarchive..picount query on the remote server, without the tag = @elapsedTimeTag and filterexpr = <stuff> expressions in the WHERE clause, and then do a join within SQL Server to select only the data for the specified tags.

Unfortunately this is an incorrect optimization. The picount table is a view on an underlying database which contains thousands of tags. If the tag = @elapsedTimeTag filter criteria is not supplied to the remote server, the query times out. And the filterexpr=<stuff> criteria needs to match the same tagname as the tag criteria, in order to get the correct answers. So I really need to run one TVF remote subquery for each row in the left-hand table.

How do I hint/force SQL Server to actually run the table-valued function's query once for each row in the left-hand table of the CROSS APPLY, instead of what it's currently doing?

I have tried refactoring the outer query to explicitly select the tag list first, but it doesn't seem to help:

DECLARE @TagNames AS TABLE (tag NVARCHAR(50) NOT NULL)

INSERT INTO @TagNames
SELECT tag FROM PI.pipoint..pipoint2 WHERE tag LIKE @TagPattern

SELECT results.*
FROM @TagNames t
CROSS APPLY dbo.fnGetResultsForTag(t.tag) AS results
ORDER BY time ASC, tag ASC


问:
XPCOM error in maven SWT project on windows 10 64 bit
I am trying to run simplest example of SWT browser with MOZILLA as default renderer. and getting this error

```<code>--- exec-maven-plugin:1.2.1:exec (default-cli) @ SwtBrowser ---
Exception in thread "main" org.eclipse.swt.SWTError: XPCOM error 0x80004005
    at org.eclipse.swt.browser.Mozilla.error(Unknown Source)
    at org.eclipse.swt.browser.Mozilla.initXULRunner(Unknown Source)
    at org.eclipse.swt.browser.Mozilla.create(Unknown Source)
    at org.eclipse.swt.browser.Browser.<init>(Unknown Source)
    at dev.nazm.swt.Mozilla.main(Mozilla.java:57)
------------------------------------------------------------------------
</code>```

I googled this problem and got these answers, but none of these are any help

Creating a SWT.MOZILLA browser on Windows 64 bit and SWT 4.3

How to make SWT Browser control use mozilla instead of IE on Windows

Cannot run due to XPCOM error 0x80004005 #48

The SWT FAQ

And some other links on eclipse support. But nothing helped me

This is my pom.xml

```<code>    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>dev.nazm</groupId>
    <artifactId>SwtBrowser</artifactId>
    <packaging>jar</packaging>
    <version>1.0</version>
    <name>SwtBrowser</name>
    <url>http://maven.apache.org</url>

    <repositories>
        <repository>
            <id>maven-eclipse-repo</id>
            <url>http://maven-eclipse.github.io/maven</url>
        </repository>
    </repositories>

    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>${swtGroup}</groupId>
            <artifactId>${swtArtifact}</artifactId>
            <version>${swtVersion}</version>
        </dependency>

        <dependency>
            <groupId>naz.dev</groupId>
            <artifactId>javafx.embed.swt</artifactId>
            <version>8.0.0-Final</version>
        </dependency>

        <dependency>
            <groupId>org.apache.maven.shared</groupId>
            <artifactId>maven-invoker</artifactId>
            <version>3.0.0</version>
        </dependency>

        <dependency>
            <groupId>org.jogamp.gluegen</groupId>
            <artifactId>gluegen-rt-main</artifactId>
            <version>2.3.2</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.jogamp.jogl/jogl-all-main -->
        <dependency>
            <groupId>org.jogamp.jogl</groupId>
            <artifactId>jogl-all-main</artifactId>
            <version>2.3.2</version>
        </dependency>
        <dependency>
            <groupId>org.osgi</groupId>
            <artifactId>osgi.core</artifactId>
            <version>6.0.0</version>
            <type>jar</type>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.eclipse.core/org.eclipse.core.runtime -->
        <dependency>
            <groupId>org.eclipse.core</groupId>
            <artifactId>org.eclipse.core.runtime</artifactId>
            <version>3.7.0</version>
        </dependency>

    </dependencies>

    <profiles>
        <profile>
            <id>mac</id>
            <activation>
                <os>
                    <name>Mac OS X</name>
                    <arch>x86_64</arch>
                </os>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>exec-maven-plugin</artifactId>
                        <version>1.6.0</version>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>exec</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <executable>java</executable>
                            <arguments>
                                <argument>-XstartOnFirstThread</argument>
                                <argument>-classpath</argument>
                                <classpath/>
                                <argument>dev.nazm.browser.SwtBrowser</argument>
                            </arguments>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
            <properties>
                <swtGroup>org.eclipse.swt</swtGroup>
                <swtArtifact>org.eclipse.swt.cocoa.macosx.x86_64</swtArtifact>
                <swtVersion>4.4</swtVersion>
            </properties>
        </profile>

        <profile>
            <id>windows10_64</id>
            <activation>
                <os>
                    <name>windows 10</name>
                    <family>Windows</family>
                    <arch>amd64</arch>
                </os>
            </activation>
            <properties>
                <swtGroup>org.eclipse.swt</swtGroup>
                <swtArtifact>org.eclipse.swt.win32.win32.x86_64</swtArtifact>
                <swtVersion>4.4</swtVersion>
            </properties>
        </profile>

        <profile>
            <id>windows32</id>
            <activation>
                <os>
                    <family>Windows</family>
                    <arch>x86</arch>
                </os>
            </activation>
            <properties>
                <swtGroup>org.eclipse.swt</swtGroup>
                <swtArtifact>org.eclipse.swt.win32.win32.x86</swtArtifact>
                <swtVersion>4.4</swtVersion>
                <!--<classifier>debug</classifier>-->
            </properties>
        </profile>
    </profiles>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <version>2.3</version>
                <configuration>
                    <!-- specify UTF-8, ISO-8859-1 or any other file encoding -->
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>

            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <configuration>
                    <archive>
                        <manifest>
                            <mainClass>dev.nazm.browser.SwtBrowser</mainClass>
                        </manifest>
                    </archive>
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>
</project>
</code>```

I have downloaded xulrunner 24.0 and extracted it to C:\Program Files\xulrunner24 .

This is my main class

```<code>public class SwtBrowser {
    public static void main(String[] args) {
        String path = "C:\\Program Files\\xulrunner24";
        System.getProperties().setProperty("org.eclipse.swt.browser.XULRunnerPath",path);
        Display display = new Display();
        Shell shell = new Shell(display);
        shell.setLayout(new FillLayout());
        Browser browser = new Browser(shell, SWT.MOZILLA);
        browser.setUrl("https://chromium.github.io/octane/");
        shell.open();
        while (!shell.isDisposed()) {
            if (!display.readAndDispatch()) {
                display.sleep();
            }
        }
        display.dispose();
    }
}
</code>```

This is my java version

```<code>java -version
java version "1.8.0_60"
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)`
</code>```

I am trying this on Windows 10 amd64 environment.
I have installed Mozilla FirefoxESR 24.0 on my computer.
I have installed VisualC++ Redistributable also

Now my questions are ?

Does Firefox version installed on my PC needs to meet version of xulrunner.

As SWT FAQ says requirements  of Windows (x86_64):

Any XULRunner release with version 1.9.2.x - 3.6.x, 10.x or 24.x, and
  the Visual C++ 2010 runtime must be installed

Does OS architecture matters for xulrunner?

I have installed eclipse neon 3, and tried creating a project and adding runtime arguments in .ini file. But still got the same issue. So final question is how to run it in a maven project on a Windows 64 bit platform.

答:
With 64-bit 4.3 SWT (and 4.4 - I've only tested those two) I was able to run your code by using XULRunner version 1.9.2.25 runtime.

I also had to update your pom.xml to pull 64-bit SWT (org.eclipse.swt.win32.win32.x86_64 instead of org.eclipse.swt.win32.win32.x86) because of the 64-bit JVM (1.8.0_131 in my case).

Originally I found the xulrunner download from here: https://osdn.net/projects/sfnet_runawfe/downloads/SRC%20and%20BIN%20files/extras/xulrunner-1.9.2.25-win64.zip/

However, I have also re-hosted it as xulrunner-1.9.2.25.en-US.win64.zip in my repository.

In regards to doing this in a Maven project, I'm not sure. You could simply package it with your application in a lib directory. If it would help to have the xulrunner runtime packaged and put in a Maven repository I can host it that was as well (our you can host it yourself on a repo that you own).

Let me know if this doesn't work and I'll be happy to take another look.

Body:
I am trying to run simplest example of SWT browser with MOZILLA as default renderer. and getting this error

--- exec-maven-plugin:1.2.1:exec (default-cli) @ SwtBrowser ---
Exception in thread "main" org.eclipse.swt.SWTError: XPCOM error 0x80004005
    at org.eclipse.swt.browser.Mozilla.error(Unknown Source)
    at org.eclipse.swt.browser.Mozilla.initXULRunner(Unknown Source)
    at org.eclipse.swt.browser.Mozilla.create(Unknown Source)
    at org.eclipse.swt.browser.Browser.<init>(Unknown Source)
    at dev.nazm.swt.Mozilla.main(Mozilla.java:57)
------------------------------------------------------------------------

I googled this problem and got these answers, but none of these are any help

Creating a SWT.MOZILLA browser on Windows 64 bit and SWT 4.3

How to make SWT Browser control use mozilla instead of IE on Windows

Cannot run due to XPCOM error 0x80004005 #48

The SWT FAQ

And some other links on eclipse support. But nothing helped me

This is my pom.xml

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>dev.nazm</groupId>
    <artifactId>SwtBrowser</artifactId>
    <packaging>jar</packaging>
    <version>1.0</version>
    <name>SwtBrowser</name>
    <url>http://maven.apache.org</url>

    <repositories>
        <repository>
            <id>maven-eclipse-repo</id>
            <url>http://maven-eclipse.github.io/maven</url>
        </repository>
    </repositories>

    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>${swtGroup}</groupId>
            <artifactId>${swtArtifact}</artifactId>
            <version>${swtVersion}</version>
        </dependency>

        <dependency>
            <groupId>naz.dev</groupId>
            <artifactId>javafx.embed.swt</artifactId>
            <version>8.0.0-Final</version>
        </dependency>

        <dependency>
            <groupId>org.apache.maven.shared</groupId>
            <artifactId>maven-invoker</artifactId>
            <version>3.0.0</version>
        </dependency>

        <dependency>
            <groupId>org.jogamp.gluegen</groupId>
            <artifactId>gluegen-rt-main</artifactId>
            <version>2.3.2</version>
        </dependency>

        <dependency>
            <groupId>org.jogamp.jogl</groupId>
            <artifactId>jogl-all-main</artifactId>
            <version>2.3.2</version>
        </dependency>
        <dependency>
            <groupId>org.osgi</groupId>
            <artifactId>osgi.core</artifactId>
            <version>6.0.0</version>
            <type>jar</type>
        </dependency>

        <dependency>
            <groupId>org.eclipse.core</groupId>
            <artifactId>org.eclipse.core.runtime</artifactId>
            <version>3.7.0</version>
        </dependency>

    </dependencies>

    <profiles>
        <profile>
            <id>mac</id>
            <activation>
                <os>
                    <name>Mac OS X</name>
                    <arch>x86_64</arch>
                </os>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>exec-maven-plugin</artifactId>
                        <version>1.6.0</version>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>exec</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <executable>java</executable>
                            <arguments>
                                <argument>-XstartOnFirstThread</argument>
                                <argument>-classpath</argument>
                                <classpath/>
                                <argument>dev.nazm.browser.SwtBrowser</argument>
                            </arguments>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
            <properties>
                <swtGroup>org.eclipse.swt</swtGroup>
                <swtArtifact>org.eclipse.swt.cocoa.macosx.x86_64</swtArtifact>
                <swtVersion>4.4</swtVersion>
            </properties>
        </profile>

        <profile>
            <id>windows10_64</id>
            <activation>
                <os>
                    <name>windows 10</name>
                    <family>Windows</family>
                    <arch>amd64</arch>
                </os>
            </activation>
            <properties>
                <swtGroup>org.eclipse.swt</swtGroup>
                <swtArtifact>org.eclipse.swt.win32.win32.x86_64</swtArtifact>
                <swtVersion>4.4</swtVersion>
            </properties>
        </profile>

        <profile>
            <id>windows32</id>
            <activation>
                <os>
                    <family>Windows</family>
                    <arch>x86</arch>
                </os>
            </activation>
            <properties>
                <swtGroup>org.eclipse.swt</swtGroup>
                <swtArtifact>org.eclipse.swt.win32.win32.x86</swtArtifact>
                <swtVersion>4.4</swtVersion>

            </properties>
        </profile>
    </profiles>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <version>2.3</version>
                <configuration>

                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>

            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <configuration>
                    <archive>
                        <manifest>
                            <mainClass>dev.nazm.browser.SwtBrowser</mainClass>
                        </manifest>
                    </archive>
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>
</project>

I have downloaded xulrunner 24.0 and extracted it to C:\Program Files\xulrunner24 .

This is my main class

public class SwtBrowser {
    public static void main(String[] args) {
        String path = "C:\\Program Files\\xulrunner24";
        System.getProperties().setProperty("org.eclipse.swt.browser.XULRunnerPath",path);
        Display display = new Display();
        Shell shell = new Shell(display);
        shell.setLayout(new FillLayout());
        Browser browser = new Browser(shell, SWT.MOZILLA);
        browser.setUrl("https://chromium.github.io/octane/");
        shell.open();
        while (!shell.isDisposed()) {
            if (!display.readAndDispatch()) {
                display.sleep();
            }
        }
        display.dispose();
    }
}

This is my java version

java -version
java version "1.8.0_60"
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)`

I am trying this on Windows 10 amd64 environment.
I have installed Mozilla FirefoxESR 24.0 on my computer.
I have installed VisualC++ Redistributable also

Now my questions are ?

Does Firefox version installed on my PC needs to meet version of xulrunner.

As SWT FAQ says requirements  of Windows (x86_64):

Any XULRunner release with version 1.9.2.x - 3.6.x, 10.x or 24.x, and
  the Visual C++ 2010 runtime must be installed

Does OS architecture matters for xulrunner?

I have installed eclipse neon 3, and tried creating a project and adding runtime arguments in .ini file. But still got the same issue. So final question is how to run it in a maven project on a Windows 64 bit platform.


答:
If you examine that input, you'll see it's taking its color from the following code block, which has more specific selectors:

```<code>.login_content .container input[type="submit"]{
width: auto;
padding: 10px 50px;
border-radius: 25px;
background: #e8e8e8;
color: #c5c5c5;
text-transform: uppercase;
border: none;
cursor: pointer;
}
</code>```

Also, this rule on the input tag, says the text color should be transparent:

```<code>-webkit-text-fill-color: transparent;
</code>```

Here's your jsFiddle with red text.

Use your browser's dev tools to for this type of debugging.

Body:
If you examine that input, you'll see it's taking its color from the following code block, which has more specific selectors:

.login_content .container input[type="submit"]{
width: auto;
padding: 10px 50px;
border-radius: 25px;
background: #e8e8e8;
color: #c5c5c5;
text-transform: uppercase;
border: none;
cursor: pointer;
}

Also, this rule on the input tag, says the text color should be transparent:

-webkit-text-fill-color: transparent;

Here's your jsFiddle with red text.

Use your browser's dev tools to for this type of debugging.


问:
Getting directory listing over http
There is a directory that is being served over the net which I'm interested in monitoring. Its contents are various versions of software that I'm using and I'd like to write a script that I could run which checks what's there, and downloads anything that is newer that what I've already got.

Is there a way, say with wget or something, to get a a directory listing. I've tried using wget on the directory, which gives me html. To avoid having to parse the html document, is there a way of retrieving a simple listing like ls would give?

答: AFAIK, there is no way to get a directory listing like that for security purposes. It is rather lucky that your target directory has the HTML listing because it does allow you to parse it and discover new downloads.</p>

Title: Getting directory listing over http


问:
How to replace values in specific lines and on determined conditions
I'm in trouble: I have a dataset with 128597 lines and 10 columns.
I need to change the values from column 10 between line 10276 until 128597.

And this change have to respect some conditions, like:
If the value is between 11 and 33, the value will become 1
If the value is between 34 and 56, the value will become 5
And go on...

I tried the code below, but didn't work:

m(10276:128597,10) > 11 & m(10276:128597,10)< 33=1;

Can anyone help me please!!! :)

Body:
i think this may be help

a=[1,2,3;2,3,4;3,2,1;2,4,1];
amask=false(size(a));
amask(2:3,3)= a(2:3,3)>3;
a(amask)=9999;

and the ans is

a =

 1     2     3
 2     3     4
 3     2     1
 2     4     1

a =

       1           2           3
       2           3        9999
       3           2           1
       2           4           1