问:
Azure DevOps Publish to the App Store TestFlight track fails with exit code 1
We are trying to publish the IPA to App Store. but task is getting failed with error code 1.

2021-12-22T13:40:44.9828920Z ##[section]Starting: Publish to the App Store TestFlight track
2021-12-22T13:40:44.9841780Z ==============================================================================
2021-12-22T13:40:44.9842160Z Task : Apple App Store Release
2021-12-22T13:40:44.9842730Z Description : Release an app to TestFlight or the Apple App Store
2021-12-22T13:40:44.9843080Z Version : 1.189.0
2021-12-22T13:40:44.9843340Z Author : Microsoft Corporation
2021-12-22T13:40:44.9843860Z Help : More Information
2021-12-22T13:40:44.9844350Z ==============================================================================
2021-12-22T13:40:45.2032820Z [command]/usr/local/opt/ruby@2.7/bin/gem install fastlane
2021-12-22T13:41:12.7283020Z Successfully installed fastlane-2.199.0
2021-12-22T13:41:12.7285250Z Parsing documentation for fastlane-2.199.0
2021-12-22T13:41:12.7287270Z Installing ri documentation for fastlane-2.199.0
2021-12-22T13:41:12.7288910Z Done installing documentation for fastlane after 23 seconds
2021-12-22T13:41:12.7290200Z 1 gem installed
2021-12-22T13:41:12.7637580Z [command]/usr/local/opt/ruby@2.7/bin/gem update fastlane -i /Users/runner/.gem-cache
2021-12-22T13:41:15.6010280Z Updating installed gems
2021-12-22T13:41:15.6010960Z Nothing to update
2021-12-22T13:41:15.6330030Z [command]/usr/local/lib/ruby/gems/2.7.0/bin/fastlane pilot upload --api_key_path /Users/runner/work/_temp/api_key***.json -i /Users/runner/work/r1/a/_Calendar-Mobile-Build/Calendar-MobileApp/ExtractedFiles/in.store.calendar.ipa -a in.store.calendar --skip_submission true --skip_waiting_for_build_processing true -p 1596887926
2021-12-22T13:41:18.3757000Z [13:41:18]: �[33mGet started using a Gemfile for fastlane https://docs.fastlane.tools/getting-started/ios/setup/#use-a-gemfile�[0m
2021-12-22T13:41:24.9984700Z [13:41:24]: Sending anonymous analytics information
2021-12-22T13:41:25.0084340Z [13:41:24]: Learn more at https://docs.fastlane.tools/#metrics
2021-12-22T13:41:25.0085930Z [13:41:24]: No personal or sensitive data is sent.
2021-12-22T13:41:25.0087420Z [13:41:24]: You can disable this by adding opt_out_usage at the top of your Fastfile
2021-12-22T13:41:25.0342540Z
2021-12-22T13:41:25.0347110Z Looking for related GitHub issues on fastlane/fastlane...
2021-12-22T13:41:25.0347960Z
2021-12-22T13:41:25.5644610Z ➡ Pilot fails using environment variables on GitHub
2021-12-22T13:41:25.5646070Z https://github.com//issues/18655 [open] 11
2021-12-22T13:41:25.5646810Z 2 weeks ago
2021-12-22T13:41:25.5647060Z
2021-12-22T13:41:25.5681000Z ➡ Pilot and deliver fails with "string contains null byte"
2021-12-22T13:41:25.5682210Z https://github.com//issues/18312 [closed] 7
2021-12-22T13:41:25.5685140Z 12 Jul 2021
2021-12-22T13:41:25.5685600Z
2021-12-22T13:41:25.5687110Z ➡ Deliver step gets stuck while running Transporter
2021-12-22T13:41:25.5688670Z https://github.com//issues/19428 [closed] 0
2021-12-22T13:41:25.5689470Z 2 weeks ago
2021-12-22T13:41:25.5689810Z
2021-12-22T13:41:25.5690920Z and 8 more at: https://github.com/fastlane/fastlane/search?q=string%20contains%20null%20byte&type=Issues&utf8=✓
2021-12-22T13:41:25.5691290Z
2021-12-22T13:41:25.5692440Z  You can ⌘ + double-click on links to open them directly in your browser.
2021-12-22T13:41:25.5693940Z /usr/local/lib/ruby/gems/2.7.0/gems/fastlane-2.199.0/spaceship/lib/spaceship/connect_api/token.rb:71:in initialize': [!] string contains null byte (ArgumentError) 2021-12-22T13:41:25.5695490Z from /usr/local/lib/ruby/gems/2.7.0/gems/fastlane-2.199.0/spaceship/lib/spaceship/connect_api/token.rb:71:in new'
2021-12-22T13:41:25.5696930Z from /usr/local/lib/ruby/gems/2.7.0/gems/fastlane-2.199.0/spaceship/lib/spaceship/connect_api/token.rb:71:in create' 2021-12-22T13:41:25.5698560Z from /usr/local/lib/ruby/gems/2.7.0/gems/fastlane-2.199.0/spaceship/lib/spaceship/connect_api/token.rb:49:in from_json_file'
2021-12-22T13:41:25.5700740Z from /usr/local/lib/ruby/gems/2.7.0/gems/fastlane-2.199.0/spaceship/lib/spaceship/connect_api/token.rb:33:in from' 2021-12-22T13:41:25.5702140Z from /usr/local/lib/ruby/gems/2.7.0/gems/fastlane-2.199.0/pilot/lib/pilot/manager.rb:23:in login'
2021-12-22T13:41:25.5703520Z from /usr/local/lib/ruby/gems/2.7.0/gems/fastlane-2.199.0/pilot/lib/pilot/manager.rb:19:in start' 2021-12-22T13:41:25.5704920Z from /usr/local/lib/ruby/gems/2.7.0/gems/fastlane-2.199.0/pilot/lib/pilot/build_manager.rb:17:in upload'
2021-12-22T13:41:25.5706370Z from /usr/local/lib/ruby/gems/2.7.0/gems/fastlane-2.199.0/pilot/lib/pilot/commands_generator.rb:67:in block (2 levels) in run' 2021-12-22T13:41:25.5707770Z from /usr/local/lib/ruby/gems/2.7.0/gems/commander-4.6.0/lib/commander/command.rb:187:in call'
2021-12-22T13:41:25.5709110Z from /usr/local/lib/ruby/gems/2.7.0/gems/commander-4.6.0/lib/commander/command.rb:157:in run' 2021-12-22T13:41:25.5710430Z from /usr/local/lib/ruby/gems/2.7.0/gems/commander-4.6.0/lib/commander/runner.rb:444:in run_active_command'
2021-12-22T13:41:25.5711890Z from /usr/local/lib/ruby/gems/2.7.0/gems/fastlane-2.199.0/fastlane_core/lib/fastlane_core/ui/fastlane_runner.rb:117:in run!' 2021-12-22T13:41:25.5713720Z from /usr/local/lib/ruby/gems/2.7.0/gems/commander-4.6.0/lib/commander/delegates.rb:18:in run!'
2021-12-22T13:41:25.5715210Z from /usr/local/lib/ruby/gems/2.7.0/gems/fastlane-2.199.0/pilot/lib/pilot/commands_generator.rb:167:in run' 2021-12-22T13:41:25.5716630Z from /usr/local/lib/ruby/gems/2.7.0/gems/fastlane-2.199.0/pilot/lib/pilot/commands_generator.rb:19:in start'
2021-12-22T13:41:25.5718090Z from /usr/local/lib/ruby/gems/2.7.0/gems/fastlane-2.199.0/fastlane/lib/fastlane/cli_tools_distributor.rb:114:in take_off' 2021-12-22T13:41:25.5719490Z from /usr/local/lib/ruby/gems/2.7.0/gems/fastlane-2.199.0/bin/fastlane:23:in <top (required)>'
2021-12-22T13:41:25.5720740Z from /usr/local/lib/ruby/gems/2.7.0/bin/fastlane:25:in load' 2021-12-22T13:41:25.5721910Z from /usr/local/lib/ruby/gems/2.7.0/bin/fastlane:25:in

'
2021-12-22T13:41:25.5723370Z /usr/local/lib/ruby/gems/2.7.0/gems/fastlane-2.199.0/spaceship/lib/spaceship/connect_api/token.rb:71:in initialize': string contains null byte (ArgumentError) 2021-12-22T13:41:25.5724890Z from /usr/local/lib/ruby/gems/2.7.0/gems/fastlane-2.199.0/spaceship/lib/spaceship/connect_api/token.rb:71:in new'
2021-12-22T13:41:25.5727030Z from /usr/local/lib/ruby/gems/2.7.0/gems/fastlane-2.199.0/spaceship/lib/spaceship/connect_api/token.rb:71:in create' 2021-12-22T13:41:25.5728480Z from /usr/local/lib/ruby/gems/2.7.0/gems/fastlane-2.199.0/spaceship/lib/spaceship/connect_api/token.rb:49:in from_json_file'
2021-12-22T13:41:25.5729920Z from /usr/local/lib/ruby/gems/2.7.0/gems/fastlane-2.199.0/spaceship/lib/spaceship/connect_api/token.rb:33:in from' 2021-12-22T13:41:25.5731260Z from /usr/local/lib/ruby/gems/2.7.0/gems/fastlane-2.199.0/pilot/lib/pilot/manager.rb:23:in login'
2021-12-22T13:41:25.5732610Z from /usr/local/lib/ruby/gems/2.7.0/gems/fastlane-2.199.0/pilot/lib/pilot/manager.rb:19:in start' 2021-12-22T13:41:25.5734180Z from /usr/local/lib/ruby/gems/2.7.0/gems/fastlane-2.199.0/pilot/lib/pilot/build_manager.rb:17:in upload'
2021-12-22T13:41:25.5735680Z from /usr/local/lib/ruby/gems/2.7.0/gems/fastlane-2.199.0/pilot/lib/pilot/commands_generator.rb:67:in block (2 levels) in run' 2021-12-22T13:41:25.5737030Z from /usr/local/lib/ruby/gems/2.7.0/gems/commander-4.6.0/lib/commander/command.rb:187:in call'
2021-12-22T13:41:25.5738370Z from /usr/local/lib/ruby/gems/2.7.0/gems/commander-4.6.0/lib/commander/command.rb:157:in run' 2021-12-22T13:41:25.5739750Z from /usr/local/lib/ruby/gems/2.7.0/gems/commander-4.6.0/lib/commander/runner.rb:444:in run_active_command'
2021-12-22T13:41:25.5741190Z from /usr/local/lib/ruby/gems/2.7.0/gems/fastlane-2.199.0/fastlane_core/lib/fastlane_core/ui/fastlane_runner.rb:117:in run!' 2021-12-22T13:41:25.5742590Z from /usr/local/lib/ruby/gems/2.7.0/gems/commander-4.6.0/lib/commander/delegates.rb:18:in run!'
2021-12-22T13:41:25.5744360Z from /usr/local/lib/ruby/gems/2.7.0/gems/fastlane-2.199.0/pilot/lib/pilot/commands_generator.rb:167:in run' 2021-12-22T13:41:25.5745800Z from /usr/local/lib/ruby/gems/2.7.0/gems/fastlane-2.199.0/pilot/lib/pilot/commands_generator.rb:19:in start'
2021-12-22T13:41:25.5747260Z from /usr/local/lib/ruby/gems/2.7.0/gems/fastlane-2.199.0/fastlane/lib/fastlane/cli_tools_distributor.rb:114:in take_off' 2021-12-22T13:41:25.5748660Z from /usr/local/lib/ruby/gems/2.7.0/gems/fastlane-2.199.0/bin/fastlane:23:in <top (required)>'
2021-12-22T13:41:25.5749910Z from /usr/local/lib/ruby/gems/2.7.0/bin/fastlane:25:in load' 2021-12-22T13:41:25.5751100Z from /usr/local/lib/ruby/gems/2.7.0/bin/fastlane:25:in '
2021-12-22T13:41:25.5788050Z ##[error]Error: The process '/usr/local/lib/ruby/gems/2.7.0/bin/fastlane' failed with exit code 1
2021-12-22T13:41:25.5806900Z ##[section]Finishing: Publish to the App Store TestFlight track

答:
(nice if you could space the output.. :)

I was experiencing this issue in my pipeline. The culprit is

2021-12-22T13:41:25.5723370Z /usr/local/lib/ruby/gems/2.7.0/gems/fastlane-2.199.0/spaceship/lib/spaceship/connect_api/token.rb:71:in initialize': string contains null byte (ArgumentError) 2021-12-22T13:41:25.5724890Z from /usr/local/lib/ruby/gems/2.7.0/gems/fastlane-2.199.0/spaceship/lib/spaceship/connect_api/token.rb:71:in new'

Fastlane requires the .p8 key file in your service connection to be base64 encoded to use in the AppStoreRelease@1 task.

The issue is described here: https://github.com/microsoft/app-store-vsts-extension/issues/219

Try updating your service connection Key Content with a base64 encoded key. You can use the tool https://www.base64encode.org/ to complete online


来源: stackexchange

问:
Is it possible to delete a record with Athena?
I would like to delete all records related to a client. My datalake is composed of parquet files. Is it possible to delete data with a query on Athena</p>
```<code>DELETE
FROM myTable
WHERE client_id=73513
</code>```

答:
I know there has been more than a year, but I decided to share it here because this comes out on top when you search for Athena delete. ACID level transactions are now supported for Athena using Iceberg
https://aws.amazon.com/about-aws/whats-new/2021/11/amazon-athena-acid-apache-iceberg/</p>

ContentLicense: CC BY-SA 4.0

Body:
I would like to delete all records related to a client. My datalake is composed of parquet files. Is it possible to delete data with a query on Athena

DELETE
FROM myTable
WHERE client_id=73513


问:
How to get a ComboBox with swiftUI
Is there a way to create a NSComboBox in SwiftUI?
When I use Picker, a NSPopUpButton is created under MacOS.

I've tried this:

```<code>var body: some View {
    Picker("Test:", selection: $selected) {
        ForEach(1..<10) { i in
            Text(String(i))
        }
    }
    .padding()
}
</code>```

But this will get me this:

But I need a ComboBox where I can enter text as well as select from a list.

Is this even possible with SwiftUI without integrating an NSComboBox as NSViewRepresentable.

I've already check the following question: SwiftUI Custom Picker / ComboBox
But it's about a customised picker and not about a NSComboBox.

答:
VDKComboBox

Using NSViewRepresentable isn't as awful as I was expecting. Here's a complete implementation of an NSComboBox for SwiftUI:

```<code>import Foundation
import SwiftUI

struct VDKComboBox: NSViewRepresentable
{
    // The items that will show up in the pop-up menu:
    var items: [String]

    // The property on our parent view that gets synced to the current stringValue of the NSComboBox, whether the user typed it in or selected it from the list:
    @Binding var text: String

    func makeCoordinator() -> Coordinator {
        return Coordinator(self)
    }

    func makeNSView(context: Context) -> NSComboBox
    {
        let comboBox = NSComboBox()
        comboBox.usesDataSource = false
        comboBox.completes = false
        comboBox.delegate = context.coordinator
        comboBox.intercellSpacing = NSSize(width: 0.0, height: 10.0)            // Matches the look and feel of Big Sur onwards.
        return comboBox
    }

    func updateNSView(_ nsView: NSComboBox, context: Context)
    {
        nsView.removeAllItems()
        nsView.addItems(withObjectValues: items)

        // ComboBox doesn't automatically select the item matching its text; we must do that manually. But we need the delegate to ignore that selection-change or we'll get a "state modified during view update; will cause undefined behavior" warning.
        context.coordinator.ignoreSelectionChanges = true
        nsView.stringValue = text
        nsView.selectItem(withObjectValue: text)
        context.coordinator.ignoreSelectionChanges = false
    }
}

// MARK: - Coordinator

extension VDKComboBox
{
    class Coordinator: NSObject, NSComboBoxDelegate
    {
        var parent: VDKComboBox
        var ignoreSelectionChanges: Bool = false

        init(_ parent: VDKComboBox) {
            self.parent = parent
        }

        func comboBoxSelectionDidChange(_ notification: Notification)
        {
            if !ignoreSelectionChanges,
               let box: NSComboBox = notification.object as? NSComboBox,
               let newStringValue: String = box.objectValueOfSelectedItem as? String
            {
                parent.text = newStringValue
            }
        }

        func controlTextDidEndEditing(_ obj: Notification)
        {
            if let textField = obj.object as? NSTextField
            {
                parent.text = textField.stringValue
            }
        }
    }
}
</code>```

Using It:

```<code>struct MyView: View
{
    @State var comboBoxText: String = ""

    var body: some View
    {
         VDKComboBox(items: ["one", "two", "three"], text: $comboBoxText)
             .padding()
    }
}
</code>```

Of course, you'll populate your list of items dynamically; the hard-coded array of strings is just a quick example.

Alternatives

I do realize you explicitly ruled out NSViewRepresentable, but I tried LOTS of other ways to imitate NSComboBox, including:

A SwiftUI Button on top of a TextField, .trailing aligned

Dynamically swapping a TextField and Picker

A custom Popover linked to a TextField

All of that looked "foreign" in one way or another. And since NSViewRepresentable wasn't all that bad, that's what I settled on. It may help others in the future, so I put my implementation here even though you wanted one that didn't rely on NSViewRepresentable.

Title: How to get a ComboBox with swiftUI

Body:
Is there a way to create a NSComboBox in SwiftUI?
When I use Picker, a NSPopUpButton is created under MacOS.

I've tried this:

var body: some View {
    Picker("Test:", selection: $selected) {
        ForEach(1..<10) { i in
            Text(String(i))
        }
    }
    .padding()
}

But this will get me this:

But I need a ComboBox where I can enter text as well as select from a list.

Is this even possible with SwiftUI without integrating an NSComboBox as NSViewRepresentable.

I've already check the following question: SwiftUI Custom Picker / ComboBox
But it's about a customised picker and not about a NSComboBox.

Body:
VDKComboBox

Using NSViewRepresentable isn't as awful as I was expecting. Here's a complete implementation of an NSComboBox for SwiftUI:

import Foundation
import SwiftUI

struct VDKComboBox: NSViewRepresentable
{
    // The items that will show up in the pop-up menu:
    var items: [String]

    // The property on our parent view that gets synced to the current stringValue of the NSComboBox, whether the user typed it in or selected it from the list:
    @Binding var text: String

    func makeCoordinator() -> Coordinator {
        return Coordinator(self)
    }

    func makeNSView(context: Context) -> NSComboBox
    {
        let comboBox = NSComboBox()
        comboBox.usesDataSource = false
        comboBox.completes = false
        comboBox.delegate = context.coordinator
        comboBox.intercellSpacing = NSSize(width: 0.0, height: 10.0)            // Matches the look and feel of Big Sur onwards.
        return comboBox
    }

    func updateNSView(_ nsView: NSComboBox, context: Context)
    {
        nsView.removeAllItems()
        nsView.addItems(withObjectValues: items)

        // ComboBox doesn't automatically select the item matching its text; we must do that manually. But we need the delegate to ignore that selection-change or we'll get a "state modified during view update; will cause undefined behavior" warning.
        context.coordinator.ignoreSelectionChanges = true
        nsView.stringValue = text
        nsView.selectItem(withObjectValue: text)
        context.coordinator.ignoreSelectionChanges = false
    }
}

// MARK: - Coordinator

extension VDKComboBox
{
    class Coordinator: NSObject, NSComboBoxDelegate
    {
        var parent: VDKComboBox
        var ignoreSelectionChanges: Bool = false

        init(_ parent: VDKComboBox) {
            self.parent = parent
        }

        func comboBoxSelectionDidChange(_ notification: Notification)
        {
            if !ignoreSelectionChanges,
               let box: NSComboBox = notification.object as? NSComboBox,
               let newStringValue: String = box.objectValueOfSelectedItem as? String
            {
                parent.text = newStringValue
            }
        }

        func controlTextDidEndEditing(_ obj: Notification)
        {
            if let textField = obj.object as? NSTextField
            {
                parent.text = textField.stringValue
            }
        }
    }
}

Using It:

struct MyView: View
{
    @State var comboBoxText: String = ""

    var body: some View
    {
         VDKComboBox(items: ["one", "two", "three"], text: $comboBoxText)
             .padding()
    }
}

Of course, you'll populate your list of items dynamically; the hard-coded array of strings is just a quick example.

Alternatives

I do realize you explicitly ruled out NSViewRepresentable, but I tried LOTS of other ways to imitate NSComboBox, including:

A SwiftUI Button on top of a TextField, .trailing aligned

Dynamically swapping a TextField and Picker

A custom Popover linked to a TextField

All of that looked "foreign" in one way or another. And since NSViewRepresentable wasn't all that bad, that's what I settled on. It may help others in the future, so I put my implementation here even though you wanted one that didn't rely on NSViewRepresentable.


问:
Tab replaced to space automatically in Delphi11
I'm using delphi 11.0(28.0.42600.6491).
Typing some tabs in code editor, and after a short pause, typing any character.
Then, I found tabs are replaced to space automatically.

And it seems to be happened when input character after already exists line.
My problem is like GIF image(animated).

I don't want that. tabs must be tabs strictly.
Is there any setting or way to do that?

答: This is a bug (in my opinion) that started in 10.4.  I have reported it as RSP-36776:  https://quality.embarcadero.com/browse/RSP-36776</p>


问:
How to add a space before each tweet in css
http://cargocollective.com/joingateillustration

Hi everyone, this is my site I am developing and I have managed to add my twitter feed to my page however I cant add a line break before each tweet, Ive searched here and people have posted answers to a similar post but this doesnt seem to affect mine, can anyone help?

答:
Something like this?  </p>

```<code>#twitter_update_list li span
{
   padding-top:10px;
}
</code>```

ContentLicense: CC BY-SA 3.0

Body:
Something like this?

#twitter_update_list li span
{
   padding-top:10px;
}


问:
Error: Schema validation failed with the following errors: Data path "" should NOT have additional properties(project)
After migrating application from angular 5 to 6, on running ng serve the following errors pop up.

Schema validation failed with the following errors:
    Data path "" should NOT have additional properties(project).
  Error: Schema validation failed with the following errors:
    Data path "" should NOT have additional properties(project).
      at MergeMapSubscriber._registry.compile.pipe.operators_1.concatMap.validatorResult [as project] (.../TemplateApp/me-cmf-web-template-angular/node_modules/@angular-devkit/core/src/workspace/workspace.js:210:42)
      at MergeMapSubscriber._tryNext (/.../me-cmf-web-template-angular/node_modules/@angular-devkit/core/node_modules/rxjs/internal/operators/mergeMap.js:65:27)
      at MergeMapSubscriber._next (.../me-cmf-web-template-angular/node_modules/@angular-devkit/core/node_modules/rxjs/internal/operators/mergeMap.js:55:18)
      at MergeMapSubscriber.Subscriber.next (/home/training/Attinad_Projects/TemplateApp/me-cmf-web-template-angular/node_modules/@angular-devkit/core/node_modules/rxjs/internal/Subscriber.js:64:18)
      at MergeMapSubscriber.notifyNext (.../TemplateApp/me-cmf-web-template-angular/node_modules/@angular-devkit/core/node_modules/rxjs/internal/operators/mergeMap.js:84:26)
      at InnerSubscriber._next (.../me-cmf-web-template-angular/node_modules/@angular-devkit/core/node_modules/rxjs/internal/InnerSubscriber.js:25:21)
      at InnerSubscriber.Subscriber.next (/.../me-cmf-web-template-angular/node_modules/@angular-devkit/core/node_modules/rxjs/internal/Subscriber.js:64:18)
      at MapSubscriber._next (.../me-cmf-web-template-angular/node_modules/@angular-devkit/core/node_modules/rxjs/internal/operators/map.js:52:26)
      at MapSubscriber.Subscriber.next (/.../me-cmf-web-template-angular/node_modules/@angular-devkit/core/node_modules/rxjs/internal/Subscriber.js:64:18)
      at SwitchMapSubscriber.notifyNext (.../me-cmf-web-template-angular/node_modules/@angular-devkit/core/node_modules/rxjs/internal/operators/switchMap.js:77:26)

I assume that the error is with .angular.json file which I re-named from .angular-cli.json .

My .angular.json file is as follows :

```<code>{
    "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
    "project": {
        "name": "mediaweb"
    },
    "apps": [{
            "root": "src",
            "outDir": "dist/browser",
            "assets": [
                "assets",
                "favicon.ico"
            ],
            "index": "index.html",
            "main": "main.ts",
            "polyfills": "polyfills.ts",
            "test": "test.ts",
            "tsconfig": "tsconfig.app.json",
            "testTsconfig": "tsconfig.spec.json",
            "prefix": "app",
            "styles": [
                "styles.scss",
                "../node_modules/owl.carousel/dist/assets/owl.carousel.css",
                "../node_modules/owl.carousel/dist/assets/owl.theme.default.css",
                "../node_modules/video.js/dist/video-js.css"
            ],
            "scripts": [
                "../node_modules/jquery/dist/jquery.js",
                "../node_modules/owl.carousel/dist/owl.carousel.js",
                "../node_modules/video.js/dist/ie8/videojs-ie8.js",
                "../node_modules/video.js/dist/video.js"
            ],
            "environmentSource": "environments/environment.ts",
            "environments": {
                "dev": "environments/environment.dev.ts",
                "prod": "environments/environment.prod.ts"
            }
        },
        {
            "platform": "server",
            "root": "src",
            "outDir": "dist/server",
            "assets": [
                "assets",
                "favicon.ico"
            ],
            "index": "index.html",
            "main": "main.server.ts",
            "test": "test.ts",
            "tsconfig": "tsconfig.server.json",
            "testTsconfig": "tsconfig.spec.json",
            "prefix": "app",
            "styles": [
                "styles.scss"
            ],
            "scripts": [],
            "environmentSource": "environments/environment.ts",
            "environments": {
                "dev": "environments/environment.dev.ts",
                "prod": "environments/environment.prod.ts"
            }
        }
    ],
    "e2e": {
        "protractor": {
            "config": "./protractor.conf.js"
        }
    },
    "lint": [{
            "project": "src/tsconfig.app.json",
            "exclude": ["**/node_modules/**", "**/UI/**"]
        },
        {
            "project": "src/tsconfig.spec.json",
            "exclude": "**/node_modules/**"
        },
        {
            "project": "e2e/tsconfig.e2e.json",
            "exclude": "**/node_modules/**"
        }
    ],
    "test": {
        "karma": {
            "config": "./karma.conf.js"
        }
    },
    "defaults": {
        "styleExt": "scss",
        "component": {}
    }
}
</code>```

Should I re-structure the json file, if so how?.

Any help would be great.

答:
please check your "angular/cli" version in "package.json", the version number must be similar to other angular packages.</p>
```<code>  "devDependencies": {
    "@angular-devkit/build-angular": "~0.803.29",
     "@angular/cli": "~13.2.2", (this is the wrong one)
    "@angular/compiler-cli": "~8.2.14",
</code>```

Body:
After migrating application from angular 5 to 6, on running ng serve the following errors pop up.

Schema validation failed with the following errors:
    Data path "" should NOT have additional properties(project).
  Error: Schema validation failed with the following errors:
    Data path "" should NOT have additional properties(project).
      at MergeMapSubscriber._registry.compile.pipe.operators_1.concatMap.validatorResult [as project] (.../TemplateApp/me-cmf-web-template-angular/node_modules/@angular-devkit/core/src/workspace/workspace.js:210:42)
      at MergeMapSubscriber._tryNext (/.../me-cmf-web-template-angular/node_modules/@angular-devkit/core/node_modules/rxjs/internal/operators/mergeMap.js:65:27)
      at MergeMapSubscriber._next (.../me-cmf-web-template-angular/node_modules/@angular-devkit/core/node_modules/rxjs/internal/operators/mergeMap.js:55:18)
      at MergeMapSubscriber.Subscriber.next (/home/training/Attinad_Projects/TemplateApp/me-cmf-web-template-angular/node_modules/@angular-devkit/core/node_modules/rxjs/internal/Subscriber.js:64:18)
      at MergeMapSubscriber.notifyNext (.../TemplateApp/me-cmf-web-template-angular/node_modules/@angular-devkit/core/node_modules/rxjs/internal/operators/mergeMap.js:84:26)
      at InnerSubscriber._next (.../me-cmf-web-template-angular/node_modules/@angular-devkit/core/node_modules/rxjs/internal/InnerSubscriber.js:25:21)
      at InnerSubscriber.Subscriber.next (/.../me-cmf-web-template-angular/node_modules/@angular-devkit/core/node_modules/rxjs/internal/Subscriber.js:64:18)
      at MapSubscriber._next (.../me-cmf-web-template-angular/node_modules/@angular-devkit/core/node_modules/rxjs/internal/operators/map.js:52:26)
      at MapSubscriber.Subscriber.next (/.../me-cmf-web-template-angular/node_modules/@angular-devkit/core/node_modules/rxjs/internal/Subscriber.js:64:18)
      at SwitchMapSubscriber.notifyNext (.../me-cmf-web-template-angular/node_modules/@angular-devkit/core/node_modules/rxjs/internal/operators/switchMap.js:77:26)

I assume that the error is with .angular.json file which I re-named from .angular-cli.json .

My .angular.json file is as follows :

{
    "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
    "project": {
        "name": "mediaweb"
    },
    "apps": [{
            "root": "src",
            "outDir": "dist/browser",
            "assets": [
                "assets",
                "favicon.ico"
            ],
            "index": "index.html",
            "main": "main.ts",
            "polyfills": "polyfills.ts",
            "test": "test.ts",
            "tsconfig": "tsconfig.app.json",
            "testTsconfig": "tsconfig.spec.json",
            "prefix": "app",
            "styles": [
                "styles.scss",
                "../node_modules/owl.carousel/dist/assets/owl.carousel.css",
                "../node_modules/owl.carousel/dist/assets/owl.theme.default.css",
                "../node_modules/video.js/dist/video-js.css"
            ],
            "scripts": [
                "../node_modules/jquery/dist/jquery.js",
                "../node_modules/owl.carousel/dist/owl.carousel.js",
                "../node_modules/video.js/dist/ie8/videojs-ie8.js",
                "../node_modules/video.js/dist/video.js"
            ],
            "environmentSource": "environments/environment.ts",
            "environments": {
                "dev": "environments/environment.dev.ts",
                "prod": "environments/environment.prod.ts"
            }
        },
        {
            "platform": "server",
            "root": "src",
            "outDir": "dist/server",
            "assets": [
                "assets",
                "favicon.ico"
            ],
            "index": "index.html",
            "main": "main.server.ts",
            "test": "test.ts",
            "tsconfig": "tsconfig.server.json",
            "testTsconfig": "tsconfig.spec.json",
            "prefix": "app",
            "styles": [
                "styles.scss"
            ],
            "scripts": [],
            "environmentSource": "environments/environment.ts",
            "environments": {
                "dev": "environments/environment.dev.ts",
                "prod": "environments/environment.prod.ts"
            }
        }
    ],
    "e2e": {
        "protractor": {
            "config": "./protractor.conf.js"
        }
    },
    "lint": [{
            "project": "src/tsconfig.app.json",
            "exclude": ["**/node_modules/**", "**/UI/**"]
        },
        {
            "project": "src/tsconfig.spec.json",
            "exclude": "**/node_modules/**"
        },
        {
            "project": "e2e/tsconfig.e2e.json",
            "exclude": "**/node_modules/**"
        }
    ],
    "test": {
        "karma": {
            "config": "./karma.conf.js"
        }
    },
    "defaults": {
        "styleExt": "scss",
        "component": {}
    }
}

Should I re-structure the json file, if so how?.

Any help would be great.

Body:
please check your "angular/cli" version in "package.json", the version number must be similar to other angular packages.

  "devDependencies": {
    "@angular-devkit/build-angular": "~0.803.29",
     "@angular/cli": "~13.2.2", (this is the wrong one)
    "@angular/compiler-cli": "~8.2.14",


问:
Copy the contents of a file to clipboard from WSL to Windows?

Rig description:

I've installed Debian in Windows Subsystem Linux (WSL) on Windows 10.

The host means Windows 10.

The box means my WSL-Debian box/container.

Goal:

I have an SSH key on WSL (my_rsa.pub);

I want to copy the contents of that file to the host's clipboard;

by running a command in the box (command-line code, not using the mouse).

Explanation:

SSH files are very long, and it doesn't make sense to copy them with the mouse cursor.

I'm also told that Debian doesn't ship with a clipboard: you need to install a clipboard?  So, I don't even know where to begin to look.

What I've tried:

"Copy to clipboard" in VIM is configured and working properly, but any contents copied to the 'clipboard' are removed from the 'clipboard' once VIM is closed; similarly, Nano has a CTRL+u function to cut text, and its clipboard does not survive outside of Nano.

答:
(Alternatives to @Biswapriyo's correct answer)

Using win32yank.exe

Having the .exe in $PATH:

```<code>cat /path/to/file | win32yank.exe -i
</code>```

Using Neovim

```<code>cat /path/to/file | nvim -c 'normal ggVG"+yZQ' --headless -
</code>```

Explanation

Neovim uses an external program to interact with the system clipboard, and this specific program varies among platforms. On Windows it uses win32yank.exe. The -c option allows to execute a command after the file is loaded, --headless makes Neovim run without a UI, and the trailing - indicates to read from standard input. So if you have Neovim already configured in WSL to work with the clipboard, this should also work (doing about the same as just directly calling win32yank.exe).

Configuring Neovim's clipboard in WSL:

https://github.com/neovim/neovim/wiki/FAQ#how-to-use-the-windows-clipboard-from-wsl

Body:
(Alternatives to @Biswapriyo's correct answer)

Using win32yank.exe

Having the .exe in $PATH:

cat /path/to/file | win32yank.exe -i

Using Neovim

cat /path/to/file | nvim -c 'normal ggVG"+yZQ' --headless -

Explanation

Neovim uses an external program to interact with the system clipboard, and this specific program varies among platforms. On Windows it uses win32yank.exe. The -c option allows to execute a command after the file is loaded, --headless makes Neovim run without a UI, and the trailing - indicates to read from standard input. So if you have Neovim already configured in WSL to work with the clipboard, this should also work (doing about the same as just directly calling win32yank.exe).

Configuring Neovim's clipboard in WSL:

https://github.com/neovim/neovim/wiki/FAQ#how-to-use-the-windows-clipboard-from-wsl


问:
geom_text gives vertically stacked labels to dot plot
I've been trying to create a dot plot with numbers inside each dot. Some of the points are close horizontally to one another (just barely intersecting), and their numerical labels appear vertically stacked in between the two points. I attached a photo of the graph.

I have tried adjusting all of the arguments of geom_dotplot and geom_text to no luck.

My code is as follows:

```<code>g <- DATA_TABLE %>%
  ggplot(aes(x = factor(X_VAR), y = AVG, fill = factor(COLOR_VAR))) +
  geom_dotplot(binaxis = "y", stackdir = "center",
               position = "dodge", binwidth = .1) +
  geom_text(mapping = aes(label = factor(LABEL_VAR)),
            position = position_dodge(.9), size = 5.5)
print(g)
</code>```

Here's a subset of the data table:

```<code>X_VAR, LABEL_VAR, AVG, COLOR_VAR
A, 3, 2.206897, blue
B, 3, 1.896552, blue
C, 3, 2.034483, blue
A, 4, 2.727273, green
B, 4, 2.545455, green
C, 4, 2.636364, green
A, 4, 2.125000, blue
B, 4, 1.875000, blue
C, 4, 2.187500, blue
</code>```

答:
This isn't a very pretty solution, but it gets you down the road toward what I think you're after.

The problem isn't with the geom_text() layer - in fact, the locations of the text labels are where they're supposed to be, according to the x/y coordinates you provide in the top level mapping. The issue instead is that geom_dotplot() bins your observations (in this case, along the y axis), and then plots those dots in the middle of the bin. So the trick is to provide x/y coordinates for the labels that match where the dots end up after the binning (and in your case, dodging) calculations.

So how to find the coordinates of the dots?

You'll note from the geom_dotplot() help page that x and y are computed variables. You can find these by accessing the ggplot_build() object for the dotplot itself:

```<code>g <- DATA_TABLE %>%
  ggplot(aes(x = factor(X_VAR), y = AVG, fill = factor(COLOR_VAR))) +
  geom_dotplot(binaxis = "y", stackdir = "center",
               position = "dodge", binwidth = 0.1)

plot_data <- ggplot_build(g)$data[[1]]
</code>```

Among other things, you'll find x, y, xmin, and xmax, all of which relate to the centres and the edges of the bins that the dots end up in, and stackpos which describes the stacking order of the dots themselves. You can use these variables to find the centre points of the dots after dodging, and add these to your data like so:

```<code>DATA_TABLE <- DATA_TABLE %>%
  arrange(X_VAR) %>%
  mutate(dot_x = plot_data$x+(plot_data$stackpos*(plot_data$xmax-plot_data$x)), dot_y=plot_data$y)
</code>```

Now you have x/y coordinates for the centre of the dots, which you can use to specify the locations of the text labels:

```<code>g + geom_text(data=DATA_TABLE, mapping = aes(x=dot_x, y=dot_y, label = factor(LABEL_VAR)), size = 5.5)

print(g)
</code>```

However, this answer falls a bit short because the size of the dots is in relation to binwidth, not to the panel size or dimensions - so as you get to very wide or very narrow plot dimensions, the numbers are no longer in the centre of the dots, despite still being in the "right" place.

Body:
I've been trying to create a dot plot with numbers inside each dot. Some of the points are close horizontally to one another (just barely intersecting), and their numerical labels appear vertically stacked in between the two points. I attached a photo of the graph.

I have tried adjusting all of the arguments of geom_dotplot and geom_text to no luck.

My code is as follows:

g <- DATA_TABLE %>%
  ggplot(aes(x = factor(X_VAR), y = AVG, fill = factor(COLOR_VAR))) +
  geom_dotplot(binaxis = "y", stackdir = "center",
               position = "dodge", binwidth = .1) +
  geom_text(mapping = aes(label = factor(LABEL_VAR)),
            position = position_dodge(.9), size = 5.5)
print(g)

Here's a subset of the data table:

X_VAR, LABEL_VAR, AVG, COLOR_VAR
A, 3, 2.206897, blue
B, 3, 1.896552, blue
C, 3, 2.034483, blue
A, 4, 2.727273, green
B, 4, 2.545455, green
C, 4, 2.636364, green
A, 4, 2.125000, blue
B, 4, 1.875000, blue
C, 4, 2.187500, blue

Body:
This isn't a very pretty solution, but it gets you down the road toward what I think you're after.

The problem isn't with the geom_text() layer - in fact, the locations of the text labels are where they're supposed to be, according to the x/y coordinates you provide in the top level mapping. The issue instead is that geom_dotplot() bins your observations (in this case, along the y axis), and then plots those dots in the middle of the bin. So the trick is to provide x/y coordinates for the labels that match where the dots end up after the binning (and in your case, dodging) calculations.

So how to find the coordinates of the dots?

You'll note from the geom_dotplot() help page that x and y are computed variables. You can find these by accessing the ggplot_build() object for the dotplot itself:

g <- DATA_TABLE %>%
  ggplot(aes(x = factor(X_VAR), y = AVG, fill = factor(COLOR_VAR))) +
  geom_dotplot(binaxis = "y", stackdir = "center",
               position = "dodge", binwidth = 0.1)

plot_data <- ggplot_build(g)$data[[1]]

Among other things, you'll find x, y, xmin, and xmax, all of which relate to the centres and the edges of the bins that the dots end up in, and stackpos which describes the stacking order of the dots themselves. You can use these variables to find the centre points of the dots after dodging, and add these to your data like so:

DATA_TABLE <- DATA_TABLE %>%
  arrange(X_VAR) %>%
  mutate(dot_x = plot_data$x+(plot_data$stackpos*(plot_data$xmax-plot_data$x)), dot_y=plot_data$y)

Now you have x/y coordinates for the centre of the dots, which you can use to specify the locations of the text labels:

g + geom_text(data=DATA_TABLE, mapping = aes(x=dot_x, y=dot_y, label = factor(LABEL_VAR)), size = 5.5)

print(g)

However, this answer falls a bit short because the size of the dots is in relation to binwidth, not to the panel size or dimensions - so as you get to very wide or very narrow plot dimensions, the numbers are no longer in the centre of the dots, despite still being in the "right" place.


问:
Buildr vs Gradle, pros and cons?
Have somebody use both Buildr and Gradle and can make comparison of this build tools. From first look they are very similar. But what to choose. And also it is good to hear about Scala support and various IDE integration(IDEA, NetBeans, Eclipse).

Thanks.

答:
I looked at both gradle and buildr and went for buildr in the end because of one huge disadvantage with gradle: start-up time of the build system. buildr is much snappier and gave me much faster incremental builds. Performance is something I found almost unbearable with gradle. Just consider how many times a build system is kicked off and add up the constant overhead.

BTW I found the build server with both build systems (buildr and gradle) to be not very useful  and error prone (that is: I spent more time with troubleshooting than it actually sped up things).

Title: Buildr vs Gradle, pros and cons?


问:
Parsing/Writing SysML v2?
I'm trying to find an existing parser (preferably in Python) to write and read SysML v2.

The official Github repo by SysML v2 Submission Team (SST) has placed some examples online already (For instance https://github.com/Systems-Modeling/SysML-v2-Release/blob/master/sysml/src/examples/Vehicle%20Example/VehicleUsages.sysml ), but I'm unable to get the Eclipse Plugin running properly. (Nothing is shown in the preview windows, no error message either).

There's a repo for the SysML-v2-API-Python-Client which I installed and executed the given sample code (https://github.com/Systems-Modeling/SysML-v2-API-Python-Client), but all I'm getting is this message:

```<code>$ python3.8 Test1.py
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 159, in _new_conn
    conn = connection.create_connection(
  File "/usr/lib/python3/dist-packages/urllib3/util/connection.py", line 84, in create_connection
    raise err
  File "/usr/lib/python3/dist-packages/urllib3/util/connection.py", line 74, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 665, in urlopen
    httplib_response = self._make_request(
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 387, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/usr/lib/python3.8/http/client.py", line 1256, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/lib/python3.8/http/client.py", line 1302, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.8/http/client.py", line 1251, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.8/http/client.py", line 1011, in _send_output
    self.send(msg)
  File "/usr/lib/python3.8/http/client.py", line 951, in send
    self.connect()
  File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 187, in connect
    conn = self._new_conn()
  File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 171, in _new_conn
    raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7f9492d1b9a0>: Failed to establish a new connection: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "Test1.py", line 38, in <module>
    api_response = api_instance.delete_branch_by_project_and_id(
  File "/home/qohelet/.local/lib/python3.8/site-packages/sysml_v2_api_client-2021.post9-py3.8.egg/sysml_v2_api_client/api/branch_api.py", line 62, in delete_branch_by_project_and_id
  File "/home/qohelet/.local/lib/python3.8/site-packages/sysml_v2_api_client-2021.post9-py3.8.egg/sysml_v2_api_client/api/branch_api.py", line 144, in delete_branch_by_project_and_id_with_http_info
  File "/home/qohelet/.local/lib/python3.8/site-packages/sysml_v2_api_client-2021.post9-py3.8.egg/sysml_v2_api_client/api_client.py", line 364, in call_api
  File "/home/qohelet/.local/lib/python3.8/site-packages/sysml_v2_api_client-2021.post9-py3.8.egg/sysml_v2_api_client/api_client.py", line 181, in __call_api
  File "/home/qohelet/.local/lib/python3.8/site-packages/sysml_v2_api_client-2021.post9-py3.8.egg/sysml_v2_api_client/api_client.py", line 431, in request
  File "/home/qohelet/.local/lib/python3.8/site-packages/sysml_v2_api_client-2021.post9-py3.8.egg/sysml_v2_api_client/rest.py", line 256, in DELETE
  File "/home/qohelet/.local/lib/python3.8/site-packages/sysml_v2_api_client-2021.post9-py3.8.egg/sysml_v2_api_client/rest.py", line 163, in request
  File "/usr/lib/python3/dist-packages/urllib3/request.py", line 75, in request
    return self.request_encode_url(
  File "/usr/lib/python3/dist-packages/urllib3/request.py", line 97, in request_encode_url
    return self.urlopen(method, url, **extra_kw)
  File "/usr/lib/python3/dist-packages/urllib3/poolmanager.py", line 330, in urlopen
    response = conn.urlopen(method, u.request_uri, **kw)
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 747, in urlopen
    return self.urlopen(
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 747, in urlopen
    return self.urlopen(
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 747, in urlopen
    return self.urlopen(
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 719, in urlopen
    retries = retries.increment(
  File "/usr/lib/python3/dist-packages/urllib3/util/retry.py", line 436, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='localhost', port=80): Max retries exceeded with url: /projects/project_id_example/branches/branch_id_example (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f9492d1b9a0>: Failed to establish a new connection: [Errno 111] Connection refused'))
</code>```

Am I supposed to have anything running? Is there anywhere a tutorial or manual on how to use it?

Or are there any other parsers out there?

答: There are no parsers currently available for Python. The API Python Client is an example implementation to interact with the Pilot Server API Implementation. You would need to run the server to interact with the API using the python client.</p>

Title: Parsing/Writing SysML v2?

Body:
I'm trying to find an existing parser (preferably in Python) to write and read SysML v2.

The official Github repo by SysML v2 Submission Team (SST) has placed some examples online already (For instance https://github.com/Systems-Modeling/SysML-v2-Release/blob/master/sysml/src/examples/Vehicle%20Example/VehicleUsages.sysml ), but I'm unable to get the Eclipse Plugin running properly. (Nothing is shown in the preview windows, no error message either).

There's a repo for the SysML-v2-API-Python-Client which I installed and executed the given sample code (https://github.com/Systems-Modeling/SysML-v2-API-Python-Client), but all I'm getting is this message:

$ python3.8 Test1.py
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 159, in _new_conn
    conn = connection.create_connection(
  File "/usr/lib/python3/dist-packages/urllib3/util/connection.py", line 84, in create_connection
    raise err
  File "/usr/lib/python3/dist-packages/urllib3/util/connection.py", line 74, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 665, in urlopen
    httplib_response = self._make_request(
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 387, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/usr/lib/python3.8/http/client.py", line 1256, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/lib/python3.8/http/client.py", line 1302, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.8/http/client.py", line 1251, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.8/http/client.py", line 1011, in _send_output
    self.send(msg)
  File "/usr/lib/python3.8/http/client.py", line 951, in send
    self.connect()
  File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 187, in connect
    conn = self._new_conn()
  File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 171, in _new_conn
    raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7f9492d1b9a0>: Failed to establish a new connection: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "Test1.py", line 38, in <module>
    api_response = api_instance.delete_branch_by_project_and_id(
  File "/home/qohelet/.local/lib/python3.8/site-packages/sysml_v2_api_client-2021.post9-py3.8.egg/sysml_v2_api_client/api/branch_api.py", line 62, in delete_branch_by_project_and_id
  File "/home/qohelet/.local/lib/python3.8/site-packages/sysml_v2_api_client-2021.post9-py3.8.egg/sysml_v2_api_client/api/branch_api.py", line 144, in delete_branch_by_project_and_id_with_http_info
  File "/home/qohelet/.local/lib/python3.8/site-packages/sysml_v2_api_client-2021.post9-py3.8.egg/sysml_v2_api_client/api_client.py", line 364, in call_api
  File "/home/qohelet/.local/lib/python3.8/site-packages/sysml_v2_api_client-2021.post9-py3.8.egg/sysml_v2_api_client/api_client.py", line 181, in __call_api
  File "/home/qohelet/.local/lib/python3.8/site-packages/sysml_v2_api_client-2021.post9-py3.8.egg/sysml_v2_api_client/api_client.py", line 431, in request
  File "/home/qohelet/.local/lib/python3.8/site-packages/sysml_v2_api_client-2021.post9-py3.8.egg/sysml_v2_api_client/rest.py", line 256, in DELETE
  File "/home/qohelet/.local/lib/python3.8/site-packages/sysml_v2_api_client-2021.post9-py3.8.egg/sysml_v2_api_client/rest.py", line 163, in request
  File "/usr/lib/python3/dist-packages/urllib3/request.py", line 75, in request
    return self.request_encode_url(
  File "/usr/lib/python3/dist-packages/urllib3/request.py", line 97, in request_encode_url
    return self.urlopen(method, url, **extra_kw)
  File "/usr/lib/python3/dist-packages/urllib3/poolmanager.py", line 330, in urlopen
    response = conn.urlopen(method, u.request_uri, **kw)
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 747, in urlopen
    return self.urlopen(
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 747, in urlopen
    return self.urlopen(
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 747, in urlopen
    return self.urlopen(
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 719, in urlopen
    retries = retries.increment(
  File "/usr/lib/python3/dist-packages/urllib3/util/retry.py", line 436, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='localhost', port=80): Max retries exceeded with url: /projects/project_id_example/branches/branch_id_example (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f9492d1b9a0>: Failed to establish a new connection: [Errno 111] Connection refused'))

Am I supposed to have anything running? Is there anywhere a tutorial or manual on how to use it?

Or are there any other parsers out there?


问:
Exact Change in Python
I am trying to write a code in Python to where it outputs exact change using the fewest coins and one coin type per line.  The coin types are Dollars, Quarters, Dimes, Nickels, and Pennies. I also have to use singular and plural coin names as appropriate, like 1 Penny vs. 2 Pennies. When I input 45 and ran the code, I got an error saying (Your program produced no output). Here is my code:</p>
```<code>total_change = int(input())

if total_change <= 0:
print('No change')

if total_change >= 100:
dollar = total_change//100
dollar_change = total_change % 100
if dollar == 1:
    print(dollar + ' Dollar')
elif dollar > 1:
    print(dollar + ' Dollars')

elif dollar_change >= 25:
    quarter = dollar_change//25
    quarter_change = dollar_change % 25
    if quarter == 1:
        print(quarter + ' Quarter')
    elif quarter > 1:
        print(quarter + ' Quarters')

    elif quarter_change >= 10:
        dime = quarter_change // 10
        dime_change = quarter_change % 10
        if dime == 1:
            print(dime + ' Dime')
        elif dime > 1:
            print(dime + ' Dimes')

        elif dime_change >= 5:
            nickel = dime_change // 5
            nickel_change = dime_change % 5
            if nickel == 1:
                print(nickel + ' Nickel')
            elif nickel > 1:
                print(nickel + ' Nickels')

        elif nickel_change >= 1:
                penny = nickel_change // 1
                if penny == 1:
                    print(penny + ' Penny')
                else:
                    print(penny + ' Pennies')

</code>```

答:
```<code>total = int(input())
if total == 0:
    print("No change")
else:
    denominations = [(100, "Dollar", "Dollars"), (25, "Quarter", "Quarters"), (10, "Dime", "Dimes"), (5, "Nickel", "Nickels"), (1, "Penny", "Pennies")]
    for d in denominations:
        coins = total // d[0]
        total %= d[0]
        if coins > 1:
            print(f"{coins} {d[2]}")
        elif coins == 1:
            print(f"1 {d[1]}")
</code>```

In this answer, I created a list full of tuples of all the coins and their values in cents. I then created a for loop which runs through all the tuples in the list, dividing the total removing the remainder for the number of coins

like this:

```<code>*coins = total // d[0] #returns the number of coins of the current iteration
</code>```

Then, in order for the loop to continue to the next iteration and do the calculations correctly, I set the total in cents equal to the remainder of the total divided by the current iteration.

like this:

```<code>total %= d[0] #can also be written as total = total % d[0]
</code>```

Then, I take the number of coins and check if the value is greater than one. If the conditional is met, it prints the number of coins followed by the corresponding "plural version" of the word.

like this:

```<code>if coins > 1:
    print(f"{coins} {d[2]}")
#d[2] refers to the third item in the tuple of the current iteration
</code>```

Finally, I use an else-if conditional to return 1 plus the "singular version" of the word

like this:

```<code>elif coins == 1:
    print(f"1 {d[1]}")
#d[1] refers to the second item in the tuple of the current iteration
</code>```

Title: Exact Change in Python

Body:
I am trying to write a code in Python to where it outputs exact change using the fewest coins and one coin type per line.  The coin types are Dollars, Quarters, Dimes, Nickels, and Pennies. I also have to use singular and plural coin names as appropriate, like 1 Penny vs. 2 Pennies. When I input 45 and ran the code, I got an error saying (Your program produced no output). Here is my code:

total_change = int(input())

if total_change <= 0:
print('No change')

if total_change >= 100:
dollar = total_change//100
dollar_change = total_change % 100
if dollar == 1:
    print(dollar + ' Dollar')
elif dollar > 1:
    print(dollar + ' Dollars')

elif dollar_change >= 25:
    quarter = dollar_change//25
    quarter_change = dollar_change % 25
    if quarter == 1:
        print(quarter + ' Quarter')
    elif quarter > 1:
        print(quarter + ' Quarters')

    elif quarter_change >= 10:
        dime = quarter_change // 10
        dime_change = quarter_change % 10
        if dime == 1:
            print(dime + ' Dime')
        elif dime > 1:
            print(dime + ' Dimes')

        elif dime_change >= 5:
            nickel = dime_change // 5
            nickel_change = dime_change % 5
            if nickel == 1:
                print(nickel + ' Nickel')
            elif nickel > 1:
                print(nickel + ' Nickels')

        elif nickel_change >= 1:
                penny = nickel_change // 1
                if penny == 1:
                    print(penny + ' Penny')
                else:
                    print(penny + ' Pennies')

Body:
total = int(input())
if total == 0:
    print("No change")
else:
    denominations = [(100, "Dollar", "Dollars"), (25, "Quarter", "Quarters"), (10, "Dime", "Dimes"), (5, "Nickel", "Nickels"), (1, "Penny", "Pennies")]
    for d in denominations:
        coins = total // d[0]
        total %= d[0]
        if coins > 1:
            print(f"{coins} {d[2]}")
        elif coins == 1:
            print(f"1 {d[1]}")

In this answer, I created a list full of tuples of all the coins and their values in cents. I then created a for loop which runs through all the tuples in the list, dividing the total removing the remainder for the number of coins

like this:

*coins = total // d[0] #returns the number of coins of the current iteration

Then, in order for the loop to continue to the next iteration and do the calculations correctly, I set the total in cents equal to the remainder of the total divided by the current iteration.

like this:

total %= d[0] #can also be written as total = total % d[0]

Then, I take the number of coins and check if the value is greater than one. If the conditional is met, it prints the number of coins followed by the corresponding "plural version" of the word.

like this:

if coins > 1:
    print(f"{coins} {d[2]}")
#d[2] refers to the third item in the tuple of the current iteration

Finally, I use an else-if conditional to return 1 plus the "singular version" of the word

like this:

elif coins == 1:
    print(f"1 {d[1]}")
#d[1] refers to the second item in the tuple of the current iteration


问:
Obtaining all possible combinations with a minimum number per group
Apologies for lack of a reproducible example as I'm not too sure how to code this.

Let's say I have four groups: red, yellow, green, and blue.

I have fifteen marbles to distribute to each group, with a constraint that each group must have at least two marbles. How can I get all possible combinations that can be allotted to each group? My desired end result is a data frame along the following lines, where the number represents the number of marbles allocated to that group:

```<code>combo_id   red   yellow   green   blue
1          3     3        5       4
2          3     5        4       3
3          5     2        5       3
</code>```

And so on until all combinations have been enumerated.

答:
I think you can achieve this using permuteGeneral from the RcppAlgos package.

Stating the problem as: what permutations of 4 numbers in the range 2-9 sum to 15. If the minimum per group is 2 then the maximum per group has to be 9, since 2 + 2 + 2 + 9 = 15.

```<code>library(RcppAlgos)
dataset <- permuteGeneral(2:9,
                          m = 4,
                          TRUE,
                          constraintFun = "sum",
                          comparisonFun = "==",
                          limitConstraints = 15)

head(dataset)

     [,1] [,2] [,3] [,4]
[1,]    2    2    2    9
[2,]    2    2    9    2
[3,]    2    9    2    2
[4,]    9    2    2    2
[5,]    2    2    3    8
[6,]    2    2    8    3

nrow(dataset)
[1] 120
</code>```

To get a data frame:

```<code>dataset <- as.data.frame(dataset)
names(dataset) <- c("red", "yellow", "green", "blue")
</code>```

Body:
Apologies for lack of a reproducible example as I'm not too sure how to code this.

Let's say I have four groups: red, yellow, green, and blue.

I have fifteen marbles to distribute to each group, with a constraint that each group must have at least two marbles. How can I get all possible combinations that can be allotted to each group? My desired end result is a data frame along the following lines, where the number represents the number of marbles allocated to that group:

combo_id   red   yellow   green   blue
1          3     3        5       4
2          3     5        4       3
3          5     2        5       3

And so on until all combinations have been enumerated.

Body:
I think you can achieve this using permuteGeneral from the RcppAlgos package.

Stating the problem as: what permutations of 4 numbers in the range 2-9 sum to 15. If the minimum per group is 2 then the maximum per group has to be 9, since 2 + 2 + 2 + 9 = 15.

library(RcppAlgos)
dataset <- permuteGeneral(2:9,
                          m = 4,
                          TRUE,
                          constraintFun = "sum",
                          comparisonFun = "==",
                          limitConstraints = 15)

head(dataset)

     [,1] [,2] [,3] [,4]
[1,]    2    2    2    9
[2,]    2    2    9    2
[3,]    2    9    2    2
[4,]    9    2    2    2
[5,]    2    2    3    8
[6,]    2    2    8    3

nrow(dataset)
[1] 120

To get a data frame:

dataset <- as.data.frame(dataset)
names(dataset) <- c("red", "yellow", "green", "blue")


问:
CPU utilisation curve from perfetto trace
I wanted to trace the CPU and memory utilization of one of my algorithm on a mobile device. So far I have implemented it in Android as an app and collected the resource utilization trace using Android profiler as a trace file (filename.trace). I have tried using the tool, perfetto UI which displays the trace like this:

How can I extract the original time series data which are being displayed in the android studio like the one below from this trace file?

答:
If I understand your question correctly, you want to see the CPU utilization chart in Perfetto UI?

The short answer is no, because they're different data.

Long answer: what Android Studio profiler shows in the chart is somewhat different:

The chart in your screenshot is actually CPU utilization data sampled by Android Studio directly from proc/[pid]/stat, not from system trace (or Perfetto). That means the trace file you exported from Android Studio does not contain that data. It's lost when you exit Android Studio.

However, when you capture a system trace, it also records CPU utilization data and if you click into CPU Profiler in Android Studio and select the system trace you captured, the CPU usage chart on the top will show the same data as collected by system trace. That is part of the trace file you exported.

Moreover, the system trace CPU utilization data is for all processes. What Android Studio does is it extracts only the data for your app process (since the IDE knows the pid) and computes the utilization percentage as follows: time_spent_in_app_per_50_miliseconds / 50_miliseconds * cpu_core_count.

What you can do if you want to compute the utilization from the trace file outside of Android Studio is to use Perfetto TraceProcessor. Write SQL queries to get the CPU scheduling data filtered by your pid, bucket them into 50 milisecond chunks and calculate the utilization same way as Android Studio. You can then visualize it in a spreadsheet but not in Perfetto UI as it doesn't support drawing charts from TraceProcessor data.


问:
Is there a cross-browser way to ignore 401 errors triggered by XHRs?
Attempting to keep as pure of a REST approach as possible, I decided that the application would be the API - down to the last bit.

Unfortunately, I have reached one stumbling block. After writing a Digest authentication handler in PHP, I found myself unable to make the experience as friendly for users in web browsers as an form-based authentication method would be.

The reason for this is that even though I can simulate a Digest authentication response through Javascript, using username and password from a HTML form (I can give the nonce values to the script safely, due to the way they are generated), on failure, the browser still shows the standard, ugly authentication prompt.

Is there any way around this? An earlier question references mozBackgroundRequest, but that seems hardly cross-browser.

Thanks!

答:
You could make a request with AJAX first, to make sure the authentication details provided work.

If they do, do what you have been doing. If they don't, tell the user about it in your own, nicer way...

EDIT

If you control the auth routine in PHP (and if auth fails, presumably doing header('HTTP/1.1 401 Unauthorized'); etc) you can just... not do it. Instead, respond with a normal 200 OK but put a string in the body that you can look for in ajax.responseText (like 'authFailed' or something).

You can just add a header (or a cookie, or something) to the AJAX requests that are not present in normal browser requests, to allow you to distinguish between the AJAX auth checks and a normal, authenticated session.

The exact mechanics are a little fuzzy in my head at the moment (it's been a long day) but I am sure it could be done using that method.


问:
Could someone help me with this function? Systems always: Incorrect Not quite, format_name('', '') returned Name: , should be
This is my code

```<code>def format_name(first_name, last_name):
    string = ('Name: ' +last_name+", "+first_name)
    if first_name =="":
        return ("Name: " + last_name)
    elif last_name =="":
        return("Name: "+ first_name)
    elif first_name == "" and last_name == "":
        return ""
    else:
        return string

print(format_name("Ernest", "Hemingway"))
# Should return the string "Name: Hemingway, Ernest"

print(format_name("", "Madonna"))
# Should return the string "Name: Madonna"

print(format_name("Voltaire", ""))
# Should return the string "Name: Voltaire"

print(format_name("", ""))
# Should return an empty string

Name: Hemingway, Ernest
Name: Madonna
Name: Voltaire
Name:
</code>```

but the system always showed my result "incorrect"
Not quite, format_name('', '') returned Name: , should be .

答:
def format_name(first_name, last_name):
    if first_name != '' and last_name != '':
        string = 'Name:'+' ' + last_name, first_name

    elif first_name != '' and last_name == '' or first_name == '' and last_name != '':
        string = 'Name:'+' ' + first_name + last_name

    else:
        string = last_name, first_name
    return string
```

Body:
This is my code

def format_name(first_name, last_name):
    string = ('Name: ' +last_name+", "+first_name)
    if first_name =="":
        return ("Name: " + last_name)
    elif last_name =="":
        return("Name: "+ first_name)
    elif first_name == "" and last_name == "":
        return ""
    else:
        return string

print(format_name("Ernest", "Hemingway"))
# Should return the string "Name: Hemingway, Ernest"

print(format_name("", "Madonna"))
# Should return the string "Name: Madonna"

print(format_name("Voltaire", ""))
# Should return the string "Name: Voltaire"

print(format_name("", ""))
# Should return an empty string

Name: Hemingway, Ernest
Name: Madonna
Name: Voltaire
Name:

but the system always showed my result "incorrect"
Not quite, format_name('', '') returned Name: , should be .


问:
Join condition do not show Nulls for a field
Let's say I have these two tables. The students table stores data about the student showing up to the respected class on a specific date. On the contrary, the classes table shows when the respected class started and when was the class last held.

How can I achieve this in postgreSQL 11.

```<code>select * from students

student_name          student_showed           class_name
  Jeter                 2022-02-05                Math
  Jeter                 2022-02-06                Math
  Jeter                 2022-02-07                Math
  Jeter                 2022-02-08                Math
  Jeter                 2022-02-09                Math
  Jeter                 2022-02-05                English
  Jeter                 2022-02-06                English
  Jeter                 2022-02-07                English
  Jeter                 2022-02-08                English
  Jeter                 2022-02-09                English
  Soriano               2022-02-05                Math
  Soriano               2022-02-06                Math
  Soriano               2022-02-07                Math
  Soriano               2022-02-08                Math
  Soriano               2022-02-09                Math
  Soriano               2022-02-05                English
  Soriano               2022-02-06                English
  Soriano               2022-02-07                English
  Soriano               2022-02-08                English
  Soriano               2022-02-09                English
</code>```

Now for the classes table!

```<code>select * from classes

 class_name             class_started             class_held_date
   Math                   2022-02-05                2022-02-06
  English                 2022-02-05                2022-02-06
   Math                   2022-02-05                2022-02-07
  English                 2022-02-05                2022-02-07
   Math                   2022-02-05                2022-02-09
  English                 2022-02-05                2022-02-09
</code>```

When I do a left-join on the two tables:

```<code>select s.*,c.class_started,c.class_held_date from students as s
left join classes as c on s.class_name = c.class_name and s.student_showed = c.class_held_date

student_name      student_showed      class_name     class_started     class_held_date
  Jeter             2022-02-05          Math
  Jeter             2022-02-06          Math           2022-02-05        2022-02-06
  Jeter             2022-02-07          Math           2022-02-05        2022-02-07
  Jeter             2022-02-08          Math
  Jeter             2022-02-09          Math           2022-02-05        2022-02-09
  Jeter             2022-02-05          English
  Jeter             2022-02-06          English        2022-02-05        2022-02-06
  Jeter             2022-02-07          English        2022-02-05        2022-02-07
  Jeter             2022-02-08          English
  Jeter             2022-02-09          English        2022-02-05        2022-02-09
  Soriano           2022-02-05          Math
  Soriano           2022-02-06          Math           2022-02-05        2022-02-06
  Soriano           2022-02-07          Math           2022-02-05        2022-02-07
  Soriano           2022-02-08          Math
  Soriano           2022-02-09          Math           2022-02-05        2022-02-09
  Soriano           2022-02-05          English
  Soriano           2022-02-06          English        2022-02-05        2022-02-06
  Soriano           2022-02-07          English        2022-02-05        2022-02-07
  Soriano           2022-02-08          English
  Soriano           2022-02-09          English        2022-02-05        2022-02-09
</code>```

Since class_started in the classes tables is a static field, I want it to always show the value rather than show NULLS. I need to show a left join since the student should get credit for showing up to the classes regardless if the classes were held or not.

Can someone please provide insights here.

Result Requested:

```<code>student_name      student_showed      class_name     class_started     class_held_date
  Jeter             2022-02-05          Math           2022-02-05
  Jeter             2022-02-06          Math           2022-02-05        2022-02-06
  Jeter             2022-02-07          Math           2022-02-05        2022-02-07
  Jeter             2022-02-08          Math           2022-02-05
  Jeter             2022-02-09          Math           2022-02-05        2022-02-09
  Jeter             2022-02-05          English        2022-02-05
  Jeter             2022-02-06          English        2022-02-05        2022-02-06
  Jeter             2022-02-07          English        2022-02-05        2022-02-07
  Jeter             2022-02-08          English        2022-02-05
  Jeter             2022-02-09          English        2022-02-05        2022-02-09
  Soriano           2022-02-05          Math           2022-02-05
  Soriano           2022-02-06          Math           2022-02-05        2022-02-06
  Soriano           2022-02-07          Math           2022-02-05        2022-02-07
  Soriano           2022-02-08          Math           2022-02-05
  Soriano           2022-02-09          Math           2022-02-05        2022-02-09
  Soriano           2022-02-05          English        2022-02-05
  Soriano           2022-02-06          English        2022-02-05        2022-02-06
  Soriano           2022-02-07          English        2022-02-05        2022-02-07
  Soriano           2022-02-08          English        2022-02-05
  Soriano           2022-02-09          English        2022-02-05        2022-02-09
</code>```

答:
Not a sql expert. But here's another way.</p>
```<code>select distinct
  s.student_name,
  s.student_showed,
  s.class_name,
  (case when c.class_started is NULL then
    (select c1.class_started from classes c1 where c1.class_name = s.class_name limit 1)
       else c.class_started
  end) as "class_started",
  c.class_held_date
 from students s
 left join classes c
 on s.student_showed = c.class_held_date
</code>```

Body:
Let's say I have these two tables. The students table stores data about the student showing up to the respected class on a specific date. On the contrary, the classes table shows when the respected class started and when was the class last held.

How can I achieve this in postgreSQL 11.

select * from students

student_name          student_showed           class_name
  Jeter                 2022-02-05                Math
  Jeter                 2022-02-06                Math
  Jeter                 2022-02-07                Math
  Jeter                 2022-02-08                Math
  Jeter                 2022-02-09                Math
  Jeter                 2022-02-05                English
  Jeter                 2022-02-06                English
  Jeter                 2022-02-07                English
  Jeter                 2022-02-08                English
  Jeter                 2022-02-09                English
  Soriano               2022-02-05                Math
  Soriano               2022-02-06                Math
  Soriano               2022-02-07                Math
  Soriano               2022-02-08                Math
  Soriano               2022-02-09                Math
  Soriano               2022-02-05                English
  Soriano               2022-02-06                English
  Soriano               2022-02-07                English
  Soriano               2022-02-08                English
  Soriano               2022-02-09                English

Now for the classes table!

select * from classes

 class_name             class_started             class_held_date
   Math                   2022-02-05                2022-02-06
  English                 2022-02-05                2022-02-06
   Math                   2022-02-05                2022-02-07
  English                 2022-02-05                2022-02-07
   Math                   2022-02-05                2022-02-09
  English                 2022-02-05                2022-02-09

When I do a left-join on the two tables:

select s.*,c.class_started,c.class_held_date from students as s
left join classes as c on s.class_name = c.class_name and s.student_showed = c.class_held_date

student_name      student_showed      class_name     class_started     class_held_date
  Jeter             2022-02-05          Math
  Jeter             2022-02-06          Math           2022-02-05        2022-02-06
  Jeter             2022-02-07          Math           2022-02-05        2022-02-07
  Jeter             2022-02-08          Math
  Jeter             2022-02-09          Math           2022-02-05        2022-02-09
  Jeter             2022-02-05          English
  Jeter             2022-02-06          English        2022-02-05        2022-02-06
  Jeter             2022-02-07          English        2022-02-05        2022-02-07
  Jeter             2022-02-08          English
  Jeter             2022-02-09          English        2022-02-05        2022-02-09
  Soriano           2022-02-05          Math
  Soriano           2022-02-06          Math           2022-02-05        2022-02-06
  Soriano           2022-02-07          Math           2022-02-05        2022-02-07
  Soriano           2022-02-08          Math
  Soriano           2022-02-09          Math           2022-02-05        2022-02-09
  Soriano           2022-02-05          English
  Soriano           2022-02-06          English        2022-02-05        2022-02-06
  Soriano           2022-02-07          English        2022-02-05        2022-02-07
  Soriano           2022-02-08          English
  Soriano           2022-02-09          English        2022-02-05        2022-02-09

Since class_started in the classes tables is a static field, I want it to always show the value rather than show NULLS. I need to show a left join since the student should get credit for showing up to the classes regardless if the classes were held or not.

Can someone please provide insights here.

Result Requested:

student_name      student_showed      class_name     class_started     class_held_date
  Jeter             2022-02-05          Math           2022-02-05
  Jeter             2022-02-06          Math           2022-02-05        2022-02-06
  Jeter             2022-02-07          Math           2022-02-05        2022-02-07
  Jeter             2022-02-08          Math           2022-02-05
  Jeter             2022-02-09          Math           2022-02-05        2022-02-09
  Jeter             2022-02-05          English        2022-02-05
  Jeter             2022-02-06          English        2022-02-05        2022-02-06
  Jeter             2022-02-07          English        2022-02-05        2022-02-07
  Jeter             2022-02-08          English        2022-02-05
  Jeter             2022-02-09          English        2022-02-05        2022-02-09
  Soriano           2022-02-05          Math           2022-02-05
  Soriano           2022-02-06          Math           2022-02-05        2022-02-06
  Soriano           2022-02-07          Math           2022-02-05        2022-02-07
  Soriano           2022-02-08          Math           2022-02-05
  Soriano           2022-02-09          Math           2022-02-05        2022-02-09
  Soriano           2022-02-05          English        2022-02-05
  Soriano           2022-02-06          English        2022-02-05        2022-02-06
  Soriano           2022-02-07          English        2022-02-05        2022-02-07
  Soriano           2022-02-08          English        2022-02-05
  Soriano           2022-02-09          English        2022-02-05        2022-02-09

Body:
Not a sql expert. But here's another way.

select distinct
  s.student_name,
  s.student_showed,
  s.class_name,
  (case when c.class_started is NULL then
    (select c1.class_started from classes c1 where c1.class_name = s.class_name limit 1)
       else c.class_started
  end) as "class_started",
  c.class_held_date
 from students s
 left join classes c
 on s.student_showed = c.class_held_date


问:
Remove Even numbers from stack up to int k
I'm trying to write a recursive function that removes the first k even numbers from the stack. If there are less than k even elements in the stack, just remove all even elements by not using any loops or data structures other than the stack passed in as a parameter. I have this but I can't figure out how to incorporate k correctly</p>
```<code>public static int removeEvenNumbers(Stack<Integer> stack, int k) {
    if (k <= 0 || stack.empty()) {
        return 0;
    }
    if (stack.peek() % 2 == 0) {
        stack.pop();
        return 1 + removeEvenNumbers(stack, k - 1);
    } else {
        int removed = stack.pop();
        int returns = removeEvenNumbers(stack, k);
        stack.push(removed);
        return returns;
    }
}
</code>```

答:
You aren't verifying K after removing a element, so if you just removed a element with K = 1, then you should stop.

```<code>public static int removeEvenNumbers(Stack<Integer> stack, int k) {
    if (k <= 0 || stack.empty()) {
        return 0;
    }
    if (stack.peek() % 2 == 0) {
        stack.pop();
        return k > 1 ? removeEvenNumbers(stack, k - 1) : 1;
    } else {
        int removed = stack.pop();
        int returns = removeEvenNumbers(stack, k);
        stack.push(removed);
        return returns;
    }
}
</code>```

Body:
I'm trying to write a recursive function that removes the first k even numbers from the stack. If there are less than k even elements in the stack, just remove all even elements by not using any loops or data structures other than the stack passed in as a parameter. I have this but I can't figure out how to incorporate k correctly

public static int removeEvenNumbers(Stack<Integer> stack, int k) {
    if (k <= 0 || stack.empty()) {
        return 0;
    }
    if (stack.peek() % 2 == 0) {
        stack.pop();
        return 1 + removeEvenNumbers(stack, k - 1);
    } else {
        int removed = stack.pop();
        int returns = removeEvenNumbers(stack, k);
        stack.push(removed);
        return returns;
    }
}

Body:
You aren't verifying K after removing a element, so if you just removed a element with K = 1, then you should stop.

public static int removeEvenNumbers(Stack<Integer> stack, int k) {
    if (k <= 0 || stack.empty()) {
        return 0;
    }
    if (stack.peek() % 2 == 0) {
        stack.pop();
        return k > 1 ? removeEvenNumbers(stack, k - 1) : 1;
    } else {
        int removed = stack.pop();
        int returns = removeEvenNumbers(stack, k);
        stack.push(removed);
        return returns;
    }
}


问:
Python / Tkinter Grid - Placing PNG Labels below Entry boxes
Here's the code I am using (one example):

```<code>import os
import win32api
from tkinter import *
from tkinter import ttk
from tkinter import filedialog
from PIL import ImageTk, Image
#...
def mainloop():

    root = Tk()
    mainframe = ttk.Frame(root)
    mainframe.grid(column=0, row=0, sticky=(N,W,E,S))
    root.columnconfigure(0, weight=1)
    root.rowconfigure(0,weight=1)
#...
    pillarImg = ImageTk.PhotoImage(Image.open("pillars.png"))
    pillars_label = ttk.Label(root)
    pillars_label['image'] = pillarImg
#...
    rldir_entry = ttk.Entry(mainframe, width=40, textvariable=rldir)
    pillars_entry = ttk.Entry(mainframe, width=10, textvariable=Pillars)
#...
    rldir_entry.grid(column=0, row=0, columnspan=5, sticky=(W,E))
    pillars_label.grid(column=0, row=1, columnspan=2, sticky=(N,W,E,S))
    pillars_entry.grid(column=0, row=2, sticky=(W,E))
#...
    root.mainloop()

mainloop()
</code>```

This code results in the two entry boxes being above the image, even though I set the grid to have the image between the two entry boxes...?

Here's a pic of what I mean:

答:
Ahh I just figured it out.

here:

```<code>pillars_label = ttk.Label(root)
</code>```

I added the label to root.

While here:

```<code>rldir_entry = ttk.Entry(mainframe, width=40, textvariable=rldir)
</code>```

the entry boxes are in the mainframe. lol.

Body:
Here's the code I am using (one example):

import os
import win32api
from tkinter import *
from tkinter import ttk
from tkinter import filedialog
from PIL import ImageTk, Image
#...
def mainloop():

    root = Tk()
    mainframe = ttk.Frame(root)
    mainframe.grid(column=0, row=0, sticky=(N,W,E,S))
    root.columnconfigure(0, weight=1)
    root.rowconfigure(0,weight=1)
#...
    pillarImg = ImageTk.PhotoImage(Image.open("pillars.png"))
    pillars_label = ttk.Label(root)
    pillars_label['image'] = pillarImg
#...
    rldir_entry = ttk.Entry(mainframe, width=40, textvariable=rldir)
    pillars_entry = ttk.Entry(mainframe, width=10, textvariable=Pillars)
#...
    rldir_entry.grid(column=0, row=0, columnspan=5, sticky=(W,E))
    pillars_label.grid(column=0, row=1, columnspan=2, sticky=(N,W,E,S))
    pillars_entry.grid(column=0, row=2, sticky=(W,E))
#...
    root.mainloop()

mainloop()

This code results in the two entry boxes being above the image, even though I set the grid to have the image between the two entry boxes...?

Here's a pic of what I mean:

Body:
Ahh I just figured it out.

here:

pillars_label = ttk.Label(root)

I added the label to root.

While here:

rldir_entry = ttk.Entry(mainframe, width=40, textvariable=rldir)

the entry boxes are in the mainframe. lol.


问:
How to upload a dataframe to Google Cloud Storage(bucket) on Python 3?
I want to create a Cloud Function (which shall be executed daily at 01:00).
The function should

generate a dataframe

[export as dataframe.csv]  <---- not sure if required

push the dataframe(or .csv) to a bucket

.....

Question1: Is it possible to push a dataframe to a bucket?

Question2: How can I create a .csv file within the CloudFunction(CF), that it can be pushed to a bucket?

Updated code now: (still giving error)

```<code>def push_cars( data ):    ##  <<----- not sure how many paramter &why??

    import requests
    import pandas as pd
    import os
    from datetime import datetime

    from google.cloud.storage.blob import Blob
    from google.cloud import storage
    #import csv               # <<--- not sure if required???

    cars_dict = {'Brand': ['Honda Civic','Toyota Corolla','Ford Focus','Audi A4'],
        'Price': [22000,25000,27000,35000]
        }

    cars = pd.DataFrame(cars_dict, columns = ['Brand', 'Price'])

    timestamp = datetime.now().strftime("%Y_%m_%d-%H_%M_%S")
    name = "cars_" + timestamp + ".csv"

    cars.to_csv(  "/tmp/test.csv" ,index=False)
    with open('/tmp/test.csv', "w") as csv:
      csv.write(name)

    os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = "My-project.json"

    target_bucket = 'cars:python_gogo'

    storage_client = storage.Client()
    bucket         = storage_client.get_bucket(  target_bucket )
    data           = bucket        .blob(        name_output   )

</code>```

For replication on the cloud, you need to create a requirements.txt with following content:

```<code>requests
pandas
google-cloud-storage
datetime
</code>```

In the cloud shell, i am using following to deploy this CF:
gcloud functions deploy push_cars--entry-point=push_cars--runtime=python37 --memory=1024MB --region=us-east1 --allow-unauthenticated --trigger-http

答:
Use the df.to_csv('file path') to directly save the CSV in the cloud storage bucket. Put your gcs bucket route in place of the file path.

For example - df.to_csv('gs://bucketname/filename.csv')

Body:
I want to create a Cloud Function (which shall be executed daily at 01:00).
The function should

generate a dataframe

[export as dataframe.csv]  <---- not sure if required

push the dataframe(or .csv) to a bucket

.....

Question1: Is it possible to push a dataframe to a bucket?

Question2: How can I create a .csv file within the CloudFunction(CF), that it can be pushed to a bucket?

Updated code now: (still giving error)

def push_cars( data ):    ##  <<----- not sure how many paramter &why??

    import requests
    import pandas as pd
    import os
    from datetime import datetime

    from google.cloud.storage.blob import Blob
    from google.cloud import storage
    #import csv               # <<--- not sure if required???

    cars_dict = {'Brand': ['Honda Civic','Toyota Corolla','Ford Focus','Audi A4'],
        'Price': [22000,25000,27000,35000]
        }

    cars = pd.DataFrame(cars_dict, columns = ['Brand', 'Price'])

    timestamp = datetime.now().strftime("%Y_%m_%d-%H_%M_%S")
    name = "cars_" + timestamp + ".csv"

    cars.to_csv(  "/tmp/test.csv" ,index=False)
    with open('/tmp/test.csv', "w") as csv:
      csv.write(name)

    os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = "My-project.json"

    target_bucket = 'cars:python_gogo'

    storage_client = storage.Client()
    bucket         = storage_client.get_bucket(  target_bucket )
    data           = bucket        .blob(        name_output   )

For replication on the cloud, you need to create a requirements.txt with following content:

requests
pandas
google-cloud-storage
datetime

In the cloud shell, i am using following to deploy this CF:
gcloud functions deploy push_cars--entry-point=push_cars--runtime=python37 --memory=1024MB --region=us-east1 --allow-unauthenticated --trigger-http


问:
git remote repository contains commits unmerged into the local branch
I am using git inside netbeans IDE. I wanted to change the commit message for the most recent commit I had made. I did that, checked the amend last commit checkbox and committed it to my local repository. When I push this commit to my github repo, I get the error: git remote repository contains commits unmerged into the local branch. open output to see more information. How do I fix this ? I am new to source control. I only want to do very basic version control with my current project. Please tell me how to fix this.

Screen:

Output message:

```<code>git branch
git remote -v
setting up remote: origin
git submodule status
git push https://github.com/double-whammy/netbeans_affablebean.git refs/heads/master:refs/heads/master
Remote Repository Updates
Branch Update : master
Old Id        : id1
New Id        : id2
Result        : REJECTED_NONFASTFORWARD
Local Repository Updates
Branch Update : origin/master
Old Id        : id1
New Id        : id2
Result        : NOT_ATTEMPTED
==[IDE]== Pushing - AffableBean finished.
</code>```

答:
Though it's already solved.
just want to post it down here.
I had the same error as yours but it happened because i modified my repository in github and didn't pull it to my local repository.

you need to remote > pull and then choose rebase.

that's what i did

Body:
I am using git inside netbeans IDE. I wanted to change the commit message for the most recent commit I had made. I did that, checked the amend last commit checkbox and committed it to my local repository. When I push this commit to my github repo, I get the error: git remote repository contains commits unmerged into the local branch. open output to see more information. How do I fix this ? I am new to source control. I only want to do very basic version control with my current project. Please tell me how to fix this.

Screen:

Output message:

git branch
git remote -v
setting up remote: origin
git submodule status
git push https://github.com/double-whammy/netbeans_affablebean.git refs/heads/master:refs/heads/master
Remote Repository Updates
Branch Update : master
Old Id        : id1
New Id        : id2
Result        : REJECTED_NONFASTFORWARD
Local Repository Updates
Branch Update : origin/master
Old Id        : id1
New Id        : id2
Result        : NOT_ATTEMPTED
==[IDE]== Pushing - AffableBean finished.


问:
How to draw ellipses in Scilab with orientation?
The existing functions xarc draw an ellipse, but the semi-major axes are aligned with the plot axes. Is there a way to 'rotate' the ellipse so it has an orientation that is not with the plot axes?</p>

答:
If the arc is the only element drawn in the axes, then you can actually use xarc() to generate it, and then rotate the whole axes:

```<code>clf
xarc(0, 1, 3, 1, 0, 310*64)
isoview
gca().rotation_angles(2) = 70;
</code>```

But, its likely not the case. Then the arc must be generated as a polyline object, and then rotate() can be used to rotate it:

```<code>clf
alpha = 0:1:310;
[a, b, xc, yc] = (3, 1, 2, 2);
x = xc + a*cosd(alpha);
y = yc + b*sind(alpha);
r = 20;   // rotation angle in °
xyR = rotate([x;y], r/180*%pi, [xc ; yc])';
plot(xyR(:,1), xyR(:,2))
</code>```

Body:
If the arc is the only element drawn in the axes, then you can actually use xarc() to generate it, and then rotate the whole axes:

clf
xarc(0, 1, 3, 1, 0, 310*64)
isoview
gca().rotation_angles(2) = 70;

But, its likely not the case. Then the arc must be generated as a polyline object, and then rotate() can be used to rotate it:

clf
alpha = 0:1:310;
[a, b, xc, yc] = (3, 1, 2, 2);
x = xc + a*cosd(alpha);
y = yc + b*sind(alpha);
r = 20;   // rotation angle in °
xyR = rotate([x;y], r/180*%pi, [xc ; yc])';
plot(xyR(:,1), xyR(:,2))


问:
How to open references in left or bottom panel instead of in a peak view
When I left-click on class definition holding ctrl (tested in Python), then there is "peak view" shown with a list of all class usages/references in the code.

I would like to have a full view of the list like in other IDEs (like Pycharm) to browse though them easily going to full view of those files back and forth without loosing the list of references each time I go to full view.

For example by sticking the references view in a bottom panel.

Is it possible?

There is an old issue exactly about that in here: https://github.com/microsoft/vscode/issues/22261 but is resolved and it was closed when some beta proposal was added via separate extension and now I don't see anything related in Settings.

答:
I think that what you are looking for is "Find All References" as opposed to Go To References.

By default highlight and press alt+shift+F12, or use the right click context menu, or use ctrl+shift+p command palette.

This should open a panel that you can click and drag to the side bar, side menu or bottom as desired.


问:
python inverse matrix without numpy
I can't figure it out what's wrong with my code, it's rly frustrating.
I have to make inverse matrix function, what I thought I've done. I don't know why it doesn't work. The problem is probably in line with stars, after this step my matrix named mat is changed to identity matrix, but why? Before stars it prints my mat matrix normaly which I gave to function, but after stars it's a identity matrix, I don't understand why it happend. Here's what I have:</p>
```<code>def identity_matrix_convertion(m):
    x = m[:]
    for i in range(len(x)):
        for j in range(len(x[0])):
            if i == j:
                x[i][j] = 1
            else:
                x[i][j] = 0
    return x

def inverse_matrix(mat):
    n = len(mat)
    am = mat[:]
    show_matrix(mat)
    **i = identity_matrix_convertion(am)**
    show_matrix(mat)
    im = i[:]
    ind = list(range(n))
    print(len(mat))
    if determinant(mat) == 0:
        print("This matrix doesn't have an inverse.")
    if len(mat) == len(mat[0]):
        for i in range(n):
            scal = 1.0 / am[i][i]
            for j in range(n):
                am[i][j] *= scal
                im[i][j] *= scal
            for k in ind[0:i] + ind[i + 1:]:
                current_scal = am[k][i]
                for l in range(n):
                    am[k][l] = am[k][l] - current_scal * am[i][j]
                    im[k][l] = im[k][l] - current_scal * im[i][j]
    return im

so after line **i = identity_matrix_convertion(am)** my mat matrix is changed into identity matrix, but why?

    The result is:

    1.0 2.0 3.0
    2.0 1.0 3.0
    4.0 3.0 2.0

    The result is:
    1 0 0
    0 1 0
    0 0 1
</code>```

答:
Following up on @NumberC's answer, the x = m[:] does make a copy, but only a shallow copy. The copied list will contain references to internal lists of the other list, and so manipulating those lists within x cause change in m too. This is because we represent the 2D matrix as list of lists. If someone would reorder the lists in m (so not the items within the lists but just the pure order of the lists within m) the order would stay the same in the x copy. However any change within the list of the lists is mutating the other too. I hope this is not confusing, List changes unexpectedly after assignment. Why is this and how can I prevent it? has some figures.

Since we don't have to scare away from [:] we can still say:

```<code>x = new_list = [y[:] for y in m]
</code>```

Or even better: we can use the built-in copy module (available everywhere):

```<code>import copy
x = copy.deepcopy(m)
</code>```

See also: Copying nested lists in Python

Title: python inverse matrix without numpy

Body:
I can't figure it out what's wrong with my code, it's rly frustrating.
I have to make inverse matrix function, what I thought I've done. I don't know why it doesn't work. The problem is probably in line with stars, after this step my matrix named mat is changed to identity matrix, but why? Before stars it prints my mat matrix normaly which I gave to function, but after stars it's a identity matrix, I don't understand why it happend. Here's what I have:

def identity_matrix_convertion(m):
    x = m[:]
    for i in range(len(x)):
        for j in range(len(x[0])):
            if i == j:
                x[i][j] = 1
            else:
                x[i][j] = 0
    return x

def inverse_matrix(mat):
    n = len(mat)
    am = mat[:]
    show_matrix(mat)
    **i = identity_matrix_convertion(am)**
    show_matrix(mat)
    im = i[:]
    ind = list(range(n))
    print(len(mat))
    if determinant(mat) == 0:
        print("This matrix doesn't have an inverse.")
    if len(mat) == len(mat[0]):
        for i in range(n):
            scal = 1.0 / am[i][i]
            for j in range(n):
                am[i][j] *= scal
                im[i][j] *= scal
            for k in ind[0:i] + ind[i + 1:]:
                current_scal = am[k][i]
                for l in range(n):
                    am[k][l] = am[k][l] - current_scal * am[i][j]
                    im[k][l] = im[k][l] - current_scal * im[i][j]
    return im

so after line **i = identity_matrix_convertion(am)** my mat matrix is changed into identity matrix, but why?

    The result is:

    1.0 2.0 3.0
    2.0 1.0 3.0
    4.0 3.0 2.0

    The result is:
    1 0 0
    0 1 0
    0 0 1

Body:
Following up on @NumberC's answer, the x = m[:] does make a copy, but only a shallow copy. The copied list will contain references to internal lists of the other list, and so manipulating those lists within x cause change in m too. This is because we represent the 2D matrix as list of lists. If someone would reorder the lists in m (so not the items within the lists but just the pure order of the lists within m) the order would stay the same in the x copy. However any change within the list of the lists is mutating the other too. I hope this is not confusing, List changes unexpectedly after assignment. Why is this and how can I prevent it? has some figures.

Since we don't have to scare away from [:] we can still say:

x = new_list = [y[:] for y in m]

Or even better: we can use the built-in copy module (available everywhere):

import copy
x = copy.deepcopy(m)

See also: Copying nested lists in Python