问:
Get the content of siblings elements with jQuery
I need to get the content of some specific elements using jquery, the problem is that i have the same element repeating on my page:

```<code><div class="content">
   <img alt="" src="">
   <p class="txt">Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>
   <p class="info">Lorem ipsum dolor...</p>
   <ul>
     <li><a class="uiButton">Test</a></li>
   </ul>
 </div>
</code>```

So, the div.content repeat on my page many times and I want to get only the contents of the div that holds the button was clicked. I've added a onclick event on the .uiButton and tried to use parent(".txt") or siblings(".txt"), but dont seems to work...

```<code>$(".uiButton").click(function(){
  var txt = $(this).parent(".txt").text();
}
</code>```

答:
.txt isn't a parent, and even then it has to be a direct parent (.parent() matches the immediate parent if it matches the selector), instead you need:

```<code>$(".uiButton").click(function(){
  var txt = $(this).closest("ul").siblings(".txt").text();
});
</code>```

The alternative is to go all the way up to .content (via .closest()) to be safe then traverse down with .find():

```<code>$(".uiButton").click(function(){
  var txt = $(this).closest(".content").find(".txt").text();
});
</code>```

Body:
I need to get the content of some specific elements using jquery, the problem is that i have the same element repeating on my page:

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

Lorem ipsum dolor...

Test

So, the div.content repeat on my page many times and I want to get only the contents of the div that holds the button was clicked. I've added a onclick event on the .uiButton and tried to use parent(".txt") or siblings(".txt"), but dont seems to work...

$(".uiButton").click(function(){
  var txt = $(this).parent(".txt").text();
}

Body:
.txt isn't a parent, and even then it has to be a direct parent (.parent() matches the immediate parent if it matches the selector), instead you need:

$(".uiButton").click(function(){
  var txt = $(this).closest("ul").siblings(".txt").text();
});

The alternative is to go all the way up to .content (via .closest()) to be safe then traverse down with .find():

$(".uiButton").click(function(){
  var txt = $(this).closest(".content").find(".txt").text();
});


来源: stackexchange

问:
Declare Variable of Child Class Type in Abstract Class
I would like to enforce that a function in a child class is the type of the class from the abstract parent. For example:

```<code>abstract class Animal {
    public abstract void Add(Animal animal);
}

class Cat: Animal {
    public override void Add(Cat cat) {
        //Do cat things
    }
}

class Dog: Animal {
    //This should not be allowed
    public override void Add(Animal dog) {
        //Do dog things
    }
}
</code>```

Here we see that a Cat type object could be passed to Dog.Add. Is there a way to enforce the function to take type Dog?

I believe there are ways for it to be checked at run time, but I would much rather have a compiler error if possible.

答:
You might declare an interface and use generics with a where constraint.

```<code>public abstract class Animal
{
}

public interface IAnimalCollection<T> where T : Animal
{
    void Add<T>(T animal);
}

public class Cat : Animal, IAnimalCollection<Cat>
{
    public void Add(Cat animal)
    {
    }
}

public class Dog : Animal, IAnimalCollection<Dog>
{
    // won't compile
    public void Add(Animal animal)
    {
    }
}

public class Ferret : IAnimalCollection<Ferret>
{
    public void Add(Ferret animal)
    {
    }

    public void Add(Animal animal)
    {
    }
}

// won't compile
public class Foo : IAnimalCollection<Foo>
{
    public void Add(Foo animal)
    {
    }
}
</code>```

ContentLicense: CC BY-SA 3.0

Body:
I would like to enforce that a function in a child class is the type of the class from the abstract parent. For example:

abstract class Animal {
    public abstract void Add(Animal animal);
}

class Cat: Animal {
    public override void Add(Cat cat) {
        //Do cat things
    }
}

class Dog: Animal {
    //This should not be allowed
    public override void Add(Animal dog) {
        //Do dog things
    }
}

Here we see that a Cat type object could be passed to Dog.Add. Is there a way to enforce the function to take type Dog?

I believe there are ways for it to be checked at run time, but I would much rather have a compiler error if possible.

Body:
You might declare an interface and use generics with a where constraint.

public abstract class Animal
{
}

public interface IAnimalCollection<T> where T : Animal
{
    void Add<T>(T animal);
}

public class Cat : Animal, IAnimalCollection<Cat>
{
    public void Add(Cat animal)
    {
    }
}

public class Dog : Animal, IAnimalCollection<Dog>
{
    // won't compile
    public void Add(Animal animal)
    {
    }
}

public class Ferret : IAnimalCollection<Ferret>
{
    public void Add(Ferret animal)
    {
    }

    public void Add(Animal animal)
    {
    }
}

// won't compile
public class Foo : IAnimalCollection<Foo>
{
    public void Add(Foo animal)
    {
    }
}


问:
eslint should be listed in the project's dependencies, not devDependencies
Either I don't understand dependencies vs. devDependencies in node 100% yet or eslint is just wrong here (not capable of analyzing this correctly):

```<code>   3:1   error  'chai' should be listed in the project's dependencies, not devDependencies              import/no-extraneous-dependencies
   4:1   error  'chai-enzyme' should be listed in the project's dependencies, not devDependencies       import/no-extraneous-dependencies
   5:1   error  'enzyme' should be listed in the project's dependencies, not devDependencies            import/no-extraneous-dependencies
   7:1   error  'sinon' should be listed in the project's dependencies, not devDependencies             import/no-extraneous-dependencies
   9:1   error  'redux-mock-store' should be listed in the project's dependencies, not devDependencies  import/no-extraneous-dependencies
</code>```

These are test dependencies, so why is it saying that they should be listed in dependencies?

Additional note: We're using Travis as our CI so I don't know if it makes a difference for that at all either.

答:
Solved it with adding this to my .eslintrc:

"import/no-extraneous-dependencies": ["error", {"devDependencies": true}]

[no-extraneous-dependencies] Add exceptions? #422

Based on this user's reply:

you could set the option devDependencies: true in an .eslintrc in your
  test folder:

rules:   import/no-extraneous-dependencies: [error, { devDependencies:
  true }] Then you'll get reports of any packages referenced that are
  not included dependencies or devDependencies. Then you get the
  goodness of the rule, with no noise from the disable comments.

I think that might work for you? This is how I would use the rule, in
  your case, since you have your test code separated into a test
  directory.

Also this post was helpful to confirm I wasn't insane to not want some of these in my dependencies list: Sharable ESLint Config

Body:
Either I don't understand dependencies vs. devDependencies in node 100% yet or eslint is just wrong here (not capable of analyzing this correctly):

   3:1   error  'chai' should be listed in the project's dependencies, not devDependencies              import/no-extraneous-dependencies
   4:1   error  'chai-enzyme' should be listed in the project's dependencies, not devDependencies       import/no-extraneous-dependencies
   5:1   error  'enzyme' should be listed in the project's dependencies, not devDependencies            import/no-extraneous-dependencies
   7:1   error  'sinon' should be listed in the project's dependencies, not devDependencies             import/no-extraneous-dependencies
   9:1   error  'redux-mock-store' should be listed in the project's dependencies, not devDependencies  import/no-extraneous-dependencies

These are test dependencies, so why is it saying that they should be listed in dependencies?

Additional note: We're using Travis as our CI so I don't know if it makes a difference for that at all either.


问:
How do I test which class an object is in Objective-C?
How do I test whether an object is an instance of a particular class in Objective-C? Let's say I want to see if object a is an instance of class b, or class c, how do I go about doing it?</p>

答:
You can also check run time. Put one breakpoint in code and inside (lldb) console write

```<code>(lldb) po [yourObject class]
</code>```

Like this..

Body:
You can also check run time. Put one breakpoint in code and inside (lldb) console write

(lldb) po [yourObject class]

Like this..


问:
iOS UI Test Error when tap second text field
I am working in UI Test iOS using. My test is to type 2 text fields firstName and lastName. This test is work in simulator iphone 6 and 7, but failed when I tried in simulator iphone 5 and SE. The error is in "txtFieldLastName.tap()" code which is when tapping the second text field. I have tried to disable Connect Hardware Keyboard of simulator but still failed. How to fix that? I am confused because in simulator iOS 6 or larger it's work.</p>

```<code>let txtFieldFirstName = app.textFields["firstName"]
let txtFieldLastName = app.textFields["lastName"]

txtFieldFirstName.tap()
txtFieldFirstName.typeText("First")
txtFieldLastName.tap()
txtFieldLastName.typeText("Last")
</code>```

答: The answer is try to dismiss keyboard before tap the second text field. thank you. </p>

Body:
I am working in UI Test iOS using. My test is to type 2 text fields firstName and lastName. This test is work in simulator iphone 6 and 7, but failed when I tried in simulator iphone 5 and SE. The error is in "txtFieldLastName.tap()" code which is when tapping the second text field. I have tried to disable Connect Hardware Keyboard of simulator but still failed. How to fix that? I am confused because in simulator iOS 6 or larger it's work.

let txtFieldFirstName = app.textFields["firstName"]
let txtFieldLastName = app.textFields["lastName"]

txtFieldFirstName.tap()
txtFieldFirstName.typeText("First")
txtFieldLastName.tap()
txtFieldLastName.typeText("Last")


问:
Sintaxis in xml request of Acumatica Export
I have a struggle for setting up a FILTER for my xml request for Acumatica.
Without filters this works fine. But when i include any filter I receive a BLANK response.

I believe I have an issue with a sintaxis.
Could you please advice me where I am wrong?

```<code> <commands>
   <Command>
     <FieldName>InventoryCD</FieldName>
     <ObjectName>Item</ObjectName>
     <Value>Inventory</Value>
       <Commit>1</Commit>
       <IgnoreError>0</IgnoreError>
       <LinkedCommand>
       <FieldName>InventoryCD</FieldName>
       <ObjectName>Item</ObjectName>
       <Value>[Item.InventoryCD]</Value>
       <Commit>1</Commit>
       <IgnoreError>0</IgnoreError>
       <LinkedCommand xsi:nil=""true"" />
       <Descriptor xsi:nil=""true"" />
    </LinkedCommand>

   </Command>
   <Command>
   <FieldName>InventoryCD!Descr</FieldName>
     <ObjectName>Item</ObjectName>
     <Value>Description</Value>
   </Command>

    <Command>
   <FieldName>AlternateID</FieldName>
     <ObjectName>itemxrefrecords</ObjectName>
     <Value>Manufacturer P/N</Value>
   </Command>
  </commands>

<filters>
    <Filter>
      <Field = InventoryCD.Item.Inventory/>
      <Condition>Contain</Condition>
      <Value = ""300""/>

    </Filter>
 </filters>

 <topCount>10</topCount>
 <includeHeaders>1</includeHeaders>
 <breakOnError>1</breakOnError>
</code>```

答:
So this fixed my problem

```<code><filters>
    <Filter>
        <Field>
            <FieldName>InventoryCD</FieldName>
            <ObjectName>Item</ObjectName>
            <Value>Inventory</Value>
        </Field>
        <Condition>StartsWith</Condition>
        <Value xsi:type="xsd:string" xmlns:xsd="http://www.w3.org/2001/XMLSchema">300</Value>
        <OpenBrackets>0</OpenBrackets>
        <CloseBrackets>0</CloseBrackets>
    </Filter>
</filters>
</code>```

cheers.

Body:
I have a struggle for setting up a FILTER for my xml request for Acumatica.
Without filters this works fine. But when i include any filter I receive a BLANK response.

I believe I have an issue with a sintaxis.
Could you please advice me where I am wrong?

 <commands>
   <Command>
     <FieldName>InventoryCD</FieldName>
     <ObjectName>Item</ObjectName>
     <Value>Inventory</Value>
       <Commit>1</Commit>
       <IgnoreError>0</IgnoreError>
       <LinkedCommand>
       <FieldName>InventoryCD</FieldName>
       <ObjectName>Item</ObjectName>
       <Value>[Item.InventoryCD]</Value>
       <Commit>1</Commit>
       <IgnoreError>0</IgnoreError>
       <LinkedCommand xsi:nil=""true"" />
       <Descriptor xsi:nil=""true"" />
    </LinkedCommand>

   </Command>
   <Command>
   <FieldName>InventoryCD!Descr</FieldName>
     <ObjectName>Item</ObjectName>
     <Value>Description</Value>
   </Command>

    <Command>
   <FieldName>AlternateID</FieldName>
     <ObjectName>itemxrefrecords</ObjectName>
     <Value>Manufacturer P/N</Value>
   </Command>
  </commands>

<filters>
    <Filter>
      <Field = InventoryCD.Item.Inventory/>
      <Condition>Contain</Condition>
      <Value = ""300""/>

    </Filter>
 </filters>

 <topCount>10</topCount>
 <includeHeaders>1</includeHeaders>
 <breakOnError>1</breakOnError>

Body:
So this fixed my problem

<filters>
    <Filter>
        <Field>
            <FieldName>InventoryCD</FieldName>
            <ObjectName>Item</ObjectName>
            <Value>Inventory</Value>
        </Field>
        <Condition>StartsWith</Condition>
        <Value xsi:type="xsd:string" xmlns:xsd="http://www.w3.org/2001/XMLSchema">300</Value>
        <OpenBrackets>0</OpenBrackets>
        <CloseBrackets>0</CloseBrackets>
    </Filter>
</filters>

cheers.


问:
Android Studio Gradle BuildTools Revision
I have an Android Project in Android Studio 0.5.9 and Gradle is throwing this error:

```<code>Error:The SDK Build Tools revision (17.0.0) is too low. Minimum required is 19.0.0
</code>```

I have already installed SDK Build Tools Revision 19 from the SDK Manager and here is my build.gradle

```<code>buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.10.+'
    }
}
apply plugin: 'android'

repositories {
    mavenCentral()
}

android {
    compileSdkVersion 17
    buildToolsVersion "19.0.0"

    defaultConfig {
        minSdkVersion 9
        targetSdkVersion 17
    }

    sourceSets {
        main {
            manifest.srcFile 'Manantiales/src/main/AndroidManifest.xml'
        }
    }
}
</code>```

How do I tell gradle to use the Build Tools 19 if it's already installed?

EDIT: I marked a different answer as The Best Answer because it was the one that worked for most people

答:
change in build.gradle "project: layout xml"</p>
```<code>buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.3'

    }
} allprojects {
    repositories {
        jcenter()

    }
}
</code>```

Body:
I have an Android Project in Android Studio 0.5.9 and Gradle is throwing this error:

Error:The SDK Build Tools revision (17.0.0) is too low. Minimum required is 19.0.0

I have already installed SDK Build Tools Revision 19 from the SDK Manager and here is my build.gradle

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.10.+'
    }
}
apply plugin: 'android'

repositories {
    mavenCentral()
}

android {
    compileSdkVersion 17
    buildToolsVersion "19.0.0"

    defaultConfig {
        minSdkVersion 9
        targetSdkVersion 17
    }

    sourceSets {
        main {
            manifest.srcFile 'Manantiales/src/main/AndroidManifest.xml'
        }
    }
}

How do I tell gradle to use the Build Tools 19 if it's already installed?

EDIT: I marked a different answer as The Best Answer because it was the one that worked for most people

Body:
change in build.gradle "project: layout xml"

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.3'

    }
} allprojects {
    repositories {
        jcenter()

    }
}

ContentLicense: CC BY-SA 4.0


问:
How do I check the exit code in Test::More?
According to Test::More documentation, it will exit with certain exit codes depending on the out come of your tests.
My question is, how do I check these exit codes?

ps. I am trying to build a harness myself. Is there a simple harness I can use?

ps2. Test::Harness did the trick for me. In particular execute_tests function. This function returns all the statistics I want. Thank you everyone who gave useful links.

答:
If you're calling your test program from Perl, then the hard (and traditional) way involves doing dark and horrid bit-shifts to $?.  You can read about that in the system function documentation if you really want to see how to do it.

The nice way involves using a module which gives you a system style function that processes return values for you:

```<code>use IPC::System::Simple qw(systemx EXIT_ANY);

my $exit_value = systemx( EXIT_ANY, 'mytest.t' );
</code>```

The EXIT_ANY symbol allows your script to return any exit value, which we can then capture.  If you just want to make sure that your scripts are passing (ie, returning a zero exit status), and halt as soon as any fail, that's IPC::System::Simple's default behaviour:

```<code>use IPC::System::Simple qw(systemx);

systemx( 'mytest.t' );  # Run this command successfully or die.
</code>```

In all the above examples, you can ask for a replacement system command rather than systemx if you're happy for the possibility of the shell getting involved.  See the IPC::System::Simple documentation for more details.

There are other modules that may allow you to easily run a command and capture its exit value.  TIMTOWTDI.

Having said that, all the good harnesses should check return values for you, so it's only if you're writing our own testing testers that you should need to look at this yourself.

All the best,

Paul

Disclosure: I wrote IPC::System::Simple, and so may have some positive bias toward it.

OwnerDisplayName: rick

ContentLicense: CC BY-SA 2.5

LastEditorDisplayName: rick

Body:
If you're calling your test program from Perl, then the hard (and traditional) way involves doing dark and horrid bit-shifts to $?.  You can read about that in the system function documentation if you really want to see how to do it.

The nice way involves using a module which gives you a system style function that processes return values for you:

use IPC::System::Simple qw(systemx EXIT_ANY);

my $exit_value = systemx( EXIT_ANY, 'mytest.t' );

The EXIT_ANY symbol allows your script to return any exit value, which we can then capture.  If you just want to make sure that your scripts are passing (ie, returning a zero exit status), and halt as soon as any fail, that's IPC::System::Simple's default behaviour:

use IPC::System::Simple qw(systemx);

systemx( 'mytest.t' );  # Run this command successfully or die.

In all the above examples, you can ask for a replacement system command rather than systemx if you're happy for the possibility of the shell getting involved.  See the IPC::System::Simple documentation for more details.

There are other modules that may allow you to easily run a command and capture its exit value.  TIMTOWTDI.

Having said that, all the good harnesses should check return values for you, so it's only if you're writing our own testing testers that you should need to look at this yourself.

All the best,

Paul

Disclosure: I wrote IPC::System::Simple, and so may have some positive bias toward it.

OwnerDisplayName: pjf


问:
Swift: import framework but can't find class in it
I import a swift framework to a swift project, but when I call the class in this framework, Xcode  throw a compile error "Use of undeclared type 'xxxx(class name)' ".

I feel Xcode have found the framework, otherwise it will complaint "can't find xxx(framework name)".

But why Xcode can't find the class of this framework.

I have tried remove and re-add framework, and delete DeivedData files, but all of them not work. I haven't use CocoaPods to import framework.

Any idea?

答: Make sure that the FrameWorkSearch path in the BuildSettings of the project is reflecting the correct path to your framework.</p>


问:
how to make div to new line
i am beginner to css.

i want to make new div into new line like this,

i try my code like this

```<code><style>
div{
  display:inline-block;
  float:left;
  color:#fff;
  font-size:20px;
}

.one{
  width:100px;
  height:100px;
  background:red;
}
.three{
    width:100px;
  height:100px;
}

.four{
  width:150px;
  height:50px;
background:darkblue;
}
.five{
  width:150px;
  height:50px;
background:blue;
}
 </style>

<div class="one">image</div>

<div class="three">
  <div class="four">name</div>
  <div class="five">desc</div>
</div>

<div class="one">image</div>

<div class="three">
  <div class="four">name</div>
  <div class="five">desc</div>
</div>

<div class="one">image</div>

<div class="three">
  <div class="four">name</div>
  <div class="five">desc</div>
</div>
</code>```

but result like this

how to move, the second image to new line..
pls anybody help me. i ll appreciate your answer

答: You should add clear:both or clear:left to make the div to be displayed in the new line

Title: how to make div to new line

Body:
i am beginner to css.

i want to make new div into new line like this,

i try my code like this

image

name

desc

image

name

desc

image

name

desc

but result like this

how to move, the second image to new line..
pls anybody help me. i ll appreciate your answer


答:
Try the following code after style tag

```<code><div class="one">image</div>

<div class="three">
  <div class="four">name</div>
  <div class="five">desc</div>
</div>
<br>

<div class="one">image</div>

  <div class="three">
  <div class="four">name</div>
  <div class="five">desc</div>
</div>
<br>

<div class="one">image</div>

<div class="three">
  <div class="four">name</div>
  <div class="five">desc</div>
</div>
</code>```

I think this is what you want to do

Hope it helps

Let me know if you require any further help

Title: how to make div to new line

Body:
Try the following code after style tag

<div class="one">image</div>

<div class="three">
  <div class="four">name</div>
  <div class="five">desc</div>
</div>
<br>

<div class="one">image</div>

  <div class="three">
  <div class="four">name</div>
  <div class="five">desc</div>
</div>
<br>

<div class="one">image</div>

<div class="three">
  <div class="four">name</div>
  <div class="five">desc</div>
</div>

I think this is what you want to do

Hope it helps

Let me know if you require any further help


问:
PHP files not working when using Bootstrap
I am new to Programming hence need some help. Below is the code I am using for a Contact Form using Bootstrap but my PHP code doesn't seem to work.
I have been keeping "index.php" file with other files of Bootstrap. But when I run this it shows an error and doesn't run.
And when I save this file as "index.html", the HTML part of the code runs but PHP files don't.
In order to run PHP file in wamp server where should I save the files in Bootstrap or in Wamp?</p>

```<code><?php

if ($_POST['submit']) {

    if(!$_POST['name']) {
        $error="<br/>-Please enter your name";
    }

    if(!$_POST['email']) {
        $error.="<br/>- Please enter your email";
    }

    if(!$_POST['subject']) {
        $error.="<br/>- Please enter a subject";
    }

    if(!$_POST['message']) {
        $error.="<br/>- Please enter a message";
    }

    if(!$_POST['check']) {
        $error.="<br/>- Please confirm you are human";
    }

    if($error) {
        $result="Whoops, there is an error; Please correct the following: $error";
    } else {
        mail("namitajamwal19@gmail.com", "Contact message", "Name: ".$_POST['name']."
        Email: ".$_POST['name']."
        Subject: ".$_POST['subject']."
        Message: ".$_POST['message']);"

        {
        $result="Thank you, I'll be in touch shortly";
        }
    }
}
?>

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
    <title>Contact Us</title>

    <!-- Bootstrap -->
    <link href="css/bootstrap.min.css" rel="stylesheet">

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>
  <body>

    <section id="contact">
        <div class="container">

            <div class="row">
                <div class="col-md-6 col-md-offset-3">
                    <h1>Contact Us</h1>

                    <?php echo $result;?>

                    <p>Send a message via the form below</p>

                    <form method="post" role="form">

                        <div class="form-group">
                            <input type="text" name="name" class="form-control" placeholder="Your Name" value="<?php echo $_POST['name']; ?>">
                        </div>

                        <div class="form-group">
                            <input type="email" name="email" class="form-control" placeholder="Your email" value="<?php echo $_POST['email']; ?>">
                        </div>

                        <div class="form-group">
                            <textarea name="subject" rows="5" class="form-control" placeholder="Subject"><?php echo $_POST['subject']; ?></textarea>
                        </div>

                        <div class="form-group">
                            <textarea name="message" rows="5" class="form-control" placeholder="Message..."><?php echo $_POST['message']; ?></textarea>
                        </div>

                        <div class="checkbox">
                            <label>
                                <input type="checkbox" name="check">I am Human
                            </label>
                        </div>

                        <div align="center">
                        <input type="submit" name="submit" class="btn btn-secondary" value="send message"/>
                        </div>
                    </form>

                </div>
            </div>

        </div>
    </section>

    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
    <!-- Include all compiled plugins (below), or include individual files as needed -->
    <script src="js/bootstrap.min.js"></script>
  </body>
</html>
</code>```

答:
I think You simply missing the point:

After reading your question I think you just put the project files directly into the www directory of wamp. so obesely that not gone work. Also, you mention that in index.html your PHP code is not working is also obvious error that to run a PHP code you need to give that file a .php extension.

In order to run PHP file in wamp server where should I save the files
  in Bootstrap or in Wamp?

To run a PHP file with WAMP you need to follow this basic step:

Install Wamp: Here is the all related detail about WAMP and you could download it and install on your local drive.  wampserver

After installing it go to the WAMP directory and find WWW this is the place where you can put your projects in.

Now Simply Create your project folder. i.e test_project
WAMP/WWW/test_project

Now inside this project folder, you can add your project bootstrap template and your index.php. After reading your question I think you just put the project template files into www directory so please change that.

Now to open this index.php you can go to your browser and type localhost/test_project. This will automatically run an index.php file of your project.

Body:
I am new to Programming hence need some help. Below is the code I am using for a Contact Form using Bootstrap but my PHP code doesn't seem to work.
I have been keeping "index.php" file with other files of Bootstrap. But when I run this it shows an error and doesn't run.
And when I save this file as "index.html", the HTML part of the code runs but PHP files don't.
In order to run PHP file in wamp server where should I save the files in Bootstrap or in Wamp?

<?php

if ($_POST['submit']) {

    if(!$_POST['name']) {
        $error="
-Please enter your name";
    }

    if(!$_POST['email']) {
        $error.="
- Please enter your email";
    }

    if(!$_POST['subject']) {
        $error.="
- Please enter a subject";
    }

    if(!$_POST['message']) {
        $error.="
- Please enter a message";
    }

    if(!$_POST['check']) {
        $error.="
- Please confirm you are human";
    }

    if($error) {
        $result="Whoops, there is an error; Please correct the following: $error";
    } else {
        mail("namitajamwal19@gmail.com", "Contact message", "Name: ".$_POST['name']."
        Email: ".$_POST['name']."
        Subject: ".$_POST['subject']."
        Message: ".$_POST['message']);"

        {
        $result="Thank you, I'll be in touch shortly";
        }
    }
}
?>

<!DOCTYPE html>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>Contact Us</title>

    <link href="css/bootstrap.min.css" rel="stylesheet">

Contact Us

                    <?php echo $result;?>

Send a message via the form below

                    <form method="post" role="form">

                            <input type="text" name="name" class="form-control" placeholder="Your Name" value="<?php echo $_POST['name']; ?>">

                            <input type="email" name="email" class="form-control" placeholder="Your email" value="<?php echo $_POST['email']; ?>">

                            <textarea name="subject" rows="5" class="form-control" placeholder="Subject"><?php echo $_POST['subject']; ?></textarea>

                            <textarea name="message" rows="5" class="form-control" placeholder="Message..."><?php echo $_POST['message']; ?></textarea>

                                <input type="checkbox" name="check">I am Human

                        <input type="submit" name="submit" class="btn btn-secondary" value="send message"/>

                    </form>


答:
div{
  /*display:inline-block;*/  /* deleted */
  /*float:left;*/            /* deleted */
  color:#fff;
  font-size:20px;
}

.some {
    margin-bottom: 10px;   /* new */
}

.one{
  float: left;  /* new  */
  width:100px;
  height:100px;
  background:red;
}

.three{
  width:100px;
  height:100px;
}

.four{
  width:150px;
  height:50px;
background:darkblue;
}
.five{
  width:150px;
  height:50px;
background:blue;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="some">
    <div class="one">image</div>

    <div class="three">
        <div class="four">name</div>
        <div class="five">desc</div>
    </div>
</div>

<div class="some">
    <div class="one">image</div>

    <div class="three">
        <div class="four">name</div>
        <div class="five">desc</div>
    </div>
</div>

<div class="some">
    <div class="one">image</div>

    <div class="three">
        <div class="four">name</div>
        <div class="five">desc</div>
    </div>
</div></code>```

separate each block ( here i added a div with class name some )

and as you want one side .one and another side .three  so just add float:left; on .one

Title: how to make div to new line

Body:
div{
  /*display:inline-block;*/  /* deleted */
  /*float:left;*/            /* deleted */
  color:#fff;
  font-size:20px;
}

.some {
    margin-bottom: 10px;   /* new */
}

.one{
  float: left;  /* new  */
  width:100px;
  height:100px;
  background:red;
}

.three{
  width:100px;
  height:100px;
}

.four{
  width:150px;
  height:50px;
background:darkblue;
}
.five{
  width:150px;
  height:50px;
background:blue;
}

<div class="some">
    <div class="one">image</div>

    <div class="three">
        <div class="four">name</div>
        <div class="five">desc</div>
    </div>
</div>

<div class="some">
    <div class="one">image</div>

    <div class="three">
        <div class="four">name</div>
        <div class="five">desc</div>
    </div>
</div>

<div class="some">
    <div class="one">image</div>

    <div class="three">
        <div class="four">name</div>
        <div class="five">desc</div>
    </div>
</div>

separate each block ( here i added a div with class name some )

and as you want one side .one and another side .three  so just add float:left; on .one


问:
Difference between weak references in a block and a NSTimer
As we know we need to use a weak reference inside a block to break the retain cycle, like so:

```<code>__weak id weakSelf = self;
[self doSomethingWithABlock:^() {
    [weakSelf doAnotherThing];
}]
</code>```

However weak references can not break the retain cycle caused by a NSTimer.

```<code>__weak id weakSelf = self;
timer = [NSTimer scheduledTimerWithTimeInterval:30.0f
                                         target:weakSelf
                                       selector:@selector(tick)
                                       userInfo:nil
                                        repeats:YES]; // No luck
</code>```

What's the difference? How can the timer still retain the target?

答:
The whole problem with the selector-based NSTimer technique is that it establishes a strong reference to the object you pass to it. So whether the variable you used to hold the reference to the target you passed to scheduledTimerWithTimeInterval was, itself, strong or weak, is immaterial. Assuming the target reference wasn't nil by the time the selector-based scheduled timer was scheduled, NSTimer will establish its own strong reference. The "weak" vs "strong" nature of the references in calling code only dictates where ARC will place its own memory management calls in the caller's code, but the target is just a simple pointer, and none of this weak vs strong information is conveyed to NSTimer. The selector-based NSTimer will establish its own strong reference that is not resolved until the timer is invalidated.

This is why, when we want to invalidate a timer built via the selector-based method, we have to it in viewDidDisappear or the like, rather than dealloc.

Note, scheduledTimerWithTimeInterval now has a block-based variation for iOS 10 and later, so you can enjoy the weak reference pattern of blocks if you don't have to support earlier iOS versions:

```<code>typeof(self) __weak weakSelf = self;
[NSTimer scheduledTimerWithTimeInterval:30 repeats:true block:^(NSTimer * _Nonnull timer) {
    // use weakSelf here
}];
</code>```

Body:
As we know we need to use a weak reference inside a block to break the retain cycle, like so:

__weak id weakSelf = self;
[self doSomethingWithABlock:^() {
    [weakSelf doAnotherThing];
}]

However weak references can not break the retain cycle caused by a NSTimer.

__weak id weakSelf = self;
timer = [NSTimer scheduledTimerWithTimeInterval:30.0f
                                         target:weakSelf
                                       selector:@selector(tick)
                                       userInfo:nil
                                        repeats:YES]; // No luck

What's the difference? How can the timer still retain the target?

Body:
The whole problem with the selector-based NSTimer technique is that it establishes a strong reference to the object you pass to it. So whether the variable you used to hold the reference to the target you passed to scheduledTimerWithTimeInterval was, itself, strong or weak, is immaterial. Assuming the target reference wasn't nil by the time the selector-based scheduled timer was scheduled, NSTimer will establish its own strong reference. The "weak" vs "strong" nature of the references in calling code only dictates where ARC will place its own memory management calls in the caller's code, but the target is just a simple pointer, and none of this weak vs strong information is conveyed to NSTimer. The selector-based NSTimer will establish its own strong reference that is not resolved until the timer is invalidated.

This is why, when we want to invalidate a timer built via the selector-based method, we have to it in viewDidDisappear or the like, rather than dealloc.

Note, scheduledTimerWithTimeInterval now has a block-based variation for iOS 10 and later, so you can enjoy the weak reference pattern of blocks if you don't have to support earlier iOS versions:

typeof(self) __weak weakSelf = self;
[NSTimer scheduledTimerWithTimeInterval:30 repeats:true block:^(NSTimer * _Nonnull timer) {
    // use weakSelf here
}];


问:
Is there a better place to store large amounts of unused data than a the database?
So the application we've got calls the API's of all the major carriers (UPS, FedEx, etc) for tracking data.

We save the most recent version of the XML feed we get from them in a TEXT field in a table in our database.

We really hardly ever (read, never so far) access that data, but have it "just in case."

It adds quite a bit of additional weight to the database. Right now a 200,000 row table is coming in at around 500MB...the large majority of which is compromised of all that XML data.

So is there a more efficient way to store all that XML data? I had thought about saving them as actual text/xml files, but we update the data every couple of hours, so wasn't sure if it would make sense to do that.

答:
Why not store them to text files, and them keep a simple path (or relative path) in the database?

We used to do something similar in the seismic industry where the bulk of the data were big arrays of floating point numbers. Much more efficient to store these as files on disk (or tape), and then only keep trace meta data (position/etc) in a RDBMS-like database (I at about the time they were porting to Oracle!). Even with the old system, the field data was always on disk and easily accessible - it was used more frequently than the array data (although, unlike in your case, this was most definitely essential!


问:
How to remote desktop (RDP) to hosted agents of Azure Pipelines
I have a Azure Pipelines (previously known as VSTS CI/CD pipelines) definition using Hosted Agent. There are cases when the build works locally but fails on hosted agent due to environment configuration differences. It will greatly improve troubleshooting experience if I can remote desktop to the Hosted Agent assigned to my job, like what AppVeyor does. Is it possible for Azure Pipelines as well?</p>

答:
I don't think that at this moment, you can RDP into the Hosted Agent.

The best you can do is to use powershell to dump all the configuration that is needed and the debug with that info on hand.


问:
Swift: How to refresh tableview without lag (UIRefreshControl)
Filling my table view with objects from a MYSQL database using PHP and JSON to Swift 3. I have a pull down to refresh function but when I'm pulling down to refresh it lags mid way for a second and then continues (like the wheel won't spin for a second).

How can I update my tableview smoother because I'm guessing as I add more content to the database in the future the bigger the lag. I currently have 12 objects in my database so imagine with 100+ objects.

In viewDidLoad

```<code>// Pull to Refresh
    let refreshControl = UIRefreshControl()
    refreshControl.addTarget(self, action: #selector(handleRefresh), for: .valueChanged)
    if #available(iOS 10.0, *) {
        myTableView.refreshControl = refreshControl
        print("iOS 10")
    } else {
        myTableView.addSubview(refreshControl)
        print("iOS 9 or iOS 8")
    }
</code>```

Then pull to refresh function

```<code>// Pull to Refresh
func handleRefresh(refreshControl: UIRefreshControl) {

    // Fetching Data for TableView
    retrieveDataFromServer()

    // Stop Refreshing
    refreshControl.endRefreshing()
}

// Retrieving Data from Server
func retrieveDataFromServer() {

    // Loading Data from File Manager
    loadData()

    let getDataURL = "http://example.com/receiving.php"
    let url: NSURL = NSURL(string: getDataURL)!

    do {
        let data: Data = try Data(contentsOf: url as URL)
        let jsonArray = try JSONSerialization.jsonObject(with: data, options: .mutableContainers) as! NSMutableArray

        // Clear the arrays
        self.followedArray = [Blog]()
        self.mainArray = [Blog]()

        // Looping through jsonArray
        for jsonObject in jsonArray {

            if let blog = Blog(jsonObject:jsonObject as! [String : Any]) {

                // Check if Identifiers Match
                if followedIdentifiers.contains(blog.blogID) {
                    self.followedArray.append(blog)
                } else {
                    self.mainArray.append(blog)
                }
            }
        }
    } catch {
        print("Error: (Retrieving Data)")
    }
    myTableView.reloadData()
}
</code>```

答:
```<code>    Spinner.isHidden = false
    Spinner.startAnimating()
    DispatchQueue.global(qos: .background).async {
       loadData()

    let getDataURL = "http://example.com/receiving.php"
    let url: NSURL = NSURL(string: getDataURL)!

    do {
        let data: Data = try Data(contentsOf: url as URL)
        let jsonArray = try JSONSerialization.jsonObject(with: data, options: .mutableContainers) as! NSMutableArray

        // Clear the arrays
        self.followedArray = [Blog]()
        self.mainArray = [Blog]()

        // Looping through jsonArray
        for jsonObject in jsonArray {

            if let blog = Blog(jsonObject:jsonObject as! [String : Any]) {

                // Check if Identifiers Match
                if followedIdentifiers.contains(blog.blogID) {
                    self.followedArray.append(blog)
                } else {
                    self.mainArray.append(blog)
                }
            }
        }
    } catch {
        print("Error: (Retrieving Data)")
    }

        DispatchQueue.main.async
        {

            myTableView.reloadData()
            self.Spinner.startAnimating()
            self.Spinner.isHidden = true
        }
    }
</code>```

Body:
Filling my table view with objects from a MYSQL database using PHP and JSON to Swift 3. I have a pull down to refresh function but when I'm pulling down to refresh it lags mid way for a second and then continues (like the wheel won't spin for a second).

How can I update my tableview smoother because I'm guessing as I add more content to the database in the future the bigger the lag. I currently have 12 objects in my database so imagine with 100+ objects.

In viewDidLoad

// Pull to Refresh
    let refreshControl = UIRefreshControl()
    refreshControl.addTarget(self, action: #selector(handleRefresh), for: .valueChanged)
    if #available(iOS 10.0, *) {
        myTableView.refreshControl = refreshControl
        print("iOS 10")
    } else {
        myTableView.addSubview(refreshControl)
        print("iOS 9 or iOS 8")
    }

Then pull to refresh function

// Pull to Refresh
func handleRefresh(refreshControl: UIRefreshControl) {

    // Fetching Data for TableView
    retrieveDataFromServer()

    // Stop Refreshing
    refreshControl.endRefreshing()
}

// Retrieving Data from Server
func retrieveDataFromServer() {

    // Loading Data from File Manager
    loadData()

    let getDataURL = "http://example.com/receiving.php"
    let url: NSURL = NSURL(string: getDataURL)!

    do {
        let data: Data = try Data(contentsOf: url as URL)
        let jsonArray = try JSONSerialization.jsonObject(with: data, options: .mutableContainers) as! NSMutableArray

        // Clear the arrays
        self.followedArray = [Blog]()
        self.mainArray = [Blog]()

        // Looping through jsonArray
        for jsonObject in jsonArray {

            if let blog = Blog(jsonObject:jsonObject as! [String : Any]) {

                // Check if Identifiers Match
                if followedIdentifiers.contains(blog.blogID) {
                    self.followedArray.append(blog)
                } else {
                    self.mainArray.append(blog)
                }
            }
        }
    } catch {
        print("Error: (Retrieving Data)")
    }
    myTableView.reloadData()
}


问:
I want to transpose a list of strings but I get TypeError
suppose I have this list of strings

```<code>li=['efh','opd','qst']
</code>```

I want to "transpose" them so they look like this

```<code>li=['eoq','fps','hdt']
</code>```

Here's the code I proposed but I get a typeError

```<code>previous=''

for i in range (len(li)):
    for j in range (len(li[0])):
        list2[j][i]=previous+list[i][j]
        previous=list2[j][i]
    previous=''
</code>```

答:
You have a number of issues, the specific error is due to a typo:

```<code>list2[j][i]=previous+list[i][j]
                     ^^^^
</code>```

list is a built in type and doesn't support indexing.

Additionally, list2 is undefined and python's str is immutable so you can't assign to a str index.

Also changing li during iteration would make later iterations produce the wrong results so would recommend creating a new list to hold the result.

A working copy of your code would look like:

```<code>In []:
li=['efh','opd','qst']
new_li = []
for i in range(len(li[0])):
    r = ''
    for j in range(len(li)):
        r += li[j][i]
    new_li.append(r)
new_li

Out[]:
['eoq', 'fps', 'hdt']
</code>```

Note: python's zip() would do this for you:

```<code>In []:
li=['efh','opd','qst']
[''.join(s) for s in zip(*li)]

Out[]:
['eoq', 'fps', 'hdt']
</code>```

Body:
suppose I have this list of strings

li=['efh','opd','qst']

I want to "transpose" them so they look like this

li=['eoq','fps','hdt']

Here's the code I proposed but I get a typeError

previous=''

for i in range (len(li)):
    for j in range (len(li[0])):
        list2[j][i]=previous+list[i][j]
        previous=list2[j][i]
    previous=''

Body:
You have a number of issues, the specific error is due to a typo:

list2[j][i]=previous+list[i][j]
                     ^^^^

list is a built in type and doesn't support indexing.

Additionally, list2 is undefined and python's str is immutable so you can't assign to a str index.

Also changing li during iteration would make later iterations produce the wrong results so would recommend creating a new list to hold the result.

A working copy of your code would look like:

In []:
li=['efh','opd','qst']
new_li = []
for i in range(len(li[0])):
    r = ''
    for j in range(len(li)):
        r += li[j][i]
    new_li.append(r)
new_li

Out[]:
['eoq', 'fps', 'hdt']

Note: python's zip() would do this for you:

In []:
li=['efh','opd','qst']
[''.join(s) for s in zip(*li)]

Out[]:
['eoq', 'fps', 'hdt']


答:
You need to clear the float on your .one div.

This is the only part that would change:

CSS:

```<code>.one{
  width:100px;
  height:100px;
  background:red;
  clear:left;
  margin-bottom: 15px;
}
</code>```

You may want to consider altering your markup as well by wrapping each group of divs, but this will get you what you need.

Fiddle: https://jsfiddle.net/k4dw68pg/

Title: how to make div to new line

Body:
You need to clear the float on your .one div.

This is the only part that would change:

CSS:

.one{
  width:100px;
  height:100px;
  background:red;
  clear:left;
  margin-bottom: 15px;
}

You may want to consider altering your markup as well by wrapping each group of divs, but this will get you what you need.

Fiddle: https://jsfiddle.net/k4dw68pg/


问:
What is the effect of extern "C" in C++?
What exactly does putting extern "C" into C++ code do?

For example:

```<code>extern "C" {
   void foo();
}
</code>```

答:
When mixing C and C++ (i.e., a. calling C function from C++; and b. calling C++ function from C), the C++ name mangling causes linking problems. Technically speaking, this issue happens only when the callee functions have been already compiled into binary (most likely, a *.a library file) using the corresponding compiler.

So we need to use extern "C" to disable the name mangling in C++.

Body:
What exactly does putting extern "C" into C++ code do?

For example:

extern "C" {
   void foo();
}


问:
codeigniter session not set first time
I have a problem. I am setting session on a login page. But when the page redirects where session does not initiate on the first attempt. When I login second time then session has set.

I am stuck what is the problem.

Here is my code

```<code>$data = $this->input->post();
    //$data['password'] = $this->encrypt->encode($data['password']);
    $result = $this->Login_m->get_userdata($data['username']);
    $result['password'] = $this->encrypt->decode($result['password']);
    //print_r($result);

    if (strtolower($data['username']) === strtolower($result['username']) and $data['password'] === $result['password'] ) {

        unset($result['password']);
        $this->session->set_userdata('user', $result);
        redirect("dashboard");
    }else{
        $this->session->set_flashdata("error","Given Username or Password is not correct");
        redirect("login");
        die();
    }
</code>```

Please help.
Thank you in advance.

答:
I think this is because of browser cache. Try setting below no cache headers rules on refresh(Or in your constructor):</p>

```<code>header('Cache-Control: no-cache');
header('Pragma: no-cache');
</code>```

Title: codeigniter session not set first time

Body:
I have a problem. I am setting session on a login page. But when the page redirects where session does not initiate on the first attempt. When I login second time then session has set.

I am stuck what is the problem.

Here is my code

$data = $this->input->post();
    //$data['password'] = $this->encrypt->encode($data['password']);
    $result = $this->Login_m->get_userdata($data['username']);
    $result['password'] = $this->encrypt->decode($result['password']);
    //print_r($result);

    if (strtolower($data['username']) === strtolower($result['username']) and $data['password'] === $result['password'] ) {

        unset($result['password']);
        $this->session->set_userdata('user', $result);
        redirect("dashboard");
    }else{
        $this->session->set_flashdata("error","Given Username or Password is not correct");
        redirect("login");
        die();
    }

Please help.
Thank you in advance.

Body:
I think this is because of browser cache. Try setting below no cache headers rules on refresh(Or in your constructor):

header('Cache-Control: no-cache');
header('Pragma: no-cache');


问:
Getting value from session using zk
i am configured the zk with struts 1 . i created a list and set in the session.

```<code>List<String> nameList = new ArrayList<String>();
nameList.add( "xxx" );
nameList.add( "yyy" );
nameList.add( "nnn" );
nameList.add( "ddd" );

request.getSession().setAttribute("NAMES_LIST", nameList);
</code>```

now from the zul file i am trying to get the session value. How do I do that?

答:
You have to call getNativeSession on the zk session then cast that to be a javax.servlet.http.Session which the one that struts is using. </p>

<p>Trying to mix zk with struts is missing the point. With zk do whatever you need to do and update the zk components and the browser will automatically be updated. Putting data into old style forms to send to the server then update the page is old style programming and less efficient than zk event driven programming where you just update the zk desktop (not bothering to think about pages) and the screen is updated. Your uses can work all day with rich behavior without ever posting a form to interact with struts. </p>

Title: Getting value from session using zk

Body:
i am configured the zk with struts 1 . i created a list and set in the session.

List<String> nameList = new ArrayList<String>();
nameList.add( "xxx" );
nameList.add( "yyy" );
nameList.add( "nnn" );
nameList.add( "ddd" );

request.getSession().setAttribute("NAMES_LIST", nameList);

now from the zul file i am trying to get the session value. How do I do that?

Body:
You have to call getNativeSession on the zk session then cast that to be a javax.servlet.http.Session which the one that struts is using.

Trying to mix zk with struts is missing the point. With zk do whatever you need to do and update the zk components and the browser will automatically be updated. Putting data into old style forms to send to the server then update the page is old style programming and less efficient than zk event driven programming where you just update the zk desktop (not bothering to think about pages) and the screen is updated. Your uses can work all day with rich behavior without ever posting a form to interact with struts.


问:
How to migrate from Gradle to Kobalt?
Kobalt is a new build tool for java written in Kotlin. As you may already know, migrating from Maven to Gradle is very easy! How can I convert my Gradle project into Kobalt? --init does not do the task!</p>

答: At this time, (7/5/2017) Kobalt's todo list has an entry for implementing import of build.gradle dependencies. As you noted, this is a fairly new tool, and as such, many of the more advanced features are not yet completed.

Title: How to migrate from Gradle to Kobalt?


答:
Here is the solution.
try this code out : </p>

```<code><style>
div{
  display:inline-block;
  float:left;
  color:#fff;
  font-size:20px;
}

.one{
  width:100px;
  height:100px;
  background:red;
  clear:both;
}
.three{
    width:100px;
  height:100px;
}

.four{
  width:150px;
  height:50px;
background:darkblue;
}
.five{
  width:150px;
  height:50px;
background:blue;
}
 </style>

<div class="one">image</div>

<div class="three">
  <div class="four">name</div>
  <div class="five">desc</div>
</div>

<div class="one">image</div>

<div class="three">
  <div class="four">name</div>
  <div class="five">desc</div>
</div>

<div class="one">image</div>

<div class="three">
  <div class="four">name</div>
  <div class="five">desc</div>
</div>
</code>```

Title: how to make div to new line

Body:
Here is the solution.
try this code out :

<style>
div{
  display:inline-block;
  float:left;
  color:#fff;
  font-size:20px;
}

.one{
  width:100px;
  height:100px;
  background:red;
  clear:both;
}
.three{
    width:100px;
  height:100px;
}

.four{
  width:150px;
  height:50px;
background:darkblue;
}
.five{
  width:150px;
  height:50px;
background:blue;
}
 </style>

<div class="one">image</div>

<div class="three">
  <div class="four">name</div>
  <div class="five">desc</div>
</div>

<div class="one">image</div>

<div class="three">
  <div class="four">name</div>
  <div class="five">desc</div>
</div>

<div class="one">image</div>

<div class="three">
  <div class="four">name</div>
  <div class="five">desc</div>
</div>


问:
How to apply remote filter on a tree panel
I have a tree panel and the store associated to it is memory I am loading the data using a loadData function where I am making a call service call. I want to add filters for the columns and filter them remotely when I say remoteFilter : true it is not making a call to the back-end. Any suggestions on how to achieve this.

Fiddle with my funcions and views (fiddle is not running )

答:
The code is utter chaos, and shows a lack of understanding of the core concepts of ExtJS. You should clean it up and use the standardized ExtJS ways of doing things whenever possible.

Right now you are trying to put remoteFilter: true on a store with a memory proxy. A memory proxy is not a server proxy, alas does not have a possibility to filter remotely. Adding remoteFilter:true on that store can only either harm or do nothing.

Then you are loading data into a store with a memory proxy by executing Ext.Ajax.request manually. By the way, the filters that you wanted to be applied by the server, are not part of your hand-crafted Ajax request.

Usually, one would use store.load on a store with an ajax proxy to load a store from a server (this executes Ext.Ajax.request under the hood, but with all special settings a store supports). In that case, remoteFilter makes sense insofar as the filters you have set are then submitted to the server, and the server then has to filter out records that should not be displayed client-side. (Let's say it like this, from your front-end code I doubt that the backend supports anything like filtering.)

And then it seems that you are loading data into a tree store that does not come in the format expected by ExtJS. You should look into whether you can craft your model in such a way that the tree store can be directly loaded from the server's response, and get rid of all the intermediate code with Ext.Ajax.request and reformatting. Since you already have to modify the server side to enable remote filtering, this would be the most futureproof way to get your code working.


问:
Had 2 different git users on same machine; Git will not recognize my global user when I push and thinks I'm pushing from my other user
I have two users on this machine. user1 is linked to my personal GitHub and user2 is linked to my work GitHub.

Setting the user with this does not work:

```<code>git config user.name "User Name"
git config user.email "UserEmail@Host"
</code>```

If I check which username, user email are it reports user1, which is what I want it to be. BUT when I push it says remote: Permission to user1/repo.git denied to user2.

I'm dying here. There has to be a simple fix for this that I'm just missing.

I remember using SSH for user2 when setting that up. I think that might have something to do with this. I'm happy to delete user2 altogether.

I found this issue, which looks the same, but the fix for it didn't work for me.

答:
When you use SSH to connect to GitHub, the values of user.name and user.email are not relevant for authentication. Those are values used by Git when creating commits in the local repository. Pushing/pulling are separate from that.

When you connect to GitHub via SSH, the key that you used to authenticate is how it decides which GitHub user you are. If you want to authenticate as user2, make sure your Git client setup has the SSH key for user2, not the one associated (on GitHub) with user1's account.

Body:
I have two users on this machine. user1 is linked to my personal GitHub and user2 is linked to my work GitHub.

Setting the user with this does not work:

git config user.name "User Name"
git config user.email "UserEmail@Host"

If I check which username, user email are it reports user1, which is what I want it to be. BUT when I push it says remote: Permission to user1/repo.git denied to user2.

I'm dying here. There has to be a simple fix for this that I'm just missing.

I remember using SSH for user2 when setting that up. I think that might have something to do with this. I'm happy to delete user2 altogether.

I found this issue, which looks the same, but the fix for it didn't work for me.


答:
user.name is only used to compose your commit message, has nothing to do with authentication, you should config credential.username for network authentication.

You can refer to gitcredentials for more details.

Title: Had 2 different git users on same machine; Git will not recognize my global user when I push and thinks I'm pushing from my other user


答:
You can use the below. you were not clearing out your floats.</p>

```<code><div class="one">image</div>

<div class="three">
  <div class="four">name</div>
  <div class="five">desc</div>
</div>
<div class="clearfix">
</div>

<div class="one">image</div>

<div class="three">
  <div class="four">name</div>
  <div class="five">desc</div>
</div>
<div class="clearfix">
</div>

<div class="one">image</div>

<div class="three">
  <div class="four">name</div>
  <div class="five">desc</div>
</div>

div{
  display:inline-block;
  float:left;
  color:#fff;
  font-size:20px;
}

.clearfix{
  clear:both;
}

.one{
  width:100px;
  height:100px;
  background:red;
  margin-bottom:20px;
  display:block !important;
}
.three{
    width:100px;
  height:100px;
}

.four{
  width:150px;
  height:50px;
background:darkblue;
}
.five{
  width:150px;
  height:50px;
background:blue;
}
</code>```

Title: how to make div to new line

Body:
i am beginner to css.

i want to make new div into new line like this,

i try my code like this

image

name

desc

image

name

desc

image

name

desc

but result like this

how to move, the second image to new line..
pls anybody help me. i ll appreciate your answer

Body:
You can use the below. you were not clearing out your floats.

<div class="one">image</div>

<div class="three">
  <div class="four">name</div>
  <div class="five">desc</div>
</div>
<div class="clearfix">
</div>

<div class="one">image</div>

<div class="three">
  <div class="four">name</div>
  <div class="five">desc</div>
</div>
<div class="clearfix">
</div>

<div class="one">image</div>

<div class="three">
  <div class="four">name</div>
  <div class="five">desc</div>
</div>

div{
  display:inline-block;
  float:left;
  color:#fff;
  font-size:20px;
}

.clearfix{
  clear:both;
}

.one{
  width:100px;
  height:100px;
  background:red;
  margin-bottom:20px;
  display:block !important;
}
.three{
    width:100px;
  height:100px;
}

.four{
  width:150px;
  height:50px;
background:darkblue;
}
.five{
  width:150px;
  height:50px;
background:blue;
}


答:
You can add a div to wrap your group of image/name/desc and then set clear: both; to this div:

div{
  display:inline-block;
  float:left;
  color:#fff;
  font-size:20px;
}

.image-wrapper {
  clear: both;
  margin-bottom: 20px;
}

.one{
  width:100px;
  height:100px;
  background:red;
}
.three{
  width:100px;
  height:100px;
}

.four{
  width:150px;
  height:50px;
  background:darkblue;
}

.five{
  width:150px;
  height:50px;
  background:blue;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="image-wrapper">
  <div class="one">image</div>

  <div class="three">
    <div class="four">name</div>
    <div class="five">desc</div>
  </div>
</div>

<div class="image-wrapper">
  <div class="one">image</div>

  <div class="three">
    <div class="four">name</div>
    <div class="five">desc</div>
  </div>
</div>

<div class="image-wrapper">
  <div class="one">image</div>

  <div class="three">
    <div class="four">name</div>
    <div class="five">desc</div>
  </div>
</div></code>```

Title: how to make div to new line

Body:
You can add a div to wrap your group of image/name/desc and then set clear: both; to this div:

div{
  display:inline-block;
  float:left;
  color:#fff;
  font-size:20px;
}

.image-wrapper {
  clear: both;
  margin-bottom: 20px;
}

.one{
  width:100px;
  height:100px;
  background:red;
}
.three{
  width:100px;
  height:100px;
}

.four{
  width:150px;
  height:50px;
  background:darkblue;
}

.five{
  width:150px;
  height:50px;
  background:blue;
}

<div class="image-wrapper">
  <div class="one">image</div>

  <div class="three">
    <div class="four">name</div>
    <div class="five">desc</div>
  </div>
</div>

<div class="image-wrapper">
  <div class="one">image</div>

  <div class="three">
    <div class="four">name</div>
    <div class="five">desc</div>
  </div>
</div>

<div class="image-wrapper">
  <div class="one">image</div>

  <div class="three">
    <div class="four">name</div>
    <div class="five">desc</div>
  </div>
</div>


问:
use of unresolved identifier 'result' swift 3
I'm writing a login page for my app and i'm getting this error
social media app , xcode 8.3.2 , swift 3
i've tried target membership in file inspector and nothing changed
also I removed test units (UITest and Test) and renew them , it didn't worked either.
at the line 41 I'm getting this error "use of unresolved identifier 'result'"

the picture below explains the code
Picture

```<code>import UIKit

class LoginViewController : UIViewController
{
    @IBOutlet weak var txt_username: UITextField!
    @IBOutlet weak var txt_password: UITextField!
    override func viewDidLoad() {
        super.viewDidLoad()
    }
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
    }
    @IBAction func btn_log_in_click(_ sender: Any){
        let server=MultipartUtility (Url:"http://x.x.x.x/appname-api/user/login/")
//I.m hiding the real ip and details for posting this
            server.AddFormField("username", value: txt_username.text)
            server.AddFormField("password", value: txt_password.text)

let task = URLSession.shared.dataTask(with: server.execute())
{Data,URLResponse,error in
    if error != nil{
    print(error as Any)
        return
    }
    do{
        let json = try JSONSerialization.jsonObject(with: Data!, options: .allowFragments)
        if let json_result = json as? [String: Any]{
            let result = json_result ["result"] as? String
            if result == "0"
            {
                DispatchQueue.main.async {
                    let alert = UIAlertController(title:"Incorrect Username",message : "The username you entered doesn't appear to belong to an account. Please check your username and try again", preferredStyle : .alert)
                    let alert_action = UIAlertAction(title: "Try Again", style: .default, handler: nil)
                    alert.addAction(alert_action)
                    self.present(alert, animated: true, completion: nil)
                }
            }
        }
        else{

            DispatchQueue.main.async {
            UserDefaults.standard.set(result!, forKey: "user_id")
//" use of unresolved identifier 'result' "
            let current_view=UIApplication.shared.windows[0] as UIWindow
            let new_view=(self.storyboard? .instantiateViewController(withIdentifier: "tab_bar"))! as UIViewController
            UIView.transition(from: (current_view.rootViewController? .view)!, to:new_view.view , duration: 0.65, options: .transitionFlipFromRight, completion: {(action) in current_view.rootViewController=new_view
            })
            }
        }
    }
    catch{
    }
}
        task.resume()

      }
}
</code>```

答:
```<code>if let json_result = json as? [String: Any]
                {
                    let result = json_result ["result"] as? String
                    if result == "0"
                    {
                        DispatchQueue.main.async {
                            let alert = UIAlertController(title:"Incorrect Username",message : "The username you entered doesn't appear to belong to an account. Please check your username and try again", preferredStyle : .alert)
                            let alert_action = UIAlertAction(title: "Try Again", style: .default, handler: nil)
                            alert.addAction(alert_action)
                            self.present(alert, animated: true, completion: nil)
                        }
                    }
                    else
                    {
                        DispatchQueue.main.async {
                            UserDefaults.standard.set(result!, forKey: "user_id")
                            //" use of unresolved identifier 'result' "
                            let current_view=UIApplication.shared.windows[0] as UIWindow
                            let new_view=(self.storyboard? .instantiateViewController(withIdentifier: "tab_bar"))! as UIViewController
                            UIView.transition(from: (current_view.rootViewController? .view)!, to:new_view.view , duration: 0.65, options: .transitionFlipFromRight, completion: {(action) in current_view.rootViewController=new_view
                            })
                        }

                    }
                }
                else{
                // Error in jsonSerialization
                }
</code>```

Body:
I'm writing a login page for my app and i'm getting this error
social media app , xcode 8.3.2 , swift 3
i've tried target membership in file inspector and nothing changed
also I removed test units (UITest and Test) and renew them , it didn't worked either.
at the line 41 I'm getting this error "use of unresolved identifier 'result'"

the picture below explains the code
Picture

import UIKit

class LoginViewController : UIViewController
{
    @IBOutlet weak var txt_username: UITextField!
    @IBOutlet weak var txt_password: UITextField!
    override func viewDidLoad() {
        super.viewDidLoad()
    }
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
    }
    @IBAction func btn_log_in_click(_ sender: Any){
        let server=MultipartUtility (Url:"http://x.x.x.x/appname-api/user/login/")
//I.m hiding the real ip and details for posting this
            server.AddFormField("username", value: txt_username.text)
            server.AddFormField("password", value: txt_password.text)

let task = URLSession.shared.dataTask(with: server.execute())
{Data,URLResponse,error in
    if error != nil{
    print(error as Any)
        return
    }
    do{
        let json = try JSONSerialization.jsonObject(with: Data!, options: .allowFragments)
        if let json_result = json as? [String: Any]{
            let result = json_result ["result"] as? String
            if result == "0"
            {
                DispatchQueue.main.async {
                    let alert = UIAlertController(title:"Incorrect Username",message : "The username you entered doesn't appear to belong to an account. Please check your username and try again", preferredStyle : .alert)
                    let alert_action = UIAlertAction(title: "Try Again", style: .default, handler: nil)
                    alert.addAction(alert_action)
                    self.present(alert, animated: true, completion: nil)
                }
            }
        }
        else{

            DispatchQueue.main.async {
            UserDefaults.standard.set(result!, forKey: "user_id")
//" use of unresolved identifier 'result' "
            let current_view=UIApplication.shared.windows[0] as UIWindow
            let new_view=(self.storyboard? .instantiateViewController(withIdentifier: "tab_bar"))! as UIViewController
            UIView.transition(from: (current_view.rootViewController? .view)!, to:new_view.view , duration: 0.65, options: .transitionFlipFromRight, completion: {(action) in current_view.rootViewController=new_view
            })
            }
        }
    }
    catch{
    }
}
        task.resume()

      }
}


问:
Replacing a pandas dataframe column
I have some code which is pulling data into a pandas dataframe.

```<code>df = df[["date","high","low","open","close"]]
</code>```

The data looks like this:

```<code>       date         high          low        open       close
0  1499140800  2615.390000  2600.000000  2610.58000  2603.00000
1  1499155200  2618.785462  2582.002100  2615.00000  2607.00000
2  1499169600  2617.674406  2550.314214  2607.00000  2554.55010
3  1499184000  2572.962113  2519.967440  2554.55010  2519.96744
4  1499198400  2595.654622  2516.000000  2519.96744  2580.00000
</code>```

I am wanting to convert the unix timestamp column with an actual datetime. Earlier in my code am having to import

```<code>from datetime import datetime
</code>```

and it seems to be giving me an error when I try to use datetime.datetime to convert. I can't just use import datetimebecause this gives me an error on my previous import which I need. So my question is twofold. How can I convert the timestamp into a datetime (possibly without using the datetime module?) and how can I overwrite the date column with the new date time before I save into a file?I have tried several approaches but none seem to be giving me any luck..

答:
This code worked for me after I copied your example data to a file in.csv

An explanation follows the code example.

```<code>>>> import pandas as pd

>>> df = pd.read_csv('in.csv')

>>> df
     date         high          low        open       close
0  1499140800  2615.390000  2600.000000  2610.58000  2603.00000
1  1499155200  2618.785462  2582.002100  2615.00000  2607.00000
2  1499169600  2617.674406  2550.314214  2607.00000  2554.55010
3  1499184000  2572.962113  2519.967440  2554.55010  2519.96744
4  1499198400  2595.654622  2516.000000  2519.96744  2580.00000

>>> from datetime import datetime

>>> converted = df['date'].apply(datetime.fromtimestamp)

>>> df['date'] = converted

>>> df
              date         high          low        open       close
0 2017-07-03 22:00:00  2615.390000  2600.000000  2610.58000  2603.00000
1 2017-07-04 02:00:00  2618.785462  2582.002100  2615.00000  2607.00000
2 2017-07-04 06:00:00  2617.674406  2550.314214  2607.00000  2554.55010
3 2017-07-04 10:00:00  2572.962113  2519.967440  2554.55010  2519.96744
4 2017-07-04 14:00:00  2595.654622  2516.000000  2519.96744  2580.00000
</code>```

Converting a Unix Timestamp to Datetime

You ran

```<code>from datetime import datetime
</code>```

and expected to use datetime.datetime later as a function, but you actually imported the datetime class from the datetime module (which is why changing the import to just datetime didn't help). See this question for more: Converting unix timestamp string to readable date in Python

So you just need to import the datetime class and use its fromtimestamp function

Updating a Column in a DataFrame

For this, a common approach is to apply a function (in this case, fromtimestamp) to the column (a Pandas Series) and then over-write the old column in the DataFrame.

I am not aware of a way to modify the column in place, but would be happy to hear a way if I missed it in the Pandas docs.

Title: Replacing a pandas dataframe column

Body:
I have some code which is pulling data into a pandas dataframe.

df = df[["date","high","low","open","close"]]

The data looks like this:

       date         high          low        open       close
0  1499140800  2615.390000  2600.000000  2610.58000  2603.00000
1  1499155200  2618.785462  2582.002100  2615.00000  2607.00000
2  1499169600  2617.674406  2550.314214  2607.00000  2554.55010
3  1499184000  2572.962113  2519.967440  2554.55010  2519.96744
4  1499198400  2595.654622  2516.000000  2519.96744  2580.00000

I am wanting to convert the unix timestamp column with an actual datetime. Earlier in my code am having to import

from datetime import datetime

and it seems to be giving me an error when I try to use datetime.datetime to convert. I can't just use import datetimebecause this gives me an error on my previous import which I need. So my question is twofold. How can I convert the timestamp into a datetime (possibly without using the datetime module?) and how can I overwrite the date column with the new date time before I save into a file?I have tried several approaches but none seem to be giving me any luck..

Body:
This code worked for me after I copied your example data to a file in.csv

An explanation follows the code example.

>>> import pandas as pd

>>> df = pd.read_csv('in.csv')

>>> df
     date         high          low        open       close
0  1499140800  2615.390000  2600.000000  2610.58000  2603.00000
1  1499155200  2618.785462  2582.002100  2615.00000  2607.00000
2  1499169600  2617.674406  2550.314214  2607.00000  2554.55010
3  1499184000  2572.962113  2519.967440  2554.55010  2519.96744
4  1499198400  2595.654622  2516.000000  2519.96744  2580.00000

>>> from datetime import datetime

>>> converted = df['date'].apply(datetime.fromtimestamp)

>>> df['date'] = converted

>>> df
              date         high          low        open       close
0 2017-07-03 22:00:00  2615.390000  2600.000000  2610.58000  2603.00000
1 2017-07-04 02:00:00  2618.785462  2582.002100  2615.00000  2607.00000
2 2017-07-04 06:00:00  2617.674406  2550.314214  2607.00000  2554.55010
3 2017-07-04 10:00:00  2572.962113  2519.967440  2554.55010  2519.96744
4 2017-07-04 14:00:00  2595.654622  2516.000000  2519.96744  2580.00000

Converting a Unix Timestamp to Datetime

You ran

from datetime import datetime

and expected to use datetime.datetime later as a function, but you actually imported the datetime class from the datetime module (which is why changing the import to just datetime didn't help). See this question for more: Converting unix timestamp string to readable date in Python

So you just need to import the datetime class and use its fromtimestamp function

Updating a Column in a DataFrame

For this, a common approach is to apply a function (in this case, fromtimestamp) to the column (a Pandas Series) and then over-write the old column in the DataFrame.

I am not aware of a way to modify the column in place, but would be happy to hear a way if I missed it in the Pandas docs.


问:
Mule - Updating third party library in runtime
I'm using Mule Server 3.8 EE which brings commons-lang 2.4 with it. A third-party library in my project needs commons-lang 2.6, because it uses a method that was introduced in this version.

So when I just start my application, I get a java.lang.NoSuchMethodError

Is there a way to update the dependency in the runtime? What I tried so far:

including commons-lang 2.6 in my app -> no effect, the one from the runtime is picked up first

replacing the jar directly in the runtime -> errors in studio, that the 2.4 jar is missing

答: so maybe i am late BUT -- this is your answer. Add the libraries that are newer in the jar distribution to the Build Path. Under Java Build Path screen you should see the libraries listed. I needed to use Apache http-client 4.5.6 and that's very interesting because it brings with it a lot of other dependencies, so your question was VERY relevant. The solution is to rely on JAVA (and not mule -- oops Anypoint or whatever) conventions and make sure the JVM loads my class files first. Then, it won't load the old ones from mule's jar. And so I went to the tab Order and Export, and moved Mule to the bottom. This simple, trivial change makes it work. I think if we would work with command line and vim, we would all know this. But all the IDE gui and everything else makes us forget the simplest things. Please use it in good health. :)</p>


问:
Visual Studio target Deploy does not exist
I'm getting this error when running a built project in Visual Studio 2017:

```<code>------ Deploy started: Project: myProj, Configuration: Debug Win32 ------

C:\...\myProj.vcxproj : error MSB4057: The target "Deploy" does not exist in the project.
Done building project "myProj.vcxproj" -- FAILED.
========== Deploy: 0 succeeded, 1 failed, 0 skipped ==========
</code>```

I found something online saying uncheck Deploy from Build, Configuration Manager... but it is already unchecked.

If I try to run it again, it will load and run.  But I'd like to be able to release code that works the first time.  What else might I try?  TIA.

答:
Odds are you have a post build event in your project. When you first build it the post build event fires and attempts the deploy. The second time you go to  build the project is already 'up to date' so it is not built and the post build event does not fire.

You can view your post build events by right clicking your project and choosing properties, expanding build events and then expanding post build.

You can also check if anything is defined under custom build steps.

Body:
I'm getting this error when running a built project in Visual Studio 2017:

------ Deploy started: Project: myProj, Configuration: Debug Win32 ------

C:\...\myProj.vcxproj : error MSB4057: The target "Deploy" does not exist in the project.
Done building project "myProj.vcxproj" -- FAILED.
========== Deploy: 0 succeeded, 1 failed, 0 skipped ==========

I found something online saying uncheck Deploy from Build, Configuration Manager... but it is already unchecked.

If I try to run it again, it will load and run.  But I'd like to be able to release code that works the first time.  What else might I try?  TIA.


问:
Why are my html buttons moving in I.E? They don't move in Chrome or FF
We are using AJAX to send data to our database. I've added some feedback for the user including a spinner (animated .gif) that spins during the request, and Pass/Fail text that is displayed to the user when the request is complete.

HTML:

```<code><center>
    <table style="width:350px;">
        <tr>
            <td style="width:100px; min-width:100px;" align="right">
                <span id="spinner-and-text-displayed-here"></span>
            </td>
            <td style="width:150px">
                <input type="button" value="Submit" onclick="submit();"/>
                <input type="button" value="Cancel" onclick="cancel();"/>
            </td>
            <td style="width:100px"></td>
        </tr>
    </table>
</center>
</code>```

When the user clicks the submit button the spinner spins until the ajax callback is returned. At this point, the buttons do NOT shift. Once I receive the callback I display the text "Successful!" (displayed in the span using jQuery $(el).html("Successful!");), which causes the buttons to shift right. That message fades out (also using jquery), and once the button fades completely, the buttons shift back to their original position.

If I hardcode "Successful!" inside the span, the buttons are shifted, so I know it has something to do with the text (remember it doesn't shift when the spinner is displayed [which uses the img tag]).

It doesn't matter how wide i set the first td width.

Is there a way I can keep these buttons from shifting in IE?

答:
Add a DOCTYPE to your file, e.g.

```<code><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<script type="text/javascript"src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js">    </script>

<body>
    <table style="width:350px;">
        <tr>
            <td style="width:100px; min-width:100px;" align="right">
                <span id="el"></span>
            </td>
            <td style="width:150px">
            <input type="button" value="Submit" onclick="$('#el').html('Success');"/>
            <input type="button" value="Cancel" onclick="cancel();"/>
           </td>
           <td style="width:100px"></td>
        </tr>
     </table>
</body>
</html>
</code>```

I had a similar issue and it was because of IE handling the  tag differently from other browsers.

Body:
We are using AJAX to send data to our database. I've added some feedback for the user including a spinner (animated .gif) that spins during the request, and Pass/Fail text that is displayed to the user when the request is complete.

HTML:

                <input type="button" value="Submit" onclick="submit();"/>
                <input type="button" value="Cancel" onclick="cancel();"/>

When the user clicks the submit button the spinner spins until the ajax callback is returned. At this point, the buttons do NOT shift. Once I receive the callback I display the text "Successful!" (displayed in the span using jQuery $(el).html("Successful!");), which causes the buttons to shift right. That message fades out (also using jquery), and once the button fades completely, the buttons shift back to their original position.

If I hardcode "Successful!" inside the span, the buttons are shifted, so I know it has something to do with the text (remember it doesn't shift when the spinner is displayed [which uses the img tag]).

It doesn't matter how wide i set the first td width.

Is there a way I can keep these buttons from shifting in IE?

Body:
Add a DOCTYPE to your file, e.g.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<script type="text/javascript"src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js">    </script>

<body>
    <table style="width:350px;">
        <tr>
            <td style="width:100px; min-width:100px;" align="right">
                <span id="el"></span>
            </td>
            <td style="width:150px">
            <input type="button" value="Submit" onclick="$('#el').html('Success');"/>
            <input type="button" value="Cancel" onclick="cancel();"/>
           </td>
           <td style="width:100px"></td>
        </tr>
     </table>
</body>
</html>

I had a similar issue and it was because of IE handling the  tag differently from other browsers.


问:
Change telegram bot owner
We have created telegram bot which has many difficult operations. Bot was created by one developer using his phone number. Is it possible change bot's owner or add another user as admin to bot? </p>

答:
One of possible solutions (most simple as I wonder) is in the creation a new bot with same username. So only need to delete your old bot, create new and change bot token in your program code.

Note that it's possible only if the old bot's owner collaborates. To prevent similar situations your company need to create one telegram account for creating bots, channels etc., without ties to concrete persons.

UPD 2020

Telegram teem finally did the trick and added the changing ownership feature. Bingo. But this will not help if you can't ping an owner, same.

Title: Change telegram bot owner


问:
How to customize/style woocommerce account page
As you can see here: https://wildlatina.com/my-account/

the white body is not inside the page and there is not margin padding for the login form? what did I do to mess this up? I'm a beginner when it comes to editing with css so please go easy on me. Just would like the account page to look nice.

答:
Hello You Can Style It By Using Some Plug-ins Which present at plug-ins>new one
for example you can go with this plug-in
https://wordpress.org/plugins/woocommerce-login-and-registration/

If You Cant Style It Please Post The Error You Are Getting Neatly And Most Probably You Can Use Wordpress Login For Woo-commerce But If You Are Really Interested To Use Only That You Can Customize It From CSS Or You Can Use Plug-ins Which Do The Same But No Coding Knowledge Required To Do It From Plug-in Because Everything is Graphically Done And whatever The Coding Part Is That Will Be Take Cared By Plug-in Itself So Maximum Use Plugins So It Could Better In Development


问:
Shutdown a java app (multiple threads) gracefully
I am trying to set up a shutdown hook to handle SIGTERM (kill -15). It shuts down but doesn't look like it gracefully finish up ** processing** function as it never output the log "Thread has been shutdown".</p>

```<code>public class Runner {
    public static void main(String[] args) {
        Test test = new Test();
        Runtime.getRuntime().addShutdownHook(new Thread() {
                @Override
                public void run() {
                    try {
                        logger.warn("Shutting things down..."); // This works
                        test.stop();
                    } catch (Exception ex) {
                        logger.error("Error shutting the app gracefully", ex);
                    }
                }
            });

        test.processing();
    }
}

public class Test {
    private volatile boolean processingExit = false;
    public void stop() {
        processingExit = true;
    }

    public void processing() {
        while (!processingExit) {
            //do work here
            logger.info("doing work... keep printing..."); //This works until I send a kill -15 signal
        }
        // This log never works
        logger.info("Thread has been shutdown"); // This doesn't works
    }
}
</code>```

答:
The problem is that as soon as the shutdown hook thread completes, the process is halted, you need to have the shutdown hook thread wait for the main thread.

Copied from https://stackoverflow.com/a/2922031/1544715

From the docs:

When the virtual machine begins its shutdown sequence it will start all registered shutdown hooks in some unspecified order and let them run concurrently. When all the hooks have finished it will then run all uninvoked finalizers if finalization-on-exit has been enabled. Finally, the virtual machine will halt.

Body:
I am trying to set up a shutdown hook to handle SIGTERM (kill -15). It shuts down but doesn't look like it gracefully finish up ** processing** function as it never output the log "Thread has been shutdown".

public class Runner {
    public static void main(String[] args) {
        Test test = new Test();
        Runtime.getRuntime().addShutdownHook(new Thread() {
                @Override
                public void run() {
                    try {
                        logger.warn("Shutting things down..."); // This works
                        test.stop();
                    } catch (Exception ex) {
                        logger.error("Error shutting the app gracefully", ex);
                    }
                }
            });

        test.processing();
    }
}

public class Test {
    private volatile boolean processingExit = false;
    public void stop() {
        processingExit = true;
    }

    public void processing() {
        while (!processingExit) {
            //do work here
            logger.info("doing work... keep printing..."); //This works until I send a kill -15 signal
        }
        // This log never works
        logger.info("Thread has been shutdown"); // This doesn't works
    }
}


问:
VSTS: How to auto-delete git branches
We currently have our dev team working out of VSTS, with git.  The number of branches are getting quite large, and rather than manually deleting branches every month, I would like ability to auto-delete branches that have not been touched for, say, 60 days.  I know this is possible to do in Jenkins, but we don't have Jenkins at the moment, and was wondering if this is possible to do in VSTS via some service hook?</p>

答:
I would suggest you to setup a scheduled build definition which will run git commands to figure out what needs to be deleted and delete those branches on server.

Useful Resources:

How to run git commands in build

How to delete a branch both locally and in remote?

Title: VSTS: How to auto-delete git branches


问:
Are infinite lists useful for any real world applications?
I've been using haskell for quite a while now, and I've read most of Real World Haskell and Learn You a Haskell. What I want to know is whether there is a point to a language using lazy evaluation, in particular the "advantage" of having infinite lists, is there a task which infinite lists make very easy, or even a task that is only possible with infinite lists?</p>

答:
Infinite data structures (including lists) give a huge boost to modularity and hence reusability, as explained & illustrated in John Hughes's classic paper Why Functional Programming Matters.
For instance, you can decompose complex code chunks into producer/filter/consumer pieces, each of which is potentially useful elsewhere.

So wherever you see real-world value in code reuse, you'll have an answer to your question.


问:
Renaming Files With Batch
I am new completely new to batch and have used Python, Java ect for about a year now. So as you can guess I dont know overly large amount.

I have been instructed by my employer to try and automate some tasks we do on a regular basis. This may sound like a stupid task that is easy to-do but it happens a lot and when talking to customers at the same time it get boring quick. The task: Renaming multiple folders... We do this when end users have forgotten their password or need a profile reset.

The code that I have at the moment is:

```<code>:again
@echo off
   set /p answer= Rename a file/folder(Y/N)?
   if /i "%answer:~,1%" EQU "Y" goto yes
   if /i "%answer:~,1%" EQU "N" goto no
   goto again

:yes
  set /p dirOfFile = Directory of file:
  set /p currentFolder = Name of folder to be re-named:
  set /p newFolder = What will it be re-named to:

  ren %dirOfFile%\%currentFolder% %newFolder%

:no
  exit
</code>```

The code is based off of a few sources, the Y/N and using variable from other StackOverflow posts and the ren %dirOfFile%\%currentFolder% %newFolder% from the cmd command of ren or rename.
When I use:

```<code>ren C:\Users\Zak\Desktop\TestFolder AlsoTest
</code>```

It renames a folder on my desktop from TestFolder to AlsoTest. This is what I want the batch file todo, but once its working, on multiple folders.

Thanks for any/all help!

答:
Simple You can rename any File with Batch

type the following in batch file

ren "oldfile.txt" "newfile.txt"

Title: Renaming Files With Batch

Body:
I am new completely new to batch and have used Python, Java ect for about a year now. So as you can guess I dont know overly large amount.

I have been instructed by my employer to try and automate some tasks we do on a regular basis. This may sound like a stupid task that is easy to-do but it happens a lot and when talking to customers at the same time it get boring quick. The task: Renaming multiple folders... We do this when end users have forgotten their password or need a profile reset.

The code that I have at the moment is:

:again
@echo off
   set /p answer= Rename a file/folder(Y/N)?
   if /i "%answer:~,1%" EQU "Y" goto yes
   if /i "%answer:~,1%" EQU "N" goto no
   goto again

:yes
  set /p dirOfFile = Directory of file:
  set /p currentFolder = Name of folder to be re-named:
  set /p newFolder = What will it be re-named to:

  ren %dirOfFile%\%currentFolder% %newFolder%

:no
  exit

The code is based off of a few sources, the Y/N and using variable from other StackOverflow posts and the ren %dirOfFile%\%currentFolder% %newFolder% from the cmd command of ren or rename.
When I use:

ren C:\Users\Zak\Desktop\TestFolder AlsoTest

It renames a folder on my desktop from TestFolder to AlsoTest. This is what I want the batch file todo, but once its working, on multiple folders.

Thanks for any/all help!


问:
How to push single docker image layers at time?
I've started pushing a new image, the scenario is something like this:

```<code>b57ecdb750f2: Pushing [====>                                              ]  43.57MB/473.9MB
9b7e4da6c261: Pushing [==================================================>]  18.94kB
21d523b40367: Pushed
e18c77c6a7b1: Pushing [==================>                                ]  106.9MB/285.9MB
5ee5be8f332e: Pushed
78a99e283d45: Retrying in 1 second
98b9d6eacb01: Pushing [=========================================>         ]  95.06MB/114MB
96e14acce2fd: Retrying in 1 second
787c930753b4: Pushing [==================================================>]  318.3MB/318.3MB
9f17712cba0b: Pushing [=======================>                           ]   56.9MB/122.6MB
223c0d04a137: Pushing [==================================================>]  45.18MB
fe4c16cbf7a4: Preparing
</code>```

All those layers being pushed at the same time are simply killing my internet connection, not allowing me to navigate and docker boycotting itself as many of those layers are uploaded with errors and restarting again and again.

Is there a way to  upload a single layer at time?

答:
You can specify a limit on concurrent layer uploads with a daemon flag. See the documentation here.

You need to set --max-concurrent-uploads when running the daemon.

Body:
I've started pushing a new image, the scenario is something like this:

b57ecdb750f2: Pushing [====>                                              ]  43.57MB/473.9MB
9b7e4da6c261: Pushing [==================================================>]  18.94kB
21d523b40367: Pushed
e18c77c6a7b1: Pushing [==================>                                ]  106.9MB/285.9MB
5ee5be8f332e: Pushed
78a99e283d45: Retrying in 1 second
98b9d6eacb01: Pushing [=========================================>         ]  95.06MB/114MB
96e14acce2fd: Retrying in 1 second
787c930753b4: Pushing [==================================================>]  318.3MB/318.3MB
9f17712cba0b: Pushing [=======================>                           ]   56.9MB/122.6MB
223c0d04a137: Pushing [==================================================>]  45.18MB
fe4c16cbf7a4: Preparing

All those layers being pushed at the same time are simply killing my internet connection, not allowing me to navigate and docker boycotting itself as many of those layers are uploaded with errors and restarting again and again.

Is there a way to  upload a single layer at time?


问:
matplotlib colorbar for scatter
I'm working with data that has the data has 3 plotting parameters: x,y,c. How do you create a custom color value for a scatter plot?

Extending this example I'm trying to do:

```<code>import matplotlib
import matplotlib.pyplot as plt
cm = matplotlib.cm.get_cmap('RdYlBu')
colors=[cm(1.*i/20) for i in range(20)]
xy = range(20)
plt.subplot(111)
colorlist=[colors[x/2] for x in xy] #actually some other non-linear relationship
plt.scatter(xy, xy, c=colorlist, s=35, vmin=0, vmax=20)
plt.colorbar()
plt.show()
</code>```

but the result is TypeError: You must first set_array for mappable

答:
If you're looking to scatter by two variables and color by the third, Altair can be a great choice.

Creating the dataset

```<code>import matplotlib.pyplot as plt
import numpy as np
import pandas as pd

df = pd.DataFrame(40*np.random.randn(10, 3), columns=['A', 'B','C'])
</code>```

Altair plot

```<code>from altair import *
Chart(df).mark_circle().encode(x='A',y='B', color='C').configure_cell(width=200, height=150)
</code>```

Plot

Title: matplotlib colorbar for scatter

Body:
I'm working with data that has the data has 3 plotting parameters: x,y,c. How do you create a custom color value for a scatter plot?

Extending this example I'm trying to do:

import matplotlib
import matplotlib.pyplot as plt
cm = matplotlib.cm.get_cmap('RdYlBu')
colors=[cm(1.*i/20) for i in range(20)]
xy = range(20)
plt.subplot(111)
colorlist=[colors[x/2] for x in xy] #actually some other non-linear relationship
plt.scatter(xy, xy, c=colorlist, s=35, vmin=0, vmax=20)
plt.colorbar()
plt.show()

but the result is TypeError: You must first set_array for mappable

Body:
If you're looking to scatter by two variables and color by the third, Altair can be a great choice.

Creating the dataset

import matplotlib.pyplot as plt
import numpy as np
import pandas as pd

df = pd.DataFrame(40*np.random.randn(10, 3), columns=['A', 'B','C'])

Altair plot

from altair import *
Chart(df).mark_circle().encode(x='A',y='B', color='C').configure_cell(width=200, height=150)

Plot