问:
Babel CLI ignores configuration when input is piped
This might be a bug in Babel CLI (I'm using 6.24.1), but it appears that Babel doesn't apply .babelrc when the source data is being piped to it.

Example:

Given this source file, foo.js:

```<code>const foo = 10;
</code>```

Good: This command does what you think it should, with a .babelrc in the same directory with the es2015 preset in it:

```<code>babel foo.js --out-file foo.classic.js
</code>```

This results in foo.classic.js, with properly transpiled content:

```<code>"use strict";

var foo = 10;
</code>```

Bad: This command does not do what you expect:

```<code>cat foo.js | babel --out-file foo2.classic.js
</code>```

This results in foo2.classic.js, with unchanged content:

```<code>const foo = 10;
</code>```

Good: This command does what you expect, so it's not the actual configuration at fault:

```<code>cat foo.js | babel --presets es2015 --out-file foo3.classic.js
</code>```

Result in foo3.classic.js:

```<code>"use strict";

var foo = 10;
</code>```

Analysis: In the piping cases, Babel is obviously reading the data from the pipe and passing it out (because the output file gets created), but it appears that Babel completely ignores the .babelrc when it gets the data from the pipe.

For reference, this is the .babelrc that is supposed to be applied:

```<code>{
    "presets": [ "es2015" ]
}
</code>```

Why use pipes?

For what it's worth, you might wonder, "Why pipe input to Babel?  Why not just use files?"

Well, for one thing, piping is a supported feature, so it should "just work."

But in my case, the source files being passed to Babel are themselves the result of a code-generation chain that produces valid ES6 code as output.  It would be nice not to have to have the code generator output a ~temp.js intermediate file and then have to have it be deleted afterward; it would be far better if the pipes just worked as they're supposed to.

The Question:

Is this a bug?  If it is, does anyone know of a better workaround than just emitting a file named ~temp.js, passing that to Babel, and then deleting it?

答:
This is currently expected behavior, but we've talked about some alternatives in https://github.com/babel/babel/pull/5384.

See my comment here for some info. As mentioned in there, the current fix for you would be to do

```<code>cat foo.js | babel --filename foo.js --out-file foo2.classic.js
</code>```

to tell Babel the filename, so it knows where to search for the .babelrc file.

Body:
This might be a bug in Babel CLI (I'm using 6.24.1), but it appears that Babel doesn't apply .babelrc when the source data is being piped to it.

Example:

Given this source file, foo.js:

const foo = 10;

Good: This command does what you think it should, with a .babelrc in the same directory with the es2015 preset in it:

babel foo.js --out-file foo.classic.js

This results in foo.classic.js, with properly transpiled content:

"use strict";

var foo = 10;

Bad: This command does not do what you expect:

cat foo.js | babel --out-file foo2.classic.js

This results in foo2.classic.js, with unchanged content:

const foo = 10;

Good: This command does what you expect, so it's not the actual configuration at fault:

cat foo.js | babel --presets es2015 --out-file foo3.classic.js

Result in foo3.classic.js:

"use strict";

var foo = 10;

Analysis: In the piping cases, Babel is obviously reading the data from the pipe and passing it out (because the output file gets created), but it appears that Babel completely ignores the .babelrc when it gets the data from the pipe.

For reference, this is the .babelrc that is supposed to be applied:

{
    "presets": [ "es2015" ]
}

Why use pipes?

For what it's worth, you might wonder, "Why pipe input to Babel?  Why not just use files?"

Well, for one thing, piping is a supported feature, so it should "just work."

But in my case, the source files being passed to Babel are themselves the result of a code-generation chain that produces valid ES6 code as output.  It would be nice not to have to have the code generator output a ~temp.js intermediate file and then have to have it be deleted afterward; it would be far better if the pipes just worked as they're supposed to.

The Question:

Is this a bug?  If it is, does anyone know of a better workaround than just emitting a file named ~temp.js, passing that to Babel, and then deleting it?

Body:
This is currently expected behavior, but we've talked about some alternatives in https://github.com/babel/babel/pull/5384.

See my comment here for some info. As mentioned in there, the current fix for you would be to do

cat foo.js | babel --filename foo.js --out-file foo2.classic.js

to tell Babel the filename, so it knows where to search for the .babelrc file.


来源: stackexchange

问:
I would like to add these for statements together so that i don't have to re-use them everytime i want to delay my text
I would like to add these for statements together so that i don't have to re-use them everytime i want to delay my text</p>

```<code>import time
import random
import sys
def NewGame():
    text = "Welcome to this game of luck and strategy!\n"
    for i in text:
        sys.stdout.write(i)
        sys.stdout.flush()
        time.sleep(0.1);
    # Remove when done time.sleep(2);
    text2 ="In a moment you will recieve a random\nGender, Class, Spawnpoint\n\n"
    for i in text2:
        sys.stdout.write(i)
        sys.stdout.flush()
        time.sleep(0.1);
    #time.sleep(2);
    gender = ["Male", "Female"]
    role = ["Warrior", "Mage", "Archer", "Thief", "Robot"]
    text3 = (random.choice(gender))
    for i in text3:
        sys.stdout.write(i)
        sys.stdout.flush()
        time.sleep(0.1);
NewGame()
</code>```

答:
You should write a function to combine the re-executing of statements:</p>

```<code>import time
import random
import sys

def typewriter(text):
    for i in text:
        sys.stdout.write(i)
        sys.stdout.flush()
        time.sleep(0.1);

def NewGame():
    typewriter("Welcome to this game of luck and strategy!\n")
    # Remove when done time.sleep(2);
    typewriter("In a moment you will recieve a random\nGender, Class, Spawnpoint\n\n")
    for i in text2:
        sys.stdout.write(i)
        sys.stdout.flush()
        time.sleep(0.1);
    #time.sleep(2);
    gender = ["Male", "Female"]
    role = ["Warrior", "Mage", "Archer", "Thief", "Robot"]
    text3 = (random.choice(gender))
    typewriter(text3)
NewGame()
</code>```

ContentLicense: CC BY-SA 3.0

Body:
I would like to add these for statements together so that i don't have to re-use them everytime i want to delay my text

import time
import random
import sys
def NewGame():
    text = "Welcome to this game of luck and strategy!\n"
    for i in text:
        sys.stdout.write(i)
        sys.stdout.flush()
        time.sleep(0.1);
    # Remove when done time.sleep(2);
    text2 ="In a moment you will recieve a random\nGender, Class, Spawnpoint\n\n"
    for i in text2:
        sys.stdout.write(i)
        sys.stdout.flush()
        time.sleep(0.1);
    #time.sleep(2);
    gender = ["Male", "Female"]
    role = ["Warrior", "Mage", "Archer", "Thief", "Robot"]
    text3 = (random.choice(gender))
    for i in text3:
        sys.stdout.write(i)
        sys.stdout.flush()
        time.sleep(0.1);
NewGame()

Body:
You should write a function to combine the re-executing of statements:

import time
import random
import sys

def typewriter(text):
    for i in text:
        sys.stdout.write(i)
        sys.stdout.flush()
        time.sleep(0.1);

def NewGame():
    typewriter("Welcome to this game of luck and strategy!\n")
    # Remove when done time.sleep(2);
    typewriter("In a moment you will recieve a random\nGender, Class, Spawnpoint\n\n")
    for i in text2:
        sys.stdout.write(i)
        sys.stdout.flush()
        time.sleep(0.1);
    #time.sleep(2);
    gender = ["Male", "Female"]
    role = ["Warrior", "Mage", "Archer", "Thief", "Robot"]
    text3 = (random.choice(gender))
    typewriter(text3)
NewGame()


问:
After using HealthKit to retrieve SleepAnalysis, I still get this Authorization Not Determined error
I've been using references to this error for a few days now trying to figure out a solution:

[query] Error activating query: Error Domain=com.apple.healthkit Code=5 "Authorization not determined" UserInfo={NSLocalizedDescription=Authorization not determined}

I've been using HealthKit to successfully retrieve sleep data but now I need to retrieve activity data. I set up HealthKit with this function:

```<code>let typesToRead = Set([
        HKObjectType.categoryType(forIdentifier: HKCategoryTypeIdentifier.sleepAnalysis)!,
        HKObjectType.categoryType(forIdentifier: HKCategoryTypeIdentifier.appleStandHour)!,
        HKObjectType.characteristicType(forIdentifier: HKCharacteristicTypeIdentifier.dateOfBirth)!,
        HKObjectType.characteristicType(forIdentifier: HKCharacteristicTypeIdentifier.bloodType)!,
        HKObjectType.characteristicType(forIdentifier: HKCharacteristicTypeIdentifier.biologicalSex)!,
        HKObjectType.quantityType(forIdentifier: HKQuantityTypeIdentifier.height)!,
        HKObjectType.quantityType(forIdentifier: HKQuantityTypeIdentifier.bodyMass)!,
        HKObjectType.workoutType(),
        HKObjectType.activitySummaryType()
        ])

self.healthStore.requestAuthorization(toShare: nil, read: typesToRead) { (sucess, error) -> Void in
        if sucess == false {
            NSLog("Error...")
        }
    }
</code>```

Then I create my query like:

```<code>let query = HKSampleQuery(sampleType: distanceType, predicate: nil, limit: 0, sortDescriptors: [startDateSort]) {
        (sampleQuery, results, error) -> Void in

        if let result = results {
            for item in result {
                if let sample = item as? HKQuantitySample {
                    self.workOutSamples.append(sample)
                }
            }
            print(self.workOutSamples)
        }
    }
    healthStore.execute(query)
</code>```

I have added Privacy - Health Update Usage Description and Privacy - Health Share Usage Description to info.plist AND my app's capabilities include HealthKit turned on successfully.

答: Added HKObjectType.quantityType(forIdentifier: HKQuantityTypeIdentifier.distanceWalkingRunning)! to typesToRead. My post doesn't show that I used the wrong type: quantityType when creating distanceType.

Body:
I've been using references to this error for a few days now trying to figure out a solution:

[query] Error activating query: Error Domain=com.apple.healthkit Code=5 "Authorization not determined" UserInfo={NSLocalizedDescription=Authorization not determined}

I've been using HealthKit to successfully retrieve sleep data but now I need to retrieve activity data. I set up HealthKit with this function:

let typesToRead = Set([
        HKObjectType.categoryType(forIdentifier: HKCategoryTypeIdentifier.sleepAnalysis)!,
        HKObjectType.categoryType(forIdentifier: HKCategoryTypeIdentifier.appleStandHour)!,
        HKObjectType.characteristicType(forIdentifier: HKCharacteristicTypeIdentifier.dateOfBirth)!,
        HKObjectType.characteristicType(forIdentifier: HKCharacteristicTypeIdentifier.bloodType)!,
        HKObjectType.characteristicType(forIdentifier: HKCharacteristicTypeIdentifier.biologicalSex)!,
        HKObjectType.quantityType(forIdentifier: HKQuantityTypeIdentifier.height)!,
        HKObjectType.quantityType(forIdentifier: HKQuantityTypeIdentifier.bodyMass)!,
        HKObjectType.workoutType(),
        HKObjectType.activitySummaryType()
        ])

self.healthStore.requestAuthorization(toShare: nil, read: typesToRead) { (sucess, error) -> Void in
        if sucess == false {
            NSLog("Error...")
        }
    }

Then I create my query like:

let query = HKSampleQuery(sampleType: distanceType, predicate: nil, limit: 0, sortDescriptors: [startDateSort]) {
        (sampleQuery, results, error) -> Void in

        if let result = results {
            for item in result {
                if let sample = item as? HKQuantitySample {
                    self.workOutSamples.append(sample)
                }
            }
            print(self.workOutSamples)
        }
    }
    healthStore.execute(query)

I have added Privacy - Health Update Usage Description and Privacy - Health Share Usage Description to info.plist AND my app's capabilities include HealthKit turned on successfully.


问:
Rename the "slices" in Pie chart using Highcharts in shiny R
Used the below code to  make a pie chart in shiny R interface using Highcharts but was unable to name the slices. I have used a dataset stored in csv format from my app folder.

```<code>  output$Hist<-renderHighchart({

        data<-read.csv(paste0(getwd(),"/data.csv"),header=TRUE,stringsAsFactors=FALSE)
        highchart() %>%
          hc_chart(type = "pie") %>%
          hc_plotOptions(
            series = list(showInLegend = TRUE)
          ) %>%
          hc_add_series(data =  data$Count, name = data$X) %>%
    hc_tooltip(valueDecimals = 0,
                     pointFormat = "Count: {point.y}") %>%
 hc_legend(enabled = TRUE)%>%
</code>```

Image of the chart:

答:
Like this:

```<code>library(highcharter)
data <- data.frame(X=c("name1","name2"),Count =c(20,30))
highchart() %>%
hc_add_series_labels_values(data$X, data$Count, name = "Pie",colorByPoint = TRUE, type = "pie")
</code>```

Body:
Used the below code to  make a pie chart in shiny R interface using Highcharts but was unable to name the slices. I have used a dataset stored in csv format from my app folder.

  output$Hist<-renderHighchart({

        data<-read.csv(paste0(getwd(),"/data.csv"),header=TRUE,stringsAsFactors=FALSE)
        highchart() %>%
          hc_chart(type = "pie") %>%
          hc_plotOptions(
            series = list(showInLegend = TRUE)
          ) %>%
          hc_add_series(data =  data$Count, name = data$X) %>%
    hc_tooltip(valueDecimals = 0,
                     pointFormat = "Count: {point.y}") %>%
 hc_legend(enabled = TRUE)%>%

Image of the chart:

Body:
Like this:

library(highcharter)
data <- data.frame(X=c("name1","name2"),Count =c(20,30))
highchart() %>%
hc_add_series_labels_values(data$X, data$Count, name = "Pie",colorByPoint = TRUE, type = "pie")


问:
cordova run ios has stopped working
Suddenly (since yesterday - when I upgraded to OSX 10.12.5) I cannot run cordova run ios from the command line on either the simulator or a physical device.

Any help or hints would be appreciated - I am totally blocked.

I get

```<code>[ 65%] InstallingEmbeddedProfile
[ 70%] VerifyingApplication
[ 75%] CreatingContainer
[ 80%] InstallingApplication
[ 85%] PostflightingApplication
[ 90%] SandboxingApplication
[ 95%] GeneratingApplicationMap
[100%] Installed package /Users/rob//Junk/MyApp/platforms/ios/build/device/HelloCordova.app
------ Debug phase ------
Starting debug of b33a71e77db63cb8b28523eba033d1ece54c1ca1 (N42AP, iPhone 5 (Global/CDMA), iphoneos, armv7s) a.k.a. 'Rob’s iPhone' connected through USB...
2017-06-07 12:29:23.706 ios-deploy[7470:113619] [ !! ] Unable to locate DeviceSupport directory. This probably means you don't have Xcode installed, you will need to launch the app manually and logging output will not be shown!
Error: Error code 253 for command: ios-deploy with args: --justlaunch,--no-wifi,-d,-b,/Users/rob/Junk/MyApp/platforms/ios/build/device/HelloCordova.app
</code>```

I have a DeviceSupport directory...

```<code>ls -l ~/Library/Developer/Xcode/iOS\ DeviceSupport
total 0
drwxr-xr-x  5 rob  staff  170  1 Jun 12:13 10.3.1 (14E304)
drwxr-xr-x  5 rob  staff  170  7 Jun 11:54 10.3.2 (14F89)
drwxr-xr-x  4 rob  staff  136 31 Jan  2013 5.1.1 (9B206)
drwxr-xr-x  4 rob  staff  136 22 Jan  2013 6.0.1 (10A525)
drwxr-xr-x  4 rob  staff  136 30 Jan  2013 6.0.2 (10A551)
drwxr-xr-x  4 rob  staff  136  6 Feb  2013 6.1 (10B142)
drwxr-xr-x  4 rob  staff  136  7 Mar  2013 6.1 (10B143)
drwxr-xr-x  4 rob  staff  136 22 Apr  2013 6.1.1 (10B145)
drwxr-xr-x  4 rob  staff  136  9 Aug  2013 6.1.2 (10B146)
drwxr-xr-x  4 rob  staff  136 14 Aug  2013 6.1.3 (10B329)
drwxr-xr-x  4 rob  staff  136 10 Sep  2013 6.1.4 (10B350)
drwxr-xr-x  4 rob  staff  136 12 Dec  2013 7.0.2 (11A501)
drwxr-xr-x  4 rob  staff  136 14 Jan  2015 7.0.4 (11B554a)
</code>```

I have tried to create a completely new project with

```<code>$ cordova create MyApp
$ cd MyApp
$ cordova platform add ios
$ cordova run ios
</code>```

Thanks

Rob

答: https://developer.apple.com/download/more/?name=Xcode I did downgrade and now it works again!</p>

Title: cordova run ios has stopped working

Body:
Suddenly (since yesterday - when I upgraded to OSX 10.12.5) I cannot run cordova run ios from the command line on either the simulator or a physical device.

Any help or hints would be appreciated - I am totally blocked.

I get

[ 65%] InstallingEmbeddedProfile
[ 70%] VerifyingApplication
[ 75%] CreatingContainer
[ 80%] InstallingApplication
[ 85%] PostflightingApplication
[ 90%] SandboxingApplication
[ 95%] GeneratingApplicationMap
[100%] Installed package /Users/rob//Junk/MyApp/platforms/ios/build/device/HelloCordova.app
------ Debug phase ------
Starting debug of b33a71e77db63cb8b28523eba033d1ece54c1ca1 (N42AP, iPhone 5 (Global/CDMA), iphoneos, armv7s) a.k.a. 'Rob’s iPhone' connected through USB...
2017-06-07 12:29:23.706 ios-deploy[7470:113619] [ !! ] Unable to locate DeviceSupport directory. This probably means you don't have Xcode installed, you will need to launch the app manually and logging output will not be shown!
Error: Error code 253 for command: ios-deploy with args: --justlaunch,--no-wifi,-d,-b,/Users/rob/Junk/MyApp/platforms/ios/build/device/HelloCordova.app

I have a DeviceSupport directory...

ls -l ~/Library/Developer/Xcode/iOS\ DeviceSupport
total 0
drwxr-xr-x  5 rob  staff  170  1 Jun 12:13 10.3.1 (14E304)
drwxr-xr-x  5 rob  staff  170  7 Jun 11:54 10.3.2 (14F89)
drwxr-xr-x  4 rob  staff  136 31 Jan  2013 5.1.1 (9B206)
drwxr-xr-x  4 rob  staff  136 22 Jan  2013 6.0.1 (10A525)
drwxr-xr-x  4 rob  staff  136 30 Jan  2013 6.0.2 (10A551)
drwxr-xr-x  4 rob  staff  136  6 Feb  2013 6.1 (10B142)
drwxr-xr-x  4 rob  staff  136  7 Mar  2013 6.1 (10B143)
drwxr-xr-x  4 rob  staff  136 22 Apr  2013 6.1.1 (10B145)
drwxr-xr-x  4 rob  staff  136  9 Aug  2013 6.1.2 (10B146)
drwxr-xr-x  4 rob  staff  136 14 Aug  2013 6.1.3 (10B329)
drwxr-xr-x  4 rob  staff  136 10 Sep  2013 6.1.4 (10B350)
drwxr-xr-x  4 rob  staff  136 12 Dec  2013 7.0.2 (11A501)
drwxr-xr-x  4 rob  staff  136 14 Jan  2015 7.0.4 (11B554a)

I have tried to create a completely new project with

$ cordova create MyApp
$ cd MyApp
$ cordova platform add ios
$ cordova run ios

Thanks

Rob


问:
using a jquery if condition on a span tag to show hide a div element
I am trying the following script to detect changes on a span tag and then show or hide a div element. For some reason the if statement is not working. I don't get any errors in my browser and not much information on what can be wrong with it.

```<code>$('#ch1').on('change',function(){
if('#ch1' > 6) {

        $('#box1').hide(2000);
} else {
        $('#box1').show(2000);
}
</code>```

});

答:
You probably wanted to check the elements value, seeing as you're listening for the change event.

Also, jQuery has a toggle functionality that makes this a little easier

$('#ch1').on('change', function() {
  $('#box1').toggle(this.value < 6);
});```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input id="ch1" value="2" />
<div id="box1" ">Less than six</div></code>```

As an FYI, a span doesn't change, you'll need an input.

Body:
I am trying the following script to detect changes on a span tag and then show or hide a div element. For some reason the if statement is not working. I don't get any errors in my browser and not much information on what can be wrong with it.

$('#ch1').on('change',function(){
if('#ch1' > 6) {

        $('#box1').hide(2000);
} else {
        $('#box1').show(2000);
}

});

Body:
You probably wanted to check the elements value, seeing as you're listening for the change event.

Also, jQuery has a toggle functionality that makes this a little easier

$('#ch1').on('change', function() {
  $('#box1').toggle(this.value < 6);
});

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input id="ch1" value="2" />
<div id="box1" ">Less than six</div>

As an FYI, a span doesn't change, you'll need an input.


问:
How to replace space as a newline in a textBox with Multiline property set to true?
Suppose I have this string:

```<code>string str = "The quick brown fox     jumps over the lazy dog";
</code>```

How can I replace or ignore the spaces in the string and enter each word in the multiline textBox?

Expected output:

```<code>The
quick
brown
fox
jumps
over
the
lazy
dog
</code>```

My .NET framework version is 2.0

答:
If you want compact and simple this may be the best bet:

```<code>Textbox.Lines = MyString.Split(' ');
</code>```

If you're wanting to split the text already in the box this may work:

```<code>Textbox.Lines = Textbox.Text.Split(' ');
</code>```

ContentLicense: CC BY-SA 2.5

Body:
Suppose I have this string:

string str = "The quick brown fox     jumps over the lazy dog";

How can I replace or ignore the spaces in the string and enter each word in the multiline textBox?

Expected output:

The
quick
brown
fox
jumps
over
the
lazy
dog

My .NET framework version is 2.0

Body:
If you want compact and simple this may be the best bet:

Textbox.Lines = MyString.Split(' ');

If you're wanting to split the text already in the box this may work:

Textbox.Lines = Textbox.Text.Split(' ');


问:
Passing this as prop in ReactJS
So I have some components that use a lot of functions so sometimes to avoid having todo <Component func1={func1} func2={func2} ... /> which looks ugly I do <Component component={this} /> when the same functions are called in the component. So this should obviously be slower but how much really? Is this a terrible coding-pattern? I suppose I could also just create a new obj with the used functions and pass that in instead.

EDIT: I belive the best solution is to create a function called:

getFuncs(component)
{
  return { func1: ..., func2: ... }
}

In the reactClass and then call: <Component funcs={this.getFuncs(this)} />

答:
```<code>   const componentProps = {
     func1: this.func1,
     func2: this.func2
   };
   <Component {...componentProps} />
</code>```

Title: Passing this as prop in ReactJS


问:
Using regex to restrict input in textbox

/^+{0,1}(?:\d\s?){11,13}$/ this regex allows + at first place only and numbers only...

on keypress I want user should only be able to type + at first and digits that what above regex validates But code always goes to if part..why regex not working in this scenario

```<code>function ValidatePhone(phone) {
            var expr = /^\+?(?:\d\s?){11,13}$/;
            return expr.test(phone);
        }

var countofPlus = 0;

    $("#phone").on("keypress", function (evt) {
        if (evt.key == "+")
        {
            countofPlus = countofPlus + 1;
            if (countofPlus > 1 || this.value.length >= 1) {
                return false;
            }
            else return true;
        }
        var charCode = (evt.which) ? evt.which : event.keyCode
        if (charCode > 31 && charCode != 43 && charCode != 32 && charCode != 40 && charCode != 41 && (charCode < 48 || charCode > 57))
            return false;
        return true;
    });
$("#phone").on("keyup", function (evt) {
        debugger;
        if (evt.key == "+") {
            countofPlus--;
            return true;
        }

    });
</code>```

答:
I think this regex is being applied only to the char code i.e. a string of length 1. In this case regex will always fail.

Instead, try running the regex test on the input value.

Body:
/^+{0,1}(?:\d\s?){11,13}$/ this regex allows + at first place only and numbers only...

on keypress I want user should only be able to type + at first and digits that what above regex validates But code always goes to if part..why regex not working in this scenario

function ValidatePhone(phone) {
            var expr = /^\+?(?:\d\s?){11,13}$/;
            return expr.test(phone);
        }

var countofPlus = 0;

    $("#phone").on("keypress", function (evt) {
        if (evt.key == "+")
        {
            countofPlus = countofPlus + 1;
            if (countofPlus > 1 || this.value.length >= 1) {
                return false;
            }
            else return true;
        }
        var charCode = (evt.which) ? evt.which : event.keyCode
        if (charCode > 31 && charCode != 43 && charCode != 32 && charCode != 40 && charCode != 41 && (charCode < 48 || charCode > 57))
            return false;
        return true;
    });
$("#phone").on("keyup", function (evt) {
        debugger;
        if (evt.key == "+") {
            countofPlus--;
            return true;
        }

    });


问:
implementing an abstract base class function in another template base class
I have a Visual Studio 2008 C++ project where I have a class that inherits from an abstract base class and another template class that implements a function in the abstract base class. For example:

```<code>class Foo;

struct Buzz
{
    virtual ~Buzz() {};
    virtual void Buzz_Do( Foo* ) = 0;
};

class Base
{
public:
    virtual ~Base() {};
    virtual void Base_Do( Buzz* ) = 0;
};

template< class T >
class Bar
{
public:
    virtual void Base_Do( Buzz* v )
    {
        v->Buzz_Do( static_cast< T* >( this ) );
    };
};

class Foo : public Base, public Bar< Foo >
{
};

int _tmain(int argc, _TCHAR* argv[])
{
    Foo c;
    return 0;
}
</code>```

Unfortunately, this yields the compiler error:

```<code>1>MyApp.cpp(39) : error C2259: 'Foo' : cannot instantiate abstract class
1>        due to following members:
1>        'void Base::Base_Do(Buzz *)' : is abstract
1>        MyApp.cpp(17) : see declaration of 'Base::Base_Do'
</code>```

I've tried adding a public using Bar< Foo >::Base_Do; to class Foo, but that did not help.

Is there a way to make this work or will I need to put a concrete Base_Do() implementation in Foo and not use Bar<>?

Thanks,
PaulH

答:
If possible let the Bar<> derive from Base,
and Foo derive only from Bar<T>.

Body:
I have a Visual Studio 2008 C++ project where I have a class that inherits from an abstract base class and another template class that implements a function in the abstract base class. For example:

class Foo;

struct Buzz
{
    virtual ~Buzz() {};
    virtual void Buzz_Do( Foo* ) = 0;
};

class Base
{
public:
    virtual ~Base() {};
    virtual void Base_Do( Buzz* ) = 0;
};

template< class T >
class Bar
{
public:
    virtual void Base_Do( Buzz* v )
    {
        v->Buzz_Do( static_cast< T* >( this ) );
    };
};

class Foo : public Base, public Bar< Foo >
{
};

int _tmain(int argc, _TCHAR* argv[])
{
    Foo c;
    return 0;
}

Unfortunately, this yields the compiler error:

1>MyApp.cpp(39) : error C2259: 'Foo' : cannot instantiate abstract class
1>        due to following members:
1>        'void Base::Base_Do(Buzz *)' : is abstract
1>        MyApp.cpp(17) : see declaration of 'Base::Base_Do'

I've tried adding a public using Bar< Foo >::Base_Do; to class Foo, but that did not help.

Is there a way to make this work or will I need to put a concrete Base_Do() implementation in Foo and not use Bar<>?

Thanks,
PaulH


问:
How to create a CSS Grid Layout box that spans 2 columns and 2 rows?
I've created a grid layout following the newest CSS Grid spec, but am not completely familiar with it yet. I'm trying to create the following layout without having to define grid areas for each grid child.

codepen

body {
  max-width: 1024px;
  margin: 10px auto;
}

.grid {
  display: grid;
  grid-gap: 10px;
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: 1fr 1fr 1fr;
  grid-template-areas: "a a b" "a a c" "d e f";
}

.grid__thing {
  background-color: rebeccapurple;
}

.a {
  grid-area: a;
}

.b {
  grid-area: b;
}

.c {
  grid-area: c;
}

.d {
  grid-area: d;
}

.e {
  grid-area: e;
}

.f {
  grid-area: f;
}

img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="grid">
  <div class="grid__thing a">
    <img src="https://placehold.it/1360x880" alt="" />
  </div>
  <div class="grid__thing b">
    <img src="https://placehold.it/660x405" alt="" />
  </div>
  <div class="grid__thing c">
    <img src="https://placehold.it/660x405" alt="" />
  </div>
  <div class="grid__thing d">
    <img src="https://placehold.it/660x405" alt="" />
  </div>
  <div class="grid__thing e">
    <img src="https://placehold.it/1327x817" alt="" />
  </div>
  <div class="grid__thing f">
    <img src="https://placehold.it/1327x817" alt="" />
  </div>
</div></code>```

Ideally, I'd like to be able to set all the grid sizing properties in the grid parent and then ONLY define properties in grid item A to span across 2 columns and rows.

Currently specifying each grid area and attaching a unique class like so:

```<code>.grid {
    display: grid;
    grid-gap: 10px;
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-rows:  1fr 1fr 1fr;
    grid-template-areas: "a a b"
                         "a a c"
                         "d e f";
.a {
    grid-area: a;
}
.b {
    grid-area: b;
}
.c {
    grid-area: c;
}
.d {
    grid-area: d;
}
.e {
    grid-area: e;
}
.f {
    grid-area: f;
}
</code>```

Would like to do something like this so I don't have to create a unique CSS class for each grid item:

```<code>.grid {
    display: grid;
    grid-gap: 10px;
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-rows:  1fr 1fr 1fr;
    grid-template-areas: "a a b"
                         "a a c"
                         "d e f";
}
.a {
    // The only unique selector, so this is the only thing that
    // should be given unique styling
}
</code>```

答:
Just do what you are planning; remove the useless classes.

body {
  max-width: 1024px;
  margin: 10px auto;
}

.grid {
  display: grid;
  grid-gap: 10px;
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: 1fr 1fr 1fr;
  grid-template-areas: "a a" "a a";
}

.grid__thing {
  background-color: rebeccapurple;
}

.a {
  grid-area: a;
}

img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="grid">
  <div class="grid__thing a">
    <img src="https://placehold.it/1360x880" alt="" />
  </div>
  <div class="grid__thing">
    <img src="https://placehold.it/660x405" alt="" />
  </div>
  <div class="grid__thing">
    <img src="https://placehold.it/660x405" alt="" />
  </div>
  <div class="grid__thing">
    <img src="https://placehold.it/660x405" alt="" />
  </div>
  <div class="grid__thing">
    <img src="https://placehold.it/1327x817" alt="" />
  </div>
  <div class="grid__thing">
    <img src="https://placehold.it/1327x817" alt="" />
  </div>
</div></code>```

Body:
I've created a grid layout following the newest CSS Grid spec, but am not completely familiar with it yet. I'm trying to create the following layout without having to define grid areas for each grid child.

codepen

body {
  max-width: 1024px;
  margin: 10px auto;
}

.grid {
  display: grid;
  grid-gap: 10px;
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: 1fr 1fr 1fr;
  grid-template-areas: "a a b" "a a c" "d e f";
}

.grid__thing {
  background-color: rebeccapurple;
}

.a {
  grid-area: a;
}

.b {
  grid-area: b;
}

.c {
  grid-area: c;
}

.d {
  grid-area: d;
}

.e {
  grid-area: e;
}

.f {
  grid-area: f;
}

img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

Ideally, I'd like to be able to set all the grid sizing properties in the grid parent and then ONLY define properties in grid item A to span across 2 columns and rows.

Currently specifying each grid area and attaching a unique class like so:

.grid {
    display: grid;
    grid-gap: 10px;
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-rows:  1fr 1fr 1fr;
    grid-template-areas: "a a b"
                         "a a c"
                         "d e f";
.a {
    grid-area: a;
}
.b {
    grid-area: b;
}
.c {
    grid-area: c;
}
.d {
    grid-area: d;
}
.e {
    grid-area: e;
}
.f {
    grid-area: f;
}

Would like to do something like this so I don't have to create a unique CSS class for each grid item:

.grid {
    display: grid;
    grid-gap: 10px;
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-rows:  1fr 1fr 1fr;
    grid-template-areas: "a a b"
                         "a a c"
                         "d e f";
}
.a {
    // The only unique selector, so this is the only thing that
    // should be given unique styling
}

Body:
Just do what you are planning; remove the useless classes.

body {
  max-width: 1024px;
  margin: 10px auto;
}

.grid {
  display: grid;
  grid-gap: 10px;
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: 1fr 1fr 1fr;
  grid-template-areas: "a a" "a a";
}

.grid__thing {
  background-color: rebeccapurple;
}

.a {
  grid-area: a;
}

img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

<div class="grid">
  <div class="grid__thing a">
    <img src="https://placehold.it/1360x880" alt="" />
  </div>
  <div class="grid__thing">
    <img src="https://placehold.it/660x405" alt="" />
  </div>
  <div class="grid__thing">
    <img src="https://placehold.it/660x405" alt="" />
  </div>
  <div class="grid__thing">
    <img src="https://placehold.it/660x405" alt="" />
  </div>
  <div class="grid__thing">
    <img src="https://placehold.it/1327x817" alt="" />
  </div>
  <div class="grid__thing">
    <img src="https://placehold.it/1327x817" alt="" />
  </div>
</div>

ContentLicense: CC BY-SA 4.0


问:
Maya animation in web application
I would like to use a Maya(Autodesk) 3D animation in a website but I don't have any clue how to do this. First, Is this possible? If yes what tools should I use. Should I put it in html div or iframe tag? Should I do it in JavaScript or in back-end(which is Java in my case)? Thank you!</p>

答: Maya does not support this natively. You can export maya models to a webGl renderer like three.js and render that into a canvas element.   Here's a very basic example: http://www.samwirch.com/blog/viewing-models-from-maya-in-webgl-with-threejs</p>

Title: Maya animation in web application


问:
input text box is hidden behind the keyboard on android browsers
input text box is hidden behind the keyboard on Android browsers, This issue can be solved by set position fixed for inputs but this's not a professional solution and it's causing many of other problems.

Any idea?

答:
The solution is probably a change to your UI. Most implementations will contain a scrollable div/section

```<code>.container {
    overflow-y: auto;
}
</code>```

for when the content expands over the container. This allows the user to continue scrolling without closing the keyboard. Hope this helps!

MDN: https://developer.mozilla.org/en-US/docs/Web/CSS/overflow-y

Body:
The solution is probably a change to your UI. Most implementations will contain a scrollable div/section

.container {
    overflow-y: auto;
}

for when the content expands over the container. This allows the user to continue scrolling without closing the keyboard. Hope this helps!

MDN: https://developer.mozilla.org/en-US/docs/Web/CSS/overflow-y


问:
Centering navigation element with CSS
I am trying to center the .site-nav ul li in the .site-nav ul but have not been successful. I've tried align-content, width:100%, margin: 0 auto, text-align. I am relatively new to CSS, a few months, and this is my first time posting a question here. This is the link to my codepen: https://codepen.io/darenjm/pen/eRpNEV

```<code>.clearfix:after{
content:"";
display:block;
clear:both;
}
.wrapper{
width:90%;
margin:0 auto;
}
.site-logo{
text-align:center;
padding: 20px 0 10px 0;
}
.site-nav{
background:#af2922;
}
.site-nav ul{
background:#efedee;
padding:0;
margin:0;
}
.site-nav > ul ul{
position:absolute;
}
.site-nav ul li{
background:#ecc019;
list-style:none;
}
.site-nav ul li a{
display:inline-block;
width:100px;
padding:5px 10px;
text-decoration:none;
}
.site-nav ul li:hover > a{
background:rgba(255,255,255,0.6);
}
nav > ul > li{
float:left;
}
</code>```

答:
You can use flexbox, just add this rule:

```<code>.site-nav > ul{
  display:flex;
  justify-content: center;
}
</code>```

https://codepen.io/anon/pen/bRVdXr

Title: Centering navigation element with CSS

Body:
I am trying to center the .site-nav ul li in the .site-nav ul but have not been successful. I've tried align-content, width:100%, margin: 0 auto, text-align. I am relatively new to CSS, a few months, and this is my first time posting a question here. This is the link to my codepen: https://codepen.io/darenjm/pen/eRpNEV

.clearfix:after{
content:"";
display:block;
clear:both;
}
.wrapper{
width:90%;
margin:0 auto;
}
.site-logo{
text-align:center;
padding: 20px 0 10px 0;
}
.site-nav{
background:#af2922;
}
.site-nav ul{
background:#efedee;
padding:0;
margin:0;
}
.site-nav > ul ul{
position:absolute;
}
.site-nav ul li{
background:#ecc019;
list-style:none;
}
.site-nav ul li a{
display:inline-block;
width:100px;
padding:5px 10px;
text-decoration:none;
}
.site-nav ul li:hover > a{
background:rgba(255,255,255,0.6);
}
nav > ul > li{
float:left;
}

Body:
You can use flexbox, just add this rule:

.site-nav > ul{
  display:flex;
  justify-content: center;
}

https://codepen.io/anon/pen/bRVdXr


问:
Python: Numpy array, Take every 100th timepoint for each cell ID
I have the following problem. I have an array ( the first 3 element are x,y,z coordinates, the 4th element is the time and the 5th element is the cell ID (1-9). Now i just want every 50th or 100th element of every timepoint FOR EACH CELL ID. This is no duplicate question! So for cell ID 1 I want the row with timepoint 50,100,150 , for Cell ID2 the timepoint 50,100,150 and so on!

Example array

```<code>arr = np.array([['2.0', '29.0', '24.0', '0.0', '1'],
       ['0.0', '18.0', '4.0', '0.0', '2'],
       ['16.0', '9.0', '0.0', '9990.0', '7'],
       ['20.0', '23.0', '31.0', '9990.0', '8'],
       ['65.0', '30.0', '20.0', '0.0', '9']
       ['16.0', '9.0', '0.0', '9990.0', '9']])
</code>```

答:
You could do something like this -</p>

```<code># Convert the fourth col to int type
a = arr[:,3].astype(float).astype(int)

steps = [15,50] # Define step intervals

# Get time-stepped array intervaled at either of the elements from steps
range_arr = np.arange(a.max()+1)
r = range_arr[((np.arange(a.max()+1)[:,None]%steps)==0).any(1)]

# Get mask of matches. Index into input array for final output.
out = arr[np.in1d(a,r)]
</code>```

Body:
I have the following problem. I have an array ( the first 3 element are x,y,z coordinates, the 4th element is the time and the 5th element is the cell ID (1-9). Now i just want every 50th or 100th element of every timepoint FOR EACH CELL ID. This is no duplicate question! So for cell ID 1 I want the row with timepoint 50,100,150 , for Cell ID2 the timepoint 50,100,150 and so on!

Example array

arr = np.array([['2.0', '29.0', '24.0', '0.0', '1'],
       ['0.0', '18.0', '4.0', '0.0', '2'],
       ['16.0', '9.0', '0.0', '9990.0', '7'],
       ['20.0', '23.0', '31.0', '9990.0', '8'],
       ['65.0', '30.0', '20.0', '0.0', '9']
       ['16.0', '9.0', '0.0', '9990.0', '9']])

Body:
You could do something like this -

# Convert the fourth col to int type
a = arr[:,3].astype(float).astype(int)

steps = [15,50] # Define step intervals

# Get time-stepped array intervaled at either of the elements from steps
range_arr = np.arange(a.max()+1)
r = range_arr[((np.arange(a.max()+1)[:,None]%steps)==0).any(1)]

# Get mask of matches. Index into input array for final output.
out = arr[np.in1d(a,r)]


问:
pyspark dataframe column name
what is limitation for pyspark dataframe column names. I have issue with following code ..

```<code>%livy.pyspark
df_context_spark.agg({'spatialElementLabel.value': 'count'})
</code>```

It gives ...

```<code>u'Cannot resolve column name "spatialElementLabel.value" among (lightFixtureID.value, spatialElementLabel.value);'
</code>```

The column name is evidently typed correctly. I got the dataframe by transformation from pandas dataframe. It there any issue with dot in the column name string?

答:
Dots are used for nested fields inside a structure type.  So if you had a column that was called "address" of type StructType, and inside that you had street1, street2, etc you would access it the individual fields like this:

```<code>df.select("address.street1", "address.street2", ..)
</code>```

Because of that, if you want to used a dot in your field name you need to quote the field whenever you refer to it.  For example:

```<code>from pyspark.sql.types import *

schema = StructType([StructField("my.field", StringType())])

rdd = sc.parallelize([('hello',), ('world',)])
df = sqlContext.createDataFrame(rdd, schema)

# Using backticks to quote the field name
df.select("`my.field`").show()
</code>```

Title: pyspark dataframe column name

Body:
what is limitation for pyspark dataframe column names. I have issue with following code ..

%livy.pyspark
df_context_spark.agg({'spatialElementLabel.value': 'count'})

It gives ...

u'Cannot resolve column name "spatialElementLabel.value" among (lightFixtureID.value, spatialElementLabel.value);'

The column name is evidently typed correctly. I got the dataframe by transformation from pandas dataframe. It there any issue with dot in the column name string?

Body:
Dots are used for nested fields inside a structure type.  So if you had a column that was called "address" of type StructType, and inside that you had street1, street2, etc you would access it the individual fields like this:

df.select("address.street1", "address.street2", ..)

Because of that, if you want to used a dot in your field name you need to quote the field whenever you refer to it.  For example:

from pyspark.sql.types import *

schema = StructType([StructField("my.field", StringType())])

rdd = sc.parallelize([('hello',), ('world',)])
df = sqlContext.createDataFrame(rdd, schema)

# Using backticks to quote the field name
df.select("`my.field`").show()


问:
Data matching in R
I have two dataframes with the same length (1000) and width (200). In both dataframes, each row is a person. In one dataframe, each column is a binary item score (i.e. 0 or 1). In the other dataframe, each column is the item label. Here is it:

Dataframe 1:

```<code>item1 item2 item3
0     1     1
1     0     0
1     1     1
</code>```

Dataframe 2:

```<code>item1   item2   item3
C2HSD   WW11S3  EI22S
WW11S3  2JDDS   TT6SQ1
EI22S   TT6SQ1  331ID
</code>```

What I want is a combined and matched dataframe like this:

```<code>C2HSD  WW11S3 EI22S 2JDDS TT6SQ1 331ID
0      1      1     NA    NA     NA
NA     1      NA    0     0      NA
NA     NA     1     NA    1      1
</code>```

Thank you!

答:
We can melt the two datasets to 'long' format', do a left_join, and later spread it to 'wide' format after removing the 'Var2'

```<code>library(reshape2)
library(tidyverse)
d1 <- melt(as.matrix(df1))
d2 <- melt(as.matrix(df2))
left_join(d2, d1, by = c("Var1", "Var2")) %>%
      select(-Var2) %>%
      spread(value.x, value.y) %>%
      select(-Var1)
#   2JDDS 331ID C2HSD EI22S TT6SQ WW11S
#1    NA    NA     0     1    NA     1
#2     0    NA    NA    NA     0     1
#3    NA     1    NA     1     1    NA
</code>```

A base R option would be to replace the corresponding column values of 'df2' with NA where the 'df1' values are 0 using Map, then stack it to 'data.frame', transform the 'values' column to factor and get the frequency with table

```<code>un1 <- unique(unlist(df2))
table(transform(stack(Map(function(x,y) replace(y, !x, NA),
  df1, df2))[2:1], values = factor(values, levels = un1)))
</code>```

Title: Data matching in R

Body:
I have two dataframes with the same length (1000) and width (200). In both dataframes, each row is a person. In one dataframe, each column is a binary item score (i.e. 0 or 1). In the other dataframe, each column is the item label. Here is it:

Dataframe 1:

item1 item2 item3
0     1     1
1     0     0
1     1     1

Dataframe 2:

item1   item2   item3
C2HSD   WW11S3  EI22S
WW11S3  2JDDS   TT6SQ1
EI22S   TT6SQ1  331ID

What I want is a combined and matched dataframe like this:

C2HSD  WW11S3 EI22S 2JDDS TT6SQ1 331ID
0      1      1     NA    NA     NA
NA     1      NA    0     0      NA
NA     NA     1     NA    1      1

Thank you!

Body:
We can melt the two datasets to 'long' format', do a left_join, and later spread it to 'wide' format after removing the 'Var2'

library(reshape2)
library(tidyverse)
d1 <- melt(as.matrix(df1))
d2 <- melt(as.matrix(df2))
left_join(d2, d1, by = c("Var1", "Var2")) %>%
      select(-Var2) %>%
      spread(value.x, value.y) %>%
      select(-Var1)
#   2JDDS 331ID C2HSD EI22S TT6SQ WW11S
#1    NA    NA     0     1    NA     1
#2     0    NA    NA    NA     0     1
#3    NA     1    NA     1     1    NA

A base R option would be to replace the corresponding column values of 'df2' with NA where the 'df1' values are 0 using Map, then stack it to 'data.frame', transform the 'values' column to factor and get the frequency with table

un1 <- unique(unlist(df2))
table(transform(stack(Map(function(x,y) replace(y, !x, NA),
  df1, df2))[2:1], values = factor(values, levels = un1)))


问:
Can't get date modified From Json
i can get section name , url  web title and headline but i can't get lastmodified date  from parse json this code for Json

{
   "response":{
      "status":"ok",
      "userTier":"developer",
      "total":368,
      "startIndex":1,
      "pageSize":10,
      "currentPage":1,
      "pages":37,
      "orderBy":"relevance",
      "results":[
         {
            "id":"technology/2017/may/24/fitness-trackers-out-of-step-when-measuring-calories-research-shows",
            "type":"article",
            "sectionId":"technology",
            "sectionName":"Technology",
            "webPublicationDate":"2017-05-24T15:00:24Z",
            "webTitle":"Fitness trackers out of step when measuring calories, research shows",
            "webUrl":"https://www.theguardian.com/technology/2017/may/24/fitness-trackers-out-of-step-when-measuring-calories-research-shows",
            "apiUrl":"https://content.guardianapis.com/technology/2017/may/24/fitness-trackers-out-of-step-when-measuring-calories-research-shows",
            "fields":{
               "headline":"Fitness trackers out of step when measuring calories, research shows",
               "lastModified":"2017-05-24T15:02:19Z",
               "thumbnail":"https://media.guim.co.uk/8d3e17604195078ec89e20329e2ddc5027eca8ea/0_213_6362_3817/500.jpg"
            },
            "isHosted":false
         },```
</div>
</div>
</p>

<p>and this my code to parse it.</p>

<p>JSONObject response = root.getJSONObject("response");</p>

```        if(response.has("results")){

            JSONArray results = response.getJSONArray("results");
            for(int i=0;i<results.length();i++){
                long lastModified=0;
                String headline=null;
                JSONObject details=results.getJSONObject(i);
                String sectionName=details.getString("sectionName");
                Log.i(LOG_TAG,sectionName);
                String webUrl=details.getString("webUrl");
                Log.i(LOG_TAG,webUrl);
                if(details.has("fields")){
                JSONObject fields=details.getJSONObject("fields");
                    if(fields.has("headline")){

                 headline =fields.getString("headline");
                Log.i(LOG_TAG,headline);}
                if(fields.has("lastModified")){
                 lastModified =fields.getLong("lastModified");
                Log.i(LOG_TAG, String.valueOf(lastModified));}}
```

i do not know why not get lastmodified date?

答:
That DateTime format is actually ISO 8601 DateTime. JSON does not specify any particular format for dates/times. If you Google a bit, you will find plenty of implementations to parse it in Java.

Here's one

If you are open to using something other than Java's built-in Date/Time/Calendar classes, I would also suggest Joda Time. They offer (among many things) a ISODateTimeFormat to parse these kinds of strings.

Title: Can't get date modified From Json

Body:
i can get section name , url  web title and headline but i can't get lastmodified date  from parse json this code for Json

{
   "response":{
      "status":"ok",
      "userTier":"developer",
      "total":368,
      "startIndex":1,
      "pageSize":10,
      "currentPage":1,
      "pages":37,
      "orderBy":"relevance",
      "results":[
         {
            "id":"technology/2017/may/24/fitness-trackers-out-of-step-when-measuring-calories-research-shows",
            "type":"article",
            "sectionId":"technology",
            "sectionName":"Technology",
            "webPublicationDate":"2017-05-24T15:00:24Z",
            "webTitle":"Fitness trackers out of step when measuring calories, research shows",
            "webUrl":"https://www.theguardian.com/technology/2017/may/24/fitness-trackers-out-of-step-when-measuring-calories-research-shows",
            "apiUrl":"https://content.guardianapis.com/technology/2017/may/24/fitness-trackers-out-of-step-when-measuring-calories-research-shows",
            "fields":{
               "headline":"Fitness trackers out of step when measuring calories, research shows",
               "lastModified":"2017-05-24T15:02:19Z",
               "thumbnail":"https://media.guim.co.uk/8d3e17604195078ec89e20329e2ddc5027eca8ea/0_213_6362_3817/500.jpg"
            },
            "isHosted":false
         },

and this my code to parse it.

JSONObject response = root.getJSONObject("response");

        if(response.has("results")){

            JSONArray results = response.getJSONArray("results");
            for(int i=0;i<results.length();i++){
                long lastModified=0;
                String headline=null;
                JSONObject details=results.getJSONObject(i);
                String sectionName=details.getString("sectionName");
                Log.i(LOG_TAG,sectionName);
                String webUrl=details.getString("webUrl");
                Log.i(LOG_TAG,webUrl);
                if(details.has("fields")){
                JSONObject fields=details.getJSONObject("fields");
                    if(fields.has("headline")){

                 headline =fields.getString("headline");
                Log.i(LOG_TAG,headline);}
                if(fields.has("lastModified")){
                 lastModified =fields.getLong("lastModified");
                Log.i(LOG_TAG, String.valueOf(lastModified));}}

i do not know why not get lastmodified date?


问:
Interactive plotting in Jupyter results in subsequent plots being appended
I am trying to make an interactive plot in Jupyter, and it works somewhat with one problem, which is that every time I hit the button to generate a plot, a new plot is appended instead of the current one being replaced. Any ideas on how to fix this problem?

```<code>field_ddl = widgets.Dropdown(
    options=['race', 'gender', 'grade'],
    value='race',
    description='field:',
    disabled=False,
    button_style='info'
)
graph_btn = widgets.Button(
    description='graph',
    disabled=False,
    button_style='success',
    tooltip='distribution plot',
    icon='check'
)

def graph_btn_clicked(e):
    field = field_ddl.value
    df[field].value_counts().plot(kind='bar', title=field)

graph_btn.on_click(graph_btn_clicked)

display(field_ddl)
display(graph_btn)
</code>```

I've looked up the interact feature, but that doesn't seem to help. Upon initialization, a graph is produced, but when the I select another field and hit the button again, nothing happens.

```<code>interact(graph_btn_clicked, x=graph_btn)
</code>```

答:
You may use the interactive backend

```<code>%matplotlib notebook
</code>```

Then create a figure and an axes to plot to,

```<code>fig, ax = plt.subplots()
</code>```

Then each time the button is clicked, clear the old plot and plot the new to the same axes.

```<code>def graph_btn_clicked(e):
    field = field_ddl.value
    ax.clear()
    df[field].value_counts().plot(kind='bar', title=field, ax=ax)
</code>```

Body:
I am trying to make an interactive plot in Jupyter, and it works somewhat with one problem, which is that every time I hit the button to generate a plot, a new plot is appended instead of the current one being replaced. Any ideas on how to fix this problem?

field_ddl = widgets.Dropdown(
    options=['race', 'gender', 'grade'],
    value='race',
    description='field:',
    disabled=False,
    button_style='info'
)
graph_btn = widgets.Button(
    description='graph',
    disabled=False,
    button_style='success',
    tooltip='distribution plot',
    icon='check'
)

def graph_btn_clicked(e):
    field = field_ddl.value
    df[field].value_counts().plot(kind='bar', title=field)

graph_btn.on_click(graph_btn_clicked)

display(field_ddl)
display(graph_btn)

I've looked up the interact feature, but that doesn't seem to help. Upon initialization, a graph is produced, but when the I select another field and hit the button again, nothing happens.

interact(graph_btn_clicked, x=graph_btn)

Body:
You may use the interactive backend

%matplotlib notebook

Then create a figure and an axes to plot to,

fig, ax = plt.subplots()

Then each time the button is clicked, clear the old plot and plot the new to the same axes.

def graph_btn_clicked(e):
    field = field_ddl.value
    ax.clear()
    df[field].value_counts().plot(kind='bar', title=field, ax=ax)


问:
Xcode 9: can't convert float3 to int3
While trying to compile my project in Xcode 9, I get errors for conversions from float3 to int3. The following line now fails to compile:

```<code>var max : int3 = vector_int(bounds.maxBounds * float3(1.0/8.0) + float3(1.0))
</code>```

With the error:

Use of unresolved identifier 'vector_int'

So the old conversion function vector_int has gone away. The "fix it" suggestion doesn't work either.

var max : int3 = vector_int3(bounds.maxBounds * float3(1.0/8.0) + float3(1.0))

yields:

Cannot invoke initializer for type 'vector_int3' with an argument list of type '(float3)'

I can write my own little conversion functions, but surely there's a built-in way to do this, no?

答:
vector_int has been replaced by simd_int:

```<code>var max : int3 = simd_int(bounds.maxBounds * float3(1.0/8.0) + float3(1.0))
</code>```

Title: Xcode 9: can't convert float3 to int3

Body:
While trying to compile my project in Xcode 9, I get errors for conversions from float3 to int3. The following line now fails to compile:

var max : int3 = vector_int(bounds.maxBounds * float3(1.0/8.0) + float3(1.0))

With the error:

Use of unresolved identifier 'vector_int'

So the old conversion function vector_int has gone away. The "fix it" suggestion doesn't work either.

var max : int3 = vector_int3(bounds.maxBounds * float3(1.0/8.0) + float3(1.0))

yields:

Cannot invoke initializer for type 'vector_int3' with an argument list of type '(float3)'

I can write my own little conversion functions, but surely there's a built-in way to do this, no?

Body:
vector_int has been replaced by simd_int:

var max : int3 = simd_int(bounds.maxBounds * float3(1.0/8.0) + float3(1.0))


问:
Error on vagrant up for laravel homestead
Hi there I have encountered below error after running vagrant up:

```<code>    $ vagrant up
Bringing machine 'homestead-7' up with 'virtualbox' provider...
==> homestead-7: Clearing any previously set forwarded ports...
==> homestead-7: Clearing any previously set network interfaces...
==> homestead-7: Preparing network interfaces based on configuration...
    homestead-7: Adapter 1: nat
    homestead-7: Adapter 2: hostonly
==> homestead-7: Forwarding ports...
    homestead-7: 80 (guest) => 8000 (host) (adapter 1)
    homestead-7: 443 (guest) => 44300 (host) (adapter 1)
    homestead-7: 3306 (guest) => 33060 (host) (adapter 1)
    homestead-7: 5432 (guest) => 54320 (host) (adapter 1)
    homestead-7: 22 (guest) => 2222 (host) (adapter 1)
==> homestead-7: Running 'pre-boot' VM customizations...
==> homestead-7: Booting VM...
There was an error while executing `VBoxManage`, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.

Command: ["startvm", "83b1dbca-4d9f-4828-a544-d8a88124eafe", "--type", "headless"]

Stderr: VBoxManage.exe: error: The virtual machine 'homestead-7' has terminated unexpectedly during startup with exit code -1073741819 (0xc0000005)
VBoxManage.exe: error: Details: code E_FAIL (0x80004005), component MachineWrap, interface IMachine
</code>```

The vagrant used to work just fine and this error happens right after Windows 10 update.
I have tried below commands non resolve the issue:

```<code>vagrant reloead
vagrant reload --provision
</code>```

vagrant and homestead version:

```<code>$ vagrant -v
Vagrant 1.9.1
$ homestead -v Laravel
Homestead version 3.1.0
</code>```

I couldn't run virtual box application even through run as administrator option (no error/warning). I check the version through cmd:

```<code>C:\Program Files\Oracle\VirtualBox>vboxmanage
--version 5.1.8r111374
</code>```

Event Viewer error upon virtual box run:

```<code>Faulting application name: VirtualBox.exe, version: 5.1.8.11374, time stamp: 0x58062715
Faulting module name: VirtualBox.exe, version: 5.1.8.11374, time stamp: 0x58062715
Exception code: 0xc0000005
Fault offset: 0x00000000000139bd
Faulting process id: 0x15fc
Faulting application start time: 0x01d2df9836f7498f
Faulting application path: C:\Program Files\Oracle\VirtualBox\VirtualBox.exe
Faulting module path: C:\Program Files\Oracle\VirtualBox\VirtualBox.exe
Report Id: e94ebe5e-a1f3-4157-92a5-3452486712ef
Faulting package full name:
Faulting package-relative application ID:
</code>```

Thanks in advance.

答:
I had this issue today after the latest Windows update. Installing the latest version of Virtual Box (5.1.22) solved this for me. I was at 5.1.6.

You may need to also update the VirtualBox Guest Additions.

Body:
Hi there I have encountered below error after running vagrant up:

    $ vagrant up
Bringing machine 'homestead-7' up with 'virtualbox' provider...
==> homestead-7: Clearing any previously set forwarded ports...
==> homestead-7: Clearing any previously set network interfaces...
==> homestead-7: Preparing network interfaces based on configuration...
    homestead-7: Adapter 1: nat
    homestead-7: Adapter 2: hostonly
==> homestead-7: Forwarding ports...
    homestead-7: 80 (guest) => 8000 (host) (adapter 1)
    homestead-7: 443 (guest) => 44300 (host) (adapter 1)
    homestead-7: 3306 (guest) => 33060 (host) (adapter 1)
    homestead-7: 5432 (guest) => 54320 (host) (adapter 1)
    homestead-7: 22 (guest) => 2222 (host) (adapter 1)
==> homestead-7: Running 'pre-boot' VM customizations...
==> homestead-7: Booting VM...
There was an error while executing `VBoxManage`, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.

Command: ["startvm", "83b1dbca-4d9f-4828-a544-d8a88124eafe", "--type", "headless"]

Stderr: VBoxManage.exe: error: The virtual machine 'homestead-7' has terminated unexpectedly during startup with exit code -1073741819 (0xc0000005)
VBoxManage.exe: error: Details: code E_FAIL (0x80004005), component MachineWrap, interface IMachine

The vagrant used to work just fine and this error happens right after Windows 10 update.
I have tried below commands non resolve the issue:

vagrant reloead
vagrant reload --provision

vagrant and homestead version:

$ vagrant -v
Vagrant 1.9.1
$ homestead -v Laravel
Homestead version 3.1.0

I couldn't run virtual box application even through run as administrator option (no error/warning). I check the version through cmd:

C:\Program Files\Oracle\VirtualBox>vboxmanage
--version 5.1.8r111374

Event Viewer error upon virtual box run:

Faulting application name: VirtualBox.exe, version: 5.1.8.11374, time stamp: 0x58062715
Faulting module name: VirtualBox.exe, version: 5.1.8.11374, time stamp: 0x58062715
Exception code: 0xc0000005
Fault offset: 0x00000000000139bd
Faulting process id: 0x15fc
Faulting application start time: 0x01d2df9836f7498f
Faulting application path: C:\Program Files\Oracle\VirtualBox\VirtualBox.exe
Faulting module path: C:\Program Files\Oracle\VirtualBox\VirtualBox.exe
Report Id: e94ebe5e-a1f3-4157-92a5-3452486712ef
Faulting package full name:
Faulting package-relative application ID:

Thanks in advance.


问:
Envers only Audit delete
I have a class audited by envers. For this specific class only need audit in delete .
How make this?
thanks

My class:

```<code>@Audited
@Entity
@Table(name = "MY_TABLE")
public class MyClass{...}
</code>```

答:
If you're using the DefaultAuditStrategy, the best approach to doing this would be to subclass all the various event listeners in order to only react in the delete listener as suggested in the comments using Conditional Auditing.

On the other hand if you're using the ValidityAuditStrategy, I would highly recommend against using the conditional auditing technique as that approach doesn't work well using that specific audit strategy.

The approach to conditional auditing is being overhauled in Envers 6.0,  allowing it to be more flexible and less intrusive on users to override listener behavior directly.

Title: Envers only Audit delete

Body:
I have a class audited by envers. For this specific class only need audit in delete .
How make this?
thanks

My class:

@Audited
@Entity
@Table(name = "MY_TABLE")
public class MyClass{...}


答:
You are Using lastModified =fields.getLong("lastModified"); whereas
  you should use getString() because you lastModified date is String
  Type.

Title: Can't get date modified From Json


问:
MATLAB: atan2 breaking ode15s
I have a program that runs ode15s a few thousand times in order to find a particular solution. However, I'm getting many integration tolerance errors such as the following:

"Warning: Failure at t=5.144337e+02.  Unable to meet integration tolerances without reducing the step size below the smallest value allowed (1.818989e-12) at time t."

Such warnings cause the program to slow down drastically, and sometimes even grind to a complete halt. The following is some test code that re-produces the error:

```<code>%Simulation constants
G = 6.672e-11; %Gravitational constant
M = 6.39e23; %Mass of Mars (kg)
g = 9.81; %Gravitational acceleration on Earth (m/s^2);
T1 = 845000/3; %Total engine thrust, 1 engine (N)
Isp = 282; %Engine specific impulse (s)
mdot1 = T1/(g*Isp); %Engine mass flow rate (kg/s)
xinit_on2 = [72368.8347685214;
            3384891.40103322;
            -598.36623436025;
            -1440.49702235844;
            16330.430678033]
tspan_on2 = [436.600093957202, 520.311296453027];
[t3,x3] = ode15s(@(t,x) engine_on_2(t, x, G, g, M, Isp, T1), tspan_on2, xinit_on2)
</code>```

where the function engine_on_2 contains the system of ODEs that model the descent of a rocket, and is given by,

```<code>function xdot = engine_on_2(t, x, G, g, M, Isp, T1)
gamma = atan2(x(4),x(3)); %flight-path angle
xdot = [x(3); %xdot1: x-velocity
        x(4); %xdot2: y-velocity
        -(G*M*x(1))/((x(1)^2+x(2)^2)^(3/2))-(T1/x(5))*cos(gamma); %xdot3: x-acceleration
        -(G*M*x(2))/((x(1)^2+x(2)^2)^(3/2))-(T1/x(5))*sin(gamma); %xdot4: y-acceleration
        -T1/(g*Isp)]; %xdot5: engine mass flow rate
end
</code>```

Having done some testing, it seems that I am getting the integration tolerance warnings because of the use of the atan2 function in gamma = atan2(x(4),x(3)) which is used to calculate the flight-path angle of the rocket. If I change atan2 to another function (for example cos or sin) I don't get any integration tolerance warnings anymore (although, due to such a change, my solutions are obviously incorrect). As such, I was wondering if I am using atan2 incorrectly, or if there is a way to implement it differently so that I do not get the integration tolerance errors anymore. Furthermore, could it be that I am incorrect and that it is something other than atan2 that is causing the errors?

答:
Use the odeset function to create an options structure that you then pass to the solver. RelTol and AbsTol can be adjusted in the ODE solver to eliminate your error.  I was able to run your code using this addition without any errors:

```<code>options = odeset('RelTol',1e-13,'AbsTol',1e-20)

[t3,x3] = ode15s(@(t,x) engine_on_2(t, x, G, g, M, Isp, T1), tspan_on2, xinit_on2, options)
</code>```

See the options are passed to the ODE solver as a 4th input parameter.  Note the RelTol maxes out just above 1e-13 but hopefully that's fine for your application.  Also you can try any of the other ODE solvers which can get rid of your error but from my playing around ode15s seems quite fast.

Title: MATLAB: atan2 breaking ode15s

Body:
I have a program that runs ode15s a few thousand times in order to find a particular solution. However, I'm getting many integration tolerance errors such as the following:

"Warning: Failure at t=5.144337e+02.  Unable to meet integration tolerances without reducing the step size below the smallest value allowed (1.818989e-12) at time t."

Such warnings cause the program to slow down drastically, and sometimes even grind to a complete halt. The following is some test code that re-produces the error:

%Simulation constants
G = 6.672e-11; %Gravitational constant
M = 6.39e23; %Mass of Mars (kg)
g = 9.81; %Gravitational acceleration on Earth (m/s^2);
T1 = 845000/3; %Total engine thrust, 1 engine (N)
Isp = 282; %Engine specific impulse (s)
mdot1 = T1/(g*Isp); %Engine mass flow rate (kg/s)
xinit_on2 = [72368.8347685214;
            3384891.40103322;
            -598.36623436025;
            -1440.49702235844;
            16330.430678033]
tspan_on2 = [436.600093957202, 520.311296453027];
[t3,x3] = ode15s(@(t,x) engine_on_2(t, x, G, g, M, Isp, T1), tspan_on2, xinit_on2)

where the function engine_on_2 contains the system of ODEs that model the descent of a rocket, and is given by,

function xdot = engine_on_2(t, x, G, g, M, Isp, T1)
gamma = atan2(x(4),x(3)); %flight-path angle
xdot = [x(3); %xdot1: x-velocity
        x(4); %xdot2: y-velocity
        -(G*M*x(1))/((x(1)^2+x(2)^2)^(3/2))-(T1/x(5))*cos(gamma); %xdot3: x-acceleration
        -(G*M*x(2))/((x(1)^2+x(2)^2)^(3/2))-(T1/x(5))*sin(gamma); %xdot4: y-acceleration
        -T1/(g*Isp)]; %xdot5: engine mass flow rate
end

Having done some testing, it seems that I am getting the integration tolerance warnings because of the use of the atan2 function in gamma = atan2(x(4),x(3)) which is used to calculate the flight-path angle of the rocket. If I change atan2 to another function (for example cos or sin) I don't get any integration tolerance warnings anymore (although, due to such a change, my solutions are obviously incorrect). As such, I was wondering if I am using atan2 incorrectly, or if there is a way to implement it differently so that I do not get the integration tolerance errors anymore. Furthermore, could it be that I am incorrect and that it is something other than atan2 that is causing the errors?

Body:
Use the odeset function to create an options structure that you then pass to the solver. RelTol and AbsTol can be adjusted in the ODE solver to eliminate your error.  I was able to run your code using this addition without any errors:

options = odeset('RelTol',1e-13,'AbsTol',1e-20)

[t3,x3] = ode15s(@(t,x) engine_on_2(t, x, G, g, M, Isp, T1), tspan_on2, xinit_on2, options)

See the options are passed to the ODE solver as a 4th input parameter.  Note the RelTol maxes out just above 1e-13 but hopefully that's fine for your application.  Also you can try any of the other ODE solvers which can get rid of your error but from my playing around ode15s seems quite fast.


问:
Start a Animation when I press a Button doesn't work
I have a beginning Animation which is called divanimated. Its a rectangel which comes in. Now I want to start a 2nd Animation on this div when I hit a button. I don't know why it isn't working.
Here is my code:

```<code>    <div class="div"> </div>
    <img src="/arrowright.png" class="arrowright">
    <script>
        $(".arrowright").click(function(){
            $(".div").toggleClass("divanimated");
        });
    </script>
</code>```

css:

```<code>.divanimated{
animation-name: divanimated;
-webkit-animation-name: divanimated;

animation-duration: 1.5s;
-webkit-animation-duration: 1.5s;

animation-timing-function: ease-out;
-webkit-animation-timing-function: ease-out;

transform-origin: 0% 0%;
-ms-transform-origin: 0% 0%;
-webkit-transform-origin: 0% 0%;

 background: #e74c3c;
z-index: 1;
width: 72.8vw;
height: 39vh;
margin-top: 136.5vh;
margin-left: 13.6vw;
position: absolute;
border-radius: 7vh;
display: none;
box-shadow:2px 2px 10px #333333;
}

@keyframes divanimated{
0% {
    transform: scaleX(0.3);
}
40% {
    transform: scaleX(1.02);
}
60% {
    transform: scaleX(0.98);
}
80% {
    transform: scaleX(1.01);
}
100% {
    transform: scaleX(0.98);
}
80% {
    transform: scaleX(1.01);
}
100% {
    transform: scaleX(1);
}
}

@-webkit-keyframes divanimated{
0% {
    -webkit-transform: scaleX(0.3);
}
40% {
    -webkit-transform: scaleX(1.02);
}
60% {
    -webkit-transform: scaleX(0.98);
}
80% {
    -webkit-transform: scaleX(1.01);
}
100% {
    -webkit-transform: scaleX(0.98);
}
80% {
    -webkit-transform: scaleX(1.01);
}
100% {
    -webkit-transform: scaleX(1);
}
}
.div{
animation-name: div;
-webkit-animation-name: div;

animation-duration: 1.6s;
-webkit-animation-duration: 1.6s;

animation-timing-function: ease-out;
-webkit-animation-timing-function: ease -out;

visibility: visible !important;

background: #e74c3c;
z-index: 1;
width: 72.8vw;
height: 39vh;
margin-top: 136.5vh;
margin-left: 13.6vw;
position: absolute;
border-radius: 7vh;
display: none;
box-shadow:2px 2px 10px #333333;
}

@keyframes div{
0% {
    transform: translateY(100%) scaleX(0.5);
}
30%{
    transform: translateY(-8%) scaleX(0.5);
}
40%{
    transform: translateY(2%) scaleX(0.5);
}
50%{
    transform: translateY(0%) scaleX(1.1);
}
60%{
    transform: translateY(0%) scaleX(0.9);
}
70% {
    transform: translateY(0%) scaleX(1.05);
}
80%{
    transform: translateY(0%) scaleX(0.95);
}
90% {
    transform: translateY(0%) scaleX(1.02);
}
100%{
    transform: translateY(0%) scaleX(1);
}
}

@-webkit-keyframes div{
0% {
    -webkit-transform: translateY(100%) scaleX(0.5);
}
30%{
    -webkit-transform: translateY(-8%) scaleX(0.5);
}
40%{
    -webkit-transform: translateY(2%) scaleX(0.5);
}
50%{
    -webkit-transform: translateY(0%) scaleX(1.1);
}
60%{
    -webkit-transform: translateY(0%) scaleX(0.9);
}
70% {
    -webkit-transform: translateY(0%) scaleX(1.05);
}
80%{
    -webkit-transform: translateY(0%) scaleX(0.95);
}
90% {
    -webkit-transform: translateY(0%) scaleX(1.02);
}
100%{
    -webkit-transform: translateY(0%) scaleX(1);
}
}
</code>```

Can someone help me ? Whats wrong with my code ?

Thanks for the help.

答:
Here's the answer...

// Created a JS function which we'll call when arrow is clicked
function myFunction() {
  document.getElementById("div").className = "divanimated";
}```
<pre class="snippet-code-css lang-css prettyprint-override"><code>.arrowright{
  height: 50px;
  width: 50px;
  margin-top: 50vh;
  margin-left:90vw;
}

.divanimated{
  animation-name: divanimated;
  -webkit-animation-name: divanimated;
  animation-duration: 1.5s;
  -webkit-animation-duration: 1.5s;
  animation-timing-function: ease-out;
  -webkit-animation-timing-function: ease-out;
  transform-origin: 0% 0%;
  -ms-transform-origin: 0% 0%;
  -webkit-transform-origin: 0% 0%;
  background: #e74c3c;
  z-index: 1;
  width: 72.8vw;
  height: 39vh;
  margin-top: 136.5vh;
  margin-left: 13.6vw;
  position: absolute;
  border-radius: 7vh;
  box-shadow:2px 2px 10px #333333;
}

@keyframes divanimated{
  0% {
    transform: scaleX(0.3);
  }
  40% {
    transform: scaleX(1.02);
  }
  60% {
    transform: scaleX(0.98);
  }
  80% {
    transform: scaleX(1.01);
  }
  100% {
    transform: scaleX(0.98);
  }
  80% {
    transform: scaleX(1.01);
  }
  100% {
    transform: scaleX(1);
  }
}

@-webkit-keyframes divanimated{
  0% {
    -webkit-transform: scaleX(0.3);
  }
  40% {
    -webkit-transform: scaleX(1.02);
  }
  60% {
    -webkit-transform: scaleX(0.98);
  }
  80% {
    -webkit-transform: scaleX(1.01);
  }
  100% {
    -webkit-transform: scaleX(0.98);
  }
  80% {
    -webkit-transform: scaleX(1.01);
  }
  100% {
    -webkit-transform: scaleX(1);
  }
}

/* Moved this into a div ID as before it was moving the div down */
#div {
  visibility: visible !important;
  background: #e74c3c;
  z-index: 1;
  width: 72.8vw;
  height: 39vh;
  margin-top: 40.5vh;
  margin-left: 13.6vw;
  position: absolute;
  border-radius: 7vh;
  box-shadow:2px 2px 10px #333333;
}

.div{
  animation-name: div;
  -webkit-animation-name: div;
  animation-duration: 1.6s;
  -webkit-animation-duration: 1.6s;
  animation-timing-function: ease-out;
  -webkit-animation-timing-function: ease -out;
}

@keyframes div{
  0% {
    transform: translateY(100%) scaleX(0.5);
  }
  30%{
    transform: translateY(-8%) scaleX(0.5);
  }
  40%{
    transform: translateY(2%) scaleX(0.5);
  }
  50%{
    transform: translateY(0%) scaleX(1.1);
  }
  60%{
    transform: translateY(0%) scaleX(0.9);
  }
  70% {
    transform: translateY(0%) scaleX(1.05);
  }
  80%{
    transform: translateY(0%) scaleX(0.95);
  }
  90% {
    transform: translateY(0%) scaleX(1.02);
  }
  100%{
    transform: translateY(0%) scaleX(1);
  }
}

@-webkit-keyframes div{
  0% {
    -webkit-transform: translateY(100%) scaleX(0.5);
  }
  30%{
    -webkit-transform: translateY(-8%) scaleX(0.5);
  }
  40%{
    -webkit-transform: translateY(2%) scaleX(0.5);
  }
  50%{
    -webkit-transform: translateY(0%) scaleX(1.1);
  }
  60%{
    -webkit-transform: translateY(0%) scaleX(0.9);
  }
  70% {
    -webkit-transform: translateY(0%) scaleX(1.05);
  }
  80%{
    -webkit-transform: translateY(0%) scaleX(0.95);
  }
  90% {
    -webkit-transform: translateY(0%) scaleX(1.02);
  }
  100%{
    -webkit-transform: translateY(0%) scaleX(1);
  }
}</code>```

```

Body:
I have a beginning Animation which is called divanimated. Its a rectangel which comes in. Now I want to start a 2nd Animation on this div when I hit a button. I don't know why it isn't working.
Here is my code:

css:

.divanimated{
animation-name: divanimated;
-webkit-animation-name: divanimated;

animation-duration: 1.5s;
-webkit-animation-duration: 1.5s;

animation-timing-function: ease-out;
-webkit-animation-timing-function: ease-out;

transform-origin: 0% 0%;
-ms-transform-origin: 0% 0%;
-webkit-transform-origin: 0% 0%;

 background: #e74c3c;
z-index: 1;
width: 72.8vw;
height: 39vh;
margin-top: 136.5vh;
margin-left: 13.6vw;
position: absolute;
border-radius: 7vh;
display: none;
box-shadow:2px 2px 10px #333333;
}

@keyframes divanimated{
0% {
    transform: scaleX(0.3);
}
40% {
    transform: scaleX(1.02);
}
60% {
    transform: scaleX(0.98);
}
80% {
    transform: scaleX(1.01);
}
100% {
    transform: scaleX(0.98);
}
80% {
    transform: scaleX(1.01);
}
100% {
    transform: scaleX(1);
}
}

@-webkit-keyframes divanimated{
0% {
    -webkit-transform: scaleX(0.3);
}
40% {
    -webkit-transform: scaleX(1.02);
}
60% {
    -webkit-transform: scaleX(0.98);
}
80% {
    -webkit-transform: scaleX(1.01);
}
100% {
    -webkit-transform: scaleX(0.98);
}
80% {
    -webkit-transform: scaleX(1.01);
}
100% {
    -webkit-transform: scaleX(1);
}
}
.div{
animation-name: div;
-webkit-animation-name: div;

animation-duration: 1.6s;
-webkit-animation-duration: 1.6s;

animation-timing-function: ease-out;
-webkit-animation-timing-function: ease -out;

visibility: visible !important;

background: #e74c3c;
z-index: 1;
width: 72.8vw;
height: 39vh;
margin-top: 136.5vh;
margin-left: 13.6vw;
position: absolute;
border-radius: 7vh;
display: none;
box-shadow:2px 2px 10px #333333;
}

@keyframes div{
0% {
    transform: translateY(100%) scaleX(0.5);
}
30%{
    transform: translateY(-8%) scaleX(0.5);
}
40%{
    transform: translateY(2%) scaleX(0.5);
}
50%{
    transform: translateY(0%) scaleX(1.1);
}
60%{
    transform: translateY(0%) scaleX(0.9);
}
70% {
    transform: translateY(0%) scaleX(1.05);
}
80%{
    transform: translateY(0%) scaleX(0.95);
}
90% {
    transform: translateY(0%) scaleX(1.02);
}
100%{
    transform: translateY(0%) scaleX(1);
}
}

@-webkit-keyframes div{
0% {
    -webkit-transform: translateY(100%) scaleX(0.5);
}
30%{
    -webkit-transform: translateY(-8%) scaleX(0.5);
}
40%{
    -webkit-transform: translateY(2%) scaleX(0.5);
}
50%{
    -webkit-transform: translateY(0%) scaleX(1.1);
}
60%{
    -webkit-transform: translateY(0%) scaleX(0.9);
}
70% {
    -webkit-transform: translateY(0%) scaleX(1.05);
}
80%{
    -webkit-transform: translateY(0%) scaleX(0.95);
}
90% {
    -webkit-transform: translateY(0%) scaleX(1.02);
}
100%{
    -webkit-transform: translateY(0%) scaleX(1);
}
}

Can someone help me ? Whats wrong with my code ?

Thanks for the help.

Body:
Here's the answer...

// Created a JS function which we'll call when arrow is clicked
function myFunction() {
  document.getElementById("div").className = "divanimated";
}

.arrowright{
  height: 50px;
  width: 50px;
  margin-top: 50vh;
  margin-left:90vw;
}

.divanimated{
  animation-name: divanimated;
  -webkit-animation-name: divanimated;
  animation-duration: 1.5s;
  -webkit-animation-duration: 1.5s;
  animation-timing-function: ease-out;
  -webkit-animation-timing-function: ease-out;
  transform-origin: 0% 0%;
  -ms-transform-origin: 0% 0%;
  -webkit-transform-origin: 0% 0%;
  background: #e74c3c;
  z-index: 1;
  width: 72.8vw;
  height: 39vh;
  margin-top: 136.5vh;
  margin-left: 13.6vw;
  position: absolute;
  border-radius: 7vh;
  box-shadow:2px 2px 10px #333333;
}

@keyframes divanimated{
  0% {
    transform: scaleX(0.3);
  }
  40% {
    transform: scaleX(1.02);
  }
  60% {
    transform: scaleX(0.98);
  }
  80% {
    transform: scaleX(1.01);
  }
  100% {
    transform: scaleX(0.98);
  }
  80% {
    transform: scaleX(1.01);
  }
  100% {
    transform: scaleX(1);
  }
}

@-webkit-keyframes divanimated{
  0% {
    -webkit-transform: scaleX(0.3);
  }
  40% {
    -webkit-transform: scaleX(1.02);
  }
  60% {
    -webkit-transform: scaleX(0.98);
  }
  80% {
    -webkit-transform: scaleX(1.01);
  }
  100% {
    -webkit-transform: scaleX(0.98);
  }
  80% {
    -webkit-transform: scaleX(1.01);
  }
  100% {
    -webkit-transform: scaleX(1);
  }
}

/* Moved this into a div ID as before it was moving the div down */
#div {
  visibility: visible !important;
  background: #e74c3c;
  z-index: 1;
  width: 72.8vw;
  height: 39vh;
  margin-top: 40.5vh;
  margin-left: 13.6vw;
  position: absolute;
  border-radius: 7vh;
  box-shadow:2px 2px 10px #333333;
}

.div{
  animation-name: div;
  -webkit-animation-name: div;
  animation-duration: 1.6s;
  -webkit-animation-duration: 1.6s;
  animation-timing-function: ease-out;
  -webkit-animation-timing-function: ease -out;
}

@keyframes div{
  0% {
    transform: translateY(100%) scaleX(0.5);
  }
  30%{
    transform: translateY(-8%) scaleX(0.5);
  }
  40%{
    transform: translateY(2%) scaleX(0.5);
  }
  50%{
    transform: translateY(0%) scaleX(1.1);
  }
  60%{
    transform: translateY(0%) scaleX(0.9);
  }
  70% {
    transform: translateY(0%) scaleX(1.05);
  }
  80%{
    transform: translateY(0%) scaleX(0.95);
  }
  90% {
    transform: translateY(0%) scaleX(1.02);
  }
  100%{
    transform: translateY(0%) scaleX(1);
  }
}

@-webkit-keyframes div{
  0% {
    -webkit-transform: translateY(100%) scaleX(0.5);
  }
  30%{
    -webkit-transform: translateY(-8%) scaleX(0.5);
  }
  40%{
    -webkit-transform: translateY(2%) scaleX(0.5);
  }
  50%{
    -webkit-transform: translateY(0%) scaleX(1.1);
  }
  60%{
    -webkit-transform: translateY(0%) scaleX(0.9);
  }
  70% {
    -webkit-transform: translateY(0%) scaleX(1.05);
  }
  80%{
    -webkit-transform: translateY(0%) scaleX(0.95);
  }
  90% {
    -webkit-transform: translateY(0%) scaleX(1.02);
  }
  100%{
    -webkit-transform: translateY(0%) scaleX(1);
  }
}

<!-- Added ID div and wrapped image with a div that listens for a click -->
<div id="div" class="div"> </div>
<div onclick="myFunction()">
  <img src="http://bbcpersian7.com/images/arrow-18.jpg" class="arrowright">
</div>


问:
SQL Server - Converting to smalldatetime in dynamic SQL Statement
The below dynamic SQL throws an error:

The conversion failed when converting character string to smalldatetime data type

My code:

```<code>DECLARE @pTimeStamp smalldatetime
SET @pTimeStamp = '2017-05-22 12:15:00'

DECLARE @SQLQuery AS NVARCHAR(4000)
Set @SQLQuery = N'Select *' +
' From SampleTable'  +
' Where TimeStamp = ' + @pTimeStamp

EXECUTE sp_executesql @SQLQuery
</code>```

I've also tried

```<code>Convert(smalldatetime, @pTimeStamp, 20)
</code>```

as well as

```<code>CAST(@pTimeStamp AS smalldatetime)
</code>```

but I only get other errors. I also tried declaring @pTimeStamp as varchar(50) and then converting but still got errors.

Doing something simple like:

```<code>DECLARE @pTimeStamp smalldatetime
SET @pTimeStamp = '2012-01-22 12:15:00'

Select *
From SampleTable
Where TimeStamp = @pTimeStamp
</code>```

ran fine so I'm guessing it has to do with the dynamic SQL.

Please help....

答:
The only truly safe formats for date/time literals in SQL Server, at least for datetime and smalldatetime, are: YYYYMMDD and YYYY-MM-DDThh:mm:ss[.nnn] - Bad habits to kick : mis-handling date / range queries - Aaron Bertrand

You are already using sp_executesql, so why not take advantage of its parameters?

```<code>declare @pTimeStamp smalldatetime;
declare @params nvarchar(4000);
declare @sqlquery nvarchar(4000);

set @pTimeStamp = '2017-05-22T12:15:00';
set @params = N'@pTimeStamp smalldatetime';
set @sqlquery = N'
select *
from SampleTable
where TimeStamp = @pTimeStamp';

execute sp_executesql @sqlquery, @params, @pTimeStamp;
</code>```

rextester demo: http://rextester.com/FVC44260

Dynamic sql reference:

sp_executesql

The curse and blessings of dynamic SQL - Erland Sommarskog

Body:
The below dynamic SQL throws an error:

The conversion failed when converting character string to smalldatetime data type

My code:

DECLARE @pTimeStamp smalldatetime
SET @pTimeStamp = '2017-05-22 12:15:00'

DECLARE @SQLQuery AS NVARCHAR(4000)
Set @SQLQuery = N'Select *' +
' From SampleTable'  +
' Where TimeStamp = ' + @pTimeStamp

EXECUTE sp_executesql @SQLQuery

I've also tried

Convert(smalldatetime, @pTimeStamp, 20)

as well as

CAST(@pTimeStamp AS smalldatetime)

but I only get other errors. I also tried declaring @pTimeStamp as varchar(50) and then converting but still got errors.

Doing something simple like:

DECLARE @pTimeStamp smalldatetime
SET @pTimeStamp = '2012-01-22 12:15:00'

Select *
From SampleTable
Where TimeStamp = @pTimeStamp

ran fine so I'm guessing it has to do with the dynamic SQL.

Please help....

Body:
The only truly safe formats for date/time literals in SQL Server, at least for datetime and smalldatetime, are: YYYYMMDD and YYYY-MM-DDThh:mm:ss[.nnn] - Bad habits to kick : mis-handling date / range queries - Aaron Bertrand

You are already using sp_executesql, so why not take advantage of its parameters?

declare @pTimeStamp smalldatetime;
declare @params nvarchar(4000);
declare @sqlquery nvarchar(4000);

set @pTimeStamp = '2017-05-22T12:15:00';
set @params = N'@pTimeStamp smalldatetime';
set @sqlquery = N'
select *
from SampleTable
where TimeStamp = @pTimeStamp';

execute sp_executesql @sqlquery, @params, @pTimeStamp;

rextester demo: http://rextester.com/FVC44260

Dynamic sql reference:

sp_executesql

The curse and blessings of dynamic SQL - Erland Sommarskog


问:
given 4 points on a textured sphere extract a 2d plane and it's projected texture
Setting the scene
I'm working on a feature in scenekit where i have a camera at the center of a sphere. The sphere has a texture wrapped around it. Let's say it was a 360 degree image captured inside of a room.

So far
I have identified the positions on the sphere that correspond to the corners of the floor. I can extract and create a new flat 2d plane that matches the dimensions of the floor from the camera's perspective. E.g. If the room had a long rectangular floor, I'd create a trapezoid shaped plane.

Problem
But I would like for the new 2d plane to have the texture of the floor, not just the shape. How do I do this given that what I want to extract is not the original texture image, but the result of its projection onto the sphere?

FYI I'm pretty new to scenekit and 3d graphics stuff and I'm even newer to opengl

答:
I assume that your image is structured in a way that lets you directly pick a pixel given an arbitrary direction. E.g. if the azimuth of the direction is mapped to the image's x-coordinate and the height of the direction to the image's y-coordinate, you would convert the direction to these parameters and pick the color at those coordinates. If that is not the case, you have to find the intersection of the according ray (starting at the camera) with the sphere and find the texture coordinate at that intersection. You can then pick the color using this texture coordinate.

Now, you have basically two options. The first option is generating a new texture for the plane. The second option is sampling the spherical image from a shader.

Option 1 - Generate a new texture

You know the extent of your plane, so you can generate a new texture whose dimensions are proportional to the plane's extents. You can use an arbitrary resolution. All you then need to do is fill the pixels of this texture. For this, you just generate the ray for a given pixel and find the according color in the spherical image like so:

```<code>input: d1, d2, d3, d3 (the four direction vectors of the plane corners)
//  d3 +------+ d4
//  d1 +------+ d2
for x from 0 to texture width
    for y from 0 to texture height
        //Find the direction vector for this pixel through bilinear interpolation
        a = x / (width - 1) //horizontal interpolation parameter
        b = y / (height - 1) //vertical interpolation parameter
        d = (1 - a) * ((1 - b) * d1 + b * d3) + a * ((1 - b) * d2 + b * d4)
        normalize d
        //Sample the spherical image at d
        color = sample(d)
        //write the color to the new planar texture
        texture(x, y) = color
    next
next
</code>```

Then, you have a new texture that you can apply to the plane. Barycentric interpolation might be more appropriate if you express the plane as two triangles. But as long as the plane is rectangular, the results will be the same.

Note that the sample() method depends on your image structure and needs to be implemented appropriately.

Option 2 - Sample in a shader

In option 2, you do the same thing as in option 1. But you do it in a fragment shader. You employ the vertices of the plane with their respective directions (this might be just the vertex position) and let the GPU interpolate them. This gives you directly the direction d, which you can use. Here is some pseudo shader code:

```<code>in vec3 direction;
out vec4 color;
void main()
{
    color = sample(normalize(direction));
}
</code>```

If your image is a cube map, you can even let the GPU do the sampling.

Body:
I assume that your image is structured in a way that lets you directly pick a pixel given an arbitrary direction. E.g. if the azimuth of the direction is mapped to the image's x-coordinate and the height of the direction to the image's y-coordinate, you would convert the direction to these parameters and pick the color at those coordinates. If that is not the case, you have to find the intersection of the according ray (starting at the camera) with the sphere and find the texture coordinate at that intersection. You can then pick the color using this texture coordinate.

Now, you have basically two options. The first option is generating a new texture for the plane. The second option is sampling the spherical image from a shader.

Option 1 - Generate a new texture

You know the extent of your plane, so you can generate a new texture whose dimensions are proportional to the plane's extents. You can use an arbitrary resolution. All you then need to do is fill the pixels of this texture. For this, you just generate the ray for a given pixel and find the according color in the spherical image like so:

input: d1, d2, d3, d3 (the four direction vectors of the plane corners)
//  d3 +------+ d4
//  d1 +------+ d2
for x from 0 to texture width
    for y from 0 to texture height
        //Find the direction vector for this pixel through bilinear interpolation
        a = x / (width - 1) //horizontal interpolation parameter
        b = y / (height - 1) //vertical interpolation parameter
        d = (1 - a) * ((1 - b) * d1 + b * d3) + a * ((1 - b) * d2 + b * d4)
        normalize d
        //Sample the spherical image at d
        color = sample(d)
        //write the color to the new planar texture
        texture(x, y) = color
    next
next

Then, you have a new texture that you can apply to the plane. Barycentric interpolation might be more appropriate if you express the plane as two triangles. But as long as the plane is rectangular, the results will be the same.

Note that the sample() method depends on your image structure and needs to be implemented appropriately.

Option 2 - Sample in a shader

In option 2, you do the same thing as in option 1. But you do it in a fragment shader. You employ the vertices of the plane with their respective directions (this might be just the vertex position) and let the GPU interpolate them. This gives you directly the direction d, which you can use. Here is some pseudo shader code:

in vec3 direction;
out vec4 color;
void main()
{
    color = sample(normalize(direction));
}

If your image is a cube map, you can even let the GPU do the sampling.


问:
Changing Selenium from Py3 to Py2
I installed a Selenium server using Python 3.6. However, I found that the tests I am working on are written in Python2. My shop has asked me to change my Selenium installation so that it can process Python2 code, but I have been unable to successfully make the change.

I have installed Python 2.7.10 and have changed the Windows path to the new Py2. I have tried re-downloading the Selenium server, to no avail. I have also tried pip install selenium in a Py2 environment, and have confirmed the files are in my C:/Python27 folder. Even with the OS pointed at Python 2, Selenium remains pointed at Python 3. How can I change Selenium to run Python2 code instead of Python3?

OS: Win10-64bit

Python: 2.7.10 (formerly 3.6)

答:
On the first line of your Python 3.5 code, as this line:

```<code>from __future__ import print_function, division
</code>```

This will take care of two main differences between Python 3.5 and Python 2.7. There are other s that could be imported to improve compatibility.

and if you want to add the path:

Open System Properties (type it in the start menu, or use the keyboard shortcut Win+Pause)

Switch to the Advanced tab

Click Environment Variables

Select PATH in the System variables section

Click Edit

Add python's path to the end of the list (the paths are separated by semicolons). For example:

C:\Windows;C:\Windows\System32;C:\Python27

Title: Changing Selenium from Py3 to Py2

Body:
On the first line of your Python 3.5 code, as this line:

from __future__ import print_function, division

This will take care of two main differences between Python 3.5 and Python 2.7. There are other s that could be imported to improve compatibility.

and if you want to add the path:

Open System Properties (type it in the start menu, or use the keyboard shortcut Win+Pause)

Switch to the Advanced tab

Click Environment Variables

Select PATH in the System variables section

Click Edit

Add python's path to the end of the list (the paths are separated by semicolons). For example:

C:\Windows;C:\Windows\System32;C:\Python27


问:
ternary operator without else in C
I want to use ternary operator without else in C. How do I do it.

```<code>(a)? b: nothing;
</code>```

something like this. What do I use in nothing part?

答:
I tried putting any integers there and it works well. For example, if you want to return "a" if it's evaluated true, then you can write it like:</p>

```<code>true ? a : 1;
</code>```

Title: ternary operator without else in C

Body:
I want to use ternary operator without else in C. How do I do it.

(a)? b: nothing;

something like this. What do I use in nothing part?

Body:
I tried putting any integers there and it works well. For example, if you want to return "a" if it's evaluated true, then you can write it like:

true ? a : 1;


问:
Eclipse Content Assist not working with Android
I'm not sure is this is a problem with my installation of Eclipse (Helios) and Android SDK or something else but Eclipse Content Assist doesn't propose Object Methods for Android classes.

For example, if I create a simple program and add a Button btn, when I go to use the btn method setBackgroundResource(int) with Content Assist (Ctrl + Space) or Word Completion (Alt + /) neither of them have any proposals. If I type btn.(Ctrl + Space), Content Assist lists;    equals(), getClass(), hasCode(), Notify()...wait(), shows none of the Button methods!  Can anyone help?

```<code>import android.app.Activity;
import android.os.Bundle;
import android.widget.Button;

public class HelloWorld extends Activity {

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    setContentView(R.layout.main);

    Button btn = Button(this);
    btn.(Ctrl + Space)

    }
}
</code>```

答: Ah, found the problem, it's down to something going wrong with the workspace, created a new workspace and copied over my projects, all working again!</p>

Body:
I'm not sure is this is a problem with my installation of Eclipse (Helios) and Android SDK or something else but Eclipse Content Assist doesn't propose Object Methods for Android classes.

For example, if I create a simple program and add a Button btn, when I go to use the btn method setBackgroundResource(int) with Content Assist (Ctrl + Space) or Word Completion (Alt + /) neither of them have any proposals. If I type btn.(Ctrl + Space), Content Assist lists;    equals(), getClass(), hasCode(), Notify()...wait(), shows none of the Button methods!  Can anyone help?

import android.app.Activity;
import android.os.Bundle;
import android.widget.Button;

public class HelloWorld extends Activity {

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    setContentView(R.layout.main);

    Button btn = Button(this);
    btn.(Ctrl + Space)

    }
}


问:
Generate or Specify Azure Service Bus Namespace SAS Token with ARM Template
I'm using Azure ARM templates in order to make sure that I can repeatedly deploy uniform infrastructure and services. My ARM template consists of an App Service, Web App, Service Bus Queue, and Azure SQL database. On top of this, I'm setting up continuous deployment through VSTS.

Everything is working well EXCEPT I am not sure how to set a Service Bus SAS token at the Namespace level. I don't see a way in the Service Bus ARM template to specify one, so I cannot pre-generate a token and place it in my web.config file. I also don't see a way to have one generated on my behalf, then pull the values back to my web.config file. Any suggestions would be greatly appreciated.

答:
This might help others arriving at this answer

In EastUS using API_VERSION = 2017-04-01

The following will work to obtain references to primarykey and related fields

```<code>  - connectionString: "[concat('',listKeys(resourceId('Microsoft.EventHub/namespaces/eventhubs/authorizationRules','{{ eh_namespace }}', '{{ eventhub_name }}','fw'), '2017-04-01').primaryConnectionString,'')]"
</code>```

Body:
This might help others arriving at this answer

In EastUS using API_VERSION = 2017-04-01

The following will work to obtain references to primarykey and related fields

  - connectionString: "[concat('',listKeys(resourceId('Microsoft.EventHub/namespaces/eventhubs/authorizationRules','{{ eh_namespace }}', '{{ eventhub_name }}','fw'), '2017-04-01').primaryConnectionString,'')]"


问:
How to retroactively delete a commit from a git repository?
I want to remove a commit from a git repository. Not the last one, thus a git reset won't work.

I have this: A->B->C->D->...

And now I want to have only

```<code>A->B->D->...
</code>```

Thus, I want to change the past on a way as if C never had been existed.

How can I do that?

The possible inconsistencies with the remote repositories are a non-issue (I have full control over them). It is not a problem if the commit ids change, too.

答:
Use git rebase -i B then squash the commit that you don't want (but whose changes you want to keep; delete it if you don't want the changes) (where B is the ref of the parent of the commit you want to delete).

You'll get something like the following

```<code>pick B Good commit
squash C Commit message I don't want, but whose changes I do want
pick D Good commit

# Rebase B..D onto B
#
# Commands:
#  p, pick = use commit
#  r, reword = use commit, but edit the commit message
#  e, edit = use commit, but stop for amending
#  s, squash = use commit, but meld into previous commit
#  f, fixup = like "squash", but discard this commit's log message
#  x, exec = run command (the rest of the line) using shell
#
# These lines can be re-ordered; they are executed from top to bottom.
#
# If you remove a line here THAT COMMIT WILL BE LOST.
#
# However, if you remove everything, the rebase will be aborted.
#
# Note that empty commits are commented out
</code>```

Body:
I want to remove a commit from a git repository. Not the last one, thus a git reset won't work.

I have this: A->B->C->D->...

And now I want to have only

A->B->D->...

Thus, I want to change the past on a way as if C never had been existed.

How can I do that?

The possible inconsistencies with the remote repositories are a non-issue (I have full control over them). It is not a problem if the commit ids change, too.

Body:
Use git rebase -i B then squash the commit that you don't want (but whose changes you want to keep; delete it if you don't want the changes) (where B is the ref of the parent of the commit you want to delete).

You'll get something like the following

pick B Good commit
squash C Commit message I don't want, but whose changes I do want
pick D Good commit

# Rebase B..D onto B
#
# Commands:
#  p, pick = use commit
#  r, reword = use commit, but edit the commit message
#  e, edit = use commit, but stop for amending
#  s, squash = use commit, but meld into previous commit
#  f, fixup = like "squash", but discard this commit's log message
#  x, exec = run command (the rest of the line) using shell
#
# These lines can be re-ordered; they are executed from top to bottom.
#
# If you remove a line here THAT COMMIT WILL BE LOST.
#
# However, if you remove everything, the rebase will be aborted.
#
# Note that empty commits are commented out