Q: Sharepoint 2013 PostSetup System.NullReferenceException after upgrade I have SharePoint 2013 with build number = 15.0.4569.1506 now we have installed November 2018 CU, but when i run the product configuration wizard i got the following exception on step 8 out of 9:

I tried many things what I found on the internet but none of them has worked
Here is the part of the related logs.
02/20/2021 10:29:04  19  INF                          Leaving function StringResourceManager.GetResourceString
02/20/2021 10:29:04  19  WRN                          Unable to create a Service Connection Point in the current Active Directory domain. Verify that the SharePoint container exists in the current domain and that you have rights to write to it.
Microsoft.SharePoint.SPException: The object LDAP://CN=Microsoft SharePoint Products,CN=System,DC=dhphbud01,DC=hph,DC=int doesn't exist in the directory.
at Microsoft.SharePoint.Administration.SPServiceConnectionPoint.Ensure(String serviceBindingInformation)
at Microsoft.SharePoint.PostSetupConfiguration.UpgradeTask.Run()
02/20/2021 10:29:24  19  INF                          Entering function TaskCommon.TraceToPsconfigLogAndUpgradeManagerLog
02/20/2021 10:29:24  19  INF                            Not spawning off the upgrade job, but rather running upgrade synchronously by calling SPFarm.Local.Upgrade() for inplace upgrade
02/20/2021 10:29:24  19  INF                          Leaving function TaskCommon.TraceToPsconfigLogAndUpgradeManagerLog
02/20/2021 10:30:15  19  ERR                          Task upgrade has failed with an unknown exception
02/20/2021 10:30:15  19  ERR                          Exception: System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.SharePoint.Upgrade.SPContentDatabaseIntegrity.CheckAppOrphans()
at Microsoft.SharePoint.Upgrade.SPContentDatabaseIntegrity.Check(SPContentDatabaseIntegrityCheckOptions options)
at Microsoft.SharePoint.Upgrade.SPContentDatabaseSequence.ContentDatabaseDataIntegrityCheck()
at Microsoft.SharePoint.Upgrade.SPContentDatabaseSequence.PreUpgrade()
at Microsoft.SharePoint.Upgrade.SPUpgradeSession.Upgrade(Object o, Boolean bRecurse)
at Microsoft.SharePoint.Administration.SPPersistedUpgradableObject.Upgrade(Boolean recursively)
at Microsoft.SharePoint.Administration.SPDatabase.Upgrade(Boolean recursively)
at Microsoft.SharePoint.Administration.SPContentDatabase.<>c__DisplayClass2.b__0()
at Microsoft.SharePoint.SPSecurity.RunAsUser(SPUserToken userToken, Boolean bResetContext, WaitCallback code, Object param)
at Microsoft.SharePoint.Administration.SPContentDatabase.Upgrade(Boolean recursively)
at Microsoft.SharePoint.Upgrade.SPUpgradeSession.ReflexiveUpgrade(Object o, Boolean bRecurse)
at Microsoft.SharePoint.Upgrade.SPUpgradeSession.Upgrade(Object o, Boolean bRecurse)
at Microsoft.SharePoint.Administration.SPPersistedUpgradableObject.Upgrade(Boolean recursively)
at Microsoft.SharePoint.Upgrade.SPUpgradeSession.ReflexiveUpgrade(Object o, Boolean bRecurse)
at Microsoft.SharePoint.Upgrade.SPUpgradeSession.Upgrade(Object o, Boolean bRecurse)
at Microsoft.SharePoint.Administration.SPPersistedUpgradableObject.Upgrade(Boolean recursively)
at Microsoft.SharePoint.Upgrade.SPUpgradeSession.ReflexiveUpgrade(Object o, Boolean bRecurse)
at Microsoft.SharePoint.Upgrade.SPUpgradeSession.Upgrade(Object o, Boolean bRecurse)
at Microsoft.SharePoint.Administration.SPPersistedUpgradableObject.Upgrade(Boolean recursively)
at Microsoft.SharePoint.Upgrade.SPUpgradeSession.ReflexiveUpgrade(Object o, Boolean bRecurse)
at Microsoft.SharePoint.Upgrade.SPUpgradeSession.Upgrade(Object o, Boolean bRecurse)
at Microsoft.SharePoint.Administration.SPPersistedUpgradableObject.Upgrade(Boolean recursively)
at Microsoft.SharePoint.Upgrade.SPUpgradeSession.ReflexiveUpgrade(Object o, Boolean bRecurse)
at Microsoft.SharePoint.Upgrade.SPUpgradeSession.Upgrade(Object o, Boolean bRecurse)
at Microsoft.SharePoint.PostSetupConfiguration.UpgradeTask.Run()
at Microsoft.SharePoint.PostSetupConfiguration.TaskThread.ExecuteTask()
Is there any chance to fix this problem? :S

A: Try to use the CLI version psconfig.exe instead of the GUI psconfigui.exe with the following command (elevated SharePoint PowerShell):
PSConfig.exe -cmd upgrade -inplace b2b -wait -cmd applicationcontent -install -cmd installfeatures -cmd secureresources -cmd services -install
Now it gets weired: If this command also issues an error, execute it again without further troubleshooting, log analysis, ... In most cases, your update will perform successfully. If not: Post your errors again please.


Q: Reading multiple offline html files to a list in R I have rawdata as 20 offline html files stored in following format
../rawdata/1999_table.html
../rawdata/2000_table.html
../rawdata/2001_table.html
../rawdata/2002_table.html
.
.
../rawdata/2017_table.html

These files contain tables that I am extracting and reshaping to a particular format.
I want to read these files at once to a list and process them one by one through a function that I have written.
What I tried:
I put the names of these files into an Excel file called filestoread.xlsx and used a for loop to load these files using the names mentioned in the sheet. But it doesn't seem to work
filestoread <- fread("../rawdata/filestoread.csv")

x <- list()
for (i in nrow(filestoread)) {
  x[[i]] <- read_html(paste0("../rawdata/", filestoread[i]))
}

How can this be done?
Also, after reading the HTML files I want to extract the tables from them and reshape them using a function I wrote after converting it to a data table.
My final objective is to rbind all the tables and have a single data table with year wise entries of the tables in the html file.

A: First save path of your data on one of the following ways.
Either, hardcoded
filestoread <- paste0("../rawdata/", 1999:2017, "_table.html")

or reading all html files in the directory
filestoread <- list.files(path = "../rawdata/", pattern="\\.html$")

Then use lapply()
library(rvest)
lapply(filestoread, function(x) try(read_html(x)))

Note: try() runs the code even when there is a file missing (throwing error).
The second part of your question is a little broad, depends on the content of your files, and there are already some answers, you could consider e.g. this answer. In principle you use a combination of ?html_nodes and  ?html_table.


Q: Transformar em Submenu Fiz uma mudança aqui sobre os códigos do menu e os códigos estava com erros
O Nosso amigo Hugocsl mandou eu pesquisar outro menu e achei
Só tenho uma duvida como faço para o menu ficar responsivo?
Outro erro ao clicar na certa duas vezes ele não volta no mesmo lugar
E na opção dos menus não tem links tem como colocar os link?
Site
Swanky Pure CSS Drop Down Menu

A: 1 - Para fazer o link é só envolver o texto dentro da LI em uma tag A. Só fiz para a primeira opção do menu Dashboard
2 - Para deixar responsivo basta colocar o componente com width de 100%
3 - Para poder abrir e fechar o menu basta vc trocar o type:radio por type:checkbox
Veja como fica o resultado:

@import url(https://fonts.googleapis.com/css?family=Roboto:400,700,300);
ul {
  padding: 0;
  margin: 0;
}

li {
  list-style-type: none;
}

input[type='checkbox'] {
  display: none;
}

label {
  cursor: pointer;
}

::-webkit-scrollbar {
  display: none;
}

body .swanky {
  margin: auto;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
}

body {
  height: 100vh;
  font-weight: 500;
  font-family: "Roboto", sans-serif;
  background: linear-gradient(135deg, #8254EA 0%, #E86DEC 100%);
  -webkit-font-smoothing: antialiased;
  font-size: 12px;
}
body .swanky {
  -webkit-perspective: 600px;
          perspective: 600px;
  /* width: 700px; */
  position: absolute;
  margin: auto;
  /* height: 360px; */
}
body .swanky_title {
  float: right;
  text-align: left;
  width: 400px;
  color: white;
  position: relative;
  top: 70px;
}
body .swanky_title__social a {
  position: relative;
  overflow: hidden;
  width: 140px;
  margin-right: 15px;
  text-decoration: none;
  padding: 0px 0px 5px 0px;
  height: 40px;
  border: 2px solid white;
  float: left;
  color: white;
  font-size: 12px;
  font-weight: 400;
  margin-top: 20px;
}
body .swanky_title__social a .slide {
  height: 45px;
  width: 100px;
  float: left;
  position: absolute;
  -webkit-transform: skew(20deg);
          transform: skew(20deg);
  left: -120px;
  transition-property: left;
  transition-duration: .2s;
  background: white;
}
body .swanky_title__social a .slide .arrow {
  position: absolute;
  right: 31px;
  top: 24px;
  opacity: 0;
  -webkit-transform: skew(-20deg);
          transform: skew(-20deg);
}
body .swanky_title__social a .slide .arrow .stem {
  width: 10px;
  height: 2px;
  background: #858490;
}
body .swanky_title__social a .slide .arrow .point {
  width: 6px;
  height: 6px;
  border-right: 2px solid #858490;
  top: -3px;
  right: 1px;
  position: absolute;
  -webkit-transform: rotate(45deg);
          transform: rotate(45deg);
  border-top: 2px solid #858490;
}
body .swanky_title__social a img {
  width: 16px;
  margin-left: 10px;
  position: relative;
  margin-right: 8px;
  transition-property: margin-left;
  transition-duration: .1s;
  margin-top: 10px;
  top: 4px;
}
body .swanky_title__social a:hover > .slide {
  left: -70px;
  transition-property: left;
  transition-duration: .1s;
}
body .swanky_title__social a:hover > img {
  margin-left: 40px;
  transition-property: margin-left;
  transition-duration: .1s;
}
body .swanky_title__social a:hover > .slide .arrow {
  right: 11px;
  opacity: 1;
  transition-property: right,opacity;
  transition-delay: .07s;
  transition-duration: .2s;
}
body .swanky .intro {
  float: right;
  color: white;
  width: 370px;
  top: 50px;
  position: relative;
}
body .swanky .intro h1 {
  text-shadow: 0px 2px rgba(0, 0, 0, 0.26);
}
body .swanky .intro p {
  line-height: 20px;
  text-shadow: 0px 1px rgba(0, 0, 0, 0.26);
}
body .swanky_wrapper {
  /* width: 225px; */
  height: auto;
  overflow: hidden;
  border-radius: 4px;
  background: #2a394f;
}
body .swanky_wrapper label {
  padding: 25px;
  float: left;
  height: 72px;
  border-bottom: 1px solid #293649;
  position: relative;
  width: 100%;
  color: #eff4fa;
  transition: text-indent .15s, height .3s;
  box-sizing: border-box;
}
body .swanky_wrapper label img {
  margin-right: 10px;
  position: relative;
  top: 2px;
  width: 16px;
}
body .swanky_wrapper label span {
  position: relative;
  top: -3px;
}
body .swanky_wrapper label:hover {
  background: #212e41;
  border-bottom: 1px solid #2A394F;
  text-indent: 4px;
}
body .swanky_wrapper label:hover .bar {
  width: 100%;
}
body .swanky_wrapper label .bar {
  width: 0px;
  transition: width .15s;
  height: 2px;
  position: absolute;
  display: block;
  background: #355789;
  bottom: 0;
  left: 0;
}
body .swanky_wrapper label .lil_arrow {
  width: 5px;
  height: 5px;
  transition: -webkit-transform 0.8s;
  transition: transform 0.8s;
  transition: transform 0.8s, -webkit-transform 0.8s;
  -webkit-transition-timing-function: cubic-bezier(0.68, -0.55, 0.265, 1.55);
  border-top: 2px solid white;
  border-right: 2px solid white;
  float: right;
  position: relative;
  top: 6px;
  right: 2px;
  -webkit-transform: rotate(45deg);
          transform: rotate(45deg);
}
body .swanky_wrapper__content {
  position: absolute;
  display: none;
  overflow: hidden;
  left: 0;
  width: 100%;
}
body .swanky_wrapper__content li {
  width: 100%;
  opacity: 0;
  left: -100%;
  background: #15a4fa;
  padding: 25px 0px;
  text-indent: 25px;
  box-shadow: 0px 0px #126CA1  inset;
  transition: box-shadow .3s,text-indent .3s;
  position: relative;
}
body .swanky_wrapper__content li:hover {
  background: #0c93e4;
  box-shadow: 3px 0px #126CA1  inset;
  transition: box-shadow .3s linear,text-indent .3s linear;
  text-indent: 31px;
}
body .swanky_wrapper__content .clear {
  clear: both;
}

input[type='checkbox']:checked + label .swanky_wrapper__content {
  display: block;
  top: 68px;
  border-bottom: 1px solid #212e41;
}

input[type="checkbox"]:checked + label > .lil_arrow {
  transition: -webkit-transform 0.8s;
  transition: transform 0.8s;
  transition: transform 0.8s, -webkit-transform 0.8s;
  -webkit-transition-timing-function: cubic-bezier(0.68, -0.55, 0.265, 1.55);
  -webkit-transform: rotate(135deg);
  transform: rotate(135deg);
  border-top: 2px solid #14a3f9;
  border-right: 2px solid #14a3f9;
}

input[type='checkbox']:checked + label {
  height: 325px;
  background: #212e41;
  text-indent: 4px;
  transition-property: height;
  transition-duration: .6s;
  -webkit-transition-timing-function: cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

input[type='checkbox']:checked + label .bar {
  width: 0;
}

input[type='checkbox']:checked + label li:nth-of-type(1) {
  -webkit-animation: in 0.15s 0.575s forwards;
          animation: in 0.15s 0.575s forwards;
  -webkit-transition-timing-function: cubic-bezier(0.68, -0.55, 0.265, 1.55);
  -moz-animation: in 0.15s 0.575s forwards;
  -moz-transition-timing-function: cubic-bezier(0.68, -0.55, 0.265, 1.55);
}
input[type='checkbox']:checked + label li:nth-of-type(2) {
  -webkit-animation: in 0.15s 0.7s forwards;
          animation: in 0.15s 0.7s forwards;
  -webkit-transition-timing-function: cubic-bezier(0.68, -0.55, 0.265, 1.55);
  -moz-animation: in 0.15s 0.7s forwards;
  -moz-transition-timing-function: cubic-bezier(0.68, -0.55, 0.265, 1.55);
}
input[type='checkbox']:checked + label li:nth-of-type(3) {
  -webkit-animation: in 0.15s 0.825s forwards;
          animation: in 0.15s 0.825s forwards;
  -webkit-transition-timing-function: cubic-bezier(0.68, -0.55, 0.265, 1.55);
  -moz-animation: in 0.15s 0.825s forwards;
  -moz-transition-timing-function: cubic-bezier(0.68, -0.55, 0.265, 1.55);
}
input[type='checkbox']:checked + label li:nth-of-type(4) {
  -webkit-animation: in 0.15s 0.95s forwards;
          animation: in 0.15s 0.95s forwards;
  -webkit-transition-timing-function: cubic-bezier(0.68, -0.55, 0.265, 1.55);
  -moz-animation: in 0.15s 0.95s forwards;
  -moz-transition-timing-function: cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@-webkit-keyframes in {
  from {
    left: -100%;
    opacity: 0;
  }
  to {
    left: 0;
    opacity: 1;
  }
}

@keyframes in {
  from {
    left: -100%;
    opacity: 0;
  }
  to {
    left: 0;
    opacity: 1;
  }
}
.love {
  position: absolute;
  right: 20px;
  bottom: 0px;
  font-size: 11px;
  font-weight: normal;
}
.love p {
  color: white;
  font-weight: normal;
  font-family: 'Open Sans', sans-serif;
}
.love a {
  color: white;
  font-weight: 700;
  text-decoration: none;
}
.love img {
  position: relative;
  top: 3px;
  margin: 0px 4px;
  width: 10px;
}

.brand {
  position: absolute;
  left: 20px;
  bottom: 14px;
}
.brand img {
  width: 30px;
}

    <input id='Dashboard' name='checkbox' type='checkbox'>

      Dashboard

Tools

Reports

Analytics

Code Blocks

    <input id='Sales' name='checkbox' type='checkbox'>

      Sales

New Sales

Expired Sales

Sales Reports

Deliveries

    <input id='Messages' name='checkbox' type='checkbox'>

      Messages

Inbox

Outbox

Sent

Archived

    <input id='Users' name='checkbox' type='checkbox'>

      Users

New User

User Groups

Permissions

Passwords

    <input id='Settings' checkbox='checkbox' type='checkbox'>

      Settings

Databases

Design

Change User

Log Out


Q: deleting arrays during run time in C++ to spare some memory I have a C++ script running with a C++98 version on a microcontroller ( No upgrade is possible). In this script I need to initialize two vectors of doubles of 405 already existing elements each. I tried initializating two arrays : double a[405]= {7.05925826e+07, ...}; and double b [405]= {arr[0], arr[0]*arr[1]...};. a[405] is defined in the following way:
double a[405] = {a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], a[10], a[11], a[12], a[13], a[14], a[15], a[16], a[17], a[18], a[19], a[20], a[21], a[22], a[23], a[24], a[25], a[26], a[0]*a[0], a[0]*a[1], a[0]*a[2], a[0]*a[3], a[0]*a[4], a[0]*a[5], a[0]*a[6], a[0]*a[7], a[0]*a[8], a[0]*a[9], a[0]*a[10], a[0]*a[11], a[0]*a[12], a[0]*a[13], a[0]*a[14], a[0]*a[15], a[0]*a[16], a[0]*a[17], a[0]*a[18], a[0]*a[19], a[0]*a[20], a[0]*a[21], a[0]*a[22], a[0]*a[23], a[0]*a[24], a[0]*a[25], a[0]*a[26], a[1]*a[1], a[1]*a[2], a[1]*a[3], a[1]*a[4], a[1]*a[5], a[1]*a[6], a[1]*a[7], a[1]*a[8], a[1]*a[9], a[1]*a[10], a[1]*a[11], a[1]*a[12], a[1]*a[13], a[1]*a[14], a[1]*a[15], a[1]*a[16], a[1]*a[17], a[1]*a[18], a[1]*a[19], a[1]*a[20], a[1]*a[21], a[1]*a[22], a[1]*a[23], a[1]*a[24], a[1]*a[25], a[1]*a[26], a[2]*a[2], a[2]*a[3], a[2]*a[4], a[2]*a[5], a[2]*a[6], a[2]*a[7], a[2]*a[8], a[2]*a[9], a[2]*a[10], a[2]*a[11], a[2]*a[12], a[2]*a[13], a[2]*a[14], a[2]*a[15], a[2]*a[16], a[2]*a[17], a[2]*a[18], a[2]*a[19], a[2]*a[20], a[2]*a[21], a[2]*a[22], a[2]*a[23], a[2]*a[24], a[2]*a[25], a[2]*a[26], a[3]*a[3], a[3]*a[4], a[3]*a[5], a[3]*a[6], a[3]*a[7], a[3]*a[8], a[3]*a[9], a[3]*a[10], a[3]*a[11], a[3]*a[12], a[3]*a[13], a[3]*a[14], a[3]*a[15], a[3]*a[16], a[3]*a[17], a[3]*a[18], a[3]*a[19], a[3]*a[20], a[3]*a[21], a[3]*a[22], a[3]*a[23], a[3]*a[24], a[3]*a[25], a[3]*a[26], a[4]*a[4], a[4]*a[5], a[4]*a[6], a[4]*a[7], a[4]*a[8], a[4]*a[9], a[4]*a[10], a[4]*a[11], a[4]*a[12], a[4]*a[13], a[4]*a[14], a[4]*a[15], a[4]*a[16], a[4]*a[17], a[4]*a[18], a[4]*a[19], a[4]*a[20], a[4]*a[21], a[4]*a[22], a[4]*a[23], a[4]*a[24], a[4]*a[25], a[4]*a[26], a[5]*a[5], a[5]*a[6], a[5]*a[7], a[5]*a[8], a[5]*a[9], a[5]*a[10], a[5]*a[11], a[5]*a[12], a[5]*a[13], a[5]*a[14], a[5]*a[15], a[5]*a[16], a[5]*a[17], a[5]*a[18], a[5]*a[19], a[5]*a[20], a[5]*a[21], a[5]*a[22], a[5]*a[23], a[5]*a[24], a[5]*a[25], a[5]*a[26], a[6]*a[6], a[6]*a[7], a[6]*a[8], a[6]*a[9], a[6]*a[10], a[6]*a[11], a[6]*a[12], a[6]*a[13], a[6]*a[14], a[6]*a[15], a[6]*a[16], a[6]*a[17], a[6]*a[18], a[6]*a[19], a[6]*a[20], a[6]*a[21], a[6]*a[22], a[6]*a[23], a[6]*a[24], a[6]*a[25], a[6]*a[26], a[7]*a[7], a[7]*a[8], a[7]*a[9], a[7]*a[10], a[7]*a[11], a[7]*a[12], a[7]*a[13], a[7]*a[14], a[7]*a[15], a[7]*a[16], a[7]*a[17], a[7]*a[18], a[7]*a[19], a[7]*a[20], a[7]*a[21], a[7]*a[22], a[7]*a[23], a[7]*a[24], a[7]*a[25], a[7]*a[26], a[8]*a[8], a[8]*a[9], a[8]*a[10], a[8]*a[11], a[8]*a[12], a[8]*a[13], a[8]*a[14], a[8]*a[15], a[8]*a[16], a[8]*a[17], a[8]*a[18], a[8]*a[19], a[8]*a[20], a[8]*a[21], a[8]*a[22], a[8]*a[23], a[8]*a[24], a[8]*a[25], a[8]*a[26], a[9]*a[9], a[9]*a[10], a[9]*a[11], a[9]*a[12], a[9]*a[13], a[9]*a[14], a[9]*a[15], a[9]*a[16], a[9]*a[17], a[9]*a[18], a[9]*a[19], a[9]*a[20], a[9]*a[21], a[9]*a[22], a[9]*a[23], a[9]*a[24], a[9]*a[25], a[9]*a[26], a[10]*a[10], a[10]*a[11], a[10]*a[12], a[10]*a[13], a[10]*a[14], a[10]*a[15], a[10]*a[16], a[10]*a[17], a[10]*a[18], a[10]*a[19], a[10]*a[20], a[10]*a[21], a[10]*a[22], a[10]*a[23], a[10]*a[24], a[10]*a[25], a[10]*a[26], a[11]*a[11], a[11]*a[12], a[11]*a[13], a[11]*a[14], a[11]*a[15], a[11]*a[16], a[11]*a[17], a[11]*a[18], a[11]*a[19], a[11]*a[20], a[11]*a[21], a[11]*a[22], a[11]*a[23], a[11]*a[24], a[11]*a[25], a[11]*a[26], a[12]*a[12], a[12]*a[13], a[12]*a[14], a[12]*a[15], a[12]*a[16], a[12]*a[17], a[12]*a[18], a[12]*a[19], a[12]*a[20], a[12]*a[21], a[12]*a[22], a[12]*a[23], a[12]*a[24], a[12]*a[25], a[12]*a[26], a[13]*a[13], a[13]*a[14], a[13]*a[15], a[13]*a[16], a[13]*a[17], a[13]*a[18], a[13]*a[19], a[13]*a[20], a[13]*a[21], a[13]*a[22], a[13]*a[23], a[13]*a[24], a[13]*a[25], a[13]*a[26], a[14]*a[14], a[14]*a[15], a[14]*a[16], a[14]*a[17], a[14]*a[18], a[14]*a[19], a[14]*a[20], a[14]*a[21], a[14]*a[22], a[14]*a[23], a[14]*a[24], a[14]*a[25], a[14]*a[26], a[15]*a[15], a[15]*a[16], a[15]*a[17], a[15]*a[18], a[15]*a[19], a[15]*a[20], a[15]*a[21], a[15]*a[22], a[15]*a[23], a[15]*a[24], a[15]*a[25], a[15]*a[26], a[16]*a[16], a[16]*a[17], a[16]*a[18], a[16]*a[19], a[16]*a[20], a[16]*a[21], a[16]*a[22], a[16]*a[23], a[16]*a[24], a[16]*a[25], a[16]*a[26], a[17]*a[17], a[17]*a[18], a[17]*a[19], a[17]*a[20], a[17]*a[21], a[17]*a[22], a[17]*a[23], a[17]*a[24], a[17]*a[25], a[17]*a[26], a[18]*a[18], a[18]*a[19], a[18]*a[20], a[18]*a[21], a[18]*a[22], a[18]*a[23], a[18]*a[24], a[18]*a[25], a[18]*a[26], a[19]*a[19], a[19]*a[20], a[19]*a[21], a[19]*a[22], a[19]*a[23], a[19]*a[24], a[19]*a[25], a[19]*a[26], a[20]*a[20], a[20]*a[21], a[20]*a[22], a[20]*a[23], a[20]*a[24], a[20]*a[25], a[20]*a[26], a[21]*a[21], a[21]*a[22], a[21]*a[23], a[21]*a[24], a[21]*a[25], a[21]*a[26], a[22]*a[22], a[22]*a[23], a[22]*a[24], a[22]*a[25], a[22]*a[26], a[23]*a[23], a[23]*a[24], a[23]*a[25], a[23]*a[26], a[24]*a[24], a[24]*a[25], a[24]*a[26], a[25]*a[25], a[25]*a[26], a[26]*a[26]};

and then converting them using this function:
std::vector<double > ArrayToVector(double* arr, size_t arr_len) {
return std::vector<double>(arr, arr + arr_len);
}

std::vector<double> vec1= ArrayToVector(a,405);
std::vector<double> vec2= ArrayToVector(b,405);

The conversion of the arrays into a vectors causes memory problems. I am looking for a way to delete the first array a[405] just after converting it to vector in order to spare some memory for the second array conversion. I tried using new operator but that didn't work for me . Any other solution to reduce memory usage is appreciated.
Then I use a[] and b[] to calculate their scalar product using this function:
double scalar_product(std::vector<double> a, std::vector<double> b)
{
    if( a.size() != b.size() ) // error check
    {
        //puts( "Error a's size not equal to b's size" ) ;
        return -1 ;  // not defined
    }
    // compute
    double product = 0;
    for (unsigned int i = 0; i <= a.size() - 1; i++)
        product += (a[i])*(b[i]); // += means add to product
    return product;
}

A: As some people have already suggested in comments, you don't really need to convert your arrays to vectors - just work directly with the arrays. All you need to add is the size of the arrays as a third parameter to your function. For that you obviously need to know the size, but since this is running on a microcontroller, where memory budget is tight, I'm relatively certain that you have access to the size info. So it could look like:
double scalar_product(double a[], double b[], unsigned int size)
{
    // compute
    double product = 0;
    for (unsigned int i = 0; i <= size - 1; i++)
        product += (a[i])*(b[i]); // += means add to product
    return product;
}

I'm assuming that their sizes are the same (they should) but even if not, you could use this to calculate a (partial) scalar product for two differently sized arrays, by supplying the shorter one's size.

A: You are not allocating your double[] arrays dynamically via new[], so they cannot be freed dynamically.  They are being declared in automatic memory, so they will be freed only when they go out of scope.
Since you are concerned with limited memory usage, your best option is to simply not convert your double[] arrays to std::vector<double> at all. Change your scalar_product() function instead so it can handle the original double[] arrays as-is, eg:
double scalar_product(const double *a, size_t a_size, const double *b, size_t b_size)
{
    if( a_size != b_size ) // error check
    {
        //puts( "Error a's size not equal to b's size" ) ;
        return -1 ;  // not defined
    }
    // compute
    double product = 0;
    for (size_t i = 0; i < a_size; ++i)
        product += (a[i])*(b[i]); // += means add to product
    return product;
}

double a[405] = ...;
double b[405] = ...;
double product = scalar_product(a, 405, b, 405);

/*
if, for some reason, you also needed to get the product of vectors,
you can do this:

double scalar_product(const std::vector<double> &a, const std::vector<double> &b)
{
    return scalar_product(&a[0], a.size(), &b[0], b.size());
}

vector<double> a = ...;
vector<double> b = ...;
double product = scalar_product(a, b);
*/

Or:
double scalar_product(const double *a, const double *b, size_t n)
{
    // compute
    double product = 0;
    for (size_t i = 0; i < n; ++i)
        product += (a[i])*(b[i]); // += means add to product
    return product;
}

double a[405] = ...;
double b[405] = ...;
double product = scalar_product(a, b, 405);

/*
if, for some reason, you also needed to get the product of vectors,
you can do this:

double scalar_product(const std::vector<double> &a, const std::vector<double> &b)
{
    return (a.size() == b.size())
        ? scalar_product(&a[0], &b[0], a.size())
        : -1.0;
}

vector<double> a = ...;
vector<double> b = ...;
double product = scalar_product(a, b);
*/

Alternatively, you can let the compiler deduce the array sizes for you, if you are passing in the original arrays directly, and not passing in pointers to the arrays:
template<size_t a_size, size_t b_size>
double scalar_product(const double (&a)[a_size], const double (&b)[b_size])
{
    if( a_size != b_size ) // error check
    {
        //puts( "Error a's size not equal to b's size" ) ;
        return -1 ;  // not defined
    }
    // compute
    double product = 0;
    for (size_t i = 0; i < a_size; ++i)
        product += (a[i])*(b[i]); // += means add to product
    return product;
}

double a[405] = ...;
double b[405] = ...;
double product;

product = scalar_product(a, b); // OK

double *pa = a;
double *pb = b;
product = scalar_product(pa, pb); // COMPILER ERROR

/*
this approach doesn't work with vectors, so you will need a
separate overload of scalar_product() for that...
*/

Or:
template<size_t N>
double scalar_product(const double (&a)[N], const double (&b)[N])
{
    // compute
    double product = 0;
    for (size_t i = 0; i < N; ++i)
        product += (a[i])*(b[i]); // += means add to product
    return product;
}

double a[405] = ...;
double b[405] = ...;
double product;

product = scalar_product(a, b); // OK

double c[404] = ...;
double d[405] = ...;

product = scalar_product(c, d); // COMPILER ERROR

/*
this approach doesn't work with vectors, so you will need a
separate overload of scalar_product() for that...
*/

Otherwise, if the array size is constant at compile-time, then just hard-code it:
const size_t ArrSize = 405;

double scalar_product(const double (&a)[ArrSize], const double (&b)[ArrSize])
{
    // compute
    double product = 0;
    for (size_t i = 0; i < ArrSize; ++i)
        product += (a[i])*(b[i]); // += means add to product
    return product;
}

double a[ArrSize] = ...;
double b[ArrSize] = ...;
double product = scalar_product(a, b);

/*
this approach doesn't work with vectors, so you will need a
separate overload of scalar_product() for that...
*/

A: An array must be dynamically allocated (using the new[] operator) in order to use the delete[] operator to free it. As the comments have mentioned, you should post how you create your arrays so we can get a better understanding of how they are stored in memory.
double a* = new double[size];
// do stuff with a
delete[] a;

The above example is legal and will do what you asked.


Q: How to find the distribution in python? I have data set from Goodreads with Number of books read over a year with details like number of pages of the each book, date read etc. I want to know in which month/week I have read most/least. How do I do that in Python ?


Q: Need help repartitioning When I installed ubuntu, I gave it 30 gb think that I wasn’t going to use it much. Well, now I am short on space and I’d like to give it some more. I have a 50 gb chunk sitting in front of the partition that ubuntu is installed on, but I cannot figure out how to add it to the partition.


Q: iCloud - Moving the file completed I can able to move a file from the local directory to iCloud using the condition setUbiquitous:YES. The file has been moved successfully. If the file size is large, it takes certain time to complete moving. Is there any method to identify, if the file has completed moving to iCloud? Thanks in advance for your answers.

A: Note: I haven't done this myself, so all the info below is purely from reading the documentation:
The NSMetadataItem class has, among others, an attribute key called NSMetadataUbiquitousItemIsUploadedKey. Knowing this, you should be able to set up an NSMetadataQuery that notifies you once the item has been uploaded.

A: You can check with NSUURL getResourceValue:forKey:error: method
NSURLUbiquitousItemIsUploadedKey—Indicates that locally made changes were successfully uploaded to the iCloud server.
NSURLUbiquitousItemIsUploadingKey—Indicates that locally made changes are being uploaded to the iCloud server now.
NSURLUbiquitousItemPercentUploadedKey—For an item being uploaded, indicates what percentage of the changes have already been uploaded to the server.
For details: https://developer.apple.com/library/ios/#documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/iCloud/iCloud.html#//apple_ref/doc/uid/TP40007072-CH5-SW1


Q: OSX equivalent of SymGetLineFromAddr or SymGetLineFromAddr64 I want to add source file and line numbers to my backtraces, on Windows there is a nice function SymGetLineFromAddr64 which provides such information if available. I can't find something similar on mac.
dladdr outputs only symbol name without file information.

A: There is no public equivalent to SymGetLineFromAddr64 on OS X, but you can get source file and line number with the atos(1) developer tool.
Here is some sample code to get a fully symbolized backtrace.
#import <Foundation/Foundation.h>

static NSArray * Backtrace(NSArray *callStackReturnAddresses)
{
    NSMutableArray *backtrace = [NSMutableArray new];
    for (NSNumber *address in callStackReturnAddresses)
    {
        NSString *hexadecimalAddress = [NSString stringWithFormat:@"0x%0*lx", (int)sizeof(void*) * 2, address.unsignedIntegerValue];
        NSTask *task = [NSTask new];
        NSPipe *pipe = [NSPipe pipe];
        task.launchPath = @"/usr/bin/xcrun";
        task.arguments = @[ @"atos", @"-d", @"-p", @(getpid()).description, hexadecimalAddress ];
        task.standardOutput = pipe;
        NSString *symbol = @"???";
        @try
        {
            [task launch];
            NSData *data = [pipe.fileHandleForReading readDataToEndOfFile];
            symbol = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
            symbol = [symbol stringByTrimmingCharactersInSet:[NSCharacterSet newlineCharacterSet]];
            [task waitUntilExit];
        }
        @catch (NSException *exception) {}
        [backtrace addObject:[NSString stringWithFormat:@"%@ %@", hexadecimalAddress, symbol]];
    }
    return [backtrace copy];
}

static void test(void)
{
    NSLog(@"%@", Backtrace([NSThread callStackReturnAddresses]));
}

int main(int argc, const char * argv[])
{
    test();
    return 0;
}

Running this code will produce the following output:
0x000000010000134e test (in a.out) (main.m:31)
0x000000010000131b main (in a.out) (main.m:36)
0x00007fff8c0935fd start (in libdyld.dylib) + 1


Q: Как выполнить select? select category
     , sum(number*(1-abs(sign(region-1)))) as reg1
     , sum(number*(1-abs(sign(region-2)))) as reg2
     , sum(number*(1-abs(sign(region-3)))) as reg3
     , sum(number*(1-abs(sign(region-4)))) as reg4
from groups
    JOIN orders USING (id_order)
WHERE datetime_order >= '$date_start'
  AND datetime_order <= '$date_end'
group by category;`

Этим кодом я получаю таблицу как на картинке.
Всего может быть 8 категорий, то есть значение должны быть цифры от 1 до 8. Но в таблице не факт, что они все будут содержаться, особенно в этот промежуток времени.
Как сделать, чтобы в первом столбце были цифры категорий, а в других соответствующие данные. Хочу, чтобы выводились нули, если по ним нем информации в таблице

A: Как правильно подметил Akina, используйте LEFT JOIN, который оставит все значения из таблицы groups. При left join в правой таблице orders при отсутствии пересекающихся значений будет null, поэтому, чтобы корректно использовать sum, необходимо добавить ifnull, coalesce или nvl на выбор:
select category
     , sum(ifnull(number*(1-abs(sign(region-1))), 0)) as reg1
     , sum(ifnull(number*(1-abs(sign(region-2))), 0)) as reg2
     , sum(ifnull(number*(1-abs(sign(region-3))), 0)) as reg3
     , sum(ifnull(number*(1-abs(sign(region-4))), 0)) as reg4
from groups
    LEFT JOIN orders ON groups.id_order = orders.id_order
         AND datetime_order between '$date_start' and '$date_end'
group by category

A: CREATE TEMPORARY TABLE temp1 (id int, reg1 int default 0, reg2 int default 0, reg3 int default 0, reg4 int default 0);
/* Заполнение */
INSERT INTO temp1 (id) VALUES ('1');
INSERT INTO temp1 (id) VALUES ('2');
INSERT INTO temp1 (id) VALUES ('3');
INSERT INTO temp1 (id) VALUES ('4');
INSERT INTO temp1 (id) VALUES ('5');
INSERT INTO temp1 (id) VALUES ('6');
INSERT INTO temp1 (id) VALUES ('7');
INSERT INTO temp1 (id) VALUES ('8');
INSERT INTO temp1 (id) VALUES ('9');

SELECT t.id, coalesce(subquery.reg1, t.reg1), coalesce(subquery.reg2, t.reg2), coalesce(subquery.reg3, t.reg3), coalesce(subquery.reg4, t.reg4)
FROM temp1 t
  LEFT JOIN
  (
    select category, sum(number*(1-abs(sign(region-1)))) as reg1,
                     sum(number*(1-abs(sign(region-2)))) as reg2,
                     sum(number*(1-abs(sign(region-3)))) as reg3,
                     sum(number*(1-abs(sign(region-4)))) as reg4
    from groups JOIN orders USING (id_order)
    WHERE datetime_order >= '$date_start' AND datetime_order <= '$date_end'
    group by category
  ) subquery ON t.id = subquery.category;

DROP TABLE temp1;

В итоге все хорошо работает через временную таблицу


Q: In a principal ideal ring, is every nonzero prime ideal maximal? Inspired by this question, I was wondering whether from just the hypothesis that $A[X]$ is a nontrivial (commutative) principal ideal ring (so without supposing it is a domain) one can deduce that $A$ is a field. One possibility to prove that would be to use the fact, if it is one, that in principal ideal rings nonzero prime ideals are maximal. Namely, if $\def\p{\mathfrak p}\p\subset A$ is a prime ideal, then $(A/\p)[X]$, which is a quotient of $A[X]$ that is an integral domain but not a field, would have to be $A[X]$ itself, so $\p=(0)$, and $A$ having no nonzero prime ideals would have to be a field.
I think I can prove this, but I don't really like the argument I found, and since commutative algebra with zero divisors is not my speciality, I might have tripped up. So my question is are the proposition and its proof below correct, and if so is there a more elementary proof?
Notably I tried, under the hypothesis that $R$ is a principal ideal ring and $\p\subset R$ a prime ideal, and supposing $R\supset I=xR\supset\p=pR$, to use the existence of $y$ with $xy=p$ to arrive at a contradiction; but from $\p$ prime I only get $yR=pR$, and since over rings with zero divisors principal ideals may concide without their generators being associated, I don't see how to conclude.
(Proposed but false)
Proposition. Any nonzero prime ideal $\p$ of a principal ideal ring $R$ is maximal in $R$.
Proof. According to the Zariski-Samuel theorem $R$ is isomorphic to a finite direct product of rings that are either a principal ideal domain or a special principal ring. Every ideal $I$ of a finite product $R_1\times\cdots\times R_n$ is equal to a product $I_1\times\cdots\times I_n$ of ideals of the respective rings, where $I_k$ is the projection of $I$ to $R_k$ (clearly $I\subseteq I_1\times\cdots\times I_n$, but also $(0,\ldots,0,1,0,\ldots,0)I=\{0\}\times\cdots\{0\}\times I_k\times\{0\}\times\cdots\times\{0\}\subseteq I$) and since a product of more than one nontrivial ring is never an integral domain,
$\p$ has to be of the form $R_1\times\cdots\times R_{k-1}\times\p_0\times R_{k+1}\times\cdots\times R_n$ where $\p_0\subset R_k$ is a prime ideal. So we have reduced to proving the proposition in the cases that $R$ is a principal ideal domain or a special principal ring. The former case is well known, and in a nontrivial special principal ring every ideal is a power of the unique maximal ideal $\def\m{\mathfrak m}\m$; putting $\p=\m^k$ a generator of $\m$ gives a nilpotent element of the integral domain $R/\p$, which must be zero, so $\p=\m$ as desired. QED

A: If $A$ is a finite product of fields, then $A[x]$ is a principal ideal ring. I think the converse also holds.
A principal ideal ring has dimension $\leq 1$ (see here, this is elementary). If $A[x]$ is a principal ideal ring, then $1 \geq \dim(A[x]) \geq \dim(A)+1$, hence $\dim(A)=0$. Besides, $A$ is a principal ideal ring (as a quotient of $A[x]$), in particular noetherian. It is well-known that then $A$ is artinian, and that $A$ is a finite product of local artinian rings. Passing to one of the factors, we may assume that $A$ is local artinian ring and have to show that $A$ is a field.
[... to be continued later, I have to go now]

A: The missing piece of Martin Brandenburg's answer is the following:

Let $A$ be an artinian local ring such that $A[X]$ is a PIR. Then $A$ is a field.

Obviously $A$ is a PIR. Let $\mathfrak m=(a)$ be the maximal ideal of $A$. If $a=0$ we are done. Assume that $a\neq 0$. Since $A[X]$ is a PIR, the ideal $(a,X)$ of $A[X]$ is principal, that is, there exists $f\in A[X]$ such that $(a,X)=(f)$. Then $A[X]/(f)\simeq A/(a)$ is a field, so $f$ generates a maximal ideal. On the other side, $A[X]/(a)\simeq A[X]/\mathfrak m[X]\simeq (A/\mathfrak m)[X]$ is an integral domain, so $a$ generates a prime ideal in $A[X]$. Since $a\in(f)$ we get that $a=fv$, $v\in A[X]$. Then $fv\in (a)$ implies $f\in (a)$ or $v\in (a)$. If $f\in (a)$, then $f=ag$, $g\in A[X]$. Since $X\in (f)$ there exists $h\in A[X]$ such that $X=fh$. We get $X=agh$ and then, by identifying the coefficients, we obtain $1=ab$, for some $b\in A$, a contradiction. If $f\notin (a)$, then $v\in(a)$, that is, $v=av'$, and therefore $a=afv'$. It follows that $1-fv'$ is a zerodivisor of $A[X]$. But it's easy to show that $J(A[X])=aA[X]$ and $Z(A[X])=aA[X]$ (here $J(A[X])$ stands for the Jacobson radical of $A[X]$ and $Z(A[X])$ for the set of zerodivisors of $A[X]$). Thus $1-fv'\in J(A[X])$. In particular, $1-(1-fv')=fv'$ is an invertible element of $A[X]$, so $f$ is invertible, a contradiction.

A: Below is a much more general characterization of PIR semigroup-ring $\rm\,R[S].\,$ Note that the polynomial ring $\rm\,R[x]\,$ is the special case when $\rm\:S \cong \Bbb N,\,$ and the Laurent polynomial ring $\rm\:R[x,x^{-1}]\:$ is the special case $\rm\:S\cong \Bbb Z.\:$ See this answer for much more.
Theorem $\ $ TFAE for a semigroup ring R[S], with unitary ring R, and nonzero torsion-free cancellative monoid S.
$\rm(1)\ \ $  R[S] is a PIR (Principal Ideal Ring)
$\rm(2)\ \ $ R[S] is a general ZPI-ring  (i.e. a Dedekind ring, see below)
$(3)\ \ $ R[S] is a multiplication ring  (i.e.  $\rm\ I \supset\ J \Rightarrow\ I\ |\ J\ $  for ideals $\rm\:I,J\,)$
$(4)\ \ $ R is a finite direct sum of fields, and $\rm\,S\,$ is isomorphic to $\,\mathbb Z\,$ or $\,\mathbb N\,$
A  general ZPI-ring  is a ring-theoretic analog of a Dedekind domain
i.e. a ring where every ideal is a finite product of prime ideals.
A unitary ring R is a general ZPI-ring $\iff$ R is a finite direct sum
of Dedekind domains and special primary rings (aka SPIR = special PIR)
i.e. local PIRs with nilpotent max ideals. ZPI comes from the German
phrase "Zerlegung in Primideale" = factorization in prime ideals.
The classical results on Dedekind domains were extended to rings
with zero divisors by S. Mori circa 1940, then later by K. Asano
and, more recently, by R. Gilmer. See Gilmer's book "Commutative
Semigroup Rings" section 18 (and section 13 for the domain case).

A: I guess the answers given clearly show that what I set out to show ($A[X]$ a principal ring implies $A$ a field) is false, and since the deduction of that conclusion from the proposition seems straightforward enough, the proposition must also be false. Indeed it is: by the first two points in Step 0 of Pete L. Clark, for any pair of fields $F,F'$ the ring $(F\times F')[X]$ has a prime ideal $(F\times\{0\})[X]$ that is not maximal.
In particular, the ring $\def\Z{\mathbf Z}(\Z/10\Z)[X]$ is a principal ideal ring, while $\Z/10\Z$ is of course not a field. More generally $(\Z/n\Z)[X]$ provides a counterexample whenever $n$ is composite but square-free. To see explicitly that this is a principal ideal ring, reduce a given ideal $I\in(\Z/n\Z)[X]$ modulo every prime factor$~p$ of$~n$, find a minimal degree nonzero element as generator, or $0$ if the ideal collapses to $\{0\}$ modulo$~p$, then apply the Chinese remainder theorem separately for the coefficients of each $X^i$ to reconstruct a polynomial in $(\Z/n\Z)[X]$ that represents all those generator polynomials at once, which gives a generator of $I$.
So what about the proof (which I really believed in when I wrote it)? It is the innocent looking condition "nonzero" that was overlooked in the proof: the fact that $R_1\times\cdots\times I_k\times\cdots\times R_n$ is nonzero does not imply that $I_k$ nonzero. So there is no reduction to the same proposition for each of the factors, and the proof fails. In fact the proposition itself fails as soon as there is at least one PID factor and at least one other nontrivial factor in the product of rings.

A: Martin Brandenburg is right: for a commutative ring $A$, $A[t]$ is a principal ideal ring (henceforth a "principal ring") iff $A$ is a finite product of fields.
In the following, all rings will be commutative.
Step 0: We make use of the following easy facts:
$\bullet$ A finite product of principal rings is a principal ring.
$\bullet$ For any rings $A_1$ and $A_2$, we have $(A_1 \times A_2)[t] \cong A_1[t] \times A_2[t]$.
$\bullet$ For any ideal $I$ in a ring $R$, $R[t]/IR[t] \cong (R/I)[t]$.
Step 1: If $A[t]$ is principal, so is $A$.  By a theorem of Hungerford, $A$ is isomorphic to a finite product of rings $\prod_{i=1}^r A_i$, each of which is either a PID or a quotient of a PID.  Then $A[t] \cong \prod_{i=1}^r A_i[t]$. Each $A_i[t]$ has dimension one more than the dimension of $A_i$, so if there is a PID factor then $A[t]$ has dimension $2$, contradiction.  So we are left with the case of a finite product of quotients of a PID.  By a Chinese Remainder Theorem argument we can further decompose this into a finite product of quotients of DVRs, and thus we reduce to the following local case:
Let $A$ be a DVR with uniformizer $\pi$.  If for some $n \in \mathbb{Z}^+$ the ring $B = A/\langle \pi^n \rangle[t] \cong A[t]/\langle \pi^n \rangle$ is principal, then $n = 1$.
Step 2: Let's assume $n > 1$. The evident thing to do here is try to show that the ideal (in $B$ naturally corresponding to) $I = \langle \pi ,t \rangle$ is not principal.  This should be an elementary calculation.  I decided to reduce myself to an easier calculation though: if $I$ were principal, then so would be its pushforward in the quotient ring $B' = A[t]/\langle \pi,t \rangle^2$, and this calculation is truly easy: suppose $I = \langle p \rangle$.  Then there are $x,y \in B'$ with $px = \pi$, $py = t$.  We can write
$p = p_0 + p_1 t$, $x = x_0 + x_1 t$, $y = y_0 + y_1 t$ with $p_i,x_i,y_i \in A$.  If you multiply everything out and consider the "valuations" of $p_i$, $x_i$, $y_i$ -- here I use parentheses because I am working in a quotient with $\pi^2 = 0$, so one can think of every element as having valuation $0$, $1$ or $\geq 2$ -- then you see in a few lines that this is not possible.
$\newcommand{\mm}{\mathfrak{m}}$
Added: Here is an approach to Step 2 that avoids any computation.  Consider the maximal ideal $\mm = \langle \pi, t \rangle$ in $\tilde{B} = A[t]$.  It obviously has height at least $2$, so by the Generalized Principal Ideal Theorem (GPIT) it is not principal (and in fact has height exactly $2$).  Consider its image in the localization $C = \tilde{B}_\mm$: the height has not changed so it still requires $2$ generators.  By Nakayama's Lemma, the minimal number of generators of $\mm$ is equal to the minimal number of generators of $\mm/\mm^2$, so $\mm/\mm^2$ is indeed a nonprincipal ideal in $C/\mm^2 = B'$.

Comments: 1) Note that I ended up using a harder result than the one of Zariski-Samuel that a principal ring is a finite product of PIDs and Artinian principal rings.  In particular, the result of Zarisk-Samuel is proved in my commutative algebra notes, but Hungerford's Theorem is only stated: the proof uses the Cohen structure theory of complete local rings, which I do not treat.  I expect this will turn out to be overkill.

*If you only wanted to answer the title question, there are easier ways to go.  Martin Brandenburg's answer links to a webpage which gives a completely elementary proof that a principal ideal ring has dimension at most one.  To my mind though the most natural proof of this is simply to apply Krull's Principal Ideal Theorem, which implies that a prime ideal of height $n$ in a Noetherian ring requires at least $n$ generators.

*If in the construction above we take our DVR $A$ to be $\mathbb{Z}_p$, then the ring $B' = A[t]/\langle p,t \rangle^2$ is a nonprincipal ring of finite order $p^3$.  This is minimal in the sense that a finite nonprincipal ring must have order divisible by the cube of some prime.

*Note that a commutative ring is a finite product of fields iff it is a semisimple ring: every short exact sequence of $R$-modules splits.  Is there a different proof which uses this fact?


Q: Rubycas-server character encoding issue (Internal server error) Since a couple of months ago we are using in production environment a rubycass-server 1.0 validating against Active directory (Microsoft 2008 r2 server). We are using ruby 1.9.2p180, sinatra-1.1.3...  We are having problems with Spanish and Catalan languages. If a user types ñ or ç … in the login or password field when he sends the form it produces an “internal server error” message. I have activated the debug mode in the config.yml options but when this error rises it does not appear any hint into the log file. A couple of days ago I tried the last version of rubycas 1.1.0 and this error (Internal server..) didn’t happen but if the login/password had any of this characters the validation always failed with the message “password incorrect”. I think it is an encoding error.
Has anybody found a solution to this problem?
Thanks in advance,

A: Solved. Problem was caused because we were using an old version of net-ldap (0.1.1). I updated this gem to the last version (0.3.1) and works like a charm.


Q: alternative method for getting http response in android I get the null response with
HttpResponse response = client.execute(post);

This method some time give correct response but mostly give the null response without any code change. I also tried it using the AsyncTask, but got same behavior. Following is my code with AsyncTask. If any suggestion please tell me.
Thank you.
protected void onPreExecute() {
     client = new DefaultHttpClient();
     HttpConnectionParams.setConnectionTimeout(client.getParams(), TIMEOUT_MS);
     HttpConnectionParams.setSoTimeout(client.getParams(), TIMEOUT_MS);
     post = new HttpPost("http://www.google.co.in/m");
     pairs = new ArrayList<NameValuePair>();
     pairs.add(new BasicNameValuePair("hl", "en"));
     pairs.add(new BasicNameValuePair("gl", "us"));
     pairs.add(new BasicNameValuePair("source", "android-launcher-widget"));
     pairs.add(new BasicNameValuePair("q", "persistent"));
     try {
            post.setEntity(new UrlEncodedFormEntity(pairs));
            SystemClock.sleep(400);

        } catch (UnsupportedEncodingException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    this.dialog.setMessage("starts...");
    this.dialog.show();

}
@Override
protected HttpResponse doInBackground(Void... arg0) {
    try {
        HttpResponse response = client.execute(post); //this returns null responce
        if(response.getStatusLine().getStatusCode() == HttpStatus.SC_OK)
        {
             return response;
        }
    } catch (ClientProtocolException e) {
        e.printStackTrace();
    } catch (IOException e) {
        //Toast.makeText(url.this, "problem in execute....", 20).show();
        // TODO Auto-generated catch block
        //put the balance is empty dialog box here.
        e.printStackTrace();
    }catch(NullPointerException e)
    {
        e.printStackTrace();
    }

    return null;
}

my log says..
04-20 20:19:55.877: WARN/System.err(365): java.net.UnknownHostException: www.google.co.in
04-20 20:19:55.897: WARN/System.err(365): at java.net.InetAddress.lookupHostByName(InetAddress.java:506)

04-20 20:19:55.897: WARN/System.err(365): at java.net.InetAddress.getAllByNameImpl(InetAddress.java:294)

04-20 20:19:55.907: WARN/System.err(365): at java.net.InetAddress.getAllByName(InetAddress.java:256)

04-20 20:19:55.907: WARN/System.err(365): at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:136)

04-20 20:19:55.907: WARN/System.err(365): at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)

04-20 20:19:55.927: WARN/System.err(365): at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
04-20 20:19:55.927: WARN/System.err(365): at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:348)

04-20 20:19:55.937: WARN/System.err(365): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)

04-20 20:19:55.937: WARN/System.err(365): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)

04-20 20:19:55.947: WARN/System.err(365): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)

04-20 20:19:55.947: WARN/System.err(365): at comm.sample.Urlasync$AddStringTask.doInBackground(Urlasync.java:82)

04-20 20:19:55.947: WARN/System.err(365): at comm.sample.Urlasync$AddStringTask.doInBackground(Urlasync.java:1)

04-20 20:19:55.947: WARN/System.err(365): at android.os.AsyncTask$2.call(AsyncTask.java:185)

04-20 20:19:55.957: WARN/System.err(365): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:306)

04-20 20:19:55.957: WARN/System.err(365): at java.util.concurrent.FutureTask.run(FutureTask.java:138)

04-20 20:19:55.957: WARN/System.err(365): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)

04-20 20:19:55.967: WARN/System.err(365): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)

04-20 20:19:55.967: WARN/System.err(365): at java.lang.Thread.run(Thread.java:1019)

A: I ran into this same problem a few days ago. Running the HttpResponse on its own thread fixed the Null response. Try using java threading instead of the android async task.
http://download.oracle.com/javase/1.5.0/docs/api/java/lang/Thread.html


Q: Testing ServiceLoader in Eclipse Plugins I have four Eclipse plugin projects (create a new Java Project, right-click, configure, Convert to Plugin Project) in my workspace. The first (my.runtime) contains an interface (MyFactoryInterface) and a class (MyClient) that defines a method (List<String> getAllFactoryNames()) that loads all implementations of that interface via java.util.ServiceLoader and calls a method (String getName()) on them, collecting the results and returning them in a list.
To test that class, I have a JUnit test in the second project (my.runtime.test, set up with my.runtime as Fragment-Host), checking if the name returned by a dummy implementation(MyDummy, returning "Dummy") I have in the my.runtime.test project is in the list returned by MyClient.getAllFactoryNames(). So far, it works fine.
In the third project (my.extension, with my.runtime as dependency) I have a class (MyHello) that uses the names returned by MyClient.getAllFactoryNames() to return a list of greetings ("Hello "+name).
Again, to test this, I have a project (my.extension.test, with my.extension as Fragment-Host) containing another Implementation (MyWorld, returning "World" as name) and a JUnit test case checking if "Hello World" is in the greetings returned by MyHello.getGreetings(). This test fails, as MyClient still only finds the MyDummy implementation, and not the MyWorld implementation. Both implementations are accompanied by matching entries in META-INF/services/my.runtime.MyFactoryInterface files.
I currently use the following code to load the implementations:
ServiceLoader<MyFactoryInterface> myFactoryLoader = ServiceLoader.load(MyFactoryInterface.class);
    for (MyFactoryInterface myFactory : myFactoryLoader) {

I know that I can supply a ClassLoader as a second argument to ServiceLoader.load, but I have no idea how to get one that knows all plugin projects... any suggestions? Or is ServiceLoader not the right tool for this problem?

A: If anyone stumbles over the same problem: the combination of ServiceLoader.load(MyFactoryInterface.class, Thread.currentThread().getContextClassLoader()) in MyClient and Thread.currentThread().setContextClassLoader(MyWorld.class.getClassLoader()); in the second test did the job.


Q: Return from function or pass into function? What would be the better way to process this data? Is this just a matter of personal preference? Guessing 2 is less prone to accidently modifying the monday...friday arrays and there is less code at this layer. Is there a best practices approach? Is there a performance difference?

*

*Like this?

        // Arrays to hold what stock price belongs to what day of the week - Note these arrays are used some way down the line
        var monday = [], tuesday = [], wednesday = [], thursday = [], friday = []

        // Sort each stock date into a day of the week
        FindDayFromDate(historyData, monday, tuesday, wednesday, thursday, friday);

        // Find the average price for each day of the week
        const avgPrices = FindAveragePricePerDay(monday, tuesday, wednesday, thursday, friday);

*Like this?

        // Sort each stock date into a day of the week - sortedDays contains arrays of monday...friday
        const sortedDays = FindDayFromDate(historyData);

        // Find the average price for each day of the week - Expand sortedDays inside function to access monday...friday
        const avgPrices = FindAveragePricePerDay(sortedDays);

A: A good function should always be free from side-effects. It should be pure and just do one specific job at a time. As a software programmer/developer, we must write source code that actually produce the output based on input. Such kind of strong pure function actually avoid all kind of side effects and code smell. Let's look at few examples to understand this.
Assume we have a function named as Greeting like below
function Greeting(name) {
  return `Hello ${name}`;
}

It is pure because you will always get the output Hello {name} for the name passed via parameter. Let's have a look at another version of same function with many side-effects.
var greeting = "Hey";

function Greeting(name) {
  return `${greeting} ${name}`;
}

Now, this function is not pure. Guess why ? Because we are not sure what output we will receive because function is actually dependent on the outer variable named as greeting . So if someone change the value of variable greeting to something else let's say Hello then obviously the output of function will change. So the function is now tightly coupled with the outer variable. That's why it is not pure function anymore.
So to conclude, you must have to write your function in such a way that there is no dependency and no side-effect and it will always do one job.
That is the best practice :)
Happy Coding :)

A: I believe the second Function "FindAveragePricePerDay" calling can be adjusted to act on single day, so that it can be reused on other places
    const avgPrices = sortedDays.map(day => FindAveragePricePerDay(day));
    /* you can also simplify the FindAveragePricePerDay using the reduce method
     following this parameters array.reduce(function(total, currentValue, currentIndex, arr), initialValue)
so all the second line would be */
    const avgPrices = day.reduce((t,c,i,arr) => t + c/arr.length, 0);

for more info about array.reduce check this


Q: Joining multiple columns into one with union, exclude results with same id I want to join columns from multiple tables to one column, in my case column 'battery_value' and 'technical_value' into column 'value'. I want to fetch data for only given category_ids, but because of UNION, I get data from other tables as well.
I have 4 tables:
Table: car
car_id   model_name
1        e6

Table: battery
battery_category_id    car_id    battery_value
1                      1         125 kW

Table: technical_data
technical_category_id  car_id    technical_value
1                      1         5
3                      1         2008

Table: categories
category_id     category_name     category_type
1               engine power      battery
1               seats             technical
3               release year      technical

From searching, people are suggesting that I use union to join these columns. My query now looks like this:
SELECT CARS.car_id
       category_id,
       CATEGORIES.category_name,
       value,
FROM   CARS
           left join (SELECT BATTERY.battery_category_id AS category_id,
                             BATTERY.car_id              AS car_id,
                             BATTERY.value               AS value
                      FROM   BATTERY
                      WHERE `BATTERY`.`battery_category_id` IN (1)
                      UNION
                      SELECT TECHNICAL_DATA.technical_category_id AS category_id,
                          TECHNICAL_DATA.car_id            AS car_id,
                          TECHNICAL_DATA.value             AS value
                      FROM   TECHNICAL_DATA
                      WHERE `TECHNICAL_DATA`.`technical_category_id` IN (3))
    tt
                     ON CARS.car_id = tt.car_id
           left join CATEGORIES
                     ON category_id = CATEGORIES.id

So the result I want is this, because I only want to get the data where category_id 1 is in battery table:
car_id   category_id   category_name   technical_value
1        1             engine power    125 kW
1        3             release year    2008

but with the query above I get this, category_id 1 from technical table is included which is not something I want:
car_id   category_id   category_name   value
1        1             engine power    125 kW
1        1             seats           125 kW
1        3             release year    2008

How can get exclude the 'seats' row?

A: For the results you want, I don't see why the cars table is needed.  Then, you seem to need an additional key for the join to categories based on which table it is referring to.
So, I suggest:
SELECT tt.*, c.category_name
FROM ((SELECT b.battery_category_id AS category_id,
              b.car_id AS car_id, b.value AS value,
              'battery' as which
       FROM BATTERY b
       WHERE b.battery_category_id IN (1)
      ) UNION ALL
      (SELECT td.technical_category_id AS category_id,
              td.car_id AS car_id, td.value AS value,
              'technical' as which
       FROM TECHNICAL_DATA td
       WHERE td.technical_category_id IN (3)
      )
     ) tt LEFT JOIN
     CATEGORIES c
     ON c.id = tt.category_id AND
        c.category_type = tt.which;

That said, you seem to have a problem with your data model, if the join to categories requires "hidden" data such as the type.  However, that is outside the scope of the question.


Q: Accessing bazel files outside the docker I am quite new to docker environment and need help in understanding / fixing the below issue.
Scenario:
I am running an application (assume App1) inside the docker.
This application/docker uses bazel framework. So the run time files (some C++ .h and .cc files) which are getting generated are saved inside directory Bazel-App1.
I can use those generated files in some other code inside the docker. However I am not able to link those files (which are inside the bazel-App1 directory) to the codes which I am writing outside the docker.
Is there a way I can get access to those files?
Kindly let me know if you need more details to suggest me a fix.


Q: What does the dot do in Racket? I know the dot for creating a procedure, which can take an arbitrary amount of arguments, but I saw several other examples, which use the dot in other places. One example is from the docs of csv-reading:

(define next-row
  (make-csv-reader
   (open-input-file "fruits.csv")
   '((separator-chars            #\|)
     (strip-leading-whitespace?  . #t)
     (strip-trailing-whitespace? . #t))))

To me this looks like a list of configuration parameters is "set", but what does the dot do there?
Another example is from a web application tutorial from the docs (in the formlet section) as well:

; new-post-formlet : formlet (values string? string?)
; A formlet for requesting a title and body of a post
(define new-post-formlet
  (formlet
   (#%# ,{input-string . => . title}
        ,{input-string . => . body})
   (values title body)))

My guess for this example is, that the dots somehow allow to write => as an infix operator. I was able to put the => at the front of the lists and leave the dots away and it still worked at some point. I didn't try with the final version of the tutorial's code though.
However, this "infixing" wouldn't fit the first example, I think.

A: The dot is not uniquely a racket thing, but a lisp thing. A list is made out of pairs and one pair has the literal form (car . cdr) and a list of the elements 2, 3 is made up like (2 . (3 . ())) and the reader can read this, however a list that has a pair as it's cdr can be shown without the dot and the parens such that (2 . (3 . ())) is the same as (2 3 . ()). Also a dot with the special empty list in the end can be omitted so that (2 3) is how it can be read and the only way display and the REPL would print it.
What happens if you don't have a pair or null as the cdr? Then the only way to represent it is as a dotted. With (2 . (3 . 5)) you can only simplify the first dot so it's (2 3 . 5).
The literal data structure looks like an assoc with pairs as elements where the car is the key and cdr is the value. Using a new pair is just wast of space.
As an parameter list an interpreter looks at the elements and if it's a pair it binds the symbol in car, but if it's not a pair it is either finished with null or you have a rest argument symbol. It's convenient way to express it. Clojure that don't have dotted pairs use a & element while Common Lisp does dotted in structures, but not as a parameter specification since it supports more features than Scheme and Clojure and thus use special keywords to express it instead.
The second is #lang racket specific and is indeed used to support infix. If you write (5 . + . 6) a reader extension will change it to (+ 5 6) before it gets evaluated. It works the same way even if it's quoted or actual code and curlies are of course equal to normal and square parentheses so the second one actually becomes:
(define new-post-formlet
  (formlet
   (#%# ,(=> input-string title)
        ,(=> input-string body))
   (values title body)))

If you were to use #!r5rs or #!r6rs in racket (5 . + . 6) will give you a read error.


Q: What is the C++ equivalent of Python's "in" operator? What is the C++ way of checking if an element is contained in an array/list, similar to what the in operator does in Python?
if x in arr:
    print "found"
else
    print "not found"

How does the time complexity of the C++ equivalent compare to Python's in operator?

A: I guess one might make use of this thread and create a custom version of in function.
The main idea is to use SFINAE (Substitution Failure Is Not An Error) to differentiate associative containers (which have key_type member) from sequence containers (which have no key_type member).
Here is a possible implementation:
namespace detail
{
    template<typename, typename = void>
    struct is_associative : std::false_type {};

    template<typename T>
    struct is_associative<T,
        std::enable_if_t<sizeof(typename T::key_type) != 0>> : std::true_type {};

    template<typename C, typename T>
    auto in(const C& container, const T& value) ->
        std::enable_if_t<is_associative<C>::value, bool>
    {
        using std::cend;

        return container.find(value) != cend(container);
    }

    template<typename C, typename T>
    auto in(const C& container, const T& value) ->
        std::enable_if_t<!is_associative<C>::value, bool>
    {
        using std::cbegin;
        using std::cend;

        return std::find(cbegin(container), cend(container), value) != cend(container);
    }

}

template<typename C, typename T>
auto in(const C& container, const T& value)
{
    return detail::in(container, value);
}

Small usage example on WANDBOX.

A: This gives you an infix *in* operator:
namespace notstd {
  namespace ca_helper {
    template<template<class...>class, class, class...>
    struct can_apply:std::false_type{};
    template<class...>struct voider{using type=void;};
    template<class...Ts>using void_t=typename voider<Ts...>::type;

    template<template<class...>class Z, class...Ts>
    struct can_apply<Z,void_t<Z<Ts...>>, Ts...>:std::true_type{};
  }
  template<template<class...>class Z, class...Ts>
  using can_apply = ca_helper::can_apply<Z,void,Ts...>;

  namespace find_helper {
    template<class C, class T>
    using dot_find_r = decltype(std::declval<C>().find(std::declval<T>()));
    template<class C, class T>
    using can_dot_find = can_apply< dot_find_r, C, T >;
    template<class C, class T>
    constexpr std::enable_if_t<can_dot_find<C&, T>{},bool>
    find( C&& c, T&& t ) {
      using std::end;
      return c.find(std::forward<T>(t)) != end(c);
    }
    template<class C, class T>
    constexpr std::enable_if_t<!can_dot_find<C&, T>{},bool>
    find( C&& c, T&& t ) {
      using std::begin; using std::end;
      return std::find(begin(c), end(c), std::forward<T>(t)) != end(c);
    }
    template<class C, class T>
    constexpr bool finder( C&& c, T&& t ) {
      return find( std::forward<C>(c), std::forward<T>(t) );
    }
  }
  template<class C, class T>
  constexpr bool find( C&& c, T&& t ) {
    return find_helper::finder( std::forward<C>(c), std::forward<T>(t) );
  }
  struct finder_t {
    template<class C, class T>
    constexpr bool operator()(C&& c, T&& t)const {
      return find( std::forward<C>(c), std::forward<T>(t) );
    }
    constexpr finder_t() {}
  };
  constexpr finder_t finder{};
  namespace named_operator {
    template<class D>struct make_operator{make_operator(){}};

    template<class T, char, class O> struct half_apply { T&& lhs; };

    template<class Lhs, class Op>
    half_apply<Lhs, '*', Op> operator*( Lhs&& lhs, make_operator<Op> ) {
      return {std::forward<Lhs>(lhs)};
    }

    template<class Lhs, class Op, class Rhs>
    auto operator*( half_apply<Lhs, '*', Op>&& lhs, Rhs&& rhs )
    -> decltype( named_invoke( std::forward<Lhs>(lhs.lhs), Op{}, std::forward<Rhs>(rhs) ) )
    {
      return named_invoke( std::forward<Lhs>(lhs.lhs), Op{}, std::forward<Rhs>(rhs) );
    }
  }
  namespace in_helper {
    struct in_t:notstd::named_operator::make_operator<in_t> {};
    template<class T, class C>
    bool named_invoke( T&& t, in_t, C&& c ) {
      return ::notstd::find(std::forward<C>(c), std::forward<T>(t));
    }
  }
  in_helper::in_t in;
}

On a flat container, like a vector array or string, it is O(n).
On an associative sorted container, like a std::map, std::set, it is O(lg(n)).
On an unordered associated container, like std::unordered_set, it is O(1).
Test code:
std::vector<int> v{1,2,3};
if (1 *in* v)
    std::cout << "yes\n";
if (7 *in* v)
    std::cout << "no\n";
std::map<std::string, std::string, std::less<>> m{
    {"hello", "world"}
};

if ("hello" *in* m)
    std::cout << "hello world\n";

Live example.
C++14, but mainly for enable_if_t.
So what is going on here?
Well, can_apply is a bit of code that lets me write can_dot_find, which detects (at compile time) if container.find(x) is a valid expression.
This lets me dispatch the searching code to use member-find if it exists.  If it doesn't exist, a linear search using std::find is used instead.
Which is a bit of a lie.  If you define a free function find(c, t) in the namespace of your container, it will use that rather than either of the above.  But that is me being fancy (and it lets you extend 3rd party containers with *in* support).
That ADL (argument dependent lookup) extensibity (the 3rd party extension ability) is why we have three different functions named find, two in a helper namespace and one in notstd.  You are intended to call notstd::find.
Next, we want a python-like in, and what is more python like than an infix operator?  To do this in C++ you need to wrap your operator name in other operators.  I chose *, so we get an infix *in* named operator.

TL;DR
You do using notstd::in; to import the named operator in.
After that, t *in* c first checks if find(t,c) is valid.  If not, it checks if c.find(t) is valid.  If that fails, it does a linear search of c using std::begin std::end and std::find.
This gives you very good performance on a wide variety of std containers.
The only thing it doesn't support is
if (7 *in* {1,2,3})

as operators (other than =) cannot deduce initializer lists I believe.  You could get
if (7 *in* il(1,2,3))

to work.

A: The time complexity of Python's in operator varies depending on the data structure it is actually called with. When you use it with a list, complexity is linear (as one would expect from an unsorted array without an index). When you use it to look up set membership or presence of a dictionary key complexity is constant on average (as one would expect from a hash table based implementation):

*

*https://wiki.python.org/moin/TimeComplexity
In C++ you can use std::find to determine whether or not an item is contained in a std::vector. Complexity is said to be linear (as one would expect from an unsorted array without an index). If you make sure the vector is sorted, you can also use std::binary_search to achieve the same in logarithmic time.

*

*http://en.cppreference.com/w/cpp/algorithm/find

*Check if element is in the list (contains)

*Check if element found in array c++

*http://en.cppreference.com/w/cpp/algorithm/binary_search
The associative containers provided by the standard library (std::set, std::unordered_set, std::map, ...) provide the member functions find() and count() and contains() (C++20) for this. These will perform better than linear search, i.e., logarithmic or constant time depending on whether you have picked the ordered or the unordered alternative. Which one of these functions to prefer largely depends on what you want to achieve with that info afterwards, but also a bit on personal preference. (Lookup the documentation for details and examples.)

*

*How to check that an element is in a std::set?

*How to check if std::map contains a key without doing insert?

*https://en.wikipedia.org/wiki/Associative_containers

*http://en.cppreference.com/w/cpp/container
If you want to, you can use some template magic to write a wrapper function that picks the correct method for the container at hand, e.g., as presented in this answer.

A: You can use std::find from <algorithm>, but this works only for datatypes like: std::map and std::vector (etc).
Also note that this will return, iterator to the first element that is found equal to the value you pass, unlike the in operator in Python that returns a bool.

A: You can approach this in two ways:
You can use std::find from <algorithm>:
auto it = std::find(container.begin(), container.end(), value);
if (it != container.end())
    return it;

or you can iterate through every element in your containers with for ranged loops:
for(const auto& it : container)
{
    if(it == value)
        return it;
}

A: Python does different things for in depending on what kind of container it is. In C++, you'd want the same mechanism. Rule of thumb for the standard containers is that if they provide a find(), it's going to be a better algorithm than std::find() (e.g. find() for std::unordered_map is O(1), but std::find() is always O(N)).
So we can write something to do that check ourselves. The most concise would be to take advantage of C++17's if constexpr and use something like Yakk's can_apply:
template <class C, class K>
using find_t = decltype(std::declval<C const&>().find(std::declval<K const&>()));

template <class Container, class Key>
bool in(Container const& c, Key const& key) {
    if constexpr (can_apply<find_t, Container, Key>{}) {
        // the specialized case
        return c.find(key) != c.end();
    } else {
        // the general case
        using std::begin; using std::end;
        return std::find(begin(c), end(c), key) != end(c);
    }
}

In C++11, we can take advantage of expression SFINAE:
namespace details {
    // the specialized case
    template <class C, class K>
    auto in_impl(C const& c, K const& key, int )
            -> decltype(c.find(key), true) {
        return c.find(key) != c.end();
    }

    // the general case
    template <class C, class K>
    bool in_impl(C const& c, K const& key, ...) {
        using std::begin; using std::end;
        return std::find(begin(c), end(c), key) != end(c);
    }
}

template <class Container, class Key>
bool in(Container const& c, Key const& key) {
    return details::in_impl(c, key, 0);
}

Note that in both cases we have the using std::begin; using std::end; two-step in order to handle all the standard containers, raw arrays, and any use-provided/adapted containers.

A: I think one of the nice features of the "in" operator in python is that it can be used with different data types (strings v/s strings, numbers v/s lists, etc).
I am developing a library for using python constructions in C++. It includes "in" and "not_in" operators.
It is based on the same technique used to implement the in operator posted in a previous answer, in which make_operator<in_t> is implemented. However, it is extended for handling more cases:

*

*Searching a string inside a string

*Searching an element inside vector and maps

It works by defining several overloads for a function: bool in__(T1 &v1, T2 &v2), in which T1 and T2 consider different possible types of objects. Also, overloads for a function: bool not_in__(T1 &v1, T2 &v2) are defined. Then, the operators "in" and "not_in" call those functions for working.
The implementation is in this repository:
https://github.com/ploncomi/python_like_cpp


Q: Validation: creating sequences given certain subsequences (one going to infinity and zero simultaneously) I have problem with few exercises.

*

*I want to find a sequence that can create sequence that has different terms and has three subsequences: one going to minus inifnity, one to inifnity and other to zero.
I was thinking to create 3 sequences $ a_i $, $ b_i $, $ c_i $, such as:
$ a_i = {1, 2, 3, 4, 5....}$
$ b_i = {1/n} $
$ c_i = -1, -2, -3, -4 $
Then connect it depending on i, but not sure how to create a proper sequence from those? Could it be something along for i mod 3, every 1,2,3 pick $ a_i $, $ b_i $,$ c_i $ ?

*There are two sequences,
$ a_i = -11, -12, -13, -14, -15, -16, -17, -18, -19....$
$ b_i = 1000, 10001, -16, -17, -18, -19...$
And the sequence $ b_i $ from 3rd term would then become the same as $ a_i $ from 6th term, for the rest of the sequences. Is that equivalence relation? $ a_{i-3} = b_i $ and $ b_{i-3} = a_i$ for $ i>3$ so it is symmetric. The terms are the same so it is reflexive if I understand it correctly. Then it is not transitive.
Also, what would be the correct definition of such sequences and mathematical notations for them? I am doing Real Analysis as a part of electives for my comp sci degree and am really struggling with the semantics and mathematical language for those..
Appreciate ANY help and suggestions!!


Q: Angular 2 How to make singleton service available to lazy loaded modules According to my understanding of Angular 2 rc5, to make a service from another module (not AppModule) available as a singleton to every component, even those lazy-loaded, we don't include the service in the providers array of that other module. We instead export it with RouterModule.forRoot() and import the result in AppModule
According to the docs:

The SharedModule should only provide the UserService when imported by
  the root AppModule. The SharedModule.forRoot method helps us meet this
  challenge...the SharedModule does not have providers...When we add
  the SharedModule to the imports of the AppModule, we call forRoot. In
  doing so, the AppModule gains the exported classes and the
  SharedModule delivers the singleton UserService provider at the same
  time

I'm really struggling with how to make a 3rd-party service (a service used by a module in the imports array of my AppModule) available to lazy loaded routes. I have no control over this 3rd-party module, so I cannot just remove that service from the NgModule.providers array of that module and place it inside RouterModule.forRoot() as I would with one of my services.
The specific service is MdIconRegistry, which is in providers for the MdIconModule of Angular Material 2 alpha 7-3.  This service is used to register svg icons that can then be displayed on the page with the <md-icon svgIcon='iconName'> tag. So:

*

*I imported MdIconModule in my root AppModule

*I used the service in question to register svg icons in my AppComponent
The icon is visible and works well, but only in the modules that were loaded at launch.  Lazy-loaded modules cannot see these icons, so I suspect that the Angular injector is not injecting the same instance of the MdIconRegistry service.
tl;dr: How can I make the service from a 3rd-party module a singleton available to my lazy-loaded components?
Here is a plunker that demonstrates the problem (coded in typescript).
PS: This just got the attention of the MdIconModule developer on github.

A: I do not think it has anything to do with the component being lazy-loaded.

LazyLoadedComponent is not part of the AppModule – it is part of the LazyModule. According to the docs, a component can only be part of one module. If you try adding LazyLoadedComponent to AppModule also, you would get an error to that effect. So LazyLoadedComponent is not even seeing MdIconModule at all. You can confirm this by looking at the template output in the debugger – it is unchanged.
<md-icon svgIcon="play"></md-icon>

The solution appears to be adding the MdIconModule to the LazyModule, and while this alone does not fix the problem, it does add an error to the output.

Error retrieving icon: Error: Unable to find icon with the name ":play"

And the template output now looks like this, so we know it is loading.
<md-icon role="img" svgicon="play" ng-reflect-svg-icon="play" aria-label="play"></md-icon>

I added the call to addSvgIconSet from LazyLoadedComponent, and that got it working… so this proves there is an instance of the MdIconRegistry service per component – not what you want, but may point you in the right direction.
Here’s the new plunk - http://plnkr.co/edit/YDyJYu?p=preview
After further review, I found this in the docs:

Why is a service provided in a lazy loaded module visible only to that module?
Unlike providers of the modules loaded at launch, providers of lazy loaded modules are module-scoped.

Final Update! Here is the answer. MdIconModule is not properly setup for lazy loaded components... but we can easily create our own module that IS properly set up and use that instead.
import { NgModule } from '@angular/core';
import { HttpModule } from '@angular/http';

import { MdIcon } from '@angular2-material/icon';
import { MdIconRegistry } from '@angular2-material/icon';

@NgModule({
  imports: [HttpModule],
  exports: [MdIcon],
  declarations: [MdIcon]
})
export class MdIconModuleWithProviders {
  static forRoot(): ModuleWithProviders {
    return {
      ngModule: MdIconModuleWithProviders,
      providers: [ MdIconRegistry ]
    };
  }
}

Plunk updated and fully working. (sorry, updated the same one) -> http://plnkr.co/edit/YDyJYu?p=preview
One might submit a pull request such that Angular Material exports modules of both styles.

A: New to Angular 6 there is a new way to register a provider as a singleton. Inside the @Injectable() decorator for a service, use the providedIn attribute. Set its value to 'root'. Then you won't need to add it to the providers list of the root module, or in this case you could also set it to your MdIconModuleWithProviders module like this:
@Injectable({
  providedIn: MdIconModuleWithProviders // or 'root' for singleton
})
export class MdIconRegistry {
...


Q: IIS 6.0 PCI Compliance - "Information Disclosure Vulnerability" We're trying to pass PCI compliance on a few of our websites. After an outside scan, we still have this vulnerability:

Synopsis : The remote web server is affected by an information disclosure vulnerability. Description : The remote host appears to be running a version of IIS which allows remote users to determine which authentication schemes are required for confidential web pages. That is, by requesting valid web pages with purposely invalid credentials, you can ascertain whether or not the authentication scheme is in use. This can be used for brute-force attacks against known USerIDs.

How do we remedy this in IIS?
Thanks

A: We needed to UNCHECK "Integrated Windows Authentication" in the site's IIS properties:

*

*right click the website in IIS, click "properties"

*click "Directory Security" TAB

*under "Authentication and access control", click "Edit"

*under "Authenticated access", UNCHECK "integrated windows authentication"

I rescanned after making this change and we passed compliance.


Q: Proving that $\lim \limits_{b \rightarrow \infty} F(1,b,1;\frac{z}{b})=e^z$ I am trying to prove that $\lim \limits_{b \rightarrow \infty} F(1,b,1;\frac{z}{b})=e^z$ without using dominated convergence theorem. Here $F$
 is the hypergeometric function.
I have been  able to show that if the limit exists it has to be equal to $e^x$ but I have not been able to show that the limit exists. I am struck as to why we can exchange the sum and limit here. But again I was able to show that the limit exists when $x>0$. Since as $b$ increases $ F(1,b,1;\frac{x}{b})$ decreases and it is greater than $0$ so limit exists.

A: From the series definition of the hypergeometric function it follows that
$$_2F_1(1,b;1;z)=(1-z)^{-b}.$$
Does this solve your problem?


Q: Exit position Pine Script How can I exit or close a position on a specific time of exchange in Pine Script.
Example
I have long position and want to close it on or before 1500 hrs as per Indian Time Zone.
Please help?

A: You can use the time() function for that.
Here is an example where it marks candles between 1200 and 1500. It shouldn't be difficult to adapt according to your needs.
//@version=5
indicator("My Script", overlay=true)

timeAllowed = input.session("1200-1500", "Allowed hours")

// Check to see if we are in allowed hours using session info on all 7 days of the week.
timeIsAllowed = time(timeframe.period, timeAllowed + ":1234567")

plotchar(timeIsAllowed, size=size.small)


Q: The integral $\int_{-\infty}^{\infty}\frac{ a^2x^2 dx}{(x^2-b^2)^2+a^2x^2}=a\pi,~ a, b \in \Re ?$ This integral
$$\int_{-\infty}^{\infty}\frac{ a^2x^2 dx}{(x^2-b^2)^2+a^2x^2}=a\pi, ~ a, b \in \Re$$
looks suspiciously interesting as it is independent of the parameter $b$. The question is: What is the best way of proving or disproving this?

A: One way:
Denote the integral as $$I=\int_{-\infty}^{\infty}\frac{ a^2x^2 dx}{(x^2-b^2)^2+a^2x^2}.$$
$$(x^2-b^2)^2+a^2x^2=(x^2+p^2)(x^2+q^2) \Rightarrow p=(a+c)/2,q=(a-c)/2, c=\sqrt{a^2-4b^2}.$$
Then $$I=\frac{2a^2}{p^2-q^2} \int_{0}^{\infty} \left( \frac{p^2}{x^2+p^2}-\frac{q^2}{x^2+q^2} \right)dx=
\frac{2a^2}{p^2-q^2}[p\tan^{-1}(x/p)-q \tan^{-1}(x/q)]_{0}^{\infty}=\frac{a^2\pi}{p+q}=a\pi.$$

A: Glasser's master theorem states that for arbitrary constants $\alpha$, $(\alpha_n)_{n=1}^{N}$, $(\beta_n)_{n=1}^N$, the function
$$\phi(x)=|\alpha|x-\sum_{n=1}^{N}\frac{|\alpha_n|}{x-\beta_n},$$
and any integrable function $F(x)$,
$$\mathrm{PV}\int_{-\infty}^{\infty}F(\phi(x))dx=\mathrm{PV}\int_{-\infty}^\infty F(x)dx.$$
For your integral, set $$\phi(x)=x-\frac{b^2}{x}$$
and
$$F(\phi(x))=\frac{a^2x^2}{(x^2-b^2)^2-a^2x^2}=\frac{1}{(\frac{x}{a}-\frac{b^2}{ax})^2+1}$$
to immediately yield the desired result.

A: How about this, please check it critically
Denote the integral as $$I=\int_{-\infty}^{\infty}\frac{ a^2x^2 dx}{(x^2-b^2)^2+a^2x^2}.$$
$$(x^2-b^2)^2+a^2x^2=(x^2-r^2)(x^2-s^2) \Rightarrow r=(d+ia)/2,s=(d-ia)/2, d=\sqrt{4b^2-a^2}.$$
$$I=\frac{a^2}{r^2-s^2} \int_{-\infty}^{\infty} \left( \frac{r^2}{x^2-r^2}-\frac{s^2}{x^2-s^2} \right)dx.$$
By considering a semi-circle contour in the upper half plane and applying the residue theorem, we get
$$I=\frac{a^2}{r^2-s^2} 2i\pi \left( r^2  Res \left (\frac{1}{x^2-r^2} \right)_{x=r}-s^2  Res \left ( \frac{1}{x^2-s^2} \right)_{x=-s}\right)=\frac{i\pi a^2}{r-s}=a\pi.$$


Q: Android device how to run one program? Here is the question I have android device version 4.1.1 and ı want change the android working style. For example I restart my android device and want to see my application on screen just one. Another app for example camera or notepad ı dont want to see that just one program in my android device and I use that . How can ı programming that ?
ı will try again ı wanna root my android device for my claims how can ı do that


Q: How to automatically drop down DateTimePicker in Vb.net through a Citrix client Through a variety of reasons I am forced to use the incredibly frustrating vb.net DateTimePicker control, in the even more frustrating Citrix client, for an application. This isn't actually my main problem, the problem is, I have to make the datetimepicker automatically drop down when the user presses any button (besides tab, escape, etc).
I really need to get this to work, the users won't really take no for an answer. I would prefer to not get a new custom control, but if one exists that is easy to implement (and doesn't allow the user to type in the date) then I would be open to it.
This is what I've done so far, it works perfectly well outside of Citrix, but when it triggers in Citrix the DateTimePicker doesn't refresh when the user navigates around it. Meaning the square is over the current date, and the user can press arrow keys to their heart's content, but it never shows this to the user. (Even if the user uses the mouse to drop it down.)
Again outside of Citrix this works fine.
'Used to manually dropdown datetimepickers
Private dateTimePickerControl As DateTimePicker
Private Declare Auto Function SendMessage Lib "user32.dll" (ByVal hWnd As IntPtr, ByVal msg As Integer, ByVal wParam As IntPtr, ByVal lParam As IntPtr) As IntPtr

Public Sub DropDownCalendar()
    Const WM_LBUTTONDOWN As Int32 = &H201
    Const WM_LBUTTONUP As Int32 = &H202

    Dim x As Integer = Me.dateTimePickerControl.Width - 10
    Dim y As Integer = CInt(Me.dateTimePickerControl.Height / 2)
    Dim lParam As Integer = x + y * &H10000

    'click down, and show the calendar
    SendMessage(Me.dateTimePickerControl.Handle, WM_LBUTTONDOWN, CType(1, IntPtr), CType(lParam, IntPtr))

    'Click-up, and activate the calendar (without this the calendar is shown, but is not active, and doesn't work as expected)
    SendMessage(Me.dateTimePickerControl.Handle, WM_LBUTTONUP, CType(1, IntPtr), CType(lParam, IntPtr))
End Sub

Private Sub dteDate_KeyDown(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles dteDate.KeyDown
    Try
        If e.KeyCode = Keys.Delete Then
            sender.customFormat = " "
            e.Handled = True
        ElseIf e.KeyCode <> Keys.Tab And e.KeyCode <> Keys.ShiftKey Then
            sender.focus()
            dateTimePickerControl = sender
            DropDownCalendar()
        End If
    Catch ex As Exception
        MsgBox(ex.Message)
    End Try
End Sub

I'm completely at a loss. Is such a thing even possible in Citrix? In a previous attempt I used SendKeys("{F4}") which worked fine outside of Citrix, but in Citrix would just drop down a frozen white background.
Does anyone have any ideas that could help me out here?

A: Sometimes we've had to add DoEvents when sending messages like this in our VB app hosted on Citrix. See if this works for you:
Private Declare Auto Function SendMessage Lib "user32.dll" (ByVal hWnd As IntPtr, ByVal msg As Integer, ByVal wParam As IntPtr, ByVal lParam As IntPtr) As IntPtr

Private Sub DropDownCalendar(ctl As DateTimePicker)
    Const WM_LBUTTONDOWN = &H201
    Const WM_LBUTTONUP = &H202

    If ctl Is Nothing Then
        Exit Sub
    End If

    ctl.Select()

    Dim lParam = (ctl.Width - 10) + (CInt(ctl.Height / 2) * &H10000)

    'click down, and show the calendar
    SendMessage(ctl.Handle, WM_LBUTTONDOWN, CType(1, IntPtr), CType(lParam, IntPtr))

    Application.DoEvents()

    'Click-up, and activate the calendar (without this the calendar is shown, but is not active, and doesn't work as expected)
    SendMessage(ctl.Handle, WM_LBUTTONUP, CType(1, IntPtr), CType(lParam, IntPtr))
End Sub

Private Sub dteDate_KeyDown(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles dteDate.KeyDown
    Try
        If e.KeyCode = Keys.Delete Then
            CType(sender, DateTimePicker).CustomFormat = " "
            e.Handled = True
        ElseIf e.KeyCode <> Keys.Tab And e.KeyCode <> Keys.ShiftKey Then
            DropDownCalendar(CType(sender, DateTimePicker))
        End If
    Catch ex As Exception
        MsgBox(ex.Message)
    End Try
End Sub


Q: Xamarin Forms OnAppLinkRequestReceived event - Shell.Current is null I am testing App Links / Deep Linking / Universal Links on my Xamarin Forms app. I have an app that correctly intercepts URLs as expected, but when I go to navigate to the page using Shell in my app, Shell.Current is null.
Visual Studio 2022, Android Pixel 4 emulator, Xamarin Forms version 5.0.0.2291
Setup: Simple onAppLinkRequestReceived handler. The debugger executes and breaks at this code, so I know my applinks are set up properly.
protected override async void OnAppLinkRequestReceived(Uri uri)
{
    base.OnAppLinkRequestReceived(uri);

    var shellRoute = uri.PathAndQuery;
    try
    {
        Log.Information("User followed applink for {shellRoute}", shellRoute);
        Shell.Current.GoToAsync(shellRoute);
    }
    catch(Exception ex)
    {
        Log.Error(ex, "User encountered an error attempting to navigate to an applink request", shellRoute);
    }
}

The problem here is that Shell.Current is null so I nullref. I expect shell.current should always be valid?
I am testing this using Android's suggested test technique, found here:
.\adb shell am start -W -a android.intent.action.VIEW -d "my-url" my-package-id
a null shell current value appears unexpected especially when other examples on the web indicate that navigation straight from the applinkrequest event should be valid?


Q: How to set up the event Datagridviewcombobox cell selectionchanged? I have a DataGridViewComboBoxCell control with some items into it. I would like to get the values when user chooses a value from the dropdown. I cant use DataGridViewComboBoxColumn where EditingControlShowing can be used. I need similar event handler for DataGridViewComboBoxCell. Can anyone help pls.
Please find code sample below:
private DataGridViewComboBoxCell NameDropDown = new DataGridViewComboBoxCell();

public void SetDropDown(int index)
      {
         NameDropDown = new DataGridViewComboBoxCell();
         DropDownValues(index);
         for (int j = 0; j < DropDownOld.Items.Count; j++)
         {
            NameDropDown.Items.Add(DropDownOld.Items[j]);
         }
         dataGridView1.Rows[index].Cells[4] = NameDropDown;
      }

A: Yes, you can use the EditingControlShowing event to get a handle to the combobox.
Then hook up an event handler for the SelectedIndexChanged or whatever event you want and code it..!
DataGridViewComboBoxEditingControl cbec = null;

private void dataGridView1_EditingControlShowing(object sender,
                           DataGridViewEditingControlShowingEventArgs e)
{
    if (e.Control is DataGridViewComboBoxEditingControl)
    {
        cbec = e.Control as DataGridViewComboBoxEditingControl;
        cbec.SelectedIndexChanged -=Cbec_SelectedIndexChanged;
        cbec.SelectedIndexChanged +=Cbec_SelectedIndexChanged;
    }
}

private void Cbec_SelectedIndexChanged(object sender, EventArgs e)
{
    if (cbec != null) Console.WriteLine(cbec.SelectedItem.ToString());
}


Q: Cannot register nested generic interface in .NET Core I am trying to register the nested generic type in DI container, but unable to register
throws {Open generic service type requires registering an open generic implementation type. (Parameter descriptors)} error
Implemented Interface method looks like:
public class CustomerEvent<TEntity> : IEventConsumer<EntityInsertedEvent<TEntity>>,
    IEventConsumer<EntityUpdatedEvent<TEntity>>,
    IEventConsumer<EntityDeletedEvent<TEntity>> where TEntity : BaseEntity
{
    public void HandleEvent(EntityInsertedEvent<TEntity> eventMessage)
    {
        throw new NotImplementedException("Inserted");
    }

    public void HandleEvent(EntityUpdatedEvent<TEntity> eventMessage)
    {
        throw new NotImplementedException("Updated");
    }

    public void HandleEvent(EntityDeletedEvent<TEntity> eventMessage)
    {
        throw new NotImplementedException("Deleted");
    }
}

Tried
Assembly.GetExecutingAssembly()
    .GetTypes()
    .Where(item => item.GetInterfaces()
    .Where(i => i.IsGenericType)
        .Any(i => i.GetGenericTypeDefinition() == typeof(IEventConsumer<>))
            && !item.IsAbstract && !item.IsInterface)
    .ToList().ForEach(assignedTypes =>
    {
        assignedTypes.GetInterfaces()
            .Where(i => i.GetGenericTypeDefinition() == typeof(IEventConsumer<>)).ToList()
            .ForEach(imp =>
            {
                services.AddScoped(imp, assignedTypes);
            });
    });

but failed

A: There is no easy way to do this. Typically, you need to map an open-generic abstraction to an open-generic implementation, like this:
services.AddTransient(typeof(IEventConsumer<>), typeof(CustomerEvent<>));

This, however, will not work in your case because MS.DI is unable to figure out how the generic type argument for IEventCustomer<T> should maps to the generic type argument of CustomerEvent<TEntity>. When resolving an IEventCustomer<EntityInsertedEvent<Order>>, for instance, it will try to create a CustomerEvent<EntityInsertedEvent<Order>>, while it should have been creating a CustomerEvent<Order>.
This is not a limitation of .NET or the CLR, but a limitation that is specific to the MS.DI DI Container, because some other DI Containers are actually able to make these kinds of mappings.
Unfortunately, with MS.DI, there is no easy way out. The only thing you can do is making all possible closed-generic registrations explicitly, e.g.:
s.AddTransient<IEventConsumer<EntityInsertedEvent<Order>>, CustomerEvent<Order>>();
s.AddTransient<IEventConsumer<EntityInsertedEvent<Customer>>, CustomerEvent<Customer>>();
s.AddTransient<IEventConsumer<EntityInsertedEvent<Product>>, CustomerEvent<Product>>();
s.AddTransient<IEventConsumer<EntityInsertedEvent<Employee>>, CustomerEvent<Employee>>();
s.AddTransient<IEventConsumer<EntityInsertedEvent<etc>>, CustomerEvent<etc>>();


Q: PHP - how to watch for cookie (every second or time interval)? I want to watch for cookie and if this cookie exist do somethink. I tried this :
while (true)
{
    sleep(1);
    if ($_COOKIE['name'])
    {
       doSomethink();
    }
}

But this code really make execution to 'sleep'.
Is there a way to watch without stopping the execution?

A: if this is a browser activity, a better way to do this may be a javascript setInverval() with an ajax call to a php function.
Otherwise, I'd recommend running the PHP script via CRON. There's no other way that I know to run PHP asynchronously, which is probably what you're trying to accomplish.


Q: How to access In XCUITestCase UITableViewRowAction and How to take action from XCUITestCase Leftswape delete tableViewCell Basically I want to access the UItableViewRowAction event in XCUITestCase. But I couldn't find any solution for this.

A: I assume you have a table view with cells that can be swiped left, and that swiping shows a delete button entitled DELETE.
Then you could do the following:
let firstCell = XCUIApplication().cells.element(boundBy: 0)
firstCell().swipeLeft()
let deleteButton = firstCell.buttons[„DELETE“]
deleteButton.tap()

EDIT:
Thanks for your edit! Your delete button does not have any title text. Thus, you cannot access the button with firstCell.buttons[„DELETE“].
From your screen shot it looks as if the delete button was the only button in the cell. If so, you could try firstCell.buttons.firstMatch.
If you have more buttons, you could access the delete button using firstCell.buttons.element(boundBy: 0) where „0“ had to be replaced by the correct index.


Q: Is there even a closed-form formula for the number of associative operations on an $n$-element set? I have read many questions that ask for a closed-form formula for the function $f$ that takes a natural number $n$ and outputs the number of associative operations on an $n$-element set. So far, we only know upper and lower bounds for $f$. I suspect now that there is in fact no closed-form formula. So, my question is, has it been proven that there is no closed-form formula? Of course, to answer this question, we need to know a rigorous definition of a closed-form formula for a function. Has any paper or text rigorously defined closed-form formula, and proven that there is no closed-form formula?


Q: Azure invalid AccessToken i am trying to use Microsoft.Azure.Management.Resources library to manage some Azure resources. I have registered app in Azure AD and i gave it all permissons. I took its ApplicationId and Secret + TennantId and SubscriptionId and tried to obtaion AccessToken like this:
var clientCredential = new ClientCredential(_model.DeploymentDetails.CliendId, _model.DeploymentDetails.ClientSecret);
var context = new AuthenticationContext("https://login.windows.net/"+model.DeploymentDetails.TennantId);
_accessToken = context.AcquireTokenAsync("https://management.azure.com/", clientCredential).Result.AccessToken;
_resourceManagementClient =  new ResourceManagementClient(new TokenCloudCredentials(_model.DeploymentDetails.SubscriptionId,_accessToken));

I get some AccessToken. BUT when i try to use it like this:
var x = _resourceManagementClient.ResourceGroups.List(...);

I get this error:
Additional information: InvalidAuthenticationToken: The received access token is not valid: at least one of the claims 'puid' or 'altsecid' or 'oid' should be present. If you are accessing as application please make sure service principal is properly created in the tenant.
Any ideas?
Thank you very much.

A: As far as I know, Microsoft.Azure.Management.Resources.dll that implements the ARM API. We need to assign application to role, after that then we can use  token in common. More information about how to assign application to role please refer to the article .This blog also has more detail steps to get AceessToken.