text:
Q: Сайт дергается вниз после загрузки и при проигрывании первой анимации Проблема в том, что при загрузке сайта проигрывается несколько аннимаций одновременно и какая-то из них сдвигает сайт вниз пока не проигается . Смотрите сайт через ф12 поскольку сайт не адаптивный. Только в разрешении 1920х1080. Заранее спасибо !!!

html {
  box-sizing: border-box;
}

*,
*::before,
*::after {
  box-sizing: inherit;
}

body {
  font-family: 'Inter';
  font-style: normal;
  font-size: 16px;
  font-weight: normal;
  color: #FAFAF9;
  position: relative;
}

.custom-btn {
  padding: 24px 74px;
  color: #fff;
  border-radius: 10px;
  padding: 10px 25px;
  background: transparent;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  display: inline-block;
  box-shadow: inset 2px 2px 2px 0px rgba(255, 255, 255, .5), 7px 7px 20px 0px rgba(0, 0, 0, .1), 4px 4px 5px 0px rgba(0, 0, 0, .1);
  outline: none;
}

/*Header styles start*/

.header {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 2;
  background: #0C0B0B;
}

.header_wrapper {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  padding-top: 54px;
  padding-left: 6px;
}

.wrapper {
  max-width: 1520px;
  margin: 0 auto;
}

.header_list {
  margin-left: 330px;
  left: 0;
  display: flex;
  flex-wrap: wrap;
  padding-bottom: 16px;
}

.header_item {
  margin-right: 46px;
}

.header_item:last-child {
  margin-right: 0px;
}

.header_link {
  font-size: 26px;
  line-height: 31px;
  color: #FAFAF9;
  text-decoration: none;
}

.header_link:hover,
.header_link:focus,
.header_link:active {
  opacity: .75;
  text-decoration: underline;
}

/*Header styles end*/

/*Intro styles start*/

.intro {
  /*min-height: 100vh;*/
  min-height: 944px;
  background: #0C0B0B;
  padding-top: 250px;
}

.intro_main {
  padding-left: 50px;
}

.intro_title {
  display: block;
  position: relative;
  letter-spacing: -2px;
  color: black;
  -webkit-text-stroke-width: 2px;
  -webkit-text-stroke-color: #FFFFFF;
  font-weight: 900;
  font-size: 150px;
  font-family: 'Roboto';
  min-height: 132px;
}

.intro_title_bottom {
  display: block;
  font-family: 'Roboto';
  font-weight: 900;
  max-width: 1028px;
  font-size: 146px;
  line-height: 154px;
  letter-spacing: 2px;
  color: #FAFAF9;
  border: 1px solid #000000;
}

.intro_sub_title {
  display: block;
  margin-top: 66px;
  min-width: 587px;
  font-weight: 400;
  font-size: 20px;
  line-height: 24px;
  letter-spacing: 0.5px;
  color: rgba(239, 237, 232, 0.65);
}

.intro_title span {
  opacity: 0;
  animation-delay: 1.4s;
  display: block;
  animation: textAnimate 1.5s cubic-bezier(1, 1, 0, 0) forwards;
}

@keyframes textAnimate {
  0% {
    transform: translateY(-100px);
    opacity: 0;
  }
  50% {
    transform: translateY(-50px);
    opacity: 0.5;
  }
  100% {
    transform: translateY(0);
    opacity: 1;
  }
}

.intro_title_bottom span {
  opacity: 0;
  animation-delay: 0.7s;
  display: block;
  animation: textAnimate_bot 1.5s cubic-bezier(1, 1, 0, 0) forwards;
}

@keyframes textAnimate_bot {
  0% {
    transform: translateY(-200px);
    opacity: 0;
  }
  50% {
    transform: translateY(-100px);
    opacity: 0.5;
  }
  100% {
    transform: translateY(0);
    opacity: 1;
  }
}

.btn-5 {
  margin-top: 54px;
  padding: 24px 74px;
  font-size: 26px;
  line-height: 42px;
  border: none;
  background: #E6533C;
  ;
  background: linear-gradient(0deg, rgba(255, 27, 0, 1) 0%, rgba(251, 75, 2, 1) 100%);
}

.btn-5:hover {
  color: #f0094a;
  background: transparent;
  box-shadow: none;
}

.btn-5:before,
.btn-5:after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  height: 2px;
  width: 0;
  background: #f0094a;
  box-shadow: -1px -1px 5px 0px #fff, 7px 7px 20px 0px #0003, 4px 4px 5px 0px #0002;
  transition: 400ms ease all;
}

.btn-5:after {
  right: inherit;
  top: inherit;
  left: 0;
  bottom: 0;
}

.btn-5:hover:before,
.btn-5:hover:after {
  width: 100%;
  transition: 800ms ease all;
}

.foto_trener {
  position: absolute;
  margin-left: 904px;
  top: 0;
  right: 0;
  z-index: 1;
  margin-top: 167px;
}

.foto_trener img {
  opacity: 0;
  animation-delay: 0.7s;
  animation: foto_trenerAnimation 1.5s cubic-bezier(0, 0, 1, 1) forwards;
}

@keyframes foto_trenerAnimation {
  0% {
    transform: translateX(-200px);
    opacity: 0;
  }
  50% {
    transform: translateX(-100px);
    opacity: 0.5;
  }
  100% {
    transform: translateX(0);
    opacity: 1;
  }
}

/*Intro styles end*/

HTML
=========
<!DOCTYPE html>

  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Personalny Trener</title>
  <link rel="stylesheet" type="text/css" href="./css/reset.css">
  <link rel="stylesheet" type="text/css" href="./css/style.css">

              PROGRAMS

              HEALTHY LIVING

              COMMUNITY

              ABOUT

              STORE

            PERSONALNY

            TRENER

              Programs offer day-to-day Lorem Ipsum is simply
 dummy text of the printing and typesetting industry.

          <button class="custom-btn btn-5">

PROGRAMS

                        </button>


text:
Q: Python ggplot: Is it possible to turn off the GUI displayed? and get a command-line ("non-interactive plotting"/"batch") When plotting with Python ggplot, every single plot command causes a GUI pane to be displayed and suspend execution ("interactive plotting"). But I want to:

*

*avoid/ turn off this GUI and save the plot object some where in runtime (I will be displaying it in some other C# forms control).

*find a Python equivalent to dev.off() command in R language which turns off the GUI for plotting.
Example:
print ggplot(data, aes('Age', 'Weight')) + geom_point(colour='steelblue')

When I execute this, it opens up a new GUI (like below) displaying the plot.

A: Since plotting is triggered by __repr__ method the obvious approach is to avoid situations when it is called. Since you want to use this plot in some other place there is no reason to call print or even executing statements which will be discarded like this:
ggplot(data, aes('Age', 'Weight')) + geom_point(colour='steelblue')

Instead you can simply assign it to the variable
p = ggplot(data, aes('Age', 'Weight')) + geom_point(colour='steelblue')

what is exactly the same thing one would do in R. Using graphic device to redirect output and discarding it doesn't really make sense.
If for some reason that's not enough you switch to non-interactive matplotlib backend:
import matplotlib
matplotlib.use('Agg')
from ggplot import *
ggplot(aes(x='date', y='beef'), data=meat)
<ggplot: (...)>

A: You can do the following, which returns a matplotlib figure:
g = ggplot(...) + geom_xxx(...)
fig = g.draw()

ggplots __repr__() method (what is called by print(g) is basically self.draw() then use matplotlibs plt.show() to show the plot...
You can also use ggsave(g) to save the plot somewhere.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Python3: complicated regex I'm trying to build a complicated regex. I want to match a regex of the following structure:

*

*.+ (any character, at least once)

*either "del" or "ins" or "dup" or [ATGC]

*.* (string ends or is followed by whatever)

I have tried different things and at the moment I am here, which doesn't work:
hgvs = "c.*1017delT"
a = re.match('(.*)(del|ins|dup|[ATGC]).*', hgvs)
a.groups()
('c.*1017del', 'T')

I expect to catch everything before the "del" with "(.*)". But he seems to apply the [ATGC] match over the del match.

A: Try non-greedy match:
re.match('(.*?)(del|ins|dup|[ATGC]).*', hgvs)
             ^

With the non-greedy qualifier, the first .*? will match as few as possible.
P.S. If you learn more regex, you won't think this one is "complex" because there are far more really complex regex syntax.


text:
Q: Can I use a script to copy and rename a sheet in Google Sheets with the current data as the tab name? I have a data sheet that will update weekly. I would like a script to copy the sheet and rename it with the current date. The goal is to preserve the data in the sheet weekly before it updates so that I have a record of the data.
This is the script that I have so far:
    /** @OnlyCurrentDoc */function myFunction() {
    let sh, temp_one_values;
    sh = SpreadsheetApp.getActive();
    temp_one_values = transpose_(sh.getSheetByName('Complete Tutoring Roster').getRange('A1:Z1000').getValues());
        {temp_one.copyTo(sh).setName(szToday);

    }
}

function transpose_(array) {
    return Object.keys(array[0]).map(function (col) {
        return array.map(function (row) {
            return row[col];
        });
    });
}

function CopyDataSheet() {
  var spreadsheet = SpreadsheetApp.getActive();
  spreadsheet.getRange('A1').activate();
  spreadsheet.duplicateActiveSheet();
  spreadsheet.getActiveSheet().setName('11/19/2020');
};

I used record a macro to get the script.
I know that I need to edit the setName code. But I am not sure how to code it to pull the current date.

A: Explanation:

*

*You just need to get the date of today in the desired format: MM/dd/yyyy:
const today = Utilities.formatDate(new Date(), spreadsheet.getSpreadsheetTimeZone(), "MM/dd/yyyy");

*And then use the copyTo(spreadsheet) method to duplicate the sheet into the existing spreadsheet and then name it with the date of today:
sheet.copyTo(spreadsheet).setName(today);

*You don't need to activate ranges or sheet. That is a logic generated by macros but it makes your code confusing and inefficient. Instead of getting the active sheet, use getSheetByName to get the desired sheet based on its name.
Solution:
In this solution, change Sheet1 to the name of the sheet you want to duplicate.
function CopyDataSheet() {
 const spreadsheet = SpreadsheetApp.getActive();
 const sheet = spreadsheet.getSheetByName('Sheet1');
 const today = Utilities.formatDate(new Date(), spreadsheet.getSpreadsheetTimeZone(), "MM/dd/yyyy");
 sheet.copyTo(spreadsheet).setName(today);
};


text:
Q: getClassLoaderCache error when upgrading Gradle from 6.7 to 7.0.1 I'm fairly new to Gradle. Whenever I try to upgrade an existing project from 6.7 to 7.0.1 a traceback comes up as
java.lang.NoSuchMethodException: org.gradle.api.tasks.testing.Test.getClassLoaderCache()

Is there any workaround or missing dependency that I'm overlooking?

A: I had the same problem and could solve it by upgrading one of my plugins. From
 plugins {
     id 'org.gradle.test-retry' version '1.1.3'
 }

to
 plugins {
     id 'org.gradle.test-retry' version '1.3.1'
 }

So perhaps checking your plugins might help. Shame that the Gradle exception doesn't help at all.


text:
Q: how do i make the div column with fixed height, also respond according to the content inside i have created the following layout and i want the div columns "title 1" "title 2" have a fixed height and also grow when there is content inside of them, now when i add content to it the content goes past the height of the div. i want the content to be inside the div and grow accordingly. i have tried min-height but it didn't work i'm wondering if there is a way to achieve this.

* {
  margin: 0;
  padding: 0;
}

html,
body {
  margin: 0;
  padding: 0;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  color: white;
  box-sizing: border-box;
}

/**** Main Layout container ****/

.container {
  display: flex;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

/**** Sidebar Static Left ****/

.sidebar {
  width: 12%;
  height: 100%;
  background-color: #f1f1f1;
  overflow-y: auto;
  position: absolute;
  top: 0;
  left: 0;
}

/*** Fluid Container ***/

.fluid-container {
  width: 88%;
  height: 100%;
  background-color: cadetblue;
  position: absolute;
  left: 12%;
  overflow: hidden;
}

.navbar {
  width: 100%;
  text-align: center;
  background-color: skyblue;
  color: #484545;
  font-size: 1.7rem;
  display: flex;
  justify-content: center;
}

.header h1 {
  border: 2px solid skyblue;
  width: 180px;
  display: block;
  margin: 0 auto;
  font-size: 1.5rem;
  border-radius: 3px;
  background-color: skyblue;
  color: rgb(31, 30, 30);
}

/*** Title Box Containers ***/

.box-container {
  width: 100%;
  background-color: skyblue;
  display: flex;
  height: 100%;
}

.box {
  width: 50%;
  border: 2px solid rgb(229 221 221);
  background-color: skyblue;
  display: flex;
  overflow-x: scroll;
  height: calc(100% - 5%);
}

div#box1 {
  width: 100%;
  overflow-x: auto;
}

@media only screen and (min-width: 1200px) {
  div#box1 {
    justify-content: center;
  }
}

.item {
  width: 220px;
  border: 2px solid rgb(229 221 221);
  margin: 0 7px;
  background-color: #f1f1f1;
  min-width: 220px;
}

#item2 {
  overflow-y: auto;
  height: calc(100% - 2px);
  min-width: 220px;
  width: 220px;
}

#item1 {
  height: calc(100% - 50%);
  width: 220px;
  min-width: 220px;
  overflow-y: auto;
}

#item3 {
  height: calc(100% - 30%);
  width: 220px;
  min-width: 220px;
}

h1 {
  border: 2px solid skyblue;
}

h3 {
  border: 2px solid skyblue;
  text-align: center;
  border-radius: 7px;
  background-color: skyblue;
  color: #484545;
  font-size: 1.7rem;
}

p {
  text-align: left;
  padding: 0px 4px;
  color: rgb(31, 30, 30);
}

/* The side navigation menu */

.sidenav {
  height: 100%;
  width: 0;
  position: fixed;
  z-index: 1;
  top: 0;
  right: 0;
  background-color: #f1f1f1;
  overflow-x: hidden;
  padding-top: 60px;
  transition: 0.5s;
}

span {
  float: right;
  margin: -41px 17px 0px 0px;
  color: black;
  font-size: 2.5rem;
  position: absolute;
  top: 35px;
  right: 5px;
  cursor: pointer;
}

/* The navigation menu links */

.sidenav a {
  padding: 8px 8px 8px 32px;
  text-decoration: none;
  font-size: 25px;
  color: #818181;
  display: block;
  transition: 0.3s;
  cursor: pointer;
}

/* Position and style the close button (top right corner) */

.sidenav .closebtn {
  position: absolute;
  top: 0;
  right: 25px;
  font-size: 36px;
  margin-left: 50px;
  color: black;
}

/* On smaller screens, where height is less than 450px, change the style of the sidenav (less padding and a smaller font size) */

@media screen and (max-height: 450px) {
  .sidenav {
    padding-top: 15px;
  }
  .sidenav a {
    font-size: 18px;
  }
}

Title

Lorem ipsum dolor sit, amet consectetur adipisicing elit. Voluptas suscipit aliquid nobis eius harum ipsam eum perferendis modi excepturi laudantium, rerum recusandae nulla odio ullam aliquam aut quam ea cupiditate officiis? Tempora corrupti, officiis
      placeat quam praesentium quis dolores itaque repudiandae libero voluptates consequatur repellat, temporibus et laboriosam, accusantium ducimus quia distinctio a iste quaerat culpa ex cum. Officia laborum nesciunt quidem. Aliquid possimus soluta
      dolores obcaecati doloribus aut corrupti, at tenetur odit optio, facilis ipsam natus illum magni voluptas, quos animi. Sunt laudantium ut itaque, aperiam provident, nisi officiis inventore perspiciatis tenetur quidem sapiente natus vel ipsum omnis
      ad quia nemo ipsam in harum? Distinctio tempora quis facere animi molestiae iste quas voluptas iusto quaerat, officia modi aliquam earum saepe at est, suscipit vitae optio alias doloribus ea molestias illum impedit? Culpa sint, iure, illo provident
      officia minima consectetur, ea autem ut atque dolore quaerat dolor adipisci odio accusantium dolores dolorum odit rem dignissimos soluta. Veniam laborum, sint qui ad nemo ipsam voluptates magnam iure consectetur reprehenderit adipisci sed quos placeat
      ipsa aperiam repudiandae officia? Eum dicta quod, laudantium

Header Section

          ×
          About
          Services
          Clients
          Contact

                    <ion-icon name="menu-outline"></ion-icon>

Title 1

Title 2

Lorem ipsum dolor sit amet consectetur adipisicing elit. Aperiam laborum doloremque quas tempora deleniti molestiae ullam nostrum repellat quae commodi, quaerat labore, rerum voluptatibus perferendis ex cupiditate excepturi officiis! Obcaecati
            quisquam sit vero a, vitae laborum eius reiciendis placeat nemo provident ea labore incidunt? Distinctio, explicabo? Ab asperiores eos quasi eum blanditiis ipsum ut reprehenderit nostrum dignissimos cupiditate, ipsa facere inventore laudantium
            ducimus dicta sunt quidem, nam harum. Esse iure, voluptate ducimus a voluptatem expedita quas nam officia obcaecati saepe necessitatibus exercitationem quo iusto, libero omnis? Earum esse, dolor quo non vitae repellat odit. Ad voluptates iure
            tenetur explicabo excepturi!

Title 3

Title A

Title B

Lorem ipsum dolor sit amet consectetur adipisicing elit. Aperiam laborum doloremque quas tempora deleniti molestiae ullam nostrum repellat quae commodi, quaerat labore, rerum voluptatibus perferendis ex cupiditate excepturi officiis! Obcaecati
            quisquam sit vero a, vitae laborum eius reiciendis placeat nemo provident ea labore incidunt? Distinctio, explicabo? Ab asperiores eos quasi eum blanditiis ipsum ut reprehenderit nostrum dignissimos cupiditate, ipsa facere inventore laudantium
            ducimus dicta sunt quidem, nam harum. Esse iure, voluptate ducimus a voluptatem expedita quas nam officia obcaecati saepe necessitatibus exercitationem quo iusto, libero omnis? Earum esse, dolor quo non vitae repellat odit. Ad voluptates iure
            tenetur explicabo excepturi!

Title C

A: Use height: fit-content; on  #item2. This way both divs will grow/shrink based on the content inside.

function openNav() {
  document.getElementById("mySidenav").style.width = "250px";
}

function closeNav() {
  document.getElementById("mySidenav").style.width = "0";
}
* {
  margin: 0;
  padding: 0;
}

html,
body {
  margin: 0;
  padding: 0;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  color: white;
  box-sizing: border-box;
}

/**** Main Layout container ****/

.container {
  display: flex;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

/**** Sidebar Static Left ****/

.sidebar {
  width: 12%;
  height: 100%;
  background-color: #f1f1f1;
  overflow-y: auto;
  position: absolute;
  top: 0;
  left: 0;
}

/*** Fluid Container ***/

.fluid-container {
  width: 88%;
  height: 100%;
  background-color: cadetblue;
  position: absolute;
  left: 12%;
  overflow: hidden;
}

.navbar {
  width: 100%;
  text-align: center;
  background-color: skyblue;
  color: #484545;
  font-size: 1.7rem;
  display: flex;
  justify-content: center;
}

.header h1 {
  border: 2px solid skyblue;
  width: 180px;
  display: block;
  margin: 0 auto;
  font-size: 1.5rem;
  border-radius: 3px;
  background-color: skyblue;
  color: rgb(31, 30, 30);
}

/*** Title Box Containers ***/

.box-container {
  width: 100%;
  background-color: skyblue;
  display: flex;
  height: 100%;
}

.box {
  width: 50%;
  border: 2px solid rgb(229 221 221);
  background-color: skyblue;
  display: flex;
  overflow-x: scroll;
  height: calc(100% - 5%);
}

div#box1 {
  width: 100%;
  overflow-x: auto;
}

@media only screen and (min-width: 1200px) {
  div#box1 {
    justify-content: center;
  }
}

.item {
  width: 220px;
  border: 2px solid rgb(229 221 221);
  margin: 0 7px;
  background-color: #f1f1f1;
  min-width: 220px;
}

#item2 {
  overflow-y: auto;
  height: fit-content;
  min-width: 220px;
  width: 220px;
}

#item1 {
  height: calc(100% - 50%);
  width: 220px;
  min-width: 220px;
  overflow-y: auto;
}

#item3 {
  height: calc(100% - 30%);
  width: 220px;
  min-width: 220px;
}

h1 {
  border: 2px solid skyblue;
}

h3 {
  border: 2px solid skyblue;
  text-align: center;
  border-radius: 7px;
  background-color: skyblue;
  color: #484545;
  font-size: 1.7rem;
}

p {
  text-align: left;
  padding: 0px 4px;
  color: rgb(31, 30, 30);
}

/* The side navigation menu */

.sidenav {
  height: 100%;
  width: 0;
  position: fixed;
  z-index: 1;
  top: 0;
  right: 0;
  background-color: #f1f1f1;
  overflow-x: hidden;
  padding-top: 60px;
  transition: 0.5s;
}

span {
  float: right;
  margin: -41px 17px 0px 0px;
  color: black;
  font-size: 2.5rem;
  position: absolute;
  top: 35px;
  right: 5px;
  cursor: pointer;
}

/* The navigation menu links */

.sidenav a {
  padding: 8px 8px 8px 32px;
  text-decoration: none;
  font-size: 25px;
  color: #818181;
  display: block;
  transition: 0.3s;
  cursor: pointer;
}

/* Position and style the close button (top right corner) */

.sidenav .closebtn {
  position: absolute;
  top: 0;
  right: 25px;
  font-size: 36px;
  margin-left: 50px;
  color: black;
}

/* On smaller screens, where height is less than 450px, change the style of the sidenav (less padding and a smaller font size) */

@media screen and (max-height: 450px) {
  .sidenav {
    padding-top: 15px;
  }
  .sidenav a {
    font-size: 18px;
  }
}

Title

Lorem ipsum dolor sit, amet consectetur adipisicing elit. Voluptas suscipit aliquid nobis eius harum ipsam eum perferendis modi excepturi laudantium, rerum recusandae nulla odio ullam aliquam aut quam ea cupiditate officiis? Tempora corrupti, officiis
      placeat quam praesentium quis dolores itaque repudiandae libero voluptates consequatur repellat, temporibus et laboriosam, accusantium ducimus quia distinctio a iste quaerat culpa ex cum. Officia laborum nesciunt quidem. Aliquid possimus soluta
      dolores obcaecati doloribus aut corrupti, at tenetur odit optio, facilis ipsam natus illum magni voluptas, quos animi. Sunt laudantium ut itaque, aperiam provident, nisi officiis inventore perspiciatis tenetur quidem sapiente natus vel ipsum omnis
      ad quia nemo ipsam in harum? Distinctio tempora quis facere animi molestiae iste quas voluptas iusto quaerat, officia modi aliquam earum saepe at est, suscipit vitae optio alias doloribus ea molestias illum impedit? Culpa sint, iure, illo provident
      officia minima consectetur, ea autem ut atque dolore quaerat dolor adipisci odio accusantium dolores dolorum odit rem dignissimos soluta. Veniam laborum, sint qui ad nemo ipsam voluptates magnam iure consectetur reprehenderit adipisci sed quos placeat
      ipsa aperiam repudiandae officia? Eum dicta quod, laudantium

Header Section

          ×
          About
          Services
          Clients
          Contact

                    <ion-icon name="menu-outline"></ion-icon>

Title 1

Title 2

Lorem ipsum dolor sit amet consectetur adipisicing elit. Aperiam laborum doloremque quas tempora deleniti molestiae ullam nostrum repellat quae commodi, quaerat labore, rerum voluptatibus perferendis ex cupiditate excepturi officiis! Obcaecati
            quisquam sit vero a, vitae laborum eius reiciendis placeat nemo provident ea labore incidunt? Distinctio, explicabo? Ab asperiores eos quasi eum blanditiis ipsum ut reprehenderit nostrum dignissimos cupiditate, ipsa facere inventore laudantium
            ducimus dicta sunt quidem, nam harum. Esse iure, voluptate ducimus a voluptatem expedita quas nam officia obcaecati saepe necessitatibus exercitationem quo iusto, libero omnis? Earum esse, dolor quo non vitae repellat odit. Ad voluptates iure
            tenetur explicabo excepturi!

Title 3

Title A

Title B

Lorem ipsum dolor sit amet consectetur adipisicing elit. Aperiam laborum doloremque quas tempora deleniti molestiae ullam nostrum repellat quae commodi, quaerat labore, rerum voluptatibus perferendis ex cupiditate excepturi officiis! Obcaecati
            quisquam sit vero a, vitae laborum eius reiciendis placeat nemo provident ea labore incidunt? Distinctio, explicabo? Ab asperiores eos quasi eum blanditiis ipsum ut reprehenderit nostrum dignissimos cupiditate, ipsa facere inventore laudantium
            ducimus dicta sunt quidem, nam harum. Esse iure, voluptate ducimus a voluptatem expedita quas nam officia obcaecati saepe necessitatibus exercitationem quo iusto, libero omnis? Earum esse, dolor quo non vitae repellat odit. Ad voluptates iure
            tenetur explicabo excepturi!

Title C


text:
Q: AngularJS ng-repeat ng-click I am trying to have a grid of images, when clicked the image is hid from the grid and shown featured at the top.
HTML:

{{selected.des}}

And my controller:
light.controller('imageCtrl', function($scope){
  $scope.images = [{img: '',des: ''},{img: '',des: ''},{img: '',des: ''}];
  $scope.selected = $scope.images[0];
  $scope.clicked = function(id){
    selected = $scope.images[id];
};

});
Currently the first image is shown but when I click on other images nothing happens. Anybody have any tips as to what I'm doing wrong? Thank You!

A: you'll need to set $scope.selected not selected
$scope.clicked = function(id){
   $scope.selected = $scope.images[id];
}

EDIT: i suck at plunker ;)
anyways: use ng-repeat as you did in your first example and it should work

A: Try this:
In html, instead of passing id pass the index value as
ng-click="clicked($index)"
In the controller,
$scope.clicked = function(Index){
$scope.selected = $scope.images[Index];

};

A: Use this instead:

Use ng-src={{selected.image}} in your image tag instead of just src={{selected.image}}.  Angular will know it needs to update the image if the model its pointing to has been updated


text:
Q: Rails 3.2 One to Many View I have tried to get this working, looked at multiple tutorials, questions on here tried different things for about a week now and I can't get the view to work correctly.
I have teams of users. A team has_many users and a user belongs_to a team (one team at a time). I know the association works because I got it working using the console (with some help there). I'm not sure how to get it working in the view. Below is the code, please let me know if more is needed.
What am I missing?
_join_team_button
<%= form_for(@user) do |f| %>
  <%= f.submit "Join Team", class: "btn btn-large btn-primary" %>
<% end %>

Team Show Page
<%= render 'shared/join_team_button %>

Teams Controller
def show
  @team =  Team.find(params[:id])
  @team_members = @team.users
  @user = current_user.users.build if signed_in?
end

Users Controller
def show
  @user = User.find(params[:id])
  @teams = @user.team
end

A: I tried to put a complete demonstration of what you are looking for. Let me know if it fits for you.
#FILE: models/team.rb
class Team < AR::Base
   has_many :users
end

#FILE: models/user.rb
class User < AR::Base
   belongs_to :team
end

#FILE: config/routes.rb
#Here you are defining "users" as a nested resource of "teams"
resources :teams  do
    resources :users do
        member do
            put :join
        end
    end
end

#if you run "rake routes" it will show you the following line along with others
join_team_user PUT    /teams/:team_id/users/:id/join(.:format) users#join

#FILE: controllers/team_controller.rb
def show
    @team =  Team.find(params[:id])
    @team_members = @team.users
    @user = current_user.users.build if signed_in?
end

#FILE: views/teams/show.html.erb
<% if(@user) %>
    <%= form_for @user, :url => join_team_user_path(@team, @user) do |f| %>
      <%= f.submit "Join Team", class: "btn btn-large btn-primary" %>
    <% end %>
<% end %>

#You dont really need a form for this. You can simply use `link_to` like below
<%= link_to 'Join', join_team_user_path(@team, @user), method: :put %>

#FILE: controllers/users_controller.rb
def join
    # params[:id] => is the user_id
    @user = User.find(params[:id])

    # params[:team_id] => is the team_id
    @team = Team.find(params[:team_id])

    # Now make the relationship between user and team here.
    @user.update_attribute(:team, @team)
end

Update:Based on your comment
Q: Do I create a new user's resource and nest that or do I nest the already establishes user's resource?
Ans: Based on your requirements any resource can be defined both independently or nestedly. But yes you can control that which method will be available in which way. Like in your case, you can allow only join method when your user is nested under team resource.
resources :users, :only=>:join do
    member do
        put :join
    end
end
resource :users

run rake routes with and without :only=>:join option and see differences in available routes.
Q: Will that affect other things?
Ans: If you strictly define your routes following above example, it should not affect other things. You should confirm all the available routes to your application by rake routes.
Q: Should I put my current routes.rb file up there?
Ans: Assuming your current routes.rb will be modified in the above way. Could I answer the question?
Q: Confused about the comments controller?
Ans: Im extreamely sorry. Yes it must be users_controller.rb as the rake routes command is showing. Result of copy and paste from my own example code :P
Q: what should I put there? the build method
Ans: In your case both the user and team is already exists in your database. All you need to do is just setup a relationship. So you can just use update_attribute option. Ive changed the join method. Please check. But yes if want to create new entries you might need build methods.
Sorry for the late reply :)

A: I figured it out. Still not perfect, but it gets the association working. The team, and the user were already created, I just needed to establish the association, so the build method would not have worked.  Here's what I have:
View:
<%= form_for(@user) do |f| %>
<%= f.hidden_field :team_id, :value => @team.id %>
  <%= f.submit "Join Team", class: "btn btn-large btn-primary" %>
<% end %>

Teams Controller:
def show
  @team =  Team.find(params[:id])
  @team_members = @team.users
  @user = User.find(params[:id]) if signed_in?
end


text:
Q: Learning geb and Spock for Mobile app I am new to automation and wanted to learn geb for mobile with page objects. I have knowledge of page objects in geb. I just wanted to know from where to start writing test case. I am confused at getBrowser() and where to set the capabilities.

A: you have to create gebConfig.groovy script and use below code there.
import io.appium.java_client.AppiumDriver
import io.appium.java_client.remote.MobileCapabilityType
import org.openqa.selenium.remote.DesiredCapabilities

driver = { // appium driver
    DesiredCapabilities capa = new DesiredCapabilities()
    capa.setCapability('deviceName', 'Android')
    capa.setCapability('platformName', 'Android');
    capa.setCapability('appPackage', 'com.example.jiteshmohite.automationsample')
    capa.setCapability('LoginActivity', 'com.example.jiteshmohite.automationsample.LoginActivity')

    String appPath = 'C:\\temp\\automation.apk'
    String  app = new File(appPath).absolutePath
    capa.setCapability(MobileCapabilityType.APP, app)

    URL appiumUrl = new URL('http://0.0.0.0:4723/wd/hub')
    println("Creating AndroidDriver to $appiumUrl with $capa")
    new AppiumDriver(appiumUrl, capa)
}

reportsDir = "build/reports/my-reports"

above code will be executed by geb driver it will set given specified capabilities.


text:
Q: Yii2 SESSION Nesting level too deep A visitor chooses to buy a package;
The datails from that package are saved within the SESSION
Yii::$app()->session['CART'] = array( 1=>2 );
When the user tryes to pay for it, the system needs data regarding the user, like the user ID, so the user gets redrected to login.
This is where I get the error:
PHP Fatal Error – yii\base\ErrorException

Nesting level too deep - recursive dependency?

How do i login the user and not loose the data stored?


text:
Q: Проверяет ссылки на ресурсы в файлах Android XML Я просто создал приложение без каких-либо действий внутри, и когда я добавляю макет и класс java, я начал редактировать AndroidManifest.xml и при проведение манипуляций показывает мне следующее:
Здесь мой AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.alexandr.song">

<uses-permission android:name="android.permission.INTERNET" />

<application
android:name="com.example.alexandr.app.AppController"
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >

AppController.java:
package com.example.alexandr.app;

import android.app.Application;
import android.text.TextUtils;
import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.toolbox.Volley;

public class AppController extends Application {

    public static final String TAG = AppController.class.getSimpleName();

    private RequestQueue mRequestQueue;

    private static AppController mInstance;

    @Override
    public void onCreate() {
        super.onCreate();
        mInstance = this;
    }

    public static synchronized AppController getInstance() {
        return mInstance;
    }

    public RequestQueue getRequestQueue() {
        if (mRequestQueue == null) {
            mRequestQueue = Volley.newRequestQueue(getApplicationContext());
        }

        return mRequestQueue;
    }

    public <T> void addToRequestQueue(Request<T> req, String tag) {
        req.setTag(TextUtils.isEmpty(tag) ? TAG : tag);
        getRequestQueue().add(req);
    }

    public <T> void addToRequestQueue(Request<T> req) {
        req.setTag(TAG);
        getRequestQueue().add(req);
    }

    public void cancelPendingRequests(Object tag) {
        if (mRequestQueue != null) {
            mRequestQueue.cancelAll(tag);
        }
    }
}

A: Не совпадают package в манифесте и в java-файле. Один заканчивается на .song, другой на .app.


text:
Q: Microsoft Graph, Registering a Schema Extension I'm building an internal meeting room app that uses the Microsoft Graph API and I would like to extend Event objects with a Schema Extension.
Documentation:

*

*API Reference

*Tutorial Example
However when running a query to register a new schema extension, I am receiving this HTTP response:
{
    "url": "https://graph.microsoft.com/beta/schemaExtensions",
    "status": "403 Forbidden",
    "headers": {
        "request-id": "e1e36210-6c4c-4ed8-afb1-c9ee6f6362ed",
        "client-request-id": "e1e36210-6c4c-4ed8-afb1-c9ee6f6362ed",
        "x-ms-ags-diagnostic": "{\"ServerInfo\":{\"DataCenter\":\"North Europe\",\"Slice\":\"SliceA\",\"ScaleUnit\":\"001\",\"Host\":\"AGSFE_IN_2\",\"ADSiteName\":\"DUB\"}}",
        "duration": "742.4624"
    },
    "body": {
        "error": {
            "code": "Authorization_RequestDenied",
            "message": "Insufficient privileges to complete the operation.",
            "innerError": {
                "request-id": "e1e36210-6c4c-4ed8-afb1-c9ee6f6362ed",
                "date": "2017-05-10T10:05:37"
            }
        }
    }
}

I can confirm that my application has the prerequisite scope permission of Directory.AccessAsUser.All and it's also been more than 16 hours since adding this permission. I have also got verified domains, so the namespace should be OK per the documentation reference.
My API query in code:
Outlook.test({
    version: 'beta',
    resource: 'schemaExtensions',
    method: 'POST',
    body: {
        id: 'thehivegroup_beethere',
        description: 'Extension for event presence status',
        targetTypes: [ 'Event' ],
        properties: [
            { name: 'checkIn', type: 'String' },
            { name: 'checkOut', type: 'String' }
        ]
    }
})
.then(result => console.log(result), err => console.error(err))

Which results in a POST with the JSON encoded in the body and headers with authorization token to the URL https://graph.microsoft.com/beta/schemaExtensions.
I have tried different IDs, such as beethere, which resulted in a namespace error, so I know this ought to be working fine.
There are no other scope permissions I am aware of that I need to enable here as well. The error is just too vague for me to figure out what privileges are insufficient here.

EDIT: Have manually run the query in the Graph Explorer as an Admin in the tenant, added the scope permissions required for the API and some extra ones in case, but the query for registration of Schema Extensions still does not work, with the same error message as the application receives. So it is definitely not a problem in my code, but the Microsoft Graph API. Is there a contact or way to ask microsoft to look into the issue?

A: Directory.AccessAsUser.All is a delegated permission only (it must be delegated because it grants access to directory based APIs as the signed-in user's access rights).  It doesn't show up in the roles claim because it isn't an application permission.
As far as I know, right know, you cannot use the application flow (client credentials) to create a schema extension, and you need to use the "code authorization" flow.  Please let us know if this is a requirement.  Additionally we'd love to know if you want to see an experience for schema definition registration as part of the application registration...
Also you CANNOT currently create a schema extension definition (or manage it) through Graph Explorer. For you to created a definition, you must either be an admin or the owner of the app creating the extension definition AND the creation request must also come from that application (which cannot be graph explorer).  We may look at relaxing this last constraint.
If you want to see a code snippet for this it's available here (although it's a UWP c# app, not JS): https://github.com/microsoftgraph/uwp-csharp-snippets-rest-sample.
Also schema extensions is now GA, and available in the v1.0 endpoint.
Hope this helps,

A: This schema extensions creating REST works well for me. Please ensure that the token contains Directory.AccessAsUser.All permission. You can parse the token check the scp claim in it from this site.

A: Graph Explorer is able to add an extension.
You will need to create an app in your tenant and set the owner in the payload to the client id of your app.
more on this


text:
Q: Syntax highlighting for non-alphanumeric characters in emacs I would like for certain non-alphanumeric characters (= + / < > etc.) to be highlighted in emacs while editing any language.
Using the answer to a different question on this site, I found this solution for highlighting '%' while editing Fortran:
(font-lock-add-keywords 'f90-mode
        '(("%" . font-lock-keyword-face)))

but this is only one symbol in one language. I can achieve what I want by polluting my .emacs file:
(font-lock-add-keywords 'c++-mode
        '(("=" . font-lock-keyword-face)))

(font-lock-add-keywords 'java-mode
        '(("=" . font-lock-keyword-face)))

(font-lock-add-keywords 'python-mode
        '(("=" . font-lock-keyword-face)))

and so on, but this introduces a bug in which the last few lines of any file do not get any syntax highlighting at all.
How can I, across all language modes, enable syntax highlighting for a certain set of non-alphanumeric characters?

A: Use library highlight-chars.el (the code is here).
You can highlight any set of characters, using any faces. You can define the set using any number of entries of any of these kinds:

*

*string of chars

*range of successive chars (Emacs characters are integers)

*character class (e.g. [:nonascii:], [:space:])

*character set (e.g. iso-8859-1 or lao)

You can also exclude any set of characters from such highlighting.
You can thus, for example, highlight all characters in character set greek-iso8859-7 except the character GREEK SMALL LETTER LAMBDA. Or highlight all characters in class [:space:] (whitespace) except tab. Or all Unicode characters in the range ?\u2190 through ?\u21ff (mathematical arrows) except ?\u21b6, ?\u21b7, ?\u21ba, and ?\u21bb (curved arrows)...


text:
Q: Are there any performance issues if an sql query contains lot of joins? Are there any performance issues if an sql query contains lot of joins?

A: There can be -- but query performance is a sensitive thing affected by lots of factors:

*

*Number of joins

*Structure of tables

*Size of the database

*Presence if and data type of indexes

*Data types of values being joined

*etc etc

You can get into all sorts of details.  But generally the best approach is to write a query that works and then profile your app to see if you actually have a problem.  Then, start looking at optimizing your queries.

A: Yes.
But the biggest issue is: HOW are the tables joined. Suppose you had a query like:
select book.title, chapter.page_count
from chapter
join book on book.bookid=chapter.bookid
where chapter.subject='penguins'

The query would probably read the Chapter table first looking for matches on 'penguins', then join to Book. If Bookid is the primary key of book, or at least is indexed, this would be very fast. But if not, then we would have to do a full-file sequential read of Book. Depending on the engine and other factors, we might have to re-read the entire Book table for each chapter record found. That could take a long long time.
If you join three tables and both the joins require full file reads, you could be in a world of hurt.
Joins always cost you something. But joins that require full-file reads, especially multiple full-file reads, cost a lot. Some database engines mitigate this cost by recognizing it's happening and can load a table into memory and re-use it, generally doing some kind of hash search against it. This is still expensive, but not quite as bad.
Learn to read an Explain plan. These can help a lot in analyzing your queries, figuring out where they're bad, and cleaning them up. Personally, unless a query is obviously simple, like "select whatever from table where primary_key=whatever", I check out the explain plan just to be sure.

A:
One of the best ways to boost JOIN
  performance is to limit how many rows
  need to be JOINed.

Read more in this article
Performance Tuning SQL Server Joins

A: Using lots of joins can slow down retrieval performance (though with proper indexing, the penalty is often a lot less than people think -- measure first).
However, people tend to forget that removing the joins often means 'denormalizing' the data, which then incurs costs when the data must be modified.  In particular, enforcing the constraints which a fully normalized schema enforces automatically in a schema which is denormalized can be hard.  Because it is hard, it is often not done.  But when the constraints are not enforced, the data becomes unreliable, and there's one thing worse than (slightly) slow select operations that return the correct answer, and that is fast select operations that return wrong or confusing answers.
If the DBMS is read-mainly - that is, data is written once and seldom if ever modified, then you can consider whether the performance benefit from denormalization makes the risks of inaccurate data creeping into the database acceptable.  If the data is mission critical and often updated, then the risk of inaccurate data is usually too serious to be acceptable.
But, as they say, YMMV.

A: Yes if you use lot of joins in SQL affect your performance .


text:
Q: I have an issue with react-router-dom, NoMatch doesn't accept URL like /foo/bar I'm using a classic configuration with React, Redux and React-router-dom. Everything work fine in dev. and production mode (localhost and production server). I just have an issue with NoMatch process.

*

*/good-path, it's work

*/wrong-path it's work and show the NoMatch component

*/wrong/path it's show a white page (404 status in network console with wrong url www.myWebsite.com/wrong/path)

I'm using :
- react 16.8.4
- react-dom 16.8.4
- react-redux 6.0.1
- react-router-dom 5.0.1
- redux 4.0.1
This is a sample of my configuration :

<Provider store={store}>
  <Router>
    <div>

      <NavLink exact to="/">Home</NavLink>

      <NavLink exact to="/contact">Contact</NavLink>

      <Switch>
        <Route path="/" exact component={Home} />
        <Route path="/contact" component={Contact} />
        <Route component={NoMatch} />
      </Switch>

    </div>
  </Router>
</Provider>

Everything work properly but I expect the NoMatch component will be display for this kind of wrong path : /wrong/path (multiple slash url). In this case, index.html is loaded but I can't access to ressources like app.js, I've got a network error 404 with this kind of URL www.myWebsite.com/wrong/app.js
Thanks for your help.

A: A friend help me in this quest. I found the answer in Webpack config.
I need one more detail in the output setup, I had a publicPath:"/" :
// Set the output
  output: {
    // Path for the file
    path: path.resolve(__dirname, 'dist'),
    // Name for the output file
    filename: "app.js",
    //
    publicPath:"/"
  },

Thanks to my friend Georges and this post : https://stackoverflow.com/a/39278576/9945698


text:
Q: LaravelCollective v6.2: Undefined class 'Form' in PhpStorm I have just installed LaravelCollective v6.2 running $ composer require laravelcollective/html command.
I made a form:
{!! Form::open(['url' => '/posts']) !!}

            <input type="text" class="form-control" id="inputTitle" placeholder="Enter title"
                   name="title">

        <button type="submit" class="btn btn-primary">Submit</button>
    {!! Form::close() !!}

PhpStorm says Undefined class 'Form'. How can I fix this?

My composer.json:
"require": {
        "php": "^7.3|^8.0",
        "fideloper/proxy": "^4.4",
        "fruitcake/laravel-cors": "^2.0",
        "guzzlehttp/guzzle": "^7.0.1",
        "laravel/framework": "^8.40",
        "laravel/tinker": "^2.5",
        "laravelcollective/html": "^6.2"
    },

A: Form is a Laravel facade. Quite a bit of magic is involved here.
Do you use Laravel IDE Helper by Barry vd. Heuvel?

*

*If you do not: install and use it. It generates special .php file(s) that are used by the IDE to better understand the Laravel related code (facades and other Laravel stuff).

*If you do: you need to re-generate the IDE helper file so it includes the Form facade.


text:
Q: I have a string which contains a decimal point e.g. "10.00" and I want to hide it using jQuery? I have a string which contains a decimal point e.g.  "10.00" and I want to hide it using jQuery? I need to trim it to "10" from "10.00".

A: Many options, I'd probably go with
var foo = "10.00";

foo.split('.')[ 0 ];

A: Math.floor(parseInt("10.00",10));
// 10

If you need it back as a string rather than an int,
Math.floor(parseInt("10.00",10)).toString();
// "10"

Edit:
Actually, Math.floor() isn't necessary. parseInt() will do it alone:
parseInt("10.00",10).toString();
// "10"

A: The following will remove the decimal values by converting it to an integer:
// Returns an int of 10.
var myInteger = parseInt("10.00");

or
// Returns a string of "10".
var myString = parseInt("10.00").toString();

A: Or the regex way. Since we start with a String and want a String out, why bother converting back and forth to numbers ? And this will be faster than 'split'.
/[^\.]*/.exec("10.00")[0]

A: Pure string way to do this is
var Trim = function( n ) {
    var index = n.indexOf('.');
    return n.substring(0, index - 1);
};

//usage
Trim( "10.00" );

A: The following may be useful:
intvalue = parseInt($('#quantity').val(), 10);


text:
Q: Ensuring method is called I have this class:
public abstract class AbstractIncomingCall {

    /*
    class properties
    */

    public void changeStatus(/*some parameters*/){
        //store parameters in class properties
        isValid();
    }

    protected abstract boolean isValid();
}

...which is extended by this class:
public class IncomingCallImpl extends AbstractIncomingCall{

    //I override the parent's method
    public void changeStatus(/*same parameters as parent's method*/) {
        super.changeStatus(/*same parameters as parent's method*/);
        //do something interesting
    }

    protected boolean isValid() throws StatusChangeNotOccurredException {
        //implement my validation algorithm
    }

What I would like to achieve is ensuring that whenever changeStatus(/*some parameters*/) gets called the isValid() method is called; note that the isValid() method is implemented only in the concrete class, also it uses class properties inheritated from the parent class.
Is there a way I can follow to ensure that isValid() is called other than calling super?
I dislike very much the fact that I have to pass parameters all around, I think I'm going totally in the wrong direction and there is a cleaner way to achieve this.
What I would like to keep in my code is the "isValid() calling logic" in the abstract class, because every call needs to be validated and I can't rely on me remembering this in the future :P
Thanks in advance :]

A: You don't need to override changeStatus(). You are very close to implement the Template Method design pattern.

A: You could make changeStatus final, and add to it the call to a customChangeStatus method that could be overridden.
like below:
public abstract class AbstractIncomingCall {
/*
class properties
*/

public final void changeStatus(/*some parameters*/){
    //store parameters in class properties
    isValid();
    customChangeStatus();
}

protected abstract void customChangeStatus();
protected abstract boolean isValid();

}
You could even implement an empty method for customChangeStatus so you don't need to always implement it.
Using the final in the changeStatus you are sure that will be the logic when calling your classes. And you still have the flexibility to add custom behavior to it.

A: It sounds like you want changeStatus() to follow the Template Method pattern. In this pattern, you define changeStatus() in the abstract class (making it final if you don't trust people to extend properly), and have it call the required methods:
public final void changeStatus()
{
    doSomethingSubclassSpecific();
    isValid()
}

protected abstract doSomethingSubclassSpecific();

A: I suggest using composition rather than inheritance. Things should become more obvious that way.


text:
Q: VB.NET creating a directory then downloading and running a file in Appdata For my application I am trying to create a directory for my program, download an executable into the folder and then run it but I am getting two errors,

Error 1   Too many arguments to 'Public Shared Function Exists(path As String) As Boolean'.
Error 2   Value of type 'String' cannot be converted to 'System.Security.AccessControl.DirectorySecurity'.

any Idea what I am doing wrong?
 Imports System.DirectoryServices
 Imports System.IO

Module Download
    Public Sub DownloadExecute(ByVal url As String)
        Dim folder As String = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)
        If (Not System.IO.Directory.Exists(folder, "TankGame\Installer")) Then
            System.IO.Directory.CreateDirectory(folder, "TankGame\Installer")
        End If
        Dim Downloadedfile = Path.Combine(folder, "TankGame\Installer\installer.exe")
        My.Computer.Network.DownloadFile("url", Downloadedfile)
        Process.Start(Downloadedfile)
    End Sub
End Module


text: Q: Authentication in MERN stack application I am working on a MERN stack project and want to authenticate users, but don't know which method to use. I am stuck with JWT tokens, but can't really get my head around about it generally.


text:
Q: Find class in LinkedList I am making this 2-D game where I want to be able to build structures. The player must be able to benefit from certain structures. Today the game looks like this:

(the blue dot is the player, other dots are ais)
I have made a class named Structure and three other classes that inherits from Structure. These classes are more or less empty. The tiles of the game has there own class named Tile. In this class I have written some things but the code of interest is this:
public LinkedList<Structure> Structures = new LinkedList<Structure>();

When i build a structure (a fireplace for example) the code looks like this:
Bundle.map.tile[Bundle.player.X, Bundle.player.Y].Structures.
    AddFirst(new Fireplace());

The part I´m uncertain about is how I check if the list contain a fireplace for example (which is a class named Fireplace) or any other building. For example if a player finds a fireplace on a tile he/she will regain warmth. This does not work. Perhaps I have the wrong approach to all this, in either case please provide me with an code example.
Conclusion of answer:
bool anyFireplace = Bundle.map.tile[Bundle.player.X, Bundle.player.Y].Structures.OfType<Fireplace>().Any();
if (anyFireplace)
{
    Warmth = MaxWarmth;
}
else
{
if (Warmth > 0)
{
    Warmth--;
}
else
{
    HP--;
}
}

A: I would suggest using the is keyword. It is used to check whether a variable has a certain type. For example:
object example = "Hello World!";
bool isString = example is string; // Evaluates to true

And you could use that in your code as such:
foreach (Structure s in Structures)
{
    if (s is FirePlace)
    {
        // Warmup the player
    }
}

Also, I would suggest using List<T> instead of LinkedList<T>, since List<T> is (generally) much faster.
As you might have gathered from some of the other answers, multiple ways lead to Rome here, many ways. However, according to this test, the is way of doing it outperforms all other suggested ways (thanks to Hogan btw for this test):

OfType time: .6702958,
  GetType time: .2268946,
  Property time: .1400208,
  Is time: .1112995

And this way is cleaner IMHO.

A: You could use, for example, Enumerable.OfType<TResult>() and Enumerable.Any(TSource) as follows:
LinkedList<Structure> structures = new LinkedList<Structure>();

// Add Different Types of Structures

Boolean anyFireplace = structures.OfType<Fireplace>().Any();

Just make sure you have:
using System.Linq;

in your using directives at the top of your source and a reference to the System.Core assembly module. You could also use Count() method if you need to know the exact number of fireplaces inside the LinkedList, otherwise Any() is more efficient in Linq objects.

A: You can use LINQ to Objects for this:
LinkedList<Structure> list = ...

List<Fireplace> fireplaces = list.OfType<Fireplace>().ToList();

fireplaces is then a list of all the elements in the list of type Fireplace - or an empty list if none exist.
If you just want to know if one exists or not, you can adapt this to:
bool hasFirplace = list.OfType<Fireplace>().Any();

A: Maybe having the class name describe the object is not advisable.  You will have to use reflection which is kinda slow. AND you only get one description (the class name).  You will want more than just one.  You might want to consider a base object like this:
public abstract class MapObject
{
   public int x,y;  // object location
   public string myclass;  // object class
   public string mytype;   // object type
   // etc

   // constructor
   public MapObject(string myclass, string mytype);

}

Then the a fireplace might look like this
public class FirePlace : MapObject
{
   public FirePlace()
       : base("Builtin furniture", "Fireplace") { }
   // etc
}

Now you can loop over all MapObjects for ones of mytype = "Fireplace"

A: You can use the Type to know that:
foreach(var s in Structures)
{
  var type = s.GetType();
  if(type == typeof(FirePlace)
  {
    (your code here)
  }
}

For a single method
public bool HasType<T>(IEnumerable<T> list, Type t)
{
    return list.Any(e=>e.GetType() == t);
}

The usage should be like:
if(HasType(Structures,typeof(FirePlace))
{
  (code here)
}

At last you can turn this into an extension method, but I leave that option to you ;)


text:
Q: Entangled electrons seem impossible Two fermions cannot share the same quantum state.
But two electrons can be entangled. Entangled electrons share the same quantum state.
Thus a contradiction.
Where is my error?

A: The claim "Entangled electrons share the same quantum state" is not correct. In an entangled state there is no well-defined notion of the states of the individual components, this is the very definition of an entangled state:
A composite state $\chi\in\mathcal{H}_1\otimes\mathcal{H}_2$ is called entangled, if it cannot be written as $\chi=\psi\otimes\phi$ for $\psi\in\mathcal{H}_1,\phi\in\mathcal{H}_2$.
The composite states forbidden by the Pauli exclusion principle, however, are states of the form $\psi\otimes\psi\in\mathcal{H}$ for the same $\psi\in\mathcal{H}$, where both particles have the same space of states $\mathcal{H}$.
Thus, there is no contradiction.

A: I am no expert, but I think looking up Quantum entanglement on Wikipedia will tell you that the entangled particles are in correlated states, but that is not the same as sharing the same state.
Also, as a side issue,  two electrons cannot have the same 4 quantum numbers, if they are bound to an atom, but this does not apply to free electrons.


text:
Q: UFuncTypeError: ufunc 'add' did not contain a loop with signature matching types when add element in list I just want to add element in filtered index. Here's my code, A is dataframe and index is a column
my_input = A["index"] + 'a.age'
ML_filtered = ML["index"].isin(my_input)

Here's my error message
UFuncTypeError: ufunc 'add' did not contain a loop with signature matching types (dtype('<U21'), dtype('<U21')) -> dtype('<U21')

What's wrong with the code?
Edit
I try my_input = A["index"] + 'a.age'
The error is
TypeError: Cannot broadcast np.ndarray with operand of type <class 'list'>

A: There is list/array in column A['index'], possible solution is flatten it bySeries.explode :
A = pd.DataFrame({'index':[[1,2],[2,5]]}).applymap(np.array)
print (A)
    index
0  [1, 2]
1  [2, 5]

ML = pd.DataFrame({'index':['1a.age','5a.age', 'tmp']})

my_input = A["index"].explode().astype(str) + 'a.age'
ML_filtered = ML["index"].isin(my_input)
print (ML_filtered)
0     True
1     True
2    False
Name: index, dtype: bool


text:
Q: MongoDB : - Merge Two Array with same key I have 3 collections, users, attendances, shifts.
I am trying to get attendances and shifts with the help of users
I have a date in shifts and the Date key in attendances and I am trying to merge both data into 1 as per date, and if not present then that key should be none
Below is the query I tried it is working to some extent but not got the final result
User.aggregate([
  { $sort: { workerId: 1 } },
  {
    $lookup: {
      from: "shifts",
      localField: "_id",
      foreignField: "employeeId",
      pipeline: [
        {
          $match: {
            date: {
              $gte: new Date(fromDate),
              $lte: new Date(toDate),
            },
          },
        },
        {
          $project: {
            date: 1,
            shiftCode: 1,
          },
        },
        {
          $sort: {
            date: 1,
          },
        },
      ],
      as: "shifts",
    },
  },
  {
    $project: {
      _id: 1,
      workerId: 1,
      shiftListData: "$shifts",
    },
  },
  {
    $lookup: {
      from: "attendances",
      localField: "_id",
      foreignField: "employeeId",
      pipeline: [
        {
          $match: {
            Date: { $gte: new Date(fromDate), $lte: new Date(toDate) },
          },
        },
        {
          $project: {
            inTime: 1,
            name: 1,
            Date: 1,
          },
        },
      ],
      as: "attendances",
    },
  },
]);

OutPut
[
  {
    "workerId": "1005",
    "shiftListData": [
      {
        "_id": "63875e8182ebbe13ee9531d4",
        "shiftCode": "HOBGS_1100",
        "date": "2022-12-31T00:00:00.000Z"
      },
      {
        "_id": "63b277a2f6a8eccb2d95d407",
        "shiftCode": "WO",
        "date": "2023-01-01T00:00:00.000Z"
      },
      {
        "_id": "63b27787f6a8eccb2d95cf30",
        "shiftCode": "HOBGS_1100",
        "date": "2023-01-02T00:00:00.000Z"
      },
      {
        "_id": "63b277a2f6a8eccb2d95d409",
        "shiftCode": "HOBGS_1100",
        "date": "2023-01-03T00:00:00.000Z"
      }
    ],
    "attendances": [
      {
        "_id": "61307cd385b5055a15cec159",
        "Date": "2022-12-31T00:00:00.000Z",
        "inTime": "2022-12-31T11:16:10.000Z",
        "name": "name2"
      },
      {
        "_id": "63b236ef3980cffaf7715d62",
        "inTime": "2023-01-02T07:14:08.000Z",
        "Date": "2023-01-02T00:00:00.000Z",
        "name": "name2"
      }
    ]
  },
  {
    "workerId": "1006",
    "shiftListData": [
      {
        "_id": "63875e8182ebbe13ee9531d2",
        "shiftCode": "HOBGS_1100",
        "date": "2022-12-31T00:00:00.000Z"
      },
      {
        "_id": "63b277a2f6a8eccb2d95d403",
        "shiftCode": "WO",
        "date": "2023-01-01T00:00:00.000Z"
      },
      {
        "_id": "63b27787f6a8eccb2d95cf39",
        "shiftCode": "HOBGS_1100",
        "date": "2023-01-02T00:00:00.000Z"
      },
      {
        "_id": "63b277a2f6a8eccb2d95d400",
        "shiftCode": "HOBGS_1100",
        "date": "2023-01-03T00:00:00.000Z"
      }
    ],
    "attendances": [
      {
        "_id": "61307cd385b5055a15cec158",
        "Date": "2022-12-31T00:00:00.000Z",
        "inTime": "2022-12-31T11:16:10.000Z",
        "name": "name"
      },
      {
        "_id": "63b236ef3980cffaf7715d69",
        "inTime": "2023-01-02T07:14:08.000Z",
        "Date": "2023-01-02T00:00:00.000Z",
        "name": "name"
      }
    ]
  }
]

I want to merge shiftListData and attendances as per date into one array
Example : -
[
  {
    "workerId": "1005",
    "newData": [
      {
        "_id": "63875e8182ebbe13ee9531d4",
        "shiftCode": "HOBGS_1100",
        "date": "2022-12-31T00:00:00.000Z",
        "attendanceId": "61307cd385b5055a15cec159",
        "attendanceDate": "2022-12-31T00:00:00.000Z",
        "inTime": "2022-12-31T11:16:10.000Z",
        "name": "name2"
      },
      {
        "_id": "63b277a2f6a8eccb2d95d407",
        "shiftCode": "WO",
        "date": "2023-01-01T00:00:00.000Z"
      },
      {
        "_id": "63b27787f6a8eccb2d95cf30",
        "shiftCode": "HOBGS_1100",
        "date": "2023-01-02T00:00:00.000Z",
        "attendanceId": "63b236ef3980cffaf7715d62",
        "inTime": "2023-01-02T07:14:08.000Z",
        "attendanceDate": "2023-01-02T00:00:00.000Z",
        "name": "name2"
      },
      {
        "_id": "63b277a2f6a8eccb2d95d409",
        "shiftCode": "HOBGS_1100",
        "date": "2023-01-03T00:00:00.000Z"
      }
    ]
  },
  {
    "workerId": "1006",
    "newData": [
      {
        "_id": "63875e8182ebbe13ee9531d2",
        "shiftCode": "HOBGS_1100",
        "date": "2022-12-31T00:00:00.000Z",
        "attendanceId": "61307cd385b5055a15cec158",
        "attendanceDate": "2022-12-31T00:00:00.000Z",
        "inTime": "2022-12-31T11:16:10.000Z",
        "name": "name"
      },
      {
        "_id": "63b277a2f6a8eccb2d95d403",
        "shiftCode": "WO",
        "date": "2023-01-01T00:00:00.000Z"
      },
      {
        "_id": "63b27787f6a8eccb2d95cf39",
        "shiftCode": "HOBGS_1100",
        "date": "2023-01-02T00:00:00.000Z",
        "attendanceId": "63b236ef3980cffaf7715d69",
        "inTime": "2023-01-02T07:14:08.000Z",
        "attendanceDate": "2023-01-02T00:00:00.000Z",
        "name": "name"
      },
      {
        "_id": "63b277a2f6a8eccb2d95d400",
        "shiftCode": "HOBGS_1100",
        "date": "2023-01-03T00:00:00.000Z"
      }
    ]
  }
]

A: One option is to add one more step to your pipeline which finds for each shift item its matching item in attendances using $filter:
  {$set: {
      shiftListData: {$map: {
          input: "$shiftListData",
          as: "shift",
          in: {$mergeObjects: [
              "$$shift",
              {$ifNull: [
                  {$first: {
                      $filter: {
                        input: "$attendances",
                        cond: {$eq: ["$$this.Date", "$$shift.date"]}
                      }
                  }},
                  {}
              ]}
          ]}
      }},
      attendances: "$$REMOVE"
  }}

See how it works on the playground example


text:
Q: social studio case creation in SFDC i have created a macros which i have linked it with my salesforce org. I tried applying the marcos to the post(facebook & twitter). I get a message saying macros applied with the note of salesforce org id but when i check SFDC for the case, i dont find any cases in SFDC. Is there any other procedure that i need to follow to send the case to SFDC? It was working couple of months back but when i test it now its not working.

A: Whenever you push a post in from an existing author and that author has an existing open case (or a case that has been closed for less time than your defined reopen period), the Social Posts will thread into the existing case. A new case will only be created if there is no existing open case for that author or if there are no cases that have been closed in the last reopen days.


text:
Q: Download .txt file and extract file name I am trying to download the file in Python from the url https://marketdata.theocc.com/position-limits?reportType=change.
I am able to convert it to DataFrame just by using:
df = pd.read_csv('https://marketdata.theocc.com/position-limits?reportType=change')

But what I want is to obtain the name of the file also.
so, if you download the file directly from browser the name of the file obtain is "POSITIONLIMITCHANGE_20201202.txt".
Can someone suggest an efficient way to do this in Python?
Thanks.

A: if you are using the requests library, the information about the file is in the response header (a dictionary):
response = requests.get('https://marketdata.theocc.com/position-limits?reportType=change')
print(response.headers['content-disposition'])

Output:
attachment; filename=POSITIONLIMITCHANGE_20201202.txt

A: Example code in Python to fetch a file from URL, extract filename, save to local file, and import into Pandas dataframe.
import io
import requests
import re
import pandas as pd

url = 'https://marketdata.theocc.com/position-limits?reportType=change'
r = requests.get(url)
# NOTE: filename is found in content-disposition HTTP response header
s = r.headers.get('content-disposition')

# use regexp with \w to match only safe characters in filename
# this will prevent accepting paths or drive letters as part of name
m = re.search(r'filename=(\w+)', s)
if m:
    filename = m.group(1)
else:
    # set default if filename not provided or name has bad characters
    filename = "out.csv"
print("filename:", filename)
text = r.text

# if you want to write out file with filename provided
with open(filename, 'w') as fp:
    fp.write(text)

# to read from string in-memory wrap with io.StringIO()
df = pd.read_csv(io.StringIO(text))
print(list(df.columns))

Output:
filename: POSITIONLIMITCHANGE_20201202.txt
['Equity_Symbol','   ','Start_Date','Start_Pos_Limit','End_Date','End_Pos_Limit','Action']


text:
Q: How to avoid docker host & docker container access serial port at the same time? In linux host, I can use minicom -D /dev/ttyACM0 -b 115200 to open one serial port, if I execute above command in another terminal, it will show Device /dev/ttyACM0 is locked. Above is my expected behavior.
But if I execute minicom -D /dev/ttyACM0 -b 115200in host, and then use next command to launch a container:
docker run --privileged -idt --name test -v /dev:/dev -v /etc/apt:/etc/apt ubuntu:16.04

And in container, I execute minicom -D /dev/ttyACM0 -b 115200, it will show I open the serial port successfuly.
Then the phenomenon is: If the serial port print some infomation: E.g. Hello world!. The minicom in host may get the content Hello, while the minicom in container may get the content world!, it is random.
Anyway, seems two minicom will compete to grab the content of serial port.
Any suggestion to make the behavior same as in host, says if I open serial port in host, then in container. I can get Device /dev/ttyACM0 is locked in container, if possible?

A: Finally, I got it work myself.
docker run --privileged -idt --pid=host --name test -v /var/lock:/var/lock -v /dev:/dev -v /etc/apt:/etc/apt ubuntu:16.04

The minicom put its lockfile in /var/lock, now with volume container & host can know eachother which serial is used.


text:
Q: public List> MyValue - not generating on client from RIA service - need guidance I have an object in Ria service that is being generated on the client without a problem.  The only problem is that this property is not being included in the client code and therefore missing it's values.
public List<List<string>> MyValue

Everything else is fine.  I assume the problem is because it's a List within a List as regular List

I am confused as to what will generate on the client and what won't with RIA services.  Where can I find some guidance about this?
Anyone have any tips on how to solve this because I need these values returned back to the client?

A: I was able to get this to generate the proxy property on the client by creating my own class called MyStrings which has a single property of type List<string>.
Then, in the Tests class i change the object type from List<List<string>> to List<MyStrings>.
I am not sure why one serializes and one doesn't, but this is a dirty work around I will use for now.

A: I am certain that a List<List<string>> will definitely serialize and deserialize just fine using WCF/RIA. That leads me to believe that perhaps the problem is in your contracts. How are you setting up the service and client proxy?
For example, is MyValue a property on an object that you're sending to or receiving from the server? If so, is there a DataContract attribute on the class on both the client and server? Is there a DataMember attribute on the property of both classes?


text:
Q: How to pass String(phone number) for Quickreply? :D I have a problem(again)...now i want to pass a String from one Activity to another.
The first Activity is SMSReceiver, i make a ListView for contact's number and message's here.
This is the complete code :
public class SMSReceiver extends BroadcastReceiver {

private static final int NOTIF_ID = 0;

@Override
public void onReceive(Context arg0, Intent arg1) {
    // TODO Auto-generated method stub

    Bundle bundle = arg1.getExtras();
    SmsMessage[] msgs = null;
    String str = "";
    if (bundle != null) {
        Object[] pdus = (Object[]) bundle.get("pdus");
        msgs = new SmsMessage[pdus.length];

        for (int i = 0; i < msgs.length; i++) {
            msgs[i] = SmsMessage.createFromPdu((byte[]) pdus[i]);
            str += "You Get New SMS from " + msgs[i].getOriginatingAddress();
            str += " :";                    str += msgs[i].getMessageBody().toString();
            str += "\n";

        Toast.makeText(arg0, str, Toast.LENGTH_SHORT).show();

        NotificationManager nm = (NotificationManager) arg0.getSystemService(Context.NOTIFICATION_SERVICE);

        String tickerText = str;

        Notification notif = new Notification(R.drawable.ic_launcher, tickerText, System.currentTimeMillis());

        notif.flags = Notification.FLAG_AUTO_CANCEL;

        String contentTitle = msgs[i].getOriginatingAddress();
        String contentText = msgs[i].getMessageBody().toString();

        Intent intent = new Intent(arg0, SMSReply.class);
        PendingIntent pi = PendingIntent.getActivity(arg0, 0, intent, 0);

        notif.setLatestEventInfo(arg0, contentTitle, contentText, pi);
        notif.defaults = Notification.DEFAULT_ALL;
        nm.notify(NOTIF_ID, notif);

        String tempSMS = msgs[i].getOriginatingAddress();
        Intent pass = new Intent();
        Bundle bundlePass = new Bundle();

        bundlePass.putString("key", tempSMS);
        pass.putExtras(bundlePass);
        }
    }
}

And this is the PART OF SMSReceiver that i used for passing a String via Bundle and Intent
String tempSMS = msgs[i].getOriginatingAddress();
        Intent pass = new Intent();
        Bundle bundlePass = new Bundle();

        bundlePass.putString("key", tempSMS);
        pass.putExtras(bundlePass);

Now, this is the complete SMSReply Class, the class that i want to get a phone number(String) from SMSReceiver Class(so user don't have to type it again)
public class SMSReply extends Activity implements OnClickListener {

EditText etPhone, etMessage;
Button bSend;
String phone, message;

@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.reply);

    etPhone = (EditText) findViewById(R.id.etPhone);
    etMessage = (EditText) findViewById(R.id.etMessage);
    bSend = (Button) findViewById(R.id.bSend);
    bSend.setOnClickListener(this);
}

public void onClick(View arg0) {
    // TODO Auto-generated method stub
    Intent get = new Intent();

    Bundle bundleGet = get.getExtras();
    phone = bundleGet.getString("answer");
    etPhone.setText(phone);

    phone = etPhone.getText().toString();
    message = etMessage.getText().toString();

    if (phone.length() > 0 && message.length() > 0) {
        sendSms(phone, message);
    } else {
        Toast.makeText(getBaseContext(),
                "Please enter both phone number and message",
                Toast.LENGTH_SHORT).show();
    }
}

private void sendSms(String phone2, String message2) {
    // TODO Auto-generated method stub
    String SENT = "SMS_SENT";
    String DELIVERED = "SMS_DELIVERED";

    PendingIntent sentPI = PendingIntent.getBroadcast(this, 0, new Intent(
            SENT), 0);
    PendingIntent deliveredPI = PendingIntent.getBroadcast(this, 0,
            new Intent(DELIVERED), 0);

    registerReceiver(new BroadcastReceiver() {

        @Override
        public void onReceive(Context arg0, Intent arg1) {
            // TODO Auto-generated method stub
            switch (getResultCode()) {
            case Activity.RESULT_OK:
                Toast.makeText(getBaseContext(), "SMS sent",
                        Toast.LENGTH_SHORT).show();
                break;
            case SmsManager.RESULT_ERROR_GENERIC_FAILURE:
                Toast.makeText(getBaseContext(), "Generic Failure",
                        Toast.LENGTH_SHORT).show();
                break;
            case SmsManager.RESULT_ERROR_NO_SERVICE:
                Toast.makeText(getBaseContext(), "No Service",
                        Toast.LENGTH_SHORT).show();
                break;
            case SmsManager.RESULT_ERROR_NULL_PDU:
                Toast.makeText(getBaseContext(), "Null PDU",
                        Toast.LENGTH_SHORT).show();
                break;
            case SmsManager.RESULT_ERROR_RADIO_OFF:
                Toast.makeText(getBaseContext(), "Radio Off",
                        Toast.LENGTH_SHORT).show();
                break;
            }
        }
    }, new IntentFilter(SENT));

    registerReceiver(new BroadcastReceiver() {

        @Override
        public void onReceive(Context context, Intent intent) {
            // TODO Auto-generated method stub
            switch (getResultCode()) {
            case Activity.RESULT_OK:
                Toast.makeText(getBaseContext(), "SMS Delivered",
                        Toast.LENGTH_SHORT).show();
                break;
            case Activity.RESULT_CANCELED:
                Toast.makeText(getBaseContext(), "SMS not Delivered",
                        Toast.LENGTH_SHORT).show();
            }
        }
    }, new IntentFilter(DELIVERED));
    SmsManager sms = SmsManager.getDefault();
    sms.sendTextMessage(phone, null, message, sentPI, deliveredPI);
}

And this is the PART OF SMSReply class, where i put some code's for taking a String from SMSReceiver and set that String in my EditText :D
Intent get = new Intent();

    Bundle bundleGet = get.getExtras();
    phone = bundleGet.getString("answer");
    etPhone.setText(phone);

    phone = etPhone.getText().toString();
    message = etMessage.getText().toString();

Thats All!
Please help me, and thank you very much! :D
PS : Sory for the long post, and sory if my English is not good, English is not my native languange :D

A: While setting the extra arguments in bundle, you put that bundle in pass Intent and you are doing nothing of that pass Intent. Actually, you should pass these bundle into the intent which you are passing for Notification, i.e. in intent Intent.
intent.putExtras(bundlePass);.
Similarly, while reading the argument from bundle, you are accessing it from a new intent which is not the actual one which comes, So use Bundle bundleGet = getIntent().getExtras();

A: In SMSReceiver
Intent intent = new Intent(arg0, SMSReply.class);
intent.putExtras("key", tempSMS);
startActivity(intent);

In SmsReply
Bundle bund=getIntent().getExtras();
String number=bund.getString("key");

Hope this helps.


text:
Q: Is it possible to disable split screen view from metro app (windows 8)? I have a metro app that will behave funny when user uses the "split screen" windows 8 functionality (as in the following image: http://pureinfotech.com/wp-content/uploads/2012/03/metro-app-desktop-split-screen-windows-8.png).
Is there a way to programatically disable from inside of your app? I haven't found any so far, but I am posting this just in case anyone knows any better.
Thanks in advance!

A: No, you cannot.
I would recommend just navigating to a Splash Screen sort of thing.
Look what happens when you snap the Windows Store.

A: It is technically possible but probably it won't pass the app certification.
You can try using ApplicationView.TryUnsnap()
in the event handler for SizeChanged event of your Page:
In ctor put:
Window.Current.SizeChanged += OnSizeChanged;

And implement the handler method:
public void OnSizeChanged(object sender, Windows.UI.Core.WindowSizeChangedEventArgs args)
    {
        switch (Windows.UI.ViewManagement.ApplicationView.Value)
        {
            case Windows.UI.ViewManagement.ApplicationViewState.Filled:
                VisualStateManager.GoToState(this, "Fill", false);
                break;
            case Windows.UI.ViewManagement.ApplicationViewState.FullScreenLandscape:
                VisualStateManager.GoToState(this, "Full", false);
                break;
            case Windows.UI.ViewManagement.ApplicationViewState.Snapped:
                VisualStateManager.GoToState(this, "Snapped", false);
                break;
            case Windows.UI.ViewManagement.ApplicationViewState.FullScreenPortrait:
                VisualStateManager.GoToState(this, "Portrait", false);
                break;
            default:
                break;
        }

        this.ShowCurrentViewState();
    }

void ShowCurrentViewState()
    {
        ApplicationViewState currentState = Windows.UI.ViewManagement.ApplicationView.Value;
        if (currentState == ApplicationViewState.Snapped)
        {
            ApplicationView.TryUnsnap() ;
        }

   }


text:
Q: Regex skipping to next match I am using PHP/Regex to parse some data for an application.  The pages I am parsing have table formats that include a header followed by a bunch of items.  What I am trying to do is get the header for each table, along with all of the items so that I can label each item as part of that group (defined by the header).
I currently have it set up with an expression matching each header, and then everything up to the next header.  I then use a loop on the header count to match the additional data from the second match in the first expression.
So basically:
preg_match_all ('#table-header.*?>(.*?)<\/td>(.*?)table-header#s', $url, $gr, PREG_PATTERN_ORDER);

for($i = 0; $i < count($gr[0]); $i++) {
  preg_match_all ('#type_id.*?(.*?) ... #s', $gr[2][$i], $info, PREG_PATTERN_ORDER);
  $group = trim($gr[1][$i]);

  for($ii = 0; $ii < count($info[0]); $ii++) {
    $name = trim($info[1][$ii]);
    ...
   }
 }

My issue is that it is skipping every other group, what I can only assume is because it matches table-header to table-header, and then skips to the next table-header instead of starting the next match with the ending table-header of the first match.  How can I get it to start the next match with the end point of the previous match?  Unfortunately the pages do not have enough unique items near the beginning/end points to use something different to match.  The code looks similar to this:

    Header

...items...

    Header 2

I tried using the colspan as the start of my expression, and grabbing everything up to the next table-header, but it just breaks.
Thanks for any suggestions.

A: You should have a look to this class instead:
http://simplehtmldom.sourceforge.net/


text:
Q: calculate the tile of rotation axis of a rolling ball I want to solve the problem of friction effect on rotation axis of a rolling ball on collision with another ball.
I've read Tennis racket theorem in this wikipedia article and thought it might help.
But according to wikipedia :
For bodies with constant density an axis of rotational symmetry is a principal axis.
Assuming the ball has constant density, this means the ball will always rotate around its principal axis, and even if it doesn't I can't determine the first,second,third principal axes as the ball have more than three(every diameter can be a principle axis).
So how to solve this problem ?


text:
Q: Qt error exit code -1073741515 (0xC0000135) I am new to Qt. I was trying to use Qt in CLion and have already modified the CMake settings in CLion to make it use the CMake in Qt. Then I wrote a piece of test code:
#include <iostream>
#include <QApplication>
#include <QDebug>

int main() {
    std::cout << "Hello, World!" << std::endl;
    qDebug() << QT_VERSION_STR;
    return 0;
}

The Build succeeded, but when I try to run it the error Process finished with exit code -1073741515 (0xC0000135) occurred. Could anyone give some instructions on why this error occur and how to fix it?

A: Problem solved by adding C:\Qt\Tools\QtCreator\bin and C:\Qt\5.15.2\mingw81_64\bin to the environment variable PATH. These two paths could be different depends on where you install Qt.
NOTE: Only add C:\Qt\5.15.2\mingw81_64\bin did not solve this problem.


text:
Q: No module named 'gtts' i install gtts with :
pip install gTTS
but Pycharm doesnt import it correctly :/
Python version : 3.7   (i use this version for use pygame)
pip version : 22.3.1
I reinstalled python
but doesnt work
my name file is test (not gtts)


text:
Q: Distinct not working in Doctrine/Symfony Here's what I have:
    $tag = $this->getEntityManager()
        ->getRepository('Model:Tag')
        ->createQueryBuilder('t')
        ->where('t.name LIKE :tag')
        ->setParameter('tag', '%' . $tag . '%')
        ->distinct()
        ->getQuery();

    $tags = $tag->getResult();

    return $tags;

Which I return as a JSON response. Which ends up looking like this:
["2000", "2000", "8000", "8000", "6000", "6000", "7000", "7000", "16000", "16000", "21000", "21000",…]

Clearly the distinct() isn't working. Am I using it in correctly? I must be missing something really obvious!
Any tips are most welcome. Thanks.

EDIT
I now have:
    $tagQuery = $this->getEntityManager()
        ->getRepository('Model:Tag')
        ->createQueryBuilder('t')
        ->select('DISTINCT t.name')
        ->where('t.name LIKE :tag')
        ->setParameter('tag', '%' . $tag . '%')
        ->getQuery();

    $tags = $tagQuery->getResult();

This returns a distinct result set like this:
array (size=19)
  0 =>
    array (size=1)
      'name' => string '2000' (length=4)
  1 =>
    array (size=1)
      'name' => string '8000' (length=4)
  2 =>
    array (size=1)
      'name' => string '6000' (length=4)
  3 =>
    array (size=1)
      'name' => string '7000' (length=4)
  4 =>
    array (size=1)
      'name' => string '16000' (length=5)
  5 =>
    array (size=1)
      'name' => string '21000' (length=5)
  etc...

So I'm moving in the right direction. But how do I just return an array of results like [2000, 8000, 6000, ...]? Rather than the massive array of objects I currently have?


text:
Q: Style is not applied to iframe after deployment to web server I am using id selector to set style for iframe:

and CSS:
@media screen and (max-width: 1199px) and (min-width: 401px) {
    #iframeStyle {
        width: 700px;
        height: 400px;
        max-width: 100%;
        overflow: hidden;
        border: none;
    }
    #idImg {
        width: 700px;
        height: 400px;
    }
}

@media screen and (max-width: 400px) {
    #iframeStyle {
        width: 360px;
        height: 190px;
        max-width: 100%;
        overflow: hidden;
        border: none;
    }
    #idImg {
        width: 360px;
        height: 190px;
    }
}

metadata:

    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>@ViewBag.Title</title>
    @Styles.Render("~/Content/css")
    @Scripts.Render("~/bundles/modernizr")

It works perfectly at localhost and #iframeStyle is always resized when width of the browser is more than 400px or less 400px.
However, after deploying to smarterasp.net, then #iframeStyle is always set to @media screen and (max-width: 400px) even I open the web site at wide display(at Personal Computer). That is, I always see is just small iframe and the size is not changed if I even resize the browser.
How to set properly style for iframe?

A: It loosk correct, i would suggest to

*

*have a fall back to be before the media-query and see what it does.

*Add !important tag and see if it works.

*Check the dev-console and see which one is being used and if anything changes when you resize the window

pls let me know which one worked for u :)
Update:
Cause you are loading styles through Razor:
@Styles.Render("~/Content/css")

then the style is not applied to plain html page.
Just load CSS without Razor and style will be applied to your html page:
<link href="/Content/bootstrap.css" rel="stylesheet" type="text/css" />


text:
Q: Setting an UIImage for UIControlStateHighlighted
board[i] is an array of UIButtons that I have created programmmatically, and I can't change their image for UIControlStateHighlighted:
    [board[i] setImage:[UIImage imageNamed:@"block"] forState:UIControlStateNormal];
    [board[i] setImage:[UIImage imageNamed:@"blockPressed"] forState:UIControlStateHighlighted];

When I press the button with the mouse in the simulator the image doesn't change. I think this is a very noob question, but I don't what the code doesn't work.

A: when adding button programatically do this:

*

*add target of each same.

*provide tag all button from 0 to count.

*set UserInteraction to true

*setBackgroundImage:[UIImage imageNamed:@"blockPressed.png"]  forState:UIControlStateHighlighted if u want button to be highlited
Now button is pressed same method is called for all button: For example
-(void)ButtonTouched:(id)sender
{
   UIButton *btntouched = sender;
   NSLog(@"%@", btntouched);
   [btntouched setBackgroundImage:[UIImage imageNamed:@"blockPressed.png"]  forState:UIControlStateHighlighted];// it can be forState:UIControlStateNormal also
}

A: I don't think you are triggering the highlighted state. This could be because they are not set to have interaction enabled. Or there is something else missing from the way you set up your buttons.
The other thing you can try is to add a selector to each of the buttons for when they are touched, and then change the image by referencing sender for the selector function.

A: Assuming you've made sure your image doesn't return nil, this code should work:
[myUIButton setImage:[UIImage imageNamed:@"myHighlightedButtonImage.png"] forState:UIControlStateHighlighted];

It should work find if you call that line in your viewDidLoad().


text:
Q: brew install sklearn didn't work. What to do next? Heyyy, so I'm following a video tutorial that requires me to install sklearn, quandl, and pandas.
Unfortunately the video author is using Windows and gave no explanation of what to do if on a Mac. I thought maybe I could use homebrew, so I installed homebrew and tried brew install sklearn, but that didn't work.
Error: No available formula with the name "sklearn"

When I tried pip install sklearn I got
-bash: pip: command not found

I had read this comment by user acidjunk: "a home brew python already has pip." I didn't understand this the first time I read it. Now I understand that pip is included in some Python installations. But I've also since learned that installing that way can result in a double installation of Python, so I'm hesitant about doing that.
Also, the accepted answer for that question about installing pip uses sudo, and a comment was made "Never sudo install a package for any language. This is insecure and will ruin your life later as more and more packages need sudo permissions." which sounds like a reasonable argument, and that's why I haven't installed pip that way.
Another user commented elsewhere on Stack Overflow "I can use install sklearn using pip or home brew", so there must be some piece of the puzzle I'm missing if it worked for them but not for me.
To further complicate matters, another user suggested brew install pip, but when I tried that I got the following message:
Homebrew provides pip via: `brew install python`. However you will then
have two Pythons installed on your Mac, so alternatively you can install
pip via the instructions at:
  https://pip.readthedocs.io/en/stable/installing/

Of course I followed the link, but on the page it says: pip is already installed if you're using Python 2 >=2.7.9 or Python 3 >=3.4 binaries downloaded from python.org, but you'll need to upgrade pip.
I have Python 2.7.10 installed, but I didn't get it directly from python.org. I want to make sure that I install it in a way that it will be compatible with homebrew and the packages I mentioned. And I don't think I want to end up with two Pythons installed (unless I need to).
Also, the tutorial author is using Python 3.5.x, so I guess I need to get both 2.7.10 and 3.5.x installed... in a way that they play nicely together. But in any case I don't want to end up with two instances of 2.7.10 in different locations or anything like that.
What's the best way to proceed? Any help greatly appreciated.

A: *

*As far as I know, sklearn alias is deprecated. You may give a try with brew install scikit-learn

*For some reason, you don't have pip as system command. This is probably because you're using system-bundled python. Apple is famous for bundling super-old system deps. I propose to install proper python version with brew. It should install python and pip. Or use official installer

*Even with current installation, you probably should be able to run pip as module with
python -m pip install -U pip


text:
Q: Equivalent C declarations Are
int (*x)[10];

and
int x[10];

equivalent?
According to the "Clockwise Spiral" rule, they parse to different C declarations.
For the click-weary:

The ``Clockwise/Spiral Rule'' By David
  Anderson
There is a technique known as the
  ``Clockwise/Spiral Rule'' which
  enables any C programmer to parse in
  their head any C declaration!
There are three simple steps to follow:

   1. Starting with the unknown element, move in a spiral/clockwise direction;
          when ecountering the following elements replace them with the
          corresponding english statements:

      [X] or []
          => Array X size of... or Array undefined size of...
      (type1, type2)
          => function passing type1 and type2 returning...
      *
          => pointer(s) to...

   2. Keep doing this in a spiral/clockwise direction until all tokens have been covered.

   3. Always resolve anything in parenthesis first!

A: Follow this simple process when reading declarations:

Start at the variable name (or
  innermost construct if no identifier
  is present. Look right without jumping
  over a right parenthesis; say what you
  see. Look left again without jumping
  over a parenthesis; say what you see.
  Jump out a level of parentheses if
  any. Look right; say what you see.
  Look left; say what you see. Continue
  in this manner until you say the
  variable type or return type.

So:
int (*x)[10];

x is a pointer to an array of 10 ints
int x[10];

x is an array of 10 ints
int *x[10];

x is an array of 10 pointers to ints

A: They are not equal. in the first case x is a pointer to an array of 10 integers, in the second case x is an array of 10 integers.
The two types are different. You can see they're not the same thing by checking sizeof in the two cases.

A: I tend to follow The Precedence Rule for Understanding C Declarations which is given very nicely in the book Expert C Programming - Deep C Secrets by Peter van der Linden
A - Declarations are read by starting with the name and then reading in
precedence order.

B - The precedence, from high to low, is:
        B.1 parentheses grouping together parts of a declaration
        B.2 the postfix operators:
        parentheses () indicating a function, and
        square brackets [] indicating an array.
        B.3 the prefix operator: the asterisk denoting "pointer to".

C If a const and/or volatile keyword is next to a type specifier (e.g. int,
        long, etc.) it applies to the type specifier.
        Otherwise the const and/or volatile keyword
        applies to the pointer asterisk on its immediate left.

A: For me, it's easier to remember the rule as absent any explicit grouping, () and [] bind before *.  Thus, for a declaration like
T *a[N];

the [] bind before the *, so a is an N-element array of pointer.  Breaking it down in steps:
   a     -- a
   a[N]  -- is an N-element array
  *a[N]  -- of pointer
T *a[N]  -- to T.

For a declaration like
T (*a)[N];

the parens force the * to bind before the [], so
    a      -- a
  (*a)     -- is a pointer
  (*a)[N]  -- to an N-element array
T (*a)[N]  -- of T

It's still the clockwise/spiral rule, just expressed in a more compact manner.

A: No. First one declares an array of 10 int pointers and second one declares an array of 10 ints.


text:
Q: What Would be the Big O Time Complexity of this Greedy Search for TSP? I just want some clarification/reassurance, looking at the code on this GitHub here, would the Big O notation for the time complexity by On2, as it is directly proportional to the amount of vertices/cities in the problem?

A: The code relies on a distance matrix of cities:
def getDistanceMatrix(cities):
    distanceMatrix = []
    for currentNode in cities:
        subArray = []
        for comparisonNode in cities:
            subArray.append(getDistanceBetweenTwoCities(currentNode, comparisonNode))
        distanceMatrix.append(subArray)
    return distanceMatrix

It is thus of order O(n^2) where n is the number of cities.


text:
Q: How to get appropriate images in respective android Device in Android Studio I'm designing the layout of Music Player. When I'm rendering it with the Nexus 5 virtual device, I'm not facing any problem at all

When I render the image with Nexus 7 it is showing the same image size.

Posting screenshot of my photo too.
Hope to get some solution from you guys.

A: You have to follow this to support multiple devices :
changes in screen density.
xlarge screens are at least 960dp x 720dp
large screens are at least 640dp x 480dp
normal screens are at least 470dp x 320dp
small screens are at least 426dp x 320dp

Make this layout files, so that it will be same for all devices.
res/layout/main_activity.xml           # For handsets (smaller than 600dp available width)
res/layout-sw600dp/main_activity.xml   # For 7" tablets (600dp wide and bigger)
res/layout-sw720dp/main_activity.xml   # For 10" tablets (720dp wide and bigger)

For Layout ,
res/layout/my_layout.xml              // layout for normal screen size ("default")
res/layout-large/my_layout.xml        // layout for large screen size
res/layout-xlarge/my_layout.xml       // layout for extra-large screen size
res/layout-xlarge-land/my_layout.xml  // layout for extra-large in landscape orientation

For Images
res/drawable-mdpi/graphic.png         // bitmap for medium-density
res/drawable-hdpi/graphic.png         // bitmap for high-density
res/drawable-xhdpi/graphic.png        // bitmap for extra-high-density
res/drawable-xxhdpi/graphic.png       // bitmap for extra-extra-high-density

For Icon
res/mipmap-mdpi/my_icon.png         // launcher icon for medium-density
res/mipmap-hdpi/my_icon.png         // launcher icon for high-density
res/mipmap-xhdpi/my_icon.png        // launcher icon for extra-high-density
res/mipmap-xxhdpi/my_icon.png       // launcher icon for extra-extra-high-density
res/mipmap-xxxhdpi/my_icon.png      // launcher icon for extra-extra-extra-high-density

For Launcher icon
36x36 (0.75x) for low-density
48x48 (1.0x baseline) for medium-density
72x72 (1.5x) for high-density
96x96 (2.0x) for extra-high-density
180x180 (3.0x) for extra-extra-high-density
192x192 (4.0x) for extra-extra-extra-high-density (launcher icon only; see note above)

NOTE: Always try to use SP whenever you deal with textSize, like textsize=12sp

Use predefined textAppearance:
It will set text size automatically as per device density.

    <TextView android:textAppearance="?android:attr/textAppearanceSmall"/>
    <TextView android:textAppearance="?android:attr/textAppearanceMedium"/>
    <TextView android:textAppearance="?android:attr/textAppearanceLarge" />
Sample usage:

    <TextView
        style="@android:style/TextAppearance.Small"
        android:text="Sample Text - Small" />
    <TextView
        style="@android:style/TextAppearance.Medium"
        android:text="Sample Text  - Medium" />
    <TextView
        style="@android:style/TextAppearance.Large"
        android:text="Sample Text  - Large" />

Please visit Supporting Multiple Screens


text:
Q: Stimulsoft report not load in MVC View I have tried to use StimulSoftReport in MVC 5. I have designed an .mrt file in stimulsoft designer. I have a view which will print the report.
This view file contains this code:
@using Stimulsoft.Report.Mvc;
@{
    ViewBag.Title = "چاپ قبض";
    Layout = null;
}
@Html.Stimulsoft().StiMvcViewer(
"MvcViewerReport",
new Stimulsoft.Report.Mvc.StiMvcViewerOptions()
{
    ActionGetReportSnapshot = "GetReportSnapshot",
    ActionViewerEvent = "ViewerEvent"

})

The print Action located in same controller as GetReportSnapshot and ViewerEvent . But when Print View shown. It just have toolbar of report viewer and doesn't show my reporter even I create a break point and I found that none of above actions called from the view.
here is the code of GetReportSnapshot :
public ActionResult GetReportSnapshot()
        {
            DataSet dataset = new DataSet();
            dataset.ReadXmlSchema(Server.MapPath("~/Content/report/BillXmlFile.xsd"));
            StiReport report = new StiReport();
            report.Load(Server.MapPath("~/Content/report/Report.mrt"));
            report.Dictionary.ImportXMLSchema(dataset);
            report.Compile();
            return StiMvcViewer.GetReportSnapshotResult(HttpContext, report);
        }

and here is the ViewerEvent code :
public ActionResult ViewerEvent()
        {
            return StiMvcViewer.ViewerEventResult(HttpContext);
        }

What is the matter ? :(

A: my problme fix by adding this part of code to assemblyBinding tag on web.config
<dependentAssembly>
    <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
    <bindingRedirect oldVersion="2.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
</dependentAssembly>

A: You don't pass data to the report. There is just Schema. Usually the DataSet is registered with RegData() method.

A: I don't know could you solve your issue or not? But I had recently problem same as you, I'm working with mvc 5.2.3, I googled but couldn't find suitable solution, so I guessed it's need to change .dll version.
I changed dll to Stimulsoft.Suite.2015.2.Retail and issue has been fixed.
Hope this is help to you.