text:
Q: Attempt at displaying data results in graphql error "Cannot read property 'map' of undefined" Here's the code in my gatsby-node.js:

const fetch = require("node-fetch")

const NODE_TYPE = `objkt`

exports.sourceNodes = async ({
  actions,
  createContentDigest,
  createNodeId,
}) => {
  const { createNode } = actions

  const response = await fetch(
    "https://staging.api.tzkt.io/v1/bigmaps/523/keys?value.issuer=tz1V9ZviaGUWZjGx4U7cGYFEyUGyqpFnVGXx&active=true"
  )
  const objkt = await response.json()

  objkt.forEach((node, index) => {
    createNode({
      ...node,
      id: createNodeId(`${NODE_TYPE}-${node.id}`),
      parent: null,
      children: [],
      internal: {
        type: NODE_TYPE,
        content: JSON.stringify(node),
        contentDigest: createContentDigest(node),
      },
    })
  })
}

exports.onPreInit = () => console.log("Loaded gatsby-node")

This works fine when displaying the data through {JSON.stringify(data, null, 4)}Results in error when used in a gatsby .js page file.
Code in the gatsby page file:

import React from "react"
import { graphql, useStaticQuery } from "gatsby"
import { Helmet } from "react-helmet"

export const query = graphql`
  {
    allObjkt {
      edges {
        node {
          value {
            objkt_id
            xtz_per_objkt
          }
        }
      }
    }
  }
`
export default ({ data }) => <>

Punks on sale...

    {data.allObjkt.nodes.map(objkt => (

{objkt.xtz_per_objkt}

    ))}

</>

Error produced:

Cannot read property 'map' of undefined

  20 |
Punks on sale...

  21 |

> 22 |     {data.allObjkt.nodes.map(objkt => (
     |                         ^
  23 |

  24 |
{objkt.xtz_per_objkt}

  25 |

Some background, I'm using this site to source my data. I've been getting this error for a while now and I don't know what is up with the code.

A: You have a typo. You are querying for edges and node, not nodes. So your code should look like:
export default ({ data }) => <>

Punks on sale...

    {console.log("data is", data)}
    {data.allObjkt.edges.map(({node})=> {
     console.log("node", node);
     return

{node.value.xtz_per_objkt}

    })}

</>


text:
Q: Borel Group on R Last week in class we used the fact that if we have a group within R which is also a Borel Set, then it is either R or meagre. Why is it so? Can you direct me to a proof?

A: These notes written by Julien Melleray help us to solve the problem. I just state the results which will help in our case.

Lemma 3.3 (Pettis) Let $G$ a Polish group. For $A\subset G$, define
  $U(A)$ as the biggest open set $V$ such that $A$ is comeagre $V$.
  For any subsets $A$ and $B$ of $G$, we have
  $$U(A)\cdot U(B)\subset A\cdot B.$$

As a consequence:

Theorem 3.4 Let $G$ a Polish group, and $A$ a Baire measurable non-meagre subset of $G$. Then $e$, the neutral element, belongs to the interior of $A\cdot A^{-1}$.

Back to the problem. Of course, $\Bbb R$ with the addition is a Polish group. Let $H$ a subgroup of $\Bbb R$ which is non-meagre and Borel measurable. It's Baire measurable. By the last theorem, $e$ belongs to the interior of $H\cdot H^{-1}=H$ as $H$ is a sub-group.
It's well-know that the subgroups of $\Bbb R$ are either of the form $a\Bbb Z$ (hence meagre) or dense. So we have a subgroup $H$ which is dense and has non-empty interior, say $(-r,r)$. Let $x\in \Bbb R$, and $x'\in H$ such that $|x-x'|\lt r$. Then $x-x'\in H$ and $x\in H$.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Not able to pass JSON object as second argument in javascript function call I am generating rows in javascript with for each loop, where each row has an anchor and with onclick of that anchor I am trying to pass a JSON object as  second argument in my javascript function but I am getting undefined error.
I have already verified that result is a JSON object
Here is my code to generate rows.
 _.each(
response.details,
function(result, key, list) {searchdetails += "
Details
";
   });

I am getting below error:-

I have also tried by appending it like string as below:-
 _.each(
response.details,
function(result, key, list) {searchdetails += "
Details
";
   });

With this, I am getting below error:-

Can anybody tell me how do I pass it as JSON object.

A: You are missing quotes and need to stringify your object:
function(result, key, list) {searchdetails += "
Details
";

Note how modified code differs:
"...'Updatedetails(\"2\",\""+JSON.stringify(result)+"\")'..."


text:
Q: Error when runnin Arm-Based Network Meta-Analysis for Binary Outcomes I am trying to perform a  network meta analysis in R using the package "pcnetmeta".
It is a meta analysis of different studies (8) on the same treatment. I would like to plot 95% credible intervals (CIs) for the treatment-specific effect sizes.
I have a simple data set, it is the following:
dataset
s.id    t.id    r   n
1   1   0   60
2   1   1   100
3   1   6   264
4   1   2   108
5   1   3   73
6   1   6   241
7   1   10  317
8   1   2   71

Where "s.id"=study identification number, "t.id" = treatment ID (there is only one treatment), "r"=number of events for each study & "n"=the number of patients enrolled in each study.
I run the following code, which is really similar to the example from the introduction to the package "pcnetmeta" but I get the following error message:

Error in jags.model(file = textConnection(modelstring), data = data.jags,  :
    unused argument (n.iter = n.burnin)

I use the following code:
# Abs Plot
# increase n.iter to reach convergence
# increase n.adapt to enhance efficiency
set.seed(1234)
nma.out <- nma.ab.bin(s.id, t.id, r, n, data = data,
trtname = c("treatment"), param= "AR",
model = "het_cor", n.adapt = 400, n.iter = 100, n.chains = 1)

absolute.plot(nma.out)
absolute.plot(nma.out, alphabetic = FALSE)

The code is the same as the example from the data package (below), I have only adapted it to my dataset:
data(smoke)
# increase n.iter to reach convergence
# increase n.adapt to enhance efficiency
set.seed(1234)
nma.out <- nma.ab.bin(s.id, t.id, r, n, data = smoke,
trtname = c("NC", "SH", "IC", "GC"), param= "AR",
model = "het_cor", n.adapt = 400, n.iter = 100, n.chains = 1)
absolute.plot(nma.out)
absolute.plot(nma.out, alphabetic = FALSE)

https://cran.r-project.org/web/packages/pcnetmeta/pcnetmeta.pdf
I tried to do some de-bugging but I cannot find the problem.
Could you please help me?
Thank you!
Christian

A: Firstly, unfortunately the error message which pcnetmeta package giving is not informative at all.
To understand the underlying problem, I ran the source code of nma.ab.bin step by step using your data. Note that, this package actually uses JAGS program to fit arm-based NMA models via Bayesian inference.
The resulting JAGS error is following:
RUNTIME ERROR:
Non-conforming parameters in distribution dwish

You can read a very similar problem and it's solution from here. When we look at the JAGS code used in the pcnetmeta:
T[1:ntrt,1:ntrt]~dwish(I[1:ntrt,1:ntrt],ntrt+1)

we can see that it is related to dwish. By the way, JAGS syntax is very similar to R syntax. Here ntrt variable is the number of treatment of your data. So in your case it is just 1. By default, nma.ab.bin uses Wishart (dwish) distribution for the variance covariance matrix of random effects. Apparently there is a problem related to dwish, and this is because ntrt = 1. To make it work, ntrt must be bigger than 1.
Bottom line is that you should have at least two treatments to use nma.ab.bin. This makes senses, since when you look at the title of the reference paper of the pcnetmeta package:
Network meta-analysis of randomized clinical trials: Reporting the proper summaries

As you can see, it is NMA of randomized clinical trials (RCTs). And RCTs, by definition, has at least two treatment arms (usually one placebo and one is experimental). Of course there are one-arm trials, but they are not randomized (because you randomize with what, right).


text:
Q: Azure Express route forced-tunneling with NVA I want to set-up forced tunneling in Azure. All traffic destined to internet should be routed to on-prem and exit to internet from there.

*

*As far as i understand i need to advertise default route via BGP in Azure so that it replaces internet default route and send everything to on-prem via Express route.

*Then i make UDRs 0.0.0.0/0 next hop to NVA Cisco firewall on all subnets in Azure.

All traffic from Azure subnets will go to NVA and from there it will be routed to on-prem or to another vNET.
Question is what about the traffic coming from on-prem to Azure ? I want that traffic to also go through NVA cisco firewall. How could it be done as gateway subnet do not support 0.0.0.0/0 UDRs with Express route setup.

A: Your initial understanding of the setup is correct. You will have to advertise a default route of 0.0.0.0/0 via BGP from your on-premises to Azure, so that all your Azure traffic is sent to your on-premises via the ExpressRoute. And in order to filter all that traffic by an NVA, you can add a UDR with 0.0.0.0/0 on all the subnets (except the NVA subnet) with next hop as your Cisco Firewall NVA.
This setup will take care of the routing from Azure to on-premises which will go as below:
All subnets --> Cisco NVA --> ExpressRoute gateway --> On-premises.
Now coming back to your question on what about the return traffic, yes GatewaySubnet do not support 0.0.0.0/0 UDRs but it supports UDRs with other address prefixes.
Hence, you can add a UDR to the ExpressRoute GatewaySubnet with the address prefix of your Vnet range with next hop type Virtual Appliance and IP address of your Cisco NVA. This will make sure that any traffic that comes from your on-premises for your Azure Vnet range, when reaches your ExpressRoute gateway will be forwarded to the Cisco NVA.
For example : If your Vnet address range is 10.0.0.0/16 then you can add a UDR to your ExpressRoute GatewaySubnet as below:
Address prefix : 10.0.0.0/16 --> Next hop = Virtual Appliance --> Next hop = IP address of Cisco NVA
So the routing from On-premises to Azure will go as below:
On-premises --> ExpressRoute gateway --> Cisco NVA --> All subnets.


text:
Q: Play framework 2.x laconic template internationalization Does anyone know a more laconic way to internationalization than:

@Messages.get("Title")

Something in the spirit of the Play 1.x:

&{'Title'}

A: That's the standard way. You could create your own tag:
//file: I.scala.html under views.tags

@(key: String)

@Messages.get(key)

and then use it like
@import tags._  //to import tags, only once per template

@I("my.key")

A: Based on Pere Villega's answer, I created a small tag file to support message parameters.
i.scala.html (because I don't trust uppercase is):
@(key: String, args:String*)@Messages(key, args:_*)

The file's content is on a single line and doesn't contain any and whitespace in the html part, because otherwise linebreaks would be included and may break something or at least make the resulting code ugly and hard to read.
It can be used like this: @i("my.key", value1, value2).

Another tag, hi.scala.html, for messages including html:
@(key: String, args:String*)@Html(Messages(key, args:_*))


text:
Q: How to find spid of SQL Agent job that is running or has already run? I am having difficulties trying to find the SPID of a job that is still running over a certain timeframe or has already ran. Does anyone know where I can find that? I do know that I can look at the master.sys.sysprocesses table to find the spid's that are known to SQL Server.
This is one of my many tries:
SELECT        TOP (100) PERCENT sj.name, sja.run_requested_date, CONVERT(VARCHAR(12), sja.stop_execution_date - sja.start_execution_date, 114) AS Duration, sj.job_id, sj.enabled
FROM            msdb.dbo.sysjobactivity AS sja INNER JOIN
                         msdb.dbo.sysjobs AS sj ON sja.job_id = sj.job_id
WHERE        (sja.run_requested_date IS NOT NULL) AND (CONVERT(VARCHAR(12), sja.stop_execution_date - sja.start_execution_date, 114) > CONVERT(VARCHAR(12), '00:00:02:000', 114))
ORDER BY sja.run_requested_date DESC

A: I use Adam Machanic's sp_WhoIsActive to get this info.
For historical data I run it every minute and capture the output to a table.
Brent Ozar has an article on how to do this here.


text:
Q: Windows.old - How does it work? Contents have disappeared When I installed Win8 Developer Preview over my WinXP, it produced a Windows.old that contained the old "Program Files" folder among other things.
After a few weeks of mucking around with W8DP not-supporting some of my hardware, I sold the PC, while keeping the harddisk.
Now when I connect the harddisk to my new PC (running Win7) via a USB-SATA adapter, everything appears to be present except for most of the contents of the Windows.old folder. Explorer shows it as zero bytes. There is just one chain of folders inside Windows.old: F:\Windows.old\Users\Bob\AppData\Roaming\Macromedia\Flash Player\#SharedObjects\AXKPGGN6\i.d.com.com\av\video
I have tried taking ownership using this, but there is no difference.
Properties of the harddisk shows the space that used to be occupied by the Windows.old folder as free. (Same according to WinDirStat).
Have I somehow permanently lost the files?

A: Yes. If the folder is empty, then there are no files there anymore and unless they're all in your recycle bin (don't bother looking, they're not - your recycle bin isn't big enough), you'll need forensic software to recover the files if you need them back.

A: Your computer could have had some kind of error because normally what would happen if you installed onto of another Windows after doing it once, you'd achieve another Windows.old folder probably with a #1 or #2 added or something.
Did you happen to forget you copied your Windows.old files/folders somewhere else & just not remember where it went? I wouldn't discount it because my parents did exactly that when Windows 7 came out.
If not, you could try looking into data recovery software. Although, it usually only works when you don't save & it doesn't change the indentations (secretly undeleted data) in the HDD platter.

A: Sounds like you have probably lost the files but you may like to try Recuva - http://www.filehippo.com/download_recuva
It's free and I've used it to good effect. Definitely worth a try if you are only looking to recover a few key files.


text:
Q: Why we use Static Members on C#? Can someone explain what is main difference between Instance and Static Members with real examples?

A: Static Members are run without using the implied "this" parameter which is the instance reference to the object that Instance Method was called from.
var number = Int32.TryParse("1234"); // Static member of Int32.
//Is not called using an object, it doesnt not need the 'this'
//because it doesn't change the data of the class.

string stringy = "asdfasdf";

char [] characters = stringy.ToCharArray();
//requires the strings data so it needs the instance stringy.

If the classes data is needed then you need an instance. If not you can make the method static so that it can be called at any time without an object.
Edit: I Initially read that as static methods. Static Data Members are completely different. When your program runs there is exactly one data object of that type allocated and is accessible via the class name not an instance of the class.
public class Classy
{
    public static int number= 4;

    public static void func() { }

    // Other non-static fields and properties...
}

//mainline..
//
int n = Classy.number;
Classy.func(); // etc..

A: You don't create instances for static classes. You just call them using their type name.
For example.
public static StaticClass {
   public static void StaticMethod(){}
}

To call the static method, you will just type this, StaticClass.StaticMethod().
When you create an object of a class, it is known as creating an instance of that class. You can only create instance of concrete classes).
For example
public class ConcreteClass {

public void RandomMethod(){}

}

To call RandomMethod, you will have to create an instance of the ConcreteClass by creating an object.
ConcreteClass abc = new ConcreteClass();
abc.RandomMethod();

Also note that, in a static class, all it's members will have to be static and this makes sense because, since you will not be instantiating the class, you should be able to call it's members directly. This is why in my static class example above, the method too is also static.
I hope this helps.


text:
Q: How do you allow PUTs and DELETEs in ASP.NET Core 3.1 MVC I'm trying to get a simple MVC page to PUT to my Controller. GET and POST will work fine, but I am doing an Update, so a PUT is more applicable, and it's calling the WebAPI backend with a PUT just fine.
I've created a new base project and replicated the issue too. If I POST a form it is caught by the controller. If I change the same controller endpoint to HttpPut and change the form to Put, it doesn't. Instead a GET is called!
I'm aware of the WebDAV fix in web.config, but this is Core 3.1, so there is no web.config. Does anyone know how to affect that same WebDAV fix in 3.1? If that is in fact the issue.
I've replicated the issue with this minimal code:
HomeController.cs
public class HomeController : Controller
{
    public IActionResult Index()
    {
        var model = new IndexViewModel();
        return View(model);
    }

    [HttpPut] // Change this to HttpPost
    public IActionResult Index(IndexViewModel model)
    {
        Debug.Print(model.Text);
        return RedirectToAction("Index");
    }
}

IndexViewModel.cs
public class IndexViewModel
{
    public int Id { get; set; }
    public string Text { get; set; }
}

Index.cshtml
@model IndexViewModel
<div class="text-center">
    <form asp-action="Index" method="put"> @*Change this to method="post"*@
        <input type="hidden" asp-for="Id" />
        <input type="text" asp-for="Text" />
        <button type="submit">Go</button>
    </form>
</div>


text:
Q: In the film of A Boy and His Dog "Blue Screamers" are mentioned -- do we know anything more about them? Do we know anything more about "Blue Screamers"? For example, had they been human? What are their attributes?
BTW, maybe they were just called "screamers" -- maybe color was not mentioned.

A: They're "burnpit screamers" in the book, and yes, in the movie, they were not actually shown, only heard, and at one point implied by a blue light.
Here's an excerpt from the book:

"Well, I guess maybe I do. Maybe I have to remind you of some stuff. Like the time that burnpit-screamer came up out of the street and made a grab for you."
I shuddered. The motherfucker'd been green. Righteous stone green, glowing like fungus. My gut heaved, just thinking.
"And I went for him, right?"
I nodded. Right, mutt, right.
"And I could have been burned bad, and died, and that would've been all of it for me, right or wrong, isn't that true?" I nodded again. I was getting pissed off proper. I didn't like being made to feel guilty. It was a fifty-fifty with Blood and me. He knew that. "But I did it, right?" I remembered the way the green thing had screamed. Christ, it was all ooze and eyelashes.

The scene plays very similarly in the film. I don't think it's ever completely spelled out in the text, but the burnpit screamers are implied to be survivors of radiation poisoning, deformed and glowing mutants who can deliver burns from residual radiation on contact.


text:
Q: Merge two .csv files and add missing rows? I have two files. A.csv:
date,colA
2016-01-01,1
2016-01-02,4
2016-01-03,2

And B.csv:
date,colB
2016-01-01,2
2016-01-03,4

I'd like to combine these to get equivalent of:
date,colA,colB
2016-01-01,1,2
2016-01-02,4,0
2016-01-03,2,4

So I want to append colB to original data and all missing dates from B.csv should have value 0 added. The resulting data will be plotted with pgfplots.
Is this possible with LaTeX, pgfplots or pgfplotstable? We can safely assuma that A.csv has all the needed dates.
Or is it possible to add the missing rows first to B.csv before merging?
My current solution is to add the missing rows manually and then use \pgfplotstablecreatecol[copy column from table=... macro.
EDIT: I'm using Overleaf so the solution should work there aswell.

A: Well,if you have R and you admit knitr as LaTeX solution, then is easy:

\documentclass{article}
\usepackage{verbatim,xcolor}
\begin{filecontents*}{A.csv}
date,colA
2016-01-01,1
2016-01-02,4
2016-01-03,2
\end{filecontents*}
\begin{filecontents*}{B.csv}
date,colB
2016-01-01,2
2016-01-03,4
\end{filecontents*}
\begin{document}
<<echo=F,results='asis'>>=
A <- read.csv(file="A.csv")
B <- read.csv(file="B.csv")
C <- merge(A,B,by="date", all=T)
C[is.na(C)] <- 0
write.csv(C, file="C.csv",quote=F,row.names=F)
@
Contents of \fcolorbox{gray}{gray!20}{\texttt{C.csv}}:~~~~~
\parbox{6cm}{\verbatiminput{C.csv}}
\end{document}

A: How about this solution, not requiring R? Uses only LaTeX and the datatool package
\documentclass{article}
\usepackage{filecontents}
\usepackage{datatool}

\begin{filecontents*}{A.csv}
date,colA
2016-01-01,1
2016-01-02,4
2016-01-03,2
\end{filecontents*}

\begin{filecontents*}{B.csv}
date,colB
2016-01-01,2
2016-01-03,4
\end{filecontents*}

% \DTLloaddb{A}{A.csv}
\DTLloaddb{B}{B.csv}
\DTLloaddb{C}{A.csv}

\DTLforeach{C}{\Date=date}{
    \DTLgetvalueforkey{\tmp}{colB}{B}{date}{\Date}
    \DTLappendtorow{colB}{\DTLifnull{\tmp}{0}{\tmp}}
}

\begin{document}

\DTLsetseparator{,}
\DTLsetdelimiter{"}
\DTLsavedb{C}{C.csv} % doesn't write if before \begin{document}

\DTLdisplaydb{C}

\end{document}


text:
Q: Change tty resolution to fit larger screen I have a dual screen setup:
 - Main screen, 1920x1080 plugged in via HDMI
 - Additional screen, 1366x768, plugged in via VGA
When I switch to tty, its resolution fit the smaller screen. But, as the video output is duplicated into the larger screen, the output on the larger screen isn't stretched, or anything, so I end up with TTY filling only about half of the larger screen which looks ugly on "fullscreen" terminal applications.
Is there any way I can make tty resolution fit the 1080p screen at the cost of text visibility on the smaller screen?
I am using Debian testing.

A: Finally I've setup fbset -xres 1920 -yres 1080 to be executed by root on startup and it worked just like I've wanted, without modifying GRUB config files.


text:
Q: Associate personal VSTS to an Organisation When I created VSTS account, mistakenly I have chosen Personal instead of Work,School... (as you can see on the picture)
Now I need to associate it with my organisation account. I search a lot and I couldn't find anything useful.
Please guide me to solve this problem.

A: Sorry, you can't associate personal VSTS to an Organisation Although both identities use the same email address, they're still separate identities with different profiles, security settings, and permissions.
Please see the Q&A below:

Why must I choose between a "work or school account" and my "personal
  account"?

*

*Choose Work or school account if you want to use your organization's    directory to authenticate VSTS users and to control
  VSTS account    access. This limits access to members in your
  organization's    directory. All other users must sign in with work or
  school accounts    too.

*Choose Personal account if you want to use your Microsoft account    with VSTS. All other users must sign in with Microsoft
  accounts too.

*

*If you feel annoying about the pop-up, you could just follow the
link to rename your personal Microsoft account.

*If you are worrying about the subscribers:

Within the Visual Studio subscriber portal, you may be able to add an
  alternate identity--in addition to the identity you used during activation. Today we allow you to add an alternate identity if you
  used a Microsoft account to activate your subscription. This way you
  can also add a work or school account (which you use when logging into
  Visual Studio, Office 365, or your corporate or school network),
  allowing you to access VSTS using both your personal account and your work or school account.

Detail steps please take a look at:How to add an alternate identity to your Visual Studio subscription

*If you can't sign in when choose both please see: Why can't I sign
in after I choose either "personal Microsoft account" or "work or
school account"?

A: Check this link to associate your personal account with a organization account.
https://learn.microsoft.com/en-us/vsts/release-notes/2018/mar-05-vsts#subscriptions


text:
Q: How to handle invalid inputs while displaying Game menus? #include <iostream>
#include <string>

using namespace std;

int main() { //Program starts
    cout << "-------------------------------" << endl;
    cout << "Welcome to Ninjas vs. Samurais!" << endl; //The intro
    cout << "-------------------------------" << endl;

    string newAdventure;
    string chosenKind;

    cout << "Hello, new solder! Are you ready for your adventure to begin,       yes or no?\n"; //Asks you if you are ready

    cin >> newAdventure;//Takes in if you are ready or not

    if (newAdventure == "yes" || newAdventure == "Yes" || newAdventure ==    "Yes!") { //Asks if they are ready
        cout << "Great!\n" << endl;
    }
    else if (newAdventure == "no" || newAdventure == "No" || newAdventure ==     "No!") { //Asks if they are ready
        cout << "Too bad!\n" << endl;

    }
    else {
        cout << "Please type a yes or no answer!\n";
    }
    system("PAUSE");
    return 0;
}

If the user didn't input a valid answer, how could I make them restart the question? Would I have to use a loop? If so, how would I do that?

A: You can add a condition like this:
while(true)
{

cout << "Hello, new solder! Are you ready for your adventure to begin,       yes or no?\n"; //Asks you if you are ready

cin >> newAdventure;//Takes in if you are ready or not

if (newAdventure == "yes" || newAdventure == "Yes" || newAdventure ==    "Yes!") { //Asks if they are ready
    cout << "Great!\n" << endl;
    break;
}
else if (newAdventure == "no" || newAdventure == "No" || newAdventure ==     "No!") { //Asks if they are ready
    cout << "Too bad!\n" << endl;
    break;
}
else {
    cout << "Please type a yes or no answer!\n";
}

}

A: Yes you would have to use a loop. Something like:
while(cin >> newAdventure)//Takes in if you are ready or not
  {
    if (newAdventure == "yes" || newAdventure == "Yes" || newAdventure ==    "Yes!") { //Asks if they are ready
        cout << "Great!\n" << endl;
        break;
    }
    else if (newAdventure == "no" || newAdventure == "No" || newAdventure ==     "No!") { //Asks if they are ready
        cout << "Too bad!\n" << endl;
        break;
    }
    else {
        cout << "Please type a yes or no answer!\n";
    }
  }

The break keyword will exit the loop once your answer is valid, otherwise, it keeps going.


text:
Q: Create a calculated column to be yes IF([due date]=[Today]-31, "yes", no) or custom view Im trying to set up a calculated column to look at another calculated date column and if its under a month (ie its due to be renewed) than say yes.
if i cant do that can i create a custom view from a calculated date column?
the greater than or equal to [Today]-31 doesnt work on calculated columns?
My end goal is to use flow to look for the yes column and then create a new list item, but i cant use odata filters from calculated columns and [Today]-31 doesnt work on calculated columns? Kinda stuck

A: To get today's date in calculate column, you should use the function TODAY() instead of [Today]. Change your formula to this
=IF([due date]=TODAY()-31,"yes","no")


text:
Q: Spinors in dimension 6 From the representation of $\operatorname{Spin}(6)\cong \operatorname{SU}(4)$, one can deduce that on a $6$-dimensional manifold we get the postive spinor bundle from the usual $4$-dimensional representation of $\operatorname{SU}(4)$ and we get the negative spinor bundle from the dual or adjoint representation of the usual representation (e.g., see Representation of $SU(4)$). So, $S_-\cong S_+^*$.
But I am having a hard time to decode it in practice, for example we can have the whole spinor bundle: $S\cong S_+\oplus S_+^*$ and we have a metric on $S_+$, and we can give a map $*:S_+\rightarrow S_+^*, \phi\mapsto \langle\hspace{1 ex}, \phi\rangle$. How do we get the Clifford multiplication $e_i\cdot *(\phi)$ in-terms of $e_i\cdot\phi$, notice that for the action of the volume form $dV,$ $S_+$ is the eigen-space of eigenvalue $i$ and $S_-\cong S_+^*$ is the eigen-space of eigenvalue $-i$. Also for a spin connection $A$ and a positive spinor $\phi$, how do we see $D_A(\phi)$ acting on another positive spinor? Any description solving the issues is most welcome.


text:
Q: When I declare a double and assign a value it returns an integer value When I declare a global variable as double and assign a value it returns an integer value.
Using debug mode, I observe that the compiler initializes the variable with an integer value as opposed to a floating point, as shown in the picture.

Edit:
ok here is the whole code==
xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.ommabdelhafiz.amathmess.MainActivity">
    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:padding="16dp"
            android:orientation="vertical">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal">

                <TextView
                    android:layout_width="70dp"
                    android:layout_height="wrap_content"
                    android:text="7"
                    android:textSize="16sp"
                    android:id="@+id/first_1st"/>

                <TextView
                    android:layout_width="70dp"
                    android:layout_height="wrap_content"
                    android:text="×"
                    android:textSize="16sp"
                    />

                <TextView
                    android:layout_width="70dp"
                    android:layout_height="wrap_content"
                    android:text="7"
                    android:textSize="16sp"
                    android:id="@+id/first_2nd"/>

                <TextView
                    android:layout_width="70dp"
                    android:layout_height="wrap_content"
                    android:text="="
                    android:textSize="16sp"
                    />

                <EditText
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:textSize="16sp"
                    android:inputType="number"
                    android:maxLength="3"
                    android:hint="                "
                    android:id="@+id/first_ans"
                    android:imeOptions="actionDone"
                    android:layout_marginRight="20dp"/>

                <LinearLayout
                    android:layout_width="wrap_content"
                    android:layout_height="match_parent"
                    android:orientation="vertical">

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="0"
                        android:textSize="16dp"
                        android:layout_gravity="center_horizontal"
                        android:id="@+id/first_true_ans"/>

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="0"
                        android:textSize="16dp"
                        android:gravity="bottom"
                        android:layout_gravity="center_horizontal"
                        android:id="@+id/first_false_ans"/>

                </LinearLayout>

                <Button
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="Check"
                    android:layout_marginLeft="20dp"
                    android:onClick="check1st"
                    android:id="@+id/first_btn"/>

            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal">

                <TextView
                    android:layout_width="70dp"
                    android:layout_height="wrap_content"
                    android:text="49"
                    android:textSize="16sp"
                    android:id="@+id/second_1st"/>

                <TextView
                    android:layout_width="70dp"
                    android:layout_height="wrap_content"
                    android:text="÷"
                    android:textSize="16sp"
                    />

                <TextView
                    android:layout_width="70dp"
                    android:layout_height="wrap_content"
                    android:text="7"
                    android:textSize="16sp"
                    android:id="@+id/second_2nd"/>

                <TextView
                    android:layout_width="70dp"
                    android:layout_height="wrap_content"
                    android:text="="
                    android:textSize="16sp"
                    />

                <EditText
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:textSize="16sp"
                    android:inputType="number"
                    android:maxLength="2"
                    android:hint="                "
                    android:id="@+id/second_ans"
                    android:imeOptions="actionDone"
                    android:layout_marginRight="20dp"/>

                <LinearLayout
                    android:layout_width="wrap_content"
                    android:layout_height="match_parent"
                    android:orientation="vertical">

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="0"
                        android:textSize="16dp"
                        android:layout_gravity="center_horizontal"
                        android:id="@+id/second_true_ans"/>

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="0"
                        android:textSize="16dp"
                        android:gravity="bottom"
                        android:layout_gravity="center_horizontal"
                        android:id="@+id/second_false_ans"/>

                </LinearLayout>

                <Button
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="Check"
                    android:layout_marginLeft="20dp"
                    android:onClick="check2nd"
                    android:id="@+id/second_btn"/>

            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal">

                <TextView
                    android:layout_width="70dp"
                    android:layout_height="wrap_content"
                    android:text="711"
                    android:textSize="16sp"
                    android:id="@+id/third_1st"/>

                <TextView
                    android:layout_width="70dp"
                    android:layout_height="wrap_content"
                    android:text="×"
                    android:textSize="16sp"
                    />

                <TextView
                    android:layout_width="70dp"
                    android:layout_height="wrap_content"
                    android:text="7"
                    android:textSize="16sp"
                    android:id="@+id/third_2nd"/>

                <TextView
                    android:layout_width="70dp"
                    android:layout_height="wrap_content"
                    android:text="="
                    android:textSize="16sp"
                    />

                <EditText
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:textSize="16sp"
                    android:inputType="number"
                    android:maxLength="4"
                    android:hint="                "
                    android:id="@+id/third_ans"
                    android:imeOptions="actionDone"
                    android:layout_marginRight="20dp"/>

                <LinearLayout
                    android:layout_width="wrap_content"
                    android:layout_height="match_parent"
                    android:orientation="vertical">

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="0"
                        android:textSize="16dp"
                        android:layout_gravity="center_horizontal"
                        android:id="@+id/third_true_ans"/>

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="0"
                        android:textSize="16dp"
                        android:gravity="bottom"
                        android:layout_gravity="center_horizontal"
                        android:id="@+id/third_false_ans"/>

                </LinearLayout>

                <Button
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="Check"
                    android:layout_marginLeft="20dp"
                    android:onClick="check3rd"
                    android:id="@+id/third_btn"/>

            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal">

                <TextView
                    android:layout_width="70dp"
                    android:layout_height="wrap_content"
                    android:text="41.735"
                    android:textSize="16sp"
                    android:id="@+id/fourth_1st"/>

                <TextView
                    android:layout_width="70dp"
                    android:layout_height="wrap_content"
                    android:text="+"
                    android:textSize="16sp"
                    />

                <TextView
                    android:layout_width="70dp"
                    android:layout_height="wrap_content"
                    android:text="23.836"
                    android:textSize="16sp"
                    android:id="@+id/fourth_2nd"/>

                <TextView
                    android:layout_width="70dp"
                    android:layout_height="wrap_content"
                    android:text="="
                    android:textSize="16sp"
                    />

                <EditText
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:textSize="16sp"
                    android:inputType="numberDecimal"
                    android:hint="                "
                    android:maxLength="7"
                    android:id="@+id/fourth_ans"
                    android:imeOptions="actionDone"
                    android:layout_marginRight="20dp"/>

                <LinearLayout
                    android:layout_width="wrap_content"
                    android:layout_height="match_parent"
                    android:orientation="vertical">

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="0"
                        android:textSize="16dp"
                        android:layout_gravity="center_horizontal"
                        android:id="@+id/fourth_true_ans"/>

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="0"
                        android:textSize="16dp"
                        android:gravity="bottom"
                        android:layout_gravity="center_horizontal"
                        android:id="@+id/fourth_false_ans"/>

                </LinearLayout>

                <Button
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="Check"
                    android:layout_marginLeft="20dp"
                    android:onClick="check4th"
                    android:id="@+id/fourth_btn"/>

            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal">

                <TextView
                    android:layout_width="70dp"
                    android:layout_height="wrap_content"
                    android:text="71.159"
                    android:textSize="16sp"
                    android:id="@+id/fifth_1st"/>

                <TextView
                    android:layout_width="70dp"
                    android:layout_height="wrap_content"
                    android:text="-"
                    android:textSize="16sp"
                    />

                <TextView
                    android:layout_width="70dp"
                    android:layout_height="wrap_content"
                    android:text="14.704"
                    android:textSize="16sp"
                    android:id="@+id/fifth_2nd"/>

                <TextView
                    android:layout_width="70dp"
                    android:layout_height="wrap_content"
                    android:text="="
                    android:textSize="16sp"
                    />

                <EditText
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:textSize="16sp"
                    android:inputType="numberDecimal"
                    android:maxLength="7"
                    android:hint="                "
                    android:id="@+id/fifth_ans"
                    android:imeOptions="actionDone"
                    android:layout_marginRight="20dp"/>

                <LinearLayout
                    android:layout_width="wrap_content"
                    android:layout_height="match_parent"
                    android:orientation="vertical">

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="0"
                        android:textSize="16dp"
                        android:layout_gravity="center_horizontal"
                        android:id="@+id/fifth_true_ans"/>

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="0"
                        android:textSize="16dp"
                        android:gravity="bottom"
                        android:layout_gravity="center_horizontal"
                        android:id="@+id/fifth_false_ans"/>

                </LinearLayout>

                <Button
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="Check"
                    android:layout_marginLeft="20dp"
                    android:onClick="check5th"
                    android:id="@+id/fifth_btn"/>

            </LinearLayout>

        </LinearLayout>
    </ScrollView>
</RelativeLayout>

Java:
package com.example.ommabdelhafiz.amathmess;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import java.util.Random;

public class MainActivity extends AppCompatActivity {

    int firstTrueAns = 0;
    int firstFalseAns = 0;
    int firstFirstValue = 7;
    int firstSecondValue = 7;

    int secondTrueAns = 0;
    int secondFalseAns = 0;

    int thirdTrueAns = 0;
    int thirdFalseAns = 0;
    int thirdFirstValue = 711;
    int thirdSecondValue = 7;

    int fourthTrueAns = 0;
    int fourthFalseAns = 0;
    double fourthFirstValue = 41.735;
    double fourthSecondValue = 23.836;

    int fifthTrueAns = 0;
    int fifthFalseAns = 0;
    double fifthFirstValue = 71159;
    double fifthSecondValue = 14704;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

    }

    public void check1st(View v) {
        int firstRealAns ;
        TextView first1st = (TextView) findViewById(R.id.first_1st);
        TextView first2nd = (TextView) findViewById(R.id.first_2nd);
        TextView firstTrueAnsText = (TextView) findViewById(R.id.first_true_ans);
        TextView firstFalseAnsText = (TextView) findViewById(R.id.first_false_ans);
        EditText firstAns = (EditText) findViewById(R.id.first_ans);

        firstRealAns = firstFirstValue * firstSecondValue;

        if (firstAns.getText().toString().equals(String.valueOf(firstRealAns))) {

            firstTrueAns += 1;
            firstTrueAnsText.setText(String.valueOf(firstTrueAns));

        } else {

            firstFalseAns += 1;
            firstFalseAnsText.setText(String.valueOf(firstFalseAns));
            Toast.makeText(this, "Wrong answer, The true answer is " + firstRealAns, Toast.LENGTH_LONG).show();
        }

        Random rand = new Random();
        firstFirstValue = rand.nextInt(13) + 1;
        firstSecondValue = rand.nextInt(13) + 1;
        first1st.setText(String.valueOf(firstFirstValue));
        first2nd.setText(String.valueOf(firstSecondValue));
        firstAns.setText("");
    }

    public void check2nd() {

    }

    public void check3rd(View v) {
        int thirdRealAns = 0;
        TextView third1st = (TextView) findViewById(R.id.third_1st);
        TextView third2nd = (TextView) findViewById(R.id.third_2nd);
        EditText thirdAns = (EditText) findViewById(R.id.third_ans);
        TextView thirdTrueAnsText = (TextView) findViewById(R.id.third_true_ans);
        TextView thirdFalseAnsText = (TextView) findViewById(R.id.third_false_ans);

        thirdRealAns = thirdFirstValue * thirdSecondValue;

        String ans = thirdAns.getText().toString();
        if (ans.equals(String.valueOf(thirdRealAns))) {

            thirdTrueAns += 1;
            thirdTrueAnsText.setText(String.valueOf(thirdTrueAns));

        } else {

            thirdFalseAns += 1;
            thirdFalseAnsText.setText(String.valueOf(thirdFalseAns));
            Toast.makeText(this, "Wrong answer, The true answer is " + thirdRealAns, Toast.LENGTH_LONG).show();
        }

        Random rand = new Random();
        thirdFirstValue = rand.nextInt(10) + 1;
        thirdSecondValue = rand.nextInt(1000) + 1;
        third1st.setText(String.valueOf(thirdFirstValue));
        third2nd.setText(String.valueOf(thirdSecondValue));
        thirdAns.setText("");
    }

    public void check4th(View v) {
        double fourthRealAns ;
        TextView fourth1st = (TextView) findViewById(R.id.fourth_1st);
        TextView fourth2nd = (TextView) findViewById(R.id.fourth_2nd);
        TextView fourthTrueAnsText = (TextView) findViewById(R.id.fourth_true_ans);
        TextView fourthFalseAnsText = (TextView) findViewById(R.id.fourth_false_ans);
        EditText fourthAns = (EditText) findViewById(R.id.fourth_ans);

        fourthRealAns = (fourthFirstValue + fourthSecondValue) / 1000;

        if (fourthAns.getText().toString().equals(String.valueOf(fourthRealAns))) {

            fourthTrueAns += 1;
            fourthTrueAnsText.setText(String.valueOf(fourthTrueAns));

        } else {

            fourthFalseAns += 1;
            fourthFalseAnsText.setText(String.valueOf(fourthFalseAns));
            Toast.makeText(this, "Wrong answer, The true answer is " + fourthRealAns, Toast.LENGTH_LONG).show();
        }

        Random rand = new Random();
        fourthFirstValue = (rand.nextInt(100000) + 1) / 1000;
        fourthSecondValue = (rand.nextInt(100000) + 1) /1000;
        fourth1st.setText(String.valueOf(firstFirstValue));
        fourth2nd.setText(String.valueOf(firstSecondValue));
        fourthAns.setText("");
    }

    public void check5th(View v) {
        double fifthRealAns ;
        TextView fifth1st = (TextView) findViewById(R.id.fifth_1st);
        TextView fifth2nd = (TextView) findViewById(R.id.fifth_2nd);
        TextView fifthTrueAnsText = (TextView) findViewById(R.id.fifth_true_ans);
        TextView fifthFalseAnsText = (TextView) findViewById(R.id.fifth_false_ans);
        EditText fifthAns = (EditText) findViewById(R.id.fifth_ans);

        fifthRealAns = fifthFirstValue - fifthSecondValue;

        if (fifthAns.getText().toString().equals(String.valueOf(fifthRealAns))) {

            fifthTrueAns += 1;
            fifthTrueAnsText.setText(String.valueOf(fifthTrueAns));

        } else {

            firstFalseAns += 1;
            fifthFalseAnsText.setText(String.valueOf(fifthFalseAns));
            Toast.makeText(this, "Wrong answer, The true answer is " + fifthRealAns, Toast.LENGTH_LONG).show();
        }

        Random rand = new Random();
        fifthFirstValue = rand.nextInt(100000) + 1;
        fifthSecondValue = rand.nextInt((int) fifthSecondValue) + 1;
        fifth1st.setText(String.valueOf(fifthFirstValue / 1000));
        fifth2nd.setText(String.valueOf(fifthSecondValue / 1000));
        fifthAns.setText("");
    }
}

A: You should add a (d) after the value before the (;) like this example:
fourthFirstValue = 41.735d ;


text:
Q: Embeddings of an infinite graph. I'm asking for a formal proof or counterexample (if it's false) of the following.
If a graph (in general) has a vertex like in the picture below (of infinity degree), the
the graph cannot have a cellular embedding into any surface.
Any elaboration to help me build more intuition about this or similar questions
are very welcome.

A: If a graph $G$ has a vertex $v$ of infinite valence then $v$ does not have a countable neighborhood basis.
To sketch a proof of this, let $E_i$ ($i \in I$) be the oriented edges of $G$ with initial vertex $G$, and let $\alpha_i : [0,1] \to E_i$ be an orientation preserving parameterization of $E_i$. For any function $R : I \to (0,1)$, the set $U(R) = \bigcup_{i \in I} \alpha_i \bigl([0,R(i))\bigr)$ is a neighborhood of $v$ (by definition of the celluar topology, also known as the CW topology). And then, for any countable set of neighborhoods $V_1,V_2,...$ of $f(v)$, one can choose a countably infinite subset $\{i_1,i_2,...\} \subset I$ and use a diagonalization construction to produce $R : I \to (0,1)$ so that $U(R)$ does not contain any of the subsets $V_j$.
But for any surface $S$ and any continuous injection $f : G \to S$, the image $f(v)$ does have a countable neighborhood basis in the subspace topology on $f(G)$, namely the intersection with $f(G)$ of any countable neighborhood basis of $f(v)$ in $S$. Therefore, $f$ is not an embedding, meaning that it does not have a continuous inverse with respect to the subspace topology on $f(G)$.
The point is that the cellular topology is a very fine topology, with many many open sets, too many for $G$ to be embeddable into a surface.


text:
Q: how to enable filestream in SQL Server 2008 without SQL Server Management Studio I'm trying to enable Filestream in SQL Server 2008 and I Do not have  SQL Server Management Studio component installed on my computer, all info I've found already needs the Management studio, how could I enable it without it? thanks

A: using sqlcmd utility enter the following commands:
USE master
Go
EXEC sp_configure 'show advanced options'
GO
EXEC sp_configure filestream_access_level, 1
GO
RECONFIGURE WITH OVERRIDE
GO

There are 3 levels of FILESTREAM access which are supported in SQL Server 2008 and they are mentioned below for your reference.

*

*When the value specified is 0 then, FILESTREAM support for the instance is Disabled

*When the value specified is 1 then, FILESTREAM for Transact-SQL Access is Enabled

*When the value specified is 2 then, FILESTREAM for Transact-SQL and Windows streaming access is Enabled

look at this page (http://www.mssqltips.com/tip.asp?tip=1838) for more info.

A: Although you can use sp_configure to set the FILESTREAM access level, the documentation notes that it has no effect unless Windows is also configured using the SQL Server Configuration tool.
Assuming that the server is under your or your company's internal control, you can just RDP to it and use the tools installed on the server.

A: You can enable the OS portion using WMI. Here's some details on this along with a downloadable script:
http://sqlsrvengine.codeplex.com/wikipage?title=FileStreamEnable
After doing this you'll still need to enable through osql or similar like Alex_L's answer.

A: To enable FILESTREAM feature on SQL Server 2008, you can use  SQL Server Configuration Manager :

*

*Open SQL Server Configuration Manager (Start > Programs > Microsoft SQL Server 2008 > Configuration Tools > SQL Server Configuration Manager)

*Navigate to the SQL Server Services node and select the SQL Server instance you want to modify SQL Server

*Click the FILESTREAM tab and select the checkboxes to enable FILESTREAM and enter a share name for the files


text:
Q: Log in to my Windows 7 account from another computer on the same network Okay, let's say I have a network called "myNetwork" and on this network three computers, all of which run Windows 7 Home. One has my user account on it (lets call it "user1") and the PC's name is "foo". I want to log into my account on "foo" on one of the other two computers on the network ("bar"). If possible, I want to do something like foo\user1 on the login screen (. Is there a way to do this? If not, is there an alternate solution?

A: This is not possible. Under Windows Home, user accounts are local to the individual machine, and have no context on another machine. The closest you could come would be to define identical accounts and passwords on all three machines, eg 'User1' on foo and bar. The problem is that account may look the same, but they are in reality entirely different and distinct accounts on each machine.
You can share a resource from one machine, and control access to it via accounts on that machine, and then connect to it from a different machine by specifying the credentials on the machine hosting the resource, but that's still not what you're looking for. That's exactly what the Pro series of Windows OS's is intended to provide.

A: As David said, the accounts are local only to the computer itself. The way companies and schools are able to have users log in to any workstation and access the appropriate files is using Active Directory.
One solution I recommend if you're looking to access files and programs local to a different machine than you're using is VNC. It is very easy to install a VNC server on the computer you want to log in to and install a viewer on the machine you're using. On a local network there should be no additional setup. You can then "remote" in to the computer you want to use and log in as the user on that computer.

A: ctrl-alt-del at the login screen will give a machine\user logon experience.
To default to the machine\user logon experience, see a discussion on answers.microsoft.com. There are two versions of the same solution at the bottom of the comments

*

*HKLM\Software\Microsoft\Windows NT\CurrentVersion\ProfileList\DomainStyleLogon

*HKLM\Software\Microsoft\Windows NT\CurrentVersion\ProfileList.DEFAULT


text:
Q: OutOfMemoryError heap dump I have a java.lang.OutOfMemoryError:GC Overhead limit exceeded.
There is no HeapDumpOnOutOfMemoryError command line option for my application.
I need a heap dump but when I try to capture the dump with jmap or jcmd tools they are not responding:
jmap
D:\program>jmap -dump:live,format=b,file=d:\dump4.hprof 8280
Dumping heap to D:\dump4.hprof ...

jcmd
D:\program>jcmd 8280 GC.heap_dump d:\dump6.hprof
8280:

Processes are not completing but dump files are created. When I open them with VisualVM, they are loading infinitely.
If I capture a heap dump of e.g. VisualVM, Tools complete successfully and dumps are created and opened.
Could you please explain why jmap and jcmd are not completing? And how can I capture a dump of the application with OutOfMemoryError exception? Application is still working but there are only a few live threads.

A: One possibility is that the heap size you intend to dump is too large in size.
Please specify the size of the heap and RAM.

A: It is not due to your intended heap size is more than allocated heap size. This error occurs when the JVM spent too much time performing Garbage Collection and was only able to reclaim very little heap space. Your application might have ended up using almost all the RAM and Garbage collector has spent too much time trying to clean it and failed repeatedly.
Your application's performance will be slow comparatively, This is because the CPU is using its entire capacity for Garbage Collection and hence cannot perform any other tasks.
Following questions need to be addressed:

*

*What are the objects in the application that occupy large portions of the heap?

*In which parts of the source code are these objects being allocated?

You can also use automated graphical tools such as JConsole which helps to detect performance problems in the code including java.lang.OutOfMemoryErrors.


text:
Q: Table Formatting Correctly on Laptop...Phone won't resize table with animated gif Website is www.lionofjudahworldwide.com
Click on buy incense
On laptop table sizes correctly..
On phone animated gif is outside bounds...
Here is code
Table A

copied from inside youtube
Table B

A: Please use width in %.

It will work.


text:
Q: Django Form Reject Input if Specific User uses the same name twice and notifies user In Django, I have a custom form that creates an "email group" within a modal. The email group model contains a number of attributes, including a unique ID for the email group, for the user, etc.
The idea is that a specific user shouldn't be able to enter the same name twice - and if they do, they should be notified.
It seems right now like the form is rejecting inputs that duplicate email_name (it doesn't get added to the database), but the message it's returning is New Email Added.
I've also been trying to get the email to show within the modal but that's a whole other issue.
form.py
class EmailCreateForm(ModelForm):
class Meta:
    model = UserEmail
    fields = ['email_name']
    constraints = [
        models.UniqueConstraint(fields=['user_id', 'email_name'], name='unique_name')
    ]

def __init__(self, *args, **kwargs):
    super(EmailCreateForm, self).__init__(*args, **kwargs)  # Call to ModelForm constructor
    self.fields['email_name'].widget.attrs['rows'] = 1

views.py
def email(request):
if request.method == 'POST':
    form = EmailCreateForm(request.POST, instance=request.user)

    if form.is_valid():
        form.save()
        messages.success(request, f'New Email Added')
        return redirect('project-emails')
    else:
        messages.error(request, f'Email not Added')
        return redirect('project-emails')

else:
    form = EmailCreateForm()
return render(request, 'project/emails.html', {'form': form})

part of template emails.html
{% if messages %}
{% for message in messages %}
    <div class="alert id = 'email-message'">
        {{ message|escape }}
    </div>
{% endfor %}
{% endif %}

A: According to Django documentation:

The classes defined in this module create database constraints. They are added in the model Meta.constraints option.

So, this should be added to the model class, not form.
Thus, your form.is_valid() will return true and the success message will be displayed. If you set unique constraints on the model class they should be checked in ModelForm instances in both steps: when validating the form and when saving to DB.


text:
Q: SQL Server date range, monthly or quarterly I have a list of dates in a SQL Server table, and need to figure out a few separate themes about them:
Firstly, are the dates monthly or quarterly? The dates always start on the first of the month.
E.g. one sequence may be 01/01/13, 01/02/13, 01/03/13, 01/04/13, 01/05/13 therefore monthly (UK)
E.g. another sequence may be 01/12/12, 01/03/13, 01/06/13, 01/09/13, 01/12/13 therefore quarterly (UK)
And secondly, which may be solved by the first, are all the dates present? eg no gaps. One way I went around solving this was to say it is either monthly / quarterly or no idea, but that was in C#.
Thanks

A: You can use the DATEDIFF() function to compare two dates, and you can use a self-join and the ROW_NUMBER() function to compare dates from different rows:
;WITH cte AS (SELECT *, ROW_NUMBER() OVER (ORDER BY dt) RN
              FROM Table1)
SELECT DATEDIFF(day,a.dt,b.dt)
FROM cte a
JOIN cte b
 ON a.RN = b.RN-1

If you are using SQL 2012 you can use the LEAD() function to compare values from different rows:
SELECT  DATEDIFF(day,dt,LEAD(dt,1) OVER(ORDER BY dt)) AS Days
       ,DATEDIFF(quarter,dt,LEAD(dt,1) OVER(ORDER BY dt)) AS Quarters
FROM Table2

Demo: SQL Fiddle


text:
Q: dojo Layout is not working Can somebody post a dojo Layout working example. I have the below html file , Layout is not appearing at-all, I have all dojo related files in the root of the web app.[I even tried using google CDN , but no help]
the page contents are displayed without the Layout.
I have copy pasted the example available in the Internet, but no success.
would appreciate your help. Thanks in advance.
<!DOCTYPE HTML>

<meta charset="utf-8">
<title>Demo: Layout with Dijit</title>

Group 1 Content

para 1

h4 para 2

h4 para 3

Header content (top)

Sidebar
            content (left)

A: You need to make sure you have dojo parse your doc (see Frode's comment).
Also, you may need to give your body an explicit width and height (iirc, IE will collapse it otherwise).

A: <!DOCTYPE HTML>

<meta charset="utf-8">
<title>Demo: Layout with Dijit</title>

<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/dojo/1.6/dijit/themes/claro/claro.css" >

Group 1 Content

para 1

h4 para 2

h4 para 3

Header content (top)

Sidebar
            content (left)

above code bringing the Layout. Thanks all who have helped.


text:
Q: How to improve performance on SQLite3 iPhone program I am (still) working on an iPhone program which uses SQLite3. I have managed to optimize the database writes as far as I can.
The problem I have now is that "END TRANSACTION" is killing me as it's taking very long. The journal file is usually about 50k which might be a problem, but I'd like to know your ideas.
I tried using "PRAGMA synchronous = 0", but that caused some data corruption. My latest attempt at optimizing is "PRAGMA journal_mode=TRUNCATE" but I do not know if that helps a lot.
Any suggestions at this stage?

A: Have you tried the in memory journaling?
"PRAGMA journal_mode=MEMORY"
That was one of the most significant performance boosts for us.
If that is not quite fast enough yet, try the memsys5 stuff.
http://www.sqlite.org/compile.html#enable_memsys5


text:
Q: Python/Pandas Select Columns based on Best Value Distribution I have a dataframe (df) in pandas/python with ['Product','OrderDate','Sales'].
I noticed that some rows, values have better Distribution (like in a Histogram) than others. By "Best" meaning, the shape is more spread, or the spread of values make the shape looks wider than for other rows.
If I want to pick from say +700 Product's, those with more spread values, is there a way to do that easily in pandas/python?
txs in advance.

A: Caveat here is that I'm not a stats expert but basically scipy has a number of tests you can conduct on your data to test whether it could be considered to be a normalised Gaussian distribution.
Here I create 2 series one is simple a linear range and the other is a random normalised sampling with mean set to 50 and variance set to 25.
In [48]:

import pandas as pd
import scipy.stats as stats
df = pd.DataFrame({'linear':arange(100), 'normal':np.random.normal(50, 25, 100)})
df
Out[48]:
    linear      normal
0        0   66.565374
1        1   63.453899
2        2   65.736406
3        3   65.848908
4        4   56.916032
5        5   93.870682
6        6   89.513998
7        7    9.949555
8        8    9.727099
9        9   47.072785
10      10   62.849321
11      11   33.263309
12      12   42.168484
13      13   38.488933
14      14   51.833459
15      15   54.911915
16      16   62.372709
17      17   96.928452
18      18   65.333546
19      19   26.341462
20      20   41.692790
21      21   22.852561
22      22   15.799415
23      23   50.600141
24      24   14.234088
25      25   72.428607
26      26   45.872601
27      27   80.783253
28      28   29.561586
29      29   51.261099
..     ...         ...
70      70   32.826052
71      71   35.413106
72      72   49.415386
73      73   28.998378
74      74   32.237667
75      75   86.622402
76      76  105.098296
77      77   53.176413
78      78   -7.954881
79      79   60.313761
80      80   42.739641
81      81   56.667834
82      82   68.046688
83      83   72.189683
84      84   67.125708
85      85   24.798553
86      86   58.845761
87      87   54.559792
88      88   93.116777
89      89   30.209895
90      90   80.952444
91      91   57.895433
92      92   47.392336
93      93   13.136111
94      94   26.624532
95      95   53.461421
96      96   28.782809
97      97   16.342756
98      98   64.768579
99      99   68.410021

[100 rows x 2 columns]

From this page there are a number of tests we can use which are combined to for the normaltest, namely the skewtest and kurtosistest, I cannot explain these but you can see that the p-value is poor for the linear series and is relatively closer to 1 for the normalised data:
In [49]:

print('linear skewtest teststat = %6.3f pvalue = %6.4f' % sc.stats.skewtest(df['linear']))
print('normal skewtest teststat = %6.3f pvalue = %6.4f' % sc.stats.skewtest(df['normal']))

print('linear kurtoisis teststat = %6.3f pvalue = %6.4f' % sc.stats.kurtosistest(df['linear']))
print('normal kurtoisis teststat = %6.3f pvalue = %6.4f' % sc.stats.kurtosistest(df['normal']))

print('linear normaltest teststat = %6.3f pvalue = %6.4f' % sc.stats.normaltest(df['linear']))
print('normal normaltest teststat = %6.3f pvalue = %6.4f' % sc.stats.normaltest(df['normal']))
linear skewtest teststat =  1.022 pvalue = 0.3070
normal skewtest teststat = -0.170 pvalue = 0.8652
linear kurtoisis teststat = -5.799 pvalue = 0.0000
normal kurtoisis teststat = -1.113 pvalue = 0.2656
linear normaltest teststat = 34.674 pvalue = 0.0000
normal normaltest teststat =  1.268 pvalue = 0.5304

From the scipy site:

When testing for normality of a small sample of t-distributed
  observations and a large sample of normal distributed observation,
  then in neither case can we reject the null hypothesis that the sample
  comes from a normal distribution. In the first case this is because
  the test is not powerful enough to distinguish a t and a normally
  distributed random variable in a small sample.

So you'll have to try the above and see if it fits with what you want, hope this helps.

A: Sure. What you'd like to do here is find the 700 entries with the largest standard deviation.
pandas.DataFrame.std() will return the standard deviation for an axis, and then you just need to keep track of the entries with the highest corresponding values.
Large Standard Deviation vs. Small Standard Deviation


text:
Q: ListBox get value from index I am writing a program where you insert some numbers in a listbox and then a button click should get the values from the listbox and check whether they are positive or negative and display each other's count in a textbox.
I tried getting the value by: string x = listBox1.Items[index].Value; but it doesn't seem to work.

A: If you add the items to the list box as such:
listBox1.Items.Add(textBox1.Text);
Then you can retrieve the item from given index as follows:
string x = listBox1.Items[index];
The indexer is returning the value, which in that case is a string. Probably you might need to cast it to string, because the indexer actually returns object - see here: ListBox.ObjectCollection.Item Property :
string x = (string)listBox1.Items[index];

A: You can also try
string s = (string)listbox1.Items.GetItemAt(index);

You have to cast it to string because it's returning an object


text:
Q: How to insert html code just before I have this block of code in a login .ctp file:
<?php echo $this->Form->create('AdmUser', array(
    'class' => 'form-vertical',
    'inputDefaults' => array(
        'label' => false,
        'div' => false,
    ))); ?>

<?php echo $this->Form->input('login', array(
    'placeholder' => 'User')
    );?>

I'm using slywalker's TwitterBootstrap plugin for cakephp so the output is like this:

          <input name="data[AdmUser][login]" placeholder="User" maxlength="15" type="text" id="AdmUserLogin" required="required">

I'm trying to put some html code just before input tag like this:

          <input name="data[AdmUser][login]" placeholder="User" maxlength="15" type="text" id="AdmUserLogin" required="required">

When i try to use 'before' => '' the code goes between
 and

A: I have tested my code to the CakePhp version cakephp-2.6.6.
echo $this->Form->input(
    'login',
    array(
    'between' =>'',
    'after'=>'',
    'placeholder' => 'User'
    )
);

And which produces:

<input type="text" id="AdmUserLogin" placeholder="User" name="data[AdmUser][login]">

You have custom form helper I think that's why you got

Code before input field and your 'before' tag not working.If you add 'between' tag it will add code before your input and finally you have to add 'after' tag to null because you do not need to add extra html after your input field.
Thanks.

A: Have you tried the examples in the readme of the plugin?
https://github.com/slywalker/TwitterBootstrap/blob/master/README.md
I haven't tested it, but it seems the plugin uses 'prepend' and 'append' options to add these kind of options; if these options are set, the FormHelper internally generated these tags using this method;
BootstrapFormHelper::addOn()


text:
Q: How to list all unique values for each category I have two columns, first is the function of the Business (Upstream, Downstream , Midstream etc) and the other is the city those functions operate in. There are a ton of other functions amd cities but I have made it smaller here and it looks something like this:
Function      City
DownStream   Edmonton
Downstream   Edmonton
upstream     Edmonton
Upstream     Calgary
Midstream    Calgary
Midstream    Calgary
Midtream     Edmonton
Upstream     Vancouver

I know the unique() function will return the unqiue values I am looking for, however I am having trouble creating something that will group the Function column and then listing the unique Cities for each Function.
Something like this as the end results:
Functions  City

Downstream Edmonton

Midstream  Edmonton
           Calgary

Upstream   Edmonton
           Calgary
           Vancouver

Here is some sample data to work from
# Create sample data
Function=c("DownStream", "DownStream", "Upstream", "Upstream", "Midstream",
           "Midstream", "Midstream", "Upstream")
City=c("Edmonton", "Edmonton", "Edmonton", "Calgary","Calgary", "Calgary",
       "Edmonton", "Vancouver")
df <- data.frame(Function, City)

A: I would suggest first getting the unique rows and than replacing the duplicates with NA.
# Create sample data
Function=c("DownStream", "DownStream", "Upstream", "Upstream", "Midstream",
           "Midstream", "Midstream", "Upstream")
City=c("Edmonton", "Edmonton", "Edmonton", "Calgary", "Calgary", "Calgary",
       "Edmonton", "Vancouver")
df <- data.frame(Function, City)

# Get unique rows and replace duplicates with NA
unique_df <- unique(df)
unique_df[duplicated(unique_df[,"Function"]),"Function"] <- NA
print(unique_df)

A: First create a data frame in R, like df=data.frame(Function, City), then simply unique(Function, City) will give the results.
Or use dplyr package, then run the following codes
df %>% group_by(Function) %>% distinct(City).


text:
Q: Input Mask variable Question
I have all the input masks set-up however I'm struggling to figure this one out logically..
So I have an input field for Gigabecquerels. However, as it currently stands the input could be like this 1,428.22Gbq, 428.22Gbq, 22.80Gbq So, how does one account for this? I could simply just place the gbq after the textfield has finished editing, however I would prefer to do it with an input mask, whilst also making it easy-to-use and not confusing.
    $("#gbq").mask("9,999.99Gbq");

Any help is greatly appreciated, thank you.
EDIT
Think of it like this,
Focused
__________ (press period)
2236______ (press period)
period pressed
2,236.__Gbq
2,236.66Gbq


text:
Q: No resource found that matches the given name even though it exist I have an android relative layout
 <RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >

    <com.my.view.text.MyTextView
        style="@style/textOnBg"
        android:layout_toLeftOf="@id/SkipIcon2"
        android:text="Skip"
        android:textStyle="normal" />

    <ImageView
        android:id="@+id/SkipIcon2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:src="@drawable/signup_skip_icon" />
</RelativeLayout>

how come I get this error:
error: Error: No resource found that matches the given name (at 'layout_toLeftOf' with value '@id/
 SkipIcon2').

A: Try this..
It's android:layout_toLeftOf="@+id/SkipIcon2"  you missed the @+id
 <com.my.view.text.MyTextView
        style="@style/textOnBg"
        android:layout_toLeftOf="@+id/SkipIcon2"
        android:text="Skip"
        android:textStyle="normal" />

Well, it depends on the context, when you're using the XML attribute of android:id, then you're specifying a new id, and are instructing the parser (or call it the builder) to create a new entry in R.java, thus you have to include a + sign.

A: you are trying to use an id that is not already declared inside R.id. You can inter switch your views or
<com.my.view.text.MyTextView
    style="@style/textOnBg"
    android:layout_toLeftOf="@+id/SkipIcon2"
    android:text="Skip"
    android:textStyle="normal" />

<ImageView
    android:id="@id/SkipIcon2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:src="@drawable/signup_skip_icon" />

Since the id are final and static you could be sure that it will be initialised only once

A: You're referencing SkipIcon2 before it has been declared. Change the reference to
    android:layout_toLeftOf="@+id/SkipIcon2"

A: Try this
 @+id/SkipIcon2

instead of
@id/SkipIcon2


text:
Q: Notice: A non well formed numeric value encountered Criei um exemplo fictício de um desconto no salário de uma pessoa, o código funciona, porém aparecem dois notices que listei abaixo do código:
    class Descontos{

        public $salario;
        public $inss;
        public $salarioLiquido;

        public function calcularPorcentagemINSS():float{
            if($this->salario < 1693.62 ){
                $this->inss = 8/100;
            } else if( $this->salario > 1693.63 OR $this->salario < 2822.90 ) {
                $this->inss = 9/100;
            } else {
                $this->inss = 11/100;
            }

            return $this->inss;
        }

        public function calcularValorINSS(){
            return $this->inss * $this->salario;
        }

        public function calcularSalarioLiquido(){
            return $this->salario - $this->calcularValorINSS();
        }

    }

    # INSTÂNCIA DA CLASSE
    $salario = new Descontos();

    echo "Salário bruto: " . $salario->salario = 2000 . "
";

    echo "Porcentagem INSS: " . $salario->calcularPorcentagemINSS() * 100 . "%
";

    echo "Valor de desconto INSS: " . $salario->calcularValorINSS() . "
";

    echo "Salário Líquido: " . $salario->calcularSalarioLiquido();

Notices apresentados:

Notice: A non well formed numeric value encountered in
  C:\xampp\htdocs\18 - POO\06 - class.php on line 23
Notice: A non well formed numeric value encountered in
  C:\xampp\htdocs\18 - POO\06 - class.php on line 27

Como posso resolvê-los?

A: Quando está fazendo
$salario->salario = 2000 . "
"

está convertendo todo o valor em string e ele está sendo guardado na variável. Como há uma concatenação virará "2000
", portanto não faz o que espera. Para resolver isto teria que fazer a atribuição em linha separada, como todo mundo faz, ou pelo menos usar parênteses no local adequado:
echo "Salário bruto: " . ($salario->salario = 2000) . "
";

Coloquei no GitHub para referência futura.
Além desse, há outros problemas técnicos, até mesmo na criação da classe. E há erros conceituais na utilização de orientação a objetos. E nem falei ainda da desnecessidade de uma classe para isso. Uma coisa que venho falando bastante e todos ignoram é que há muita preocupação em usar OOP, mas pouca em fazer código certo que é o que importa. E na maior parte do tempo código certo nada tem a ver com OOP, pelo contrário, é comum o código ser mais certo sem OOP. Orientação a objeto é difícil e até as pessoas experientes têm dificuldade de fazer certo. Por isso, se não tiver muita vantagem deveria evitar o seu uso, principalmente até dominar muito bem o paradigma (o que exige profundo estudo, e hoje em dia raro quem quer fazer isso, as pessoas estão só fingindo que fazem código certo, por isso quase tudo que você vê falha muito na web).


text:
Q: Is product of two Darboux functions Darboux? I know that sum of two Darboux functions need not be a Darboux function and square of a Darboux function is a Darboux function. But I have no idea what happens to the product of two Darboux functions. Can anyone please suggest anything?

A: As Dave Renfro points out there was a good deal of activity on the subject of Darboux functions in the past.   Jack Ceder and Andy Bruckner at  UCSB investigated such questions and produced very readable surveys on the subject.  The literature is quite large.
The earliest answer to your question might be this that I have lifted from a Math Review of a paper:
"It is well known that the sum (and the product) of a continuous function and a Darboux function need not be Darboux in general [Th. Radakovič, Monatsh. Math. 38 (1931), 117–122; Zbl 1, 329]."
T. Radakovič, Über Darbouxsche und stetige Funktionen, Monatsh. Math. Phys. 38 (1931), 117–122.
The paper related to the quote is  the article below.  If you call such a Darboux function "bad" then you will appreciate their investigation of a "universally bad" one.
Kirchheim, Bernd; Natkaniec, Tomasz.
On universally bad Darboux functions.
Real Anal. Exchange 16 (1990/91), no. 2, 481–486.


text:
Q: how to make a boxplot with significant differences between two groups I managed to make a data like this
df<- structure(list(label = structure(c(2L, 2L, 2L, 1L, 1L, 1L, 2L,
2L, 2L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 1L, 1L), .Label = c("boys",
"girls"), class = "factor"), variable = structure(c(1L, 1L, 1L,
1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 5L, 2L, 2L, 2L, 2L, 2L, 4L, 4L,
4L), .Label = c(" G1", " G20", " G5", " G52", " G9"), class = "factor"),
    value = structure(c(3L, 8L, 18L, 1L, 15L, 17L, 19L, 7L, 2L,
    2L, 11L, 10L, 6L, 4L, 9L, 12L, 14L, 5L, 13L, 16L), .Label = c("112864.443",
    "11319531", "12874.443", "142983324", "1612410048", "16349475.63",
    "184901841", "2223793.8", "30553282.01", "312004.547", "3135868.44",
    "317403612.9", "3686081.063", "43701608", "623793.8", "64959501.42",
    "67666215", "767666215", "775987137.8"), class = "factor")), .Names = c("label",
"variable", "value"), class = "data.frame", row.names = c(NA,
-20L))

Now I am trying to make a box plot for each set
when I do this
ggplot(data = df, aes(x=variable, y=value)) + geom_boxplot(aes(fill=label))

it only gives me the following which means it plots all data separated

what I want is to have them together as a box together.
These are all G1 which means they will be box together (girls in one color and boys in another color) x axis become 1 . in this set, girls have 3 replicate (samp1,2 and 3) and boys have 3 replicate (samp4,5,6)
Then the second box will be In this case girls have 3 replicate (samp1,2,3) and boys have 2 replicate (samp5,6)
something like this would also be great if few points cannot be plotted by box plot
https://www.r-graph-gallery.com/47-groups-distribution-with-ggplot2/
I want to make a significant comparison between girls in different x axis and boys in different x-axis , something like this Put stars on ggplot barplots and boxplots - to indicate the level of significance (p-value)

A: Okay, your real problem is that you have your value stored as a factor as if it was categorical data. We can fix this and then plot:
df$value = as.numeric(as.character(df$value))

ggplot(df, aes(x = variable, y = value, fill = label)) +
    geom_boxplot()

But you really don't have enough data for boxplots. I would just use points, maybe dodged a little bit like this:
ggplot(df, aes(x = variable, y = value, color = label)) +
    geom_point(position = position_dodge(width = 0.2))


text:
Q: ModuleNotFoundError": No module named 'selenium' with a virtualenv I am trying to run the command (it is in a python script functional_tests.py):
from selenium import webdriver

I am running Ubuntu and here is a list of how I set up my python environment:
    2  sudo apt-get upgrade
    3  sudo apt-get update --fix-missing
    4  sudo apt-get upgrade -y
    5  sudo apt update
    6  sudo apt install software-properties-common
    9  sudo add-apt-repository ppa:deadsnakes/ppa
   10  sudo apt install python3.6
   14  mkdir python-tdd-book
   15  cd python-tdd-book/
   24  sudo apt install python3.6-venv
   25  sudo apt install python3.6
   28  python3.6 -m venv virtualenv
   33  source virtualenv/bin/activate
   34  which python
   37  pip install "django<1.12" "selenium<4"
   46  python -m pip install -U selenium

I did not get any errors when I ran #37 in history (#46 was an attempt to solve it using another solution). I had no errors - all seemed good (except wanting to upgrade version of pip).
This is the output:
(virtualenv) ubuntu@ubuntu2004:~/Documents/python-tdd-book$ python ./functional_tests.py
Traceback (most recent call last):
  File "./functional_tests.py", line 1, in <module>
    from selenium import webdriver
ModuleNotFoundError: No module named 'selenium'

According to this command I have installed selenium:
(virtualenv) ubuntu@ubuntu2004:~/Documents/python-tdd-book$ pip list
Package    Version
---------- -------
Django     1.11.29
pip        18.1
pytz       2022.1
selenium   3.141.0
setuptools 40.6.2
urllib3    1.26.10
You are using pip version 18.1, however version 21.3.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

Not sure why it is NOT seeing the selenium module.


text:
Q: Copying contents of .NET build folder to Ubuntu server using Plink I'm building a pre-deploy script in PowerShell that creates a production build of my .NET Core Web Api application and then SSHs into my Ubuntu Digital Ocean Droplet via SSH key.
I'm currently at a stage where I create the build, copy the build folder using Copy-Item, SSH into my server and then this is where I'm completely stuck.
I know that I can run BASH commands from my PowerShell script because I've tried some basic operations like creating and deleting a directory, I can cd in and out of directories. I've tried storing the copied .NET build folder in memory as a variable:
$build = Copy-Item -Path $projectBuildPath -Recurse and then found out that this can't be done (shame really, that would have been cool) and then opening a session to my server via p-link cli like so:
plink.exe -ssh -i $SSHKeyLocation $linuxRemoteHost "cd path\to\server\build-folder && paste ${build}"

But again because you can't store copied directories in memory, this failed.
My PowerShell script looks like this:
$projectRootDir
$projectBuildPath
$linuxRemoteHost
$SSHKeyLocation

Set-Location $projectRootDir
Write-Host "Building .NET application..."

dotnet publish --configuration Release --verbosity normal

Write-Host "Built Successfully..."
Write-Host "Copying project build files"

$build = Copy-Item -Path $projectBuildPath -Recurse
# fails, for obvious reasons

Write-Host "Remoting into MusicPortal Server..."

plink.exe -ssh -i $SSHKeyLocation $linuxRemoteHost "cd path\to\server\build-folder && paste ${build}"
# SSH Connection successful, paste command fails

Write-Host "Remote successfull, transfering build files..."

exit 0

What should I do in order to successfully paste the copied directory to my server? I'm such a noob with PowerShell and SSH.

A: It's quite strange to try to use plink to upload files to a server. As you didn't give any particular reason, why you want to use plink, I'm assuming that it's a mistake.
You do not want to use plink. You want to use psftp or pscp (both part of the same PuTTY package as plink).
pscp -r -i $SSHKeyLocation $projectBuildPath $linuxRemoteHost:/path/to/server/build-folder/


text:
Q: std::for_each working on more than one range of iterators The lambda notation has made stl algorithms more accessible. I am still learning to decide when it's useful and when to fall back to good old fashioned for-loops.
Often, it becomes necessary to iterate over two (or more) containers of the same size, such that corresponding elements are related, but for some reason are not packed into the same class.
A function using a for-loop to achieve that would look like this:
template<typename Data, typename Property>
void foo(vector<Data>& data, vector<Property>& prop) {
    auto i_data = begin(data);
    auto i_prop = begin(prop);
    for (; i_data != data.end(); ++i_data, ++i_prop) {
        if (i_prop->SomePropertySatistfied()) {
            i_data->DoSomething();
        }
    }
}

In order to use for_each, I need a version of it that handles multiple ranges; something like:
template<typename InputIter1, typename InputIter2, typename Function>
Function for_each_on_two_ranges(InputIter1 first1, InputIter1 last1, InputIter2 first2, Function f) {
    for (; first1 != last1; ++first1, ++first2) {
        f(*first1, *first2);
    }
    return f;
}

With this version, the above code would look like this:
template<typename Data, typename Property>
void foo_two_ranges(vector<Data>& data, vector<Property>& prop) {
    for_each_on_two_ranges(begin(data), end(data), begin(prop), [](Data& d, Property& p) {
        if (p.SomePropertySatistfied()) {
            d.DoSomething();
        }
    });
}

Is there an equivalent way of achieving the same result using stl algorithms?
EDIT
I found the exact answer to my question in the form of boost::for_each running on boost::range. I added the answer, with example code for the sake of completeness.

A: 1)  The algorithms in the STL are not meant to cover every possible case, if you need for_each_on_two_ranges then write it (as you have) and use it. The beauty of the STL is it's so extensible, and you've extended it with a useful new algo.
2) If that doesn't work, you don't have to use good old fashioned for-loops, you can use fancy new for-loops instead!
As another answer said, boost::zip_iterator is your friend here, but it doesn't have to be hard to use.  Here's a solution using a range adaptor that is implemented with zip_iterator
template<typename Data, typename Property>
void foo(vector<Data>& data, vector<Property>& prop) {
    for (auto i : redi::zip(data, prop))
        if (i.get<1>().SomePropertySatistfied())
            i.get<0>.DoSomething();
}

That zip function creates an adaptor with begin() and end() members that return a boost::zip_iterator, so the loop variable is a tuple of the elements of each underlying container (and as it's a variadic template you can do it for any number of containers, so you don't need to write for_each_for_three_ranges and for_each_for_four_ranges etc.)
You could also use it with for_each
auto z = redi::zip(data, prop);
typedef decltype(z)::iterator::reference reference;

for_each(begin(z), end(z), [](reference i) {
    if (i.get<1>().SomePropertySatistfied()) {
        i.get<0>().DoSomething();
    }
});

A: After reading up on boost::zip_iterator and boost::iterator_range as suggested by some answers, I came across the extension algorithms in boost::range, and found the exact parallel of the algorithm I wrote for two ranges, but with boost ranges.
A working code for the example would be
#include <boost/range/algorithm_ext/for_each.hpp>

template<typename Data, typename Property>
void foo_two_ranges(vector<Data>& data, vector<Property>& prop) {
    auto rng1 = boost::make_iterator_range(data.begin(), data.end());
    auto rng2 = boost::make_iterator_range(prop.begin(), prop.end());
    boost::for_each(rng1, rng2, [](Data& d, Property& p) {
        if (p.SomePropertySatistfied()) {
            d.DoSomething();
        }
    });
}

Some wrappers and utility functions, similar in mind to what @Jonathan Wakely suggested, can make this even more usable.

A: std::transform has an overload that operates on two sequences in parallel.  You'd need a null output iterator to absorb the results though, if you weren't interested in collecting any.


text:
Q: Grails: Integration test crashes with NPE on GORM collection? I'm trying to do a fairly simple integration test on a controller, and while it all works in the application, the integration test fails with a NPE. I'm still new to Grails 2.5.0 / Spock testing, and I'm sure I must be doing something stupid here, but can't figure it out. I would assume that in an integration test (unlike a unit test) the behavior should be pretty much the same as when the app is running.
Imagine the following (very simplified) scenario to reproduce the problem I'm getting. A simple 3-level domain object hierarchy:
class Author {
    String name
    static hasMany = [books: Book]
}

class Book {
    String name
    static belongsTo = [author: Author]
    static hasMany = [chapters: Chapter]
}

class Chapter {
    String name
    static belongsTo = [book: Book]
}

And a controller with a single action to receive all chapters from all books owned by a single author (i.e. accessing collections 2 levels deep):
class AuthorController {
    def listChapters(Long id) {
        Author a = Author.get(id)
        respond a.books.chapters.flatten()
    }
}

I have sample data generated in bootstrap, and the above controller method works and returns all chapters from all books by a single author in a flat, 1-level JSON array (as expected). But the integration test crashes with a NPE as if the lazy-loaded collection was never initialized, i.e. Cannot get property 'chapters' on null object
Here's the test:
class AuthorIntegrationSpec extends IntegrationSpec {
    def controller

    def setup() {
        controller = new AuthorController()
    }

    def cleanup() {
        controller = null
    }

    def "chapters of a single author can be retrieved"() {
        when: "I call the listChapters action"
        controller.response.format = 'json'
        controller.request.method = 'GET'
        controller.params.id = 1
        controller.listChapters()

        then: "I get 200 OK"
        controller.response.status == 200
    }
}

I'm sure I must be missing something pretty obvious, but have already spent 3 hours on this to no avail. I would appreciate any pointers to why this is crashing or if my way with this integration test is completely wrong?
UPDATE: Here's BootStrap code with sample data:
def init = { servletContext ->
    def rado = new Author(name: 'Rado').save(flush:true)
    def joe = new Author(name: 'Joe').save(flush:true)

    def book1 = new Book(name: 'Book1', author: rado).save(flush:true)
    def book2 = new Book(name: 'Book2', author: rado).save(flush:true)
    def book3 = new Book(name: 'Book3', author: rado).save(flush:true)
    def book4 = new Book(name: 'Book4', author: joe).save(flush:true)

    new Chapter(name: 'Chapter 1', book: book1).save(flush:true)
    new Chapter(name: 'Chapter 2', book: book1).save(flush:true)
    new Chapter(name: 'Chapter 3', book: book1).save(flush:true)
    new Chapter(name: 'Chapter 4', book: book1).save(flush:true)

    new Chapter(name: 'BChapter 1', book: book2).save(flush:true)
    new Chapter(name: 'BChapter 2', book: book2).save(flush:true)
}


text:
Q: Creating a query based on creation date I am trying to figure out how to create a query based on creation date. I tried the following:
select
s.emailaddress
, s.subscriberkey
, s.status
, s.datejoined
from _subscribers s
where s.dateJoined >= dateadd(d,-1, cast(getDate() as date))

But I receive the following error:

Error saving the Query field.Field 'Contact ID' is a required for the
  Target Data Extension. Ensure this field is specified in your query
  text.

A:
Error saving the Query field.Field 'Contact ID' is a required for the
  Target Data Extension. Ensure this field is specified in your query
  text.

This means that ContactID is set to a required / non-nullable in the target data extension. To overcome this, you either have to include it in your query, delete it from the target data extension or make it nullable (not required)


text:
Q: Best practice for creating a variables page in php? I have to create an administrator control panel and I want to create a php page that just contains variables that can be changed by the administrator and that would affect the rest of the website. Is there a specific best practice method for this? I used the array method below because I saw phpBB (open source forum software) using it. (and of course on my actual website, one php file would create just arrays/array and other php files will contain functions editing the array variables)
<?php
$acp_array = array(
    'apple' => 'red',
    'grass' => 'green',
    'sky' => 'blue'
);
print_r($acp_array);

echo '<br />';

$acp_array['sky'] = 'purple';
print_r($acp_array);
?>

Also, how would I make the array variable change (in my example the change from blue to purple for the sky variable) permanent? Or is there a better and different way to store php variables that should be used through the site globally?

A: For an admin control panel I'd recommend setting up your config key=>val pairs in a database. Easily scalable, and you don't have to worry about setting write permissions to a PHP file.
Example table:
Table 'site_config'

| id    | key   | val   |
|_______|_______|_______|
| 1     | apple | red   |
| 2     | grass | green |
| 3     | sky   | blue  |


text:
Q: Copy data from string (python) I have some data from facebook Graph API
like:
{
  u'paging': {
    u'next': u'https://graph.facebook.com/v2.0/508246595873195/posts?limit=2&access_token=CAACZAPdJZAhkI8uOZBUJ5yhBFzI1IW3M55wbQT7gO7qcRwZDZD'
  ...data...data...data...
}

and more.
I want to copy https://graph.facebook.com/v2.0/508246595873195/posts?limit=2&access_token=CAACZAPdJZAhkI8uOZBUJ5yhBFzI1IW3M55wbQT7gO7qcRwZDZD only for further requests in python.
Please help!!

A: Since your data is in the format of nested dictionaries, you need to navigate through that in-order to get the desired value.
>>> d = {u'paging': {u'next': u'https://graph.facebook.com/v2.0/508246595873195/posts?limit=2&access_token=CAACZAPdJZAhkI8uOZBUJ5yhBFzI1IW3M55wbQT7gO7qcRwZDZD'}}
>>> d['paging']['next']
u'https://graph.facebook.com/v2.0/508246595873195/posts?limit=2&access_token=CAACZAPdJZAhkI8uOZBUJ5yhBFzI1IW3M55wbQT7gO7qcRwZDZD'

You should access a specific dictionary value only through it's key. So d['paging'] gives the value of the key paging which is also a dictionary. Then again specify the key which holds your expected value.