text:
Q: SVG  with xlink:href is not working in Edge I'm experiencing weird behavior in Edge that it doesn't call the <paths> defined in the same document. Though this only happens in my app but not on the style guide. Also, I wasn't thinking that this is a Edge problem since based from microsoft docs they are supporting xlink:href attribute.
Style Guide (viewed in Edge)

From here you can see that the svg icon is rendering just fine, though from the console(DOM Explorer) the <use> element is being used and referenced to each path by ID not external svg resources. Fiddle: https://jsfiddle.net/kfL7tbcf/
Web App (missing svg)

In the web app, when I tried to use the SVG, it is not getting the referenced  by  element. Fiddle: https://jsfiddle.net/kfL7tbcf/
Web App (svg without <use> element)

SVG displays okay without <use> element. Fiddle: https://jsfiddle.net/9uuLr9gd/
Any thoughts and help would be greatly appreciated. Thank you!

A: Use inline SVG to avoid the problem! Run the snippet in the Edge and you will be see the question mark. For reliability, you could add xmlns:xlink="http://www.w3.org/1999/xlink" namespace definition to the svg element.

<svg id="action-help" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" preserveAspectRatio="xMidYMid meet" >
<defs>
  <path id="qMark" d="M10 19h3v3h-3v-3m2-17c5.35.22 7.68 5.62 4.5 9.67-.83 1-2.17 1.66-2.83 2.5C13 15 13 16 13 17h-3c0-1.67 0-3.08.67-4.08.66-1 2-1.59 2.83-2.25C15.92 8.43 15.32 5.26 12 5a3 3 0 0 0-3 3H6a6 6 0 0 1 6-6z"></path>
</defs>
<use xlink:href="#qMark"/>
</svg>

For your case:

<svg id="dashboard-calculated-lp" viewBox="0 0 1093.82 512" width="100%" height="100%" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" preserveAspectRatio="xMidYMid meet" focusable="false">
  <defs>
    <path id="dashboard-calculated-lp_b" d="M188 0H0v88h188V0z"></path>
    <path id="dashboard-calculated-lp_c" d="M32 64c17.673 0 32-14.327 32-32C64 14.327 49.673 0 32 0 14.327 0 0 14.327 0 32c0 17.673 14.327 32 32 32z"></path>
    <path id="dashboard-calculated-lp_d" fill-rule="evenodd" d="M8.012 11.223C4.925 11.223 2.4 8.698 2.4 5.61 2.4 2.525 4.925.07 8.01 0c3.088 0 5.613 2.525 5.613 5.611 0 3.087-2.525 5.612-5.612 5.612zm9.336 9.745a2.297 2.297 0 0 0-2.295-2.295H2.296A2.297 2.297 0 0 0 0 20.968v16.67a2.297 2.297 0 0 0 2.296 2.295H5.02V54.87h7.11V39.933h2.921a2.297 2.297 0 0 0 2.296-2.295v-16.67z"></path>
    <path id="dashboard-calculated-lp_f" d="M8.012 0v-2h-.045l.045 2zm-2.99 39.933h2v-2h-2v2zm0 14.936h-2v2h2v-2zm7.108 0v2h2v-2h-2zm0-14.936v-2h-2v2h2zM.4 5.611c0 4.192 3.42 7.612 7.612 7.612v-4A3.627 3.627 0 0 1 4.4 5.61h-4zm7.567-7.61C3.851-1.909.401 1.38.401 5.61h4C4.4 3.67 5.998 2.045 8.056 2l-.089-4zm7.657 7.61C15.624 1.42 12.204-2 8.012-2v4a3.627 3.627 0 0 1 3.612 3.611h4zm-7.612 7.612c4.192 0 7.612-3.42 7.612-7.612h-4a3.627 3.627 0 0 1-3.612 3.612v4zm7.04 7.45c.163 0 .296.133.296.295h4a4.297 4.297 0 0 0-4.295-4.295v4zm-12.756 0h12.757v-4H2.296v4zM2 20.968c0-.162.133-.295.296-.295v-4A4.297 4.297 0 0 0-2 20.968h4zm0 16.67v-16.67h-4v16.67h4zm.296.295A.297.297 0 0 1 2 37.638h-4a4.297 4.297 0 0 0 4.296 4.295v-4zm2.725 0H2.296v4H5.02v-4zm2 16.936V39.933h-4V54.87h4zm5.11-2H5.02v4h7.11v-4zm-2-12.936V54.87h4V39.933h-4zm4.921-2H12.13v4h2.922v-4zm.296-.295a.297.297 0 0 1-.296.295v4a4.297 4.297 0 0 0 4.296-4.295h-4zm0-16.67v16.67h4v-16.67h-4z"></path>
    <path id="dashboard-calculated-lp_g" d="M0 0h54.26v48.696H0V0z"></path>
    <path id="dashboard-calculated-lp_i" fill-rule="evenodd" d="M5.39 9.352A4.667 4.667 0 0 1 .714 4.677C.714 2.089 2.872-.07 5.39.002a4.667 4.667 0 0 1 4.676 4.675A4.667 4.667 0 0 1 5.39 9.352zm-2.781 6.36h10.043v17.673H8.413v12.969H2.61V33.442H0s1.235-.665 1.707-1.254c.398-.498.902-2.007.902-2.007V15.713z"></path>
    <path id="dashboard-calculated-lp_j" fill-rule="evenodd" d="M12.152 15.586H3.74v1.923h8.48c.84 0 1.541.712 1.541 1.567v14.538c0 .853-.7 1.565-1.54 1.565H9.56v12.828h1.891V37.106h.7c1.893 0 3.437-1.566 3.437-3.492V19.08c0-1.928-1.54-3.494-3.436-3.494zM1.249 36.876h.767v11.131h1.725V34.914H1.247v1.962h.002zM0 6.546A6.53 6.53 0 0 1 6.547 0a6.53 6.53 0 0 1 6.547 6.546 6.529 6.529 0 0 1-6.547 6.547A6.524 6.524 0 0 1 0 6.546zm1.87.001a4.666 4.666 0 0 0 4.677 4.675 4.667 4.667 0 0 0 4.676-4.675 4.668 4.668 0 0 0-4.676-4.675C4.029 1.8 1.87 3.959 1.87 6.547z"></path>
    <path id="dashboard-calculated-lp_k" fill-rule="evenodd" d="M7.215 9.352a4.668 4.668 0 0 1-4.677-4.676A4.668 4.668 0 0 1 7.215 0a4.668 4.668 0 0 1 4.676 4.676 4.667 4.667 0 0 1-4.676 4.676zm2.828 6.36H0v17.673h4.174v12.968h5.804V33.442h2.61s-1.236-.665-1.708-1.254c-.312-.39-.688-1.4-.837-1.82V15.712z"></path>
    <path id="dashboard-calculated-lp_l" fill-rule="evenodd" d="M11.85 48.007h1.724V36.876h.767v-1.962h-2.494v13.093h.003zM1.822 33.614V19.078c0-.853.701-1.566 1.54-1.566h8.485v-1.926h-8.41C1.544 15.586 0 17.152 0 19.078v14.536c0 1.92 1.54 3.49 3.437 3.49h.7v10.903H6.03V35.183H3.437c-.914-.004-1.615-.717-1.615-1.57zm.672-27.068A6.53 6.53 0 0 1 9.04 0a6.53 6.53 0 0 1 6.546 6.546 6.529 6.529 0 0 1-6.546 6.547 6.525 6.525 0 0 1-6.547-6.547zm1.87 0a4.667 4.667 0 0 0 4.677 4.676 4.667 4.667 0 0 0 4.676-4.676A4.668 4.668 0 0 0 9.04 1.87a4.668 4.668 0 0 0-4.676 4.676z"></path>
    <path id="dashboard-calculated-lp_m" fill-rule="evenodd" d="M3.716 0C1.722 0 0 1.549 0 3.542v30.06c0 1.992 1.722 3.56 3.716 3.56H20.4c-.06 1.427-.222 2.694-.58 3.697-.436 1.219-1.058 2.006-2.149 2.497h-2.186a1.24 1.24 0 0 0 0 2.477H39.02a1.24 1.24 0 0 0 0-2.477h-2.187c-1.09-.49-1.713-1.278-2.148-2.497-.359-1.003-.52-2.27-.58-3.697h16.683c1.994 0 3.716-1.568 3.716-3.56V3.541C54.504 1.55 52.782 0 50.788 0H3.716z"></path>
    <path id="dashboard-calculated-lp_o" d="M20.4 37.162l1.998.084.089-2.084H20.4v2zm-.58 3.697l1.883.673-1.883-.673zm-2.149 2.497v2h.429l.391-.176-.82-1.824zm19.162 0l-.82 1.824.392.176h.428v-2zm-2.148-2.497l-1.884.673 1.883-.673zm-.58-3.697v-2h-2.087l.088 2.084 1.998-.084zM3.715-2C.744-2-2 .321-2 3.542h4C2 2.776 2.7 2 3.716 2v-4zM-2 3.542v30.06h4V3.541h-4zm0 30.06c0 3.206 2.73 5.56 5.716 5.56v-4C2.714 35.162 2 34.38 2 33.602h-4zm5.716 5.56H20.4v-4H3.716v4zm14.686-2.085c-.055 1.343-.169 2.314-.466 3.11l3.767 1.345c.42-1.21.63-2.775.695-4.285l-3.996-.17zm-.466 3.11c-.298.834-.603 1.128-1.085 1.345l1.64 3.648c1.7-.764 2.64-2.045 3.212-3.648l-3.767-1.346zm-.265 1.169h-2.186v4h2.186v-4zm-2.186 0a3.24 3.24 0 0 0-3.24 3.239h4a.76.76 0 0 1-.76.76v-4zm-3.24 3.239a3.24 3.24 0 0 0 3.24 3.238v-4c.42 0 .76.34.76.762h-4zm3.24 3.238H39.02v-4H15.484v4zm23.535 0a3.24 3.24 0 0 0 3.239-3.238h-4a.76.76 0 0 1 .76-.762v4zm3.239-3.238a3.24 3.24 0 0 0-3.24-3.24v4a.76.76 0 0 1-.76-.76h4zm-3.24-3.24h-2.186v4h2.187v-4zm-1.365.177c-.483-.217-.788-.51-1.086-1.346L32.8 41.532c.573 1.603 1.513 2.884 3.212 3.648l1.64-3.648zm-1.086-1.345c-.297-.796-.41-1.767-.465-3.11l-3.997.17c.066 1.51.275 3.074.695 4.285l3.767-1.345zm-2.464-1.025h16.684v-4H34.104v4zm16.684 0c2.986 0 5.716-2.354 5.716-5.56h-4c0 .779-.714 1.56-1.716 1.56v4zm5.716-5.56V3.541h-4v30.06h4zm0-30.06C56.504.322 53.76-2 50.788-2v4c1.016 0 1.716.776 1.716 1.542h4zM50.788-2H3.716v4h47.072v-4z"></path>
    <path id="dashboard-calculated-lp_p" d="M54.212 0H0v2.259h54.212V0z"></path>
    <path id="dashboard-calculated-lp_q" fill-rule="evenodd" d="M1.391 9.74h.005V2.236c0-.453.43-.85 1.096-.85h5.057a.694.694 0 0 0 .8-.688.695.695 0 0 0-.679-.696V0H1.097C.433 0 .001.398.001.85v8.845L0 9.742c0 .387.312.696.696.696a.694.694 0 0 0 .695-.696v-.003z"></path>
    <path id="dashboard-calculated-lp_r" d="M50.087 0H0v2.087h50.087V0z"></path>
    <path id="dashboard-calculated-lp_s" fill-rule="evenodd" d="M0 2.092C0 .936.93 0 2.088 0h32.694c1.153 0 2.088.934 2.088 2.092v23.642c0 1.156-.93 2.092-2.088 2.092H2.088A2.088 2.088 0 0 1 0 25.734V2.092z"></path>
    <path id="dashboard-calculated-lp_u" d="M2 2.092C2 2.034 2.041 2 2.088 2v-4A4.087 4.087 0 0 0-2 2.092h4zM2.088 2h32.694v-4H2.088v4zm32.694 0c.046 0 .088.036.088.092h4A4.088 4.088 0 0 0 34.782-2v4zm.088.092v23.642h4V2.092h-4zm0 23.642c0 .058-.042.092-.088.092v4a4.087 4.087 0 0 0 4.088-4.092h-4zm-.088.092H2.088v4h32.694v-4zm-32.694 0A.088.088 0 0 1 2 25.734h-4a4.088 4.088 0 0 0 4.088 4.092v-4zM2 25.734V2.092h-4v23.642h4z"></path>
    <path id="dashboard-calculated-lp_v" d="M32.696 0H0v2.087h32.696V0z"></path>
    <path id="dashboard-calculated-lp_w" d="M16.696 0H0v1.391h16.696V0z"></path>
    <path id="dashboard-calculated-lp_x" d="M13.913 0H0v1.391h13.913V0z"></path>
    <path id="dashboard-calculated-lp_y" d="M15.304 0H0v1.391h15.304V0z"></path>
    <path id="dashboard-calculated-lp_z" d="M1.391 0H0v20.174h1.391V0z"></path>
    <path id="dashboard-calculated-lp_A" d="M44 86.128c24.3 0 44-19.28 44-43.064S68.3 0 44 0 0 19.28 0 43.064c0 23.783 19.7 43.064 44 43.064z"></path>
    <path id="dashboard-calculated-lp_C" d="M85 43.064c0 22.066-18.295 40.064-41 40.064v6c25.896 0 47-20.563 47-46.064h-6zM44 83.128c-22.705 0-41-17.998-41-40.064h-6c0 25.5 21.104 46.064 47 46.064v-6zM3 43.064C3 20.998 21.295 3 44 3v-6C18.104-3-3 17.563-3 43.064h6zM44 3c22.705 0 41 17.998 41 40.064h6C91 17.563 69.896-3 44-3v6z"></path>
    <path id="dashboard-calculated-lp_D" fill-rule="evenodd" d="M5.737 0h45.915v63.66H6.437C2.882 63.66 0 59.507 0 54.369V5.579C0 2.5 2.562 0 5.737 0z"></path>
    <path id="dashboard-calculated-lp_F" d="M51.652 0h2.5v-2.5h-2.5V0zm0 63.66v2.5h2.5v-2.5h-2.5zM5.737 2.5h45.915v-5H5.737v5zM49.152 0v63.66h5V0h-5zm2.5 61.16H6.437v5h45.215v-5zm-45.215 0c-.728 0-1.65-.422-2.497-1.643-.84-1.212-1.44-3.023-1.44-5.148h-5c0 3.013.84 5.847 2.33 7.996 1.484 2.14 3.78 3.795 6.607 3.795v-5zM2.5 54.369V5.579h-5v48.79h5zm0-48.79C2.5 3.943 3.878 2.5 5.737 2.5v-5C1.245-2.5-2.5 1.054-2.5 5.58h5z"></path>
    <path id="dashboard-calculated-lp_G" fill-rule="evenodd" d="M3.953 0l.002 1.399a59.864 59.864 0 0 1-.034 1.642 51.256 51.256 0 0 1-.241 3.552c-.189 1.781-.47 3.166-.813 3.914-.276.602-.682 1.444-1.205 1.72a3.418 3.418 0 0 1-1.602.39L0 14.979l45.359-.03c5.19 0 9.088-3.144 9.088-7.922l.06-5.615L54.521 0H3.953z"></path>
    <path id="dashboard-calculated-lp_I" d="M3.953 0v-2.5H1.449L1.453.003 3.953 0zm.002 1.399h2.5v-.003l-2.5.003zm-.005.458l-2.5-.044v.01l2.5.034zM3.92 3.04l2.499.089v-.005L3.92 3.04zm-.24 3.552L1.194 6.33v.001l2.486.263zm-.813 3.914L5.14 11.55l.001-.002-2.273-1.041zm-1.205 1.72L.498 10.013l1.164 2.212zm-1.602.39l.068-2.5-2.503-.067-.064 2.503 2.5.064zM0 14.979l-2.5-.064-.065 2.565 2.567-.001-.002-2.5zm45.359-.03v-2.5h-.002l.002 2.5zm9.088-7.922L51.947 7v.027h2.5zm.06-5.615l-2.5-.027 2.5.027zM54.521 0l2.5.027.027-2.527h-2.527V0zM1.452.003l.003 1.4 5-.007-.002-1.4-5 .007zM1.456 1.4c0 .079-.001.21-.005.414l5 .088.005-.502h-5zm-.005.424c-.004.342-.014.715-.028 1.135l4.997.167c.014-.438.026-.86.03-1.235L1.45 1.823zm-.028 1.13a47.669 47.669 0 0 1-.228 3.376l4.972.529c.125-1.178.208-2.478.253-3.728l-4.997-.177zM1.194 6.33c-.187 1.769-.442 2.792-.6 3.135L5.14 11.55c.528-1.152.836-2.9 1.026-4.693L1.194 6.33zM.596 9.463c-.138.3-.25.528-.355.696-.05.079-.07.098-.056.083.009-.01.109-.12.313-.228l2.329 4.425c.868-.457 1.39-1.212 1.647-1.62.277-.449.521-.955.665-1.269L.596 9.463zm-.099.552a.964.964 0 0 1-.235.083c-.093.02-.146.02-.134.02l-.135 4.998a5.91 5.91 0 0 0 2.835-.678l-2.33-4.424zm-2.936 2.538l-.06 2.362 4.998.128.06-2.362-4.998-.128zm2.44 4.926l45.36-.03-.004-5-45.359.03.004 5zm45.358-.03c3.087 0 5.964-.937 8.112-2.766 2.18-1.858 3.476-4.534 3.476-7.656h-5c0 1.656-.653 2.941-1.72 3.85-1.098.936-2.766 1.572-4.868 1.572v5zM56.947 7.053l.06-5.615-5-.052L51.947 7l5 .053zm.06-5.614l.015-1.412-5-.054-.015 1.412 5 .054zM54.521-2.5H53.07v5h1.45v-5zm-1.451 0H5.39v5h47.68v-5zm-47.68 0H3.952v5H5.39v-5z"></path>
    <path id="dashboard-calculated-lp_J" d="M20.924 0H0v1.872h20.924V0z"></path>
    <path id="dashboard-calculated-lp_K" d="M26.783 0H0v1.872h26.783V0z"></path>
    <path id="dashboard-calculated-lp_L" d="M21.76 0H0v1.872h21.76V0z"></path>
    <path id="dashboard-calculated-lp_M" fill-rule="evenodd" d="M18.84 31.83l-6.543 4.488-2.065-7.554-7.96-.679L5.652 21 0 15.472l7.243-3.302-.7-7.79 7.717 2.027L18.84 0l4.58 6.407 7.717-2.027-.7 7.79 7.242 3.302L32.027 21l3.38 7.086-7.96.679-2.065 7.554-6.542-4.488z"></path>
    <path id="dashboard-calculated-lp_N" d="M18.84 31.83l.848-1.237-.848-.582-.849.582.849 1.237zm-6.543 4.488l-1.447.395.556 2.035 1.74-1.193-.849-1.237zm-2.065-7.554l1.447-.396-.276-1.01-1.044-.089-.127 1.495zm-7.96-.679L.918 27.44l-.933 1.957 2.16.184.127-1.495zM5.652 21l1.354.646.462-.968-.767-.75-1.049 1.072zM0 15.472l-.622-1.365-1.991.908 1.564 1.53L0 15.471zm7.243-3.302l.622 1.365.967-.44-.095-1.06-1.494.135zm-.7-7.79l.38-1.45-2.066-.543.192 2.128 1.494-.135zm7.717 2.027l-.381 1.45 1 .264.601-.842-1.22-.872zM18.84 0l1.22-.872-1.22-1.707-1.22 1.707L18.84 0zm4.58 6.407l-1.22.872.6.842 1-.263-.38-1.45zm7.717-2.027l1.494.135.19-2.128-2.065.543.38 1.45zm-.7 7.79l-1.495-.134-.095 1.058.967.441.622-1.365zm7.242 3.302l1.049 1.072 1.564-1.53-1.99-.907-.623 1.365zM32.027 21l-1.049-1.072-.767.75.462.968L32.027 21zm3.38 7.086l.128 1.495 2.16-.184-.934-1.957-1.353.646zm-7.96.679l-.127-1.495-1.043.09-.277 1.01 1.447.395zm-2.065 7.554l-.848 1.237 1.739 1.193.556-2.035-1.447-.395zm-7.39-5.725l-6.544 4.488 1.697 2.474 6.543-4.488-1.697-2.474zm-4.248 5.33l-2.065-7.555-2.894.791 2.065 7.554 2.894-.79zm-3.385-8.654l-7.96-.678-.255 2.989 7.96.678.255-2.989zm-6.733 1.462l3.38-7.086-2.708-1.292-3.38 7.086 2.708 1.292zM6.7 19.927L1.049 14.4l-2.098 2.144 5.652 5.528 2.098-2.145zm-6.079-3.09l7.243-3.302-1.244-2.73-7.243 3.302 1.244 2.73zm8.115-4.801l-.7-7.79-2.988.269.7 7.79 2.988-.27zM6.162 5.83l7.717 2.027.762-2.902L6.924 2.93 6.162 5.83zM15.48 7.28L20.06.872 17.62-.872l-4.58 6.407 2.44 1.744zM17.62.872L22.2 7.28l2.44-1.744-4.58-6.407L17.62.872zm6.18 6.986l7.718-2.027-.762-2.901-7.718 2.026.762 2.902zm5.843-3.612l-.7 7.79 2.987.269.7-7.79-2.987-.269zm.171 9.29l7.243 3.301 1.244-2.73-7.242-3.302-1.245 2.73zm6.817.864l-5.652 5.527 2.097 2.145 5.652-5.527-2.097-2.145zm-5.958 7.245l3.38 7.086 2.708-1.292-3.38-7.086-2.708 1.292zm4.607 4.945l-7.96.68.255 2.988 7.96-.678-.255-2.99zM26 28.368l-2.065 7.554 2.894.791 2.065-7.554-2.893-.79zm.23 6.713l-6.542-4.488-1.697 2.474 6.543 4.488 1.697-2.474z"></path>
  </defs>
  <g transform="translate(-69.818 2909.09) scale(5.81818)">
    <mask id="dashboard-calculated-lp_a">
      <path d="M12-500h188v88H12v-88z" fill="#FFF"></path>
    </mask>
    <g style="mix-blend-mode:normal" mask="url(#dashboard-calculated-lp_a)">
      <use xlink:href="#dashboard-calculated-lp_b" transform="translate(12 -500)" fill="#FFF" style="mix-blend-mode:normal" opacity=".01"></use>
      <g style="mix-blend-mode:normal">
        <use xlink:href="#dashboard-calculated-lp_c" transform="translate(12 -488)" fill="#E6EAEB" style="mix-blend-mode:normal"></use>
        <g style="mix-blend-mode:normal">
          <g style="mix-blend-mode:normal">
            <use xlink:href="#dashboard-calculated-lp_d" transform="translate(35.479 -477.252)" fill="#FFF" style="mix-blend-mode:normal"></use>
            <mask id="dashboard-calculated-lp_e">
              <path fill="#fff" transform="translate(35.479 -477.252)" d="M-2-2h22v59H-2z"></path>
              <use xlink:href="#dashboard-calculated-lp_d" transform="translate(35.479 -477.252)"></use>
            </mask>
            <g mask="url(#dashboard-calculated-lp_e)">
              <use xlink:href="#dashboard-calculated-lp_f" transform="translate(35.479 -477.252)" fill="#A4A9A4" style="mix-blend-mode:normal"></use>
            </g>
          </g>
          <mask id="dashboard-calculated-lp_h">
            <use xlink:href="#dashboard-calculated-lp_g" transform="translate(16.87 -473.391)" fill="#C4C4C4" style="mix-blend-mode:normal"></use>
          </mask>
          <g style="mix-blend-mode:normal" mask="url(#dashboard-calculated-lp_h)">
            <use xlink:href="#dashboard-calculated-lp_i" transform="translate(54.696 -467.828)" fill="#F8F8F8" style="mix-blend-mode:normal"></use>
            <use xlink:href="#dashboard-calculated-lp_j" transform="translate(53.54 -469.655)" fill="#A4AAA4" style="mix-blend-mode:normal"></use>
            <use xlink:href="#dashboard-calculated-lp_k" transform="translate(20.305 -467.827)" fill="#F8F8F8" style="mix-blend-mode:normal"></use>
            <use xlink:href="#dashboard-calculated-lp_l" transform="translate(18.479 -469.655)" fill="#A4AAA4" style="mix-blend-mode:normal"></use>
          </g>
        </g>
      </g>
      <g style="mix-blend-mode:normal">
        <use xlink:href="#dashboard-calculated-lp_c" transform="translate(134.391 -488)" fill="#E6EAEB" style="mix-blend-mode:normal"></use>
        <g style="mix-blend-mode:normal">
          <g style="mix-blend-mode:normal">
            <g style="mix-blend-mode:normal">
              <use xlink:href="#dashboard-calculated-lp_m" transform="translate(133 -479.036)" fill="#FFF" style="mix-blend-mode:normal"></use>
              <mask id="dashboard-calculated-lp_n">
                <use xlink:href="#dashboard-calculated-lp_m" fill="#fff" transform="translate(133 -479.036)"></use>
              </mask>
              <g mask="url(#dashboard-calculated-lp_n)">
                <use xlink:href="#dashboard-calculated-lp_o" transform="translate(133 -479.036)" fill="#A4A9A4" style="mix-blend-mode:normal"></use>
              </g>
            </g>
            <use xlink:href="#dashboard-calculated-lp_p" transform="matrix(.69444 0 0 .83333 144.294 -443.765)" fill="#A4A9A4" style="mix-blend-mode:normal"></use>
            <use xlink:href="#dashboard-calculated-lp_q" transform="translate(143.565 -473.474)" fill="#A4A9A4" style="mix-blend-mode:normal"></use>
            <use xlink:href="#dashboard-calculated-lp_r" transform="matrix(1.02083 0 0 1 134.67 -451.21)" fill="#A4A9A4" style="mix-blend-mode:normal"></use>
          </g>
          <g style="mix-blend-mode:normal">
            <g style="mix-blend-mode:normal">
              <use xlink:href="#dashboard-calculated-lp_s" transform="translate(162.913 -456.775)" fill="#FFF" style="mix-blend-mode:normal"></use>
              <mask id="dashboard-calculated-lp_t">
                <use xlink:href="#dashboard-calculated-lp_s" fill="#fff" transform="translate(162.913 -456.775)"></use>
              </mask>
              <g mask="url(#dashboard-calculated-lp_t)">
                <use xlink:href="#dashboard-calculated-lp_u" transform="translate(162.913 -456.775)" fill="#A4A9A4" style="mix-blend-mode:normal"></use>
              </g>
            </g>
            <use xlink:href="#dashboard-calculated-lp_v" transform="matrix(1.02128 0 0 1 164.637 -451.21)" fill="#A4A9A4" style="mix-blend-mode:normal"></use>
            <use xlink:href="#dashboard-calculated-lp_w" transform="translate(177.522 -445.645)" fill="#A4A9A4" style="mix-blend-mode:normal"></use>
            <use xlink:href="#dashboard-calculated-lp_x" transform="translate(177.522 -441.471)" fill="#A4A9A4" style="mix-blend-mode:normal"></use>
            <use xlink:href="#dashboard-calculated-lp_y" transform="translate(177.522 -437.297)" fill="#A4A9A4" style="mix-blend-mode:normal"></use>
            <use xlink:href="#dashboard-calculated-lp_z" transform="matrix(1 0 0 1.01724 172.652 -451.21)" fill="#A4A9A4" style="mix-blend-mode:normal"></use>
          </g>
        </g>
      </g>
      <g style="mix-blend-mode:normal">
        <g style="mix-blend-mode:normal">
          <use xlink:href="#dashboard-calculated-lp_A" transform="translate(62 -500)" fill="#F3EFE7" style="mix-blend-mode:normal"></use>
          <mask id="dashboard-calculated-lp_B">
            <use xlink:href="#dashboard-calculated-lp_A" fill="#fff" transform="translate(62 -500)"></use>
          </mask>
          <g mask="url(#dashboard-calculated-lp_B)">
            <use xlink:href="#dashboard-calculated-lp_C" transform="translate(62 -500)" fill="#AE9357" style="mix-blend-mode:normal"></use>
          </g>
        </g>
        <g style="mix-blend-mode:normal">
          <g style="mix-blend-mode:normal">
            <use xlink:href="#dashboard-calculated-lp_D" transform="translate(86.87 -475.66)" fill="#FFF" style="mix-blend-mode:normal"></use>
            <mask id="dashboard-calculated-lp_E">
              <use xlink:href="#dashboard-calculated-lp_D" fill="#fff" transform="translate(86.87 -475.66)"></use>
            </mask>
            <g mask="url(#dashboard-calculated-lp_E)">
              <use xlink:href="#dashboard-calculated-lp_F" transform="translate(86.87 -475.66)" fill="#A4A9A4" style="mix-blend-mode:normal"></use>
            </g>
          </g>
          <g style="mix-blend-mode:normal">
            <use xlink:href="#dashboard-calculated-lp_G" transform="translate(92.609 -426.979)" fill="#FFF" style="mix-blend-mode:normal"></use>
            <mask id="dashboard-calculated-lp_H">
              <use xlink:href="#dashboard-calculated-lp_G" fill="#fff" transform="translate(92.609 -426.979)"></use>
            </mask>
            <g mask="url(#dashboard-calculated-lp_H)">
              <use xlink:href="#dashboard-calculated-lp_I" transform="translate(92.609 -426.979)" fill="#A4A9A4" style="mix-blend-mode:normal"></use>
            </g>
          </g>
          <use xlink:href="#dashboard-calculated-lp_J" transform="translate(104.394 -445.702)" fill="#677067" style="mix-blend-mode:normal" opacity=".6"></use>
          <use xlink:href="#dashboard-calculated-lp_K" transform="translate(101.883 -440.085)" fill="#677067" style="mix-blend-mode:normal" opacity=".6"></use>
          <use xlink:href="#dashboard-calculated-lp_L" transform="translate(104.394 -434.468)" fill="#677067" style="mix-blend-mode:normal" opacity=".6"></use>
          <g style="mix-blend-mode:normal" transform="translate(73.478 -485.957)">
            <use xlink:href="#dashboard-calculated-lp_M" fill="#FFF" style="mix-blend-mode:normal"></use>
            <use xlink:href="#dashboard-calculated-lp_N" fill="#AE9357" style="mix-blend-mode:normal"></use>
          </g>
        </g>
      </g>
    </g>
  </g>
</svg>

A: It is possible that the browser scaling is not properly. Try to remove width or height attribute or both from your CSS element. See details here.


text:
Q: How to write curry and compose in Typescript 4? After going through variadic types I wanted to make this, but I'm wondering how to use array of functions.
This is my first try:
function curry<T extends any[]>(fn: (...args: T) => any) {
  return function(...args: T) {
    return args.length >= fn.length
      ? fn(...args)
      : curry(fn.bind(undefined, ...args));
  }
}

But for fn.bind I'm getting "The 'this' context of type '(...args: T) => any' is not assignable to method's 'this' of type '(this: undefined, ...args: any[]) => any'."
Any ideas?

A: You're not really using variadic tuple tpes in your code.  The specific flavor of curry() you're implementing is one that takes a partial parameter list and then possibly returns another function that takes a partial remainder of the list.  That means the initial tuple of parameters T might be split into many different pieces, and this is therefore not going to be automatically inferred from context the way that the partialCall() function in the documentation can.
Instead, you need to explicitly break the T tuples apart into possible subtuples.  Let's represent the type of the desired output of curry() that takes a function whose parameters are the tuple A and whose return type is R:
type Curried<A extends any[], R> =
  <P extends Partial<A>>(...args: P) => P extends A ? R :
    A extends [...SameLength<P>, ...infer S] ? S extends any[] ? Curried<S, R>
    : never : never;

type SameLength<T extends any[]> = Extract<{ [K in keyof T]: any }, any[]>

Let me translate that into English. A Curried<A, R> is a generic function, whose arguments must be of some tuple type P that is constrained to Partial<A>.
For tuples, Partial<A> ends up meaning that you can leave out any suffix of the tuple (from some place to the end).  So [1, 2, 3] is assignable to Partial<[1,2,3,4,5,6,7]>, but [1, 2, 4] is not.  There's a bit of a wrinkle with undefined, since [1, undefined, 3] is also assignable to Partial<[1,2,3,4,5,6,7]>, but I'm going to ignore that and if it becomes important it can be worked around.  Anyway, it means that the arguments to Curried<A, R> must be some prefix (initial chunk) of the A tuple.
The return type of Curried<A, R> depends on the prefix P passed in.  If P is the whole tuple A, then the return type is just R (that's what happens when you've finally given the function all its arguments).  Otherwise, you split A into the prefix P and its suffix S, and return a new curried function of type Curried<S, R>.
Splitting A into [...SameLength<P>, ...infer S] uses variadic tuple types.  Note that SameLength<P> is just a tuple the same length as P but with its element types as any.  This avoids a problem where P is inferred to be very narrow (say A is [number, number, number] and then P is [0, 0].  You can't split [number, number, string] into [0, 0, ...infer S] because number isn't assignable to 0.  But all we care about is length here, so we split [number, number, string] into [any, any, ...infer S] and that works, and infers S to be string).
Okay, use and implement it:
function curry<A extends any[], R>(fn: (...args: A) => R): Curried<A, R> {
  return (...args: any[]): any =>
    args.length >= fn.length ? fn(...args as any) : curry((fn as any).bind(undefined, ...args));
}

I used a whole lot of type assertions inside the implementation of curry(), because the compiler is almost hopelessly lost at trying to verify that the returned function will be assignable to Curried<A, R>.  Instead of worrying about it, I just tell the compiler not to bother verifying safety, and take responsibility myself for making the implementation correct.  (If it's wrong, I blame myself, not the compiler).
Okay, so there we go.  Does it work?
const fn = (a: string, b: number, c: boolean) => (a.length <= b) === c ? "yep" : "nope";

const cFn = curry(fn);
const val1 = cFn("")(1)(true);
console.log(val1); // yep

const val2 = cFn("", 1, true);
console.log(val2); // yep

const val3 = cFn()()()()("", 1)()()(true); // yep

Looks good to me.  Note that according to my definition if you call a Curried<A, R> with no arguments you just get back a Curried<A, R>.  Here are some intentional errors so you can see that the compiler catches them:
// errors
cFn(1, 1, true); // error!
//  ~ <-- not a string
cFn("", 1, true, false); // error!
//               ~~~~~ <-- Expected 0-3 arguments, but got 4
cFn("")(1)(false)(true); // error!
//~~~~~~~~~~~~~~~ <-- This expression is not callable.

These look like the correct errors to me.

Playground link to code

redpajama_set_name: RedPajamaStackExchange


text:
Q: Isolating Constants in Orthogonal Trajectories The original function is $y^2 = kx^3$, and I'm being asked to find the orthogonal trajectory.
$$ 2y\frac{dy}{dx} = 3kx^2 $$
$$ \frac{dy}{dx} = \frac{3kx^2}{2y}$$
$$ \text{New }\frac{dy}{dx} = \frac{2y}{3kx^2} $$
$$ \frac{1}{2y}\,dy = \frac{1}{3kx^2}\,dx$$
$$ \frac{\ln|y|}{2} = \frac{-1}{3kx} + c$$
$$ \ln|y| = \frac{-2}{3kx} + c$$
$$ y = e^{\frac{-2}{3kx} + c}$$
$$ y = e^ce^\frac{-2}{3kx}$$
I'm told that the final solution is $2x^2+3y^2 = d$, where d is a constant. However, I can't find a way to get there from where I currently am. I suppose you'd have to combine c and k in some way, but I don't see it. Any hints?

A: Note that
$\dfrac{dy}{dx} = \dfrac{3kx^2}{2y} = \dfrac{3kx^3}{2xy} = \dfrac{3y^2}{2xy} = \dfrac{3y}{2x}$
so the orthogonal curves satisfy
$\dfrac{dy}{dx} = -\dfrac{2x}{3y}.$
Rewrite this equation as
$2x\ dx + 3y\ dy = 0$
and integrate both sides.


text:
Q: Whats Wikis questions and answers principles? I am asking about the supposed principles that all the users need to follow on Stack Overflow,
There are some cases I want to understand:

*

*Some one asked a question and made it as a wiki -> why all answers are wikis as well "I mean users used to make the answers as wikis, not forced to".

*When its better to make a question as a wiki and when not?

*When should you make an answer as a wiki and when not?

*Whats the real purpose of Wikis on Stack Overflow, while I still see a lot of answers on the same wiki question?

*Why wikis questions or answers votes, don't give to their owners more points? "I know its hard to calculate, but its also not fair to gain 100 votes on a question and not get at least one point, we need to think of a way"?

A: A Community Wiki is supposed to be a way to have a collection pot of information on some subject from the entire community.
So a CW does more things than you post. For example if you post an answer on a CW question and I edit this answer, your name will no longer appear. Since I am the last editor.
So any notion of ownership does not exist on a CW question.
Many users misunderstand CW's and many use them to ask subjective questions and prevent rep whoring on answers which many agree with. A CW question was not originally supposed to be about that.


text:
Q: How to fix issue "Error: Cannot find module 'puppeteer'" when running "pkg ." so I have a puppeteer script and I want to make it a .exe file that includes node_modules within the .exe file.
index.js:
const fs = require("fs");
const puppeteer = require("puppeteer-extra");

const StealthPlugin = require("puppeteer-extra-plugin-stealth");
puppeteer.use(StealthPlugin());

code...

When I run pkg . it creates the .exe files but I have to run it besides the node_modules folder to be able to run it without having the error " Error: Cannot find module 'puppeteer'"
I also tried this on my package.json
  "pkg": {
    "assets": "node_modules/**/*.*"
  },

But it has been like an hour or so, and nothing has been created, it's like it has frozen.
Anyone can help? Thanks a lot!

A: const puppeteer = require("puppeteer-extra");
const isPkg = typeof process.pkg !== 'undefined';

const chromiumExecutablePath = isPkg
    ? puppeteer.executablePath().replace(
        /^.*?\/node_modules\/puppeteer\/\.local-chromium/,
        path.join(path.dirname(process.execPath), '.local-chromium')
      ) : puppeteer.executablePath()
);
const browser = await puppeteer.launch({
   executablePath: chromiumExecutablePath,
   args: [
     "--start-maximized",
     "--no-sandbox",
   ],
   headless: false,
   defaultViewport: null
})

And to build use npm script like:
"build": "pkg src/index.js --public --targets node14-win-x64 --out-path dist"


text:
Q: Custom modeless dialog class not visible I want to make a custom non-modal dialog class with a label and a QDialogButtonBox.  I have looked at a number of postings, but none seems really on point.  My code is below.  Two questions:
1. Why isn't the dialog class displaying anything?
2. Do the connections look correct for the QDialogButtonBox?
Any help would be appreciated.  Thanks!
from PyQt5.QtWidgets import *

class Window(QWidget):
    def __init__(self):
        QWidget.__init__(self)

        cb = QCheckBox('Check me anytime', self)
        cb.move(20, 20)

        button = QPushButton('Open Dialog', self)
        button.move(20,50)
        self.resize(120, 90)

        button.clicked.connect(self.showDialog)

    def showDialog(self):
        self.dialog = ModelessDialog(self)
        self.dialog.show()

class ModelessDialog(QDialog):
    def __init__(self, parent=None):
        super().__init__(parent)
        layout = QVBoxLayout()
        lbl = QLabel("please show something ...")
        buttonBox = QDialogButtonBox(
            QDialogButtonBox.Cancel|QDialogButtonBox.Apply)
        layout.addWidget(lbl)
        layout.addWidget(buttonBox)
        self.resize(300, 200)

        applyBtn = buttonBox.button(QDialogButtonBox.Apply)
        applyBtn.clicked.connect(self.apply)

        cancelBtn = buttonBox.button(QDialogButtonBox.Cancel)
        cancelBtn.clicked.connect(ModelessDialog.reject)

        self.setWindowTitle("Modeless")

    def apply(self):
        print("ModelessDialog: in apply")

if __name__ == '__main__':
    import sys
    app = QApplication(sys.argv)
    win = Window()
    win.show()
    sys.exit(app.exec_())

A: Sets the layout manager for this widget to layout .
self.setLayout(layout)

Try it:
from PyQt5.QtWidgets import *

class Window(QWidget):
    def __init__(self):
        QWidget.__init__(self)

        cb = QCheckBox('Check me anytime', self)
        cb.move(20, 20)

        button = QPushButton('Open Dialog', self)
        button.move(20,50)
        self.resize(150, 90)

        button.clicked.connect(self.showDialog)

    def showDialog(self):
        self.dialog = ModelessDialog(self)
        self.dialog.show()

class ModelessDialog(QDialog):
    def __init__(self, parent=None):
        super().__init__(parent)

        layout = QVBoxLayout()
        lbl    = QLabel("please show something ...")
        buttonBox = QDialogButtonBox(
            QDialogButtonBox.Cancel|QDialogButtonBox.Apply)
        layout.addWidget(lbl)
        layout.addWidget(buttonBox)
        self.resize(300, 200)
        # Sets the layout manager for this widget to layout .
        self.setLayout(layout)                              # +++

        applyBtn = buttonBox.button(QDialogButtonBox.Apply)
        applyBtn.clicked.connect(self.apply)

        cancelBtn = buttonBox.button(QDialogButtonBox.Cancel)
        #cancelBtn.clicked.connect(ModelessDialog.reject)   # ---
        # first argument of unbound method must have type 'QDialog'
        cancelBtn.clicked.connect(self.reject)              # +++

        self.setWindowTitle("Modeless")

    def apply(self):
        print("ModelessDialog: in apply")

if __name__ == '__main__':
    import sys
    app = QApplication(sys.argv)
    win = Window()
    win.show()
    sys.exit(app.exec_())


text:
Q: User story definition in spock I have recently started using the spock framework for BDD in my Java project.
I noticed that in a spock specification it is possible to define a feature and a given-when-then clause in a specification. For example:
MySpec extends Specification {

  //As a User I want the system to behave in some way

  def "it should provide feature 1"() {
    given: "some state"
    when : "some action"
    then : "some symptom"
  }

  def "it should provide feature 2"() {
    ...
  }
}

What I am missing is the user story part of the specification, the part that I put in a comment.
Is it possible in some way to write a spock specification that will provide the test output in the format:
+As a User I want the system to behave in some way
  +it should provide feature 1
    -given some state
    -when some action
    -then some symptom
  +it should provide feature 2
    -given some state
    -when some action
    -then some symptom

This is very similar to how ScalaTest outputs its results.
I am basically missing that top level element that will allow me to easily group and display features. I would like to know if there is such a construct or if I do not understand the true nature of the spock framework.

A: The new business report that's in the making for Spock 1.0 will support this feature via a @Narrative annotation attached to a spec class. To get a first impression, see this sample spec and the resulting report.


text:
Q: Is there a model that can handled unbalanced repeated measures data with 1 OR 2 follow ups? I want to identify predictors of a binary healthcare outcome in a purely observational study, and some of my participants have 1 recorded outcome timepoint, while others have 2 recorded outcome timepoints. I do not care about time at all and I am not interested in within-person variation - time is not part of the research question, there is no conceptual reason that outcome time (1st vs 2nd) would matter, and the distribution of outcome variable values does not vary by time. I just want to be able to use ALL of my observations to make a statement about what variables predict the outcome in general.
I thought I would use GEE (generalized estimating equations) but then I read that with GEE every individual in the study needs to have at least 2 timepoints, so if that's correct, GEE would not serve my purpose. My sample size is very small (N total=79, N with 2 follow ups=40) and my outcome is binary. I welcome general statistics/model type selection tips, or software-specific tips as well. I was going to use PROC GEE in SAS with weighting via a missingness model before I found out it couldn't handle having unpaired response observations. Any tips are much appreciated. Thank you.

A: You have a single survey response from each individual to consider, but either 1 or 2 observations of a binary outcome for each. If you don't care about the time between taking the survey and the adherence observation, or about systematic differences with time for those having 2 observations, this could in principle be simply handled by a mixed logistic regression model, with a fixed effect for the survey response and patient having random intercepts.
Say that your survey results are put together on a combined scale such that the mean response is 0. Then a logistic regression model with just 1 observation per patient would return an intercept representing the log-odds of being adherent if the survey response were 0, and the slope would be how much the log-odds changed per unit change in the survey response.
The possibility of having more than 1 observation per patient, with patient adherence likely to be correlated between the observations, is handled by allowing each patient to have a different random intercept: the estimated log-odds of adherence if their survey response had been 0. The distribution of intercepts among patients is taken to be Gaussian. Fitting the model simultaneously finds the best estimates of the overall intercept, the distribution of individual-patient intercepts around that, and the overall slope with respect to survey response. That pools information from all observations, effectively weighting patients with 2 observations more than those with a single observation.
This approach might be extended to consider time post-survey as a continuous predictor, if there were adequate data and you could assume a linear change in log-odds of adherence with time or some other simple relationship. That could take advantage of the actual survey-to-observation time differences from all your cases, not just those having 2 observations.
That said, your ability to evaluate predictors in a binary-outcome analysis is limited by the number of cases in the minority class, here the 29 non-adherence  observations. The usual rule of thumb is you can examine about 1 predictor per 15 members of the minority class without overfitting. So don't go overboard in "looking at which variables on a survey predict a positive drug test result." The risk in examining too many predictors is that you might find a relationship that works very well in your current data set but doesn't work well on a new data set. I'd recommend using your knowledge of the subject matter to put together aspects of the survey into a small set of predictors, each of which combines related survey answers. Think about how individual Likert items are combined into a Likert scale.


text:
Q: Return contents of string as set of records I'm trying to extract the data from a Gravity Form list control.
Essentially the list control allows you to collect multi-column table data on your web form (built on a WordPress website). However, the table and the records the user provides all get put in to a single line of text for the form's record submission.
I've managed to write a custom scalar function to take the raw input text like this:
a:3:{i:0;a:3:{s:6:"ItemID";s:1:"1";s:4:"Name";s:10:"Dennis Dish";s:12:"Phone Number";s:12:"01225 123456";}i:1;a:3:{s:6:"ItemID";s:1:"2";s:4:"Name";s:13:"Sally Spatula";s:12:"Phone Number";s:12:"01225 654321";}i:2;a:3:{s:6:"ItemID";s:1:"3";s:4:"Name";s:10:"Terry Tins";s:12:"Phone Number";s:12:"01225 789456";}}
...and return it like this (still as a single text string):
ItemID: 1
Name: Dennis Dish
Phone Number: 01225 123456

ItemID: 2
Name: Sally Spatula
Phone Number: 01225 654321

ItemID: 3
Name: Terry Tins
Phone Number: 01225 789456

That was reasonably straight forward and useful, but I now need to write something that can return the raw string to a set of records instead.
So if, for example, I had a table with the following data:
|   ID   |           RawString           |
|--------|-------------------------------|
|   1    | a:3:{i:0;a:3:{s:6:"ItemID"... |

..instead of returning this as a tidier string, like this:
|   ID   |           TidyString          |
|--------|-------------------------------|
|   1    | ItemID: 1 Name: Dennis Dish...|

..I'm looking for the method to return something along the lines of:
|   ID   | ItemID |     Name      | Phone Number |
|--------|--------|---------------|--------------|
|   1    |   1    | Dennis Dish   | 01225 123456 |
|   1    |   2    | Sally Spatula | 01225 654321 |
|   1    |   3    | Terry Tins    | 01225 789456 |

In my scalar function I was able to identify parts of the raw string formatting that helped to tidy it up:

*

*a:n:{... (at the very start) indicates how many records there are, so a:3:{... means
there are 3 records.

*i:n;... indicates the record number, so i:0;... means the first
record.

*a:n:{... (within a record) indicates the number of
column/value pairs in the record, so a:3:{means there are 3 pairs
of columns/values in this record.

*s:... indicates the number of characters in following column or value, so s:2... indicates the column or value is 2 characters in length.

It may be easier to visualise this by indenting the raw string:
a:3:{
        i:0;
            a:3:{
                    s:2:"ItemID";
                    s:1:"1";

                    s:4:"Name";
                    s:10:"Dennis Dish";

                    s:12:"Phone Number";
                    s:12:"01225 123456";
                }
        i:1;
            a:3:{
                    s:2:"ItemID";
                    s:1:"2";

                    s:4:"Name";
                    s:13:"Sally Spatula";

                    s:12:"Phone Number";
                    s:12:"01225 654321";
                }

        i:2;
            a:3:{
                    s:2:"ItemID";
                    s:1:"3";

                    s:4:"Name";
                    s:10:"Terry Tins";

                    s:12:"Phone Number";
                    s:12:"01225 789456";
                }
    }

I'm not really sure where to begin in terms of returning the data out of this raw string as a result set.
Any pointers would be appreciated.

A: This is a job for NGrams8K. If you download a copy of the function you could do this:
DECLARE @yourstring varchar(1000) =
'a:3:{
    i:0;
        a:3:{
                s:2:"ItemID";
                s:1:"1";

                s:4:"Name";
                s:10:"Dennis Dish";

                s:12:"Phone Number";
                s:12:"01225 123456";
            }
    i:1;
        a:3:{
                s:2:"ItemID";
                s:1:"2";

                s:4:"Name";
                s:13:"Sally Spatula";

                s:12:"Phone Number";
                s:12:"01225 654321";
            }

    i:2;
        a:3:{
                s:2:"ItemID";
                s:1:"3";

                s:4:"Name";
                s:10:"Terry Tins";

                s:12:"Phone Number";
                s:12:"01225 789456";
            }
    }';

WITH
names(itemID, ps) AS -- extract the names
(
  SELECT
    ROW_NUMBER() OVER (ORDER BY position),
    SUBSTRING
    (
      @yourstring,
      position+7,
      CHARINDEX(';', @yourstring, position+7)-(position+8)
    )
  FROM dbo.NGrams8k(@yourstring, 7)
  WHERE token = '"Name";'
),
phoneNbrs(itemID, ps) AS -- extract the phone numbers
(
  SELECT
    ROW_NUMBER() OVER (ORDER BY position),
    SUBSTRING
    (
      @yourstring,
      position+15,
      CHARINDEX(';', @yourstring, position+15)-(position+16)
    )
  FROM dbo.NGrams8k(@yourstring, 15)
  WHERE token = '"Phone Number";'

)
SELECT
 id = 1,
 n.itemID,
 [Name]         = SUBSTRING(n.ps, CHARINDEX('"', n.ps)+1, 100),
 [Phone Number] = SUBSTRING(p.ps, CHARINDEX('"', p.ps)+1, 30)
FROM names n
JOIN phoneNbrs p ON n.itemID = p.itemID;

Results:
|   ID   | ItemID |     Name      | Phone Number |
|--------|--------|---------------|--------------|
|   1    |   1    | Dennis Dish   | 01225 123456 |
|   1    |   2    | Sally Spatula | 01225 654321 |
|   1    |   3    | Terry Tins    | 01225 789456 |


text:
Q: How to manage my application window with python-xlib? I would like to find a linux-wide (insofar as it uses X11) way to control the window geometry of my application, which I program using Python. All my researches point to using python-xlib, which happens to be very poorly documented.
What I'd like to achieve is:

*

*define position of window on screen

*define minimum and maximum size

*enable / disable window resizing

*reserve screen-space for window

*keep window above/below

*skip or not task-bar (aka window list)

*set window decorated / undecorated

*set window flags (normal, pop-up, dialogue, splash, dock, ignored)

NB: I don't want to create the with Xlib, instead I want to tell X what to do with the window i created with some GUI library (PyQt for instance).
How can I go about doing this? I realise this question is quite a big one: do you have hints at least as to how I can get hold of my window? Where in the module can I find my answers?
Edit: n.m.'s answer offered great resources, and there is also another Q&A on Unix StackExchange that provides a great example on how to get control on an application window displayed by X.

A: The first keyword you need to know is ICCCM. You need to be familiar with the ICCCM manual (see http://tronche.com/gui/x/icccm/) and the FreeDesktop extensions to the same (see http://standards.freedesktop.org/wm-spec/wm-spec-1.3.html). As for your question

how I can get hold of my window?

I don't quite understand it. You call create_window and the function returns your Window object. Or do you mean something else?

A: Just discovered this yesterday and I think it's awesome compared to using variety of xdotool, wmctrl, gtk and tkinter to move windows around:
def x11_move_window(window_id_dec, x, y, width, height):
    """ Use x11 library to move window From:
        https://gist.github.com/chipolux/13963019c6ca4a2fed348a36c17e1277
    """

    import Xlib.display

    d = Xlib.display.Display()
    window = d.create_resource_object('window', window_id_dec)
    window.configure(x=x, y=y, width=width, height=height, border_width=0,
                     stack_mode=Xlib.X.Above)
    d.sync()

Note if you used wmctrl to get your window ID you need to convert it from hexadecimal to decimal before calling x11_move_window:
    window_id_hex = \
        os.popen('wmctrl -l | grep gone_fishing.png').read().strip().split()[0]

    window_id_dec = int(window_id_hex, 16)


text:
Q: how to force layout ar to read device I'm using shared preferences to force layout-ar to work
it works fine with emulator but in my read device it did not working ,
i'm sure Arabic set local it calling and getLocal() it returns Arabic , but my layout not going to layout-ar
protected static void setLocale(final Context ctx, final String lang) {
    final Locale loc = new Locale(lang);
    Locale.setDefault(loc);
    final Configuration cfg = new Configuration();
    cfg.locale = loc;
    ctx.getResources().updateConfiguration(cfg, null);
}


text:
Q: How to set Decorators for Input type file Elements? I have the following piece of code,
Under myClass , i have set decorators variable,
 public $testDecorators = array(
    'ViewHelper',
    'Errors',
    array('Description', array('escape' => false, 'tag' => '', 'placement' => 'append')),
    array(array('data' => 'HtmlTag'), array('tag' => 'div', 'class' => 'itemR')),
    array('Label', array('tag' => 'div', 'class' => 'itemL')
    ),
    array('HtmlTag', array('tag' => 'div', 'class' => 'itemcontent'))
);

Under CreateForm function,
....
    $cover_image = new Zend_Form_Element_File('cover_test', array(
      'label' => 'Cover Test:',
      'value'   => '',
      'class' => 'test',
      'tabindex' => '5',
      'required' => false,
      'filters' => array('StringTrim'),
          'decorators' => $this->testDecorators,
    ));

....
When i use this decorators, nothing is displaying in my form, if commented that 'decorators' => $this->testDecorators, form is coming fine with default dd tag, Kindly help me

A: The file element must include the 'File' decorator, usually in place of the ViewHelper decorator. So try this instead:
public $testDecorators = array(
    'File',
    'Errors',
    array('Description', array('escape' => false, 'tag' => '', 'placement' => 'append')),
    array(array('data' => 'HtmlTag'), array('tag' => 'div', 'class' => 'itemR')),
    array('Label', array('tag' => 'div', 'class' => 'itemL'),
    array('HtmlTag', array('tag' => 'div', 'class' => 'itemcontent'))
);

A: Have you looked at what $cover_image->getDecorators() shows?
Also, is this one in the middle correct:
array(array('data' => 'HtmlTag'), array('tag' => 'div', 'class' => 'itemR')),

should it not be:
array('HtmlTag', array('tag' => 'div', 'class' => 'itemR')),

as the last one is?


text:
Q: A new problem about finding more information about two non-isomorphic graphs This question is  a follow-up to the question I asked earlier.

*

*Wish more readable information from IsomorphicGraphQ
Using Mathematica, we can easily determine that the following two graphs are non-isomorphic.
  G1 = Graph[
  ImportString["W|tNHEpCKoh`@@Po_WHB@CKC?WGO{G?KKCB`?OMG?_y_?Sn",
   "Graph6"], VertexLabels -> Automatic];
  G2 = Graph[
  ImportString["W|vJJEpCKo``P`?ocKG``?ECG[GGKGCEC@@p?CMG?G]_?H^",
   "Graph6"], VertexLabels -> Automatic];
IsomorphicGraphQ[G1, G2]
(*Flase*)

I'd like to make it easy to see that these two graphs are non-isomorphic. And I tried the method in the answer of Szabolcs, and for these two graphs, it doesn't work.
sig[g_] := Module[{dm, diam}, dm = GraphDistanceMatrix[g];
  diam = Max[dm];
  Sort[Lookup[Counts[#], Range[diam], 0] & /@ dm]]
s1[G1]
(*{{7,10,6},{7,10,6},{7,10,6},{7,10,6},{7,10,6},{7,10,6},{7,10,6},{7,\
10,6},{7,10,6},{7,10,6},{7,10,6},{7,10,6},{7,10,6},{7,10,6},{7,10,6},{\
7,10,6},{7,10,6},{7,10,6},{7,10,6},{7,10,6},{7,10,6},{7,10,6},{7,10,6}\
,{7,10,6}}*)
s2[G2]
(*{{7,10,6},{7,10,6},{7,10,6},{7,10,6},{7,10,6},{7,10,6},{7,10,6},{7,\
10,6},{7,10,6},{7,10,6},{7,10,6},{7,10,6},{7,10,6},{7,10,6},{7,10,6},{\
7,10,6},{7,10,6},{7,10,6},{7,10,6},{7,10,6},{7,10,6},{7,10,6},{7,10,6}\
,{7,10,6}}*)

So I came up with the following idea, but it could be very violent.

For two graphs $G_1$ and $G_2$,   if $G_1$ has some
subgraph $H$ and $G_2$ doesn't contain any subgraph isomorphic to $H$,
then $G_1$ is not  isomorphic to $G_2$.

Let $S$ be the set of non-isomophic subgraphs of $G$ such that $G_2$ does not contain any subgraph isomorphic to any one of $S$.
My goal is to find the graphs in $S$ such that

*

*(1) have the minimum number of vertices,

*(2) have the minimum of edges.

Note that filtered graphs prioritised to meet condition (1).
PS: choose ``the minimum` is for the sake of observation.
For example,

Then $S$ is the following graph set:

The goal graph is $g_1$ in $S$.
How can we do that with Mathematica.

Ps: One interesting thing is that these two graphs have different eigenvalues. But I prefer to look at  a small subgraph $g$ in $G_1$ that $G_2$ does not contain $g$ (up to isomorphism).
Eigenvalues[AdjacencyMatrix[G1]]
(*{7, 1 + 2 Sqrt[3], 1 + 2 Sqrt[3], 1 + 2 Sqrt[3], -3, -3, -3,
 1 - 2 Sqrt[3], 1 - 2 Sqrt[3],
 1 - 2 Sqrt[3], -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1}*)

Eigenvalues[AdjacencyMatrix[G2]]
(*7, Root[25 + 50 # - 17 #^2 - 52 #^3 - 17 #^4 + 2 #^5 + #^6& , 6, 0], \
Root[25 + 50 # - 17 #^2 - 52 #^3 - 17 #^4 + 2 #^5 + #^6& , 6, 0], 1 +
 2 Sqrt[3], Root[
25 + 50 # - 17 #^2 - 52 #^3 - 17 #^4 + 2 #^5 + #^6& , 1, 0], Root[
25 + 50 # - 17 #^2 - 52 #^3 - 17 #^4 + 2 #^5 + #^6& , 1, 0], -3, 1 -
 2 Sqrt[3], Root[
25 + 50 # - 17 #^2 - 52 #^3 - 17 #^4 + 2 #^5 + #^6& , 2, 0], Root[
25 + 50 # - 17 #^2 - 52 #^3 - 17 #^4 + 2 #^5 + #^6& , 2, 0], Root[
25 + 50 # - 17 #^2 - 52 #^3 - 17 #^4 + 2 #^5 + #^6& , 3, 0], Root[
25 + 50 # - 17 #^2 - 52 #^3 - 17 #^4 + 2 #^5 + #^6& , 3, 0], -1, -1, \
-1, -1, -1, 1, 1, 1, Root[
25 + 50 # - 17 #^2 - 52 #^3 - 17 #^4 + 2 #^5 + #^6& , 5, 0], Root[
25 + 50 # - 17 #^2 - 52 #^3 - 17 #^4 + 2 #^5 + #^6& , 5, 0], Root[
25 + 50 # - 17 #^2 - 52 #^3 - 17 #^4 + 2 #^5 + #^6& , 4, 0], Root[
25 + 50 # - 17 #^2 - 52 #^3 - 17 #^4 + 2 #^5 + #^6& , 4, 0]*)


text:
Q: How to play music only in foreground I have trouble to play music across all activity, I had implement service and handle onPause to stop the music when going to background (not visible to user).
The problem is when i navigate to another activity, the onPause method is called that make my music stop. How to fix this issue? I need to play my music across all my activity in foreground only and dont wan to play it when the application in the background. Appeciate anyone know how to solve this.
This is my base activity
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    startIntent = new Intent(getApplicationContext(), MusicService.class);
    if(binder==null){
        bindService(startIntent,this, Context.BIND_AUTO_CREATE);
    }
}

@Override
protected void onDestroy() {
    super.onDestroy();
    if(binder.getMyService()!=null){
        stopService(startIntent);
        unbindService(this);
    }

}

@Override
protected void onStart() {
    super.onStart();

}

@Override
protected void onPause() {
    super.onPause();

    if(binder!=null) {
        binder.getMyService().pauseMusic();
    }

}

@Override
protected void onResume() {
    super.onResume();
    if(binder!=null){
        binder.getMyService().resumeMusic();
    }
}

@Override
public void onServiceConnected(ComponentName name, IBinder service) {
    binder = (MusicService.Binder) service;

}

@Override
public void onServiceDisconnected(ComponentName name) {

}

this is my mainactivity extends base activity
@Override
protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    startIntent = new Intent(MainActivity.this, MusicService.class);
    startService(startIntent);

}

@Override
protected void onDestroy() {
    super.onDestroy();

}

public void how(View view) {
        Intent intent = new Intent(this, AboutActivity.class);
        this.startActivity(intent);

    }

A: Don't stop the audio play in onPause() as Harin Kaklotar suggested. You can use his method of onDestroy() or you can have it in an asynchronous task and turn off the sound by using surfaceDestroyed(). You can refer the android documentation of AudioManager if you need anything else of the sort.
https://developer.android.com/reference/android/media/AudioManager.html
Hope I Helped :D
UPDATE
You can create a system to check if your app is in the foreground or background. This involves counting how many activities are paused. Add this to all your activities:
@Override
protected void onPause() {
    super.onPause();
    MainActivity.Pause++;
}

@Override
protected void onResume() {
    super.onResume();
    MainActivity.Pause--;
}

And in your MainActivty,
  if (Pause == NUMBER_OF_ACTIVITIES) {
      //PAUSE MUSIC HERE
  }

A: You could implement code that will track current activity in your app. (Good example: How to get current activity)
And stop music only when "current activity" is null.
PS: depending on your implementation of tracking current activity you might want to check current activity not onPause() right away but with some delay .

A: You have to use ActivityLifecycleCallbacks to tell if you app is in the foreground or background.
For example:
public class DummyActivityLifecycleCallbacks implements ActivityLifecycleCallbacks {
    @Override public void onActivityCreated(Activity activity, Bundle savedInstanceState) { }
    @Override public void onActivityStarted(Activity activity) { }
    @Override public void onActivityResumed(Activity activity) { }
    @Override public void onActivityPaused(Activity activity) { }
    @Override public void onActivityStopped(Activity activity) { }
    @Override public void onActivityDestroyed(Activity activity) { }
    @Override public void onActivitySaveInstanceState(Activity activity, Bundle savedInstanceState) { }
}

public class OnApplicationForegroundBackgroundEnterCallbacks extends DummyActivityLifecycleCallbacks {
    private Listener listener;
    private int activityStartStopCounter = 0;

    public interface Listener {
        public void onEnterForeground();
        public void onEnterBackground();
    }

    public OnApplicationForegroundBackgroundEnterCallbacks(Listener listener) {
        this.listener = listener;
    }

    @Override public void onActivityStarted(Activity activity) {
        if(++activityStartStopCounter == 1) listener.onEnterForeground();
    }

    @Override public void onActivityStopped(Activity activity) {
        if(--activityStartStopCounter == 0) listener.onEnterBackground();
    }
}

Then in Application.onCreate call:
registerActivityLifecycleCallbacks(new OnApplicationForegroundBackgroundEnterCallbacks(this));


text:
Q: What is difference between <%=%> and <%#%> All, As for the inline expression in asp.net ,I had some questions about them.

*

*What is the difference between them ?

*In what situation ,Which one is better?

By the way, I found below code the first one doesn't works , but second one works. Why?
<head runat="server">
    <title></title>
    <script src="<%#FullyQualifiedApplicationPath%>Scripts/jquery.js" type="text/javascript"></script>
</head><!--Not OK-->

<head runat="server">
    <title></title>
    <script src="<%=FullyQualifiedApplicationPath%>Scripts/jquery.js" type="text/javascript"></script>
</head><!--OK-->

FullyQualifiedApplicationPath is a variable defined in code behind. Thanks your review.

A: <%= %> is for loading variables
<%# %> is for databaind
Consult this post or this question for more info

A: <%=%> is the equivalent of Response.Write or for writing directly to the page (response), while <%# %> is used specifically for databinding.

A: <%#%> is used to bind some data or control by using BIND(read and write purpose) or EVAL(for readonly purpose).
Where as <%=%> is used to display the value of a session in a html page.

A: For example when u w3ant to bind data to a grid we use the following syntax
     <ItemTemplate>
       <asp:Label ID="lbl_Id" Text='<%# Bind("Id") %>' runat="server"></asp:Label>
     </ItemTemplate>

The above syntax is used to bind the data in the gridview
while the <%=%> You will be able to do c# coding in default. aspx page as well, here is the sample code.
To show some output on the page and do some coding over out there

  <%=Session["value"].ToString() %>

It will load the session value in the default page.


text:
Q: Operation Contract not working with WCF Test Client i am getting an error
this operation is not supported in wcf test client because it uses system.object

Heres my code screenshot for IService.cs:

heres my screenshot for reference.cs

but still i am getting this error ::

A: I don't think you can expose generic object in WCF service because server/client would not know how to deserialize your data.
You have to expose a definite class with [DataContract] attribute. See http://msdn.microsoft.com/en-us/library/ms733127.aspx
---- EDIT
Sorry, I was wrong. Don't worry. It's just not working with the WCF test client. Just write a simple console client to test it.


text:
Q: UseState not triggering re-render I have a state for my orders list. On the first update everything is working fine but when an update is made on the order in the database, my order list is updated but not triggering a re-render even using <...>

const [orders, setOrders] = useState([]);

  useEffect(() => {
    const unsubscribe = firebase.firestore()
      .collection("Orders")
      .orderBy("date", "desc")
      .limit(parseInt(limit, 10))
      .onSnapshot((snapshot) => {
        let oldOrders = orders;
        let addedOrders = []

        snapshot.docChanges().forEach((change) => {
          if (change.type === "added") {
            addedOrders.push({ ...change.doc.data(), id: change.doc.id })
          }
          if (change.type === "modified") {
            oldOrders[oldOrders.findIndex(x => x.id === change.doc.id)] = { ...change.doc.data(), id: change.doc.id }
          }
          if (change.type === "removed") {
            oldOrders.splice(oldOrders.findIndex(x => x.id === change.doc.id))
          }
        });
        if (addedOrders.length > 0) {
          oldOrders.unshift(addedOrders)
        }
        setOrders(...oldOrders);
      });
    return () => {
      unsubscribe()
    }
  }, [limit]);

A: You are mutating the state.

*

*let oldOrders = orders; does not create a copy of array. It copies reference.

*setOrders(...oldOrders); makes no sense. You are spreading array as arguments but setOrders accepts 1 argument.

*If your next state depends on the previous state you should use callback form of setState

*You need to have oldOrders.unshift(...addedOrders); if you want to add multiple items not just a single array.

Your code should look somewhat like this assuming the rest of your logic is correct.
useEffect(() => {
  const unsubscribe = firebase
    .firestore()
    .collection("Orders")
    .orderBy("date", "desc")
    .limit(parseInt(limit, 10))
    .onSnapshot((snapshot) => {
      // use callback form to avoid relying on stale state
      setOrders((orders) => {
        let oldOrders = [...orders]; // create new array
        let addedOrders = [];

        snapshot.docChanges().forEach((change) => {
          if (change.type === "added") {
            addedOrders.push({ ...change.doc.data(), id: change.doc.id });
          }
          if (change.type === "modified") {
            oldOrders[oldOrders.findIndex((x) => x.id === change.doc.id)] = {
              ...change.doc.data(),
              id: change.doc.id,
            };
          }
          if (change.type === "removed") {
            oldOrders.splice(
              oldOrders.findIndex((x) => x.id === change.doc.id)
            );
          }
        });
        if (addedOrders.length > 0) {
          oldOrders.unshift(...addedOrders);
        }

        return oldOrders;
      });
    });
  return () => {
    unsubscribe();
  };
}, [limit]);


text:
Q: how can I create a new column with two columns combination? i want a new column that contains the amount of times user_id and artist_id are the same, for example if user_id = 0, and artist_id = 10, and it happens 5 times, i want to store number 5 in a column in the 5 rows in which this occurs.
This code gives me the value, but I can't store it.
treino.groupby(['user_id', 'artist_id']).count()

A: IIUC you need a column that represents the size of each group in each row. Then you need to use groupby.transform.
df["group_size"] = (
    df.assign(group_size=1)
    .groupby(["user_id", "artist_id"])["group_size"]
    .transform("count")
)


text:
Q: How Can I Pass Data from Array in didLoadObjects to cellForRowAtIndexPath So, I'm using RestKit to access a webservice and retrive data from there.
So far I have two views, and that part of retrieving the data is fine, and I get the 100 objects I need, saving them into an array called "songs".
Here is didLoadObjects:
- (void)objectLoader:(RKObjectLoader*)objectLoader didLoadObjects:(NSArray*)objects {
    NSLog(@" Reached didLoadObjects: %d", [objects count]);

    self.songs = objects;
    NSLog(@"%@",self.songs);
}

Ok, I have two views, and the problem is, of course, on the second one. I'm using Storyboards. I gave the tableView cell an identifier called "TopListCellIdentifier".
So, I get the objects, all the 100 of them are "printed" in the command line, but the problem starts when I try to access the data from the array inside cellForRowAtIndexPath, something which has to be done because I have a custom tableViewCell displaying the info I need (sons, artists, covers, stuff like that). So, when I start the app, the first view is fine, but the second has 100 cells, but no info. Here is the cellForRowAtIndexPath code.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *TopListCellIdentifier = @"TopListCellIdentifier";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:TopListCellIdentifier];

    // Loading the Cover Images in the Background
    // Cover Image: Tag 1
    [((HJManagedImageV*)[cell viewWithTag:1]) clear];
    HJManagedImageV* thumbImage = ((HJManagedImageV*)[cell viewWithTag:1]);
    NSString *thumbUrl = [[self.songs objectAtIndex:[indexPath row]] thumbnail];

    thumbImage.url = [NSURL URLWithString:thumbUrl];
    [[ImageHandler sharedHandler].imgManager manage:thumbImage];

    //Song and Artist: Tag 2 and 3
    ((UILabel*)[cell viewWithTag:2]).text = [[self.songs objectAtIndex:[indexPath row]] title];
    ((UILabel*)[cell viewWithTag:3]).text = [[self.songs objectAtIndex:[indexPath row]] artist];

    //Arrow Up/Down/Same: Tag 4
    //TODO

    //Position Number: Tag 5
    ((UILabel*)[cell viewWithTag:5]).text = [NSString stringWithFormat:@"%d.", [indexPath row]+1];

    return cell;
}

I've tried to put a debugger in the first line of cellRow(...) but the program doesn't enter there. I feel like i'm forgetting about something very simple, but I can't seem to figure out what.
Can someone help me, please?

A: You're never initing a new cell.  You need to add a line like :
if (nil == cell)
    cell = [[UITalbeViewCell alloc] init...

after your call to
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:TopListCellIdentifier];


text:
Q: Limit numbers of login I want to create the limit login based on the udid of the devices. For example users only can login with 2 different devices at the same time. this what i did, but is not working to lock the 3rd users when login
    // Get the email and password
$email       = CParam::paramPost('email');
$firstpassword    = CParam::paramPost('password');
$password    = md5(CParam::paramPost('password'));
$udid        = CParam::paramPost('udid');
$app_id      = CParam::paramPost('app_id');
$app_version = CParam::paramPost('app_version');

// Make sure we have a UDID
if (empty($udid)) {
    sendJsonError('UDID parameter is missing');
    return;
}

// Check if the user is entitled
$sql    = 'SELECT * FROM accounts WHERE email = :email AND password = :password';
$params = array('email' => $email, 'password' => $password);
$account   = $db->fetchOne($sql, $params);
if (!$account) {
    sendJsonError('We could not find your subscription.');
    return;
}

// The account was found, generate an successs token if not existing yet
if (empty($account['success_token'])) {
    $success_token = CGuid::create();
    $db->update(
        'accounts',
        array('success_token' => $success_token),
        'id = :id',
        array('id' => $account['id'])
    );
} else {
    $success_token = $account['success_token'];
}

// Register the device
$db->insertOrUpdate(
    'devices',
    array(
        'account_id'  => $account['id'],
        'udid'        => $udid,
        'app_id'      => $app_id,
        'app_version' => $app_version,
    )
);

Thanks


text:
Q: with index, returns different result Never seen this before. Running the same query, 1 forces an index. Without the index, the results are incorrect (in wrong order), with the index the results are in the correct order. Only problem with using the index is that its slower for some reason. Index is on comment_id and user_id
without index:
SELECT DISTINCT topic_id FROM comments
WHERE user_id=9384
AND (status = 1 or status = 0)
ORDER BY comment_id DESC LIMIT 15

with index:
SELECT DISTINCT topic_id FROM comments force index(index_comment_user)
WHERE user_id=9384
AND (status = 1 or status = 0)
ORDER BY comment_id DESC LIMIT 15

Any ideas? I really want to get the correct order without slowing the query down. I would have throught an index would have done that.
Here is the SQL structure.
CREATE TABLE  `db`.`comments` (
  `comment_id` int(10) unsigned NOT NULL auto_increment,
  `old_comments_id` mediumint(8) unsigned default NULL,
  `user_id` mediumint(8) unsigned default NULL,
  `content` text character set latin1,
  `status` tinyint(3) unsigned default NULL,
  `added_date` datetime default NULL,
  `category_id` tinyint(3) unsigned default NULL,
  `helpful` tinyint(3) unsigned default NULL,
  `modified_date` datetime default NULL,
  `topic_id` mediumint(8) unsigned default NULL,
  `last_mod_user_id` mediumint(8) unsigned default NULL,
  PRIMARY KEY  USING BTREE (`comment_id`),
  KEY `Index_user_id` (`user_id`),
  KEY `Index_added_date` (`added_date`),
  KEY `Index_comments_status` USING BTREE (`status`),
  KEY `Index_user_activity` USING BTREE (`comment_id`,`user_id`),
  KEY `Index_user_activity2` USING BTREE (`user_id`,`topic_id`),
  KEY `Index_question_id` USING BTREE (`topic_id`,`status`),
  KEY `Index_user_activity3` (`user_id`,`status`,`topic_id`,`comment_id`)
) ENGINE=InnoDB AUTO_INCREMENT=2040237 DEFAULT CHARSET=utf8;

A: Your use of DISTINCT together with an ORDER BY on a column you are not selecting will give you problems. Try using a GROUP BY instead:
SELECT topic_id, MAX(comment_id) AS comment_id
FROM comments
WHERE user_id=9384 AND status IN (0, 1)
GROUP BY topic_id
ORDER BY comment_id DESC
LIMIT 15

You shouldn't need to force the index. Just add the correct index and it should be used automatically. You might want to try different combinations and ordering of the columns in the index to see which works best.

A: The manual says

If the table has a multiple-column index, any leftmost prefix of the index can be used by the optimizer to find rows. For example, if you have a three-column index on (col1, col2, col3), you have indexed search capabilities on (col1), (col1, col2), and (col1, col2, col3).

i.e. I think you need an index on user_id, column_id for your query - it doesn't sound like mysql can use column_id, user_id. You should run EXPLAIN SELECT on both of the queries to verify this.
Why it goes wrong with the other index I don't know sorry.

A: This is the common "max per group" problem, and usually it is solved like this:
SELECT
  comment.user_id,
  comment.topic_id,
  comment.comment_id
FROM
  comment
  INNER JOIN (
      SELECT user_id, topic_id, MAX(comment_id) AS comment_id
        FROM comments
    GROUP BY user_id, topic_id
  ) AS max ON max.comment_id = comment.comment_id
WHERE
  comment.user_id = 9384
  AND comment.status IN (1, 0)
ORDER BY
  comment.comment_id DESC


text:
Q: Only keep .csv column containing X Y Z data? How can I keep .csv line data that only contains the words dog or cat and only check for them on the second column, if the word "dog" appears on any other column but not the 2nd then it should be ignored.
For example if I had:
email1.com dog
email2dog.com steve
email3.com cat

Expected output:
email1.com dog
email3.com cat

There maybe a long list of words to keep so if possible load them from another file.

A: With sed:
$ sed -n -e 's/dog$/&/p' -e 's/cat$/&/p' file
email1.com dog
email3.com cat

Or you can use awk:
awk '$2~/^dog|cat$/' file

A: A few approaches:

*

*If the dog or cat is always the last word on the line:
awk '/(dog|cat)$/' file
grep -E '(dog|cat)$' file
sed -n '/\(dog\|cat\)$/p' file
perl -ne 'print if /(dog|cat)$/' file

*If the dog or cat can be anywhere in the second space-delimited field:
awk '$2~/dog|cat/' file
grep -E '^\S+\s+\S*(dog|cat)\S*\s*' file
perl -ane 'print if $F[1]=~/dog|cat/' file
sed -nr '/^\S+\s+\S*(dog|cat)\S*\s*/p' file
sed -n '/^\S\+\s\+\S*\(dog\|cat\)\S*\s*/p' file

*To read the search patterns from a file, you can do:
awk '{if(NR==FNR){a[$0]++; next}for(p in a){if($2~p){print}}}' patterns  file

A: {   sed 's/[]$^&\./*[]/\\&/g;s/$/$/'|
    grep -f- ./greppedfile
}   <words

Would handle the case where you're dealing with a lot of match patterns in words which contained a pattern per line. It takes care to escape any possible regexp metacharacters and then anchors the resulting pattern - at the tail of the line - so any character in words will be matched literally by grep and its pattern will only be matched if word occurs at the tail of a line - which is what I think I understand is wanted.
Usually with grep we don't have the metachar escapes like that because we can use -Fixed-string patterns - which don't have any. But, that also means, we can't use the $ metachar to anchor the pattern, so we work with what we got.

A: I'd do it like this in perl:
#!/usr/bin/perl;
use strict;
use warnings;

my @words      = qw ( dog cat );
my $column_num = 1;                #perl starts arrays zero.

my $regex = join( "|", map {quotemeta} @words );
$regex = qr/$regex/;

while (<>) {
    print if ( split() )[$column_num] =~ $regex;
}

You 'load' a regular expression with @words - qw is simply 'quoted words' e.g. space delimited. You turn that into a regular expression.
Then using the diamond operator <> which either reads from <STDIN> or opens files as listed on the command line (so cat $file | ./myscript.pl or ./myscript.pl <filename> ) - we then read each line.
We check for the presence of that regular expression in the designated column number (split splits on whitespace by default).

A: Using grep with PCRE:
$ grep -P '^[^ ]+\s+dog|cat(?=\s|$)' file.txt
email1.com dog
email3.com cat

This will print the lines where dog or cat appears only on the second column of the line.


text:
Q: iOS UIPageViewController - Attempt to present X on Y whose view is not in the window hierarchy I have multiple VC and it looks like ,
What happens is:

*

*Data loads in Splash View Controller

*After loading modal segue from Splash View Controller to Root View Controller

*Root View Controller is from the Apple's example UIPageViewController which loads bunch of pages (Data View Controller)

*From those pages there is modal segue to Other View Controller

*From Other View Controller, it is possible to go back to Splash View Controller to load more data

Do I need to provide some other parameters along with this to get rid of the warning?
[self performSegueWithIdentifier:@"splashToRoot" sender:self];


text:
Q: Barcode font not loading dynamically in MS Word when generating RTF from Java using iText I am using iText API to generate RTF using Java.  The RTF file is generated fine but one requirement is adding a barcode. What i did is:
FontFactory.register("c:\\windows\\fonts\\FREE3OF9.ttf", "Free 3 of 9 Extended");
return FontFactory.getFont("Free 3 of 9 Extended",20, Font.NORMAL, Color.BLACK);

I tried loading other fonts; that was working fine, but it doesn't work when I use the barcode font (FREE3OF9.ttf).
The RTF file is generated but the the "Font name" looks like "New" instead of "Free 3 of 9 Extended" in MS Word when I open it. When I select the words and choose the font name, the barcode appears fine.
I think there is a problem with Free 3 of 9 Extended Font.

A: Odd.  I don't really have The Answer, but I can certainly offer some advice.

*

*Check the return value from getFont(...).  It's entirely possible that the problem is in registration, and you're just getting back a default font.  I don't see why it'd be called "New", but definitely worth checking.

*If that's not the problem, have a look at your raw RTF output.  Is the font in question really "New" or is MS mangling it on the way in?

*

*Check MS's RTF output when you manually pick the font vs your own.

*Get the iText source, step through it, see what's wrong.

The source link is to iText v2.1.7, the last version that supported RTF.  The guy who worked on it vanished into the web some time prior to that, so we stopped supporting it with 5.0 (along with the licensing change, package rename, and so forth).


text:
Q: Board game: steady state probability of being in starting location (GO) Considering a board game which has 20 positions only. There are 2 fair dice that can be rolled and the player moves in a clockwise position over the board positions. Considering that the dice are fair and player moves around the board as per the dice roll, how can I compute the steady state probability of being in the starting location (GO i.e. the bottom right position)?
I am thinking that since the average dice roll sum is 7, so the steady state probability of being in any position on the board is $\frac{1}{7}$. Therefore it would be the same for the starting location as well. However, I am not sure. Any help would be appreciated. Thank you.

A: The probability of being on any square at all is the sum of the probabilities of being on the particular squares. Thus, if your result $\frac17$ were correct, the probability of being on any square at all would have to be $\frac{20}7$. It is in fact $1$, so the probability of being on any particular square is ...?
Note that this probability has nothing to do with how many dice you roll or their average; it depends only on the number of squares.


text:
Q: Samba erases content of files when saving Samba SMB share hosted on Debian "Jessie" in a private home network setup.
Can connect to share, open files and copy files to / from share OK.
Attempting to make any changes to a file on the share (example: edit a text document) results in ALL CONTENT OF THE FILE ERASED. File itself remains on share but with file size of 0.
Shared directory on the server has permissions 775.
Have tried chown combinations of root:root and root:users without success.
Settings smb.conf for share sets both writable=yes and browsable=yes. Have tried combinations of force user, force group and create mask without success.
Using:
security = user
encrypt passwords = true
obey pam restrictions = yes
unix password sync = yes

EDIT:
I seem to have narrowed down the issue to Leafpad, specifically. Other apps seem to be able to edit documents on the share OK. Ironically, I was using Leafpad as the simplest tool to test opening and editing.

A: One of the few reasons for a file being truncated unexpectedly is lack of disk space.
It would be worth confirming the amount of available disk space using df -h. For example, if the share is hosted on /home/share then the command df -h /home/share will provide the necessary information.
$ df -h /home/share
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1        15G   12G  2.1G  85% /

In this example there is 85% used, so 15% available on the root partition hosting /home/share.
Typically 5% of the available disk space is reserved for root, so unless there is at least this amount of disk space files cannot be created or extended except by the root user. (Samba does not generally write files with root ownership.)

A: This is a known bug:

*

*Bug #708829 "Text truncated when I save a txt file during a sftp..." : Bugs : leafpad package : Ubuntu has a number of dups linked to it and provides further links

*#680418 - gvfs-fuse: Wrongly sucessful posix fwrite call on a gvfs sftp mount can lead to data loss - Debian Bug report logs + 1295007 – Non-GIO (POSIX) API call to save data truncates file to 0 bytes. suggest a cause at a deeper level, but apparently, Leafpad is one of only a few applications where the bug triggers


text:
Q: Can I build my jQuery promise pipe chain without using eval()? I need a promise pipe chain which for this example looks like this:
populateOfferSettings().pipe(populateSegmentationSettings).pipe(populateHousehold).pipe(viewReady);

This is generated dynamically and could contain many functions, provided as an array. I've figured out a way of doing this but it relies on eval(). User input isn't a factor here as this function is only used by developers to manage presenting views so I don't feel too bad about using it (I understand the pitfalls), but I'd feel better not doing so.
Here's my code:
//Array of functions (generally provided as a function parameter)
var requiredFunctions = [
    'populateOfferSettings',
    'populateSegmentationSettings',
    'populateHousehold'
];

//Start building code string to evaluate later, starting with first required function
var code = requiredFunctions[0] + '()';

//Process each required function after first
$.each(requiredFunctions.slice(1), function (index, functionName) {
    //Add function to code string using pipe()
    code += '.pipe(' + functionName + ')';
});

//Add viewReady() to code string as this should always be at the end
code += '.pipe(viewReady);';

//Evaluate code string
eval(code);

Is there another way of handling piping of functions that would eliminate the need for eval() without making this much more verbose? It seems like there should be but I'm finding it difficult to get my head around jQuery's promise functionality, especially as I'm currently limited to jQuery 1.7.1 before the documentation and functionality of these things were changed.

A: Per conversation below with @AnthonyGrist:
var code = requiredFunctions[0]();

for (var i=1; i<requiredFunctions.length; i++)
   code = code.pipe(window[requiredFunctions[i]]);

if the requiredFunctions are strings, and defined in window scope.

And code = code.pipe(requiredFunctions[i]); if they are functions.
Was also thinking about using code = code.pipe(new Function(requiredFunctions[i])) but that's practically the same as window approach. (only the scopes will change, sheesh...)


text:
Q: Should docker container have a OS distro? I am new to docker and following many tutorials. I came to know that we can include any thing (db, server etc) in docker container. However, I saw in many tutorials that docker image files have a "FROM some OS distro" (I know that this distro is not a complete OS, but provides the utilities, processes of the distro).  My question is that:
should always a container have a OS distro ?
If yes, why? (Can't the rest of components (For instance: java vm) run on the kernel ?),
If no: what are the ramifications? Or what could be the best practice in general ?
(I am from Java background)

A: Every docker image you define must have a FROM clause becuase it needs to be based on another image. You can create your own base image but imo you should not need it. An image is nothing more than a collection of binaries you can use in your container created from your image. There are lots of images available on docker hub, whereby best pratice is to keep the images as small as possible. Therefore I would recommend base images based on alpine.
https://hub.docker.com/_/openjdk
If you really need an own base image take a look here
https://docs.docker.com/develop/develop-images/baseimages/
and also on the linked stackoverflow article of the comment.
Processes of docker containers always use the kernel of the docker host, therefore the docker images need to be compatible with the kernel of the host running the containers. A docker conttainer is nothing more than an isolated process running on the host, there is no special runtime. If a java process is running in a container its actually running on the host and you can see it when you list the host processes on the docker host.


text:
Q: Where did my backslashes go? I have a JSON structure, escaped inside another JSON structure, escaped inside another JSON structure.
cat shows the file contents just fine:
 cat test.json
{
  "payload": "{\"data\":\"{\\\"nested\\\":1}\"}"
}

I want to assign this to a variable in zsh.
But I am finding that my every attempt to return the cat output from a subshell, gives me the wrong number of backslashes.
 X="$(cat test.json)"
 echo "$X"
{
  "payload": "{\"data\":\"{\\"nested\\":1}\"}"
}

 echo $(cat test.json)
{ "payload": "{\"data\":\"{\\"nested\\":1}\"}" }

 echo $(<test.json)
{ "payload": "{\"data\":\"{\\"nested\\":1}\"}" }

Where did my backslashes go? Can I get them back?
I am using zsh 5.2 (x86_64-apple-darwin16.0).

A: The variable is being set to the correct value. You are either using dash, not bash, or your bash shell has the xpg_echo option set. The zsh built-in echo, though, behaves according to the POSIX specification, which replaces certain escaped characters. Try using printf instead:
$ printf '%s\n' "$X"
{
  "payload": "{\"data\":\"{\\\"nested\\\":1}\"}"
}


text:
Q: How to append component to body but communicate with parent? I am trying to do modals in VueJS 2.0.
My goal is to call it from wherever in DOM is it possible and render component as child of body but communicate with component where it was initialized.
What I have tried is:
...
mounted () {
   document.getElementsByTagName('div')[0].appendChild(this.$el);
}
...

Which of course renders element where I want it to be rendered and also communicate with component where it was initialized. But when I try to remove it... I get:
DOMException: Failed to execute 'insertBefore' on 'Node': The node before which the new node is to be inserted is not a child of this node.

The way I show / hide model in component where modal is initialized including parameter visible: true / false and then:
<modal v-if="visible"></modal>

Any ideas?


text:
Q: How would I use the header command in the Cloud 9 IDE to redirect someone after their forms are validated? I am using the Cloud 9 IDE and I had created the registration page would like to redirect the user once they submit their registration credentials. I am trying to do this by using the header method in PHP. However, I don't know if I can use this or would I have to work around it due to the URL they provide you with for your website. For example, the URL would be, "https://example-user.c9users.io/register.php" and the header I am trying to use is:
header("Location:https://vomica-porixify.c9users.io/home.php");
The main problem is that it won't work and I can't figure out why. I don't know if this due to the links you are given or if my registration page is broken.
Here is register.php
<?php

    $pageTitle = "Sign Up";
    $section = "signing";

?>

<?php include 'INC/header.php'; ?>

 Register

                    <form class="form-horizontal" role="form" acion="process.php" method="post">

                             Username

                                <input type="text" class="form-control" id="inputUser" placeholder="Username">

                             E-Mail

                                    <input type="email" class="form-control" id="inputEmail" placeholder="E-Mail">

                             Password

                                <input type="password" class="form-control" id="inputPassword" placeholder="Password">

                                <button type="submit" class="btn btn-primary"> Register </button>

                                <button type="button" class="btn btn-info"> User Login </button>

                        <?php include 'INC/redirect.php' ?>

                    </form>

<?php include 'INC/footer.php' ?>

and here is my redirect.php
<?php $pageTitle = "Redirected"; ?>

<?php include 'INC/header.php' ?>

<?php

    if(isset($_GET['submit'])) {

        // Fetches variables from the form
        $username = $_GET['inputUser'];
        $email = $_GET['inputEmail'];
        $password = $_GET['inputPassword'];

        if(inputUser !='' && inputEmail !='' && inputPassword !='')
        {

            // Redirects to the page
            header("Location:https://vomica-porixify.c9users.io/home.php");

        } else {
            ?>
 <?php echo 'Please fill out all the fields!'; ?>
 <?php
        }

    }

?>

<?php include 'INC/footer.php' ?>

A: When you use header() you should remember that:

header() must be called before any actual output is sent, either by normal HTML tags, blank lines in a file, or from PHP. It is a very common error to read code with include, or require, functions, or another file access function, and have spaces or empty lines that are output before header() is called. The same problem exists when using a single PHP/HTML file.

In your code, when you submit the form, there is a post request to call your process.php file, you can write some register code here and user header() to redirect:
//process.php

// Register code
...

// Redirect
header("Location: http://www.example.com/home");
// Make sure that code below does not get executed when we redirect.
exit;


text:
Q: pyclustering: intended method of initializing kmeans On wikipedia, there is a description of how to initialize the kmeans cluster locations according to a random method.
In pyclustering, a python clustering library, the various clusters are implemented with a high performance c-core.  This core is faster than numpy/sklearn, so I want to avoid implementing anything in sklearn/numpy (or else I might lose the speedy feel of the code right now).
However, the kmeans class requires an initial cluster location list to get going.  What is the intended method of initializing these cluster locations in pyclustering?

A: There is automatically generated pyclustering documentation where API of kmeans algorithm is described.
For example, you have a 2D-data where two clusters should extracted, then you need to specify initial centers (pyclustering doesn't generate initial centers they should be provided by user):
kmeans_instance = kmeans(sample, [ [0.0, 0.1], [2.5, 2.6] ], ccore = True);

Where [0.0, 0.1] is a initial center on the first cluster and [2.5, 2.6] is a initial center of the second. Flag 'ccore = True' is for CCORE library usage.
Run processing:
kmeans_instance.process();

Obtain clustering result:
clusters = kmeans_instance.get_clusters(); # list of clusters
centers = kmeans_instance.get_centers(); # list of cluster centers.

Visualize obtained result:
visualizer = cluster_visualizer();
visualizer.append_clusters(clusters, sample);
visualizer.append_cluster(start_centers, marker = '*', markersize = 20);
visualizer.append_cluster(centers, marker = '*', markersize = 20);
visualizer.show();

Click here to see example of result visualization
Usage examples can be found in: 'pyclustering/cluster/example/kmeans_examples.py'
$ ls pyclustering/cluster/examples/ -1
__init__.py
agglomerative_examples.py
birch_examples.py
clarans_examples.py
cure_examples.py
dbscan_examples.py
dbscan_segmentation.py
general_examples.py
hsyncnet_examples.py
kmeans_examples.py  <--- kmeans examples
kmeans_segmentation.py
kmedians_examples.py
kmedoids_examples.py
optics_examples.py
rock_examples.py
somsc_examples.py
syncnet_examples.py
syncsom_examples.py
syncsom_segmentation.py
xmeans_examples.py


text:
Q: Adding new signature by reatining existing unsigned signature fields using PDFBox I want to sign PDF which has signature fields in it already. I need to add new signature field retaining existing unsigned signature fields. After signing such PDFs, I see that  new signature field added by code is always invalid.  Says 'document has been altered'.
Below code being used to compute hash of the document:
private DocumentSignatureStructure createSignatureStructureAndComputeHash(byte[] inputFile, File tempFile,
                                                                              SignatureProperties sigProperties)
            throws IOException, NoSuchAlgorithmException {

        try (FileOutputStream fos = new FileOutputStream(tempFile);
             PDDocument doc = PDDocument.load(inputFile);
             SignatureOptions signatureOptions = new SignatureOptions();) {

            signatureOptions.setPreferredSignatureSize(SignatureOptions.DEFAULT_SIGNATURE_SIZE * 2);
            signatureOptions.setPage(sigProperties.getPage() - 1);
            if (sigProperties.isVisibleSignature()) {
                PDRectangle rect = createSignatureRectangle(doc, sigProperties);
                signatureOptions.setVisualSignature(createVisualSignatureTemplate(doc, rect, sigProperties));
            }

            PDSignature signature = new PDSignature();
            signature.setFilter(PDSignature.FILTER_ADOBE_PPKLITE);
            signature.setSubFilter(PDSignature.SUBFILTER_ADBE_PKCS7_DETACHED);
            signature.setSignDate(Calendar.getInstance());
            doc.addSignature(signature, signatureOptions);
            ExternalSigningSupport externalSigning = doc.saveIncrementalForExternalSigning(fos);

            MessageDigest digest = MessageDigest.getInstance(sigProperties.getHashAlgorithm().getAlgoName());
            byte[] hashBytes = digest.digest(IOUtils.toByteArray(externalSigning.getContent()));
            String base64Hash = Base64.toBase64String(hashBytes);
            externalSigning.setSignature(new byte[0]);
            int offset = signature.getByteRange()[1] + 1;
            IOUtils.closeQuietly(signatureOptions);
            return DocumentSignatureStructure.builder().offset(offset)
                    .hashValue(base64Hash)
                    .build();
        }
    }

Embedding signature code:
byte[] originalDocumentByte = docBlob.getBytes(1L, (int) docBlob.length());
            File file = new File(getTempFolderPath(), getTempFileName("signed"));
            try (FileOutputStream fos = new FileOutputStream(file);) {
                fos.write(originalDocumentByte);
            }
            try (RandomAccessFile raf = new RandomAccessFile(file, "rw")) {
                raf.seek(documentSignatureStructure.getOffset());
                raf.write(Hex.getBytes(Base64.decode(encodedSignature)));
            }
            Blob signedAndLtvBlob;
            try (PDDocument doc = PDDocument.load(file);
                 FileOutputStream fos = new FileOutputStream(file);
                 FileInputStream fis = new FileInputStream(file)) {
                if (createDss) {
                    log.info("Adding revocation information to DSS dictionary of PDF");
                    makeLtv(doc, revocationData);
                }
                doc.saveIncremental(fos);
            }

It did not work with above code.
Googled up and saw few solutions where COSObject 'NeedToBeUpdated' flag needs to be set to true.
Added below code block before adding new signature fields in above code.
//..
if (sigProperties.isVisibleSignature()) {
                PDRectangle rect = createSignatureRectangle(doc, sigProperties);
                signatureOptions.setVisualSignature(createVisualSignatureTemplate(doc, rect, sigProperties));
            }

            PDAcroForm acroForm = doc.getDocumentCatalog().getAcroForm();
            COSDictionary catalogDictionary = doc.getDocumentCatalog().getCOSObject();
            catalogDictionary.setNeedToBeUpdated(true);
            COSDictionary acroFormDictionary = (COSDictionary) catalogDictionary.getDictionaryObject(COSName.ACRO_FORM);
            acroFormDictionary.setNeedToBeUpdated(true);
            COSArray array = (COSArray) acroFormDictionary.getDictionaryObject(COSName.FIELDS);
            array.setNeedToBeUpdated(true);
            for (PDField field : acroForm.getFieldTree()) {
                if (field instanceof PDSignatureField) {
                    COSDictionary fieldDictionary = field.getCOSObject();
                    COSDictionary dictionary = (COSDictionary) fieldDictionary.getDictionaryObject(COSName.AP);
                    dictionary.setNeedToBeUpdated(true);
                    COSStream stream = (COSStream) dictionary.getDictionaryObject(COSName.N);
                    stream.setNeedToBeUpdated(true);
                    while (fieldDictionary != null)
                    {
                        fieldDictionary.setNeedToBeUpdated(true);
                        fieldDictionary = (COSDictionary) fieldDictionary.getDictionaryObject(COSName.PARENT);
                    }
                }
            }

            PDSignature signature = new PDSignature();
            signature.setFilter(PDSignature.FILTER_ADOBE_PPKLITE);
            signature.setSubFilter(PDSignature.SUBFILTER_ADBE_PKCS7_DETACHED);
//..

Even this did not work.
Resulting PDF shows signature is invalid:

PDF used for signing with signature fields:

Whats the piece I am missing here?
PDF file : https://drive.google.com/file/d/1-vu9_WIfFo198v6AxoBMxCuyX1rE2FOS/view?usp=share_link
Signed PDF (invalid): https://drive.google.com/file/d/1DD0aKVkonH9a_CfGrj9mACe6DBt4Ijsj/view?usp=share_link

A: Something indeed damaged your file, and it's apparently not the code you show.
Comparing your signed file "Formulier DSS-01 - DC+QV Onboarding Checklist-signed.pdf" with your original "Formulier DSS-01 - DC+QV Onboarding Checklist.pdf", one sees that the former is not simply the latter with incremental updates as one would expect but that some regions in that file part have been overwritten with zeros.
The regions in question are from 0x2c000-0x2cfff and 0x40000-0x40fff.
After fixing this issue by copying the contents from those regions of the original file into the signed file, Adobe Acrobat validates the signature positively.
So you should try and find out what zeroed those two 4KB regions in your file.

A: I was looking for mistake in code for generating hash of the document.
But the issue actually was with the way file streams were used to write CMSSignedData and adding DSS dictionary for making signing PDF LTV.
Using same File for loading and writing was causing some parts of file getting overwritten by zeros.
Below piece of code for embedding external signature solved my issue.
Blob docBlob = documentSignatureStructure.getReadyDocument();
byte[] originalDocumentByte = docBlob.getBytes(1L, (int) docBlob.length());
File signedFile = new File(getTempFolderPath(), getTempFileName("signed_"));
try (FileOutputStream fos = new FileOutputStream(signedFile)) {
    fos.write(originalDocumentByte);
}
try (RandomAccessFile raf = new RandomAccessFile(signedFile, "rw")) {
    raf.seek(documentSignatureStructure.getOffset());
    raf.write(Hex.getBytes(Base64.decode(encodedSignature)));
}

File signedLtvFile = new File(getTempFolderPath(), getTempFileName("signedLtv_"));
try (PDDocument doc = PDDocument.load(signedFile);
     FileOutputStream fos = new FileOutputStream(signedLtvFile)) {
    if (createDss) {
        log.info("Adding revocation information to DSS dictionary of PDF");
        makeLtv(doc, revocationData);
        doc.saveIncremental(fos);
    }
}

Blob signedAndLtvBlob;
try (FileInputStream fis = new FileInputStream(signedLtvFile)) {
    signedAndLtvBlob = new javax.sql.rowset.serial.SerialBlob(fis.readAllBytes());
}

Files.delete(signedFile.toPath());
log.debug("temp signed file {} deleted successfully", signedFile.getName());
Files.delete(signedLtvFile.toPath());
log.debug("temp ltv signed file {} deleted successfully", signedLtvFile.getName());
return signedAndLtvBlob;