qid
int64 1
74.7M
| question
stringlengths 0
58.3k
| date
stringlengths 10
10
| metadata
list | response_j
stringlengths 2
48.3k
| response_k
stringlengths 2
40.5k
|
---|---|---|---|---|---|
7,266,915 |
Consider the following:
```
class A
{
private:
A() {}
public:
A(int x = 0) {}
};
int main()
{
A a(1);
return 0;
}
```
I have two constructors, one is a default and the other one is converting constructor with a default argument. When I try to compile the code, I expected an ambiguity error, but the compiler doesn't produce one.
Even when I don't create an instance of `A`, it doesn't produce an ambiguity error either.
```
int main()
{
return 0;
}
```
Why is that?
|
2011/09/01
|
[
"https://Stackoverflow.com/questions/7266915",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/911575/"
] |
Your code compiles because there is no ambiguity. You created a class with two constructors, one which always takes 0 arguments, and one which always takes one argument, an int. You then unambiguously called the constructor taking an int value. That this int has a default value does not matter, it is still a completely different signature. That the constructors are potentially ambiguous doesn't matter, the compiler only complains when a particular call is actually ambiguous.
When you create an instance of A with no arguments, it doesn't know which constructor you want to call: the default constructor, or the constructor taking an int with a parameter value of 0. In this case it would be nice if C++ notices that the private constructor is ineligible, but that is not always possible.
This behavior ends up being useful in some circumstances (e.g. if you have a few overloads involving templates, some of which will overlap if given the right types), though for simple cases like this, I would just make the single constructor with the default argument (preferably marked explicit unless you have a really really good reason to leave it implicit, and then I would second guess that reason just to be sure!)
-- EDIT --
Let's have some fun with this and try to explore further what is happening.
```
// A.h
class A
{
public:
A(); // declare that somewhere out there, there exists a constructor that takes no args. Note that actually figuring out where this constructor is defined is the linker's job
A(int x = 10); // declare that somewhere out there, there exists a constructor that take one arg, an integer. Figuring out where it is defined is still the linker's job. (this line does _not_ declare two constructors.)
int x;
};
// A.cpp
#include "A.h"
A::A() { ... } // OK, provide a definition for A::A()
A::A(int x) { ... } // OK, provide a definition for A::A(int) -- but wait, where is our default param??
// Foo.cpp
#include "A.h"
void Foo()
{
A a1(24); // perfectly fine
A a2; // Ambigious!
}
// Bar.cpp
class A // What's going on? We are redefining A?!?!
{
public:
A();
A(int x); // this definition doesn't have a default param!
int x;
};
void Bar()
{
A a; // This works! The default constructor is called!
}
// Baz.cpp
class A // What's going on? We are redefining A again?!?!
{
public:
//A(); // no default constructor!
A(int x = 42); // this definition has a default param again, but wait, it's different!
int x;
};
void Baz()
{
A a; // This works! A::A(int) is call! (but with what parameter?)
}
```
Note that we are taking advantage of the fact that the compiler doesn't know about headers; by the time it looks at a .cpp file, the preprocessor has already substituted #includes with the body of the header. I am playing at being my own preprocessor, doing some dangerous things like providing multiple, different definitions of a class. Later on, one of the linker's jobs is to throw out all but one of these definitions. If they do not align up in the exact right way, all kinds of bad things will happen, as you will be in the twilight zone of undefined behavior.
Note that I was careful to provide the exact same layout for my class in every compilation unit; every definition has exactly 1 int and 0 virtual methods. Note that I did not introduce any extra methods (though that might work; still doing things like this should be looked on with great suspicion), the only thing that changed were some non-virtual member functions (well constructors really) and then only to remove the default constructor. Changing and removing the default value changed nothing about the definition of A::A(int).
I don't have a copy of the spec on me, so I can't say if my careful changes fall under undefined behavior or implementation specific behavior, but I would treat it as such for production code and avoid leveraging such tricks.
And the ultimate answer to what argument is used inside of Baz is,.... 42!
|
Declaring potentially ambiguous functions in C++ does not produce any ambiguity errors. Ambiguity takes place when you attempt to *refer* to these functions in an ambiguous way. In your example ambiguity will occur if you try to default-construct your object.
Strictly speaking, it is perfectly normal to have declarations in C++ program that are potentially ambiguous (i.e. that can be referred to in an ambiguous way). For example, at the first sight these overloaded functions look fine
```
void foo(double);
void foo(int);
```
but calling `foo(1u)` will trigger ambiguity error. So, once again, ambiguity is the property of the way you refer to the previously declared functions, not the property of the function declarations themselves.
|
32,640 |
Are there gases that are not transparent at room temperature (i.e. at temperature below the point where the substance starts to radiate visible light due to heating)?
|
2015/06/09
|
[
"https://chemistry.stackexchange.com/questions/32640",
"https://chemistry.stackexchange.com",
"https://chemistry.stackexchange.com/users/9831/"
] |
First, a little bit of background. Transparency is not an absolute property of a material. *Every* substance is opaque, so long as light has to pass through enough of it, and opacity also changes according to ambient conditions. Some substances, such as most metals, are opaque even in $100\ \mathrm{nm}$ thin films, while many gasses will let a small amount of light through mostly unperturbed even after several kilometres. For example, [here](http://en.wikipedia.org/wiki/File:Photon_Mean_Free_Path.png) is a measure of how far photons of different energies can travel on average in the pure elements before interacting once with their atoms (the graph is actually for high energy x-rays rather than visible wavelengths, but they're all photons nonetheless). It makes intuitive sense that a gas should let more light through, as the atoms in it are much more spaced than in a solid or liquid.
The two general processes that work to make materials non-transparent are *photon absorption* and *photon scattering* (reflection being included as an example of scattering). When we say a material is "transparent" *colloquially*, what we generally mean is that the material, at the thickness observed, does not scatter much light and thus allows a coherent image to pass through the material (basically, you can see through it to the other side without a lot of distortion, that is, the object is **"see-through"** or **clear**). Interestingly, this means that *a clear material need not be colourless*, as correctly pointed out by Geoff, because photons of a given colour may be absorbed while letting most other wavelengths pass through without scattering.
Gasses in general are highly transparent because they are both highly colourless (absorb little light) and very clear (scatter little light) unless you're looking through several kilometres of gas, as I mentioned previously. However, there *are* examples of highly clear but coloured gasses, as it is possible for them to absorb a significant amount of photons of a certain energy due to low energy electronic transitions, while allowing the rest of the visible spectrum to pass through unimpeded. While some gasses are coloured and others are not, I believe all pure gasses must be very clear (small amounts of gas will scatter almost no light), and they can only scatter a fair amount of light across a short distance in conditions where they are probably not best described as gasses anymore (plasmas, supercritical fluids, etc).
Perhaps the most classic example of a coloured gas is nitrogen dioxide, $\ce{NO2}$, a strongly brown-red noxious gas which is [easily formed by decomposition of nitric acid](https://www.youtube.com/watch?v=pJSQq494oV4), among several other ways. The unpaired electron in its structure is somewhat uncommon, and it can be easily excited to a higher electronic state upon absorption of photons in the blue region of the visible spectrum. Since blue light is strongly absorbed even in relatively thin samples (a few centimetres of $\ce{NO2}$ gas), the rest of the white light passes through with essentially no scattering, forming a perfect image of the other side but with a strong red tinge.
Even more interestingly, $\ce{NO2}$ reacts with itself at low temperatures or high pressures and dimerizes to form [dinitrogen tetroxide](http://en.wikipedia.org/wiki/Dinitrogen_tetroxide), $\ce{N2O4}$, a colourless solid/liquid/gas (depending on conditions). In other words, the two substances are in a reversible equilibrium:
$$\ce{2 NO2 (g) <=> N2O4 (g) + energy}$$
Coincidentally, this equilibrium is characterized by an equilibrium constant which is close to 1 at ambient conditions, and this constant can easily be changed by varying temperature or pressure to higher or lower values. This means that under relatively easily achieved conditions, it is possible to study the reversible change of a coloured gas into a colourless one!

([Source](http://catalog.flatworldknowledge.com/bookhub/4309?e=averill_1.0-ch15_s01))
Though I focused on $\ce{NO2}$ because it is a remarkable case, there are several other examples of clear but coloured gasses. As Geoff mentioned, the halogens all form coloured gasses, though bromine is a volatile liquid and iodine is a solid at room temperature, so a small amount of heating is necessary. Ozone, $\ce{O3}$, is [somewhat blue](https://i.stack.imgur.com/CfI3i.jpg) ([source](http://www.masterorganicchemistry.com/2011/09/16/reagent-friday-ozone-o3/)), though its colour is best observed in the liquid phase. The same goes for oxygen gas, $\ce{O2}$, which is slightly blue, though it is not [the cause for the blue sky](http://en.wikipedia.org/wiki/Rayleigh_scattering#Reason_for_the_blue_color_of_the_sky). There are probably a few more examples out there.
|
I'd separate ***transparent*** and *colorless*.
Most gases are transparent or very nearly so because the concentration is low and absorptions are often weak.
[Chlorine](http://en.wikipedia.org/wiki/Chlorine), though is yellow-green, and has a noticeable color (from Wikipedia)

Other halogens such as bromine and iodine do have observable colors as vapor, although as mentioned in the comments, you often need slightly elevated temperature for significant vapor to form.
|
32,640 |
Are there gases that are not transparent at room temperature (i.e. at temperature below the point where the substance starts to radiate visible light due to heating)?
|
2015/06/09
|
[
"https://chemistry.stackexchange.com/questions/32640",
"https://chemistry.stackexchange.com",
"https://chemistry.stackexchange.com/users/9831/"
] |
I'd separate ***transparent*** and *colorless*.
Most gases are transparent or very nearly so because the concentration is low and absorptions are often weak.
[Chlorine](http://en.wikipedia.org/wiki/Chlorine), though is yellow-green, and has a noticeable color (from Wikipedia)

Other halogens such as bromine and iodine do have observable colors as vapor, although as mentioned in the comments, you often need slightly elevated temperature for significant vapor to form.
|
The answer to your question is yes, there are non-transparent gases, however, it depends upon the wavelength at which you are observing and how much gas you are looking through. At some wavelengths the gas is opaque at others transparent. The amount of light absorbed depends on its concentration, the path-length through which the light passes, and how strongly a molecule absorbs the light. It is quite easy to have conditions that absorbs 99.9% of all light at a given wavelength.
If you are observing in the infra red then simple gases such as oxygen or nitrogen have no transitions which absorb photons as they have no dipole which can 'capture' (in a vibrational transition or rotational) the energy of a photon. (Technically weak transitions can occur by other perturbations but for the present discussion we ignore these details).
Oxygen has low lying electronic transitions, which is when an electron is promoted from the ground state to an excited state, but these are in the near infra red and cannot be observed by eye. NO$\_2$ also has visible electronic transitions as it is brown and so do the halogen gases and vapours. Mercury vapour also absorbs in the visible and this can be seen as shadows of vapour from the liquid when illuminated by light also from a mercury lamp. The transition is so intense that the vapour becomes opaque.
At shorter wavelengths such as the ultraviolet, oxygen, nitrogen and water vapour and most all other vapours and gases become opaque at relatively low pressures and path-lengths. i.e. if our eyes were sensitive to uv light only the air would look black.
At very short wavelengths, x-rays are absorbed by a molecules atoms (not by the molecule itself) but they are also elastically scattered (no energy imparted to atom as in diffraction) or inelastically scattered (some energy imparted).
|
32,640 |
Are there gases that are not transparent at room temperature (i.e. at temperature below the point where the substance starts to radiate visible light due to heating)?
|
2015/06/09
|
[
"https://chemistry.stackexchange.com/questions/32640",
"https://chemistry.stackexchange.com",
"https://chemistry.stackexchange.com/users/9831/"
] |
First, a little bit of background. Transparency is not an absolute property of a material. *Every* substance is opaque, so long as light has to pass through enough of it, and opacity also changes according to ambient conditions. Some substances, such as most metals, are opaque even in $100\ \mathrm{nm}$ thin films, while many gasses will let a small amount of light through mostly unperturbed even after several kilometres. For example, [here](http://en.wikipedia.org/wiki/File:Photon_Mean_Free_Path.png) is a measure of how far photons of different energies can travel on average in the pure elements before interacting once with their atoms (the graph is actually for high energy x-rays rather than visible wavelengths, but they're all photons nonetheless). It makes intuitive sense that a gas should let more light through, as the atoms in it are much more spaced than in a solid or liquid.
The two general processes that work to make materials non-transparent are *photon absorption* and *photon scattering* (reflection being included as an example of scattering). When we say a material is "transparent" *colloquially*, what we generally mean is that the material, at the thickness observed, does not scatter much light and thus allows a coherent image to pass through the material (basically, you can see through it to the other side without a lot of distortion, that is, the object is **"see-through"** or **clear**). Interestingly, this means that *a clear material need not be colourless*, as correctly pointed out by Geoff, because photons of a given colour may be absorbed while letting most other wavelengths pass through without scattering.
Gasses in general are highly transparent because they are both highly colourless (absorb little light) and very clear (scatter little light) unless you're looking through several kilometres of gas, as I mentioned previously. However, there *are* examples of highly clear but coloured gasses, as it is possible for them to absorb a significant amount of photons of a certain energy due to low energy electronic transitions, while allowing the rest of the visible spectrum to pass through unimpeded. While some gasses are coloured and others are not, I believe all pure gasses must be very clear (small amounts of gas will scatter almost no light), and they can only scatter a fair amount of light across a short distance in conditions where they are probably not best described as gasses anymore (plasmas, supercritical fluids, etc).
Perhaps the most classic example of a coloured gas is nitrogen dioxide, $\ce{NO2}$, a strongly brown-red noxious gas which is [easily formed by decomposition of nitric acid](https://www.youtube.com/watch?v=pJSQq494oV4), among several other ways. The unpaired electron in its structure is somewhat uncommon, and it can be easily excited to a higher electronic state upon absorption of photons in the blue region of the visible spectrum. Since blue light is strongly absorbed even in relatively thin samples (a few centimetres of $\ce{NO2}$ gas), the rest of the white light passes through with essentially no scattering, forming a perfect image of the other side but with a strong red tinge.
Even more interestingly, $\ce{NO2}$ reacts with itself at low temperatures or high pressures and dimerizes to form [dinitrogen tetroxide](http://en.wikipedia.org/wiki/Dinitrogen_tetroxide), $\ce{N2O4}$, a colourless solid/liquid/gas (depending on conditions). In other words, the two substances are in a reversible equilibrium:
$$\ce{2 NO2 (g) <=> N2O4 (g) + energy}$$
Coincidentally, this equilibrium is characterized by an equilibrium constant which is close to 1 at ambient conditions, and this constant can easily be changed by varying temperature or pressure to higher or lower values. This means that under relatively easily achieved conditions, it is possible to study the reversible change of a coloured gas into a colourless one!

([Source](http://catalog.flatworldknowledge.com/bookhub/4309?e=averill_1.0-ch15_s01))
Though I focused on $\ce{NO2}$ because it is a remarkable case, there are several other examples of clear but coloured gasses. As Geoff mentioned, the halogens all form coloured gasses, though bromine is a volatile liquid and iodine is a solid at room temperature, so a small amount of heating is necessary. Ozone, $\ce{O3}$, is [somewhat blue](https://i.stack.imgur.com/CfI3i.jpg) ([source](http://www.masterorganicchemistry.com/2011/09/16/reagent-friday-ozone-o3/)), though its colour is best observed in the liquid phase. The same goes for oxygen gas, $\ce{O2}$, which is slightly blue, though it is not [the cause for the blue sky](http://en.wikipedia.org/wiki/Rayleigh_scattering#Reason_for_the_blue_color_of_the_sky). There are probably a few more examples out there.
|
The answer to your question is yes, there are non-transparent gases, however, it depends upon the wavelength at which you are observing and how much gas you are looking through. At some wavelengths the gas is opaque at others transparent. The amount of light absorbed depends on its concentration, the path-length through which the light passes, and how strongly a molecule absorbs the light. It is quite easy to have conditions that absorbs 99.9% of all light at a given wavelength.
If you are observing in the infra red then simple gases such as oxygen or nitrogen have no transitions which absorb photons as they have no dipole which can 'capture' (in a vibrational transition or rotational) the energy of a photon. (Technically weak transitions can occur by other perturbations but for the present discussion we ignore these details).
Oxygen has low lying electronic transitions, which is when an electron is promoted from the ground state to an excited state, but these are in the near infra red and cannot be observed by eye. NO$\_2$ also has visible electronic transitions as it is brown and so do the halogen gases and vapours. Mercury vapour also absorbs in the visible and this can be seen as shadows of vapour from the liquid when illuminated by light also from a mercury lamp. The transition is so intense that the vapour becomes opaque.
At shorter wavelengths such as the ultraviolet, oxygen, nitrogen and water vapour and most all other vapours and gases become opaque at relatively low pressures and path-lengths. i.e. if our eyes were sensitive to uv light only the air would look black.
At very short wavelengths, x-rays are absorbed by a molecules atoms (not by the molecule itself) but they are also elastically scattered (no energy imparted to atom as in diffraction) or inelastically scattered (some energy imparted).
|
6,285,137 |
If you have a server that you made in C running and then connect to it as a client with a web browser, how would you display an HTML page to the client?
I tried just writing html code to the client, but it didn't work, the page is blank.
|
2011/06/08
|
[
"https://Stackoverflow.com/questions/6285137",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/789882/"
] |
Sleepycat was acquired by Oracle in 2006. The product continues to be available under the original open source license and continues to be enhanced. You can find the source code on [Oracle's web site](http://www.oracle.com/technetwork/database/berkeleydb/downloads/index.html) here in both .zip and .tar formats. The distribution includes the full source code.
Just FYI: Oracle has many open source products. Source code is freely available for all of them.
Disclaimer: I'm the Product Manager for Berkeley DB and have been working with the product for over 7 years, so I'm a little biased. :-)
|
You can find the source code on [Launchpad](https://launchpad.net/berkeley-db).
|
6,285,137 |
If you have a server that you made in C running and then connect to it as a client with a web browser, how would you display an HTML page to the client?
I tried just writing html code to the client, but it didn't work, the page is blank.
|
2011/06/08
|
[
"https://Stackoverflow.com/questions/6285137",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/789882/"
] |
You can find the source code on [Launchpad](https://launchpad.net/berkeley-db).
|
It is not currently possible to download the source without creating an account.
|
6,285,137 |
If you have a server that you made in C running and then connect to it as a client with a web browser, how would you display an HTML page to the client?
I tried just writing html code to the client, but it didn't work, the page is blank.
|
2011/06/08
|
[
"https://Stackoverflow.com/questions/6285137",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/789882/"
] |
Sleepycat was acquired by Oracle in 2006. The product continues to be available under the original open source license and continues to be enhanced. You can find the source code on [Oracle's web site](http://www.oracle.com/technetwork/database/berkeleydb/downloads/index.html) here in both .zip and .tar formats. The distribution includes the full source code.
Just FYI: Oracle has many open source products. Source code is freely available for all of them.
Disclaimer: I'm the Product Manager for Berkeley DB and have been working with the product for over 7 years, so I'm a little biased. :-)
|
It is not currently possible to download the source without creating an account.
|
27,434,873 |
How do I update all rows with calculated data derived from the values in two other columns of the same record?
Here's the situation:
I have a table called `customers`. It had 4 columns - `Customer_ID`, `Customer_Name`, `Coordinate_X` and `Coordinate_Y`'. Since creating and filling the table with data I have added an empty 5th column called `Distance`
What I'd like to do is fill the `Distance` column with the calculated distances from (0,0) to the locations specified in the `Coordinate_X` and `Coordinate_Y` columns of each row. I figured I could use Pythagoras's theory - and the correct values come up when I use the query:
```
Select SQRT(Power(customers.coordinate_x,2) + Power(customers.coordinate_y,2)) from customers
```
I fiddled about trying to make a trigger - failed that through lack of experience.
Then I tried to fill the column using queries - failed that too.
I've been trying things like this;
```
update customers set distance = (Select SQRT(Power(customers.coordinate_x,2) + Power(customers.coordinate_y,2)) from customers)
```
Nothing's working - the best I'm getting is `ORA-01427: single-row subquery returns more than one row`
|
2014/12/12
|
[
"https://Stackoverflow.com/questions/27434873",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4352168/"
] |
The query is simpler than what you are doing:
```
update customers
set distance = SQRT(Power(coordinate_x, 2) + Power(coordinate_y, 2))
```
|
Gordon's answer is correct. However, for this particular example, it's better to use a virtual column and you won't have to update the distance after changing a customer's coordinates:
```
create table customers (
customer_id number,
customer_name varchar(255),
coordinate_x number,
coordinate_y number,
distance number generated always as (SQRT(Power(coordinate_x, 2) + Power(coordinate_y, 2))) VIRTUAL
```
);
See this sqlfiddle: <http://sqlfiddle.com/#!4/c6db3/4>
|
28,725,159 |
I'm creating a book archival program, and one of the data members says if the book is read or not. However I can't get the program to write "Yes" to the screen, so I'm guessing it is never changed, even though I say 'Y' when asked if I have read the book. Can anyone see what I have done wrong?
```
cout << "\n\tEnter title of book: ";
cin >> title;
cout << "\tEnter author of book: ";
cin >> author;
cout << "\tEnter genre of book (1. Crime, 2. Sports, 3. Science, 4. Drama): ";
cin >> choice;
switch(choice)
{
case 1: genre = crime; break;
case 2: genre = sports; break;
case 3: genre = science; break;
case 4: genre = drama; break;
}
cout << "\tEnter year of publication: ";
cin >> yearPublished;
cout << "\tHave you read the book? (Y/N): ";
cin >> ch;
if(toupper(ch) == 'Y')
{
haveRead == true;
}
else
{
haveRead == false;
}
```
|
2015/02/25
|
[
"https://Stackoverflow.com/questions/28725159",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4202447/"
] |
```
haveRead == true
```
Is a comparison, not an assignment. Remove one = from both clauses
```
if(toupper(ch) == 'Y')
haveRead = true;
else
haveRead = false;
```
|
The operator `==` is a comparison operator, used to compare things. Here you just want to assign, so you need the assignment operator that is `=`.
|
48,308,080 |
Im trying to create a small JavaScript timer in which a user has a limited amount of time to answer a question, and if the user does not answer in time, they will be directed back to the main page. All I get back from my code in terms of the timer is literally " [ ] ".
My code:
```
<DOCTYPE! html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="style_q1.css">
<script type="text/javascript">
var time="60";
var min="0";
var sec="0";
function startTimer() {
min=parseInt(timer/60);
sec=parseInt(timer%60);
if(timer<1){
window.location="index.html";
}
document.getElementById("time").innerHTML = "<b> Time Left: </b>"+min.toString()+":"+sec.toString();
timer--;
setTimeout(function(){
startTimer();
}, 1000) ;
}
</script>
</head>
<body onload="startTimer();">
<div id="top">
</div>
<div id="logo">
<h1 style="color:white;"> Question 1 - Geography </h1>
</div>
<div id="game_area">
<center> <h2> What is the capital of Ireland? </h2> </center>
</div>
<div id="time">
<center> <b>[<span id="time" ></span></b>]</center>
</div>
</body>
</html>
```
|
2018/01/17
|
[
"https://Stackoverflow.com/questions/48308080",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6849240/"
] |
Just use [`setInterval()`](https://www.w3schools.com/jsref/met_win_setinterval.asp), it's pretty much designed for this:
**UPDATE:** Remember to stop the setinterval process when the time is up.
Use this method [`clearInterval()`](https://www.w3schools.com/jsref/met_win_clearinterval.asp) to stop the process.
```js
var secondsLeft = 60;
function startTimer() {
var min=parseInt(secondsLeft/60);
var sec=parseInt(secondsLeft%60);
if(secondsLeft<1){
alert('timer expired');
//window.location="index.html";
}
document.getElementById("time").innerHTML = "<b> Time Left: </b>"+min.toString()+":"+sec.toString();
secondsLeft--;
}
setInterval(startTimer, 1000);
```
```html
<DOCTYPE! html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="style_q1.css">
</head>
<body onload="startTimer();">
<div id="top">
</div>
<div id="logo">
<h1 style="color:white;"> Question 1 - Geography </h1>
</div>
<div id="game_area">
<center> <h2> What is the capital of Ireland? </h2> </center>
</div>
<div id="time">
<center> <b>[<span id="time" ></span></b>]</center>
</div>
</body>
</html>
```
|
spelling mistake
>
> rename time to timer
>
>
>
```
<html>
<head>
<link rel="stylesheet" type="text/css" href="style_q1.css">
<script type="text/javascript">
var timer="60";
var min="0";
var sec="0";
function startTimer() {
min=parseInt(timer/60);
sec=parseInt(timer%60);
if(timer<1){
window.location="index.html";
}
document.getElementById("time").innerHTML = "<b> Time Left: </b>"+min.toString()+":"+sec.toString();
timer--;
setTimeout(function(){
startTimer();
}, 1000) ;
}
</script>
</head>
<body onload="startTimer();">
<div id="top">
</div>
<div id="logo">
<h1 style="color:white;"> Question 1 - Geography </h1>
</div>
<div id="game_area">
<center> <h2> What is the capital of Ireland? </h2> </center>
</div>
<body onload="startTimer();">
<div id="time">
<center> <b>[<span id="time" ></span></b>]</center>
</div>
</body>
</html>
```
|
48,308,080 |
Im trying to create a small JavaScript timer in which a user has a limited amount of time to answer a question, and if the user does not answer in time, they will be directed back to the main page. All I get back from my code in terms of the timer is literally " [ ] ".
My code:
```
<DOCTYPE! html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="style_q1.css">
<script type="text/javascript">
var time="60";
var min="0";
var sec="0";
function startTimer() {
min=parseInt(timer/60);
sec=parseInt(timer%60);
if(timer<1){
window.location="index.html";
}
document.getElementById("time").innerHTML = "<b> Time Left: </b>"+min.toString()+":"+sec.toString();
timer--;
setTimeout(function(){
startTimer();
}, 1000) ;
}
</script>
</head>
<body onload="startTimer();">
<div id="top">
</div>
<div id="logo">
<h1 style="color:white;"> Question 1 - Geography </h1>
</div>
<div id="game_area">
<center> <h2> What is the capital of Ireland? </h2> </center>
</div>
<div id="time">
<center> <b>[<span id="time" ></span></b>]</center>
</div>
</body>
</html>
```
|
2018/01/17
|
[
"https://Stackoverflow.com/questions/48308080",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6849240/"
] |
Just use [`setInterval()`](https://www.w3schools.com/jsref/met_win_setinterval.asp), it's pretty much designed for this:
**UPDATE:** Remember to stop the setinterval process when the time is up.
Use this method [`clearInterval()`](https://www.w3schools.com/jsref/met_win_clearinterval.asp) to stop the process.
```js
var secondsLeft = 60;
function startTimer() {
var min=parseInt(secondsLeft/60);
var sec=parseInt(secondsLeft%60);
if(secondsLeft<1){
alert('timer expired');
//window.location="index.html";
}
document.getElementById("time").innerHTML = "<b> Time Left: </b>"+min.toString()+":"+sec.toString();
secondsLeft--;
}
setInterval(startTimer, 1000);
```
```html
<DOCTYPE! html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="style_q1.css">
</head>
<body onload="startTimer();">
<div id="top">
</div>
<div id="logo">
<h1 style="color:white;"> Question 1 - Geography </h1>
</div>
<div id="game_area">
<center> <h2> What is the capital of Ireland? </h2> </center>
</div>
<div id="time">
<center> <b>[<span id="time" ></span></b>]</center>
</div>
</body>
</html>
```
|
* Your code has an error with the variable `time`
* You can use setInterval to accomplish your scenario.
* Remember to stop the setinterval process when the time is up.
```js
var timer = 10;
var min = 0;
var sec = 0;
var refreshIntervalId;
function startTimer() {
min=parseInt(timer / 60);
sec=parseInt(timer % 60);
if (timer < 1) {
//window.location="index.html";
console.log("Time is up!");
clearInterval(refreshIntervalId);
return;
}
document.getElementById("time").innerHTML = "<b> Time Left: </b>" + min + ":" + sec;
timer--;
}
var refreshIntervalId = setInterval(startTimer, 1000);
```
```html
<div id="top">
</div>
<div id="logo">
<h1 style="color:white;"> Question 1 - Geography </h1>
</div>
<div id="game_area">
<center> <h2> What is the capital of Ireland? </h2> </center>
</div>
<div id="time">
<center> <b>[<span id="time" ></span></b>]</center>
</div>
```
**Hope it helps!**
|
48,308,080 |
Im trying to create a small JavaScript timer in which a user has a limited amount of time to answer a question, and if the user does not answer in time, they will be directed back to the main page. All I get back from my code in terms of the timer is literally " [ ] ".
My code:
```
<DOCTYPE! html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="style_q1.css">
<script type="text/javascript">
var time="60";
var min="0";
var sec="0";
function startTimer() {
min=parseInt(timer/60);
sec=parseInt(timer%60);
if(timer<1){
window.location="index.html";
}
document.getElementById("time").innerHTML = "<b> Time Left: </b>"+min.toString()+":"+sec.toString();
timer--;
setTimeout(function(){
startTimer();
}, 1000) ;
}
</script>
</head>
<body onload="startTimer();">
<div id="top">
</div>
<div id="logo">
<h1 style="color:white;"> Question 1 - Geography </h1>
</div>
<div id="game_area">
<center> <h2> What is the capital of Ireland? </h2> </center>
</div>
<div id="time">
<center> <b>[<span id="time" ></span></b>]</center>
</div>
</body>
</html>
```
|
2018/01/17
|
[
"https://Stackoverflow.com/questions/48308080",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6849240/"
] |
A few things to note:
* `<!DOCTYPE>` instead of `<DOCTYPE!>`
* id attributes should be unique, you have two declared
* `<center>` is deprecated. Find a solution using CSS.
* Rather than adding an `onload` attribute to your `<body>` I would suggest adding an `DOMContentLoaded` event listener to your document.
```
<link rel="stylesheet" type="text/css" href="style_q1.css">
<script type="text/javascript">
function startTimer() {
min = parseInt(timer / 60);
sec = parseInt(timer % 60);
if (timer < 1) {
window.location = "index.html";
}
document.getElementById("time").innerHTML = "<b> Time Left: </b>" + min.toString() + ":" + sec.toString();
timer--;
setTimeout(function () {
startTimer();
}, 1000);
}
var timer = 60,
min = 0,
sec = 0;
document.addEventListener('DOMContentLoaded', function () {
startTimer();
});
</script>
```
Question 1 - Geography
What is the capital of Ireland?
--------------------------------
**[**]
|
spelling mistake
>
> rename time to timer
>
>
>
```
<html>
<head>
<link rel="stylesheet" type="text/css" href="style_q1.css">
<script type="text/javascript">
var timer="60";
var min="0";
var sec="0";
function startTimer() {
min=parseInt(timer/60);
sec=parseInt(timer%60);
if(timer<1){
window.location="index.html";
}
document.getElementById("time").innerHTML = "<b> Time Left: </b>"+min.toString()+":"+sec.toString();
timer--;
setTimeout(function(){
startTimer();
}, 1000) ;
}
</script>
</head>
<body onload="startTimer();">
<div id="top">
</div>
<div id="logo">
<h1 style="color:white;"> Question 1 - Geography </h1>
</div>
<div id="game_area">
<center> <h2> What is the capital of Ireland? </h2> </center>
</div>
<body onload="startTimer();">
<div id="time">
<center> <b>[<span id="time" ></span></b>]</center>
</div>
</body>
</html>
```
|
48,308,080 |
Im trying to create a small JavaScript timer in which a user has a limited amount of time to answer a question, and if the user does not answer in time, they will be directed back to the main page. All I get back from my code in terms of the timer is literally " [ ] ".
My code:
```
<DOCTYPE! html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="style_q1.css">
<script type="text/javascript">
var time="60";
var min="0";
var sec="0";
function startTimer() {
min=parseInt(timer/60);
sec=parseInt(timer%60);
if(timer<1){
window.location="index.html";
}
document.getElementById("time").innerHTML = "<b> Time Left: </b>"+min.toString()+":"+sec.toString();
timer--;
setTimeout(function(){
startTimer();
}, 1000) ;
}
</script>
</head>
<body onload="startTimer();">
<div id="top">
</div>
<div id="logo">
<h1 style="color:white;"> Question 1 - Geography </h1>
</div>
<div id="game_area">
<center> <h2> What is the capital of Ireland? </h2> </center>
</div>
<div id="time">
<center> <b>[<span id="time" ></span></b>]</center>
</div>
</body>
</html>
```
|
2018/01/17
|
[
"https://Stackoverflow.com/questions/48308080",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6849240/"
] |
A few things to note:
* `<!DOCTYPE>` instead of `<DOCTYPE!>`
* id attributes should be unique, you have two declared
* `<center>` is deprecated. Find a solution using CSS.
* Rather than adding an `onload` attribute to your `<body>` I would suggest adding an `DOMContentLoaded` event listener to your document.
```
<link rel="stylesheet" type="text/css" href="style_q1.css">
<script type="text/javascript">
function startTimer() {
min = parseInt(timer / 60);
sec = parseInt(timer % 60);
if (timer < 1) {
window.location = "index.html";
}
document.getElementById("time").innerHTML = "<b> Time Left: </b>" + min.toString() + ":" + sec.toString();
timer--;
setTimeout(function () {
startTimer();
}, 1000);
}
var timer = 60,
min = 0,
sec = 0;
document.addEventListener('DOMContentLoaded', function () {
startTimer();
});
</script>
```
Question 1 - Geography
What is the capital of Ireland?
--------------------------------
**[**]
|
* Your code has an error with the variable `time`
* You can use setInterval to accomplish your scenario.
* Remember to stop the setinterval process when the time is up.
```js
var timer = 10;
var min = 0;
var sec = 0;
var refreshIntervalId;
function startTimer() {
min=parseInt(timer / 60);
sec=parseInt(timer % 60);
if (timer < 1) {
//window.location="index.html";
console.log("Time is up!");
clearInterval(refreshIntervalId);
return;
}
document.getElementById("time").innerHTML = "<b> Time Left: </b>" + min + ":" + sec;
timer--;
}
var refreshIntervalId = setInterval(startTimer, 1000);
```
```html
<div id="top">
</div>
<div id="logo">
<h1 style="color:white;"> Question 1 - Geography </h1>
</div>
<div id="game_area">
<center> <h2> What is the capital of Ireland? </h2> </center>
</div>
<div id="time">
<center> <b>[<span id="time" ></span></b>]</center>
</div>
```
**Hope it helps!**
|
19,592,096 |
I have the following MySQL query:
```
SELECT t.date_time, COUNT(t.submission_id) AS click_count, s.title, s.first_name, s.family_name, s.email, ut.ukip_name, a.advertiser_name
FROM recards.tracking t
INNER JOIN submissions s ON t.submission_id = s.submission_id
INNER JOIN form_settings fs ON t.form_id = fs.form_id
INNER JOIN advertisers a ON t.advertiser_id = a.advertiser_id
INNER JOIN db2829.ukip_titles ut ON fs.ukip_title_id = ut.ukip_title_id
WHERE t.advertiser_id = 621
GROUP BY t.submission_id
ORDER BY t.date_time DESC
```
However, of course, as the `ORDER BY` is done after the `GROUP BY`, I only get the first record, where as I need the last. Investigating, I read about using `MAX()` on the column during the `SELECT`, but that does not work with `datetime` types.
Is there another work around? Maybe embedding `SELECTs` within `SELECTs`? What I have above is about as far as my `MySQL` knowledge goes, unfortunately!
|
2013/10/25
|
[
"https://Stackoverflow.com/questions/19592096",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1894453/"
] |
Turns out I was just forgetting the `AS` after the `MAX()`, with `MAX(t.date_time) AS top_time` it works fine.
My full query working:
```
SELECT MAX(t.date_time) AS top_time, COUNT(t.submission_id) AS click_count, s.title, s.first_name, s.family_name, s.email, ut.ukip_name, a.advertiser_name
FROM recards.tracking t
INNER JOIN submissions s ON t.submission_id = s.submission_id
INNER JOIN form_settings fs ON t.form_id = fs.form_id
INNER JOIN advertisers a ON t.advertiser_id = a.advertiser_id
INNER JOIN db2829.ukip_titles ut ON fs.ukip_title_id = ut.ukip_title_id
WHERE t.advertiser_id = 621
GROUP BY t.submission_id
ORDER BY top_time DESC
```
|
You are just grouping by t.submission\_id and nothing else, so this query will not work. The other attributes need to be added to the `GROUP BY` or need to be eliminated from the `SELECT`.
As far as ordering add `MAX(t.date_time)` or `MIN(t.date_time)` to your `SELECT` and then `ORDER BY` that result either ascending or descending.
|
53,164 |
Hi,
I have a couple of open source PHP libraries on Google Code. Someone who uses one of them recently suggested I create a forum for users to post questions/answers (or at the very least, allow me to post my answers somewhere public so other people can learn from them). This is something Google Code doesn't offer.
Given that these are very small libraries (in terms of user base) creating a whole forum for them seems like overkill. As Stack Overflow works so well, and is already full of people who might be able to answer questions before I can, is it OK to direct people here to post their questions, with a specific tag that I can monitor?
I only ask because although many of the questions are about broad subjects such as XPath etc., some are very specific to code I've written, which only I could answer (probably), and I don't want to hijack Stack Overflow for my own private Q&A site. There's also the bit in the FAQ that says "software tools *commonly* used by programmers" which my code obviously isn't.
Be great to know what the opinion on this is. Cheers,
Jack
|
2010/06/10
|
[
"https://meta.stackexchange.com/questions/53164",
"https://meta.stackexchange.com",
"https://meta.stackexchange.com/users/134642/"
] |
I believe it's becoming reasonably common to use Stack Overflow for "how do I do X" questions, but *also* to have a mailing list for forum for more detailed questions, discussions, feature requests etc. Basically consider whether a topic could be answered reasonably by other users of your libraries, or whether it's really aimed at you personally.
While Google Code doesn't provide forums as such, it's dead easy to set up a Google Group - that's what I've done for Noda Time, for example. I think that would definitely be worth doing whether you also use Stack Overflow or not.
|
Which libraries? You should link to them here so we can take a look. (I looked in your profile hoping to find them. FYI, you should put links to your work in there.)
I think as long as you have your users tag the questions appropriately with the name of the tool and language, it should be fine. One thing you should warn people **not** to do is address their questions directly to *you*. (I give this warning because we've had people do that before.) Just let them know that you'll monitor the tag for your tool. Also encourage them to do the same and answer any questions that they can.
|
53,164 |
Hi,
I have a couple of open source PHP libraries on Google Code. Someone who uses one of them recently suggested I create a forum for users to post questions/answers (or at the very least, allow me to post my answers somewhere public so other people can learn from them). This is something Google Code doesn't offer.
Given that these are very small libraries (in terms of user base) creating a whole forum for them seems like overkill. As Stack Overflow works so well, and is already full of people who might be able to answer questions before I can, is it OK to direct people here to post their questions, with a specific tag that I can monitor?
I only ask because although many of the questions are about broad subjects such as XPath etc., some are very specific to code I've written, which only I could answer (probably), and I don't want to hijack Stack Overflow for my own private Q&A site. There's also the bit in the FAQ that says "software tools *commonly* used by programmers" which my code obviously isn't.
Be great to know what the opinion on this is. Cheers,
Jack
|
2010/06/10
|
[
"https://meta.stackexchange.com/questions/53164",
"https://meta.stackexchange.com",
"https://meta.stackexchange.com/users/134642/"
] |
I believe it's becoming reasonably common to use Stack Overflow for "how do I do X" questions, but *also* to have a mailing list for forum for more detailed questions, discussions, feature requests etc. Basically consider whether a topic could be answered reasonably by other users of your libraries, or whether it's really aimed at you personally.
While Google Code doesn't provide forums as such, it's dead easy to set up a Google Group - that's what I've done for Noda Time, for example. I think that would definitely be worth doing whether you also use Stack Overflow or not.
|
>
> I only ask because although many of the questions are about broad subjects such as XPath etc., some are very specific to code I've written, which only I could answer (probably), and I don't want to hijack Stack Overflow for my own private Q&A site. There's also the bit in the FAQ that says "software tools commonly used by programmers" which my code obviously isn't.
>
>
>
For these reasons, I'd vote *no*, unless you can make a reasonable case that your tool is not "too localized".
|
53,164 |
Hi,
I have a couple of open source PHP libraries on Google Code. Someone who uses one of them recently suggested I create a forum for users to post questions/answers (or at the very least, allow me to post my answers somewhere public so other people can learn from them). This is something Google Code doesn't offer.
Given that these are very small libraries (in terms of user base) creating a whole forum for them seems like overkill. As Stack Overflow works so well, and is already full of people who might be able to answer questions before I can, is it OK to direct people here to post their questions, with a specific tag that I can monitor?
I only ask because although many of the questions are about broad subjects such as XPath etc., some are very specific to code I've written, which only I could answer (probably), and I don't want to hijack Stack Overflow for my own private Q&A site. There's also the bit in the FAQ that says "software tools *commonly* used by programmers" which my code obviously isn't.
Be great to know what the opinion on this is. Cheers,
Jack
|
2010/06/10
|
[
"https://meta.stackexchange.com/questions/53164",
"https://meta.stackexchange.com",
"https://meta.stackexchange.com/users/134642/"
] |
Which libraries? You should link to them here so we can take a look. (I looked in your profile hoping to find them. FYI, you should put links to your work in there.)
I think as long as you have your users tag the questions appropriately with the name of the tool and language, it should be fine. One thing you should warn people **not** to do is address their questions directly to *you*. (I give this warning because we've had people do that before.) Just let them know that you'll monitor the tag for your tool. Also encourage them to do the same and answer any questions that they can.
|
>
> I only ask because although many of the questions are about broad subjects such as XPath etc., some are very specific to code I've written, which only I could answer (probably), and I don't want to hijack Stack Overflow for my own private Q&A site. There's also the bit in the FAQ that says "software tools commonly used by programmers" which my code obviously isn't.
>
>
>
For these reasons, I'd vote *no*, unless you can make a reasonable case that your tool is not "too localized".
|
63,521,299 |
I'm working on a React component that uses drag and drop to upload a file based on this tutorial: <https://blog.logrocket.com/create-a-drag-and-drop-component-with-react-dropzone/>
and I am not too familiar with React Hooks component types.
In my customization, I want to hide the drag and drop container once the file is dropped in the area and display just the file container.
The state I've created for this is `const [isDropped, setIsDropped] = useState(false);`
This is the function which displays the file once it is dropped in:
```
const fileDrop = (e) => {
e.preventDefault();
const files = e.dataTransfer.files;
if (files.length) {
handleFiles(files);
}
};
```
Finally, this is an abbreviated version of what I am trying to accomplish:
### Drop.js
```
{!isDropped ? (
<div
className="drop_container"
onDragOver={dragOver}
onDragEnter={dragEnter}
onDragLeave={dragLeave}
onDrop={fileDrop}
// Alternate onDrop ~~~> onDrop={() => setIsDropped(!isDropped)}
onClick={fileInputClicked}
>
<p className="drop_message">
<input
ref={fileInputRef}
className="file-input"
type="file"
multiple
onChange={filesSelected}
/>
Drop your file (format pdf max 20MB)
</p>
) : (
<div className="file-display-container">
<div className="file-type">{fileType(data.name)}</div>
</div>
)}
```
My idea was in `onDrop` to set the state `onDrop={() => setIsDropped(!isDropped)}`, however onClick is already being used by the fileUpload function.
My question is how can I combine the function into my state or how would I add the state to the current onClick event?
|
2020/08/21
|
[
"https://Stackoverflow.com/questions/63521299",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1391595/"
] |
* Check if the output you're getting from *from\_usd\_to\_eur(usd)* isn't
too long to be displayed. Also try with "//" instead of "/". The
first one giving you an int instead of a float.
* You misspelled "usd" as "usr" when you called the command, maybe
that's the reason.
|
Thanks guys, your answer will be my next step to study. At the moment the small program work. I run for a second time and now /usd (thanks @nordmanden) work correctly
|
49,927,053 |
I'm trying to get value="3474636382675" from:
`<input class="lst" value="3474636382675" title="Zoeken" autocomplete="off" id="sbhost" maxlength="2048" name="q" type="text"`>
I've tried
```
response.css(".lst >value").extract()
```
This one works but i'm getting everything back and i just need the value.
```
response.css(".lst").extract()
```
|
2018/04/19
|
[
"https://Stackoverflow.com/questions/49927053",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9595180/"
] |
With CSS you select the attribute you want like this:
```
response.css(".lst::attr(value)").extract()
```
You can read more about the selectors in Scrapy’s [documentation](https://doc.scrapy.org/en/latest/topics/selectors.html)
|
I use beautiful soup to parse html. Here's an example that grabs stock prices from yahoo finance.
```
import urllib.request
from bs4 import BeautifulSoup
def getPrice(tag):
source = "https://finance.yahoo.com/quote/"+tag
filehandle = urllib.request.urlopen(source)
soup = BeautifulSoup(filehandle.read(), "html.parser")
priceSpan = soup.findAll("span", { "class" : "Fz(36px)" })
for k in priceSpan:
return(k.getText())
def getDayChange(tag):
source = "https://finance.yahoo.com/quote/"+tag
filehandle = urllib.request.urlopen(source)
soup = BeautifulSoup(filehandle.read(), "html.parser")
priceSpan = soup.findAll("span", { "class" : "Fw(500)" })
for k in priceSpan:
return(k.getText())
```
<https://gist.github.com/Krewn/0e624d35c396df63262dd42d74f2beb6>
|
49,927,053 |
I'm trying to get value="3474636382675" from:
`<input class="lst" value="3474636382675" title="Zoeken" autocomplete="off" id="sbhost" maxlength="2048" name="q" type="text"`>
I've tried
```
response.css(".lst >value").extract()
```
This one works but i'm getting everything back and i just need the value.
```
response.css(".lst").extract()
```
|
2018/04/19
|
[
"https://Stackoverflow.com/questions/49927053",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9595180/"
] |
With CSS you select the attribute you want like this:
```
response.css(".lst::attr(value)").extract()
```
You can read more about the selectors in Scrapy’s [documentation](https://doc.scrapy.org/en/latest/topics/selectors.html)
|
Not quite sure about css. But [here is one](https://stackoverflow.com/questions/21181628/python-scrapy-get-href-using-css-selector) from another SO answer. Alternatively try xpath:
```
response.xpath('//input[@class="lst"]/@value').extract()
```
or if you need only one value:
```
response.xpath('//input[@class="lst"]/@value').extract_first()
```
|
1,592,442 |
I Have a text file that is like the following:
[group1]
value1
value2
value3
[group2]
value1
value2
[group3]
value3
value 4
etc
What I want to be able to do, is load the values into an array (or list?) based on a passed in group value. eg. If i pass in "group2", then it would return a list of "value1" and "value2".
Also these values don't change that often (maybe every 6 months or so), so is there a better way to store them instead of a plain old text file so that it makes it faster to load etc?
Thanks for your help.
Leddo
|
2009/10/20
|
[
"https://Stackoverflow.com/questions/1592442",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/192829/"
] |
This is a home work question?
Use the StreamReader class to read the file (you will need to probably use .EndOfStream and ReadLine()) and use the String class for the string manipulation (probably .StartsWith(), .Substring() and .Split().
As for the better way to store them "IT DEPENDS". How many groups will you have, how many values will there be, how often is the data accessed, etc. It's possible that the original wording of the question will give us a better clue about what they were after hear.
**Addition:**
So, assuming this program/service is up and running all day, and that the file isn't very large, then you probably want to read the file just once into a Dictionary(of String, List(of String)). The ContainsKey method of this will determine if a group exists.
```
Function GetValueSet(ByVal filename As String) As Dictionary(Of String, List(Of String))
Dim valueSet = New Dictionary(Of String, List(Of String))()
Dim lines = System.IO.File.ReadAllLines(filename)
Dim header As String
Dim values As List(Of String) = Nothing
For Each line As String In lines
If line.StartsWith("[") Then
If Not values Is Nothing Then
valueSet.add(header, values)
End If
header = GetHeader(line)
values = New List(Of String)()
ElseIf Not values Is Nothing Then
Dim value As String = line.Trim()
If value <> "" Then
values.Add(value)
End If
End If
Next
If Not values Is Nothing Then
valueSet.add(header, values)
End If
Return valueSet
End Function
Function GetHeader(ByVal line As String)
Dim index As Integer = line.IndexOf("]")
Return line.Substring(1, index - 1)
End Function
```
**Addition:**
Now if your running a multi-threaded solution (that includes all ASP.Net solutions) then you either want to make sure you do this at the application start up (for ASP.Net that's in Global.asax, I think it's ApplicationStart or OnStart or something), or you will need locking. WinForms and Services are by default not multi-threaded.
Also, if the file changes you need to restart the app/service/web-site or you will need to add a file watcher to reload the data (and then multi-threading will need locking because this is not longer confined to application startup).
|
ok, here is what I edned up coding:
```
Public Function FillFromFile(ByVal vFileName As String, ByVal vGroupName As String) As List(Of String)
' open the file
' read the entire file into memory
' find the starting group name
Dim blnFoundHeading As Boolean = False
Dim lstValues As New List(Of String)
Dim lines() As String = IO.File.ReadAllLines(vFileName)
For Each line As String In lines
If line.ToLower.Contains("[" & vGroupName.ToLower & "]") Then
' found the heading, now start loading the lines into the list until the next heading
blnFoundHeading = True
ElseIf line.Contains("[") Then
If blnFoundHeading Then
' we are at the end so exit the loop
Exit For
Else
' its another group so keep going
End If
Else
If blnFoundHeading And line.Trim.Length > 0 Then
lstValues.Add(line.Trim)
End If
End If
Next
Return lstValues
End Function
```
|
1,592,442 |
I Have a text file that is like the following:
[group1]
value1
value2
value3
[group2]
value1
value2
[group3]
value3
value 4
etc
What I want to be able to do, is load the values into an array (or list?) based on a passed in group value. eg. If i pass in "group2", then it would return a list of "value1" and "value2".
Also these values don't change that often (maybe every 6 months or so), so is there a better way to store them instead of a plain old text file so that it makes it faster to load etc?
Thanks for your help.
Leddo
|
2009/10/20
|
[
"https://Stackoverflow.com/questions/1592442",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/192829/"
] |
This is a home work question?
Use the StreamReader class to read the file (you will need to probably use .EndOfStream and ReadLine()) and use the String class for the string manipulation (probably .StartsWith(), .Substring() and .Split().
As for the better way to store them "IT DEPENDS". How many groups will you have, how many values will there be, how often is the data accessed, etc. It's possible that the original wording of the question will give us a better clue about what they were after hear.
**Addition:**
So, assuming this program/service is up and running all day, and that the file isn't very large, then you probably want to read the file just once into a Dictionary(of String, List(of String)). The ContainsKey method of this will determine if a group exists.
```
Function GetValueSet(ByVal filename As String) As Dictionary(Of String, List(Of String))
Dim valueSet = New Dictionary(Of String, List(Of String))()
Dim lines = System.IO.File.ReadAllLines(filename)
Dim header As String
Dim values As List(Of String) = Nothing
For Each line As String In lines
If line.StartsWith("[") Then
If Not values Is Nothing Then
valueSet.add(header, values)
End If
header = GetHeader(line)
values = New List(Of String)()
ElseIf Not values Is Nothing Then
Dim value As String = line.Trim()
If value <> "" Then
values.Add(value)
End If
End If
Next
If Not values Is Nothing Then
valueSet.add(header, values)
End If
Return valueSet
End Function
Function GetHeader(ByVal line As String)
Dim index As Integer = line.IndexOf("]")
Return line.Substring(1, index - 1)
End Function
```
**Addition:**
Now if your running a multi-threaded solution (that includes all ASP.Net solutions) then you either want to make sure you do this at the application start up (for ASP.Net that's in Global.asax, I think it's ApplicationStart or OnStart or something), or you will need locking. WinForms and Services are by default not multi-threaded.
Also, if the file changes you need to restart the app/service/web-site or you will need to add a file watcher to reload the data (and then multi-threading will need locking because this is not longer confined to application startup).
|
Regarding a possible better way to store the data: you might find XML useful. It is ridiculously easy to read XML data into a DataTable object.
Example:
```
Dim dtTest As New System.Data.DataTable
dtTest.ReadXml("YourFilePathNameGoesHere.xml")
```
|
1,592,442 |
I Have a text file that is like the following:
[group1]
value1
value2
value3
[group2]
value1
value2
[group3]
value3
value 4
etc
What I want to be able to do, is load the values into an array (or list?) based on a passed in group value. eg. If i pass in "group2", then it would return a list of "value1" and "value2".
Also these values don't change that often (maybe every 6 months or so), so is there a better way to store them instead of a plain old text file so that it makes it faster to load etc?
Thanks for your help.
Leddo
|
2009/10/20
|
[
"https://Stackoverflow.com/questions/1592442",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/192829/"
] |
ok, here is what I edned up coding:
```
Public Function FillFromFile(ByVal vFileName As String, ByVal vGroupName As String) As List(Of String)
' open the file
' read the entire file into memory
' find the starting group name
Dim blnFoundHeading As Boolean = False
Dim lstValues As New List(Of String)
Dim lines() As String = IO.File.ReadAllLines(vFileName)
For Each line As String In lines
If line.ToLower.Contains("[" & vGroupName.ToLower & "]") Then
' found the heading, now start loading the lines into the list until the next heading
blnFoundHeading = True
ElseIf line.Contains("[") Then
If blnFoundHeading Then
' we are at the end so exit the loop
Exit For
Else
' its another group so keep going
End If
Else
If blnFoundHeading And line.Trim.Length > 0 Then
lstValues.Add(line.Trim)
End If
End If
Next
Return lstValues
End Function
```
|
Regarding a possible better way to store the data: you might find XML useful. It is ridiculously easy to read XML data into a DataTable object.
Example:
```
Dim dtTest As New System.Data.DataTable
dtTest.ReadXml("YourFilePathNameGoesHere.xml")
```
|
2,340,604 |
```
object obj = new object[] { new object(), new object() };
```
How does this compile? It seems confusing.
Seems it should either be
```
object[] obj = new object[] { new object(), new object() };
```
or
```
object[] obj = { new object(), new object() };
```
|
2010/02/26
|
[
"https://Stackoverflow.com/questions/2340604",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35026/"
] |
object is the base for everything. *Anything* can be assigned to a variable of type object.
|
object obj = ... here may refer to a Collection. It's not said that the difference usage of 'object' here refers to the same type of object.
|
2,340,604 |
```
object obj = new object[] { new object(), new object() };
```
How does this compile? It seems confusing.
Seems it should either be
```
object[] obj = new object[] { new object(), new object() };
```
or
```
object[] obj = { new object(), new object() };
```
|
2010/02/26
|
[
"https://Stackoverflow.com/questions/2340604",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35026/"
] |
object is the base for everything. *Anything* can be assigned to a variable of type object.
|
An array of objects is an object, but this is indeed weird.
|
2,340,604 |
```
object obj = new object[] { new object(), new object() };
```
How does this compile? It seems confusing.
Seems it should either be
```
object[] obj = new object[] { new object(), new object() };
```
or
```
object[] obj = { new object(), new object() };
```
|
2010/02/26
|
[
"https://Stackoverflow.com/questions/2340604",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35026/"
] |
object is the base for everything. *Anything* can be assigned to a variable of type object.
|
In
```
object obj = new object[] { ...}
```
The right hand part does yield a reference of type `object[]` but that type, like any other type, is assignment-compatible with `object`.
|
2,340,604 |
```
object obj = new object[] { new object(), new object() };
```
How does this compile? It seems confusing.
Seems it should either be
```
object[] obj = new object[] { new object(), new object() };
```
or
```
object[] obj = { new object(), new object() };
```
|
2010/02/26
|
[
"https://Stackoverflow.com/questions/2340604",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35026/"
] |
In
```
object obj = new object[] { ...}
```
The right hand part does yield a reference of type `object[]` but that type, like any other type, is assignment-compatible with `object`.
|
object obj = ... here may refer to a Collection. It's not said that the difference usage of 'object' here refers to the same type of object.
|
2,340,604 |
```
object obj = new object[] { new object(), new object() };
```
How does this compile? It seems confusing.
Seems it should either be
```
object[] obj = new object[] { new object(), new object() };
```
or
```
object[] obj = { new object(), new object() };
```
|
2010/02/26
|
[
"https://Stackoverflow.com/questions/2340604",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35026/"
] |
It compiles because an "object" can be anything, therefore it can be a reference to an array of object. The code below using strings to make the distinction a little clearer, might help. So:
```
List<string> myStrings = new List<string>() { "aa", "bb" };
// Now we have an array of strings, albeit an empty one
string[] myStringsArray = myStrings.ToArray();
// Still a reference to myStringsArray, just held in the form of an object
object stillMyStringsArray = (object)myStringsArray;
// Get another array of strings and hold in the form of an object
string[] anotherArray = myStrings.ToArray();
object anotherArrayAsObject = (object)anotherArray;
// Store both our objects in an array of object, in the form of an object
object myStringArrays = new object[] { stillMyStringsArray, anotherArrayAsObject };
// Convert myStringArrays object back to an array of object and take the first item in the array
object myOriginalStringsArrayAsObject = ((object[])myStringArrays)[0];
// Conver that first array item back into an array of strings
string[] myOriginalStringsArray = (string[])myOriginalStringsArrayAsObject;
```
Essentially, an object can always be a reference to anything, even an array of object. Object doesn't care what is put in it, so by the very end of the code there, we've got a string array back. Run that code up in Visual Studio, drop a few breakpoints in and follow it through. It'll hopefully help you make sense of why the code you specified is valid =)
|
object obj = ... here may refer to a Collection. It's not said that the difference usage of 'object' here refers to the same type of object.
|
2,340,604 |
```
object obj = new object[] { new object(), new object() };
```
How does this compile? It seems confusing.
Seems it should either be
```
object[] obj = new object[] { new object(), new object() };
```
or
```
object[] obj = { new object(), new object() };
```
|
2010/02/26
|
[
"https://Stackoverflow.com/questions/2340604",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35026/"
] |
In
```
object obj = new object[] { ...}
```
The right hand part does yield a reference of type `object[]` but that type, like any other type, is assignment-compatible with `object`.
|
An array of objects is an object, but this is indeed weird.
|
2,340,604 |
```
object obj = new object[] { new object(), new object() };
```
How does this compile? It seems confusing.
Seems it should either be
```
object[] obj = new object[] { new object(), new object() };
```
or
```
object[] obj = { new object(), new object() };
```
|
2010/02/26
|
[
"https://Stackoverflow.com/questions/2340604",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35026/"
] |
It compiles because an "object" can be anything, therefore it can be a reference to an array of object. The code below using strings to make the distinction a little clearer, might help. So:
```
List<string> myStrings = new List<string>() { "aa", "bb" };
// Now we have an array of strings, albeit an empty one
string[] myStringsArray = myStrings.ToArray();
// Still a reference to myStringsArray, just held in the form of an object
object stillMyStringsArray = (object)myStringsArray;
// Get another array of strings and hold in the form of an object
string[] anotherArray = myStrings.ToArray();
object anotherArrayAsObject = (object)anotherArray;
// Store both our objects in an array of object, in the form of an object
object myStringArrays = new object[] { stillMyStringsArray, anotherArrayAsObject };
// Convert myStringArrays object back to an array of object and take the first item in the array
object myOriginalStringsArrayAsObject = ((object[])myStringArrays)[0];
// Conver that first array item back into an array of strings
string[] myOriginalStringsArray = (string[])myOriginalStringsArrayAsObject;
```
Essentially, an object can always be a reference to anything, even an array of object. Object doesn't care what is put in it, so by the very end of the code there, we've got a string array back. Run that code up in Visual Studio, drop a few breakpoints in and follow it through. It'll hopefully help you make sense of why the code you specified is valid =)
|
An array of objects is an object, but this is indeed weird.
|
2,340,604 |
```
object obj = new object[] { new object(), new object() };
```
How does this compile? It seems confusing.
Seems it should either be
```
object[] obj = new object[] { new object(), new object() };
```
or
```
object[] obj = { new object(), new object() };
```
|
2010/02/26
|
[
"https://Stackoverflow.com/questions/2340604",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35026/"
] |
It compiles because an "object" can be anything, therefore it can be a reference to an array of object. The code below using strings to make the distinction a little clearer, might help. So:
```
List<string> myStrings = new List<string>() { "aa", "bb" };
// Now we have an array of strings, albeit an empty one
string[] myStringsArray = myStrings.ToArray();
// Still a reference to myStringsArray, just held in the form of an object
object stillMyStringsArray = (object)myStringsArray;
// Get another array of strings and hold in the form of an object
string[] anotherArray = myStrings.ToArray();
object anotherArrayAsObject = (object)anotherArray;
// Store both our objects in an array of object, in the form of an object
object myStringArrays = new object[] { stillMyStringsArray, anotherArrayAsObject };
// Convert myStringArrays object back to an array of object and take the first item in the array
object myOriginalStringsArrayAsObject = ((object[])myStringArrays)[0];
// Conver that first array item back into an array of strings
string[] myOriginalStringsArray = (string[])myOriginalStringsArrayAsObject;
```
Essentially, an object can always be a reference to anything, even an array of object. Object doesn't care what is put in it, so by the very end of the code there, we've got a string array back. Run that code up in Visual Studio, drop a few breakpoints in and follow it through. It'll hopefully help you make sense of why the code you specified is valid =)
|
In
```
object obj = new object[] { ...}
```
The right hand part does yield a reference of type `object[]` but that type, like any other type, is assignment-compatible with `object`.
|
6,514,794 |
There are tons of online suggestions for setting MSMQ permissions programmatically using .net System.Messaging.MessageQueue SetPermissions method. But I cannot find any system.messaging property that lets me read the permissions currently configured on existing queues.
I'm trying to write a powershell audit script to take stock of dozens of machines configurations, and its almost entirely useless if I can't get the configured permissions for the queues.
I'm open to suggestions for command line options, didn't find anything mentioned in stackoverflow. Yoel's MSMQ WMI provider doesn't expose the necessary info, and as far as I can tell there is no command line provided with MSMQ that gets you this.
Can't believe this is something no one has addressed. Another enterprise product by Microsoft that's missing a fundamental security feature (verification).
Using powershell for the audit, would prefer built in or .net framework solutions, but getting the info by any means necessary (CLI) if need be.
|
2011/06/29
|
[
"https://Stackoverflow.com/questions/6514794",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/761599/"
] |
Here's a simple example handler, which needs a login.html template containing a username/password form. I don't have a sign up example, but it's quite similar, on the post you validate the input and insert the user record rather than authenticating.
```
class BaseHandler(tornado.web.RequestHandler):
def get_login_url(self):
return u"/login"
def get_current_user(self):
user_json = self.get_secure_cookie("user")
if user_json:
return tornado.escape.json_decode(user_json)
else:
return None
class LoginHandler(BaseHandler):
def get(self):
self.render("login.html", next=self.get_argument("next","/"))
def post(self):
username = self.get_argument("username", "")
password = self.get_argument("password", "")
# The authenticate method should match a username and password
# to a username and password hash in the database users table.
# Implementation left as an exercise for the reader.
auth = self.db.authenticate(username, password)
if auth:
self.set_current_user(username)
self.redirect(self.get_argument("next", u"/"))
else:
error_msg = u"?error=" + tornado.escape.url_escape("Login incorrect.")
self.redirect(u"/login" + error_msg)
def set_current_user(self, user):
if user:
self.set_secure_cookie("user", tornado.escape.json_encode(user))
else:
self.clear_cookie("user")
class LogoutHandler(BaseHandler):
def get(self):
self.clear_cookie("user")
self.redirect(u"/login)
```
|
I started using Cole's example but realised I was creating an account for accessing the database which might not be the same thing as an account for our webapp.
I've changed the above example to use bcrpyt. Now a user's connection to our webapp is different from our webapp's connection to the database. [My sample app on github](https://github.com/bootandy/tornado_sample)
Note: bcrpyt is computationally heavy and will block the IO loop
```
class BaseHandler(tornado.web.RequestHandler):
def get_login_url(self):
return u"/login"
def get_current_user(self):
user_json = self.get_secure_cookie("user")
if user_json:
return tornado.escape.json_decode(user_json)
else:
return None
class LoginHandler(BaseHandler):
def get(self):
self.render("login.html", next=self.get_argument("next","/"), message=self.get_argument("error","") )
def post(self):
email = self.get_argument("email", "")
password = self.get_argument("password", "")
user = self.application.syncdb['users'].find_one( { 'user': email } )
if user and user['password'] and bcrypt.hashpw(password, user['password']) == user['password']:
self.set_current_user(email)
self.redirect("hello")
else:
error_msg = u"?error=" + tornado.escape.url_escape("Login incorrect.")
self.redirect(u"/login" + error_msg)
def set_current_user(self, user):
print "setting "+user
if user:
self.set_secure_cookie("user", tornado.escape.json_encode(user))
else:
self.clear_cookie("user")
class RegisterHandler(LoginHandler):
def get(self):
self.render( "register.html", next=self.get_argument("next","/"))
def post(self):
email = self.get_argument("email", "")
already_taken = self.application.syncdb['users'].find_one( { 'user': email } )
if already_taken:
error_msg = u"?error=" + tornado.escape.url_escape("Login name already taken")
self.redirect(u"/login" + error_msg)
password = self.get_argument("password", "")
hashed_pass = bcrypt.hashpw(password, bcrypt.gensalt(8))
user = {}
user['user'] = email
user['password'] = hashed_pass
auth = self.application.syncdb['users'].save(user)
self.set_current_user(email)
self.redirect("hello")
```
|
5,907,070 |
```
Array
(
[0] => Array
(
[accountNo] => 208773
)
)
Array
(
[0] => Array
(
[accountNo] => 9415238
)
)
Array
(
)
```
how can i unset the last array so that it must display only first 2 array.
please help
thanks
|
2011/05/06
|
[
"https://Stackoverflow.com/questions/5907070",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/729022/"
] |
If these 3 arrays are the content of one array, let's call it `$array`:
```
array_pop($array);
```
Will remove the last one, and optionally return it's value.
>
> array\_pop — Pop the element off the end of array
>
>
>
<http://php.net/manual/function.array-pop.php>
---
This does the same thing as `unset()` here, but for curiosity's sake, here's another way:
```
// Move the pointer to the last element
end($array);
// Get the key of the element
$key = key($array);
// Unset the item
unset($array[$key]);
```
---
Just use `array_pop()` though, the other method was for entertainment purposes only, but you could use it if you want to change the last element's value.
Demo: <http://codepad.org/UFjal89X>
Some reference:
`key()`: <http://php.net/manual/function.key.php>
`end()`: <http://php.net/manual/function.end.php>
|
try this ( if i understand your problem)
```
$output =array();
foreach($input as $k=>$v){
if(!empty($v)){
$output[$k]=$v;
}
}
```
[WORKING DEMO](http://codepad.org/eIWXd8z1)
-------------------------------------------
|
67,513 |
Everytime I press `D` + `LMB` I see the pencil as cursor and the indication that I'm about to draw something, but every time I draw a line, the line disappears.
|
2016/11/18
|
[
"https://blender.stackexchange.com/questions/67513",
"https://blender.stackexchange.com",
"https://blender.stackexchange.com/users/32712/"
] |
Double check the opacity of the active layer. If it's set to zero, the created stroke won't be shown after drawing, by it will be visible when drawing
|
Be sure that `X-Ray` mode is disabled on the object you are drawing on. Having it on will make the object's geometry draw on top of any grease pencil strokes you make on it.
[](https://i.stack.imgur.com/y39T4.png)
|
67,513 |
Everytime I press `D` + `LMB` I see the pencil as cursor and the indication that I'm about to draw something, but every time I draw a line, the line disappears.
|
2016/11/18
|
[
"https://blender.stackexchange.com/questions/67513",
"https://blender.stackexchange.com",
"https://blender.stackexchange.com/users/32712/"
] |
Double check the opacity of the active layer. If it's set to zero, the created stroke won't be shown after drawing, by it will be visible when drawing
|
I met the same problem today.Maybe you pressed H accidentally. Go to the edit Mode and then try press Alt+H see if it works.
|
67,513 |
Everytime I press `D` + `LMB` I see the pencil as cursor and the indication that I'm about to draw something, but every time I draw a line, the line disappears.
|
2016/11/18
|
[
"https://blender.stackexchange.com/questions/67513",
"https://blender.stackexchange.com",
"https://blender.stackexchange.com/users/32712/"
] |
Check to make sure you don't have the [Grease Pencil layers] and [Grease Pencil Colors] set to invisible (eye icon). I spent an hour trying to figure out why, but forgot that I turned them off.
For the new players:
N to open the right hand menu.
Uncollapse the ▼ ☑Grease Pencil and ▼Grease Pencil Colors
Look to make sure the eyes are visible for both layers. Also try creating a new Grease Pencil layer and seeing if that fixes any issues.
|
I'm using a 3D mouse for zooming, so my grease pencil drawing planes are created in weird angles. As a quick fix, I set *Scale Y* to $0$.
When I then draw a stroke, it instantly shrinks to an invisible point at the drawing plane origin.
This does not happen, if I set *Scale Y* to $0.001$
[](https://i.stack.imgur.com/zfKQr.png)
Edit:
Just found a better way to fix the grease pencil drawing plane angle.
Change the option at the top of the drawing window from *View* to *Front (X-Z)*.
[](https://i.stack.imgur.com/x1KwT.png)
|
67,513 |
Everytime I press `D` + `LMB` I see the pencil as cursor and the indication that I'm about to draw something, but every time I draw a line, the line disappears.
|
2016/11/18
|
[
"https://blender.stackexchange.com/questions/67513",
"https://blender.stackexchange.com",
"https://blender.stackexchange.com/users/32712/"
] |
Check to make sure you don't have the [Grease Pencil layers] and [Grease Pencil Colors] set to invisible (eye icon). I spent an hour trying to figure out why, but forgot that I turned them off.
For the new players:
N to open the right hand menu.
Uncollapse the ▼ ☑Grease Pencil and ▼Grease Pencil Colors
Look to make sure the eyes are visible for both layers. Also try creating a new Grease Pencil layer and seeing if that fixes any issues.
|
Maybe in somehow your stroke keyframe location changed!
check the time line or the dope sheet, i found mine in 173
|
67,513 |
Everytime I press `D` + `LMB` I see the pencil as cursor and the indication that I'm about to draw something, but every time I draw a line, the line disappears.
|
2016/11/18
|
[
"https://blender.stackexchange.com/questions/67513",
"https://blender.stackexchange.com",
"https://blender.stackexchange.com/users/32712/"
] |
Check to make sure you don't have the [Grease Pencil layers] and [Grease Pencil Colors] set to invisible (eye icon). I spent an hour trying to figure out why, but forgot that I turned them off.
For the new players:
N to open the right hand menu.
Uncollapse the ▼ ☑Grease Pencil and ▼Grease Pencil Colors
Look to make sure the eyes are visible for both layers. Also try creating a new Grease Pencil layer and seeing if that fixes any issues.
|
I met the same problem today.Maybe you pressed H accidentally. Go to the edit Mode and then try press Alt+H see if it works.
|
67,513 |
Everytime I press `D` + `LMB` I see the pencil as cursor and the indication that I'm about to draw something, but every time I draw a line, the line disappears.
|
2016/11/18
|
[
"https://blender.stackexchange.com/questions/67513",
"https://blender.stackexchange.com",
"https://blender.stackexchange.com/users/32712/"
] |
Check to make sure you don't have the [Grease Pencil layers] and [Grease Pencil Colors] set to invisible (eye icon). I spent an hour trying to figure out why, but forgot that I turned them off.
For the new players:
N to open the right hand menu.
Uncollapse the ▼ ☑Grease Pencil and ▼Grease Pencil Colors
Look to make sure the eyes are visible for both layers. Also try creating a new Grease Pencil layer and seeing if that fixes any issues.
|
Double check the opacity of the active layer. If it's set to zero, the created stroke won't be shown after drawing, by it will be visible when drawing
|
67,513 |
Everytime I press `D` + `LMB` I see the pencil as cursor and the indication that I'm about to draw something, but every time I draw a line, the line disappears.
|
2016/11/18
|
[
"https://blender.stackexchange.com/questions/67513",
"https://blender.stackexchange.com",
"https://blender.stackexchange.com/users/32712/"
] |
Double check the opacity of the active layer. If it's set to zero, the created stroke won't be shown after drawing, by it will be visible when drawing
|
Check to see that you didn't accidentally go to a new frame in the dope sheet.
|
67,513 |
Everytime I press `D` + `LMB` I see the pencil as cursor and the indication that I'm about to draw something, but every time I draw a line, the line disappears.
|
2016/11/18
|
[
"https://blender.stackexchange.com/questions/67513",
"https://blender.stackexchange.com",
"https://blender.stackexchange.com/users/32712/"
] |
Double check the opacity of the active layer. If it's set to zero, the created stroke won't be shown after drawing, by it will be visible when drawing
|
I just had this problem and found that it was caused by being in *Wireframe* shading mode. I just switched from *Wireframe* to *Solid* and it works correctly.
|
67,513 |
Everytime I press `D` + `LMB` I see the pencil as cursor and the indication that I'm about to draw something, but every time I draw a line, the line disappears.
|
2016/11/18
|
[
"https://blender.stackexchange.com/questions/67513",
"https://blender.stackexchange.com",
"https://blender.stackexchange.com/users/32712/"
] |
I'm using a 3D mouse for zooming, so my grease pencil drawing planes are created in weird angles. As a quick fix, I set *Scale Y* to $0$.
When I then draw a stroke, it instantly shrinks to an invisible point at the drawing plane origin.
This does not happen, if I set *Scale Y* to $0.001$
[](https://i.stack.imgur.com/zfKQr.png)
Edit:
Just found a better way to fix the grease pencil drawing plane angle.
Change the option at the top of the drawing window from *View* to *Front (X-Z)*.
[](https://i.stack.imgur.com/x1KwT.png)
|
I am using a mac mini m1 and I had this issue while I tried upgrading to 3.2.1 from 3.1.2 but this seems to have been occuring intermittently and leaves me with no clue if I have done anything wrong.
Solution: I updated my version with 2.93.9 LTS version and this has resolved the issue for me.
Hope it helps.
|
67,513 |
Everytime I press `D` + `LMB` I see the pencil as cursor and the indication that I'm about to draw something, but every time I draw a line, the line disappears.
|
2016/11/18
|
[
"https://blender.stackexchange.com/questions/67513",
"https://blender.stackexchange.com",
"https://blender.stackexchange.com/users/32712/"
] |
I had the same issue and was that the Grease Pencil stroke was created at a specific point in the timeline, so just grab the time marker and check in which frame the strokes were created.
|
Maybe in somehow your stroke keyframe location changed!
check the time line or the dope sheet, i found mine in 173
|
1,985,367 |
Let $T$ and $L$ linear operators with vector space $V$ such that $Im(T)=Im(L)$ and $Ker(T)=Ker(L)$ show that $L = T$
Since they are linear operators
$$T:V\to V \mbox{ and } L:V\to V$$
Base is $ \{\alpha\_{1},\cdots,\alpha\_{r}\} $ of $Ker(T)$ base completed of $V$ wiht $ \{\alpha\_{r+1},\cdots,\alpha\_{n}\} $ and $ \{T\alpha\_{r+1},\cdots,T\alpha\_{n}\} $ is base of $Im(T)$ but I can not think like finding equality
|
2016/10/26
|
[
"https://math.stackexchange.com/questions/1985367",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/378669/"
] |
This is just not true as stated. Take two maps $\mathbb{R} \rightarrow \mathbb{R}$, the first being multiplication by 1 and the second being multiplication by 2. The maps have the same kernel $\{0\}$ and the same image $\mathbb{R}$ but are clearly not the same map.
|
Take an invertible linear transformation from $V$ to $V$. The kernal is $\{0\}$ and image is $V$. So if you can find two distinct inverible linear transformations you can see that your question is wrong.
One can also give examples with two non-invertible ones having same kernel and image.
Let $L$ be a non-invertible transformation with image $W$. Take a basis of $W$, extend it to a basis of $V$. Let $T$ be any permutation that pemutes this basis by sending $W$-basis vectors among itself, and the others among itself. Now $L$ and $L\circ T$ both are non-invertible with same kernel and image.
|
156,373 |
I'm writing a custom Processing script that needs to know which database connection a vector layer resides in. I can't find anywhere in the API a function to return this information from a layer. So I guess I have two questions:
1. Is there a Python function (either from qgis.core or from Processing tools) that easily returns things like the DB name, schema, etc. of a given layer?
2. If not, do I need to parse the URI of the layer? How do I get that information?
|
2015/07/30
|
[
"https://gis.stackexchange.com/questions/156373",
"https://gis.stackexchange.com",
"https://gis.stackexchange.com/users/7809/"
] |
I ended up writing a small module to extract information out of the string that source() returns:
```
import re
class LayerDbInfo:
def __init__(self, layerInfo):
if layerInfo[:6] == 'dbname':
layerInfo = layerInfo.replace('\'','"')
vals = dict(re.findall('(\S+)="?(.*?)"? ',layerInfo))
self.dbName = str(vals['dbname'])
self.key = str(vals['key'])
self.user = str(vals['user'])
self.password = str(vals['password'])
self.srid = int(vals['srid'])
self.type = str(vals['type'])
self.host = str(vals['host'])
self.port = int(vals['port'])
# need some extra processing to get table name and schema
table = vals['table'].split('.')
self.schemaName = table[0].strip('"')
self.tableName = table[1].strip('"')
else:
raise
def getDBName(self):
return self.dbName
def getHost(self):
return self.host
def getPort(self):
return self.port
def getKey(self):
return self.key
def getUser(self):
return self.user
def getPassword(self):
return self.password
def getSRID(self):
return self.srid
def getType(self):
return self.type
def getSchema(self):
return self.schemaName
def getTable(self):
return self.tableName
```
|
I think you could use the following code to obtain source information for your layer. Select a layer from the layer window and input the code into the Python Console:
```
layer = qgis.utils.iface.activeLayer()
print layer.source()
```
You should receive information about the layer.
Hope this helps!
|
32,409,449 |
I have the model that uses paperclip like this
```
has_attached_file :image, styles: { :medium => "50x50>" }
validates_attachment_content_type :image, content_type: /\Aimage\/.*\Z/
def image_url
image.url(:medium)
end
```
I need it Json, So in my controller,
```
respond_to do |format|
format.json { render json: @celebrity.to_json(:methods => [:image_url])}
end
```
And the result is
```
"image_url":"/system/celebrities/images/000/000/003/medium/Designed___developed_by_wd_ApS.png?1430926991"
```
but, I need to include the domain name, localhost:3000 ,
So what I have to do here
|
2015/09/05
|
[
"https://Stackoverflow.com/questions/32409449",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5287288/"
] |
Try this.
Create module:
```
module WithDomain
def domain
@domain
end
def domain=(val)
@domain = val
end
def domain?
@domain.present?
end
end
```
Change you model accordingly:
```
class Celebtiry < ActiveRecord::Base
include WithDomain
# existing staff
def image_url
if domain?
URI.join(domain, image.url(:medium)).to_s
else
image.url(:medium)
end
end
end
```
and in your controller:
```
respond_to do |format|
format.json {
@celebrity.domain = request.base_url
render json: @celebrity.to_json(:methods => [:image_url])
}
end
```
|
### Solution 1: (with existing code)
You can use [asset\_url](http://api.rubyonrails.org/classes/ActionView/Helpers/AssetUrlHelper.html#method-i-asset_url) from `ActionView::Helpers::AssetUrlHelper` module which will give you the absolute url of your image. Just `include ActionView::Helpers::AssetUrlHelper` this in your model so that `asset_url` becomes available inside your model.
So, your method inside the model would be:
```
include ActionView::Helpers::AssetUrlHelper
def image_url
asset_url(image.url(:medium))
end
```
**This is the easiest solution for you with your current code.**
### Solution 2: (inside the controller)
In your controller `request` is available, so you can do:
```
URI.join(request.url, @celebrity.image.url(:medium))
```
which will give you the absolute url of the `image`. This will be an `URI` object, which can be converted to a String with `.to_s` method.
Here is the [issue from paperclip](https://github.com/thoughtbot/paperclip/issues/584) from where this solution is derived. Hope this helps.
|
1,557,140 |
Let $A$ and $B$ be two sets such that $B \subset A$ and there is an injection $f \colon A \to B$. Then how to show that $A$ and $B$ have the same cardinality?
Munkres' Hint:
We define $A\_1 \colon= A$, $B\_1 \colon= B$, and, for $n > 1$, we define $A\_n \colon= f(A\_{n-1})$ and $B\_n \colon= f(B\_{n-1})$.
Thus, we have
$$B\_1 = B \subset A\_1 = A$$
and
$$A\_2 = f(A\_1) = f(A) \subset B = B\_1,$$
that is,
$$A\_2 \subset B\_1 \subset A\_1.$$
Now if, for any +ive integer $n \geq 1$, we have
$$B\_{n+1} \subset B\_n \subset A\_n, $$
then we also have
$$B\_{n+2} = f(B\_{n+1}) \subset f(B\_n) = B\_{n+1}$$
and
$$B\_{n+1} = f(B\_n) \subset f(A\_n) = A\_{n+1}, $$
that is,
$$B\_{n+2} \subset B\_{n+1} \subset A\_{n+1}.$$
Hence using induction we can conclude that
$$A\_{n+1} \subset B\_n \subset A\_n \ \mbox{ for each } \ n \in \mathbb{N}.$$
That is,
$$A\_1 \supset B\_1 \supset A\_2 \supset B\_2 \supset A\_3 \supset B\_3 \supset \ldots.$$
Now let the map $h \colon A \to B$ be defined as follows:
$$ h(x) \colon=
\begin{cases}
f(x) \ & \mbox{ if } \ x \in A\_n - B\_n \ \mbox{ for some } \ n; \\
x \ & \mbox{ otherwise}.
\end{cases}
$$
Munkres claims that this map $h$ is a bijection. How do we show this?
Injectivity of $h$:
Suppose $a, x \in A$ such that $h(a) = h(x)$. We need to show that $a=x$.
If there exist $m, n \in \mathbb{N}$ such that $a \in A\_m - B\_m$ and $x \in A\_n - B\_n$, then we must have
$$f(a) = h(a) = h(b) = f(b),$$
which implies $a = b$.
On the other hand, if $a \not\in A\_n - B\_n$ for any $n \in \mathbb{N}$ and $x \not\in A\_n - B\_n$ for any $n \in \mathbb{N}$, then we have
$$a = h(a) = h(b) = b.$$
How to show that $a = b$ in the following situation?
There exists some $m \in \mathbb{N}$ such that $a \in A\_m - B\_m$ but
$x \not\in A\_n - B\_n$ for any $n \in \mathbb{N}$.
Surjectivity of $h$:
Let $b \in B$.
Then $b \in A$.
If $b \not\in A\_n - B\_n$ for any $n \in \mathbb{N}$, then we have
$b = h(b)$.
On the other hand, if, for some $k \in \mathbb{N}$, we have $b \in A\_k - B\_k$, then let $k$ be the smallest such positive integer.
If $k = 1$, then we have $b \in A - B$, which is a contradiction as $b \in B$, by our hypothesis. So we must have $k > 1$; rather, $k \geq 2$.
As $b \in A\_k - B\_k$ and as $A\_k \subset B\_{k-1}$, so we must have $b \in B\_{k-1}$. What next?
|
2015/12/02
|
[
"https://math.stackexchange.com/questions/1557140",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/59734/"
] |
Since you asked me to answer here: <http://dbfin.com/topology/munkres/chapter-1/section-7-countable-and-uncountable-sets/problem-6-solution/#comment-2390104583>.
Step 1. We show the inclusions $A\_1\supset B\_1\supset A\_2\supset B\_2\supset\cdots$, you have already shown it in the question.
Step 2. We show that $h$ is well-defined. Indeed, for all $x\in A$, $h(x)\in B$, as if $x\in A−B=A\_1−B\_1$ then $h(x)=f(x)\in B$, otherwise $x\in B$, and $h(x)\in \{x,f(x)\}\subset B$, so that $h(x)\in B$.
Step 3. We show that $h$ is bijective. We split all of $A$ into "slices" $C\_n=A\_n−B\_n$ and the rest $X=A−\cup\_{n\in\mathbb{Z}\_+}C\_n$.
(a) All slices and $X$ are pairwise disjoint. $X$ is disjoint from any $C\_n$ by definition. Further, for $m>n$, we have $C\_m\subset A\_m$ (by definition), $A\_m\subset B\_n$ by Step 1, $B\_n\cap C\_n=\emptyset$ by definition. Overall, we have $C\_m\cap C\_n=\emptyset$.
(b) The restriction of $h$ to $C\_n$ is a bijection $h\_n:C\_n\rightarrow C\_{n+1}$ because $f|A\_n:A\_n\rightarrow A\_{n+1}$ and $f|B\_n:B\_n\rightarrow B\_{n+1}$ where $B\_k\subset A\_k$ are bijections.
(c) The restriction of $h$ to X is the identity function.
Since the image sets of the functions $h\_n$ and $h|X$ are pairwise disjoint (by (a), (b) and (c)), $A=X\cup\_{n\in \mathbb{Z}\_+}C\_n$ and $h(A)=X\cup\_{n\in \mathbb{Z}\_+}C\_{n+1}=A−C\_1=B$, we conclude that $h$ is injective and surjective, i.e. bijective.
|
I understand you didn't finish proving surjectivity of $h$, let me complete it. You want to prove that, that for any $b \in B$ such that $b \in (A\_k - B\_k)$ for some positive integer $k>1$, there exists some $\alpha \in A \; |\,h(\alpha)=b $.
Due to $A\_k=f(A\_{k-1})$, $B\_k = f(B\_{k-1})$ and $f$ is an injective function,$A\_k - B\_k = f(A\_{k-1}) - f(B\_{k-1}) = f(A\_{k-1} - B\_{k-1})$. Then, $b\in f(A\_{k-1} - B\_{k-1})$, i.e, there exists some $\alpha\in A\_{k-1}\subseteq A$ such that $f(\alpha)=b$ when $\alpha \in (A\_{k-1} - B\_{k-1})$, and $h(\alpha)=b$. This should complete the surjectivity proof you started.
|
56,904,413 |
I am having some doubts with this homework on python. The exercise consists on the following:
>
> This bus has a passenger entry and exit control system to monitor the number of occupants it carries and thus detect when there is too high a capacity.
>
>
> At each stop the entry and exit of passengers is represented by a tuple consisting of two integer numbers.
>
>
>
> ```
> bus_stop = (in, out)
>
> ```
>
> The succession of stops is represented by a list of these tuples.
>
>
>
> ```
> stops = [(in1, out1), (in2, out2), (in3, out3), (in4, out4)]
>
> ```
>
> Goals:
>
>
> * Use lists, tuples
> * Use while/for loops
> * Use minimum, maximum, length
> * Use average, standard deviation
>
>
> Tasks:
>
>
> * Calculate the number of stops.
> * Assign to a variable a list whose elements are the number of passengers at each stop (in-out),
> * Find the maximum occupation of the bus.
>
>
>
So far I've come up with this code but it's not returning anything, so, definitely I am doing something wrong due to my inexperience with python.
```
bus_is_full = False
bus_capacity = 0
stops = [(20, 0), (13, 7), (40, 10), (1, 20)]
while not bus_is_full == True:
for stop in stops:
bus_capacity = stops()
if bus_capacity == 50:
bus_is_full = True
stops +=1
elif bus_capacity < 50:
stops +=1
print(bus_capacity)
```
|
2019/07/05
|
[
"https://Stackoverflow.com/questions/56904413",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11631992/"
] |
Change the content in `.npmignore`
`*.ts=>.ts`
|
I also had this problem, I simply named my `.ts` files as `__typescript__` and then declared `__typescript__` in the template variables, so your file will be: `fight.__typescript__`
```
const templateSource = apply(url('./files'), [
template({
typescript: 'ts',
}),
```
|
139,375 |
I have a quick question about updating my references from Bibtex. I am using TexStudio as my Latex editor.
I have to make changes to some of the references. I put the changes in the "references.bib" file. I then compile the Bibtex and the main document I'm working on. Sometimes the changes show up, and sometimes they don't, and I haven't figured out why. I have even gone as far as trying to delete the references by changing the filename, but the original references still appear. Here's what I put in my main document:
```
\newpage %Puts in References
\bibliographystyle{unsrt}
\bibliography{references}
```
My references.bib file shows all the changes I have made. Any suggestions are appreciated!
|
2013/10/18
|
[
"https://tex.stackexchange.com/questions/139375",
"https://tex.stackexchange.com",
"https://tex.stackexchange.com/users/38466/"
] |
Sometimes you need delete all temporary files, like:
>
> .aux, .bbl, .blg, .brf, .dvi, .ilg, .ind, .log, .out, .nav, .snm,
> .toc, .idx, .lof, .lot, .snm, .bcf, .run.xml, .vrb, ...
>
>
>
And recompile your `.tex` file:
```
latex main.tex
bibtex main.aux
latex main.tex
latex main.tex
```
P.S. Look for some missing comma in .bib file.
|
Maybe this answer shouldn't be in this topic but i don't know were to put it. I lost a lot of time trying to figure out why I couldn't update the references in my `.bib` files, until I realize that I had to completely disable the UAC (Windows 8). To do this see:
<http://www.eightforums.com/system-security/2434-disable-uac-completely.html>
Hope it helps.
|
139,375 |
I have a quick question about updating my references from Bibtex. I am using TexStudio as my Latex editor.
I have to make changes to some of the references. I put the changes in the "references.bib" file. I then compile the Bibtex and the main document I'm working on. Sometimes the changes show up, and sometimes they don't, and I haven't figured out why. I have even gone as far as trying to delete the references by changing the filename, but the original references still appear. Here's what I put in my main document:
```
\newpage %Puts in References
\bibliographystyle{unsrt}
\bibliography{references}
```
My references.bib file shows all the changes I have made. Any suggestions are appreciated!
|
2013/10/18
|
[
"https://tex.stackexchange.com/questions/139375",
"https://tex.stackexchange.com",
"https://tex.stackexchange.com/users/38466/"
] |
Sometimes you need delete all temporary files, like:
>
> .aux, .bbl, .blg, .brf, .dvi, .ilg, .ind, .log, .out, .nav, .snm,
> .toc, .idx, .lof, .lot, .snm, .bcf, .run.xml, .vrb, ...
>
>
>
And recompile your `.tex` file:
```
latex main.tex
bibtex main.aux
latex main.tex
latex main.tex
```
P.S. Look for some missing comma in .bib file.
|
If that doesn't help, make sure you don't have several .bib files with the same name in your path (and you're updating the wrong one).
|
139,375 |
I have a quick question about updating my references from Bibtex. I am using TexStudio as my Latex editor.
I have to make changes to some of the references. I put the changes in the "references.bib" file. I then compile the Bibtex and the main document I'm working on. Sometimes the changes show up, and sometimes they don't, and I haven't figured out why. I have even gone as far as trying to delete the references by changing the filename, but the original references still appear. Here's what I put in my main document:
```
\newpage %Puts in References
\bibliographystyle{unsrt}
\bibliography{references}
```
My references.bib file shows all the changes I have made. Any suggestions are appreciated!
|
2013/10/18
|
[
"https://tex.stackexchange.com/questions/139375",
"https://tex.stackexchange.com",
"https://tex.stackexchange.com/users/38466/"
] |
If that doesn't help, make sure you don't have several .bib files with the same name in your path (and you're updating the wrong one).
|
Maybe this answer shouldn't be in this topic but i don't know were to put it. I lost a lot of time trying to figure out why I couldn't update the references in my `.bib` files, until I realize that I had to completely disable the UAC (Windows 8). To do this see:
<http://www.eightforums.com/system-security/2434-disable-uac-completely.html>
Hope it helps.
|
8,631,524 |
Clearly, the intention of this animation is to turn all "editable" elements to a blue color in 300 ms, and then slowly fade back to the body background color over the course of 1000 ms. Basically, make them "blink".
```
$('#highlight_button').click( function (e) {
var x = $('body').css('background-color');
$('.editable').animate({backgroundColor: '#0000ff'}, 300, function() {
$('.editable').animate({backgroundColor: x}, 1000);
});
});
```
When the page loads, it always seems to work as intended on the first click. However, with subsequent clicks it fires only periodically, or with a very long delay. I suppose a solution would involve not queuing this animation, but looking around it isn't clear to me how to do this. Any thoughts?
Thanks in advance!
|
2011/12/25
|
[
"https://Stackoverflow.com/questions/8631524",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/927604/"
] |
Python Webdriver Script:
```
from selenium import webdriver
browser = webdriver.Firefox()
browser.get("http://sandbox.dev/alert.html")
alert = browser.switch_to_alert()
alert.accept()
browser.close()
```
Webpage (alert.html):
```
<html><body>
<script>alert("hey");</script>
</body></html>
```
Running the webdriver script will open the HTML page that shows an alert. Webdriver immediately switches to the alert and accepts it. Webdriver then closes the browser and ends.
If you are not sure there will be an alert then you need to catch the error with something like this.
```
from selenium import webdriver
browser = webdriver.Firefox()
browser.get("http://sandbox.dev/no-alert.html")
try:
alert = browser.switch_to_alert()
alert.accept()
except:
print "no alert to accept"
browser.close()
```
If you need to check the text of the alert, you can get the text of the alert by accessing the text attribute of the alert object:
```
from selenium import webdriver
browser = webdriver.Firefox()
browser.get("http://sandbox.dev/alert.html")
try:
alert = browser.switch_to_alert()
print alert.text
alert.accept()
except:
print "no alert to accept"
browser.close()
```
|
**Try The Code below! Working Fine for me!**
```
alert = driver.switch_to.alert
try:
alert.accept() #If you want to Accept the Alert
except:
alert.dismiss() #If You want to Dismiss the Alert.
```
|
8,631,524 |
Clearly, the intention of this animation is to turn all "editable" elements to a blue color in 300 ms, and then slowly fade back to the body background color over the course of 1000 ms. Basically, make them "blink".
```
$('#highlight_button').click( function (e) {
var x = $('body').css('background-color');
$('.editable').animate({backgroundColor: '#0000ff'}, 300, function() {
$('.editable').animate({backgroundColor: x}, 1000);
});
});
```
When the page loads, it always seems to work as intended on the first click. However, with subsequent clicks it fires only periodically, or with a very long delay. I suppose a solution would involve not queuing this animation, but looking around it isn't clear to me how to do this. Any thoughts?
Thanks in advance!
|
2011/12/25
|
[
"https://Stackoverflow.com/questions/8631524",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/927604/"
] |
```
from selenium import webdriver
from selenium.webdriver.support import expected_conditions as EC
driver = webdriver.Firefox()
#do something
if EC.alert_is_present:
print "Alert Exists"
driver.switch_to_alert().accept()
print "Alert accepted"
else:
print "No alert exists"
```
More about excepted\_conditions <https://seleniumhq.github.io/selenium/docs/api/py/webdriver_support/selenium.webdriver.support.expected_conditions.html>
|
**Try The Code below! Working Fine for me!**
```
alert = driver.switch_to.alert
try:
alert.accept() #If you want to Accept the Alert
except:
alert.dismiss() #If You want to Dismiss the Alert.
```
|
8,631,524 |
Clearly, the intention of this animation is to turn all "editable" elements to a blue color in 300 ms, and then slowly fade back to the body background color over the course of 1000 ms. Basically, make them "blink".
```
$('#highlight_button').click( function (e) {
var x = $('body').css('background-color');
$('.editable').animate({backgroundColor: '#0000ff'}, 300, function() {
$('.editable').animate({backgroundColor: x}, 1000);
});
});
```
When the page loads, it always seems to work as intended on the first click. However, with subsequent clicks it fires only periodically, or with a very long delay. I suppose a solution would involve not queuing this animation, but looking around it isn't clear to me how to do this. Any thoughts?
Thanks in advance!
|
2011/12/25
|
[
"https://Stackoverflow.com/questions/8631524",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/927604/"
] |
Python Webdriver Script:
```
from selenium import webdriver
browser = webdriver.Firefox()
browser.get("http://sandbox.dev/alert.html")
alert = browser.switch_to_alert()
alert.accept()
browser.close()
```
Webpage (alert.html):
```
<html><body>
<script>alert("hey");</script>
</body></html>
```
Running the webdriver script will open the HTML page that shows an alert. Webdriver immediately switches to the alert and accepts it. Webdriver then closes the browser and ends.
If you are not sure there will be an alert then you need to catch the error with something like this.
```
from selenium import webdriver
browser = webdriver.Firefox()
browser.get("http://sandbox.dev/no-alert.html")
try:
alert = browser.switch_to_alert()
alert.accept()
except:
print "no alert to accept"
browser.close()
```
If you need to check the text of the alert, you can get the text of the alert by accessing the text attribute of the alert object:
```
from selenium import webdriver
browser = webdriver.Firefox()
browser.get("http://sandbox.dev/alert.html")
try:
alert = browser.switch_to_alert()
print alert.text
alert.accept()
except:
print "no alert to accept"
browser.close()
```
|
I am using Ruby bindings but here what I found in Selenium Python Bindings 2 documentation:
<http://readthedocs.org/docs/selenium-python/en/latest/index.html>
Selenium WebDriver has built-in support for handling popup dialog boxes. After you’ve triggerd and action that would open a popup, you can access the alert with the following:
```
alert = driver.switch_to_alert()
```
Now I guess you can do something like that:
```
if alert.text == 'A value you are looking for'
alert.dismiss
else
alert.accept
end
```
Hope it helps!
|
8,631,524 |
Clearly, the intention of this animation is to turn all "editable" elements to a blue color in 300 ms, and then slowly fade back to the body background color over the course of 1000 ms. Basically, make them "blink".
```
$('#highlight_button').click( function (e) {
var x = $('body').css('background-color');
$('.editable').animate({backgroundColor: '#0000ff'}, 300, function() {
$('.editable').animate({backgroundColor: x}, 1000);
});
});
```
When the page loads, it always seems to work as intended on the first click. However, with subsequent clicks it fires only periodically, or with a very long delay. I suppose a solution would involve not queuing this animation, but looking around it isn't clear to me how to do this. Any thoughts?
Thanks in advance!
|
2011/12/25
|
[
"https://Stackoverflow.com/questions/8631524",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/927604/"
] |
If you want to Accept or Click the popup, regardless of for what it is then
```
alert.accept
```
Where
`alert` is object of class `selenium.webdriver.common.alert.Alert(driver)`
and `accept` is method of that object
[Source](https://www.selenium.dev/selenium/docs/api/py/webdriver/selenium.webdriver.common.alert.html)
|
I am using Ruby bindings but here what I found in Selenium Python Bindings 2 documentation:
<http://readthedocs.org/docs/selenium-python/en/latest/index.html>
Selenium WebDriver has built-in support for handling popup dialog boxes. After you’ve triggerd and action that would open a popup, you can access the alert with the following:
```
alert = driver.switch_to_alert()
```
Now I guess you can do something like that:
```
if alert.text == 'A value you are looking for'
alert.dismiss
else
alert.accept
end
```
Hope it helps!
|
8,631,524 |
Clearly, the intention of this animation is to turn all "editable" elements to a blue color in 300 ms, and then slowly fade back to the body background color over the course of 1000 ms. Basically, make them "blink".
```
$('#highlight_button').click( function (e) {
var x = $('body').css('background-color');
$('.editable').animate({backgroundColor: '#0000ff'}, 300, function() {
$('.editable').animate({backgroundColor: x}, 1000);
});
});
```
When the page loads, it always seems to work as intended on the first click. However, with subsequent clicks it fires only periodically, or with a very long delay. I suppose a solution would involve not queuing this animation, but looking around it isn't clear to me how to do this. Any thoughts?
Thanks in advance!
|
2011/12/25
|
[
"https://Stackoverflow.com/questions/8631524",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/927604/"
] |
I am using Ruby bindings but here what I found in Selenium Python Bindings 2 documentation:
<http://readthedocs.org/docs/selenium-python/en/latest/index.html>
Selenium WebDriver has built-in support for handling popup dialog boxes. After you’ve triggerd and action that would open a popup, you can access the alert with the following:
```
alert = driver.switch_to_alert()
```
Now I guess you can do something like that:
```
if alert.text == 'A value you are looking for'
alert.dismiss
else
alert.accept
end
```
Hope it helps!
|
that depends on the javascript function that handles the form submission
if there's no such function try to submit the form using post
|
8,631,524 |
Clearly, the intention of this animation is to turn all "editable" elements to a blue color in 300 ms, and then slowly fade back to the body background color over the course of 1000 ms. Basically, make them "blink".
```
$('#highlight_button').click( function (e) {
var x = $('body').css('background-color');
$('.editable').animate({backgroundColor: '#0000ff'}, 300, function() {
$('.editable').animate({backgroundColor: x}, 1000);
});
});
```
When the page loads, it always seems to work as intended on the first click. However, with subsequent clicks it fires only periodically, or with a very long delay. I suppose a solution would involve not queuing this animation, but looking around it isn't clear to me how to do this. Any thoughts?
Thanks in advance!
|
2011/12/25
|
[
"https://Stackoverflow.com/questions/8631524",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/927604/"
] |
Python Webdriver Script:
```
from selenium import webdriver
browser = webdriver.Firefox()
browser.get("http://sandbox.dev/alert.html")
alert = browser.switch_to_alert()
alert.accept()
browser.close()
```
Webpage (alert.html):
```
<html><body>
<script>alert("hey");</script>
</body></html>
```
Running the webdriver script will open the HTML page that shows an alert. Webdriver immediately switches to the alert and accepts it. Webdriver then closes the browser and ends.
If you are not sure there will be an alert then you need to catch the error with something like this.
```
from selenium import webdriver
browser = webdriver.Firefox()
browser.get("http://sandbox.dev/no-alert.html")
try:
alert = browser.switch_to_alert()
alert.accept()
except:
print "no alert to accept"
browser.close()
```
If you need to check the text of the alert, you can get the text of the alert by accessing the text attribute of the alert object:
```
from selenium import webdriver
browser = webdriver.Firefox()
browser.get("http://sandbox.dev/alert.html")
try:
alert = browser.switch_to_alert()
print alert.text
alert.accept()
except:
print "no alert to accept"
browser.close()
```
|
If you want to Accept or Click the popup, regardless of for what it is then
```
alert.accept
```
Where
`alert` is object of class `selenium.webdriver.common.alert.Alert(driver)`
and `accept` is method of that object
[Source](https://www.selenium.dev/selenium/docs/api/py/webdriver/selenium.webdriver.common.alert.html)
|
8,631,524 |
Clearly, the intention of this animation is to turn all "editable" elements to a blue color in 300 ms, and then slowly fade back to the body background color over the course of 1000 ms. Basically, make them "blink".
```
$('#highlight_button').click( function (e) {
var x = $('body').css('background-color');
$('.editable').animate({backgroundColor: '#0000ff'}, 300, function() {
$('.editable').animate({backgroundColor: x}, 1000);
});
});
```
When the page loads, it always seems to work as intended on the first click. However, with subsequent clicks it fires only periodically, or with a very long delay. I suppose a solution would involve not queuing this animation, but looking around it isn't clear to me how to do this. Any thoughts?
Thanks in advance!
|
2011/12/25
|
[
"https://Stackoverflow.com/questions/8631524",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/927604/"
] |
If you want to Accept or Click the popup, regardless of for what it is then
```
alert.accept
```
Where
`alert` is object of class `selenium.webdriver.common.alert.Alert(driver)`
and `accept` is method of that object
[Source](https://www.selenium.dev/selenium/docs/api/py/webdriver/selenium.webdriver.common.alert.html)
|
**Try The Code below! Working Fine for me!**
```
alert = driver.switch_to.alert
try:
alert.accept() #If you want to Accept the Alert
except:
alert.dismiss() #If You want to Dismiss the Alert.
```
|
8,631,524 |
Clearly, the intention of this animation is to turn all "editable" elements to a blue color in 300 ms, and then slowly fade back to the body background color over the course of 1000 ms. Basically, make them "blink".
```
$('#highlight_button').click( function (e) {
var x = $('body').css('background-color');
$('.editable').animate({backgroundColor: '#0000ff'}, 300, function() {
$('.editable').animate({backgroundColor: x}, 1000);
});
});
```
When the page loads, it always seems to work as intended on the first click. However, with subsequent clicks it fires only periodically, or with a very long delay. I suppose a solution would involve not queuing this animation, but looking around it isn't clear to me how to do this. Any thoughts?
Thanks in advance!
|
2011/12/25
|
[
"https://Stackoverflow.com/questions/8631524",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/927604/"
] |
Python Webdriver Script:
```
from selenium import webdriver
browser = webdriver.Firefox()
browser.get("http://sandbox.dev/alert.html")
alert = browser.switch_to_alert()
alert.accept()
browser.close()
```
Webpage (alert.html):
```
<html><body>
<script>alert("hey");</script>
</body></html>
```
Running the webdriver script will open the HTML page that shows an alert. Webdriver immediately switches to the alert and accepts it. Webdriver then closes the browser and ends.
If you are not sure there will be an alert then you need to catch the error with something like this.
```
from selenium import webdriver
browser = webdriver.Firefox()
browser.get("http://sandbox.dev/no-alert.html")
try:
alert = browser.switch_to_alert()
alert.accept()
except:
print "no alert to accept"
browser.close()
```
If you need to check the text of the alert, you can get the text of the alert by accessing the text attribute of the alert object:
```
from selenium import webdriver
browser = webdriver.Firefox()
browser.get("http://sandbox.dev/alert.html")
try:
alert = browser.switch_to_alert()
print alert.text
alert.accept()
except:
print "no alert to accept"
browser.close()
```
|
that depends on the javascript function that handles the form submission
if there's no such function try to submit the form using post
|
8,631,524 |
Clearly, the intention of this animation is to turn all "editable" elements to a blue color in 300 ms, and then slowly fade back to the body background color over the course of 1000 ms. Basically, make them "blink".
```
$('#highlight_button').click( function (e) {
var x = $('body').css('background-color');
$('.editable').animate({backgroundColor: '#0000ff'}, 300, function() {
$('.editable').animate({backgroundColor: x}, 1000);
});
});
```
When the page loads, it always seems to work as intended on the first click. However, with subsequent clicks it fires only periodically, or with a very long delay. I suppose a solution would involve not queuing this animation, but looking around it isn't clear to me how to do this. Any thoughts?
Thanks in advance!
|
2011/12/25
|
[
"https://Stackoverflow.com/questions/8631524",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/927604/"
] |
```
from selenium import webdriver
from selenium.webdriver.support import expected_conditions as EC
driver = webdriver.Firefox()
#do something
if EC.alert_is_present:
print "Alert Exists"
driver.switch_to_alert().accept()
print "Alert accepted"
else:
print "No alert exists"
```
More about excepted\_conditions <https://seleniumhq.github.io/selenium/docs/api/py/webdriver_support/selenium.webdriver.support.expected_conditions.html>
|
I am using Ruby bindings but here what I found in Selenium Python Bindings 2 documentation:
<http://readthedocs.org/docs/selenium-python/en/latest/index.html>
Selenium WebDriver has built-in support for handling popup dialog boxes. After you’ve triggerd and action that would open a popup, you can access the alert with the following:
```
alert = driver.switch_to_alert()
```
Now I guess you can do something like that:
```
if alert.text == 'A value you are looking for'
alert.dismiss
else
alert.accept
end
```
Hope it helps!
|
8,631,524 |
Clearly, the intention of this animation is to turn all "editable" elements to a blue color in 300 ms, and then slowly fade back to the body background color over the course of 1000 ms. Basically, make them "blink".
```
$('#highlight_button').click( function (e) {
var x = $('body').css('background-color');
$('.editable').animate({backgroundColor: '#0000ff'}, 300, function() {
$('.editable').animate({backgroundColor: x}, 1000);
});
});
```
When the page loads, it always seems to work as intended on the first click. However, with subsequent clicks it fires only periodically, or with a very long delay. I suppose a solution would involve not queuing this animation, but looking around it isn't clear to me how to do this. Any thoughts?
Thanks in advance!
|
2011/12/25
|
[
"https://Stackoverflow.com/questions/8631524",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/927604/"
] |
If you want to Accept or Click the popup, regardless of for what it is then
```
alert.accept
```
Where
`alert` is object of class `selenium.webdriver.common.alert.Alert(driver)`
and `accept` is method of that object
[Source](https://www.selenium.dev/selenium/docs/api/py/webdriver/selenium.webdriver.common.alert.html)
|
that depends on the javascript function that handles the form submission
if there's no such function try to submit the form using post
|
45,976,281 |
I'm trying to use google-vision to fetch text from an image (uploaded to AWS S3) and store it in AWS Dynamo DB. I'm encountering dependency conflicts on jackson-core as both google-api and aws-java-sdk are using two different versions.
---
**Dependency Hierarchy**
>
> google-api-client: 1.22.0 uses jackson-core: 2.1.3
>
>
> google-cloud-vision: 0.22.0-beta uses jackson-core: 2.1.3
>
>
> aws-java-sdk: 1.11.106 uses jackson-core: 2.6.6
>
>
>
I tried "exclusions" and added explicit dependency in pom.xml to use jackson-core: 2.6.6. Google-vision api works fine with that change. However, AmazonDynamoDBClientBuilder fails with below error:
---
```
Exception in thread "main" java.lang.IllegalAccessError: tried to access method com.amazonaws.AmazonWebServiceClient.<init>(Lcom/amazonaws/client/AwsSyncClientParams;)V from class com.amazonaws.services.dynamodbv2.AmazonDynamoDBClientBuilder
at com.amazonaws.services.dynamodbv2.AmazonDynamoDBClientBuilder.build(AmazonDynamoDBClientBuilder.java:60)
at com.amazonaws.services.dynamodbv2.AmazonDynamoDBClientBuilder.build(AmazonDynamoDBClientBuilder.java:26)
at com.amazonaws.client.builder.AwsSyncClientBuilder.build(AwsSyncClientBuilder.java:46)
at com.oneglint.ImageProcessing.AddItem.main(AddItem.java:133)
```
Following error is displayed when there was version conflict
```
Exception in thread "main" java.lang.NoSuchMethodError: com.fasterxml.jackson.core.JsonFactory.requiresPropertyOrdering()Z
at com.fasterxml.jackson.databind.ObjectMapper.<init>(ObjectMapper.java:537)
at com.fasterxml.jackson.databind.ObjectMapper.<init>(ObjectMapper.java:448)
at com.amazonaws.partitions.PartitionsLoader.<clinit>(PartitionsLoader.java:51)
at com.amazonaws.regions.RegionMetadataFactory.create(RegionMetadataFactory.java:30)
at com.amazonaws.regions.RegionUtils.initialize(RegionUtils.java:64)
at com.amazonaws.regions.RegionUtils.getRegionMetadata(RegionUtils.java:52)
at com.amazonaws.regions.RegionUtils.getRegion(RegionUtils.java:105)
at com.amazonaws.client.builder.AwsClientBuilder.withRegion(AwsClientBuilder.java:239)
at com.oneglint.ImageProcessing.AddItem.main(AddItem.java:132)
```
---
What am I missing here? Thanks for the help..
BTW, I'm using example code from github to achieve this. Here are the links:
DynamoDB example: <https://github.com/awsdocs/aws-doc-sdk-examples/tree/master/java/example_code/dynamodb>
Google Vision DetectText example: <https://github.com/GoogleCloudPlatform/java-docs-samples/blob/master/vision/cloud-client/src/main/java/com/example/vision/Detect.java>
---
Additional Details
------------------
Both the examples are working fine if executed as independent projects. The problem occurs ONLY when both `PutItem` (AWS) & `Detect` (google-vision) classes are brought together in a single project, with appropriate code changes.
|
2017/08/31
|
[
"https://Stackoverflow.com/questions/45976281",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8541830/"
] |
Don't use ordinary Python lists for your stacks. Use Lisp-style linked lists, so your stacks share most of their structure with each other and building a new stack with an additional element is constant time:
```
def empty_stack():
return ()
def push(stack, item):
return (item, stack)
def stack_to_list(stack):
l = []
while stack:
item, stack = stack
l.append(item)
return l[::-1]
```
Here, `push` runs in constant time and produces a new stack, without mutating the old, so you can call `push` on the old stack repeatedly without copying it.
|
You can just bulk copy it:
```
def copyList(thelist, number_of_copies):
return tuple(thelist[:] for _ in xrange(number_of_copies))
a, b, c = copyList(range(10), 3)
```
Here you have a [live example](https://repl.it/K9gC/0)
|
20,475,309 |
I'm trying to do a post of the mapped `KnockoutJS` model. I can see when debugging it, the `JSON` is correct. But the server shows that `Product` is 0 (empty). While it does contain 1 item.
`MVC Controller`:
```
[HttpPost]
public ActionResult Test(MyModel model, FormCollection fc)
{
return RedirectToAction("index");
}
```
The `AJAX` submit:
```
$('#btnSubmit').click(function (event) {
var theModel = ko.mapping.toJSON(viewModel);
debugger;
$.ajax({
type: 'POST',
url: "@Url.Action("Test", "Home")",
data: theModel,
contentType: 'application/json; charset=utf-8',
success: function (result) {
if (!result.success) {
//alert(result.error);
}
else { }
}
});
});
```
This is a partial `JSON` object:
```
"Products":[{"Id":2,"Name":"bread"}]
```
What am I doing wrong?
EDIT:
```
public class MyModel
{
public int User { get; set; }
public string Address { get; set; }
public string ZipCode { get; set; }
public List<Product> Products { get; set; }
}
public class Product
{
public int Id { get; set; }
public string Name { get; set; }
}
```
|
2013/12/09
|
[
"https://Stackoverflow.com/questions/20475309",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1085263/"
] |
Here is a full working tested example (sending a model back from the controller and posting):
**Controller**
```
public ActionResult Test()
{
var model = new MyModel();
model.Products = new List<Product> { new Product { Id = 2, Name = "bread" } };
return View(model);
}
[HttpPost]
public ActionResult Test(MyModel model, FormCollection fc)
{
// Count equals one
var count = model.Products.Count();
return RedirectToAction("index");
}
```
**Model**
```
public class MyModel
{
public int User { get; set; }
public string Address { get; set; }
public string ZipCode { get; set; }
public List<Product> Products { get; set; }
}
public class Product
{
public int Id { get; set; }
public string Name { get; set; }
}
```
**View**
```
@model MyModel
<form method="post">
<input id="btnSubmit" type="submit" value="submit" />
</form>
<script src="~/Scripts/jquery-1.8.2.js"></script>
<script src="~/Scripts/knockout-2.2.0.js"></script>
<script src="~/Scripts/knockout.mapping-latest.js"></script>
<script type="text/javascript">
var Product = function (Id, Name) {
self = this;
self.Id = Id;
self.Name = Name;
}
var mapping = {
'Products': {
create: function (options) {
return new Product(options.data.Id, options.data.Name);
}
}
}
function MyModel(data) {
var self = this;
ko.mapping.fromJS(data, mapping, self);
}
var viewModel = new MyModel(@Html.Raw(Json.Encode(Model)));
$('#btnSubmit').click(function (event) {
event.preventDefault();
var theModel = ko.mapping.toJSON(viewModel);
debugger;
$.ajax({
type: 'POST',
url: "@Url.Action("Test", "Home")",
data: theModel,
contentType: 'application/json; charset=utf-8',
dataType: 'json',
success: function (result) {
if (!result.success) {
//alert(result.error);
}
else { }
}
});
});
</script>
```
|
After investigating some more with fiddler, it turned out that I was getting a 500 error with this message:
```
System.MissingMethodException: No parameterless constructor defined for this object.
```
After adding the parameterless constructor in the model, I still got the error message. This was caused because I had a few `SelectList` in my model. So that's why It couldn't be bound to the model.
Found the solution on this [SO](https://stackoverflow.com/questions/1355464/asp-net-mvc-no-parameterless-constructor-defined-for-this-object) post (look for the answer of Chris S). Hope it helps others when facing this issue too.
|
31,471,279 |
I'm using QT 5.5.0.
When I compile a program, it shows “no type named 'u16string' in namespace 'std'”. The interesting part is that I compiled it successfully in the past, why is it failing now? It seems to be trouble with `qstring.h`.
How do I fix it? Here is where the error happen
```
#ifndef QSTRING_H
#define QSTRING_H
#if defined(QT_NO_CAST_FROM_ASCII) && defined(QT_RESTRICTED_CAST_FROM_ASCII)
#error QT_NO_CAST_FROM_ASCII and QT_RESTRICTED_CAST_FROM_ASCII must not be defined at the same time
#endif
#include <QtCore/qchar.h>
#include <QtCore/qbytearray.h>
#include <QtCore/qrefcount.h>
#include <QtCore/qnamespace.h>
#include <string>
#if defined(Q_OS_ANDROID)
// std::wstring is disabled on android's glibc, as bionic lacks certain features
// that libstdc++ checks for (like mbcslen). namespace std { typedef basic_string<wchar_t> wstring; }
#endif
#if defined(Q_COMPILER_UNICODE_STRINGS) || defined(Q_QDOC)
static inline QString fromStdU16String(const std::u16string &s);
inline std::u16string toStdU16String() const;
static inline QString fromStdU32String(const std::u32string &s);
inline std::u32string toStdU32String() const;
#endif
```
|
2015/07/17
|
[
"https://Stackoverflow.com/questions/31471279",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4041114/"
] |
>
> The interesting part is that I compiled it successfully in the past, why is it failing now?
>
>
>
Earlier you would have included some library's header which in turn included `<string>`; this, after some update perhaps, would've stopped including it directly and thus the error.
>
> How to fix it?
>
>
>
Include the proper header in your source to avoid these kind of issues.
```
#include <string>
```
in the [translation unit](https://stackoverflow.com/q/1106149/183120) where the error occurs and make sure you're referring to it with the namespace: `std::u16string`.
|
The problem is in the file ExpGame.pro.I delete code as bellow:
QMAKE\_CXXFLAGS += -std=c++11
And it is OK.
|
31,471,279 |
I'm using QT 5.5.0.
When I compile a program, it shows “no type named 'u16string' in namespace 'std'”. The interesting part is that I compiled it successfully in the past, why is it failing now? It seems to be trouble with `qstring.h`.
How do I fix it? Here is where the error happen
```
#ifndef QSTRING_H
#define QSTRING_H
#if defined(QT_NO_CAST_FROM_ASCII) && defined(QT_RESTRICTED_CAST_FROM_ASCII)
#error QT_NO_CAST_FROM_ASCII and QT_RESTRICTED_CAST_FROM_ASCII must not be defined at the same time
#endif
#include <QtCore/qchar.h>
#include <QtCore/qbytearray.h>
#include <QtCore/qrefcount.h>
#include <QtCore/qnamespace.h>
#include <string>
#if defined(Q_OS_ANDROID)
// std::wstring is disabled on android's glibc, as bionic lacks certain features
// that libstdc++ checks for (like mbcslen). namespace std { typedef basic_string<wchar_t> wstring; }
#endif
#if defined(Q_COMPILER_UNICODE_STRINGS) || defined(Q_QDOC)
static inline QString fromStdU16String(const std::u16string &s);
inline std::u16string toStdU16String() const;
static inline QString fromStdU32String(const std::u32string &s);
inline std::u32string toStdU32String() const;
#endif
```
|
2015/07/17
|
[
"https://Stackoverflow.com/questions/31471279",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4041114/"
] |
To fix it:
1. as the Qt on mac is built by clang, in "Qt Creator" -> "Preferences" -> "Kits", you should set "Compiler" to clang.
2. instead of writing "QMAKE\_CXXFLAGS += -std=c++11", add below config to your .pro file:
```
CONFIG += c++11
```
<https://forum.qt.io/topic/56064/solved-problem-with-qt-5-5/11>
|
>
> The interesting part is that I compiled it successfully in the past, why is it failing now?
>
>
>
Earlier you would have included some library's header which in turn included `<string>`; this, after some update perhaps, would've stopped including it directly and thus the error.
>
> How to fix it?
>
>
>
Include the proper header in your source to avoid these kind of issues.
```
#include <string>
```
in the [translation unit](https://stackoverflow.com/q/1106149/183120) where the error occurs and make sure you're referring to it with the namespace: `std::u16string`.
|
31,471,279 |
I'm using QT 5.5.0.
When I compile a program, it shows “no type named 'u16string' in namespace 'std'”. The interesting part is that I compiled it successfully in the past, why is it failing now? It seems to be trouble with `qstring.h`.
How do I fix it? Here is where the error happen
```
#ifndef QSTRING_H
#define QSTRING_H
#if defined(QT_NO_CAST_FROM_ASCII) && defined(QT_RESTRICTED_CAST_FROM_ASCII)
#error QT_NO_CAST_FROM_ASCII and QT_RESTRICTED_CAST_FROM_ASCII must not be defined at the same time
#endif
#include <QtCore/qchar.h>
#include <QtCore/qbytearray.h>
#include <QtCore/qrefcount.h>
#include <QtCore/qnamespace.h>
#include <string>
#if defined(Q_OS_ANDROID)
// std::wstring is disabled on android's glibc, as bionic lacks certain features
// that libstdc++ checks for (like mbcslen). namespace std { typedef basic_string<wchar_t> wstring; }
#endif
#if defined(Q_COMPILER_UNICODE_STRINGS) || defined(Q_QDOC)
static inline QString fromStdU16String(const std::u16string &s);
inline std::u16string toStdU16String() const;
static inline QString fromStdU32String(const std::u32string &s);
inline std::u32string toStdU32String() const;
#endif
```
|
2015/07/17
|
[
"https://Stackoverflow.com/questions/31471279",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4041114/"
] |
To fix it:
1. as the Qt on mac is built by clang, in "Qt Creator" -> "Preferences" -> "Kits", you should set "Compiler" to clang.
2. instead of writing "QMAKE\_CXXFLAGS += -std=c++11", add below config to your .pro file:
```
CONFIG += c++11
```
<https://forum.qt.io/topic/56064/solved-problem-with-qt-5-5/11>
|
The problem is in the file ExpGame.pro.I delete code as bellow:
QMAKE\_CXXFLAGS += -std=c++11
And it is OK.
|
28,366,665 |
I am unable to create Shared Preference file I have been struggling with this for 2 days please help,I am new here.In my app I am having 15 question each on different screens and I want to store the text of the option selected so that I can use it in future.
My Code
public class QuestionPagerFragment extends Fragment {
```
protected View mView;
String pageData[]; //Stores the text to swipe.
String optionData[];//Stores the option data.
static int rid;
RadioGroup group;
static ArrayList<Integer> list = new ArrayList();
SharedPreferences prefs;
public static final String MyPREFERENCES = "MyPrefs" ;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
mView = inflater.inflate(R.layout.page, container, false);
return mView;
}
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
prefs = getActivity().getSharedPreferences(MyPREFERENCES, Context.MODE_PRIVATE);
pageData=getResources().getStringArray(R.array.desserts);
optionData=getResources().getStringArray(R.array.options);
group = (RadioGroup)mView.findViewById(R.id.group);
group.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
// TODO Auto-generated method stub
int radioButtonID = group.getCheckedRadioButtonId();
View radioButton = group.findViewById(radioButtonID);
rid = group.indexOfChild(radioButton);
list.add(getArguments().getInt("pos"), rid);
click();
}
});
((TextView)mView.findViewById(R.id.textMessage)).setText(pageData[getArguments().getInt("pos")]);
if(getArguments().getInt("pos") == 14) {
((Button)mView.findViewById(R.id.submitbtn)).setVisibility(View.VISIBLE);
((Button)mView.findViewById(R.id.submitbtn)).setOnClickListener(new View.OnClickListener() {
public void onClick(View v){
}
});
}
for(int i = 0; i < group.getChildCount(); i++){
((RadioButton) group.getChildAt(i)).setText(optionData[(getArguments().getInt("pos")*4)+i]);
}
}
public static void save() {
if(rid==0){
MainActivity.FLAG_A++;
}
else if(rid==1){
MainActivity.FLAG_B++;
}
else if(rid==2){
MainActivity.FLAG_C++;
}
else if(rid==3){
MainActivity.FLAG_D++;
}
}
public void click(){
SharedPreferences prefs = getActivity().getSharedPreferences( "idValue", 0 );
SharedPreferences.Editor editor = prefs.edit();
editor.putString( "idValue", list.get(getArguments().getInt("pos")).toString());
editor.commit();
}
```
}
|
2015/02/06
|
[
"https://Stackoverflow.com/questions/28366665",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3699550/"
] |
Try to change commit() into apply() something like this:
```
public void click(){
SharedPreferences prefs = getActivity().getSharedPreferences( "your.project.package.name", 0 ); // don't use short id because sharedPreferences is a global file
SharedPreferences.Editor editor = prefs.edit();
editor.putString( "idValue", list.get(getArguments().getInt("pos")).toString());
editor.apply(); //Here is the change
}
```
to read your prefs try:
```
SharedPreferences prefs = this.getSharedPreferences("your.project.package.name", Context.MODE_PRIVATE);
String idValue= prefs.getString("idValue", null);
```
|
This code Will help you to store values
```
SharedPreferences pref = getApplicationContext().getSharedPreferences("MyPref", MODE_PRIVATE);
Editor editor = pref.edit();
```
// Storing data as KEY/VALUE pair
```
editor.putBoolean("key_name1", true); // Saving boolean - true/false
editor.putInt("key_name2", "int value"); // Saving integer
editor.putFloat("key_name3", "float value"); // Saving float
editor.putLong("key_name4", "long value"); // Saving long
editor.putString("key_name5", "string value"); // Saving string
// Save the changes in SharedPreferences
editor.commit(); // commit changes
```
// Get SharedPreferences data
// If value for key not exist then return second param value - In this case null
```
pref.getBoolean("key_name1", null); // getting boolean
pref.getInt("key_name2", null); // getting Integer
pref.getFloat("key_name3", null); // getting Float
pref.getLong("key_name4", null); // getting Long
pref.getString("key_name5", null); // getting String
```
//Deleting Key value from SharedPreferences
```
editor.remove("key_name3"); // will delete key key_name3
editor.remove("key_name4"); // will delete key key_name4
// Save the changes in SharedPreferences
editor.commit(); // commit changes
```
// Clear all data from SharedPreferences
```
editor.clear();
editor.commit(); // commit changes
```
|
28,366,665 |
I am unable to create Shared Preference file I have been struggling with this for 2 days please help,I am new here.In my app I am having 15 question each on different screens and I want to store the text of the option selected so that I can use it in future.
My Code
public class QuestionPagerFragment extends Fragment {
```
protected View mView;
String pageData[]; //Stores the text to swipe.
String optionData[];//Stores the option data.
static int rid;
RadioGroup group;
static ArrayList<Integer> list = new ArrayList();
SharedPreferences prefs;
public static final String MyPREFERENCES = "MyPrefs" ;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
mView = inflater.inflate(R.layout.page, container, false);
return mView;
}
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
prefs = getActivity().getSharedPreferences(MyPREFERENCES, Context.MODE_PRIVATE);
pageData=getResources().getStringArray(R.array.desserts);
optionData=getResources().getStringArray(R.array.options);
group = (RadioGroup)mView.findViewById(R.id.group);
group.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
// TODO Auto-generated method stub
int radioButtonID = group.getCheckedRadioButtonId();
View radioButton = group.findViewById(radioButtonID);
rid = group.indexOfChild(radioButton);
list.add(getArguments().getInt("pos"), rid);
click();
}
});
((TextView)mView.findViewById(R.id.textMessage)).setText(pageData[getArguments().getInt("pos")]);
if(getArguments().getInt("pos") == 14) {
((Button)mView.findViewById(R.id.submitbtn)).setVisibility(View.VISIBLE);
((Button)mView.findViewById(R.id.submitbtn)).setOnClickListener(new View.OnClickListener() {
public void onClick(View v){
}
});
}
for(int i = 0; i < group.getChildCount(); i++){
((RadioButton) group.getChildAt(i)).setText(optionData[(getArguments().getInt("pos")*4)+i]);
}
}
public static void save() {
if(rid==0){
MainActivity.FLAG_A++;
}
else if(rid==1){
MainActivity.FLAG_B++;
}
else if(rid==2){
MainActivity.FLAG_C++;
}
else if(rid==3){
MainActivity.FLAG_D++;
}
}
public void click(){
SharedPreferences prefs = getActivity().getSharedPreferences( "idValue", 0 );
SharedPreferences.Editor editor = prefs.edit();
editor.putString( "idValue", list.get(getArguments().getInt("pos")).toString());
editor.commit();
}
```
}
|
2015/02/06
|
[
"https://Stackoverflow.com/questions/28366665",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3699550/"
] |
Try to change commit() into apply() something like this:
```
public void click(){
SharedPreferences prefs = getActivity().getSharedPreferences( "your.project.package.name", 0 ); // don't use short id because sharedPreferences is a global file
SharedPreferences.Editor editor = prefs.edit();
editor.putString( "idValue", list.get(getArguments().getInt("pos")).toString());
editor.apply(); //Here is the change
}
```
to read your prefs try:
```
SharedPreferences prefs = this.getSharedPreferences("your.project.package.name", Context.MODE_PRIVATE);
String idValue= prefs.getString("idValue", null);
```
|
Try deleting this line:
SharedPreferences prefs = getActivity().getSharedPreferences( "idValue", 0 );
|
65,793,800 |
I am building an Azure Function project, so I cannot target .NET 5. Instead, my project is a `netcoreapp3.1`.
However, when my project is built, anytime there is some information printed, I see dotnet 5 being mentioned. Example:
>
> ##[warning]/usr/share/dotnet/sdk/5.0.101/Microsoft.Common.CurrentVersion.targets(2123,5): Warning MSB3245: Could not resolve this reference. Could not locate the assembly "System.Text.Json, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
>
>
>
(The issue that I'm having with System.Text.Json is a problem of its own, in this post I'd like to understand how .NET 5 can build netcoreapp3.1).
I have .NET Core 3.1 installed on my system next to .NET 5. Why doesn't the build system use 3.1? I believe that .NET 5 has some breaking changes in comparison to 3.1, so I am not sure if this is OK to use .NET 5 to build the project.
The same thing happens both in Azure DevOps Pipeline builds, and locally. Locally, in Rider, I see also this when I Build:
>
> CONSOLE: Use build tool: /usr/share/dotnet/sdk/5.0.102/MSBuild.dll
>
>
>
Here's the result of `ll /usr/share/dotnet/sdk`:
```sh
drwxr-xr-x 28 root root 12K sty 13 08:24 3.1.405/
drwxr-xr-x 28 root root 12K sty 13 08:24 5.0.102/
```
As you can see, I have both 3.1 and 5.
|
2021/01/19
|
[
"https://Stackoverflow.com/questions/65793800",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5021151/"
] |
You need to separate three things:
* the build SDK being used to perform the build steps
* the *target* platform which defines the API features available in the core packages (used by the build SDK)
* the *runtime* platform being used to actually execute your application, which is expected to support the *target* platform's API features
In this case, the *build* SDK is 5, and the *target* platform is 3.1; that's fine - build SDK 5 knows all about .NET Core 3.1 in terms of *target* features, so it knows what to do. As long as the runtime is *at least* .NET Core 3.1, it should all be fine (if we presume that nobody makes breaking changes to the core libraries in some future runtime environment).
The fact that the *build* SDK is v5 is interesting but largely irrelevant - they could have given the build SDK *completely different* version numbers and everything would still work. It is just *useful* to keep them in sync, so you know what is what.
If you really want to use a specific *build* SDK rather than the default (which *largely* means: the highest): that's what `global.json` can enable for you.
|
There's a difference between the .NET Core version Visual Studio (or Rider) uses for *building* the project and the version used for running the target application. By default, the latest installed version is used for building, and it runs against the version specified with the `<TargetFramework>` entry in the .csproj file. If the build works fine with .NET Core 5.0, I would stick with that, because it allows use of some advanced features even if targetting the old runtime.
If you have problems with 5.0 (there were some breaking changes even in the build infrastructure), you can create a file named `global.json` in the project root directory, telling the build system which SDK to use.
This `global.json` file ensures that the build uses the latest .NET Core 3.1 version:
```
{
"sdk": {
"version": "3.1.101",
"rollForward": "minor"
}
}
```
|
35,343,689 |
I have much data with several timestamps and I just recognized that some are in "dd.mm.YYYY" which works very well with `date("Y-m-d", strtotime($input));` but some are in "dd.mm.YY" and this does not work anymore - it always returns the current date.
My problem is that my data is too huge to fix this problem manually by editting. Is there any way to get the `YYYY-mm-dd` out of `mm.dd.YY` ?
|
2016/02/11
|
[
"https://Stackoverflow.com/questions/35343689",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1794338/"
] |
Here you go...
```
$date = "20.02.71"; // sample date... (common German format)
$date = DateTime::createFromFormat('d.m.y', $date);
echo $date->format('Y-m-d');
```
will result in:
>
> 1971-02-20
>
>
>
Create a DateTime object, then format it to anything you want...
|
Well you can replace the `.` by `-`, you could do something like the following:
```
$date = str_replace(".", "-", "mm.dd.YY")
```
This would return
```
mm-dd-YY
```
You could use [date\_parse\_from\_format](http://php.net/manual/en/function.date-parse-from-format.php) which would convert any formate into the formate you specify.
```
date_parse_from_format("y-m-d", $date);
```
It returns an array with very useful information like month, year etc.
|
41,021,730 |
I have this jQuery code
```
if (date != !date) {
console.log(date);
}
```
The `date` is an array, or `null`. If it's an array, I want to log it, if it is `null` I want to stop it right there. I thought the `!= !var` was exactly for this purpose. Still when I try this, I do also get `null` console logs. How come?
|
2016/12/07
|
[
"https://Stackoverflow.com/questions/41021730",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4632458/"
] |
Try this, it should catch everything in the else...
```
if(Array.isArray(date)){
console.log(date);
}
else {
console.log('not array');
}
```
|
Try this:
```
if (date){
console.log(date);
}
```
|
41,021,730 |
I have this jQuery code
```
if (date != !date) {
console.log(date);
}
```
The `date` is an array, or `null`. If it's an array, I want to log it, if it is `null` I want to stop it right there. I thought the `!= !var` was exactly for this purpose. Still when I try this, I do also get `null` console logs. How come?
|
2016/12/07
|
[
"https://Stackoverflow.com/questions/41021730",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4632458/"
] |
x is always not equal to !x (this is what `x!= !x` means).
You want something like : does x exist ? Is it null ?
```
if (date != null) {
console.log(date);
}
```
```js
var x1;
var x2 = [1,2];
if(x1 != null) // <- false
console.log(x1);
if(x2 != null) // <- true
console.log(x2);
```
|
Try this:
```
if (date){
console.log(date);
}
```
|
41,021,730 |
I have this jQuery code
```
if (date != !date) {
console.log(date);
}
```
The `date` is an array, or `null`. If it's an array, I want to log it, if it is `null` I want to stop it right there. I thought the `!= !var` was exactly for this purpose. Still when I try this, I do also get `null` console logs. How come?
|
2016/12/07
|
[
"https://Stackoverflow.com/questions/41021730",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4632458/"
] |
Try this, it should catch everything in the else...
```
if(Array.isArray(date)){
console.log(date);
}
else {
console.log('not array');
}
```
|
So you need to find out whether some value is an array or not. Here is another way to do this as recommended by the ECMAScript standard. For more infos about this see this post: [Check if object is array?](https://stackoverflow.com/questions/4775722/check-if-object-is-array)
```js
var date = ['one', 'two', 'three'];
var txt = "bla ... bla ...";
if( Object.prototype.toString.call( date ) === '[object Array]' ) {
console.log('is array');
} else {
console.log(' not an array');
}
if( Object.prototype.toString.call( txt ) === '[object Array]' ) {
console.log('is array');
} else {
console.log('is not an array');
}
```
|
41,021,730 |
I have this jQuery code
```
if (date != !date) {
console.log(date);
}
```
The `date` is an array, or `null`. If it's an array, I want to log it, if it is `null` I want to stop it right there. I thought the `!= !var` was exactly for this purpose. Still when I try this, I do also get `null` console logs. How come?
|
2016/12/07
|
[
"https://Stackoverflow.com/questions/41021730",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4632458/"
] |
x is always not equal to !x (this is what `x!= !x` means).
You want something like : does x exist ? Is it null ?
```
if (date != null) {
console.log(date);
}
```
```js
var x1;
var x2 = [1,2];
if(x1 != null) // <- false
console.log(x1);
if(x2 != null) // <- true
console.log(x2);
```
|
So you need to find out whether some value is an array or not. Here is another way to do this as recommended by the ECMAScript standard. For more infos about this see this post: [Check if object is array?](https://stackoverflow.com/questions/4775722/check-if-object-is-array)
```js
var date = ['one', 'two', 'three'];
var txt = "bla ... bla ...";
if( Object.prototype.toString.call( date ) === '[object Array]' ) {
console.log('is array');
} else {
console.log(' not an array');
}
if( Object.prototype.toString.call( txt ) === '[object Array]' ) {
console.log('is array');
} else {
console.log('is not an array');
}
```
|
44,654,101 |
I've built a nested flexbox grid that I'll be using for individual gateways. Currently, presumably due to the use of `outline`, the content within each container is running over into (and being hidden by) the whitespace surrounding each gateway, which acts as spacing between each div.
Is there a better way to handle the grid spacing, which allows me to ensure the content doesn't run over into the div outline? I've included a JSFiddle to illustrates the issue (seen best in the secondary & tertiary gateways).
JSFiddle here: <https://jsfiddle.net/graemebryson/6gehj4v7/>
**HTML**
```
<!-- Product Grid -->
<div class="flex-grid">
<div class="flex__direction--column">
<div class="flex__direction--row">
<!-- Primary Gateway -->
<div class="item item--primary">
<div class="item__description">
<h3>Primary Gateway</h3>
<p>It is a long established fact that a reader will be distracted by the readable.</p>
</div>
</div>
<div class="item flex__direction--column">
<!-- Secondary Gateway -->
<div class="item item--secondary">
<div class="item__description">
<h4>Secondary Gateway</h4>
<p>It is a long established fact that a reader will be distracted by the readable.</p>
</div>
</div>
<div class="item">
<div class="flex__direction--row">
<!-- Tertiary Gateway -->
<div class="item item--tertiary">
<div class="item__description">
<h5>Tertiary Gateway</h5>
<p>It is a long established fact that a reader will be distracted by the readable.</p>
</div>
</div>
<!-- Tertiary Gateway -->
<div class="item item--tertiary">
<div class="item__description">
<h5>Tertiary Gateway</h5>
<p>It is a long established fact that a reader will be distracted by the readable.</p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
```
**SCSS**
```
// Grid
.flex-grid {
.item {
flex: 1;
outline: 5px solid white;
min-height: 150px;
}
}
// Set Flex Direction - Column
.flex__direction--column {
display: flex;
flex-direction: column;
-ms-flex-direction: column;
-webkit-flex-direction: column;
}
// Set Flex Direction - Row
.flex__direction--row {
display: flex;
flex-direction: row;
-ms-flex-direction: row;
-webkit-flex-direction: row;
}
```
|
2017/06/20
|
[
"https://Stackoverflow.com/questions/44654101",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2291689/"
] |
You can get the functionality done with map/itertools.izip\_longest in python 2.x or itertools.zip\_longest in python 3.x
With that said,
* iterate through all elements in the result of map function
* for `each` sublist, you can use the sum() inbuilt function of python.
* to handle the none values, check if `None` is present in `each` variable. If present, then iterate through that sublist, every element `i` is checked if that is None, if so, then replace it with 0.
That is,
```
>>> addFn = lambda a,b: [sum(each) if None not in each else sum(i if i else 0 for i in each )for each in map(None,a,b)]
>>> addFn([1,2,3],[4])
[5, 2, 3]
>>> addFn(addFn([1,2,3],[4]),[7,3,0,2])
[12, 5, 3, 2]
```
And for the second functionality, if `l` if your list, then
For every element `i` in l, convert either numerator or denominator float and perform the operation!
```
>>> divByN = lambda l,N:[i/float(N) for i in l]
>>> divByN([5,6,7,8],2)
[2.5, 3.0, 3.5, 4.0]
```
As mentioned by Baldrickk, here is an example with itertools,
```
from itertools import izip_longest as izip_l
sum = [a+b for a,b in izip_l(arr1,arr2, fillvalue=0)]
```
|
```
import numpy as np
def Add(a, b):
a, b = map(np.array, (a, b))
if a.size > b.size:
a[:b.size] += b
return a
else:
b[:a.size] += a
return b
```
Example usage:
```
>>> Add([1,2], [3])
array([ 4., 2.])
>>> Add([0,0,0,2], _)
array([ 4., 2., 0., 2.])
```
The first line of the function is there to get a copy of these arrays converted to floating point, so you could divide without rounding later.
|
44,654,101 |
I've built a nested flexbox grid that I'll be using for individual gateways. Currently, presumably due to the use of `outline`, the content within each container is running over into (and being hidden by) the whitespace surrounding each gateway, which acts as spacing between each div.
Is there a better way to handle the grid spacing, which allows me to ensure the content doesn't run over into the div outline? I've included a JSFiddle to illustrates the issue (seen best in the secondary & tertiary gateways).
JSFiddle here: <https://jsfiddle.net/graemebryson/6gehj4v7/>
**HTML**
```
<!-- Product Grid -->
<div class="flex-grid">
<div class="flex__direction--column">
<div class="flex__direction--row">
<!-- Primary Gateway -->
<div class="item item--primary">
<div class="item__description">
<h3>Primary Gateway</h3>
<p>It is a long established fact that a reader will be distracted by the readable.</p>
</div>
</div>
<div class="item flex__direction--column">
<!-- Secondary Gateway -->
<div class="item item--secondary">
<div class="item__description">
<h4>Secondary Gateway</h4>
<p>It is a long established fact that a reader will be distracted by the readable.</p>
</div>
</div>
<div class="item">
<div class="flex__direction--row">
<!-- Tertiary Gateway -->
<div class="item item--tertiary">
<div class="item__description">
<h5>Tertiary Gateway</h5>
<p>It is a long established fact that a reader will be distracted by the readable.</p>
</div>
</div>
<!-- Tertiary Gateway -->
<div class="item item--tertiary">
<div class="item__description">
<h5>Tertiary Gateway</h5>
<p>It is a long established fact that a reader will be distracted by the readable.</p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
```
**SCSS**
```
// Grid
.flex-grid {
.item {
flex: 1;
outline: 5px solid white;
min-height: 150px;
}
}
// Set Flex Direction - Column
.flex__direction--column {
display: flex;
flex-direction: column;
-ms-flex-direction: column;
-webkit-flex-direction: column;
}
// Set Flex Direction - Row
.flex__direction--row {
display: flex;
flex-direction: row;
-ms-flex-direction: row;
-webkit-flex-direction: row;
}
```
|
2017/06/20
|
[
"https://Stackoverflow.com/questions/44654101",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2291689/"
] |
You can get the functionality done with map/itertools.izip\_longest in python 2.x or itertools.zip\_longest in python 3.x
With that said,
* iterate through all elements in the result of map function
* for `each` sublist, you can use the sum() inbuilt function of python.
* to handle the none values, check if `None` is present in `each` variable. If present, then iterate through that sublist, every element `i` is checked if that is None, if so, then replace it with 0.
That is,
```
>>> addFn = lambda a,b: [sum(each) if None not in each else sum(i if i else 0 for i in each )for each in map(None,a,b)]
>>> addFn([1,2,3],[4])
[5, 2, 3]
>>> addFn(addFn([1,2,3],[4]),[7,3,0,2])
[12, 5, 3, 2]
```
And for the second functionality, if `l` if your list, then
For every element `i` in l, convert either numerator or denominator float and perform the operation!
```
>>> divByN = lambda l,N:[i/float(N) for i in l]
>>> divByN([5,6,7,8],2)
[2.5, 3.0, 3.5, 4.0]
```
As mentioned by Baldrickk, here is an example with itertools,
```
from itertools import izip_longest as izip_l
sum = [a+b for a,b in izip_l(arr1,arr2, fillvalue=0)]
```
|
Another solution:
```
def add_shortest(a, b):
a = numpy.array(a)
b = numpy.array(b)
common_length = min(a.size, b.size)
a[:common_length] += b[:common_length]
return a
add_shortest(numpy.arange(2), numpy.arange(3)) # array([0, 2])
add_shortest(numpy.arange(3), numpy.arange(3)) # array([0, 2, 4])
add_shortest(numpy.arange(3), numpy.arange(2)) # array([0, 2, 2])
add_shortest(add_shortest([0, 0, 0, 2], add_shortest([1, 2], [3])), [3, 1]) # array([7, 3, 0, 2])
```
|
13,839,254 |
I am creating a child process and passing some arguments to it.
Now, the child process starts execution from the next line of code, but will I have to write another int main () separately for the child process, as below, or would it just use the already written code for int main() of the parent process?
```
createProcess(All required arguments);
if (pid == child_process)
{
int main ()
{
......
}
}
```
ENV: WinXP, VS2005
NOTE: The above code just describes the flow and may have syntax errors.
|
2012/12/12
|
[
"https://Stackoverflow.com/questions/13839254",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/966739/"
] |
Are you confusing Windows `CreateProcess` with UNIX `fork()`? The two operating systems are different in the way that processes are created. With Windows you have to execute an exe file from the beginning, you can't continue as the child process after `CreateProcess` as you can with `fork` on UNIX. Your statement "the child process starts execution from the next line of code" is mistaken for Windows.
Mind you, your code would be illegal on UNIX as well, you can't have two functions called main, and you can't have nested functions in C.
|
Please read the documentation of `[CreateProcess()](http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425%28v=vs.85%29.aspx)` again.
The function takes the filename of the program to run in the new process. The nested function you're showing is not valid C.
|
14,102,007 |
note that I am not asking what are the methods to convert lowercase letters to UPPERCASE letters in C++ but instead, I want to know which of these two methods in the codes below (Upper1 and Upper2) are better than the other one and what's the reason, programming wise.
```
#include <string>
#include <iostream>
#include <locale> //Upper2 requires this module
using namespace std;
void Upper1(string &inputStr);
void Upper2(string &inputStr);
int main(){
string test1 = "ABcdefgHIjklmno3434dfsdf3434PQRStuvwxyz";
string test2 = "ABcdefgHIjklmnoPQRStuvwxyz";
Upper1(test1);
cout << endl << endl << "test1 (Upper1): ";
for (int i = 0; i < test1.length(); i++){
cout << test1[i] << " ";
}
Upper2(test2);
cout << endl << endl << "test2 (Upper2): ";
for (int i = 0; i < test2.length(); i++){
cout << test2[i] << " ";
}
return 0;
}
void Upper1(string &test1){
for (int i = 0; i < 27; i++){
if (test1[i] > 96 && test1[i] <123){ //convert only those of lowercase letters
test1[i] = (char)(test1[i]-(char)32);
}
}
}
void Upper2(string &test2){
locale loc;
for (size_t i=0; i<test2.length(); ++i)
test2[i] = toupper(test2[i],loc);
}
```
|
2012/12/31
|
[
"https://Stackoverflow.com/questions/14102007",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1123627/"
] |
The main difference between the two proposed solutions is that
`Upper2` sort of works, regardless of the platform; `Upper1`
makes assumptions concerning the encoding, and doesn't work on
any modern platform that I know of. (It assumes ASCII, and
ASCII is, for all intents and purposes, dead.)
Of course, neither really works, for two simple reasons: the
first is that most modern machines use a multibyte encoding
(UTF-8), so you cannot convert a string from lower to upper one
byte at a time. The second is because there is not, generally
speaking, a one to one relationship of lower to upper: the
classical example is `'ß'`, whose upper case equivalent is the
two character string `"SS"`. Still, for a somewhat simplistic
definition of the function, and a single byte encoding like ISO
8859-1 (probably the most widely used in the recent past),
`Upper2` will do a reasonably good job (provided there is no `'ß'`
in the input), adequate for many uses, whereas `Upper1` will fail lamentably.
|
1. *toupper()* can handle non-ASCII character
2. Syntax wise, *Upper2()* is less error-prone
3. Not too sure about this, but i think *toupper()* is slower
|
14,102,007 |
note that I am not asking what are the methods to convert lowercase letters to UPPERCASE letters in C++ but instead, I want to know which of these two methods in the codes below (Upper1 and Upper2) are better than the other one and what's the reason, programming wise.
```
#include <string>
#include <iostream>
#include <locale> //Upper2 requires this module
using namespace std;
void Upper1(string &inputStr);
void Upper2(string &inputStr);
int main(){
string test1 = "ABcdefgHIjklmno3434dfsdf3434PQRStuvwxyz";
string test2 = "ABcdefgHIjklmnoPQRStuvwxyz";
Upper1(test1);
cout << endl << endl << "test1 (Upper1): ";
for (int i = 0; i < test1.length(); i++){
cout << test1[i] << " ";
}
Upper2(test2);
cout << endl << endl << "test2 (Upper2): ";
for (int i = 0; i < test2.length(); i++){
cout << test2[i] << " ";
}
return 0;
}
void Upper1(string &test1){
for (int i = 0; i < 27; i++){
if (test1[i] > 96 && test1[i] <123){ //convert only those of lowercase letters
test1[i] = (char)(test1[i]-(char)32);
}
}
}
void Upper2(string &test2){
locale loc;
for (size_t i=0; i<test2.length(); ++i)
test2[i] = toupper(test2[i],loc);
}
```
|
2012/12/31
|
[
"https://Stackoverflow.com/questions/14102007",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1123627/"
] |
The usage of toupper won't make sense if you have letters from other languages than English A-Z alphabet, e.g. the Germanic ä, ö or ü, and various accented letters in French/Spanish, and of course, if the input is a "germano-latin" language at all, for example Russian. [As pointed out by James, that may require Unicode parsing, which is a whole new ballgame altogether, tho']
Obviously, the first function is also hard-coded to convert the 27 first characters of the input, which is bad coding because the function shouldn't rely on the size of the string - particularly not since "std::string" does have a length in the first place!
|
1. *toupper()* can handle non-ASCII character
2. Syntax wise, *Upper2()* is less error-prone
3. Not too sure about this, but i think *toupper()* is slower
|
14,102,007 |
note that I am not asking what are the methods to convert lowercase letters to UPPERCASE letters in C++ but instead, I want to know which of these two methods in the codes below (Upper1 and Upper2) are better than the other one and what's the reason, programming wise.
```
#include <string>
#include <iostream>
#include <locale> //Upper2 requires this module
using namespace std;
void Upper1(string &inputStr);
void Upper2(string &inputStr);
int main(){
string test1 = "ABcdefgHIjklmno3434dfsdf3434PQRStuvwxyz";
string test2 = "ABcdefgHIjklmnoPQRStuvwxyz";
Upper1(test1);
cout << endl << endl << "test1 (Upper1): ";
for (int i = 0; i < test1.length(); i++){
cout << test1[i] << " ";
}
Upper2(test2);
cout << endl << endl << "test2 (Upper2): ";
for (int i = 0; i < test2.length(); i++){
cout << test2[i] << " ";
}
return 0;
}
void Upper1(string &test1){
for (int i = 0; i < 27; i++){
if (test1[i] > 96 && test1[i] <123){ //convert only those of lowercase letters
test1[i] = (char)(test1[i]-(char)32);
}
}
}
void Upper2(string &test2){
locale loc;
for (size_t i=0; i<test2.length(); ++i)
test2[i] = toupper(test2[i],loc);
}
```
|
2012/12/31
|
[
"https://Stackoverflow.com/questions/14102007",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1123627/"
] |
The main difference between the two proposed solutions is that
`Upper2` sort of works, regardless of the platform; `Upper1`
makes assumptions concerning the encoding, and doesn't work on
any modern platform that I know of. (It assumes ASCII, and
ASCII is, for all intents and purposes, dead.)
Of course, neither really works, for two simple reasons: the
first is that most modern machines use a multibyte encoding
(UTF-8), so you cannot convert a string from lower to upper one
byte at a time. The second is because there is not, generally
speaking, a one to one relationship of lower to upper: the
classical example is `'ß'`, whose upper case equivalent is the
two character string `"SS"`. Still, for a somewhat simplistic
definition of the function, and a single byte encoding like ISO
8859-1 (probably the most widely used in the recent past),
`Upper2` will do a reasonably good job (provided there is no `'ß'`
in the input), adequate for many uses, whereas `Upper1` will fail lamentably.
|
The usage of toupper won't make sense if you have letters from other languages than English A-Z alphabet, e.g. the Germanic ä, ö or ü, and various accented letters in French/Spanish, and of course, if the input is a "germano-latin" language at all, for example Russian. [As pointed out by James, that may require Unicode parsing, which is a whole new ballgame altogether, tho']
Obviously, the first function is also hard-coded to convert the 27 first characters of the input, which is bad coding because the function shouldn't rely on the size of the string - particularly not since "std::string" does have a length in the first place!
|
52,199,599 |
I'm trying to convert a Visual SourceSafe Repository to Git while keeping the exact version history. So I've tried using <https://github.com/trevorr/vss2git>. It worked, but it didn't keep the history. So I tried using TFS as a middleman. I used The latest version of TFS and its upgrade wizard but it didn't keep the history, so I tried with TFS 2013 ([How to migrate VSS 2005 to TFS 2015?](https://stackoverflow.com/questions/38092930/how-to-migrate-vss-2005-to-tfs-2015)) and its upgrade wizard, but still no history. I'm pretty desperate now, and I don't know where the problem lies, as I even analyzed my VSS repository, and no errors were found. I've read that I could also try using SVN as the middleman, so I'll do that, but I'm skeptic.
|
2018/09/06
|
[
"https://Stackoverflow.com/questions/52199599",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9789912/"
] |
You can try <https://github.com/azarkevich/VssSvnConverter>, but it is not user friendly.
(Despite it`s name it can convert VSS to Git)
Also this tool does not keep history of file/directory moves/renames. File will have history with latest name.
|
I've found the solution, and the programs I used do work. It's just that I tried to move too much data, so it would just glitch and not store the history. I'm not sure exactly the amount of data I can safely move, but I now have a history
|
52,199,599 |
I'm trying to convert a Visual SourceSafe Repository to Git while keeping the exact version history. So I've tried using <https://github.com/trevorr/vss2git>. It worked, but it didn't keep the history. So I tried using TFS as a middleman. I used The latest version of TFS and its upgrade wizard but it didn't keep the history, so I tried with TFS 2013 ([How to migrate VSS 2005 to TFS 2015?](https://stackoverflow.com/questions/38092930/how-to-migrate-vss-2005-to-tfs-2015)) and its upgrade wizard, but still no history. I'm pretty desperate now, and I don't know where the problem lies, as I even analyzed my VSS repository, and no errors were found. I've read that I could also try using SVN as the middleman, so I'll do that, but I'm skeptic.
|
2018/09/06
|
[
"https://Stackoverflow.com/questions/52199599",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9789912/"
] |
Here is the solution which worked for me a couple years ago. When I tried the mentioned vss2git, it has blown our 9GB vss database in 103GB over a weekend without reaching the end.
So I took the TFS server (2010) as middleman and it worked. The TFS 2010 could import VSS database directly, I am not sure about newer ones. Simultaneously, the TFS can serve as a git remote using git-tf, or git-tfs for example. After the import, simple `git tfs clone` has done the second part of the business. So here you go:
1. Get a TFS version capable of VSS import. This [link](https://learn.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2013/ms253060(v=vs.120)) can help you.
2. Use the wizard, or command line to import your VSS database.
3. Get git-tfs from [here](https://github.com/git-tfs/git-tfs)
4. (Optionally) fix the commit dates - see below.
5. Do something like this `git tfs clone http://tfs:8080/tfs/DefaultCollection $/some_project`
The only quirk I can remember was that the TFS has set the date of all commits to current date and has put the original vss dates into the comments. I have fixed this directly in the SQLEXPRESS database of the TFS like this:
```
UPDATE tbl_ChangeSet
SET CreationDate = CONVERT (datetime, Substring(Comment,2,19), 104)
Where CreationDate > '2014-01-28' AND Comment LIKE '{%'
```
Please put your own date (of the last VSS comit) into the query.
<https://learn.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2013/ms253060(v=vs.120)>
|
You can try <https://github.com/azarkevich/VssSvnConverter>, but it is not user friendly.
(Despite it`s name it can convert VSS to Git)
Also this tool does not keep history of file/directory moves/renames. File will have history with latest name.
|
52,199,599 |
I'm trying to convert a Visual SourceSafe Repository to Git while keeping the exact version history. So I've tried using <https://github.com/trevorr/vss2git>. It worked, but it didn't keep the history. So I tried using TFS as a middleman. I used The latest version of TFS and its upgrade wizard but it didn't keep the history, so I tried with TFS 2013 ([How to migrate VSS 2005 to TFS 2015?](https://stackoverflow.com/questions/38092930/how-to-migrate-vss-2005-to-tfs-2015)) and its upgrade wizard, but still no history. I'm pretty desperate now, and I don't know where the problem lies, as I even analyzed my VSS repository, and no errors were found. I've read that I could also try using SVN as the middleman, so I'll do that, but I'm skeptic.
|
2018/09/06
|
[
"https://Stackoverflow.com/questions/52199599",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9789912/"
] |
Here is the solution which worked for me a couple years ago. When I tried the mentioned vss2git, it has blown our 9GB vss database in 103GB over a weekend without reaching the end.
So I took the TFS server (2010) as middleman and it worked. The TFS 2010 could import VSS database directly, I am not sure about newer ones. Simultaneously, the TFS can serve as a git remote using git-tf, or git-tfs for example. After the import, simple `git tfs clone` has done the second part of the business. So here you go:
1. Get a TFS version capable of VSS import. This [link](https://learn.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2013/ms253060(v=vs.120)) can help you.
2. Use the wizard, or command line to import your VSS database.
3. Get git-tfs from [here](https://github.com/git-tfs/git-tfs)
4. (Optionally) fix the commit dates - see below.
5. Do something like this `git tfs clone http://tfs:8080/tfs/DefaultCollection $/some_project`
The only quirk I can remember was that the TFS has set the date of all commits to current date and has put the original vss dates into the comments. I have fixed this directly in the SQLEXPRESS database of the TFS like this:
```
UPDATE tbl_ChangeSet
SET CreationDate = CONVERT (datetime, Substring(Comment,2,19), 104)
Where CreationDate > '2014-01-28' AND Comment LIKE '{%'
```
Please put your own date (of the last VSS comit) into the query.
<https://learn.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2013/ms253060(v=vs.120)>
|
I've found the solution, and the programs I used do work. It's just that I tried to move too much data, so it would just glitch and not store the history. I'm not sure exactly the amount of data I can safely move, but I now have a history
|
49,476,176 |
I know it is possible to use TextureView in ExoPlayer. But I cannot find any sample on how to implement this functionality in a proper way. Could you please help me on this issue?
|
2018/03/25
|
[
"https://Stackoverflow.com/questions/49476176",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4671981/"
] |
The `PlayerView` has an xml attribute `surface_type` which let's you choose whether you want to use a `SurfaceView` or a `TextureView`.
(Note: `SimpleExoPlayerView` has been renamed to `PlayerView` in recent versions since it only depends on the `Player` interface and not on SimpelExoPlayerView anymore.)
You can choose texture\_view, surface\_view (default) or none. See [the main section of the JavaDoc of PlayerView](https://google.github.io/ExoPlayer/doc/reference/com/google/android/exoplayer2/ui/PlayerView.html) for details.
```
<com.google.android.exoplayer2.ui.PlayerView android:id="@+id/player_view"
app:surface_type="texture_view"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
```
|
From [the documentation](https://google.github.io/ExoPlayer/guide.html):
>
> If you require fine-grained control over the player controls and the `Surface` onto which video is rendered, you can set the player’s target `SurfaceView`, `TextureView`, `SurfaceHolder` or `Surface` directly using SimpleExoPlayer’s `setVideoSurfaceView`, `setVideoTextureView`, `setVideoSurfaceHolder` and `setVideoSurface` methods respectively.
>
>
>
So the relevant part here would be the `setVideoTextureView()`. Something like:
```
SimpleExoPlayer player = ExoPlayerFactory.newSimpleInstance(context, trackSelector);
TexturView textureView = findViewById(texture_view);
player.setVideoTextureView(textureView);
```
You can also create a `Surface` from a `SurfaceTexture` which you can get through `TextureView`'s `setSurfaceTextureViewListener()`. See [TextureView's documentation](https://developer.android.com/reference/android/view/TextureView.html) and [this post](https://stackoverflow.com/questions/30971534/textureview-get-surface). And then you could call `setSurface(...)` on the player.
But you shouldn't really need to do this anymore now that `SimpleExoPlayer` has the `TextureView` setter (we didn't always have this in old ExoPlayer). Also as another reference, here's [the issue on ExoPlayer](https://github.com/google/ExoPlayer/issues/98) about supporting this.
As a side note, you can see the differences between `SurfaceView` and `TextureView` [here](https://google.github.io/ExoPlayer/faqs.html#should-i-use-surfaceview-or-textureview). The general recommendation is to use a `SurfaceView`, but there are nuances.
[EDIT]
If you want to do it on the fly, you can instantiate the `SimpleExoPlayer` (not `SimpleExoPlayerView`) like I've written above, and then call `setPlayer(...)` on your `PlayerView` (which you could have defined in XML or dynamically).
If you don't need to set the surface/texture view on the fly, then you can just set it on the `PlayerView` in the layout XML via `app:surface_type="texture_view"`.
|
49,476,176 |
I know it is possible to use TextureView in ExoPlayer. But I cannot find any sample on how to implement this functionality in a proper way. Could you please help me on this issue?
|
2018/03/25
|
[
"https://Stackoverflow.com/questions/49476176",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4671981/"
] |
From [the documentation](https://google.github.io/ExoPlayer/guide.html):
>
> If you require fine-grained control over the player controls and the `Surface` onto which video is rendered, you can set the player’s target `SurfaceView`, `TextureView`, `SurfaceHolder` or `Surface` directly using SimpleExoPlayer’s `setVideoSurfaceView`, `setVideoTextureView`, `setVideoSurfaceHolder` and `setVideoSurface` methods respectively.
>
>
>
So the relevant part here would be the `setVideoTextureView()`. Something like:
```
SimpleExoPlayer player = ExoPlayerFactory.newSimpleInstance(context, trackSelector);
TexturView textureView = findViewById(texture_view);
player.setVideoTextureView(textureView);
```
You can also create a `Surface` from a `SurfaceTexture` which you can get through `TextureView`'s `setSurfaceTextureViewListener()`. See [TextureView's documentation](https://developer.android.com/reference/android/view/TextureView.html) and [this post](https://stackoverflow.com/questions/30971534/textureview-get-surface). And then you could call `setSurface(...)` on the player.
But you shouldn't really need to do this anymore now that `SimpleExoPlayer` has the `TextureView` setter (we didn't always have this in old ExoPlayer). Also as another reference, here's [the issue on ExoPlayer](https://github.com/google/ExoPlayer/issues/98) about supporting this.
As a side note, you can see the differences between `SurfaceView` and `TextureView` [here](https://google.github.io/ExoPlayer/faqs.html#should-i-use-surfaceview-or-textureview). The general recommendation is to use a `SurfaceView`, but there are nuances.
[EDIT]
If you want to do it on the fly, you can instantiate the `SimpleExoPlayer` (not `SimpleExoPlayerView`) like I've written above, and then call `setPlayer(...)` on your `PlayerView` (which you could have defined in XML or dynamically).
If you don't need to set the surface/texture view on the fly, then you can just set it on the `PlayerView` in the layout XML via `app:surface_type="texture_view"`.
|
Note, `TextureView` can only be used in a hardware accelerated window. When rendered in software, TextureView will draw nothing. so after set surface type
```
<com.google.android.exoplayer2.ui.PlayerView android:id="@+id/player_view"
app:surface_type="texture_view"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
```
you need to make sure that hardware acceleration is enabled, go to manifest file and ad this line
* At application level: `<application android:hardwareAccelerated="true" ...>`
|
49,476,176 |
I know it is possible to use TextureView in ExoPlayer. But I cannot find any sample on how to implement this functionality in a proper way. Could you please help me on this issue?
|
2018/03/25
|
[
"https://Stackoverflow.com/questions/49476176",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4671981/"
] |
The `PlayerView` has an xml attribute `surface_type` which let's you choose whether you want to use a `SurfaceView` or a `TextureView`.
(Note: `SimpleExoPlayerView` has been renamed to `PlayerView` in recent versions since it only depends on the `Player` interface and not on SimpelExoPlayerView anymore.)
You can choose texture\_view, surface\_view (default) or none. See [the main section of the JavaDoc of PlayerView](https://google.github.io/ExoPlayer/doc/reference/com/google/android/exoplayer2/ui/PlayerView.html) for details.
```
<com.google.android.exoplayer2.ui.PlayerView android:id="@+id/player_view"
app:surface_type="texture_view"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
```
|
Note, `TextureView` can only be used in a hardware accelerated window. When rendered in software, TextureView will draw nothing. so after set surface type
```
<com.google.android.exoplayer2.ui.PlayerView android:id="@+id/player_view"
app:surface_type="texture_view"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
```
you need to make sure that hardware acceleration is enabled, go to manifest file and ad this line
* At application level: `<application android:hardwareAccelerated="true" ...>`
|
141,378 |
How can I add custom classes for links into main menu in Drupal 8. This is template for my main menu called `menu--main.html.twig`
```
{% import _self as menus %}
{{ menus.menu_links(items, attributes, 0) }}
{% macro menu_links(items, attributes, menu_level) %}
{% import _self as menus %}
{% if items %}
{% if menu_level == 0 %}
<ul{{ attributes.addClass('main-nav') }}>
{% for item in items %}
<li{{ item.attributes.addClass('main-nav__item') }}>
{{ link(item.title, item.url) }}
{% if item.below %}
{{ menus.menu_links(item.below, attributes, menu_level + 1) }}
{% endif %}
</li>
{% endfor %}
{% else %}
<ul class="main-nav__sub js-nav-submenu ">
{% for item in items %}
<li{{ item.attributes.addClass('main-nav__sub-item') }}>
{{ link(item.title, item.url) }}
{% if item.below %}
{{ menus.menu_links(item.below, attributes, menu_level + 1) }}
{% endif %}
</li>
{% endfor %}
{% endif %}
</ul>
{% endif %}
{% endmacro %}
```
And I need to achieve this result:
```
<ul class="main-nav">
<li class="main-nav__item"><a class="main-nav__link main-nav__link--active" href="index.html">Úvod</a></li>
<li class="main-nav__item"><a class="main-nav__link js-nav-submenu-toggler" href="#">O škole</a>
<ul class="main-nav__sub js-nav-submenu">
<li class="main-nav__sub-item"><a class="main-nav__sub-link" href="#">Aktuality</a></li>
<li class="main-nav__sub-item"><a class="main-nav__sub-link " href="pedagogovia.html">Pedagógovia</a></li>
<li class="main-nav__sub-item"><a class="main-nav__sub-link" href="#">Dokumenty</a></li>
<li class="main-nav__sub-item"><a class="main-nav__sub-link " href="historia.html">História</a></li>
</ul>
</li>
<li class="main-nav__item"><a class="main-nav__link" href="#">Informácie o štúdiu</a></li>
<li class="main-nav__item"><a class="main-nav__link" href="#">Fotogaléria</a></li>
<li class="main-nav__item"><a class="main-nav__link " href="kontakt.html">Kontakt</a></li>
</ul>
```
My problem is that I don't know how to set custom class for `<a href="">` tags. Is there any way how can do it using `link()` function. In Drupal 7 is `l()` function but attributes aren't similar. `l()` has also third attribute with possibility to add options. Is it true, that `link($title, $url)` accepts only 2 parameters? Because I can't find the way how to send options for `link($title, $url)`. I don't insit on `link()` function, so if there is some better way please let me know. I'm open to new ideas :)
Thanks
|
2014/12/21
|
[
"https://drupal.stackexchange.com/questions/141378",
"https://drupal.stackexchange.com",
"https://drupal.stackexchange.com/users/24385/"
] |
I finally solved it using next syntax in Twig template
```
{{ link(item.title, item.url.setOptions({'set_active_class' : TRUE, 'attributes' : {'class' : 'main-nav__link'}})) }}
```
|
file name
/var/www/html/drupal/themes/theme\_name/templates/navigation/menu.html.twig
we are checking menu name in if condition
{% if menu\_name ==’account’ %}
below is the whole code you may copy and replace it
```
{#
/**
* @file
* Theme override to display a menu.
*
* Available variables:
* - menu_name: The machine name of the menu.
* - items: A nested list of menu items. Each menu item contains:
* - attributes: HTML attributes for the menu item.
* - below: The menu item child items.
* - title: The menu link title.
* - url: The menu link url, instance of \Drupal\Core\Url
* - localized_options: Menu link localized options.
* - is_expanded: TRUE if the link has visible children within the current
* menu tree.
* - is_collapsed: TRUE if the link has children within the current menu tree
* that are not currently visible.
* - in_active_trail: TRUE if the link is in the active trail.
*/
#}
{% import _self as menus %}
{#
We call a macro which calls itself to render the full tree.
@see http://twig.sensiolabs.org/doc/tags/macro.html
#}
{{ menus.menu_links(items, attributes, 0,menu_name) }}
{% macro menu_links(items, attributes, menu_level,menu_name) %}
{% import _self as menus %}
{% if items %}
{% if menu_level == 0 %}
{% if menu_name =='account' %}
<ul{{ attributes.addClass('') }}>
{% endif %}
{% if menu_name =='main' %}
<ul{{ attributes.addClass('menu nav navbar-nav') }}>
{% endif %}
{% else %}
<ul{{ attributes.addClass('menu nav navbar-nav') }}>
{% endif %}
{% for item in items %}
{%
set classes = [
'menu-item',
item.is_expanded ? 'menu-item--expanded',
item.is_collapsed ? 'menu-item--collapsed',
item.in_active_trail ? 'menu-item--active-trail',
]
%}
<li{{ item.attributes.addClass(classes) }}>
{{ link(item.title, item.url) }}
{% if item.below %}
{{ menus.menu_links(item.below, attributes, menu_level + 1) }}
{% endif %}
</li>
{% endfor %}
</ul>
{% endif %}
{% endmacro %}
```
|
141,378 |
How can I add custom classes for links into main menu in Drupal 8. This is template for my main menu called `menu--main.html.twig`
```
{% import _self as menus %}
{{ menus.menu_links(items, attributes, 0) }}
{% macro menu_links(items, attributes, menu_level) %}
{% import _self as menus %}
{% if items %}
{% if menu_level == 0 %}
<ul{{ attributes.addClass('main-nav') }}>
{% for item in items %}
<li{{ item.attributes.addClass('main-nav__item') }}>
{{ link(item.title, item.url) }}
{% if item.below %}
{{ menus.menu_links(item.below, attributes, menu_level + 1) }}
{% endif %}
</li>
{% endfor %}
{% else %}
<ul class="main-nav__sub js-nav-submenu ">
{% for item in items %}
<li{{ item.attributes.addClass('main-nav__sub-item') }}>
{{ link(item.title, item.url) }}
{% if item.below %}
{{ menus.menu_links(item.below, attributes, menu_level + 1) }}
{% endif %}
</li>
{% endfor %}
{% endif %}
</ul>
{% endif %}
{% endmacro %}
```
And I need to achieve this result:
```
<ul class="main-nav">
<li class="main-nav__item"><a class="main-nav__link main-nav__link--active" href="index.html">Úvod</a></li>
<li class="main-nav__item"><a class="main-nav__link js-nav-submenu-toggler" href="#">O škole</a>
<ul class="main-nav__sub js-nav-submenu">
<li class="main-nav__sub-item"><a class="main-nav__sub-link" href="#">Aktuality</a></li>
<li class="main-nav__sub-item"><a class="main-nav__sub-link " href="pedagogovia.html">Pedagógovia</a></li>
<li class="main-nav__sub-item"><a class="main-nav__sub-link" href="#">Dokumenty</a></li>
<li class="main-nav__sub-item"><a class="main-nav__sub-link " href="historia.html">História</a></li>
</ul>
</li>
<li class="main-nav__item"><a class="main-nav__link" href="#">Informácie o štúdiu</a></li>
<li class="main-nav__item"><a class="main-nav__link" href="#">Fotogaléria</a></li>
<li class="main-nav__item"><a class="main-nav__link " href="kontakt.html">Kontakt</a></li>
</ul>
```
My problem is that I don't know how to set custom class for `<a href="">` tags. Is there any way how can do it using `link()` function. In Drupal 7 is `l()` function but attributes aren't similar. `l()` has also third attribute with possibility to add options. Is it true, that `link($title, $url)` accepts only 2 parameters? Because I can't find the way how to send options for `link($title, $url)`. I don't insit on `link()` function, so if there is some better way please let me know. I'm open to new ideas :)
Thanks
|
2014/12/21
|
[
"https://drupal.stackexchange.com/questions/141378",
"https://drupal.stackexchange.com",
"https://drupal.stackexchange.com/users/24385/"
] |
Just incase someone stumbles upon this, Martin's solve above breaks URL fragments as it overrides the URL options completely. The better approach is here:
```
{{ link(item.title, item.url.setOption('attributes', {'class' : 'main-nav__link'})) }}
```
|
file name
/var/www/html/drupal/themes/theme\_name/templates/navigation/menu.html.twig
we are checking menu name in if condition
{% if menu\_name ==’account’ %}
below is the whole code you may copy and replace it
```
{#
/**
* @file
* Theme override to display a menu.
*
* Available variables:
* - menu_name: The machine name of the menu.
* - items: A nested list of menu items. Each menu item contains:
* - attributes: HTML attributes for the menu item.
* - below: The menu item child items.
* - title: The menu link title.
* - url: The menu link url, instance of \Drupal\Core\Url
* - localized_options: Menu link localized options.
* - is_expanded: TRUE if the link has visible children within the current
* menu tree.
* - is_collapsed: TRUE if the link has children within the current menu tree
* that are not currently visible.
* - in_active_trail: TRUE if the link is in the active trail.
*/
#}
{% import _self as menus %}
{#
We call a macro which calls itself to render the full tree.
@see http://twig.sensiolabs.org/doc/tags/macro.html
#}
{{ menus.menu_links(items, attributes, 0,menu_name) }}
{% macro menu_links(items, attributes, menu_level,menu_name) %}
{% import _self as menus %}
{% if items %}
{% if menu_level == 0 %}
{% if menu_name =='account' %}
<ul{{ attributes.addClass('') }}>
{% endif %}
{% if menu_name =='main' %}
<ul{{ attributes.addClass('menu nav navbar-nav') }}>
{% endif %}
{% else %}
<ul{{ attributes.addClass('menu nav navbar-nav') }}>
{% endif %}
{% for item in items %}
{%
set classes = [
'menu-item',
item.is_expanded ? 'menu-item--expanded',
item.is_collapsed ? 'menu-item--collapsed',
item.in_active_trail ? 'menu-item--active-trail',
]
%}
<li{{ item.attributes.addClass(classes) }}>
{{ link(item.title, item.url) }}
{% if item.below %}
{{ menus.menu_links(item.below, attributes, menu_level + 1) }}
{% endif %}
</li>
{% endfor %}
</ul>
{% endif %}
{% endmacro %}
```
|
141,378 |
How can I add custom classes for links into main menu in Drupal 8. This is template for my main menu called `menu--main.html.twig`
```
{% import _self as menus %}
{{ menus.menu_links(items, attributes, 0) }}
{% macro menu_links(items, attributes, menu_level) %}
{% import _self as menus %}
{% if items %}
{% if menu_level == 0 %}
<ul{{ attributes.addClass('main-nav') }}>
{% for item in items %}
<li{{ item.attributes.addClass('main-nav__item') }}>
{{ link(item.title, item.url) }}
{% if item.below %}
{{ menus.menu_links(item.below, attributes, menu_level + 1) }}
{% endif %}
</li>
{% endfor %}
{% else %}
<ul class="main-nav__sub js-nav-submenu ">
{% for item in items %}
<li{{ item.attributes.addClass('main-nav__sub-item') }}>
{{ link(item.title, item.url) }}
{% if item.below %}
{{ menus.menu_links(item.below, attributes, menu_level + 1) }}
{% endif %}
</li>
{% endfor %}
{% endif %}
</ul>
{% endif %}
{% endmacro %}
```
And I need to achieve this result:
```
<ul class="main-nav">
<li class="main-nav__item"><a class="main-nav__link main-nav__link--active" href="index.html">Úvod</a></li>
<li class="main-nav__item"><a class="main-nav__link js-nav-submenu-toggler" href="#">O škole</a>
<ul class="main-nav__sub js-nav-submenu">
<li class="main-nav__sub-item"><a class="main-nav__sub-link" href="#">Aktuality</a></li>
<li class="main-nav__sub-item"><a class="main-nav__sub-link " href="pedagogovia.html">Pedagógovia</a></li>
<li class="main-nav__sub-item"><a class="main-nav__sub-link" href="#">Dokumenty</a></li>
<li class="main-nav__sub-item"><a class="main-nav__sub-link " href="historia.html">História</a></li>
</ul>
</li>
<li class="main-nav__item"><a class="main-nav__link" href="#">Informácie o štúdiu</a></li>
<li class="main-nav__item"><a class="main-nav__link" href="#">Fotogaléria</a></li>
<li class="main-nav__item"><a class="main-nav__link " href="kontakt.html">Kontakt</a></li>
</ul>
```
My problem is that I don't know how to set custom class for `<a href="">` tags. Is there any way how can do it using `link()` function. In Drupal 7 is `l()` function but attributes aren't similar. `l()` has also third attribute with possibility to add options. Is it true, that `link($title, $url)` accepts only 2 parameters? Because I can't find the way how to send options for `link($title, $url)`. I don't insit on `link()` function, so if there is some better way please let me know. I'm open to new ideas :)
Thanks
|
2014/12/21
|
[
"https://drupal.stackexchange.com/questions/141378",
"https://drupal.stackexchange.com",
"https://drupal.stackexchange.com/users/24385/"
] |
Just replace
```
{{ link(item.title, item.url) }}
```
by
```
{{ link(item.title, item.url, { 'class':['main-nav__link']}) }}
```
|
file name
/var/www/html/drupal/themes/theme\_name/templates/navigation/menu.html.twig
we are checking menu name in if condition
{% if menu\_name ==’account’ %}
below is the whole code you may copy and replace it
```
{#
/**
* @file
* Theme override to display a menu.
*
* Available variables:
* - menu_name: The machine name of the menu.
* - items: A nested list of menu items. Each menu item contains:
* - attributes: HTML attributes for the menu item.
* - below: The menu item child items.
* - title: The menu link title.
* - url: The menu link url, instance of \Drupal\Core\Url
* - localized_options: Menu link localized options.
* - is_expanded: TRUE if the link has visible children within the current
* menu tree.
* - is_collapsed: TRUE if the link has children within the current menu tree
* that are not currently visible.
* - in_active_trail: TRUE if the link is in the active trail.
*/
#}
{% import _self as menus %}
{#
We call a macro which calls itself to render the full tree.
@see http://twig.sensiolabs.org/doc/tags/macro.html
#}
{{ menus.menu_links(items, attributes, 0,menu_name) }}
{% macro menu_links(items, attributes, menu_level,menu_name) %}
{% import _self as menus %}
{% if items %}
{% if menu_level == 0 %}
{% if menu_name =='account' %}
<ul{{ attributes.addClass('') }}>
{% endif %}
{% if menu_name =='main' %}
<ul{{ attributes.addClass('menu nav navbar-nav') }}>
{% endif %}
{% else %}
<ul{{ attributes.addClass('menu nav navbar-nav') }}>
{% endif %}
{% for item in items %}
{%
set classes = [
'menu-item',
item.is_expanded ? 'menu-item--expanded',
item.is_collapsed ? 'menu-item--collapsed',
item.in_active_trail ? 'menu-item--active-trail',
]
%}
<li{{ item.attributes.addClass(classes) }}>
{{ link(item.title, item.url) }}
{% if item.below %}
{{ menus.menu_links(item.below, attributes, menu_level + 1) }}
{% endif %}
</li>
{% endfor %}
</ul>
{% endif %}
{% endmacro %}
```
|
70,001,069 |
I am trying to extract a specific value from a JSON column in SQL Server. Unfortunately I have read several posts on this topic but still cannot figure out how to translate their solutions to what I need. I am looking to extract "foo testing" but simply do not understand how to get at this with a nested JSON. Can someone please advise?
The structure of the JSON column is:
```
{
"values": [
{
"id": "x01",
"status": "STATUS1",
"subStatus": "SubStatus1",
"values": [
{
"key": "dropdown",
"value": "",
"optionType": null
}
]
},
...
{
"id": "x03",
"status": "STATUS3",
"subStatus": "SubStatus3",
"values": [
{
"key": "dropdown",
"value": "",
"optionType": null
},
{
"key": "textInput",
"value": null,
"optionType": null
},
{
"key": "checkbox1",
"value": true,
"optionType": null
},
{
"key": "textInput2",
"value": "foo testing",
"optionType": null
}
]
}
]
}
```
|
2021/11/17
|
[
"https://Stackoverflow.com/questions/70001069",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6100400/"
] |
The statement depends on the structure of the parsed JSON, in your case you need to use two nested `OPENJSON()` calls and additinal `APPLY` operators. Note, that you need to use `AS JSON` in a `"values"` column definition to specify that the referenced property contains an inner JSON array and the type of that column must be `nvarchar(max)`.
Test table:
```
DECLARE @json varchar(max) = '
{
"values": [
{
"id": "x01",
"status": "STATUS1",
"subStatus": "SubStatus1",
"values": [
{"key": "dropdown", "value": "", "optionType": null}
]
},
{
"id": "x03",
"status": "STATUS3",
"subStatus": "SubStatus3",
"values": [
{"key": "dropdown", "value": "", "optionType": null},
{"key": "textInput", "value": null, "optionType": null},
{"key": "checkbox1", "value": true, "optionType": null},
{"key": "textInput2", "value": "foo testing", "optionType": null}
]
}
]
}
'
SELECT JsonColumn
INTO JsonTable
FROM (VALUES (@json)) v (JsonColumn)
```
Statement:
```
SELECT j1.[id], j2.[key], j2.[value] -- or add all columns
FROM JsonTable t
CROSS APPLY OPENJSON(t.JsonColumn, '$.values') WITH (
[id] varchar(3) '$.id',
[status] varchar(30) '$.status',
[subStatus] varchar(30) '$.subStatus',
[values] nvarchar(max) '$.values' AS JSON
) j1
CROSS APPLY OPENJSON(j1.[values], '$') WITH (
[key] varchar(50) '$.key',
[value] varchar(50) '$.value',
[optionType] varchar(50) '$.optionType'
) j2
```
Result:
```
id key value
---------------------------
x01 dropdown
x03 dropdown
x03 textInput
x03 checkbox1 true
x03 textInput2 foo testing
```
|
you can use following query
```
;with summery as(
SELECT *
FROM OPENJSON((SELECT value FROM OPENJSON(@json)))
WITH (
id NVARCHAR(50) 'strict $.id',
status NVARCHAR(50) '$.status',
subStatus NVARCHAR(50) '$.subStatus',
[values] NVARCHAR(max) '$.values' AS JSON
)
)
select id,status,subStatus,[key],value,optionType from summery
CROSS APPLY OPENJSON(summery.[values])
WITH (
[key] NVARCHAR(50) '$.key',
[value] NVARCHAR(50) '$.value',
[optionType] NVARCHAR(50) '$.optionType'
);
```
*demo in [db<>fiddle](https://dbfiddle.uk/?rdbms=sqlserver_2019&fiddle=ef34206281bec08d5f284cdc13e4d835)*
|
10,915,734 |
Have anyone experienced this error, from the Apple's developer console?

The strange thing is that according to the next screen, everything has been perfect:

At last, my push notification does not work, and I wonder If the problem comes from this "error".
**EDIT :**
It comes just after uploading the `CertificateSigningRequest.certSigningRequest`file generated by the Keychain Access application.
|
2012/06/06
|
[
"https://Stackoverflow.com/questions/10915734",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/127493/"
] |
I have found a workaround for this:
```
sub vcl_fetch {
// Fix a strange problem: HTTP 301 redirects to the same page sometimes go in$
if (beresp.http.Location == "http://" + req.http.host + req.url) {
if (req.restarts > 2) {
unset beresp.http.Location;
#set beresp.http.X-Restarts = req.restarts;
} else {
return (restart);
}
}
}
```
I give the backend a second (and thirhd) chance to return a proper page. If that fails as well, the Location header is removed. This works, because the proper page is served with just an additional invalid Location header.
|
The accepted answer by @philip updated for Varnish 4:
```
sub vcl_backend_response {
#Fix a strange problem: HTTP 301 redirects to the same page sometimes go in$
if (beresp.http.Location == "http://" + bereq.http.host + bereq.url) {
if (bereq.retries > 2) {
unset beresp.http.Location;
#set beresp.http.X-Restarts = bereq.retries;
} else {
return (retry);
}
}
}
```
|
28,704,867 |
In a PowerShell window:
```none
PS C:\> echo -abc.def.ghi
-abc
.def.ghi
```
For some reason, the combination of a hyphen and period cause Powershell to split the argument into two lines.
It does not occur with without the hyphen:
```none
PS C:\> echo abc.def.ghi
abc.def.ghi
```
Nor does it occur when there are no periods:
```none
PS C:\> echo -abcdefghi
-abcdefghi
```
Through experimentation, I've found I can escape the behavior with a backtick:
```none
PS C:\> echo `-abc.def.ghi
-abc.def.ghi
```
But *why* does this occur? What fundamental part of PowerShell syntax am I not understanding?
|
2015/02/24
|
[
"https://Stackoverflow.com/questions/28704867",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/634824/"
] |
I've disassembled Microsoft.PowerShell.Utility to look at the code of `Write-Output` nothing special there, it just iterates through InputObject and passes each to a `WriteObject` method implemented by the current `ICommandRuntime`.

My guess is that the tokenizer that process the text tries to match anything starting with a `-` to a declared parameter. Failing that, it passes it through the pipeline as an item in `-InputObject`. Since a `.` cannot be a part of a variable name and therefore can't be part of a switch name it might separate it before doing the if check and when it turns out to be a parameter it doesn't join it back up with the rest of the token. You might therefore have found a minor bug.
When using the back tick or quotation marks it doesn't make this mistake however since it can tokenize the entire thing.
This is all conjecture though, I'd love to see a authoritative answer as much as you.
**Edit**
Evidence of what I'm saying:
```
PS> echo -NoEnumerate.foo
.foo
```
|
FYI not sure if George was trying to mention this or not but `echo` is an alias for `Write-Output` in PowerShell.
```
PS C:\temp> Get-Alias echo
CommandType Name ModuleName
----------- ---- ----------
Alias echo -> Write-Output
```
In the example `echo -abc.def.ghi` the parser sees the unquoted hyphen as the prefix for a parameter/switch name. Period also has special meaning. Parameters cannot contain periods so the parser is treating that like the string terminator.
As a whole `write-output` sees it as an array so it is matched positionally to -InputObject
(I hope i'm not totally wrong with my assertions.)
|
97,845 |
This is for a book. An ancient, badly damaged, base has been found in the asteroid belt. The base has been open to the vacuum of space, although a large proportion of the base is within the body of the asteroid and not on the surface, so has been protected from solar radiations and micro-meteor impacts.
I wanted the protagonists to discover remains in the base that will allow them to get a rough age but I don't know the limits of carbon dating or if it would even be possible, given the overall conditions caused by a hard vacuum. I don't know if carbon dating is a viable option and, if it isn't, does another another field of science offer a plausible way of getting to the age of the base?
Note -
The base is tens of millions of years old and the majority of it is buried deep under the surface of the asteroid.
The technology basis for the protagonist is roughly fifty years advanced from current day earth. Two major changes are hydrogen-based power units have replaced all fossil fuels and inter-solar system travel is viable but only just starting using ships powered by EM Drives.
The technology basis for the base builders is highly advanced; viable interstellar travel capabilities, for example.
Not sure I understand the reasons for this being put on hold as it would appear to fit in to the "Effects of events or world elements, including biology, technology and magic, on specific aspects of that world's societies, cultures, and environment" caveat of the exchanges rules.
Can you please explain what I am misunderstanding ?
* Edited for spelling, clarity and on hold clarification.
|
2017/11/14
|
[
"https://worldbuilding.stackexchange.com/questions/97845",
"https://worldbuilding.stackexchange.com",
"https://worldbuilding.stackexchange.com/users/44392/"
] |
Extra-solar and extra-terrestrial material is very hard to date, which works for you
====================================================================================
To elaborate on @Gawainuk's comment: **all** [radiometric dating](https://en.wikipedia.org/wiki/Radiometric_dating) (\*) of objects hinges on that you have a good estimate — a "baseline" — of how radioactive a material was when that material was "fixed" in the object.
On Earth this is comparatively "easy". But out in space, this can become really tricky, especially so if the material has its origins outside our solar system. Further complicating this is that ionizing cosmic radiation affects how radioactive materials are, adding a significant count of radiation that messes up the baseline. On Earth our atmosphere decreases this effect significantly, but it is still significant enough that we must consider it.
For your purposes, what your protagonists can do is to compare material found deep inside the base, that can be concluded had its origins on the surface of the same asteroid. A simple geological and then chemical analysis can conclude this with ease. They then do a radiometric comparison with surface material that stayed exposed to cosmic radiation, with the material that was deep inside, and thus shielded. With this your protagonists can get a ballpark figure of the age of the base that puts them within one or two magnitudes of its true age, i.e. "My best guess says this is between 10 and 100 million years old, my worst at 5 to 500 million".
(\*) **Carbon dating** is one of several ways of performing radiometric dating.
There are other substances apart from carbon we can do this on, providing different time scales, ranging from decades to billions of years
|
**[One option is to use meteorite impacts](https://pseudoastro.wordpress.com/2008/10/21/dating-planetary-surfaces-with-craters-why-there-is-no-crisis-in-crater-count-dating/)**
miteorite [dating](https://pseudoastro.wordpress.com/2008/10/21/dating-planetary-surfaces-with-craters-why-there-is-no-crisis-in-crater-count-dating/) is usually used to date large impact basins and other planetary structures. It tends to use impacts caused by large objects of tens to hundreds of meters or more in diameter, but there is no reason why this technique shouldn’t be extended to micrometeorites on any surface.
Over thousands of years meteorites would cause a roughening of surfaces in general and pitting in places. Depending on the size of the surface installation and the exact amount of time, a few larger impacts might be seen that were capable of making holes in the outer structural material.
Statistical analysis of the size distribution of such micro craters could provide an estimate of the age of the installation assuming that the structure would have been installed impact free from new materials. The background level of expected impacts could be discovered from examining the surface of the asteroid that was not covered by the base or other nearby planetary bodies using traditional techniques as well as radioisotope dating.
|
97,845 |
This is for a book. An ancient, badly damaged, base has been found in the asteroid belt. The base has been open to the vacuum of space, although a large proportion of the base is within the body of the asteroid and not on the surface, so has been protected from solar radiations and micro-meteor impacts.
I wanted the protagonists to discover remains in the base that will allow them to get a rough age but I don't know the limits of carbon dating or if it would even be possible, given the overall conditions caused by a hard vacuum. I don't know if carbon dating is a viable option and, if it isn't, does another another field of science offer a plausible way of getting to the age of the base?
Note -
The base is tens of millions of years old and the majority of it is buried deep under the surface of the asteroid.
The technology basis for the protagonist is roughly fifty years advanced from current day earth. Two major changes are hydrogen-based power units have replaced all fossil fuels and inter-solar system travel is viable but only just starting using ships powered by EM Drives.
The technology basis for the base builders is highly advanced; viable interstellar travel capabilities, for example.
Not sure I understand the reasons for this being put on hold as it would appear to fit in to the "Effects of events or world elements, including biology, technology and magic, on specific aspects of that world's societies, cultures, and environment" caveat of the exchanges rules.
Can you please explain what I am misunderstanding ?
* Edited for spelling, clarity and on hold clarification.
|
2017/11/14
|
[
"https://worldbuilding.stackexchange.com/questions/97845",
"https://worldbuilding.stackexchange.com",
"https://worldbuilding.stackexchange.com/users/44392/"
] |
Extra-solar and extra-terrestrial material is very hard to date, which works for you
====================================================================================
To elaborate on @Gawainuk's comment: **all** [radiometric dating](https://en.wikipedia.org/wiki/Radiometric_dating) (\*) of objects hinges on that you have a good estimate — a "baseline" — of how radioactive a material was when that material was "fixed" in the object.
On Earth this is comparatively "easy". But out in space, this can become really tricky, especially so if the material has its origins outside our solar system. Further complicating this is that ionizing cosmic radiation affects how radioactive materials are, adding a significant count of radiation that messes up the baseline. On Earth our atmosphere decreases this effect significantly, but it is still significant enough that we must consider it.
For your purposes, what your protagonists can do is to compare material found deep inside the base, that can be concluded had its origins on the surface of the same asteroid. A simple geological and then chemical analysis can conclude this with ease. They then do a radiometric comparison with surface material that stayed exposed to cosmic radiation, with the material that was deep inside, and thus shielded. With this your protagonists can get a ballpark figure of the age of the base that puts them within one or two magnitudes of its true age, i.e. "My best guess says this is between 10 and 100 million years old, my worst at 5 to 500 million".
(\*) **Carbon dating** is one of several ways of performing radiometric dating.
There are other substances apart from carbon we can do this on, providing different time scales, ranging from decades to billions of years
|
**Date the base by accumulation of solar wind particles.**
The solar wind moves out from the sun and hits everything in the solar system. Our magnetosphere and atmosphere deflect most of the fast moving charged particles. In places like the moon without that protection, fast moving particles hit and accumulate. In this article they examined accumulations of neon isotopes deposited by the solar wind on the moon and on a spacecraft.
<https://www.newscientist.com/article/dn10595-solar-wind-particles-solve-lunar-mystery/>
>
> For the last 4 billion years, energetic solar particles have bombarded
> the Moon. But studies of these particles in rocks brought back by the
> Apollo astronauts have mystified scientists.
>
>
> That is because the ratio of two isotopes of neon have varied
> according to depth in the rocks, with comparatively more neon-22 than
> neon-20 at lower depths. That suggested that counter to theory, the
> Sun had once been significantly more active than it is today, shooting
> out higher energy particles that could travel farther into the rocks.
>
>
> Now, Ansgar Grimberg at the Swiss Federal Institute of Technology
> (ETH) in Zurich, and colleagues have resolved the conundrum.
>
>
> They used nitric acid to strip away layers of a specially made
> metallic glass that had been exposed to the solar wind for 27 months
> on the Genesis spacecraft, which crashed to Earth in 2004.
>
>
> When they measured the neon distribution in the exposed solar wind
> samples, they found the top layer had considerably higher proportions
> of neon-20 than observed in the lunar samples, while the underlying
> layers were similar to those seen in the Moon rocks.
>
>
> That suggests that erosion from micrometeorites and space particles
> removed some of the original neon from the top surface of all lunar
> rocks.
>
>
> More importantly, it also shows that the solar wind alone – not any
> extra activity on the Sun – can explain the puzzling neon variations
> in the Moon rocks, with the heavier neon-22 simply implanting itself
> more deeply than neon-20.
>
>
>
The sun ejects lots of particles including massive ones like xenon. Any number of different stable elements could be used and it makes sense to use more than one. One can extrapolate from the above article that the more massive the particle, the deeper it goes when it hits that makes sense as the massive particles have more kinetic energy. The base will have particles implanted in it no matter how deep. If it is very deep it will be more massive particles than light ones, but they will be there. Given a known rate of particle deposition by the solar wind you can calculate the age of the base by the amount of particles which have been deposited there by the solar wind.
|
97,845 |
This is for a book. An ancient, badly damaged, base has been found in the asteroid belt. The base has been open to the vacuum of space, although a large proportion of the base is within the body of the asteroid and not on the surface, so has been protected from solar radiations and micro-meteor impacts.
I wanted the protagonists to discover remains in the base that will allow them to get a rough age but I don't know the limits of carbon dating or if it would even be possible, given the overall conditions caused by a hard vacuum. I don't know if carbon dating is a viable option and, if it isn't, does another another field of science offer a plausible way of getting to the age of the base?
Note -
The base is tens of millions of years old and the majority of it is buried deep under the surface of the asteroid.
The technology basis for the protagonist is roughly fifty years advanced from current day earth. Two major changes are hydrogen-based power units have replaced all fossil fuels and inter-solar system travel is viable but only just starting using ships powered by EM Drives.
The technology basis for the base builders is highly advanced; viable interstellar travel capabilities, for example.
Not sure I understand the reasons for this being put on hold as it would appear to fit in to the "Effects of events or world elements, including biology, technology and magic, on specific aspects of that world's societies, cultures, and environment" caveat of the exchanges rules.
Can you please explain what I am misunderstanding ?
* Edited for spelling, clarity and on hold clarification.
|
2017/11/14
|
[
"https://worldbuilding.stackexchange.com/questions/97845",
"https://worldbuilding.stackexchange.com",
"https://worldbuilding.stackexchange.com/users/44392/"
] |
Extra-solar and extra-terrestrial material is very hard to date, which works for you
====================================================================================
To elaborate on @Gawainuk's comment: **all** [radiometric dating](https://en.wikipedia.org/wiki/Radiometric_dating) (\*) of objects hinges on that you have a good estimate — a "baseline" — of how radioactive a material was when that material was "fixed" in the object.
On Earth this is comparatively "easy". But out in space, this can become really tricky, especially so if the material has its origins outside our solar system. Further complicating this is that ionizing cosmic radiation affects how radioactive materials are, adding a significant count of radiation that messes up the baseline. On Earth our atmosphere decreases this effect significantly, but it is still significant enough that we must consider it.
For your purposes, what your protagonists can do is to compare material found deep inside the base, that can be concluded had its origins on the surface of the same asteroid. A simple geological and then chemical analysis can conclude this with ease. They then do a radiometric comparison with surface material that stayed exposed to cosmic radiation, with the material that was deep inside, and thus shielded. With this your protagonists can get a ballpark figure of the age of the base that puts them within one or two magnitudes of its true age, i.e. "My best guess says this is between 10 and 100 million years old, my worst at 5 to 500 million".
(\*) **Carbon dating** is one of several ways of performing radiometric dating.
There are other substances apart from carbon we can do this on, providing different time scales, ranging from decades to billions of years
|
There are a large number of problems with this scenario. First things first Carbon-14 Dating tops out at around 50,000 years. Second Carbon-14 dating relies on the fact that Earth has a steady rate of Carbon-14 creation and terrestrial creatures have a predictable rate of carbon uptake, thus dates in the nuclear age are skewed by fallout from atmospheric testing. Thirdly exposure to vacuum has some strange and unpredictable effects on organic material that would be hard to factor in. Fourth, any radiological dating will be "messed up beyond all recognition" (that's a technical term) by exposure to cosmic radiation outside the shielding of a thick atmosphere and strong magnetosphere.
So that's things you can't easily use, you can possibly use the rate of decay of the construction materials *in vacuum* as a benchmark for the age of the site since that will be fairly uniform, for a given material.
|
97,845 |
This is for a book. An ancient, badly damaged, base has been found in the asteroid belt. The base has been open to the vacuum of space, although a large proportion of the base is within the body of the asteroid and not on the surface, so has been protected from solar radiations and micro-meteor impacts.
I wanted the protagonists to discover remains in the base that will allow them to get a rough age but I don't know the limits of carbon dating or if it would even be possible, given the overall conditions caused by a hard vacuum. I don't know if carbon dating is a viable option and, if it isn't, does another another field of science offer a plausible way of getting to the age of the base?
Note -
The base is tens of millions of years old and the majority of it is buried deep under the surface of the asteroid.
The technology basis for the protagonist is roughly fifty years advanced from current day earth. Two major changes are hydrogen-based power units have replaced all fossil fuels and inter-solar system travel is viable but only just starting using ships powered by EM Drives.
The technology basis for the base builders is highly advanced; viable interstellar travel capabilities, for example.
Not sure I understand the reasons for this being put on hold as it would appear to fit in to the "Effects of events or world elements, including biology, technology and magic, on specific aspects of that world's societies, cultures, and environment" caveat of the exchanges rules.
Can you please explain what I am misunderstanding ?
* Edited for spelling, clarity and on hold clarification.
|
2017/11/14
|
[
"https://worldbuilding.stackexchange.com/questions/97845",
"https://worldbuilding.stackexchange.com",
"https://worldbuilding.stackexchange.com/users/44392/"
] |
Carbon dating is problematic, as you need to know level of Carbon 14 in the atmosphere at the time the animal or plant you are studying died. But there are other radiometric dating methods which might work.
The simplest thing would perhaps be if they found a machine similar to a [radioisotope thermoelectric generator](https://en.wikipedia.org/wiki/Radioisotope_thermoelectric_generator), which is a device that uses a radioactive substance to create electricity. It is today used to power interplanetary probes, among other things.
If the protagonists find a device powered by say plutonium-238, they can look at the ratio of plutonium, uranium and lead to infer the number of years since the plutonium was refined. This is similar to [uranium-lead dating](https://en.wikipedia.org/wiki/Uranium%E2%80%93lead_dating) which is a dating method that can determine the age of rocks that are from a million year old to several billion.
The base may also have a derelict nuclear reactor, similar to that of nuclear-powered submarines today. You can have the protagonists do a similar analysis here.
*Edit: A generator using Americum-241 makes for more straightforward dating, see discussion below*
|
There are a large number of problems with this scenario. First things first Carbon-14 Dating tops out at around 50,000 years. Second Carbon-14 dating relies on the fact that Earth has a steady rate of Carbon-14 creation and terrestrial creatures have a predictable rate of carbon uptake, thus dates in the nuclear age are skewed by fallout from atmospheric testing. Thirdly exposure to vacuum has some strange and unpredictable effects on organic material that would be hard to factor in. Fourth, any radiological dating will be "messed up beyond all recognition" (that's a technical term) by exposure to cosmic radiation outside the shielding of a thick atmosphere and strong magnetosphere.
So that's things you can't easily use, you can possibly use the rate of decay of the construction materials *in vacuum* as a benchmark for the age of the site since that will be fairly uniform, for a given material.
|
97,845 |
This is for a book. An ancient, badly damaged, base has been found in the asteroid belt. The base has been open to the vacuum of space, although a large proportion of the base is within the body of the asteroid and not on the surface, so has been protected from solar radiations and micro-meteor impacts.
I wanted the protagonists to discover remains in the base that will allow them to get a rough age but I don't know the limits of carbon dating or if it would even be possible, given the overall conditions caused by a hard vacuum. I don't know if carbon dating is a viable option and, if it isn't, does another another field of science offer a plausible way of getting to the age of the base?
Note -
The base is tens of millions of years old and the majority of it is buried deep under the surface of the asteroid.
The technology basis for the protagonist is roughly fifty years advanced from current day earth. Two major changes are hydrogen-based power units have replaced all fossil fuels and inter-solar system travel is viable but only just starting using ships powered by EM Drives.
The technology basis for the base builders is highly advanced; viable interstellar travel capabilities, for example.
Not sure I understand the reasons for this being put on hold as it would appear to fit in to the "Effects of events or world elements, including biology, technology and magic, on specific aspects of that world's societies, cultures, and environment" caveat of the exchanges rules.
Can you please explain what I am misunderstanding ?
* Edited for spelling, clarity and on hold clarification.
|
2017/11/14
|
[
"https://worldbuilding.stackexchange.com/questions/97845",
"https://worldbuilding.stackexchange.com",
"https://worldbuilding.stackexchange.com/users/44392/"
] |
How about if an artifact is found that dates the base. Something like a calendar left by the occupants of the base and one of your characters puzzles out how to read it. Maybe something related to position of the stars relative to the solar system or something.
|
**Date the base by accumulation of solar wind particles.**
The solar wind moves out from the sun and hits everything in the solar system. Our magnetosphere and atmosphere deflect most of the fast moving charged particles. In places like the moon without that protection, fast moving particles hit and accumulate. In this article they examined accumulations of neon isotopes deposited by the solar wind on the moon and on a spacecraft.
<https://www.newscientist.com/article/dn10595-solar-wind-particles-solve-lunar-mystery/>
>
> For the last 4 billion years, energetic solar particles have bombarded
> the Moon. But studies of these particles in rocks brought back by the
> Apollo astronauts have mystified scientists.
>
>
> That is because the ratio of two isotopes of neon have varied
> according to depth in the rocks, with comparatively more neon-22 than
> neon-20 at lower depths. That suggested that counter to theory, the
> Sun had once been significantly more active than it is today, shooting
> out higher energy particles that could travel farther into the rocks.
>
>
> Now, Ansgar Grimberg at the Swiss Federal Institute of Technology
> (ETH) in Zurich, and colleagues have resolved the conundrum.
>
>
> They used nitric acid to strip away layers of a specially made
> metallic glass that had been exposed to the solar wind for 27 months
> on the Genesis spacecraft, which crashed to Earth in 2004.
>
>
> When they measured the neon distribution in the exposed solar wind
> samples, they found the top layer had considerably higher proportions
> of neon-20 than observed in the lunar samples, while the underlying
> layers were similar to those seen in the Moon rocks.
>
>
> That suggests that erosion from micrometeorites and space particles
> removed some of the original neon from the top surface of all lunar
> rocks.
>
>
> More importantly, it also shows that the solar wind alone – not any
> extra activity on the Sun – can explain the puzzling neon variations
> in the Moon rocks, with the heavier neon-22 simply implanting itself
> more deeply than neon-20.
>
>
>
The sun ejects lots of particles including massive ones like xenon. Any number of different stable elements could be used and it makes sense to use more than one. One can extrapolate from the above article that the more massive the particle, the deeper it goes when it hits that makes sense as the massive particles have more kinetic energy. The base will have particles implanted in it no matter how deep. If it is very deep it will be more massive particles than light ones, but they will be there. Given a known rate of particle deposition by the solar wind you can calculate the age of the base by the amount of particles which have been deposited there by the solar wind.
|
97,845 |
This is for a book. An ancient, badly damaged, base has been found in the asteroid belt. The base has been open to the vacuum of space, although a large proportion of the base is within the body of the asteroid and not on the surface, so has been protected from solar radiations and micro-meteor impacts.
I wanted the protagonists to discover remains in the base that will allow them to get a rough age but I don't know the limits of carbon dating or if it would even be possible, given the overall conditions caused by a hard vacuum. I don't know if carbon dating is a viable option and, if it isn't, does another another field of science offer a plausible way of getting to the age of the base?
Note -
The base is tens of millions of years old and the majority of it is buried deep under the surface of the asteroid.
The technology basis for the protagonist is roughly fifty years advanced from current day earth. Two major changes are hydrogen-based power units have replaced all fossil fuels and inter-solar system travel is viable but only just starting using ships powered by EM Drives.
The technology basis for the base builders is highly advanced; viable interstellar travel capabilities, for example.
Not sure I understand the reasons for this being put on hold as it would appear to fit in to the "Effects of events or world elements, including biology, technology and magic, on specific aspects of that world's societies, cultures, and environment" caveat of the exchanges rules.
Can you please explain what I am misunderstanding ?
* Edited for spelling, clarity and on hold clarification.
|
2017/11/14
|
[
"https://worldbuilding.stackexchange.com/questions/97845",
"https://worldbuilding.stackexchange.com",
"https://worldbuilding.stackexchange.com/users/44392/"
] |
Extra-solar and extra-terrestrial material is very hard to date, which works for you
====================================================================================
To elaborate on @Gawainuk's comment: **all** [radiometric dating](https://en.wikipedia.org/wiki/Radiometric_dating) (\*) of objects hinges on that you have a good estimate — a "baseline" — of how radioactive a material was when that material was "fixed" in the object.
On Earth this is comparatively "easy". But out in space, this can become really tricky, especially so if the material has its origins outside our solar system. Further complicating this is that ionizing cosmic radiation affects how radioactive materials are, adding a significant count of radiation that messes up the baseline. On Earth our atmosphere decreases this effect significantly, but it is still significant enough that we must consider it.
For your purposes, what your protagonists can do is to compare material found deep inside the base, that can be concluded had its origins on the surface of the same asteroid. A simple geological and then chemical analysis can conclude this with ease. They then do a radiometric comparison with surface material that stayed exposed to cosmic radiation, with the material that was deep inside, and thus shielded. With this your protagonists can get a ballpark figure of the age of the base that puts them within one or two magnitudes of its true age, i.e. "My best guess says this is between 10 and 100 million years old, my worst at 5 to 500 million".
(\*) **Carbon dating** is one of several ways of performing radiometric dating.
There are other substances apart from carbon we can do this on, providing different time scales, ranging from decades to billions of years
|
How about if an artifact is found that dates the base. Something like a calendar left by the occupants of the base and one of your characters puzzles out how to read it. Maybe something related to position of the stars relative to the solar system or something.
|
97,845 |
This is for a book. An ancient, badly damaged, base has been found in the asteroid belt. The base has been open to the vacuum of space, although a large proportion of the base is within the body of the asteroid and not on the surface, so has been protected from solar radiations and micro-meteor impacts.
I wanted the protagonists to discover remains in the base that will allow them to get a rough age but I don't know the limits of carbon dating or if it would even be possible, given the overall conditions caused by a hard vacuum. I don't know if carbon dating is a viable option and, if it isn't, does another another field of science offer a plausible way of getting to the age of the base?
Note -
The base is tens of millions of years old and the majority of it is buried deep under the surface of the asteroid.
The technology basis for the protagonist is roughly fifty years advanced from current day earth. Two major changes are hydrogen-based power units have replaced all fossil fuels and inter-solar system travel is viable but only just starting using ships powered by EM Drives.
The technology basis for the base builders is highly advanced; viable interstellar travel capabilities, for example.
Not sure I understand the reasons for this being put on hold as it would appear to fit in to the "Effects of events or world elements, including biology, technology and magic, on specific aspects of that world's societies, cultures, and environment" caveat of the exchanges rules.
Can you please explain what I am misunderstanding ?
* Edited for spelling, clarity and on hold clarification.
|
2017/11/14
|
[
"https://worldbuilding.stackexchange.com/questions/97845",
"https://worldbuilding.stackexchange.com",
"https://worldbuilding.stackexchange.com/users/44392/"
] |
How about if an artifact is found that dates the base. Something like a calendar left by the occupants of the base and one of your characters puzzles out how to read it. Maybe something related to position of the stars relative to the solar system or something.
|
**[One option is to use meteorite impacts](https://pseudoastro.wordpress.com/2008/10/21/dating-planetary-surfaces-with-craters-why-there-is-no-crisis-in-crater-count-dating/)**
miteorite [dating](https://pseudoastro.wordpress.com/2008/10/21/dating-planetary-surfaces-with-craters-why-there-is-no-crisis-in-crater-count-dating/) is usually used to date large impact basins and other planetary structures. It tends to use impacts caused by large objects of tens to hundreds of meters or more in diameter, but there is no reason why this technique shouldn’t be extended to micrometeorites on any surface.
Over thousands of years meteorites would cause a roughening of surfaces in general and pitting in places. Depending on the size of the surface installation and the exact amount of time, a few larger impacts might be seen that were capable of making holes in the outer structural material.
Statistical analysis of the size distribution of such micro craters could provide an estimate of the age of the installation assuming that the structure would have been installed impact free from new materials. The background level of expected impacts could be discovered from examining the surface of the asteroid that was not covered by the base or other nearby planetary bodies using traditional techniques as well as radioisotope dating.
|
97,845 |
This is for a book. An ancient, badly damaged, base has been found in the asteroid belt. The base has been open to the vacuum of space, although a large proportion of the base is within the body of the asteroid and not on the surface, so has been protected from solar radiations and micro-meteor impacts.
I wanted the protagonists to discover remains in the base that will allow them to get a rough age but I don't know the limits of carbon dating or if it would even be possible, given the overall conditions caused by a hard vacuum. I don't know if carbon dating is a viable option and, if it isn't, does another another field of science offer a plausible way of getting to the age of the base?
Note -
The base is tens of millions of years old and the majority of it is buried deep under the surface of the asteroid.
The technology basis for the protagonist is roughly fifty years advanced from current day earth. Two major changes are hydrogen-based power units have replaced all fossil fuels and inter-solar system travel is viable but only just starting using ships powered by EM Drives.
The technology basis for the base builders is highly advanced; viable interstellar travel capabilities, for example.
Not sure I understand the reasons for this being put on hold as it would appear to fit in to the "Effects of events or world elements, including biology, technology and magic, on specific aspects of that world's societies, cultures, and environment" caveat of the exchanges rules.
Can you please explain what I am misunderstanding ?
* Edited for spelling, clarity and on hold clarification.
|
2017/11/14
|
[
"https://worldbuilding.stackexchange.com/questions/97845",
"https://worldbuilding.stackexchange.com",
"https://worldbuilding.stackexchange.com/users/44392/"
] |
Extra-solar and extra-terrestrial material is very hard to date, which works for you
====================================================================================
To elaborate on @Gawainuk's comment: **all** [radiometric dating](https://en.wikipedia.org/wiki/Radiometric_dating) (\*) of objects hinges on that you have a good estimate — a "baseline" — of how radioactive a material was when that material was "fixed" in the object.
On Earth this is comparatively "easy". But out in space, this can become really tricky, especially so if the material has its origins outside our solar system. Further complicating this is that ionizing cosmic radiation affects how radioactive materials are, adding a significant count of radiation that messes up the baseline. On Earth our atmosphere decreases this effect significantly, but it is still significant enough that we must consider it.
For your purposes, what your protagonists can do is to compare material found deep inside the base, that can be concluded had its origins on the surface of the same asteroid. A simple geological and then chemical analysis can conclude this with ease. They then do a radiometric comparison with surface material that stayed exposed to cosmic radiation, with the material that was deep inside, and thus shielded. With this your protagonists can get a ballpark figure of the age of the base that puts them within one or two magnitudes of its true age, i.e. "My best guess says this is between 10 and 100 million years old, my worst at 5 to 500 million".
(\*) **Carbon dating** is one of several ways of performing radiometric dating.
There are other substances apart from carbon we can do this on, providing different time scales, ranging from decades to billions of years
|
Carbon dating is problematic, as you need to know level of Carbon 14 in the atmosphere at the time the animal or plant you are studying died. But there are other radiometric dating methods which might work.
The simplest thing would perhaps be if they found a machine similar to a [radioisotope thermoelectric generator](https://en.wikipedia.org/wiki/Radioisotope_thermoelectric_generator), which is a device that uses a radioactive substance to create electricity. It is today used to power interplanetary probes, among other things.
If the protagonists find a device powered by say plutonium-238, they can look at the ratio of plutonium, uranium and lead to infer the number of years since the plutonium was refined. This is similar to [uranium-lead dating](https://en.wikipedia.org/wiki/Uranium%E2%80%93lead_dating) which is a dating method that can determine the age of rocks that are from a million year old to several billion.
The base may also have a derelict nuclear reactor, similar to that of nuclear-powered submarines today. You can have the protagonists do a similar analysis here.
*Edit: A generator using Americum-241 makes for more straightforward dating, see discussion below*
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.