问:
Have video Quality Controls in hls.js / Video.js for Live Streaming
Using HLS.js

    (() => {
        var video = document.getElementById('video');
        console.log('VIDEO',video);
        if(Hls.isSupported()) {
            var hls = new Hls();
        hls.loadSource('https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8');

            hls.attachMedia(video);
            hls.on(Hls.Events.MANIFEST_PARSED,function() {
                //https://github.com/video-dev/hls.js/blob/master/docs/API.md#quality-switch-control-api
                //console.log('RAHUL',hls.levels);
                video.play();
            });
        }
            // hls.js is not supported on platforms that do not have Media Source Extensions (MSE) enabled.
            // When the browser has built-in HLS support (check using `canPlayType`), we can provide an HLS manifest (i.e. .m3u8 URL) directly to the video element through the `src` property.
            // This is using the built-in support of the plain video element, without using hls.js.
            // Note: it would be more normal to wait on the 'canplay' event below however on Safari (where you are most likely to find built-in HLS support) the video.src URL must be on the user-driven
        // white-list before a 'canplay' event will be emitted; the last video event that can be reliably listened-for when the URL is not on the white-list is 'loadedmetadata'.
        else if (video.canPlayType('application/vnd.apple.mpegurl')) {
            video.src = 'https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8';
            video.addEventListener('loadedmetadata',function() {
                video.play();
            });
        }

        video.addEventListener('canplaythrough',  () =>  {
            var promise = video.play();
            if (promise !== undefined) {
                promise.catch(function(error) {
                    console.error('Auto-play was prevented');
                }).then(function() {
                    console.info('Auto-play started');
                });
            }
        });
    })();```
</div>
</div>
</p>

<p>In this Stream i can get the levels or the qualities i have for the Video but the controls dosen't show up in the video player. how can we get that . </p>

<p>Using Video .js </p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>    (() => {
        let source = document.getElementById('video-source');
        console.log('RAHUL',source);
        source.src = 'https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8';
        source.type = 'application/x-mpegURL';
    })()</code>```

                <video
                        id="videoJS"
                        class="video-js vjs-4-3 vjs-big-play-centered"
                        controls = "true"
                        preload="auto"
                        width="640"
                        height="264"
                        poster="MY_VIDEO_POSTER.jpg"
                        data-setup="{}">
                    <source id = "video-source" src="" />

                        To view this video please enable JavaScript, and consider upgrading to a
                        web browser that
                        supports HTML5 video

                </video>```

Same problem occurs for Video Js too . I cannot get to see the controls , what am i missing .

Things i have looked into . https://www.npmjs.com/package/videojs-hls-quality-selector
Every-time i add this i get hlsQualitySelector not a function .
And for hls.js i got //https://github.com/video-dev/hls.js/blob/master/docs/API.md#quality-switch-control-api which explains it but do i need to have my own UI for this.

I am using Plain vanilla JS and HTML for this project.

答:
There is a plugin available for video.js which does exactly what I think you want.

If you look at the screen here you can see the user can switch between SH and HD for example:

You can see full details here: https://github.com/kmoskwiak/videojs-resolution-switcher

Note that it states it is for Video.js version 5 which is an older version now so you may have to check and modify for the current video.js version.

Body:
Using HLS.js

    (() => {
        var video = document.getElementById('video');
        console.log('VIDEO',video);
        if(Hls.isSupported()) {
            var hls = new Hls();
        hls.loadSource('https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8');

            hls.attachMedia(video);
            hls.on(Hls.Events.MANIFEST_PARSED,function() {
                //https://github.com/video-dev/hls.js/blob/master/docs/API.md#quality-switch-control-api
                //console.log('RAHUL',hls.levels);
                video.play();
            });
        }
            // hls.js is not supported on platforms that do not have Media Source Extensions (MSE) enabled.
            // When the browser has built-in HLS support (check using `canPlayType`), we can provide an HLS manifest (i.e. .m3u8 URL) directly to the video element through the `src` property.
            // This is using the built-in support of the plain video element, without using hls.js.
            // Note: it would be more normal to wait on the 'canplay' event below however on Safari (where you are most likely to find built-in HLS support) the video.src URL must be on the user-driven
        // white-list before a 'canplay' event will be emitted; the last video event that can be reliably listened-for when the URL is not on the white-list is 'loadedmetadata'.
        else if (video.canPlayType('application/vnd.apple.mpegurl')) {
            video.src = 'https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8';
            video.addEventListener('loadedmetadata',function() {
                video.play();
            });
        }

        video.addEventListener('canplaythrough',  () =>  {
            var promise = video.play();
            if (promise !== undefined) {
                promise.catch(function(error) {
                    console.error('Auto-play was prevented');
                }).then(function() {
                    console.info('Auto-play started');
                });
            }
        });
    })();

In this Stream i can get the levels or the qualities i have for the Video but the controls dosen't show up in the video player. how can we get that .

Using Video .js

    (() => {
        let source = document.getElementById('video-source');
        console.log('RAHUL',source);
        source.src = 'https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8';
        source.type = 'application/x-mpegURL';
    })()

                <video
                        id="videoJS"
                        class="video-js vjs-4-3 vjs-big-play-centered"
                        controls = "true"
                        preload="auto"
                        width="640"
                        height="264"
                        poster="MY_VIDEO_POSTER.jpg"
                        data-setup="{}">
                    <source id = "video-source" src="" />

                        To view this video please enable JavaScript, and consider upgrading to a
                        web browser that
                        supports HTML5 video

                </video>

Same problem occurs for Video Js too . I cannot get to see the controls , what am i missing .

Things i have looked into . https://www.npmjs.com/package/videojs-hls-quality-selector
Every-time i add this i get hlsQualitySelector not a function .
And for hls.js i got //https://github.com/video-dev/hls.js/blob/master/docs/API.md#quality-switch-control-api which explains it but do i need to have my own UI for this.

I am using Plain vanilla JS and HTML for this project.


来源: stackexchange

问:
Why is the output for my datediff expression to return a number of days bracketed?
I have written the following expression to give me the number of days between a date and today.

```<code>=IIF(Fields!First_Check_Start_Date.Value = nothing,nothing,datediff("d",Today,Fields!First_Check_Start_Date.Value))
</code>```

The output is correct but is bracketing the number

ie.  (292) instead of 292

Any help as to why this is

答:
if you are using text box to display your result, check what is the type of your text box. Make it as number and look for it's format and set to correct

Else you could also format like below

```<code>=IIF(Fields!First_Check_Start_Date.Value = nothing,nothing,Format(datediff("d",Today,Fields!First_Check_Start_Date.Value),"##"))
</code>```

ContentLicense: CC BY-SA 4.0

Body:
I have written the following expression to give me the number of days between a date and today.

=IIF(Fields!First_Check_Start_Date.Value = nothing,nothing,datediff("d",Today,Fields!First_Check_Start_Date.Value))

The output is correct but is bracketing the number

ie.  (292) instead of 292

Any help as to why this is

Body:
if you are using text box to display your result, check what is the type of your text box. Make it as number and look for it's format and set to correct

Else you could also format like below

=IIF(Fields!First_Check_Start_Date.Value = nothing,nothing,Format(datediff("d",Today,Fields!First_Check_Start_Date.Value),"##"))


问:
Handle net::ERR_CONTENT_LENGTH_MISMATCH error in JavaScript
I have a JavaScript video playlist. The videos are served from another domain, not mine. And recently I discovered problems with playing some videos. Sometimes, I receive net::ERR_CONTENT_LENGTH_MISMATCH error. These videos start playing and after 2-3 seconds they stop by themselves. Then they begin playing after 1-4 minutes. Only some videos have this behavior.
Can I check somehow for this error before playing a video? I want to skip the video if the error is detected and play a next one.

答:
I encountered this exact issue when I was trying to continually re-download an image that was continually being re-uploaded.

Unsurprisingly the image was sometimes incomplete but, even so, I've not found a way to prevent the error from being logged - but I can catch it like this:

```<code>    $('#myPic').attr('src', 'cacheless-pic.bmp?d='+ new Date().getTime())
       .on('error', function() {
          console.log('Oops - image of broken.');
       });
</code>```

I'm uncertain if this will help with your videos, but it's all I've got right now!

ContentLicense: CC BY-SA 3.0

Body:
I encountered this exact issue when I was trying to continually re-download an image that was continually being re-uploaded.

Unsurprisingly the image was sometimes incomplete but, even so, I've not found a way to prevent the error from being logged - but I can catch it like this:

    $('#myPic').attr('src', 'cacheless-pic.bmp?d='+ new Date().getTime())
       .on('error', function() {
          console.log('Oops - image of broken.');
       });

I'm uncertain if this will help with your videos, but it's all I've got right now!


问:
Translate a MySql query in a Laravel query builder
```<code>SELECT apartment_id, COUNT(created_at) AS n_view,
DATE_FORMAT(created_at, '%Y-%m-%d') as day_view
FROM views
WHERE apartment_id=36 GROUP BY day_view
ORDER BY COUNT(created_at) DESC
</code>```

how can I Translate this  MySql query in a Laravel query builder ?

答:
```<code>DB::table('views')
    ->selectRaw("apartment_id, COUNT(created_at) AS n_view, DATE_FORMAT(created_at, '%Y-%m-%d') as day_view")
    ->where("apartment_id", "=", "36")
    ->groupBy('day_view')
    ->orderBy(n_view, "DESC")
    ->get();
</code>```

Body:
SELECT apartment_id, COUNT(created_at) AS n_view,
DATE_FORMAT(created_at, '%Y-%m-%d') as day_view
FROM views
WHERE apartment_id=36 GROUP BY day_view
ORDER BY COUNT(created_at) DESC

how can I Translate this  MySql query in a Laravel query builder ?


问:
Nuxt.js problem with server-side API call with https
I have problem with nuxt server-side API call when im using HTTPS. On client side everyting is fine and API works when im switching pages on client side via links, but when I hit Ctrl + f5 and data will be pre-fetched on server side, there is no actually API call and data is not provided. Even no error is thrown, but eveything works just fine with plain HTTP.

On my production server nodejs version - v10.9.0
And for HTTPS im using SNI SSL provided via my nodejs web hosting provider

This problem is similar to:
https://github.com/nuxt/nuxt.js/issues/2934
Except that the solution provided there does not work for me.

Edited:

This is the error im getting in store.js after axios get in nuxtServerInit:
'unable to verify the first certificate'

Edited 2:

After that Ive found: https://forum.vuejs.org/t/nuxtserverinit-with-axios-unable-to-verify-the-first-certificate/31010

And I applied plugin which extends axios:

plugins/axios.js:

```<code>import https from 'https';

export default function ({ $axios }) {
    $axios.defaults.httpsAgent = new https.Agent({ rejectUnauthorized: false });
}
</code>```

nuxt.config.js:

```<code>plugins: [
    '@/plugins/axios',
]
</code>```

It works now on server-side as good as on client-side. But I have another questions. Is this solution safe?

答:
I found this solution to be easier to manage:

```<code>export NODE_TLS_REJECT_UNAUTHORIZED=0 && yarn dev --env.NODE_TLS_REJECT_UNAUTHORIZED=0
</code>```

Also it ensures that it is only run during development, where the issue with self signed certificates would most likely occur.

You could also add it to your package.json like so:

```<code>"scripts": {
  "dev": "export NODE_TLS_REJECT_UNAUTHORIZED=0 && nuxt --env.NODE_TLS_REJECT_UNAUTHORIZED=0",
</code>```

As a plugin

You could also create an plugins/axios.js file

import https from 'https';

export default function ({
  $axios,
  store
}) {
  const agent = new https.Agent({
    rejectUnauthorized: false
  });
  $axios.onRequest(config => {
    if (process.env.dev) {
      config.httpsAgent = agent;
    }
  });
}
```

Be sure to add the plugin to your nuxt.config.js file

Body:
I have problem with nuxt server-side API call when im using HTTPS. On client side everyting is fine and API works when im switching pages on client side via links, but when I hit Ctrl + f5 and data will be pre-fetched on server side, there is no actually API call and data is not provided. Even no error is thrown, but eveything works just fine with plain HTTP.

On my production server nodejs version - v10.9.0
And for HTTPS im using SNI SSL provided via my nodejs web hosting provider

This problem is similar to:
https://github.com/nuxt/nuxt.js/issues/2934
Except that the solution provided there does not work for me.

Edited:

This is the error im getting in store.js after axios get in nuxtServerInit:
'unable to verify the first certificate'

Edited 2:

After that Ive found: https://forum.vuejs.org/t/nuxtserverinit-with-axios-unable-to-verify-the-first-certificate/31010

And I applied plugin which extends axios:

plugins/axios.js:

import https from 'https';

export default function ({ $axios }) {
    $axios.defaults.httpsAgent = new https.Agent({ rejectUnauthorized: false });
}

nuxt.config.js:

plugins: [
    '@/plugins/axios',
]

It works now on server-side as good as on client-side. But I have another questions. Is this solution safe?

Body:
I found this solution to be easier to manage:

export NODE_TLS_REJECT_UNAUTHORIZED=0 && yarn dev --env.NODE_TLS_REJECT_UNAUTHORIZED=0

Also it ensures that it is only run during development, where the issue with self signed certificates would most likely occur.

You could also add it to your package.json like so:

"scripts": {
  "dev": "export NODE_TLS_REJECT_UNAUTHORIZED=0 && nuxt --env.NODE_TLS_REJECT_UNAUTHORIZED=0",

As a plugin

You could also create an plugins/axios.js file

import https from 'https';

export default function ({
  $axios,
  store
}) {
  const agent = new https.Agent({
    rejectUnauthorized: false
  });
  $axios.onRequest(config => {
    if (process.env.dev) {
      config.httpsAgent = agent;
    }
  });
}

Be sure to add the plugin to your nuxt.config.js file


问:
Is it possible for multiple Docker Swarm Services to access an env_file that is located on a volume mount?
I am trying to use a single env_file in multiple Docker Swarm Services. The volume mount point and file are available in the container. I validated it by logging into the running container. As soon as I deploy the stack's .yml file I receive an error stating that the .env file could not be found.

This is what I have done:

First, added a volume to a service in any given stack.

```<code>volumes:
 - /environment:/environment
</code>```

Then, include the .env file directive

```<code>env_file:
  - /environment/.env
</code>```

Is it at all possible to use an env_file that is located on a volume mount? I might be worth to note that the volume mount resolves to a NFS volume on the host and that I am using Swarmpit. However it seems that deploying the stack on the command line yields to the same problem.

答:
The env_file option points to a file on the deployment server, not necessarily the node running the containers, and not to a file inside the container. I believe the contents are expanded by the docker client, converted into environment entries in the container definition, and you will see the container running with the result.

Because of this, there is no need for the file to be mounted as a volume.

However, it is necessary for the file to exist where you run the docker client (docker is a client/server based application, often communicating over the docker socket). With Swarmpit, that client is likely inside of a container, where your files on the host will not be visible and cannot be expanded.

Body:
I am trying to use a single env_file in multiple Docker Swarm Services. The volume mount point and file are available in the container. I validated it by logging into the running container. As soon as I deploy the stack's .yml file I receive an error stating that the .env file could not be found.

This is what I have done:

First, added a volume to a service in any given stack.

volumes:
 - /environment:/environment

Then, include the .env file directive

env_file:
  - /environment/.env

Is it at all possible to use an env_file that is located on a volume mount? I might be worth to note that the volume mount resolves to a NFS volume on the host and that I am using Swarmpit. However it seems that deploying the stack on the command line yields to the same problem.


问:
How to hide label if something is in input value

First name

#Start+ #DITBT {
  position: absolute;
  top:5px;
  right:1160px;
  left: 15px;-webkit-transform: translate3d(0px, 0px, 0px);
  opacity: 0.5;
  transition: opacity .25s ease-in-out;
  -webkit-transition: opacity .25s ease-in-out;  }
#Start:focus + #DITBT {
 opacity:0;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="input-field">
  <input type="text" name="firstname" id="Start" maxlength="30" class="pad" required />
  <label for="Start" id="DITBT">First name</label>
</div> </code>```

How to hide label if something is in input value

答:
input::placeholder {
  opacity: 0;
}

input:not(:placeholder-shown) ~ label {
  display: none;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="input-field">
  <input type="text" placeholder="placeholder" name="firstname" id="Start" maxlength="30" class="pad" required />
  <label for="Start" id="DITBT">First name</label>
</div> </code>```

Body:
First name

#Start+ #DITBT {
  position: absolute;
  top:5px;
  right:1160px;
  left: 15px;-webkit-transform: translate3d(0px, 0px, 0px);
  opacity: 0.5;
  transition: opacity .25s ease-in-out;
  -webkit-transition: opacity .25s ease-in-out;  }
#Start:focus + #DITBT {
 opacity:0;
}

  <input type="text" name="firstname" id="Start" maxlength="30" class="pad" required />
  First name

How to hide label if something is in input value

Body:
input::placeholder {
  opacity: 0;
}

input:not(:placeholder-shown) ~ label {
  display: none;
}

<div class="input-field">
  <input type="text" placeholder="placeholder" name="firstname" id="Start" maxlength="30" class="pad" required />
  <label for="Start" id="DITBT">First name</label>
</div>


问:
android open a .properties file from project
I have a file defined next to the default.properties, AndroidManifest.xml,  called my_config.properties. my question is. how do open this file in my class?

if i move it to the class package i can read it using the folowing code:

```<code> Properties configFile = new Properties();
    try {
        configFile.load(MyConstantsClass.class.getResourceAsStream("my_config.properties"));
    } catch (IOException e) {
        e.printStackTrace();
    }
</code>```

but in this case the file needs to be inside the same package as the class i use this snippet in. how do i read from it when its defined like in the beggining of my question?
Thank you.

答: You can only open files from Android that are included in your APK, the current location of the my_config.properties will not be included in there. I would suggest that the right place for this kind of file would be your "assets" directory and you have to use the correct class to access it.</p>

Body:
I have a file defined next to the default.properties, AndroidManifest.xml,  called my_config.properties. my question is. how do open this file in my class?

if i move it to the class package i can read it using the folowing code:

 Properties configFile = new Properties();
    try {
        configFile.load(MyConstantsClass.class.getResourceAsStream("my_config.properties"));
    } catch (IOException e) {
        e.printStackTrace();
    }

but in this case the file needs to be inside the same package as the class i use this snippet in. how do i read from it when its defined like in the beggining of my question?
Thank you.


问:
Use of twiml attribute in Client.calls.create()l
I am new on Twilio and I was trying to use the following tutorial:

https://www.twilio.com/docs/voice/tutorials/how-to-make-outbound-phone-calls-python

Using the twiml attribute instead of Url:

```<code>call = client.calls.create(
                        twiml='<Response><Say>Ahoy, World!</Say></Response>',
                        to='+YYYYYYYYY',
                        from_='+XXXXXXXXX'
                    )
</code>```

When I launched it, I received the following error:

```<code>responded with an error: error processing request: create() got an unexpected keyword argument 'twiml'
</code>```

Is twiml deprecated? I use the last version of Twilio and Python 2.7. It seems really odd to me since the tutorial was made in January 2020.

答:
Using the twiml attribute for calls create is a newer feature, and thus requires a more recent version of the Twilio Helper Library. You can use url (if you cannot upgrade), which has existed for some time and takes a URL which returns TwiML.

Pass TwiML with Call Initiation Requests GA

[2019-12-12] Version 6.35.0

Body:
I am new on Twilio and I was trying to use the following tutorial:

https://www.twilio.com/docs/voice/tutorials/how-to-make-outbound-phone-calls-python

Using the twiml attribute instead of Url:

call = client.calls.create(
                        twiml='<Response><Say>Ahoy, World!</Say></Response>',
                        to='+YYYYYYYYY',
                        from_='+XXXXXXXXX'
                    )

When I launched it, I received the following error:

responded with an error: error processing request: create() got an unexpected keyword argument 'twiml'

Is twiml deprecated? I use the last version of Twilio and Python 2.7. It seems really odd to me since the tutorial was made in January 2020.


问:
python requests only returning empty sets when scraping
It's my first try doing programming. I'm trying to scrape some words by scraping using bs4, selenium etc...
The site I use is 'http://oulim.kr'

How can I scrape things inside the frameset?

this is what i have tried

```<code>import urllib
from bs4 import BeautifulSoup
from selenium import webdriver

url = 'http://oulim.kr/'

driver = webdriver.Chrome('./driver/chromedriver')
driver.get(url)

html = driver.page_source
soup = BeautifulSoup(html)

a = soup.select("#divAlba > table:nth-child(3) > tbody > tr:nth-child(2) > td:nth-child(5) > a > font > b")
print(a)

from requests_html import HTMLSession
session = HTMLSession()
r = session.get('http://oulim.kr')
r.html.find('.tbody')
</code>```

答:
Selenium treats frames as separated pages (because it has to load it separatelly) and it doesn't search in frames. And page_source doesn't return HTML from frame.

You have to find <frame> and switch to correct frame switch_to.frame(..) to work with it.

```<code>frames = driver.find_elements_by_tag_name('frame')
driver.switch_to.frame(frames[0])
</code>```

```<code>import urllib
from bs4 import BeautifulSoup
from selenium import webdriver

url = 'http://oulim.kr/'

driver = webdriver.Chrome('./driver/chromedriver')
driver.get(url)

# --- switch frame ---

frames = driver.find_elements_by_tag_name('frame')
driver.switch_to.frame(frames[0])

# --- CSS without BeautifulSoup ---

a = driver.find_element_by_css_selector("#divAlba > table:nth-child(3) > tbody > tr:nth-child(2) > td:nth-child(5) > a > font > b")
print(a.text)

# --- CSS with BeautifulSoup ---

html = driver.page_source
soup = BeautifulSoup(html)

a = soup.select("#divAlba > table:nth-child(3) > tbody > tr:nth-child(2) > td:nth-child(5) > a > font > b")
print(a[0].text)
</code>```

Body:
It's my first try doing programming. I'm trying to scrape some words by scraping using bs4, selenium etc...
The site I use is 'http://oulim.kr'

How can I scrape things inside the frameset?

this is what i have tried

import urllib
from bs4 import BeautifulSoup
from selenium import webdriver

url = 'http://oulim.kr/'

driver = webdriver.Chrome('./driver/chromedriver')
driver.get(url)

html = driver.page_source
soup = BeautifulSoup(html)

a = soup.select("#divAlba > table:nth-child(3) > tbody > tr:nth-child(2) > td:nth-child(5) > a > font > b")
print(a)

from requests_html import HTMLSession
session = HTMLSession()
r = session.get('http://oulim.kr')
r.html.find('.tbody')

Body:
Selenium treats frames as separated pages (because it has to load it separatelly) and it doesn't search in frames. And page_source doesn't return HTML from frame.

You have to find <frame> and switch to correct frame switch_to.frame(..) to work with it.

frames = driver.find_elements_by_tag_name('frame')
driver.switch_to.frame(frames[0])

import urllib
from bs4 import BeautifulSoup
from selenium import webdriver

url = 'http://oulim.kr/'

driver = webdriver.Chrome('./driver/chromedriver')
driver.get(url)

# --- switch frame ---

frames = driver.find_elements_by_tag_name('frame')
driver.switch_to.frame(frames[0])

# --- CSS without BeautifulSoup ---

a = driver.find_element_by_css_selector("#divAlba > table:nth-child(3) > tbody > tr:nth-child(2) > td:nth-child(5) > a > font > b")
print(a.text)

# --- CSS with BeautifulSoup ---

html = driver.page_source
soup = BeautifulSoup(html)

a = soup.select("#divAlba > table:nth-child(3) > tbody > tr:nth-child(2) > td:nth-child(5) > a > font > b")
print(a[0].text)


问:
QWebChannel: crash on construction when running outside of QtCreator
When I try to run my programm outside the QtCreator, the code crashes, when new QWebChannel(this) is called. I already checked DLL dependencies, but can't find the difference between running it from within the IDE and outside of it.

```<code>MyView::MyView() : ui(new Ui::MyView) {
    ui->setupUi(this);
    view = new QWebEngineView(this);

    channel = new QWebChannel(this); // crash at this line

    ui->content->addWidget(view);
    connect(view, &QWebEngineView::loadFinished, this, &MyView::finishLoading);
    view->page()->setWebChannel(channel);
    channel->registerObject("controller", this);
    view->load(QUrl("qrc:///res/index.html"));
}
</code>```

In the project file I added QT += webengine webenginewidgets webchannel. Are there any other dependencies I may forgot?

答: Running windeployqt.exe copies all necessary dependencies (see https://doc.qt.io/qt-5/windows-deployment.html). Seames like some other resources nedded where causing the crash.

Body:
When I try to run my programm outside the QtCreator, the code crashes, when new QWebChannel(this) is called. I already checked DLL dependencies, but can't find the difference between running it from within the IDE and outside of it.

MyView::MyView() : ui(new Ui::MyView) {
    ui->setupUi(this);
    view = new QWebEngineView(this);

    channel = new QWebChannel(this); // crash at this line

    ui->content->addWidget(view);
    connect(view, &QWebEngineView::loadFinished, this, &MyView::finishLoading);
    view->page()->setWebChannel(channel);
    channel->registerObject("controller", this);
    view->load(QUrl("qrc:///res/index.html"));
}

In the project file I added QT += webengine webenginewidgets webchannel. Are there any other dependencies I may forgot?


问:
SSLHandshakeException when connecting to Wiremock with my own self-signed cert
I'm running a stand-alone instance of Wiremock for mocking in JUnit tests. This works fine with http and if I use the wiremock self-signed cert with the switch --https-port 8443. If I specify --https-keystore server_keystore.jks however, any attempt to communicate with Wiremock e.g WireMock.reset(); throws a javax.net.ssl.SSLHandshakeException: Remote host terminated the handshake. Connecting to the admin page https://localhost:9093/__admin/ in a browser shows a similar error about the connection being closed.

The keystore was generated as follows;

```<code>keytool -genkey -keyalg RSA -keysize 2048 -alias server -keypass secret -storepass secret -keystore server_keystore.jks
</code>```

If I enable logging for all traffic in Wiremock I see;

```<code>Problem decoding network traffic
java.nio.charset.MalformedInputException: Input length = 1
</code>```

I've added System.setProperty("javax.net.ssl.trustStore", "server_keystore.jks"); in my calling code prior to attempting to communicate with Wiremock with no success.

答: Since you've set a password on your keystore you'll need to provide this to WireMock via the --keystore-password parameter.

Body:
I'm running a stand-alone instance of Wiremock for mocking in JUnit tests. This works fine with http and if I use the wiremock self-signed cert with the switch --https-port 8443. If I specify --https-keystore server_keystore.jks however, any attempt to communicate with Wiremock e.g WireMock.reset(); throws a javax.net.ssl.SSLHandshakeException: Remote host terminated the handshake. Connecting to the admin page https://localhost:9093/__admin/ in a browser shows a similar error about the connection being closed.

The keystore was generated as follows;

keytool -genkey -keyalg RSA -keysize 2048 -alias server -keypass secret -storepass secret -keystore server_keystore.jks

If I enable logging for all traffic in Wiremock I see;

Problem decoding network traffic
java.nio.charset.MalformedInputException: Input length = 1

I've added System.setProperty("javax.net.ssl.trustStore", "server_keystore.jks"); in my calling code prior to attempting to communicate with Wiremock with no success.


问:
Event that gets fired before (not after!) DOM elements are scrolled in javascript
Basically, I would like to do some pre-processing before the DOM elements are scrolled. The problem is that the scroll event is fired AFTER the DOM elements are scrolled. I know that when you use the mousewheel to scroll, the mousewheel scroll event gets fired before DOM elements are scrolled although it does not provide you with the anticipated scroll position and it is only one type of scroll. I am wondering if there is any event that gets fired for every scroll method(eg. mousewheel, dragging the scroll bar, pushing the down arrow etc.) BEFORE the DOM elements are scrolled. It does not have to be an event. I am not trying to scroll to a certain position so scrollTo would not be applicable.

The chain of event with on scroll:
User scrolls -> DOM elements physically scroll -> fires onScroll event -> handle stuff

The desired chain of event:
User scrolls -> some event is captured and do what I want to do -> DOM elements physically scroll -> fires onScroll event -> handle stuff

答:
Heres something you might want to try.

Give your page overflow:hidden so that no scroll bars appear, then place an absolutely positioned div with the correct width & height over the content. When this div is scrolled, you can then update any underlying content before re-triggering the event.

You would need to pass through clicks etc as well, so this is really a hack. Something like jQuery would help with the triggering of the events and measuring the height of the content.

EDIT: css pointer-events:none may help here depending on the browser. See https://developer.mozilla.org/en/css/pointer-events


问:
C# How to Use button click Function from code and not only users click
Lets assume I have this code

```<code> private void Exitbtn_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }
</code>```

And I want to call this function from another part of my code and not only from the click of the user

```<code>code...
{
    ...do something...
    Exitbtn_Click()
}
</code>```

I have tried Exitbtn.Click +=new EventHandler(Exitbtn_Click); but it doesn't work i believe it is because of the word new but I am not sure, I am new to C#

答:
Whilst you could call:

```<code>Exitbtn_Click(null, EventArgs.Empty);
</code>```

If you actually need sender / EventArgs to be populated it could become messy.

Personally it seems cleaner to wrap the common logic in a private method and call from both places.

```<code>private void ApplicationExit()
{
    Application.Exit();
}

private void Exitbtn_Click(object sender, EventArgs e)
{
    ApplicationExit();
}

code...
{
    ...do something...
    ApplicationExit();
}
</code>```

Body:
Lets assume I have this code

 private void Exitbtn_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

And I want to call this function from another part of my code and not only from the click of the user

code...
{
    ...do something...
    Exitbtn_Click()
}

I have tried Exitbtn.Click +=new EventHandler(Exitbtn_Click); but it doesn't work i believe it is because of the word new but I am not sure, I am new to C#

Body:
Whilst you could call:

Exitbtn_Click(null, EventArgs.Empty);

If you actually need sender / EventArgs to be populated it could become messy.

Personally it seems cleaner to wrap the common logic in a private method and call from both places.

private void ApplicationExit()
{
    Application.Exit();
}

private void Exitbtn_Click(object sender, EventArgs e)
{
    ApplicationExit();
}

code...
{
    ...do something...
    ApplicationExit();
}


答:
because you path is not correct， it include other file， change your path to source code path.</p>

```<code>find .(change here) -iname *.h -o -iname *.cpp -iname *.c | xargs clang-format -i
</code>```

Title: clang-format 3.8.1 fails with "Assertion failed: getClient() && "DiagnosticClient not set!""

Body:
I'm running clang-format 3.8.1 on Windows through git-bash with the line:

find . -iname *.h -o -iname *.cpp -iname *.c | xargs clang-format -i

but it keeps failing:

Assertion failed: getClient() && "DiagnosticClient not set!", file D:\src\llvm_package_3.8.1-final\llvm\tools\clang\lib\Basic\Diagnostic.cpp, line 363

  0x000000013FFC26A6 (0x0000000000000016 0x0000000189CC4301 0x0000000000000000 0x00000000771A7E0A)
  0x00000001400DB32D (0x0000000100000001 0xFFFFFFFF00000000 0x0000000140159EE4   0x0000000000000260)

  0x00000001400DB638 (0x000000014018B270 0x0000000140159EE4 0x000000014015A3B0 0x0000000140159EE4)

  0x00000001400D9857 (0x0000000000000000 0x000000000000000F 0x000000000000004F 0x0000000000000000)

  0x000000013FFF5D3C (0x0000000000CB29BA 0x0000000000CB29BA 0x0000000000C2C940 0x0000000000CB29B8)

  0x00000001400379BD (0x0000000000BF9530 0x000007FE00000000 0x000000000E00020C 0x00000000771CF2D3)

  0x000000013FFB3D37 (0x0000000000000000 0x0000000000000338 0x0000000002520B80 0x0000000000000000) 0x000000013FFB1DD6

  (0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000)  0x00000001400DA2F0 (0x0000000000000000
  0x0000000000000000 0x0000000000000000 0x0000000000000000)

  0x0000000076F759BD (0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000), BaseThreadInitThunk() + 0xD bytes(s)

  0x00000000771AA2E1 (0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000), RtlUserThreadStart() + 0x21

  bytes(s) xargs: clang-format: terminated by signal 4

The same error is listed in LLVM assertion error but that's for a build and there's no helpful answer. Is there a simple way to get round this?

Body:
because you path is not correct， it include other file， change your path to source code path.

find .(change here) -iname *.h -o -iname *.cpp -iname *.c | xargs clang-format -i


问:
Keeping track of mutated rows in BigQuery?
I have a large table whose rows get updated/inserted/merged periodically from a few different queries. I need a scheduled process to run (via API) to periodically check for which rows in that table were updated since the last check. So here are my issues...

When I run the merge query, I don't see a way for it to return which records were updated... otherwise, I could be copying those updated rows to a special updated_records table.

There are no triggers so I can't keep track of mutations that way.

I could add a last_updated timestamp column to keep track that way, but then repeatedly querying the entire table all day for that would be a huge amount of data billed (expensive).

I'm wondering if I'm overlooking something obvious or if maybe there's some kind of special BQ metadata that could help?

The reason I'm attempting this is that I'm wanting to extract and synchronize a smaller subset of this table into my PostgreSQL instance because the latency for querying BQ is just too much for smaller queries.

Any ideas? Thanks!

答:
If the table is large but the amount of data updated per day is modest then you can partition and/or cluster the table on the last_updated_date column. There are some edge cases, like the first today's check should filter for last_updated_date being either today or yesterday.

Depending of how modest this amount of data updated throughout a day is, even repeatedly querying the entire table all day could be affordable because BQ engine will scan one daily partition only.

P.S.

Detailed explanation

I could add a last_updated timestamp column to keep track that way

I inferred from that the last_updated column is not there yet (so the check-for-updates statement cannot currently distinguish between updated rows and non-updated ones) but you can modify the table UPDATE statements so that this column will be added to the newly modified rows.

Therefore I assumed you can modify the updates further to set the additional  last_updated_date column which will contain the date portion of the timestamp stored in the last_updated column.

but then repeatedly querying the entire table all day

From here I inferred there are multiple checks throughout the day.

but the data being updated can be for any time frame

Sure, but as soon as a row is updated, no matter how old this row is, it will acquire two new columns last_updated and last_updated_date - unless both columns have already been added by the previous update in which cases the two columns will be updated rather than added. If there are several updates to the same row between the update checks, then the latest update will still make the row to be discoverable by the checks that use the logic described below.

The check-for-update statement will (conceptually, not literally):

filter rows to ensure last_updated_date=today AND last_updated>last_checked. The datetime of the previous update check will be stored in last_checked and where this piece of data is held (table, durable config) is implementation dependent.

discover if the current check is the first today's check. If so then additionally search for last_updated_date=yesterday AND last_updated>last_checked.

Note 1
If the table is partitioned and/or clustered on the last_updated_date column, then the above update checks will not cause table scan. And subject to ‘modest’ assumption made at the very beginning of my answer, the checks will satisfy your 3rd bullet point.

Note 2
The downside of this approach is that the checks for updates will not find rows that had been updated before the table UPDATE statements were modified to include the two extra columns. (Such rows will be in the__NULL__ partition with rows that never were updated.) But I assume until the changes to the UPDATE statements are made it will be impossible to distinguish between updated rows and non-updated ones anyway.

Note 3
 This is an explanatory concept. In the real implementation you might need one extra column instead of two. And you will need to check which approach works better: partitioning or clustering (with partitioning on a fake column) or both.

The detailed explanation of the initial (e.g. above P.S.) answer ends here.

Note 4

clustering only helps performance

From the point of view of table scan avoidance and achieving a reduction in the data usage/costs, clustering alone (with fake partitioning) could be as potent as partitioning.

Note 5

In the comment you mentioned there is already some partitioning in place. I’d suggest to examine if the existing partitioning is indispensable, can it be replaced with clustering.


问:
Using flexbox to change ordering in Bootstrap 4
I'm currently building a site that has a team section that should look like the following:

Here is my current scss file:

```<code>.team-member-card {
  &__text-content {
    background-color: red;
    padding: 16px;
    overflow-y: scroll;
  }

  &__name {
    font-family: CircularStd;
    font-size: 24px;
    font-weight: bold;
    font-stretch: normal;
    font-style: normal;
    line-height: normal;
    letter-spacing: normal;
    color: $white;
  }

  &__role {
    font-family: CircularStd;
    font-size: 18px;
    font-weight: 500;
    font-stretch: normal;
    font-style: normal;
    line-height: 1.44;
    letter-spacing: normal;
    color: $white;
  }

  &__biography {
    font-family: Balto;
    font-size: 16px;
    font-weight: normal;
    font-stretch: normal;
    font-style: normal;
    line-height: 1.5;
    letter-spacing: normal;
    color: $white;
  }

  &__image-container {
    position: relative;
  }

  &__image {
    height: auto;
    max-width: 100%;
    object-fit: contain;
    background-color: #ffffff;
  }

  &__social-link {
    position: absolute;
    width: 48px;
    height: 48px;
    object-fit: contain;
  }
}
</code>```

I have broken the component down into the obvious sections I can see but as you can see, every n+1 team member has their image on the other side, is there a way to inverse the column order?

答:
https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Flexible_Box_Layout/Ordering_Flex_Items

please check documentation. To understand code check below

```<code>    <div class="box">
        <div><a href="#">1</a></div>
        <div><a href="#">2</a></div>
        <div><a href="#">3</a></div>
        <div><a href="#">4</a></div>
        <div><a href="#">5</a></div>
    </div>

 .box {
          display: flex;
          flex-direction: row;
        }
        .box :nth-child(1) { order: 2; }
        .box :nth-child(2) { order: 3; }
        .box :nth-child(3) { order: 1; }
        .box :nth-child(4) { order: 3; }
        .box :nth-child(5) { order: 1; }
</code>```

Body:
I'm currently building a site that has a team section that should look like the following:

Here is my current scss file:

.team-member-card {
  &__text-content {
    background-color: red;
    padding: 16px;
    overflow-y: scroll;
  }

  &__name {
    font-family: CircularStd;
    font-size: 24px;
    font-weight: bold;
    font-stretch: normal;
    font-style: normal;
    line-height: normal;
    letter-spacing: normal;
    color: $white;
  }

  &__role {
    font-family: CircularStd;
    font-size: 18px;
    font-weight: 500;
    font-stretch: normal;
    font-style: normal;
    line-height: 1.44;
    letter-spacing: normal;
    color: $white;
  }

  &__biography {
    font-family: Balto;
    font-size: 16px;
    font-weight: normal;
    font-stretch: normal;
    font-style: normal;
    line-height: 1.5;
    letter-spacing: normal;
    color: $white;
  }

  &__image-container {
    position: relative;
  }

  &__image {
    height: auto;
    max-width: 100%;
    object-fit: contain;
    background-color: #ffffff;
  }

  &__social-link {
    position: absolute;
    width: 48px;
    height: 48px;
    object-fit: contain;
  }
}

I have broken the component down into the obvious sections I can see but as you can see, every n+1 team member has their image on the other side, is there a way to inverse the column order?

Body:
https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Flexible_Box_Layout/Ordering_Flex_Items

please check documentation. To understand code check below

    <div class="box">
        <div><a href="#">1</a></div>
        <div><a href="#">2</a></div>
        <div><a href="#">3</a></div>
        <div><a href="#">4</a></div>
        <div><a href="#">5</a></div>
    </div>

 .box {
          display: flex;
          flex-direction: row;
        }
        .box :nth-child(1) { order: 2; }
        .box :nth-child(2) { order: 3; }
        .box :nth-child(3) { order: 1; }
        .box :nth-child(4) { order: 3; }
        .box :nth-child(5) { order: 1; }


问:
Setting parameters in Kedro Notebook
Is it possible to overwrite properties taken from the parameters.yaml file within a Kedro notebook?

I am trying to dynamically change parameter values within a notebook. I would like to be able to give users the ability to run a standard pipeline but with customizable parameters. I don't want to change the YAML file, I just want to change the parameter for the life of the notebook.

I have tried editing the params within the context but this has no affect.

```<code>context.params.update({"test_param": 2})
</code>```

Am I missing something or is this not an intended use case?

答:
Kedro supports specifying extra parameters from the command line by running

kedro run --params "key1:value1,key2:value2"
```

<p>which solves your second use case.</p>

<p>As for the notebook use case, updating <code>context.params</code> does not have any effect since the context does not store the parameters on <code>self</code> but rather pulls them from the config every time the property is being called.</p>

<p>However you can still add extra parameters to the context object after it being instantiated:</p>

<pre class="lang-py prettyprint-override"><code>extra_params = context._extra_params or {}
extra_params.update({"test_param": 2})
context._extra_params = extra_params
</code>```

This will update extra parameters that are applied on top of regular parameters coming from the config.

Title: Setting parameters in Kedro Notebook

Body:
Is it possible to overwrite properties taken from the parameters.yaml file within a Kedro notebook?

I am trying to dynamically change parameter values within a notebook. I would like to be able to give users the ability to run a standard pipeline but with customizable parameters. I don't want to change the YAML file, I just want to change the parameter for the life of the notebook.

I have tried editing the params within the context but this has no affect.

context.params.update({"test_param": 2})

Am I missing something or is this not an intended use case?

Body:
Kedro supports specifying extra parameters from the command line by running

kedro run --params "key1:value1,key2:value2"

which solves your second use case.

As for the notebook use case, updating context.params does not have any effect since the context does not store the parameters on self but rather pulls them from the config every time the property is being called.

However you can still add extra parameters to the context object after it being instantiated:

extra_params = context._extra_params or {}
extra_params.update({"test_param": 2})
context._extra_params = extra_params

This will update extra parameters that are applied on top of regular parameters coming from the config.


问:
how do i Delay a component html from loading till all images are gotten?
i have a home page where i want to display the first 3 images as a slider which are called from an API.
this is my controller

```<code>export class ClientComponent implements OnInit {   public event;   public imgePAth: any;   public singleImg: any;   public secondImg: any;   public isAv: boolean = false;   filtersLoaded: Promise<boolean>;

  constructor(private servive: TycketService, private http: HttpClient,private route: Router) { }

  ngOnInit() {
    this.servive.allEvent().subscribe(data => {
      this.event = data;
      console.log(this.event);

      this.imgePAth = this.servive.imagebaseUrl(this.event[0]['image']);
      this.singleImg = this.servive.imagebaseUrl(this.event[1]['image']);
      this.secondImg = this.servive.imagebaseUrl(this.event[2]['image']);
      this.isAv = true;
      this.filtersLoaded = Promise.resolve(true);
      console.log(this.imgePAth);
    });   } }
</code>```

my api service

```<code>  imagebaseUrl(data){
    return (this.imageUrl + data);
  }
</code>```

my html ignore the event index, i am setting the background image w the [ngStyle], when i inspect i get an undefined path of the variable, but when i console.log the path in my ngOnInit i get the right path

```<code><div class="cover_slider owl-carousel owl-theme" *ngIf="filtersLoaded | async">
        <div class="overlay">
            <div class="cover_item" [ngStyle]="{'background-image':'url('+imgePAth+')'}">
                <div class="slider_content">
                    <div class="slider-content-inner">
                        <div class="container">
                            <div class="slider-content-center" *ngIf="event && event[0]">
                                <h2 class="cover-title">
                                    Prepare yourself for
                                </h2>
                                <strong class="cover-xl-text">{{event[0]['name']}}</strong>
                                <p class="cover-date">
                                    {{event[0]['date']}}  - {{event[0]['venue']}} {{event[0]['location']}}.
                                </p>
                                <button class=" btn btn-primary btn-rounded" (click)="onClickBuy(event[0])">Buy Tickets Now</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
</div>
</code>```

what is the solution for this?
enter image description here

答:
it turned out that the pictures were coming down.

```<code><div class="cover_slider owl-carousel owl-theme" *ngIf="filtersLoaded | async">
    <div class="overlay">
        <div class="cover_item" [ngStyle]="{'background-image':'url('+imgePAth+')'}">
            <div class="slider_content">
                <div class="slider-content-inner">
                    <div class="container">
                        <div class="slider-content-center" *ngIf="event && event[0]">
                            <h2 class="cover-title">
                                Prepare yourself for
                            </h2>
                            <strong class="cover-xl-text">{{event[0]['name']}}</strong>
                            <p class="cover-date">
                                {{event[0]['date']}}  - {{event[0]['venue']}} {{event[0]['location']}}.
                            </p>
                            <button class=" btn btn-primary btn-rounded" (click)="onClickBuy(event[0])">Buy Tickets Now</button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</code>```

when i took out the ngIf condition, (*ngIf="event && event[0]") the pictures and details are rendered. i added that condition to resolve this error

ERROR MESSAGE

```<code>ClientComponent.html:58 ERROR TypeError: Cannot read property '0' of undefined
    at Object.eval [as updateRenderer] (ClientComponent.html:58)
    at Object.debugUpdateRenderer [as updateRenderer] (core.js:30069)
    at checkAndUpdateView (core.js:29444)
    at callViewAction (core.js:29680)
    at execComponentViewsAction (core.js:29622)
    at checkAndUpdateView (core.js:29445)
    at callViewAction (core.js:29680)
    at execEmbeddedViewsAction (core.js:29643)
    at checkAndUpdateView (core.js:29440)
    at callViewAction (core.js:29680)
</code>```

making sure i had the events so i could access their indexs, although their details are rendered, the error comes up in the console
how can i go about this?

Body:
i have a home page where i want to display the first 3 images as a slider which are called from an API.
this is my controller

export class ClientComponent implements OnInit {   public event;   public imgePAth: any;   public singleImg: any;   public secondImg: any;   public isAv: boolean = false;   filtersLoaded: Promise<boolean>;

  constructor(private servive: TycketService, private http: HttpClient,private route: Router) { }

  ngOnInit() {
    this.servive.allEvent().subscribe(data => {
      this.event = data;
      console.log(this.event);

      this.imgePAth = this.servive.imagebaseUrl(this.event[0]['image']);
      this.singleImg = this.servive.imagebaseUrl(this.event[1]['image']);
      this.secondImg = this.servive.imagebaseUrl(this.event[2]['image']);
      this.isAv = true;
      this.filtersLoaded = Promise.resolve(true);
      console.log(this.imgePAth);
    });   } }

my api service

  imagebaseUrl(data){
    return (this.imageUrl + data);
  }

my html ignore the event index, i am setting the background image w the [ngStyle], when i inspect i get an undefined path of the variable, but when i console.log the path in my ngOnInit i get the right path

                                    Prepare yourself for

                                {{event[0]['name']}}

                                    {{event[0]['date']}}  - {{event[0]['venue']}} {{event[0]['location']}}.

                                <button class=" btn btn-primary btn-rounded" (click)="onClickBuy(event[0])">Buy Tickets Now</button>

what is the solution for this?
enter image description here

Body:
it turned out that the pictures were coming down.

<div class="cover_slider owl-carousel owl-theme" *ngIf="filtersLoaded | async">
    <div class="overlay">
        <div class="cover_item" [ngStyle]="{'background-image':'url('+imgePAth+')'}">
            <div class="slider_content">
                <div class="slider-content-inner">
                    <div class="container">
                        <div class="slider-content-center" *ngIf="event && event[0]">
                            <h2 class="cover-title">
                                Prepare yourself for
                            </h2>
                            <strong class="cover-xl-text">{{event[0]['name']}}</strong>
                            <p class="cover-date">
                                {{event[0]['date']}}  - {{event[0]['venue']}} {{event[0]['location']}}.
                            </p>
                            <button class=" btn btn-primary btn-rounded" (click)="onClickBuy(event[0])">Buy Tickets Now</button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

when i took out the ngIf condition, (*ngIf="event && event[0]") the pictures and details are rendered. i added that condition to resolve this error

ERROR MESSAGE

ClientComponent.html:58 ERROR TypeError: Cannot read property '0' of undefined
    at Object.eval [as updateRenderer] (ClientComponent.html:58)
    at Object.debugUpdateRenderer [as updateRenderer] (core.js:30069)
    at checkAndUpdateView (core.js:29444)
    at callViewAction (core.js:29680)
    at execComponentViewsAction (core.js:29622)
    at checkAndUpdateView (core.js:29445)
    at callViewAction (core.js:29680)
    at execEmbeddedViewsAction (core.js:29643)
    at checkAndUpdateView (core.js:29440)
    at callViewAction (core.js:29680)

making sure i had the events so i could access their indexs, although their details are rendered, the error comes up in the console
how can i go about this?


问:
Bash exceute multuple commands after || if non 0
I have a line of code in my scripts to make sure a conda environment exists and then if not install the environment and download the database for a programme in the environment. I have this code:

```<code>   test -d ~/miniconda3/envs/antismash_v5 || echo "Conda environment does not exist. Initialising conda environment......" && conda env create -f antismash.yml &&  conda activate antismash_v5 && download-antismash-databases
</code>```

But this just exceute everything after the first && regardless of if the test function returns non zero before ||. How can I get this to work as intended?

答: && and || have the same precedence, so you can wrap the following in {} eg. ... || { ... ; }

Body:
I have a line of code in my scripts to make sure a conda environment exists and then if not install the environment and download the database for a programme in the environment. I have this code:

   test -d ~/miniconda3/envs/antismash_v5 || echo "Conda environment does not exist. Initialising conda environment......" && conda env create -f antismash.yml &&  conda activate antismash_v5 && download-antismash-databases

But this just exceute everything after the first && regardless of if the test function returns non zero before ||. How can I get this to work as intended?


问:
Generate a binary matrix H knowing only the positions of the 1's
I would like to construct a binary matrix H of very large size, knowing only the positions of the '1's in the matrix.

For example if I know the following coordinates : (1,1) = 1 , (3,1) = 1 , (2,2) = 1, (1,3) = 1.The generated matrix gives : H = [1 0 1 ; 0 1 0 ; 1 0 0]

I tried to do it manually but with a very large matrix (For example 512*1024) it becomes very complicated.

Thank you.

答:
Use a sparse matrix:

```<code>% The coordinates
x = [1 3 2 1]
y = [1 1 2 3]

% Create a sparse matrix, then convert the sparse matrix to a full storage matrix
H = full(sparse(x,y,1))
</code>```

Or even shorter (but using the same logic):

```<code>H = sparse(x,y,1)+0
% It works because matlab use an implicit class conversion
</code>```

Body:
Use a sparse matrix:

% The coordinates
x = [1 3 2 1]
y = [1 1 2 3]

% Create a sparse matrix, then convert the sparse matrix to a full storage matrix
H = full(sparse(x,y,1))

Or even shorter (but using the same logic):

H = sparse(x,y,1)+0
% It works because matlab use an implicit class conversion


问:
Show modal page on only a portion of the screen

I am developing an iPad app using Xamarin.Forms.
I would like my settingspage to be modal so it lay over the previous page like a popup.

I have been trying all solutions I could find and most of them seems to recommend me to call this from a button:

await Navigation.PushModalAsync(ModalSettingsPage);
```

<p>What happens when I use it is that my settingspage comes in from below as a modal page but not as a popup, it covers the entire screen. </p>

<p>This is my current code: </p>

<pre class="lang-cs prettyprint-override"><code> //Setup button (action bar)
            ToolbarItems.Add(new ToolbarItem
            {
                // Text = "Setup",
                Icon = "settings1.png",
                Order = ToolbarItemOrder.Default,
                Command = new Command(() => Navigation.PushModalAsync(new ModalSettingsPage())) //Action to perfome on click , open modal view
            });
</code>```

Also, does anyone now if there is any good way to positions the ToolbarItems? I have two items and would like each one to be positioned at each side, but by default they are both positioned to the right.

答:
With the evolution of Forms (currently 4.5.0), it has now become simple to push a modalpage which is not fullscreen. Use the following in your code-behind of your xaml contentpage:

using Xamarin.Forms;
using Xamarin.Forms.PlatformConfiguration;
using Xamarin.Forms.PlatformConfiguration.iOSSpecific;

namespace YourAppWithAModalPage
{
    public class ModalPage : ContentPage
    {
        public ModalPage()
        {
            // iOS Solution for a ModalPage (popup) which is not fullscreen
            On<iOS>().SetModalPresentationStyle(UIModalPresentationStyle.FormSheet);
        }
    }
}```

Body:
I am developing an iPad app using Xamarin.Forms.
I would like my settingspage to be modal so it lay over the previous page like a popup.

I have been trying all solutions I could find and most of them seems to recommend me to call this from a button:

await Navigation.PushModalAsync(ModalSettingsPage);

What happens when I use it is that my settingspage comes in from below as a modal page but not as a popup, it covers the entire screen.

This is my current code:

 //Setup button (action bar)
            ToolbarItems.Add(new ToolbarItem
            {
                // Text = "Setup",
                Icon = "settings1.png",
                Order = ToolbarItemOrder.Default,
                Command = new Command(() => Navigation.PushModalAsync(new ModalSettingsPage())) //Action to perfome on click , open modal view
            });

Also, does anyone now if there is any good way to positions the ToolbarItems? I have two items and would like each one to be positioned at each side, but by default they are both positioned to the right.


问:
"Where" are Websocket servers hosted on Heroku?
I'm trying to host a Websocket server on my heroku app. There already is a GraphQL server running, but I don't think it's the cause of my problem.

So my server is started like this

const wss = new ws.Server({ port: port }, () => console.log(`Serveur WebSocket prêt ${port}`));
```

<p>There is no error, but when I try to connect to the server in my browser, just like this :</p>

<pre class="lang-js prettyprint-override"><code>const ws = new WebSocket('wss://ethyme-api.herokuapp.com/');
</code>```

I get an error 404.

So my question is, what is the path of the ws server, so I can connect to it ?

Thanks

答: If your Heroku app is called ethyme-api and and your locally run application is available under ws://localhost:$PORT/ the websocket will be available under wss://ethyme-api.herokuapp.com/ and ws://ethyme-api.herokuapp.com/

Body:
I'm trying to host a Websocket server on my heroku app. There already is a GraphQL server running, but I don't think it's the cause of my problem.

So my server is started like this

const wss = new ws.Server({ port: port }, () => console.log(`Serveur WebSocket prêt ${port}`));

There is no error, but when I try to connect to the server in my browser, just like this :

const ws = new WebSocket('wss://ethyme-api.herokuapp.com/');

I get an error 404.

So my question is, what is the path of the ws server, so I can connect to it ?

Thanks


问:
Retrieving original node names in Networkit
I am not sure I understand how Networkit handles the names of the nodes.

Let's say that I read a large graph from an edgelist, using another Python module like Networkx; then I convert it to a Network graph and I perform some operations, like computing the pairwise distances. A simple piece of code to do this could be:

```<code>import networkx as nx
import networkit as nk

nxG=nx.read_edgelist('test.edgelist',data=True)

G = nk.nxadapter.nx2nk(nxG, weightAttr='weight')

apsp = nk.distance.APSP(G)
apsp.run()
dist=apsp.getDistances()
</code>```

easy-peasy.

Now, what if I want to do something with those distances? For examples, what if I want to plot them against, I don’t know, the weights on the paths, or any other measure that requires the retrieval of the original node ids?

The getDistances() function returns a list of lists, one for each node with the distance to every other node,  but I have no clue on how Networkit maps the nodes’ names to the sequence of ints that it uses as nodes identifiers, thus the order it followed to compute the distances and store them in the output.

答:
When creating a new graph from networkx, NetworKit creates a dictionary that maps each node id in nxG to an unique integer from 0 to n - 1 in G (where n is the number of nodes) with this instruction.
Unfortunately, this mapping is not returned by nx2nk, so you should create it yourself.

Let's assume that you want to get a distance from node 1 to node 2, where 1 and 2 are node ids in nxG:

```<code>import networkx as nx
import networkit as nk

nxG=nx.read_edgelist('test.edgelist',data=True)

G = nk.nxadapter.nx2nk(nxG, weightAttr='weight')

# Get mapping from node ids in nxG to node ids in G
idmap = dict((id, u) for (id, u) in zip(nxG.nodes(), range(nxG.number_of_nodes())))

apsp = nk.distance.APSP(G)
apsp.run()
dist=apsp.getDistances()

# Get distance from node `1` to node `2`
dist_from_1_to_2 = dist[idmap['1']][idmap['2']]
</code>```

Body:
I am not sure I understand how Networkit handles the names of the nodes.

Let's say that I read a large graph from an edgelist, using another Python module like Networkx; then I convert it to a Network graph and I perform some operations, like computing the pairwise distances. A simple piece of code to do this could be:

import networkx as nx
import networkit as nk

nxG=nx.read_edgelist('test.edgelist',data=True)

G = nk.nxadapter.nx2nk(nxG, weightAttr='weight')

apsp = nk.distance.APSP(G)
apsp.run()
dist=apsp.getDistances()

easy-peasy.

Now, what if I want to do something with those distances? For examples, what if I want to plot them against, I don’t know, the weights on the paths, or any other measure that requires the retrieval of the original node ids?

The getDistances() function returns a list of lists, one for each node with the distance to every other node,  but I have no clue on how Networkit maps the nodes’ names to the sequence of ints that it uses as nodes identifiers, thus the order it followed to compute the distances and store them in the output.

Body:
When creating a new graph from networkx, NetworKit creates a dictionary that maps each node id in nxG to an unique integer from 0 to n - 1 in G (where n is the number of nodes) with this instruction.
Unfortunately, this mapping is not returned by nx2nk, so you should create it yourself.

Let's assume that you want to get a distance from node 1 to node 2, where 1 and 2 are node ids in nxG:

import networkx as nx
import networkit as nk

nxG=nx.read_edgelist('test.edgelist',data=True)

G = nk.nxadapter.nx2nk(nxG, weightAttr='weight')

# Get mapping from node ids in nxG to node ids in G
idmap = dict((id, u) for (id, u) in zip(nxG.nodes(), range(nxG.number_of_nodes())))

apsp = nk.distance.APSP(G)
apsp.run()
dist=apsp.getDistances()

# Get distance from node `1` to node `2`
dist_from_1_to_2 = dist[idmap['1']][idmap['2']]


问:
Change color of a background on click to a multiple choice of color us with jquery
I am trying to add multiple color choices? How can I do it with HTML and CSS?
i dont know how to correctly add multiple color choice
here are my codes

$(document).ready(function() {
      $('#btn').click(function() {
        $('body').css('background', '#ff0000', '#80ff33');
      });```
<pre class="snippet-code-css lang-css prettyprint-override"><code>body {
  height: ;
  background: #D8D8D8;
}

.text {
  color: #686868;
  font-family: arial;
  font-size: 2em;
  text-align: center;
  margin-top: 50px;
  margin-bottom: 20px;
}

#btn {
  margin-left: 550px;
  width: 200px;
  height: 100px;
  font-size: 2em;
  border-radius: 10px;
  background: #ffffff;
}

#btn:hover {
  background: #ff0000;
  background: #80ff33;
  color: #ffffff;
}</code>```

  CLICK THE BUTTON TO
 CHANGE THE BACKGROUND!

<button id="btn">CLICK ME!</button>```

答:
you can change the body color on click with that on click event

body {
    height: ;
    background: #D8D8D8;
}

.text {
    color: #686868;
    font-family: arial;
    font-size: 2em;
    text-align: center;
    margin-top: 50px;
    margin-bottom: 20px;
}

#btn {
    margin-left: 550px;
    width: 200px;
    height: 100px;
    font-size: 2em;
    border-radius: 10px;
    background: #ffffff;
}

#btn:hover {
    background: #ff0000;
    background: #80ff33 ;
    color: #ffffff;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code></script>
<section class="text">
  CLICK THE BUTTON TO<br> CHANGE THE BACKGROUND!
</section>
<button id="btn" onclick="document.body.style.backgroundColor = 'green';">Click Me</button></code>```

Body:
I am trying to add multiple color choices? How can I do it with HTML and CSS?
i dont know how to correctly add multiple color choice
here are my codes

$(document).ready(function() {
      $('#btn').click(function() {
        $('body').css('background', '#ff0000', '#80ff33');
      });

body {
  height: ;
  background: #D8D8D8;
}

.text {
  color: #686868;
  font-family: arial;
  font-size: 2em;
  text-align: center;
  margin-top: 50px;
  margin-bottom: 20px;
}

#btn {
  margin-left: 550px;
  width: 200px;
  height: 100px;
  font-size: 2em;
  border-radius: 10px;
  background: #ffffff;
}

#btn:hover {
  background: #ff0000;
  background: #80ff33;
  color: #ffffff;
}

  CLICK THE BUTTON TO
 CHANGE THE BACKGROUND!

<button id="btn">CLICK ME!</button>

Body:
you can change the body color on click with that on click event

body {
    height: ;
    background: #D8D8D8;
}

.text {
    color: #686868;
    font-family: arial;
    font-size: 2em;
    text-align: center;
    margin-top: 50px;
    margin-bottom: 20px;
}

#btn {
    margin-left: 550px;
    width: 200px;
    height: 100px;
    font-size: 2em;
    border-radius: 10px;
    background: #ffffff;
}

#btn:hover {
    background: #ff0000;
    background: #80ff33 ;
    color: #ffffff;
}

</script>
<section class="text">
  CLICK THE BUTTON TO<br> CHANGE THE BACKGROUND!
</section>
<button id="btn" onclick="document.body.style.backgroundColor = 'green';">Click Me</button>


问:
How do I get git to display the changes in vim as hg does with the hgeditor script?
An interesting feature in mercurial is the ability to view the changes that will be committed in a vim split (see DiffsInCommitMessageInVIM).

Any hint on how to do so with git ?

答:
I've modified the HGEDITOR.SH script to support Git, you can clone it here:

```<code>git clone git://github.com/dharrigan/giteditor.git
</code>```

Enjoy!

Body:
I've modified the HGEDITOR.SH script to support Git, you can clone it here:

git clone git://github.com/dharrigan/giteditor.git

Enjoy!


问:
How to know more details about a previous rollout revision using kubectl?
There are commands given here which explain how to perform a rollback using kubectl. One that lists the previous versions of your deployment is:

kubectl rollout history deployment/myDeployment

This shows a list of previous versions based on their order and just their corresponding numbers. But how to know more details about them? It is hard to know which version I am rolling back to by just looking at a number.

答:
You can use the revision flag to get more information:

kubectl rollout history deployment/<Deployment-name>  --revision=<revision-number>

This will give you details about the Pod Template used in the specified revision number.

If you want the date on which the revision was deployed, use the -o yaml flag and check for creationTimestamp

kubectl rollout history deployment/<Deployment-name>  --revision=<revision-number>  -o yaml


问:
Set videoview position in constraint layout
main_acitivity.xml

```<code><?xml version="1.0" encoding="utf-8"?>
    <!--suppress ALL -->
    <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/black"
        android:id="@+id/main"
        tools:context=".MainActivity"
        android:layout_gravity="center"
        android:gravity="center">

    <VideoView
        android:id="@+id/videoView1"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_centerInParent="true"
        android:layout_gravity="center"
        android:gravity="center"
        />
</androidx.constraintlayout.widget.ConstraintLayout>
</code>```

Then in java I do the next

```<code>vv = (VideoView) findViewById(R.id.videoView1);

ConstraintLayout.LayoutParams pararams = (ConstraintLayout.LayoutParams) vv.getLayoutParams();
int ch=vv.getHeight();
pararams.height = vv.getWidth();

vv.setLayoutParams(pararams);
</code>```

HOW TO MAKE ELEMENT VERTICALLY CENTERED AFTER THAT? I did vv.setY, I did margins, I tried do stuff with xml - nothing work, video either in the top or stretched through all window

Currently :

I need :

答:
Try to add below properties

```<code><VideoView
    android:id="@+id/videoView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"/>
</code>```

I hope this can help you!

Body:
main_acitivity.xml

<?xml version="1.0" encoding="utf-8"?>

    <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/black"
        android:id="@+id/main"
        tools:context=".MainActivity"
        android:layout_gravity="center"
        android:gravity="center">

    <VideoView
        android:id="@+id/videoView1"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_centerInParent="true"
        android:layout_gravity="center"
        android:gravity="center"
        />
</androidx.constraintlayout.widget.ConstraintLayout>

Then in java I do the next

vv = (VideoView) findViewById(R.id.videoView1);

ConstraintLayout.LayoutParams pararams = (ConstraintLayout.LayoutParams) vv.getLayoutParams();
int ch=vv.getHeight();
pararams.height = vv.getWidth();

vv.setLayoutParams(pararams);

HOW TO MAKE ELEMENT VERTICALLY CENTERED AFTER THAT? I did vv.setY, I did margins, I tried do stuff with xml - nothing work, video either in the top or stretched through all window

Currently :

I need :

Body:
Try to add below properties

<VideoView
    android:id="@+id/videoView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"/>

I hope this can help you!


问:
Azure Response Time Monitoring per Url with a range
I am trying to configure the dashboard consists few business critical functionality which we needs to focus for performance monitoring based on the SLAs.

Example a landing page url retrieves a records needs to be faster and accepted SLA is

Green < 1sec
Amber 1 sec - 2 secs
Red > 2 secs

We were able to configure the same in SPLUNK based on flat file logs. However we could not able to configure similar thing in Azure.

As of now I could not able to create a dashboard for our requirement. Any type of graphical representation is Ok for us. Based on this monitoring we might need to react and improve the performance over the period of time when it goes slow.

答:
An approximated solution which can serve your purpose

use request time vs time char along with reference lines which can be your SLA thresholds
So you can figure out at this moment the response time is below or above the threshold

// Response time trend
  // Chart request duration over the last 12 hours
  requests
  | where timestamp > ago(12h)
  | summarize avgRequestDuration=avg(duration) by bin(timestamp, 10m) // use a time grain of 10 minutes
  | render timechart
  | extend Green = 200
  | extend Amber = 400
  | extend red = 800

it would look something like below

I think it is much more useful than your previous UI, which has kind of a meter like feel that gives you health indication at that moment, but with continuous time plot you get better picture of the trend


问:
When a variable goes out of scope does that mean it doesn't exist?
I'm not sure I understand scope - does an out-of-scope variable (I'm using Ruby) exist in memory somewhere or does it stop existing (I know you can't access it). Would it be inaccurate to say that an out-of-scope variable does not exist any more?

Maybe this is a philosophical question.

答: It exists for a little bit until the garbage collector disposes it (if it can).</p>

OwnerDisplayName: Mark

ContentLicense: CC BY-SA 2.5

OwnerDisplayName: cherouvim


问:
Pyspark: Create an array of struct from another array of struct
I'm using Pyspark 2.4 and would like to create df_2 from df_1:

df_1:

```<code>root
 |-- request: array (nullable = false)
 |    |-- address: struct (nullable = false)
 |    |    |-- street: string (nullable  = false)
 |    |    |-- postcode: string (nullable  = false)
</code>```

df_2:

```<code>root
 |-- request: array (nullable = false)
 |    |-- address: struct (nullable = false)
 |    |    |-- street: string (nullable  = false)
</code>```

I know UDF is one way, but are there any other ways, like the use of map(), to achieve the same goal?

答:
Use transform function :

```<code>df_2 = df_1.withColumn("request", expr("transform(request, x -> struct(x.street) as address)"))
</code>```

For each element of request array, we select only street field and create a new struct.

Body:
I'm using Pyspark 2.4 and would like to create df_2 from df_1:

df_1:

root
 |-- request: array (nullable = false)
 |    |-- address: struct (nullable = false)
 |    |    |-- street: string (nullable  = false)
 |    |    |-- postcode: string (nullable  = false)

df_2:

root
 |-- request: array (nullable = false)
 |    |-- address: struct (nullable = false)
 |    |    |-- street: string (nullable  = false)

I know UDF is one way, but are there any other ways, like the use of map(), to achieve the same goal?

Body:
Use transform function :

df_2 = df_1.withColumn("request", expr("transform(request, x -> struct(x.street) as address)"))

For each element of request array, we select only street field and create a new struct.


问:
How to Connect models in Ruby on Rails
I'm new to Ruby on Rails, I'm trying to build a simple shop app that let the user those 2 basic shop options:

Add CUSTOMERS (name, purchased PRODUCTS from the shop, and preferred_payment (can be set to 'cash' or 'credit' only).

Add PRODUCTS to the shop (name, price, and all the CUSTOMERS who bought this)

I'm aware to has_many and belongs_to, but in this case there are many from both.
I thought about using $ 'rails g scaffold' for both of them, but what should be the best way to connect between the customers and products from your experience?

And how can I render the 'cash' / 'credit' selection as a simple dropdown menu at the new customer form?

答:
Based on Many-to-Many data model, You should create the relation table(join table).

If relations between models should have additional fields or extra code - You should use the has_many :through association

Otherwise - You can use the has_and_belongs_to_many association

Title: How to Connect models in Ruby on Rails


问:
Adobe Sign (Echo Sign) API is only sending document to draft C#
I am working with Adobe Sign APIs to send a document for signature using C#.

When I called the API to send the document to its respective recipient, it just saved my document as a draft instead of directly sending my document to the recipient.

Is this the default behavior? Is there any way to send the document to recipient directly?

答:
Please confirm that your state value should be "IN_PROCESS" instead of "DRAFT".You can aslo concern with this documentation .

https://www.adobe.io/apis/documentcloud/sign/docs.html#!adobedocs/adobe-sign/master/api_usage/send_signing.md


问:
Create IPA: provisioning profile on pom.xml
I am using maven and gluon to create my IPA. I would like to know if it is possible to set the provisioning profile in pom.xml, without using xcode?

Sorry, I wanted to ask for a slightly different thing.
I have two provisionon profiles, one for production (to publish the app) and one for development (for tests and the mvn run).
From: developer.apple.com/account/resources/certificates, download and install the production provisioning and then the development provisioning. So both certificates are present in the ~ / Library / MobileDevice / Provisioning Profiles folder.
I run the mvn build and when I try to run the mvn run I have an error for the missing provisioning development.
Vicerverse if I download and install the provisiong dev first and then the production one, I repeat the build, this time the run works but the publication does not.
How can I manage both profiles without deleting the tests from the ~ / Library / MobileDevice / Provisioning Profiles each time and modifying the pom.xml?
Thanks a lot for your contribution

答:
If you check the Gluon Client plugin for Maven, you'll see some options that can be added to the plugin configuration.

Usually, the IDE helps finding out these options or you can check the code to find them.

To sign your iOS app, you can use:

```<code><plugin>
    <groupId>com.gluonhq</groupId>
    <artifactId>client-maven-plugin</artifactId>
    <version>0.1.15</version>
    <configuration>
        <mainClass>${mainClassName}</mainClass>
        ...
        <IOSSigningIdentity>iPhone Distribution: ***</IOSSigningIdentity>
        <IOSProvisioningProfile>*****</IOSProvisioningProfile>
   </configuration>
</plugin>
</code>```

Then, build the native image with

```<code>mvn client:link
</code>```

you can run:

```<code>mvn client:package
</code>```

to build the signed IPA.

Anyway, these plugin extensions should be explained in the plugin's readme )I filed an issue for that).

Body:
If you check the Gluon Client plugin for Maven, you'll see some options that can be added to the plugin configuration.

Usually, the IDE helps finding out these options or you can check the code to find them.

To sign your iOS app, you can use:

<plugin>
    <groupId>com.gluonhq</groupId>
    <artifactId>client-maven-plugin</artifactId>
    <version>0.1.15</version>
    <configuration>
        <mainClass>${mainClassName}</mainClass>
        ...
        <IOSSigningIdentity>iPhone Distribution: ***</IOSSigningIdentity>
        <IOSProvisioningProfile>*****</IOSProvisioningProfile>
   </configuration>
</plugin>

Then, build the native image with

mvn client:link

you can run:

mvn client:package

to build the signed IPA.

Anyway, these plugin extensions should be explained in the plugin's readme )I filed an issue for that).


问:
what does nodetool garbagecollect is actually doing
I'm trying to free some disk space in C*.

I've deleted many rows which created many tombstones.

I'm running nodetool garbagecollect and was wondering what this tool is doing behind the scens. I've read that it deletes the actual data that the tombstone is shadowing but not the tombstones (which will be cleared after gc_grace_seconds).
Is that accurate? the garbagecollect tool does not have any correlation with the gc_grace_seconds parameter?
How does the garbagecollect actually releases disk space?

there is not a lot of documentation on how this tool works and what it does.

any help will be much appreciated

答:
Deletion of data in Cassandra is always adding more data so you need be careful with that.

nodetool garbagecollect performs single-sstable compactions to remove overwritten or logically deleted data.  For each sstable, it will create a new sstable with unneeded data cleaned out. By default, garbagecollect removes rows or partitions that have been deleted or updated with newer data.  It may also remove deleted or updated cell values if the -g CELL option is specified, but this will require more resources (I/O CPU). This command may also remove expired tombstones (older than gc_grace_seconds), but not the fresh ones. Plus there are also other limitations on the removal of tombstones.

If the expired tombstones are still exist, then the only major compaction may help to evict them, for example, by running nodetool compact -s on the individual tables, but you need to make sure that you have enough space - the same size as a table itself.


问:
Avoiding Returning Wildcard Types
I have a class with a collection of Wildcard Types that is a singleton, something like:

```<code>public ObliviousClass{

    private static final ObliviousClass INSTANCE = new ObliviousClass();

    private Map<Key, Type<?>> map = new HashMap<Key, Type<?>>();

    public void putType(Key key, Type<?> type){
        map.put(type);
    }

    // returns the singleton
    public static ObliviousClass getInstance(){
        return INSTANCE;
    }

}
</code>```

I'd like to be able to add different Parameterized types to this collection in client code:

```<code>void clientMethod(){
    ObliviousClass oc = ObliviousClass.getInstance();

    Type<Integer> intType = ...
    Type<String> stringType = ...

    oc.putType(new Key(0), intType);
    oc.putType(new Key(1), stringType);
}
</code>```

Up to this point, as I understand it, everything is ok. But a client also needs to be able to get a Type<?> provided the Key. So a method something like the following would be added to ObliviousClass:

```<code>public Type<?> getType(Key key){
    return map.get(key);
}
</code>```

But in my handy copy of Effective Java, I read:

Do not use wildcard types as return types.

I understand the issue, as the client would have to cast the returned Type<?>. But I really do not want to make ObliviousClass a generic type, ObliviousClass<T>, because then my client code above would not work...

Is there a better design for what I am trying to do?
-My current solution is to provide a static method for the client; something along the lines of:

```<code>public static <T> void getType(ObliviousClass instance, Key key, Type<T> dest){
    dest = (Type<T>)instance.getType(key);
}
</code>```

I searched around, but wasn't able to find an answer that totally cleared my confusion.

答:
Your ObliviousClass, by design, doesn't know the parameterized type of the item it holds. So to be type safe, you should avoid such design :-\

But if you want to keep it, first things is that you will have to cast. There is no way out of this. But the way you do it is very error prone. For example:

```<code>oc.put(k1, intType);
oc.put(k2, strType);
Type<Integer> tint = oc.get(k1, Integer.class)
Type<String>  tstr = oc.get(k1, String.class)  // typo in k2: compile fine
</code>```

And worst, due to type erasure, it will fail at runtime only once you actually use tstr, not when you get it from ObliviousClass.

So you can improve safety by tracking the parameterized type in some other way. For example, you could associate the key to the type, not losing it:

```<code>@Value // lombok
class Key<T> {
    private int index;
}

class Type<T> {}

class ObliviousClass {

    // side note: static final can be public safely
    public static final ObliviousClass instance = new ObliviousClass();

    private List<Type<?>> map = new ArrayList<>();

    public <T> Key<T> appendType(Type<T> type){
        // here, I found it nicer that obliviousClass generates and return the key
        // otherwise use:  "public <T> void appendType(key<T> key, Type<T> type)"
        // that binds parametrized type of both key and type arguments
        map.add(type);
        return new Key<>(map.size() - 1);
    }

    public <T> Type<T> get(Key<T> key){
        return (Type<T>) map.get(key.index);
    }
}
</code>```

Then you can use it such as:

```<code>    Type<Integer> intType = new Type<>();
    Type<String>  strType = new Type<>();
    Key<Integer> k1 = ObliviousClass.instance.appendType(intType);
    Key<String>  k2 = ObliviousClass.instance.appendType(strType);

    Type<Integer> t1 = ObliviousClass.instance.get(k1);
    Type<String>  t2 = ObliviousClass.instance.get(k2);
    Type<String>  t3 = ObliviousClass.instance.get(k1); // won't compile
</code>```

Title: Avoiding Returning Wildcard Types

Body:
I have a class with a collection of Wildcard Types that is a singleton, something like:

public ObliviousClass{

    private static final ObliviousClass INSTANCE = new ObliviousClass();

    private Map<Key, Type<?>> map = new HashMap<Key, Type<?>>();

    public void putType(Key key, Type<?> type){
        map.put(type);
    }

    // returns the singleton
    public static ObliviousClass getInstance(){
        return INSTANCE;
    }

}

I'd like to be able to add different Parameterized types to this collection in client code:

void clientMethod(){
    ObliviousClass oc = ObliviousClass.getInstance();

    Type<Integer> intType = ...
    Type<String> stringType = ...

    oc.putType(new Key(0), intType);
    oc.putType(new Key(1), stringType);
}

Up to this point, as I understand it, everything is ok. But a client also needs to be able to get a Type<?> provided the Key. So a method something like the following would be added to ObliviousClass:

public Type<?> getType(Key key){
    return map.get(key);
}

But in my handy copy of Effective Java, I read:

Do not use wildcard types as return types.

I understand the issue, as the client would have to cast the returned Type<?>. But I really do not want to make ObliviousClass a generic type, ObliviousClass<T>, because then my client code above would not work...

Is there a better design for what I am trying to do?
-My current solution is to provide a static method for the client; something along the lines of:

public static <T> void getType(ObliviousClass instance, Key key, Type<T> dest){
    dest = (Type<T>)instance.getType(key);
}

I searched around, but wasn't able to find an answer that totally cleared my confusion.

Body:
Your ObliviousClass, by design, doesn't know the parameterized type of the item it holds. So to be type safe, you should avoid such design :-\

But if you want to keep it, first things is that you will have to cast. There is no way out of this. But the way you do it is very error prone. For example:

oc.put(k1, intType);
oc.put(k2, strType);
Type<Integer> tint = oc.get(k1, Integer.class)
Type<String>  tstr = oc.get(k1, String.class)  // typo in k2: compile fine

And worst, due to type erasure, it will fail at runtime only once you actually use tstr, not when you get it from ObliviousClass.

So you can improve safety by tracking the parameterized type in some other way. For example, you could associate the key to the type, not losing it:

@Value // lombok
class Key<T> {
    private int index;
}

class Type<T> {}

class ObliviousClass {

    // side note: static final can be public safely
    public static final ObliviousClass instance = new ObliviousClass();

    private List<Type<?>> map = new ArrayList<>();

    public <T> Key<T> appendType(Type<T> type){
        // here, I found it nicer that obliviousClass generates and return the key
        // otherwise use:  "public <T> void appendType(key<T> key, Type<T> type)"
        // that binds parametrized type of both key and type arguments
        map.add(type);
        return new Key<>(map.size() - 1);
    }

    public <T> Type<T> get(Key<T> key){
        return (Type<T>) map.get(key.index);
    }
}

Then you can use it such as:

    Type<Integer> intType = new Type<>();
    Type<String>  strType = new Type<>();
    Key<Integer> k1 = ObliviousClass.instance.appendType(intType);
    Key<String>  k2 = ObliviousClass.instance.appendType(strType);

    Type<Integer> t1 = ObliviousClass.instance.get(k1);
    Type<String>  t2 = ObliviousClass.instance.get(k2);
    Type<String>  t3 = ObliviousClass.instance.get(k1); // won't compile