问:
Navbar disappears after scrollIntoView() use on mobile view
Problem: NavBar disappears after scrollIntoView() used on mobile view.

Related JS

```<code>function disableScroll() {
  window.addEventListener('DOMMouseScroll', preventDefault, false); // older FF
  window.addEventListener(wheelEvent, preventDefault, wheelOpt); // modern desktop
  window.addEventListener('touchmove', preventDefault, wheelOpt); // mobile
  window.addEventListener('keydown', preventDefaultForScrollKeys, false);
}

function enableScroll() {
  window.removeEventListener('DOMMouseScroll', preventDefault, false);
  window.removeEventListener(wheelEvent, preventDefault, wheelOpt);
  window.removeEventListener('touchmove', preventDefault, wheelOpt);
  window.removeEventListener('keydown', preventDefaultForScrollKeys, false);
}

function scroll_to_chapters() {
    const chapters = document.getElementsByClassName("chapter_list")[0];
    if (nav.classList.contains("nav-active")) {
        navLinks.forEach((link) => {
            if (link.style.animation) {
                link.style.animation = '';
            }
        });
        enableScroll();
        burger.classList.toggle('toggle');
        nav.classList.toggle('nav-active');
    }
    chapters.scrollIntoView({ block: 'start',  behavior: 'smooth' })
}

const navSlide = ()=> {
    burger.addEventListener('click', ()=> {
        //Toggle NavBar
        nav.classList.toggle('nav-active');
        //Animate Links
        navLinks.forEach((link, index)=> {
            if (link.style.animation) {
                enableScroll();
                link.style.animation = '';
            }
            else {
                disableScroll();
                link.style.animation = `navLinkFade 0.5s ease forwards ${index / 7 + 0.5}s`;
            }
        });
        burger.classList.toggle('toggle');
    });
}
</code>```

I'm not quite sure but there might be a problem with the disabling and enabling scrolling. I didn't want mobile users to be able to scroll while the navbar menus are opened.

Navbar HTML

```<code><div class="wrapper">
    <div class="fix">
        <header>
            <div class="container">
                <nav>
                <a href="/" data-attr="img"><img src="{% static 'img/northernlogo.png' %}" class="logo" alt="logo"></a>
                <ul class="nav-links">
                    <li><a href="/">Home</a></li>
                    <li><a href="/" onclick="scroll_to_chapters();return false;">Chapters</a></li>
                    <li><a href="/about">About</a></li>
                    <li><a href="/links">Links</a></li>
                </ul>
                <div class="burger">
                    <div class="line1"></div>
                    <div class="line2"></div>
                    <div class="line3"></div>
                </div>
                </nav>
            </div>
        </header>
    </div>
</div>
</code>```

Related CSS

```<code>.container {
    width: 100%;
    margin: 0 0;
}

.container::after {
    content: '';
    display: grid;
    clear: both;
}

.burger {
    display: none;
    margin-top: 20px;
    cursor: pointer;
}

.burger div {
    width: 25px;
    height: 3px;
    background: #EEEEEE;
    margin: 5px;
    transition: all 0.3s ease;
}

@media only screen and (max-width: 800px) {
    .wrapper {
        overflow: hidden;
        position: relative;
    }
    .nav-links {
        -webkit-box-shadow: inset 0 0.5em 1.5em -0.5em black;
        position: absolute;
        right: 0;
        height: 100%;
        top: 70px;
        background-color: #3a345c;
        z-index: 99;
        display: flex;
        flex-direction: column;
        align-items: center;
        width: 100%;
        transform: translateX(100%);
        transition: transform 0.5s ease-in;
    }
    .nav-links li {
        opacity: 0;
        padding-bottom: 50px;
        padding-top: 50px;
    }

    .nav-links li a {
        font-size: 20px;
        font-weight: bold;
    }

    .burger {
        display: block;
    }
}
</code>```

Picture of the Error

Before
After

How to Reproduce

Open the website on mobile view. Open the navbar from the home menu and click chapters. It'll take you to the chapters but now the navbar is gone.

Editor's note:

The accepted answer features a self-contained reproducible example.

答:
This happens because .nav-links are position: absolute with:

a position: static (by default) parent .fix, and

a position: relative grandparent .wrapper.

In this case, scrollIntoView({block: 'start', ...}) scrolls .fix out of view of .wrapper before scrolling .wrapper itself.

{block: 'center', ...} does the same.

{block: 'end', ...} and {block: 'nearest', ...} don't.

You can't scroll .fix back into view because .wrapper has overflow: hidden.

Solution

Make .fix have position: relative and make .nav-links have height: 100vh.

.fix {
  position: relative;
}
.nav-links {
  height: 100vh;
}
```
<p>Run this code snippet to reproduce the problem, and click on the toggle to try with answer:</p>
<p><div class="snippet" data-lang="js" data-hide="true" data-console="true" data-babel="false">
<div class="snippet-code snippet-currently-hidden">
<pre class="snippet-code-js lang-js prettyprint-override"><code>const burger = document.querySelector('.burger');
const nav = document.querySelector('.nav-links');
const navLinks = document.querySelectorAll('.nav-links li');

// left: 37, up: 38, right: 39, down: 40,
// spacebar: 32, pageup: 33, pagedown: 34, end: 35, home: 36
var keys = {
  37: 1,
  38: 1,
  39: 1,
  40: 1
};

function preventDefault(e) {
  e.preventDefault();
}

function preventDefaultForScrollKeys(e) {
  if (keys[e.keyCode]) {
    preventDefault(e);
    return false;
  }
}

// modern Chrome requires { passive: false } when adding event
var supportsPassive = false;
try {
  window.addEventListener("test", null, Object.defineProperty({}, 'passive', {
    get: function() {
      supportsPassive = true;
    }
  }));
} catch (e) {}

var wheelOpt = supportsPassive ? {
  passive: false
} : false;
var wheelEvent = 'onwheel' in document.createElement('div') ? 'wheel' : 'mousewheel';

// call this to Disable
function disableScroll() {
  window.addEventListener('DOMMouseScroll', preventDefault, false); // older FF
  window.addEventListener(wheelEvent, preventDefault, wheelOpt); // modern desktop
  window.addEventListener('touchmove', preventDefault, wheelOpt); // mobile
  window.addEventListener('keydown', preventDefaultForScrollKeys, false);
}

// call this to Enable
function enableScroll() {
  window.removeEventListener('DOMMouseScroll', preventDefault, false);
  window.removeEventListener(wheelEvent, preventDefault, wheelOpt);
  window.removeEventListener('touchmove', preventDefault, wheelOpt);
  window.removeEventListener('keydown', preventDefaultForScrollKeys, false);
}

function read_more_less(button) {
  var x = $('#more');
  $(button).find('i').remove();
  if ($(button).text().trim() === 'Read more') {
    $(button).html($('<i/>', {
      class: 'fas fa-sort-down'
    })).append(' Read less');
    x.fadeIn();
  } else {
    $(button).html($('<i/>', {
      class: 'fas fa-sort-up'
    })).append(' Read more');
    x.fadeOut();
  }
}

function scroll_to_chapters() {
  const chapters = document.getElementsByClassName("chapter_list")[0];
  if (nav.classList.contains("nav-active")) {
    navLinks.forEach((link) => {
      if (link.style.animation) {
        link.style.animation = '';
      }
    });
    enableScroll();
    burger.classList.toggle('toggle');
    nav.classList.toggle('nav-active');
  }
  chapters.scrollIntoView({
    block: 'start',
    behavior: 'smooth'
  })
}

const navSlide = () => {
  burger.addEventListener('click', () => {
    //Toggle NavBar
    nav.classList.toggle('nav-active');
    //Animate Links
    navLinks.forEach((link, index) => {
      if (link.style.animation) {
        enableScroll();
        link.style.animation = '';
      } else {
        disableScroll();
        link.style.animation = `navLinkFade 0.5s ease forwards ${index / 7 + 0.5}s`;
      }
    });
    burger.classList.toggle('toggle');
  });
}
navSlide();

function toggleAnswer(button) {
  var wrapper = document.querySelector('.wrapper');
  wrapper.classList.toggle('answer');
  button.innerHTML = wrapper.classList.contains('answer') ? 'Click to try without answer' : 'Click to try with answer';
}</code>```

body {
  margin: 0;
  background: #212121;
  font-family: 'Glory', serif !important;
}

.container {
  width: 100%;
  margin: 0 0;
}

.container::after {
  content: '';
  display: grid;
  clear: both;
}

.burger {
  display: none;
  margin-top: 20px;
  cursor: pointer;
}

.burger div {
  width: 25px;
  height: 3px;
  background: #EEEEEE;
  margin: 5px;
  transition: all 0.3s ease;
}

header {
  background: #3a345c;
}

nav {
  justify-content: space-around;
  display: flex;
}

nav ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

nav a:not([data-attr="img"]) {
  color: #eeeeee;
  text-decoration: none;
  text-transform: uppercase;
  font-size: 15px;
}

@media only screen and (max-width: 800px) {
  .wrapper {
    overflow: hidden;
    position: relative;
  }
  .nav-links {
    -webkit-box-shadow: inset 0 0.5em 1.5em -0.5em black;
    position: absolute;
    right: 0;
    height: 100%;
    top: 70px;
    background-color: #3a345c;
    z-index: 99;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    transform: translateX(100%);
    transition: transform 0.5s ease-in;
  }
  .nav-links li {
    opacity: 0;
    padding-bottom: 50px;
    padding-top: 50px;
  }
  .nav-links li a {
    font-size: 20px;
    font-weight: bold;
  }
  .burger {
    display: block;
  }
}

.nav-active {
  transform: translateX(0%);
}

@keyframes navLinkFade {
  from {
    opacity: 0;
    transform: translateX(50px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Work within Stack Snippets window height */

.nav-links li {
  padding: 10px;
}

/* Answer */

.answer .fix {
  position: relative;
}

.answer .nav-links {
  height: 100vh;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><html>

<head>
</head>

<body>
  <div class="wrapper">
    <div class="fix">
      <header>
        <div class="container">
          <nav>

            <ul class="nav-links">
              <li>Home</li>
              <li>Chapters</li>
              <li>About</li>
              <li>Links</li>
            </ul>
            <div class="burger">
              <div class="line1"></div>
              <div class="line2"></div>
              <div class="line3"></div>
            </div>
          </nav>
        </div>
      </header>
    </div>
    <button onclick="toggleAnswer(this);">Click to try with answer</button>
    <div style="height: 500px;">
    </div>
    <div class="chapter_list">
      <h2 style="color: white; padding-left: 10px;">Chapter list</h2>
    </div>
  </div>
</body>

</html></code>```

Body:
Problem: NavBar disappears after scrollIntoView() used on mobile view.

Related JS

function disableScroll() {
  window.addEventListener('DOMMouseScroll', preventDefault, false); // older FF
  window.addEventListener(wheelEvent, preventDefault, wheelOpt); // modern desktop
  window.addEventListener('touchmove', preventDefault, wheelOpt); // mobile
  window.addEventListener('keydown', preventDefaultForScrollKeys, false);
}

function enableScroll() {
  window.removeEventListener('DOMMouseScroll', preventDefault, false);
  window.removeEventListener(wheelEvent, preventDefault, wheelOpt);
  window.removeEventListener('touchmove', preventDefault, wheelOpt);
  window.removeEventListener('keydown', preventDefaultForScrollKeys, false);
}

function scroll_to_chapters() {
    const chapters = document.getElementsByClassName("chapter_list")[0];
    if (nav.classList.contains("nav-active")) {
        navLinks.forEach((link) => {
            if (link.style.animation) {
                link.style.animation = '';
            }
        });
        enableScroll();
        burger.classList.toggle('toggle');
        nav.classList.toggle('nav-active');
    }
    chapters.scrollIntoView({ block: 'start',  behavior: 'smooth' })
}

const navSlide = ()=> {
    burger.addEventListener('click', ()=> {
        //Toggle NavBar
        nav.classList.toggle('nav-active');
        //Animate Links
        navLinks.forEach((link, index)=> {
            if (link.style.animation) {
                enableScroll();
                link.style.animation = '';
            }
            else {
                disableScroll();
                link.style.animation = `navLinkFade 0.5s ease forwards ${index / 7 + 0.5}s`;
            }
        });
        burger.classList.toggle('toggle');
    });
}

I'm not quite sure but there might be a problem with the disabling and enabling scrolling. I didn't want mobile users to be able to scroll while the navbar menus are opened.

Navbar HTML

Home

Chapters

About

Links

Related CSS

.container {
    width: 100%;
    margin: 0 0;
}

.container::after {
    content: '';
    display: grid;
    clear: both;
}

.burger {
    display: none;
    margin-top: 20px;
    cursor: pointer;
}

.burger div {
    width: 25px;
    height: 3px;
    background: #EEEEEE;
    margin: 5px;
    transition: all 0.3s ease;
}

@media only screen and (max-width: 800px) {
    .wrapper {
        overflow: hidden;
        position: relative;
    }
    .nav-links {
        -webkit-box-shadow: inset 0 0.5em 1.5em -0.5em black;
        position: absolute;
        right: 0;
        height: 100%;
        top: 70px;
        background-color: #3a345c;
        z-index: 99;
        display: flex;
        flex-direction: column;
        align-items: center;
        width: 100%;
        transform: translateX(100%);
        transition: transform 0.5s ease-in;
    }
    .nav-links li {
        opacity: 0;
        padding-bottom: 50px;
        padding-top: 50px;
    }

    .nav-links li a {
        font-size: 20px;
        font-weight: bold;
    }

    .burger {
        display: block;
    }
}

Picture of the Error

Before
After

How to Reproduce

Open the website on mobile view. Open the navbar from the home menu and click chapters. It'll take you to the chapters but now the navbar is gone.

Editor's note:

The accepted answer features a self-contained reproducible example.

Body:
This happens because .nav-links are position: absolute with:

a position: static (by default) parent .fix, and

a position: relative grandparent .wrapper.

In this case, scrollIntoView({block: 'start', ...}) scrolls .fix out of view of .wrapper before scrolling .wrapper itself.

{block: 'center', ...} does the same.

{block: 'end', ...} and {block: 'nearest', ...} don't.

You can't scroll .fix back into view because .wrapper has overflow: hidden.

Solution

Make .fix have position: relative and make .nav-links have height: 100vh.

.fix {
  position: relative;
}
.nav-links {
  height: 100vh;
}

Run this code snippet to reproduce the problem, and click on the toggle to try with answer:

const burger = document.querySelector('.burger');
const nav = document.querySelector('.nav-links');
const navLinks = document.querySelectorAll('.nav-links li');

// left: 37, up: 38, right: 39, down: 40,
// spacebar: 32, pageup: 33, pagedown: 34, end: 35, home: 36
var keys = {
  37: 1,
  38: 1,
  39: 1,
  40: 1
};

function preventDefault(e) {
  e.preventDefault();
}

function preventDefaultForScrollKeys(e) {
  if (keys[e.keyCode]) {
    preventDefault(e);
    return false;
  }
}

// modern Chrome requires { passive: false } when adding event
var supportsPassive = false;
try {
  window.addEventListener("test", null, Object.defineProperty({}, 'passive', {
    get: function() {
      supportsPassive = true;
    }
  }));
} catch (e) {}

var wheelOpt = supportsPassive ? {
  passive: false
} : false;
var wheelEvent = 'onwheel' in document.createElement('div') ? 'wheel' : 'mousewheel';

// call this to Disable
function disableScroll() {
  window.addEventListener('DOMMouseScroll', preventDefault, false); // older FF
  window.addEventListener(wheelEvent, preventDefault, wheelOpt); // modern desktop
  window.addEventListener('touchmove', preventDefault, wheelOpt); // mobile
  window.addEventListener('keydown', preventDefaultForScrollKeys, false);
}

// call this to Enable
function enableScroll() {
  window.removeEventListener('DOMMouseScroll', preventDefault, false);
  window.removeEventListener(wheelEvent, preventDefault, wheelOpt);
  window.removeEventListener('touchmove', preventDefault, wheelOpt);
  window.removeEventListener('keydown', preventDefaultForScrollKeys, false);
}

function read_more_less(button) {
  var x = $('#more');
  $(button).find('i').remove();
  if ($(button).text().trim() === 'Read more') {
    $(button).html($('<i/>', {
      class: 'fas fa-sort-down'
    })).append(' Read less');
    x.fadeIn();
  } else {
    $(button).html($('<i/>', {
      class: 'fas fa-sort-up'
    })).append(' Read more');
    x.fadeOut();
  }
}

function scroll_to_chapters() {
  const chapters = document.getElementsByClassName("chapter_list")[0];
  if (nav.classList.contains("nav-active")) {
    navLinks.forEach((link) => {
      if (link.style.animation) {
        link.style.animation = '';
      }
    });
    enableScroll();
    burger.classList.toggle('toggle');
    nav.classList.toggle('nav-active');
  }
  chapters.scrollIntoView({
    block: 'start',
    behavior: 'smooth'
  })
}

const navSlide = () => {
  burger.addEventListener('click', () => {
    //Toggle NavBar
    nav.classList.toggle('nav-active');
    //Animate Links
    navLinks.forEach((link, index) => {
      if (link.style.animation) {
        enableScroll();
        link.style.animation = '';
      } else {
        disableScroll();
        link.style.animation = `navLinkFade 0.5s ease forwards ${index / 7 + 0.5}s`;
      }
    });
    burger.classList.toggle('toggle');
  });
}
navSlide();

function toggleAnswer(button) {
  var wrapper = document.querySelector('.wrapper');
  wrapper.classList.toggle('answer');
  button.innerHTML = wrapper.classList.contains('answer') ? 'Click to try without answer' : 'Click to try with answer';
}

body {
  margin: 0;
  background: #212121;
  font-family: 'Glory', serif !important;
}

.container {
  width: 100%;
  margin: 0 0;
}

.container::after {
  content: '';
  display: grid;
  clear: both;
}

.burger {
  display: none;
  margin-top: 20px;
  cursor: pointer;
}

.burger div {
  width: 25px;
  height: 3px;
  background: #EEEEEE;
  margin: 5px;
  transition: all 0.3s ease;
}

header {
  background: #3a345c;
}

nav {
  justify-content: space-around;
  display: flex;
}

nav ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

nav a:not([data-attr="img"]) {
  color: #eeeeee;
  text-decoration: none;
  text-transform: uppercase;
  font-size: 15px;
}

@media only screen and (max-width: 800px) {
  .wrapper {
    overflow: hidden;
    position: relative;
  }
  .nav-links {
    -webkit-box-shadow: inset 0 0.5em 1.5em -0.5em black;
    position: absolute;
    right: 0;
    height: 100%;
    top: 70px;
    background-color: #3a345c;
    z-index: 99;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    transform: translateX(100%);
    transition: transform 0.5s ease-in;
  }
  .nav-links li {
    opacity: 0;
    padding-bottom: 50px;
    padding-top: 50px;
  }
  .nav-links li a {
    font-size: 20px;
    font-weight: bold;
  }
  .burger {
    display: block;
  }
}

.nav-active {
  transform: translateX(0%);
}

@keyframes navLinkFade {
  from {
    opacity: 0;
    transform: translateX(50px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Work within Stack Snippets window height */

.nav-links li {
  padding: 10px;
}

/* Answer */

.answer .fix {
  position: relative;
}

.answer .nav-links {
  height: 100vh;
}

<html>

<head>
</head>

<body>
  <div class="wrapper">
    <div class="fix">
      <header>
        <div class="container">
          <nav>
            <a style="height: 70px;"></a>
            <ul class="nav-links">
              <li><a href="/">Home</a></li>
              <li><a href="/" onclick="scroll_to_chapters();return false;">Chapters</a></li>
              <li><a href="/about">About</a></li>
              <li><a href="/links">Links</a></li>
            </ul>
            <div class="burger">
              <div class="line1"></div>
              <div class="line2"></div>
              <div class="line3"></div>
            </div>
          </nav>
        </div>
      </header>
    </div>
    <button onclick="toggleAnswer(this);">Click to try with answer</button>
    <div style="height: 500px;">
    </div>
    <div class="chapter_list">
      <h2 style="color: white; padding-left: 10px;">Chapter list</h2>
    </div>
  </div>
</body>

</html>


来源: stackexchange

问:
I have 4 nested ListViews where the outer one does not change view, while the currentIndex is changed QML
Following the answer in the link how to implement nested listmodels in qml  I have managed to make nested listviews with nested listmodels.
The project is a calendar and is consisting of 4 listviews, "year", "month", "day" and "hour".These listviews are connected with a Calendar{} so  I can get selected Date() and display it in the listviews.The problem is that the "day" and "month" are changing accordingly the selected Date() but "year" stays freezed.

Full code is in below link https://gist.github.com/cgiannakidis70/b95cfcf21376b5896967d9a00d8d3dbf

How can I make "year" listview  change view accordingly with the others  when i change the selected Date() in Calendar{}.
Any help will be  appreciated because I am stucked with it for days and I can not find the reason.

Thanks in advance.

答: The problem was currentIndex of year ListView.I had to express it like this: currentIndex:calendarMonth.selectedDate.getFullYear()-2022 .Now the ListView's are working perfectly.

ContentLicense: CC BY-SA 4.0


问:
How to transform HTML to Markdown using Nokogiri?
Is there any way to transform HTML into Markdown text?

HTML is pretty simple - it's just a div element with several
 elements inside.

There may be images - I want to preserve them as well.

Also, there may be several "inline" images like this one:  which is just a minus sign - I want to replace them with text.

Nokogiri::XML::Element#text is almost something that I want, but it strips off images.

答:
As @Konrads suggested, there is a duplicate entry here. However, the link which is given in the answer on that entry is broken.

I've googled a bit more and found that some forks survived: https://github.com/tomkrush/reverse-markdown, https://gist.github.com/788039.

If these forks become dead, just google for "reverse markdown". You will definitely find something that is alive and working.

ContentLicense: CC BY-SA 3.0


问:
get decimal number in solidity from external api with chainlink
I want to Get Price in Soldity from External api , I Using the Chainlink For this :

```<code>// SPDX-License-Identifier: GPL-3.0

pragma solidity >=0.7.0 <0.9.0;
import "https://github.com/smartcontractkit/chainlink/blob/develop/contracts/src/v0.8/ChainlinkClient.sol";

contract Fiat is ChainlinkClient {

    using Chainlink for Chainlink.Request;

    uint256 public price;

    bytes32 private jobId;
    uint256 private fee;

    constructor() {
        setPublicChainlinkToken();
        jobId = "83ba9ddc927946198fbd0bf1bd8a8c25";
        fee = 0.1 * 10 ** 18; // (Varies by network and job)
    }

    /**
     * Create a Chainlink request to retrieve API response, find the target price
     * data, then multiply by 100 (to remove decimal places from price).
     */
    function findExhangeRateFiatToBaseFiat(string memory _url
     , address _oracle) public returns (bytes32 requestId)
    {
        Chainlink.Request memory request = buildChainlinkRequest(jobId, address(this), this.fulfill.selector);

        // Set the URL to perform the GET request on
        // NOTE: If this oracle gets more than 5 requests from this job at a time, it will not return.
        request.add("get", _url);

        string[] memory path = new string[](2);
        path[0] = "Realtime Currency Exchange Rate";
        path[1] = "5. Exchange Rate";
        request.addStringArray("path", path);

        // Multiply the result by 10000000000 to remove decimals
        request.addInt("times", 10000000000);

        // Sends the request
        return sendChainlinkRequestTo(_oracle, request, fee);
    }

    /**
     * Receive the response in the form of uint256
     */
    function fulfill(bytes32 _requestId, uint256 _price) public recordChainlinkFulfillment(_requestId)
    {
        price = _price;
    }

}
</code>```

Now I Have a Problem :

When I Send Request to This Api :
https://www.alphavantage.co/query?function=CURRENCY_EXCHANGE_RATE&from_currency=IRR&to_currency=USD&apikey=K41HVINGOVEW3HHR

it Show me This Result :

```<code>{
    "Realtime Currency Exchange Rate": {
        "1. From_Currency Code": "IRR",
        "2. From_Currency Name": "Iranian Rial",
        "3. To_Currency Code": "USD",
        "4. To_Currency Name": "United States Dollar",
        "5. Exchange Rate": "0.00002381",
        "6. Last Refreshed": "2022-02-09 11:45:08",
        "7. Time Zone": "UTC",
        "8. Bid Price": "0.00002381",
        "9. Ask Price": "0.00002381"
    }
}
</code>```

and I want this Result: "5. Exchange Rate": "0.00002381"

but when I Call this Api and Call the price in Remix it shows me this Result 238100 Actually it should show me this result 0.00002381.

What's the Problem? how can I Get the Current Price?

Kovan Testnet
Oracle:0x58bbdbfb6fca3129b91f0dbe372098123b38b5e9
URL:https://www.alphavantage.co/query?function=CURRENCY_EXCHANGE_RATE&from_currency=IRR&to_currency=USD&apikey=K41HVINGOVEW3HHR

答: floats or doubles does not exist in solidity, so in order to convert it to a number it get rid of the decimals, i'm not really sure of how decimals are managed in this case but you could check that and then you can work in a similar way as you would work when dealing with eth, gwei, wei, also you should check how this line of code affects the response request.addInt("times", 10000000000); since it could help you to change the format of the response

Body:
I want to Get Price in Soldity from External api , I Using the Chainlink For this :

// SPDX-License-Identifier: GPL-3.0

pragma solidity >=0.7.0 <0.9.0;
import "https://github.com/smartcontractkit/chainlink/blob/develop/contracts/src/v0.8/ChainlinkClient.sol";

contract Fiat is ChainlinkClient {

    using Chainlink for Chainlink.Request;

    uint256 public price;

    bytes32 private jobId;
    uint256 private fee;

    constructor() {
        setPublicChainlinkToken();
        jobId = "83ba9ddc927946198fbd0bf1bd8a8c25";
        fee = 0.1 * 10 ** 18; // (Varies by network and job)
    }

    /**
     * Create a Chainlink request to retrieve API response, find the target price
     * data, then multiply by 100 (to remove decimal places from price).
     */
    function findExhangeRateFiatToBaseFiat(string memory _url
     , address _oracle) public returns (bytes32 requestId)
    {
        Chainlink.Request memory request = buildChainlinkRequest(jobId, address(this), this.fulfill.selector);

        // Set the URL to perform the GET request on
        // NOTE: If this oracle gets more than 5 requests from this job at a time, it will not return.
        request.add("get", _url);

        string[] memory path = new string[](2);
        path[0] = "Realtime Currency Exchange Rate";
        path[1] = "5. Exchange Rate";
        request.addStringArray("path", path);

        // Multiply the result by 10000000000 to remove decimals
        request.addInt("times", 10000000000);

        // Sends the request
        return sendChainlinkRequestTo(_oracle, request, fee);
    }

    /**
     * Receive the response in the form of uint256
     */
    function fulfill(bytes32 _requestId, uint256 _price) public recordChainlinkFulfillment(_requestId)
    {
        price = _price;
    }

}

Now I Have a Problem :

When I Send Request to This Api :
https://www.alphavantage.co/query?function=CURRENCY_EXCHANGE_RATE&from_currency=IRR&to_currency=USD&apikey=K41HVINGOVEW3HHR

it Show me This Result :

{
    "Realtime Currency Exchange Rate": {
        "1. From_Currency Code": "IRR",
        "2. From_Currency Name": "Iranian Rial",
        "3. To_Currency Code": "USD",
        "4. To_Currency Name": "United States Dollar",
        "5. Exchange Rate": "0.00002381",
        "6. Last Refreshed": "2022-02-09 11:45:08",
        "7. Time Zone": "UTC",
        "8. Bid Price": "0.00002381",
        "9. Ask Price": "0.00002381"
    }
}

and I want this Result: "5. Exchange Rate": "0.00002381"

but when I Call this Api and Call the price in Remix it shows me this Result 238100 Actually it should show me this result 0.00002381.

What's the Problem? how can I Get the Current Price?

Kovan Testnet
Oracle:0x58bbdbfb6fca3129b91f0dbe372098123b38b5e9
URL:https://www.alphavantage.co/query?function=CURRENCY_EXCHANGE_RATE&from_currency=IRR&to_currency=USD&apikey=K41HVINGOVEW3HHR


问:
Spring Boot /actuator returns 404 not found
I am using spring boot 2.1.4.RELEASE and currently trying to access http://localhost:8080/actuator but i am getting 404 not found. I am not sure what am i doing wrong here. Below is my pom dependencies-

```<code> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.dir</groupId>
    <artifactId>api</artifactId>
    <version>2.4.0</version>
    <packaging>jar</packaging>

    <name>Search</name>
    <description>Search</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.4.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

    <distributionManagement>
        <repository>
            <id>Releases</id>
            <name>repo1.releases</name>
            <url>http://www.something.com</url>
        </repository>
        <snapshotRepository>
            <id>Snapshots</id>
            <name>repo1.com</name>
            <url>http://repo1.com/artifactory/Snapshots</url>
        </snapshotRepository>
    </distributionManagement>

    <properties>
        <!--These two should be in all ParentPOMs -->
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <!-- Keep this version in sync with the pom's version ignoring "-SNAPSHOT" -->
        <applicationVersion>1.0.0</applicationVersion>
        <elasticsearch.version>5.2.0</elasticsearch.version>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-configuration-processor</artifactId>
            <optional>true</optional>
        </dependency>

        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger2</artifactId>
            <version>2.4.0</version>
        </dependency>

        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger-ui</artifactId>
            <version>2.4.0</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webflux</artifactId>
        </dependency>

        <dependency>
            <groupId>io.swagger</groupId>
            <artifactId>swagger-annotations</artifactId>
            <version>1.5.7</version>
        </dependency>

        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>2.8.0</version>
        </dependency>

        <dependency>
            <groupId>org.elasticsearch.client</groupId>
            <artifactId>x-pack-transport</artifactId>
            <version>5.2.1</version>
        </dependency>

        <dependency>
            <groupId>org.elasticsearch.client</groupId>
            <artifactId>transport</artifactId>
            <version>5.2.0</version>
        </dependency>

        <dependency>
            <groupId>org.elasticsearch</groupId>
            <artifactId>elasticsearch</artifactId>
            <version>5.2.0</version>
        </dependency>

        <dependency>
            <groupId>apache-lang</groupId>
            <artifactId>commons-lang</artifactId>
            <version>2.1</version>
        </dependency>

        <dependency>
            <groupId>io.jsonwebtoken</groupId>
            <artifactId>jjwt</artifactId>
            <version>0.7.0</version>
        </dependency>

        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
        </dependency>

        <!-- Spring boot actuator to expose metrics endpoint -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>

        <!-- Micormeter core dependecy  -->
        <dependency>
            <groupId>io.micrometer</groupId>
            <artifactId>micrometer-core</artifactId>
        </dependency>
        <!-- Micrometer Prometheus registry  -->
        <dependency>
            <groupId>io.micrometer</groupId>
            <artifactId>micrometer-registry-prometheus</artifactId>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-deploy-plugin</artifactId>
                <version>2.8.2</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <environmentVariables>
                        <version>9.9.9</version>
                        <basePath>http://sample-basepath.com</basePath>

                    </environmentVariables>
                </configuration>
            </plugin>
        </plugins>

        <resources>
            <resource>
                <directory>src/main/resources</directory>
            </resource>
        </resources>

    </build>

</project>
</code>```

properties file config

```<code>management.endpoint.metrics.enabled=true
management.endpoints.web.exposure.include=*
management.endpoint.prometheus.enabled=true
management.metrics.export.prometheus.enabled=true
management.endpoint.health.show-details=always
management.endpoint.beans.enabled=true
</code>```

when i run the application i do see this in console

```<code>2019-04-27 00:04:25.406  INFO 32522 --- [           main] o.s.b.a.e.web.EndpointLinksResolver      : Exposing 16 endpoint(s) beneath base path '/actuator'
2019-04-27 00:04:25.534  INFO 32522 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path '/myendpoint'
</code>```

答:
I had a similar problem, but my issue was that the following application property was set in my project:

```<code>management:
  endpoints:
    web:
      base-path: /
</code>```

Which meant that the actual endpoint for something like:
http://localhost:8080/actuator/beans

was in fact:
http://localhost:8080/beans

Body:
I am using spring boot 2.1.4.RELEASE and currently trying to access http://localhost:8080/actuator but i am getting 404 not found. I am not sure what am i doing wrong here. Below is my pom dependencies-

 <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.dir</groupId>
    <artifactId>api</artifactId>
    <version>2.4.0</version>
    <packaging>jar</packaging>

    <name>Search</name>
    <description>Search</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.4.RELEASE</version>
        <relativePath/>
    </parent>

    <distributionManagement>
        <repository>
            <id>Releases</id>
            <name>repo1.releases</name>
            <url>http://www.something.com</url>
        </repository>
        <snapshotRepository>
            <id>Snapshots</id>
            <name>repo1.com</name>
            <url>http://repo1.com/artifactory/Snapshots</url>
        </snapshotRepository>
    </distributionManagement>

    <properties>

        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

        <applicationVersion>1.0.0</applicationVersion>
        <elasticsearch.version>5.2.0</elasticsearch.version>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-configuration-processor</artifactId>
            <optional>true</optional>
        </dependency>

        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger2</artifactId>
            <version>2.4.0</version>
        </dependency>

        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger-ui</artifactId>
            <version>2.4.0</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webflux</artifactId>
        </dependency>

        <dependency>
            <groupId>io.swagger</groupId>
            <artifactId>swagger-annotations</artifactId>
            <version>1.5.7</version>
        </dependency>

        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>2.8.0</version>
        </dependency>

        <dependency>
            <groupId>org.elasticsearch.client</groupId>
            <artifactId>x-pack-transport</artifactId>
            <version>5.2.1</version>
        </dependency>

        <dependency>
            <groupId>org.elasticsearch.client</groupId>
            <artifactId>transport</artifactId>
            <version>5.2.0</version>
        </dependency>

        <dependency>
            <groupId>org.elasticsearch</groupId>
            <artifactId>elasticsearch</artifactId>
            <version>5.2.0</version>
        </dependency>

        <dependency>
            <groupId>apache-lang</groupId>
            <artifactId>commons-lang</artifactId>
            <version>2.1</version>
        </dependency>

        <dependency>
            <groupId>io.jsonwebtoken</groupId>
            <artifactId>jjwt</artifactId>
            <version>0.7.0</version>
        </dependency>

        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>

        <dependency>
            <groupId>io.micrometer</groupId>
            <artifactId>micrometer-core</artifactId>
        </dependency>

        <dependency>
            <groupId>io.micrometer</groupId>
            <artifactId>micrometer-registry-prometheus</artifactId>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-deploy-plugin</artifactId>
                <version>2.8.2</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <environmentVariables>
                        <version>9.9.9</version>
                        <basePath>http://sample-basepath.com</basePath>

                    </environmentVariables>
                </configuration>
            </plugin>
        </plugins>

        <resources>
            <resource>
                <directory>src/main/resources</directory>
            </resource>
        </resources>

    </build>

</project>

properties file config

management.endpoint.metrics.enabled=true
management.endpoints.web.exposure.include=*
management.endpoint.prometheus.enabled=true
management.metrics.export.prometheus.enabled=true
management.endpoint.health.show-details=always
management.endpoint.beans.enabled=true

when i run the application i do see this in console

2019-04-27 00:04:25.406  INFO 32522 --- [           main] o.s.b.a.e.web.EndpointLinksResolver      : Exposing 16 endpoint(s) beneath base path '/actuator'
2019-04-27 00:04:25.534  INFO 32522 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path '/myendpoint'

Body:
I had a similar problem, but my issue was that the following application property was set in my project:

management:
  endpoints:
    web:
      base-path: /

Which meant that the actual endpoint for something like:
http://localhost:8080/actuator/beans

was in fact:
http://localhost:8080/beans


问:
How do I pass a variable by reference?
Are parameters passed by reference or by value? How do I pass by reference so that the code below outputs 'Changed' instead of 'Original'?

```<code>class PassByReference:
    def __init__(self):
        self.variable = 'Original'
        self.change(self.variable)
        print(self.variable)

    def change(self, var):
        var = 'Changed'
</code>```

See also: Why can a function modify some arguments as perceived by the caller, but not others?

答:
Python assigns a unique identifier to each object and this identifier can be found by using Python's built-in id() function.
It is ready to verify that actual and formal arguments in a function call have the same id value, which indicates that the dummy argument and actual argument refer to the same object.

Note that the actual argument and the corresponding dummy argument are two names referring to the same object. If you re-bind a dummy argument to a new value/object in the function scope, this does not effect the fact that the actual argument still points to the original object because actual argument and dummy argument are two names.

The above two facts can be summarized as “arguments are passed by assignment”. i.e.,

```<code>dummy_argument = actual_argument
</code>```

If you re-bind dummy_argument to a new object in the function body, the actual_argument still refers to the original object. If you use dummy_argument[0] = some_thing, then this will also modify actual_argument[0]. Therefore the effect of “pass by reference” can be achieved by modifying the components/attributes of the object reference passed in. Of course, this requires that the object passed is a mutable object.

To make comparison with other languages, you can say Python passes arguments by value in the same way as C does, where when you pass "by reference" you are actually passing by value the reference (i.e., the pointer)

Title: How do I pass a variable by reference?

Body:
Are parameters passed by reference or by value? How do I pass by reference so that the code below outputs 'Changed' instead of 'Original'?

class PassByReference:
    def __init__(self):
        self.variable = 'Original'
        self.change(self.variable)
        print(self.variable)

    def change(self, var):
        var = 'Changed'

See also: Why can a function modify some arguments as perceived by the caller, but not others?

Body:
Python assigns a unique identifier to each object and this identifier can be found by using Python's built-in id() function.
It is ready to verify that actual and formal arguments in a function call have the same id value, which indicates that the dummy argument and actual argument refer to the same object.

Note that the actual argument and the corresponding dummy argument are two names referring to the same object. If you re-bind a dummy argument to a new value/object in the function scope, this does not effect the fact that the actual argument still points to the original object because actual argument and dummy argument are two names.

The above two facts can be summarized as “arguments are passed by assignment”. i.e.,

dummy_argument = actual_argument

If you re-bind dummy_argument to a new object in the function body, the actual_argument still refers to the original object. If you use dummy_argument[0] = some_thing, then this will also modify actual_argument[0]. Therefore the effect of “pass by reference” can be achieved by modifying the components/attributes of the object reference passed in. Of course, this requires that the object passed is a mutable object.

To make comparison with other languages, you can say Python passes arguments by value in the same way as C does, where when you pass "by reference" you are actually passing by value the reference (i.e., the pointer)


问:
Kibana visualize use wild card in search bar
Is it possible to use wild card in Kibana visualize search bar.

Tried to use it like below, but did not work.

```<code>operation: "Revers" NOT file:"*Test.Revers"
</code>```

This returns 2 because there are two Revers terms ("Revers", "/test/count/Test.Revers" ) even though only one data entry is in the stats data.

The following also returns the same value as 2.

```<code>operation: "Revers"
</code>```

Stat data sample is as below.

```<code>"_source": {
  "status": 0,
  "trstime": 1819,
  "username": "test",
  "operation": "Revers",
  "file": "/test/count/Test.Revers"
}
</code>```

答:
I have tested it in ES 7.10 as you not mentioned ES version.

Answer to your question is YES, you can use wildcrad in Kibana visualize search bar but value should be without double quotes. Because if you give value in doble quotes it will consider as text and search for it.

You can try below query and it will give you your expected output:

```<code>operation: Revers AND NOT file.keyword: *Test.Revers
</code>```

Body:
Is it possible to use wild card in Kibana visualize search bar.

Tried to use it like below, but did not work.

operation: "Revers" NOT file:"*Test.Revers"

This returns 2 because there are two Revers terms ("Revers", "/test/count/Test.Revers" ) even though only one data entry is in the stats data.

The following also returns the same value as 2.

operation: "Revers"

Stat data sample is as below.

"_source": {
  "status": 0,
  "trstime": 1819,
  "username": "test",
  "operation": "Revers",
  "file": "/test/count/Test.Revers"
}

Body:
I have tested it in ES 7.10 as you not mentioned ES version.

Answer to your question is YES, you can use wildcrad in Kibana visualize search bar but value should be without double quotes. Because if you give value in doble quotes it will consider as text and search for it.

You can try below query and it will give you your expected output:

operation: Revers AND NOT file.keyword: *Test.Revers


问:
How do I configure two different triggers for a project in CruiseControl.Net?
I would like to know if its possible to create two triggers, one on a filesystem and another for an svn checkout in the same config file.
I have tried out the following:

a) have put both the triggers and their respective filesystem, svn definitions along with tasks in the same file,
Results in error: It says unused node deteted
eg:

```<code><trigggers>
<intervalTrigger seconds="100" buildCondition="ForceBuild"/>
<intervalTrigger seconds="300" buildCondition="IfModificationExists"/>
</triggers>

<sourcecontrol type="filesystem">
  <repositoryRoot>...</repositoryRoot>
</sourcecontrol>

<sourcecontrol type="svn">
 <trunkUrl>....</trunkUrl>
 <workingDirectory>...</workingDirectory>
 <executable>...\SVN.exe</executable>
 <username/>..<password/>
</sourcecontrol>

<tasks>
 <!-- To be carried out if either of the two triggers happen -->
</tasks>
</code>```

b) have created different scopes for each of the trigger bound with respective filesystem/svn and tasks, also ends up with unused node detected error.

```<code><cb:define first_trigger_and source _and_tasks>
 <triggers>
  <intervalTrigger seconds="300" buildCondition="ForceBuild"/>
 </triggers>
 <sourcecontrol type="filesystem">
   <repositoryRoot>...</repositoryRoot>
 </sourcecontrol>
 <tasks>
  <!--To be carried out when first trigger happens -->
 </tasks>
</cb:define>

<!-- And then I call the trigger this way -->
<cb:first_trigger_and source _and_tasks>
</code>```

Neither of those solution works.

答:
Multiple triggers can be specified inside the <triggers> block, but that is not why CruiseControl.Net is complaining when it's processing your configuration.

It seems to me that you want a single trigger, but two separate source control entries. The <triggers> entries specify when CruiseControl.Net should wake up and check the project state. You can't specify multiple <sourcecontrol> elements in a <project> block. To actually rebuild project on both (remote) svn changes and local filesystem changes, you should use <sourcecontrol type="multi"> with a standard trigger:

```<code><triggers>
  <intervalTrigger seconds="30" />
</triggers>

<sourcecontrol type="multi">
  <sourceControls>
    <filesystem>
      <repositoryRoot>...</repositoryRoot>
    </filesystem>
    <svn>
      <trunkUrl>....</trunkUrl>
      <workingDirectory>...</workingDirectory>
      <executable>...\SVN.exe</executable>
      <username/>..<password/>
    </svn>
  </sourceControls>
</sourcecontrol>

<tasks>
 <!-- To be executed if either of the two source control providers report changes -->
</tasks>
</code>```

Body:
I would like to know if its possible to create two triggers, one on a filesystem and another for an svn checkout in the same config file.
I have tried out the following:

a) have put both the triggers and their respective filesystem, svn definitions along with tasks in the same file,
Results in error: It says unused node deteted
eg:

<trigggers>
<intervalTrigger seconds="100" buildCondition="ForceBuild"/>
<intervalTrigger seconds="300" buildCondition="IfModificationExists"/>
</triggers>

<sourcecontrol type="filesystem">
  <repositoryRoot>...</repositoryRoot>
</sourcecontrol>

<sourcecontrol type="svn">
 <trunkUrl>....</trunkUrl>
 <workingDirectory>...</workingDirectory>
 <executable>...\SVN.exe</executable>
 <username/>..<password/>
</sourcecontrol>

<tasks>

</tasks>

b) have created different scopes for each of the trigger bound with respective filesystem/svn and tasks, also ends up with unused node detected error.

<cb:define first_trigger_and source _and_tasks>
 <triggers>
  <intervalTrigger seconds="300" buildCondition="ForceBuild"/>
 </triggers>
 <sourcecontrol type="filesystem">
   <repositoryRoot>...</repositoryRoot>
 </sourcecontrol>
 <tasks>

 </tasks>
</cb:define>

<cb:first_trigger_and source _and_tasks>

Neither of those solution works.

Body:
Multiple triggers can be specified inside the <triggers> block, but that is not why CruiseControl.Net is complaining when it's processing your configuration.

It seems to me that you want a single trigger, but two separate source control entries. The <triggers> entries specify when CruiseControl.Net should wake up and check the project state. You can't specify multiple <sourcecontrol> elements in a <project> block. To actually rebuild project on both (remote) svn changes and local filesystem changes, you should use <sourcecontrol type="multi"> with a standard trigger:

<triggers>
  <intervalTrigger seconds="30" />
</triggers>

<sourcecontrol type="multi">
  <sourceControls>
    <filesystem>
      <repositoryRoot>...</repositoryRoot>
    </filesystem>
    <svn>
      <trunkUrl>....</trunkUrl>
      <workingDirectory>...</workingDirectory>
      <executable>...\SVN.exe</executable>
      <username/>..<password/>
    </svn>
  </sourceControls>
</sourcecontrol>

<tasks>
 <!-- To be executed if either of the two source control providers report changes -->
</tasks>


问:
How to view and edit content controls in a docx file in c# winforms
Is there any component to allow end users edit "Content Controls" in a C# Windows Forms desktop application?

I have many complicated Word Documents which are ready for edit and can't create all of them on runtime.

I searched stackoverflow but didn't find anything

Thanks

答:
You may consider using the Open XML SDK if you deal only with open XML documents. See How to insert text into a content control with the Open XML SDK for more information.

A big plus is that SDK doesn't require Word installed on the system. Also such code can be used on the server-side without any issues. Be aware, Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when Office is run in this environment.

If you are building a solution that runs in a server-side context, you should try to use components that have been made safe for unattended execution. Or, you should try to find alternatives that allow at least part of the code to run client-side. If you use an Office application from a server-side solution, the application will lack many of the necessary capabilities to run successfully. Additionally, you will be taking risks with the stability of your overall solution. Read more about that in the Considerations for server-side Automation of Office article.


问:
Textipunt on the bottom doesn't avoid keyboard on iOS but on android does
I plan having that textinput on the bottom, and i want it to avoid the keyboard. On Android it avoids, but on iOS it doesn't, even though I'm using the <KeyboardAvoidingView>.

I'm placing it on the bottom with absolute position.

By the way, I'm using expo-cli

This is my return

```<code>return (

  <KeyboardAvoidingView
    behavior={Platform.OS === "ios" ? "positionx" : false}
    style={{ backgroundColor: "#fff", bottom: 0, position: "absolute", flex: 1 }}
  >

    <SafeAreaView style={styles.commentView}>
      <TextInput
         style={styles.commentInput}
         placeholder='Comentário'
      />
      <TouchableOpacity>
        <Text style={{ color: "#F5A962" }}>Publicar</Text>
      </TouchableOpacity>
    </SafeAreaView>

  </KeyboardAvoidingView>
)
</code>```

This is my stylesheet

```<code>commentInput: {
  height: 40,
  width: "80%",
  borderWidth: 1,
  borderRadius: 5,
  borderColor: "black",
  paddingStart: 10,
  marginEnd: "3.5%",
  backgroundColor: "#eee"
},
commentView: {
  flexDirection: "row",
  alignItems: "center",
  justifyContent: "center",
  backgroundColor: "#fff",
}
</code>```

Thanks in advance.

答: Yes, you can not solve it with the above code. You always will see the covered issue by the keyboard. it depends on the layout. If you are going to solve this problem, please feel free to create a google meeting(reactnativeseniordev@gmail.com). I will help your problem via a calling.</p>

Body:
I plan having that textinput on the bottom, and i want it to avoid the keyboard. On Android it avoids, but on iOS it doesn't, even though I'm using the <KeyboardAvoidingView>.

I'm placing it on the bottom with absolute position.

By the way, I'm using expo-cli

This is my return

return (

  <KeyboardAvoidingView
    behavior={Platform.OS === "ios" ? "positionx" : false}
    style={{ backgroundColor: "#fff", bottom: 0, position: "absolute", flex: 1 }}
  >

    <SafeAreaView style={styles.commentView}>
      <TextInput
         style={styles.commentInput}
         placeholder='Comentário'
      />
      <TouchableOpacity>
        <Text style={{ color: "#F5A962" }}>Publicar</Text>
      </TouchableOpacity>
    </SafeAreaView>

  </KeyboardAvoidingView>
)

This is my stylesheet

commentInput: {
  height: 40,
  width: "80%",
  borderWidth: 1,
  borderRadius: 5,
  borderColor: "black",
  paddingStart: 10,
  marginEnd: "3.5%",
  backgroundColor: "#eee"
},
commentView: {
  flexDirection: "row",
  alignItems: "center",
  justifyContent: "center",
  backgroundColor: "#fff",
}

Thanks in advance.


问:
Embedded BPMN editor needs a working download button with django
Currently I have a HTML Page which is embedding a BPMN Modeler via https://bpmn.io/.
They way it works is that I've an empty .bpmn file in my media directory and everytime I visit my page e.g. it loads the empty .bpmn file and the user is free to model his own diagram from there.

Now I'd like for the user to be able to download his .bpmn file which he created on the page.

I've never worked with JS and Django before. I don't really know how to pass my modified .bpmn diagram back to my django view downlad function.

Let me show the code I've so far, starting with the bpmn.io script which enables the user to work with the diagram(modeler.html):

```<code><link rel="stylesheet" href="https://unpkg.com/bpmn-js@8.0.0/dist/assets/diagram-js.css"/>
<link rel="stylesheet" href="https://unpkg.com/bpmn-js@8.0.0/dist/assets/bpmn-font/css/bpmn.css"/>

<script src="https://unpkg.com/bpmn-js@8.0.0/dist/bpmn-modeler.development.js"></script>
<script>
    function fetchDiagram(url) {
        return fetch(url).then(response => response.text());
    }

    var bpmnJS = new BpmnJS({
        container: '#canvas',
        width: '100%',
        height: '600px',
    });

    async function openDiagram() {
        const diagram = await fetchDiagram('static/bpmn/empty_bpmn.bpmn');
        try {
            await bpmnJS.importXML(diagram);
            viewer.get('canvas').zoom('fit-viewport');
        } catch (err) {

            console.error('something went wrong:', err);
        }
    }
    openDiagram();
</script>
</code>```

and the belonging view functions to this(views.py):

```<code>def modeler(request):
    return render(request, 'core/modeler.html')

def download_bpmn(request):

    response = HttpResponse(content_type='application/bpmn')
    response['Content-Disposition'] = 'attachment; filename="your_diagram.bpmn"'
    return response
</code>```

the download button(modeler.html):

```<code><div class="col-2">
    <a class="btn btn-primary" href="{% url 'download_bpmn' %}"> Download </a>
</div>
</code>```

TLDR:
Is there a way to pass my bpmn diagram back to django so I can create a view function which enables the user to download his diagram?

答:
I used ajax to do that. I send the XML to a view that creates and saves the document in a model that has a FileField, then you can provide the url of the document to the user.

AJAX:

```<code>async function exportDiagram() {
    const csrftoken = getCookie('csrftoken');
    try {
        var result = await bpmnModeler.saveXML({ format: true });
        $.ajax({
            type: 'POST',
            url: url,
            headers: {'X-CSRFToken': csrftoken},
            data: {'data' : result.xml},
            success: function(response){
            },
        })

    }
    catch (err) {
        console.error('Erro ao salvar BPMN 2.0', err);
    }
}
$('#save-button').click(exportDiagram);
</code>```

VIEW:

```<code>def modeler(request, pk):
    if request.method == "POST":
        content = request.POST.get('data')
        bpmn = Bpmn()
        bpmn.Filefield.save(f'{diagrama.titulo}.bpmn', ContentFile(content))
    return render(request, 'bpmn.html')
</code>```

Body:
Currently I have a HTML Page which is embedding a BPMN Modeler via https://bpmn.io/.
They way it works is that I've an empty .bpmn file in my media directory and everytime I visit my page e.g. it loads the empty .bpmn file and the user is free to model his own diagram from there.

Now I'd like for the user to be able to download his .bpmn file which he created on the page.

I've never worked with JS and Django before. I don't really know how to pass my modified .bpmn diagram back to my django view downlad function.

Let me show the code I've so far, starting with the bpmn.io script which enables the user to work with the diagram(modeler.html):

<link rel="stylesheet" href="https://unpkg.com/bpmn-js@8.0.0/dist/assets/diagram-js.css"/>
<link rel="stylesheet" href="https://unpkg.com/bpmn-js@8.0.0/dist/assets/bpmn-font/css/bpmn.css"/>

and the belonging view functions to this(views.py):

def modeler(request):
    return render(request, 'core/modeler.html')

def download_bpmn(request):

    response = HttpResponse(content_type='application/bpmn')
    response['Content-Disposition'] = 'attachment; filename="your_diagram.bpmn"'
    return response

the download button(modeler.html):

     Download

TLDR:
Is there a way to pass my bpmn diagram back to django so I can create a view function which enables the user to download his diagram?

Body:
I used ajax to do that. I send the XML to a view that creates and saves the document in a model that has a FileField, then you can provide the url of the document to the user.

AJAX:

async function exportDiagram() {
    const csrftoken = getCookie('csrftoken');
    try {
        var result = await bpmnModeler.saveXML({ format: true });
        $.ajax({
            type: 'POST',
            url: url,
            headers: {'X-CSRFToken': csrftoken},
            data: {'data' : result.xml},
            success: function(response){
            },
        })

    }
    catch (err) {
        console.error('Erro ao salvar BPMN 2.0', err);
    }
}
$('#save-button').click(exportDiagram);

VIEW:

def modeler(request, pk):
    if request.method == "POST":
        content = request.POST.get('data')
        bpmn = Bpmn()
        bpmn.Filefield.save(f'{diagrama.titulo}.bpmn', ContentFile(content))
    return render(request, 'bpmn.html')


问:
partition blocks of a 2D array with memcpy
I saw several questions on memcpy but none seem to answer my question
I want to copy a block of the array (left-up, then right-up, then left-bottom, right-bottom)
I tried for left up but can't get it to work...

(* Edit removed old code *)

```<code>initial matrix:
{{1,2,39,4},
 {4,5,6,4},
 {7,8,9,4},
 {10,12,30,40}
};
</code>```

I want to retrieve in this example a 2x2 matrix containing:

| 1 | 2 |

| 4 | 5 |

Any way to achieve this?

Edit: thanks to @Adrian Mole's comment, I now know 1 single memcpy can't handle this. Any idea on how to handle this in a generic way (that depends on the size of n)? I modified my code as follows:

```<code>void partition2 (int ** mat, int ** A, int sub_mtrx_size){
    int i,j, ioff, joff;
    // A TOP-lEFT only for now, worry about other blocks B,C,D later
    ioff= 0 * sub_mtrx_size;
    joff= 0 * sub_mtrx_size;
    printf( "%d %d\n" ,ioff,joff);
    for (i = 0; i < sub_mtrx_size; i++) {
        memcpy( A[i] , mat[i+ioff],sub_mtrx_size );

        for (j = 0; j < sub_mtrx_size; j++) {
            // A[i][j] =mat[i+ioff][j+joff];  // this works, but not with 1 single memcpy
            printf("%3d ", mat[i+ioff][j+joff]);
        }
        printf("\n");
    }

int main() {
const int n = 4;

int ** mat =  malloc(sizeof(int*) * n);
int ** C11 =  malloc(sizeof(int*) * n/2);
for (int k = 0; k < n; k++) {
    mat[k] =  malloc(sizeof(int) * n);
    if ( k < n/2){
        C11[k] =  malloc(sizeof(int) * (n/2));
    }

}
printf("aaaaaaaaaaaaaa\n");
init(mat,n,n);
// init puts {{1,2,39,4},{4,5,6,4},{7,8,9,4},{10,12,30,40}};
int sub_mtrx_size= n/2;
partition2(mat,C11,sub_mtrx_size );
for (int i = 0; i < n; i++)
    {
        // int* currentIntPtr = mat[i];
        free(mat[i]);
        if ( i < n/2){
            free(C11[i]);
        }
    }
    free (mat);
    free (C11);
return 0;
}
</code>```

with memcpy here I get the first column only...

Thanks

答:
I solved it:

here is a partition function that extracts 4 blocks (A,B,C,D) out of the initial matrix mat It is only tested and supposed to work for sizes of power 2.

```<code>void partition2 (int ** mat, int ** A,int ** B,int ** C,int ** D, int sub_mtrx_size){
    int i,j, ioff, joff;
    // A TOP-lEFT
    ioff= 0 * sub_mtrx_size;
    joff= 0 * sub_mtrx_size;
    for (i = 0; i < sub_mtrx_size; i++) {
        memcpy( A[i] , mat[i+ioff], sub_mtrx_size* sizeof(**A) );

    }

    // B Bottom-left
    ioff= 1 * sub_mtrx_size;
    joff= 0 * sub_mtrx_size;
    for (i = 0; i < sub_mtrx_size; i++) {
        memcpy( B[i] , mat[i+ioff], sub_mtrx_size* sizeof(**A) );
    }

    // C TOP-right
    ioff= 0 * sub_mtrx_size;
    joff= 1 * sub_mtrx_size;
    for (i = 0; i < sub_mtrx_size; i++) {
        for (j=0; j<sub_mtrx_size ; j++){
            C[i][j] = mat[i+ioff][j+joff];
        }

    }

    // D BOTTOM-RIGHT
    ioff= 1 * sub_mtrx_size;
    joff= 1 * sub_mtrx_size;
    for (i = 0; i < sub_mtrx_size; i++) {
        for (j=0; j<sub_mtrx_size ; j++){
            D[i][j] = mat[i+ioff][j+joff];
        }

    }

}
</code>```

Body:
I saw several questions on memcpy but none seem to answer my question
I want to copy a block of the array (left-up, then right-up, then left-bottom, right-bottom)
I tried for left up but can't get it to work...

(* Edit removed old code *)

initial matrix:
{{1,2,39,4},
 {4,5,6,4},
 {7,8,9,4},
 {10,12,30,40}
};

I want to retrieve in this example a 2x2 matrix containing:

| 1 | 2 |

| 4 | 5 |

Any way to achieve this?

Edit: thanks to @Adrian Mole's comment, I now know 1 single memcpy can't handle this. Any idea on how to handle this in a generic way (that depends on the size of n)? I modified my code as follows:

void partition2 (int ** mat, int ** A, int sub_mtrx_size){
    int i,j, ioff, joff;
    // A TOP-lEFT only for now, worry about other blocks B,C,D later
    ioff= 0 * sub_mtrx_size;
    joff= 0 * sub_mtrx_size;
    printf( "%d %d\n" ,ioff,joff);
    for (i = 0; i < sub_mtrx_size; i++) {
        memcpy( A[i] , mat[i+ioff],sub_mtrx_size );

        for (j = 0; j < sub_mtrx_size; j++) {
            // A[i][j] =mat[i+ioff][j+joff];  // this works, but not with 1 single memcpy
            printf("%3d ", mat[i+ioff][j+joff]);
        }
        printf("\n");
    }

int main() {
const int n = 4;

int ** mat =  malloc(sizeof(int*) * n);
int ** C11 =  malloc(sizeof(int*) * n/2);
for (int k = 0; k < n; k++) {
    mat[k] =  malloc(sizeof(int) * n);
    if ( k < n/2){
        C11[k] =  malloc(sizeof(int) * (n/2));
    }

}
printf("aaaaaaaaaaaaaa\n");
init(mat,n,n);
// init puts {{1,2,39,4},{4,5,6,4},{7,8,9,4},{10,12,30,40}};
int sub_mtrx_size= n/2;
partition2(mat,C11,sub_mtrx_size );
for (int i = 0; i < n; i++)
    {
        // int* currentIntPtr = mat[i];
        free(mat[i]);
        if ( i < n/2){
            free(C11[i]);
        }
    }
    free (mat);
    free (C11);
return 0;
}

with memcpy here I get the first column only...

Thanks

Body:
I solved it:

here is a partition function that extracts 4 blocks (A,B,C,D) out of the initial matrix mat It is only tested and supposed to work for sizes of power 2.

void partition2 (int ** mat, int ** A,int ** B,int ** C,int ** D, int sub_mtrx_size){
    int i,j, ioff, joff;
    // A TOP-lEFT
    ioff= 0 * sub_mtrx_size;
    joff= 0 * sub_mtrx_size;
    for (i = 0; i < sub_mtrx_size; i++) {
        memcpy( A[i] , mat[i+ioff], sub_mtrx_size* sizeof(**A) );

    }

    // B Bottom-left
    ioff= 1 * sub_mtrx_size;
    joff= 0 * sub_mtrx_size;
    for (i = 0; i < sub_mtrx_size; i++) {
        memcpy( B[i] , mat[i+ioff], sub_mtrx_size* sizeof(**A) );
    }

    // C TOP-right
    ioff= 0 * sub_mtrx_size;
    joff= 1 * sub_mtrx_size;
    for (i = 0; i < sub_mtrx_size; i++) {
        for (j=0; j<sub_mtrx_size ; j++){
            C[i][j] = mat[i+ioff][j+joff];
        }

    }

    // D BOTTOM-RIGHT
    ioff= 1 * sub_mtrx_size;
    joff= 1 * sub_mtrx_size;
    for (i = 0; i < sub_mtrx_size; i++) {
        for (j=0; j<sub_mtrx_size ; j++){
            D[i][j] = mat[i+ioff][j+joff];
        }

    }

}


问:
How to get highcharts dates in the x axis?
Is there a standard way to get dates on the x-axis for Highcharts?  Can't find it in their documentation: https://api.highcharts.com/highcharts/xAxis.type

When my time range is large enough, it shows dates.  However, when the time range isn't large enough, it just shows hours, like this:

This is less than ideal... if it could show a date and time in this case, that'd be great.  Anyone know how?

答:
Highcharts will automatically try to find the best format for the current zoom-range. This is done if the xAxis has the type 'datetime'. Next the unit of the current zoom is calculated, it could be one of:

second

minute

hour

day

week

month

year

This unit is then used find a format for the axis labels. The default patterns are:

```<code>second: '%H:%M:%S',
minute: '%H:%M',
hour: '%H:%M',
day: '%e. %b',
week: '%e. %b',
month: '%b \'%y',
year: '%Y'
</code>```

If you want the day to be part of the "hour"-level labels you should change the dateTimeLabelFormats option for that level include %d or %e.
These are the available patters:

%a: Short weekday, like 'Mon'.

%A: Long weekday, like 'Monday'.

%d: Two digit day of the month, 01 to 31.

%e: Day of the month, 1 through 31.

%b: Short month, like 'Jan'.

%B: Long month, like 'January'.

%m: Two digit month number, 01 through 12.

%y: Two digits year, like 09 for 2009.

%Y: Four digits year, like 2009.

%H: Two digits hours in 24h format, 00 through 23.

%I: Two digits hours in 12h format, 00 through 11.

%l (Lower case L): Hours in 12h format, 1 through 11.

%M: Two digits minutes, 00 through 59.

%p: Upper case AM or PM.

%P: Lower case AM or PM.

%S: Two digits seconds, 00 through 59

http://api.highcharts.com/highcharts#xAxis.dateTimeLabelFormats

Body:
Highcharts will automatically try to find the best format for the current zoom-range. This is done if the xAxis has the type 'datetime'. Next the unit of the current zoom is calculated, it could be one of:

second

minute

hour

day

week

month

year

This unit is then used find a format for the axis labels. The default patterns are:

second: '%H:%M:%S',
minute: '%H:%M',
hour: '%H:%M',
day: '%e. %b',
week: '%e. %b',
month: '%b \'%y',
year: '%Y'

If you want the day to be part of the "hour"-level labels you should change the dateTimeLabelFormats option for that level include %d or %e.
These are the available patters:

%a: Short weekday, like 'Mon'.

%A: Long weekday, like 'Monday'.

%d: Two digit day of the month, 01 to 31.

%e: Day of the month, 1 through 31.

%b: Short month, like 'Jan'.

%B: Long month, like 'January'.

%m: Two digit month number, 01 through 12.

%y: Two digits year, like 09 for 2009.

%Y: Four digits year, like 2009.

%H: Two digits hours in 24h format, 00 through 23.

%I: Two digits hours in 12h format, 00 through 11.

%l (Lower case L): Hours in 12h format, 1 through 11.

%M: Two digits minutes, 00 through 59.

%p: Upper case AM or PM.

%P: Lower case AM or PM.

%S: Two digits seconds, 00 through 59

http://api.highcharts.com/highcharts#xAxis.dateTimeLabelFormats