qid int64 1 74.7M | question stringlengths 15 58.3k | date stringlengths 10 10 | metadata list | response_j stringlengths 4 30.2k | response_k stringlengths 11 36.5k |
|---|---|---|---|---|---|
2,908,402 | Let $f$ be continuous real-valued function on $[0,1]$ and
\begin{align} F(x)=\max\{f(t):0\leq t\leq x\}. \end{align}
I want to show that $F(x)$ is also continuous on $[0,1]$.
**MY WORK**
Let $\epsilon> 0$ be given and $x\_0\in [0,1].$ Since f is continuous at $x\_0\in [0,1],$ then $\forall x\in [0,1]$ with $|x-x\_... | 2018/09/07 | [
"https://math.stackexchange.com/questions/2908402",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/586973/"
] | $$let \int\_{0}^{2014}{\frac{\sqrt{2014-x}}{\sqrt{x}+\sqrt{2014-x}}dx}=A \\ put \ 2014-x=u \\ \implies \int\_{0}^{2014}{\frac{\sqrt{2014-x}}{\sqrt{x}+\sqrt{2014-x}}dx}=\int\_{2014}^{0}{\frac{\sqrt{u}}{\sqrt{u}+\sqrt{2014-u}}(-du)}\\=\int\_{0}^{2014}{\frac{\sqrt{u}}{\sqrt{u}+\sqrt{2014-u}}(du)}=A \\ add \ both \ integra... | Don't need to do that substitution again and again just apply this formula
$$\int\_a^bf(x)~dx=\int\_a^bf(a+b-x)~dx$$
$$I=\int\_{0}^{2014}{\frac{\sqrt{2014-x}}{\sqrt{x}+\sqrt{2014-x}}dx}$$
Apply the formula
$$\int\_a^bf(x)~dx=\int\_a^bf(a+b-x)~dx$$
$$ I=\int\_{0}^{2014}{\frac{\sqrt{2014-(2014+0-x)}}{\sqrt{2014+0-x... |
25,952,573 | I am having some trouble understanding the use of two predicates in a single line without an "and" or an "or" in Racket. Here is an example, with a comment where I'm confused:
```
(define (question x)
(cond
[(cond
[(even? x) (< 20 x)] ; what is this doing? Are they both being evaluated at once?
[else (e... | 2014/09/20 | [
"https://Stackoverflow.com/questions/25952573",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4040244/"
] | `cond` clauses have the following form:
```
(<test> <result> ...)
```
In this case, the `<test>` is `(cond [(even? x) (< 20 x)] [else (even? x)])` and the `<result>` is `(cond [(odd? x) 'day] [else 'night])`.
The overall code, if I read it correctly, is the same as
```
(define (question x)
(cond ((and (even? x) ... | ```
(cond
[(even? x) (< 20 x)]
[else (even? x)])
```
In another language, such as ruby, this could be written as:
```
if x.even?
x < 20
else
x.even?
end
``` |
22,973,963 | I'm trying to use delayed\_job to have the background job to process the lengthy tasks but in my controller when I added the delay job there is a pretty significant delayed, from less then 50ms to over 1000ms and it's not what I expected. Does anyone experience this problem and know the workaround for this?
<https://g... | 2014/04/09 | [
"https://Stackoverflow.com/questions/22973963",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1661552/"
] | Delayed Job is database based, so if you'r DB is under load that could explain why it takes from 50 to 1000ms.
Take a look at Sidekiq, it uses Redis to handle the queues so your performance wont be tied to the DB. | There is a config called `sleep_delay` which means when there is no job in queue, delayed\_job would go to sleep in [sleep\_time] secs, i.e., the first job inserted in the empty queue may be delayed in [sleep\_delay] secs and it happens frequently if your queue is always in empty. Try to tune this config and see the si... |
35,333,179 | From **Template.myTemplate.rendered** function (or from other template functions), I want to call other util function. Not sure how to do it in Meteor way.
I tried
```
Template.myTemplate.rendered = function(){
console.log("chat Interface rendered");
Template.myTemplate.__helpers.get('someFunction');
};
Te... | 2016/02/11 | [
"https://Stackoverflow.com/questions/35333179",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1463072/"
] | In my opinion, you are misusing [template helpers](http://docs.meteor.com/#/full/template_helpers). In general, they are used to get data into templates and not to control UI elements.
As a result, I recommend to create a regular JavaScript function and subsequently call it inside your `onRendered` callback:
```
func... | You can create a meteor method and use it everywhere in your code. You can also call methods from other methods.
```
Meteor.methods({
someMethod: function (param) {
//do stuff
}
});
var result = Meteor.call('someMethod', param);
``` |
69,954,483 | I've got 2 functions each for specific button, which on of them finds random number and I want second function to only use that number without generating it again. I've tried to do in many ways, now my code is a little experimental but I didn't find a proper way to do it.
```
public partial class Form1 : Form
{
pu... | 2021/11/13 | [
"https://Stackoverflow.com/questions/69954483",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17403299/"
] | the answer of tia is correct:
```
public partial class Form1 : Form
{
public int ShuffleNor(int l)
{
int r = 0;
string[] nor = File.ReadAllLines(@"C:\Users\Kapi\Desktop\no.txt").ToArray();
Random rnd = new Random();
r = rnd.Next(0, nor.Length);
lbl_nor.Text = nor[r];
... | Declare a variable at class scope:
```
public partial class Form1 : Form
{
private int r;
public int ShuffleNor(int l)
{
r = 0;
[...]
```
If you make it public it will be visible to code that references instances of the class object. If you make it static, the same value/storage is used by all inst... |
2,072,693 | Suppose I have a matrix function $A(t)$ with $$\lVert A(t) - B\rVert \le ct^\alpha$$ in some matrix norm (this will work for any norm, I guess). So, in a sense $A(t)\rightarrow B$ for $t\rightarrow 0$ in $\mathcal{O}(t^\alpha)$. Plus, we have $A(0) = B$.
I happen to know the eigenvalues of $B$, but I don't know a thin... | 2016/12/26 | [
"https://math.stackexchange.com/questions/2072693",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/402051/"
] | Parts (1) and (2) -- Yes. The coefficients of the characteristic polynomial are continuous functions of $A(t)$ (they are polynomials in the entries of $A(t)$!) and the [roots of a polynomial are continuous functions of the coefficients](https://math.stackexchange.com/questions/63196/continuity-of-the-roots-of-a-polynom... | This is not answer. Just trying to make observations. Note that when $t$ is very close to zero, you have $$(I-tQ\_1)^{-1}=I+tQ\_1+t^2Q\_1^2+\dots$$ Let $C=Q\_2-Q1$. Then $$A(t) =(tI+t^2Q\_1+t^3Q\_1^2+..)C~+~(I+tQ\_1+t^2Q\_1^2+\dots)B $$ Now, let's look at the matrix $(I-tQ\_1)^{-1}$. Let $Q\_1 = T\Lambda T^{-1}$ for so... |
2,072,693 | Suppose I have a matrix function $A(t)$ with $$\lVert A(t) - B\rVert \le ct^\alpha$$ in some matrix norm (this will work for any norm, I guess). So, in a sense $A(t)\rightarrow B$ for $t\rightarrow 0$ in $\mathcal{O}(t^\alpha)$. Plus, we have $A(0) = B$.
I happen to know the eigenvalues of $B$, but I don't know a thin... | 2016/12/26 | [
"https://math.stackexchange.com/questions/2072693",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/402051/"
] | Parts (1) and (2) -- Yes. The coefficients of the characteristic polynomial are continuous functions of $A(t)$ (they are polynomials in the entries of $A(t)$!) and the [roots of a polynomial are continuous functions of the coefficients](https://math.stackexchange.com/questions/63196/continuity-of-the-roots-of-a-polynom... | The statement that eigenvalues are continuous functions of the entries of matrices is often seen in the literature. What does it really mean?
Actually, "eigenvalue continuity" is interpreted in two different meanings: in the sense of topology and in the sense of individual functions.
In the sense of topology: eigenva... |
39,738,900 | I have the following query that checks if two columns of a table are `in` another
The query works, I hope you can optimize the call in because they are equal. I doubt if there is a performance penalty because two calls are made to the same query
```
SELECT name,lastname FROM TABLA_A
WHERE
name IN (
SELECT name FROM... | 2016/09/28 | [
"https://Stackoverflow.com/questions/39738900",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6873608/"
] | There is a performance issue in using `OR` that you can use `UNION` instead like this:
```
SELECT name, lastname
FROM TABLE_A
WHERE name IN (
SELECT name
FROM TABLE_B)
UNION -- If there is not any duplicate use `UNION ALL` instead
SELECT name, lastname
FROM TABLE_A
WHERE lastname IN (
SELECT lastname
FROM ... | As you have already done
```
SELECT a.name, a.lastname
FROM TABLE_A as a
INNER JOIN TABLE_B as b on a.name=b.name OR a.lastname= b.lastname
``` |
39,738,900 | I have the following query that checks if two columns of a table are `in` another
The query works, I hope you can optimize the call in because they are equal. I doubt if there is a performance penalty because two calls are made to the same query
```
SELECT name,lastname FROM TABLA_A
WHERE
name IN (
SELECT name FROM... | 2016/09/28 | [
"https://Stackoverflow.com/questions/39738900",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6873608/"
] | You can use EXISTS which works more efficiently than IN from every aspects:
```
SELECT a.name,
a.lastname
FROM TABLE_A as a
WHERE EXISTS (SELECT b.name
FROM TABLE_B b WHERE a.name = b.name OR a.lastname= b.lastname)
``` | As you have already done
```
SELECT a.name, a.lastname
FROM TABLE_A as a
INNER JOIN TABLE_B as b on a.name=b.name OR a.lastname= b.lastname
``` |
39,738,900 | I have the following query that checks if two columns of a table are `in` another
The query works, I hope you can optimize the call in because they are equal. I doubt if there is a performance penalty because two calls are made to the same query
```
SELECT name,lastname FROM TABLA_A
WHERE
name IN (
SELECT name FROM... | 2016/09/28 | [
"https://Stackoverflow.com/questions/39738900",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6873608/"
] | There is a performance issue in using `OR` that you can use `UNION` instead like this:
```
SELECT name, lastname
FROM TABLE_A
WHERE name IN (
SELECT name
FROM TABLE_B)
UNION -- If there is not any duplicate use `UNION ALL` instead
SELECT name, lastname
FROM TABLE_A
WHERE lastname IN (
SELECT lastname
FROM ... | You can use EXISTS which works more efficiently than IN from every aspects:
```
SELECT a.name,
a.lastname
FROM TABLE_A as a
WHERE EXISTS (SELECT b.name
FROM TABLE_B b WHERE a.name = b.name OR a.lastname= b.lastname)
``` |
47,059,079 | I recently inherited a large codebase at work utilizing MOOS & Protobuf messages.
At the request of my project lead, I am porting it to use exclusively ROS where ROS messages are used instead of protobuf. The code base heavily relies on utilizing protobuf functionality such as enumerator min / max, extracting a string... | 2017/11/01 | [
"https://Stackoverflow.com/questions/47059079",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3000724/"
] | Yes there is a hack. But you need to input a some work into it.
For using the publisher/subscriber methods in ROS you need to define messages for all topics in *.msg* files.
From this file then a C++ class is automatically generated. But you don't want to touch that autogenerated file! What you could do instead is d... | Sometime ago I wrote some auto generation scripts that consume Protobufs and produce ROS headers (*not* the msg files) to transmit Protobuf blobs over ROS comms. This would satisfy your need without having to duplicate a Protobuf definition with a supporting ROS msg definition. [Code](https://github.com/ammarhusain/ros... |
15,166,747 | I have a draggable line with a stroke width of 2 and want the user to be able to drag the line even if he clicks and drags near the surrounding area. As per my understanding, the way to do that is to define a custom drawHitFunc for the line. I adapted the code from tutorial here: <http://www.html5canvastutorials.com/ki... | 2013/03/01 | [
"https://Stackoverflow.com/questions/15166747",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2125066/"
] | You can actually use a line as the hit area for a Line object. And you can achieve this in two ways:
1. Assign the line's internal colorKey as the strokeStyle and use the native canvas stroke:
context.lineWidth = 10;
context.strokeStyle = this.colorKey;
context.stroke();
2. The other solution is to set the strokeWidt... | Yes, it looks like KineticJS doesn’t like custom hit-testing a line.
Instead, this works…rather than using a “fat” line in the custom hittest, just draw a rectangle around the line.
Here is code and a Fiddle: <http://jsfiddle.net/m1erickson/twUqx/>
```
var line = new Kinetic.Line({
points: [fromX, fromY, t... |
15,166,747 | I have a draggable line with a stroke width of 2 and want the user to be able to drag the line even if he clicks and drags near the surrounding area. As per my understanding, the way to do that is to define a custom drawHitFunc for the line. I adapted the code from tutorial here: <http://www.html5canvastutorials.com/ki... | 2013/03/01 | [
"https://Stackoverflow.com/questions/15166747",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2125066/"
] | In Kinetic 4.7.2 the solution looks like:
```
drawHitFunc: function(context) {
var hitWidth = 50;
context.beginPath();
context.moveTo(this.getPoints()[0].x, this.getPoints()[0].y);
context.lineTo(this.getPoints()[1].x, this.getPoints()[1].y);
context.closePath();
var orgWidth = this.getStroke... | Yes, it looks like KineticJS doesn’t like custom hit-testing a line.
Instead, this works…rather than using a “fat” line in the custom hittest, just draw a rectangle around the line.
Here is code and a Fiddle: <http://jsfiddle.net/m1erickson/twUqx/>
```
var line = new Kinetic.Line({
points: [fromX, fromY, t... |
40,238,217 | I need to check if some strings contain any non-English characters.
```
x = c('Kält', 'normal', 'normal with, punctuation ~-+!', 'normal with number 1234')
grep(pattern = ??, x) # Expected output:1
``` | 2016/10/25 | [
"https://Stackoverflow.com/questions/40238217",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9038547/"
] | You may use `[^[:ascii:]]` PCRE regex:
```
x = c('Kält', 'normal', 'normal with, punctuation ~-+!', 'normal with number 1234')
grep(pattern = "[^[:ascii:]]", x, perl=TRUE)
grep(pattern = "[^[:ascii:]]", x, value=TRUE, perl=TRUE)
```
Ouput:
```
[1] 1
[1] "Kält"
```
See the [R demo](http://ideone.com/vxav28) | Expanding on the answer that's already been provided
**To check for non-ASCII**
```r
x = c('Kält', 'normal', 'normal punctuation ~-+!', 'normal number 1234')
grep(pattern = "[^[:ascii:]]", x, perl=TRUE)
grep(pattern = "[^[:ascii:]]", x, value=TRUE, perl=TRUE)
```
**To check for non-unicode**
```r
x = c('Kält',... |
13,749,805 | I have gone through so much code and tried to figure out what I am doing wrong but i am flunked and am wasting time. It would be pretty simple but I cannot figure it out..
I am developing an android app and need to put 2 spinners on one activity. the second spinner will populate based on the entry selected on the firs... | 2012/12/06 | [
"https://Stackoverflow.com/questions/13749805",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1883244/"
] | Well, I ended coding my own functions. Tested with gcc and tcc over all the range of double, gives exactly the same output (except for very few very small values, less than 1E-319)
I post it in case someone finds it useful.
Java:
```
/**
* Returns a double with an adhoc formatting, compatible with its C co... | This code
```
#include <stdio.h>
int main() {
double v;
char format[] = "%.5g\n";
v = 1234.0;
printf(format, v);
v = 123.45678;
printf(format, v);
v = 0.000123456;
printf(format, v);
v = 0.000000000000123456;
printf(format, v);
}
```
gave me
```
1234
123.46
0.00012346
... |
13,749,805 | I have gone through so much code and tried to figure out what I am doing wrong but i am flunked and am wasting time. It would be pretty simple but I cannot figure it out..
I am developing an android app and need to put 2 spinners on one activity. the second spinner will populate based on the entry selected on the firs... | 2012/12/06 | [
"https://Stackoverflow.com/questions/13749805",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1883244/"
] | If you really want base-10 floating-point output, it's probably easiest to write a JNI wrapper for C's `printf` here. The Java folks decided they needed to do `printf` themselves. Apart from what you've already noticed about `%g`, they decided to change the rounding behaviour and truncate output in a curious way. To wi... | This code
```
#include <stdio.h>
int main() {
double v;
char format[] = "%.5g\n";
v = 1234.0;
printf(format, v);
v = 123.45678;
printf(format, v);
v = 0.000123456;
printf(format, v);
v = 0.000000000000123456;
printf(format, v);
}
```
gave me
```
1234
123.46
0.00012346
... |
13,749,805 | I have gone through so much code and tried to figure out what I am doing wrong but i am flunked and am wasting time. It would be pretty simple but I cannot figure it out..
I am developing an android app and need to put 2 spinners on one activity. the second spinner will populate based on the entry selected on the firs... | 2012/12/06 | [
"https://Stackoverflow.com/questions/13749805",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1883244/"
] | This code
```
#include <stdio.h>
int main() {
double v;
char format[] = "%.5g\n";
v = 1234.0;
printf(format, v);
v = 123.45678;
printf(format, v);
v = 0.000123456;
printf(format, v);
v = 0.000000000000123456;
printf(format, v);
}
```
gave me
```
1234
123.46
0.00012346
... | I created a small library Double2String to address this specific issue:
<https://github.com/coconut2015/double2string> |
13,749,805 | I have gone through so much code and tried to figure out what I am doing wrong but i am flunked and am wasting time. It would be pretty simple but I cannot figure it out..
I am developing an android app and need to put 2 spinners on one activity. the second spinner will populate based on the entry selected on the firs... | 2012/12/06 | [
"https://Stackoverflow.com/questions/13749805",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1883244/"
] | Well, I ended coding my own functions. Tested with gcc and tcc over all the range of double, gives exactly the same output (except for very few very small values, less than 1E-319)
I post it in case someone finds it useful.
Java:
```
/**
* Returns a double with an adhoc formatting, compatible with its C co... | If you really want base-10 floating-point output, it's probably easiest to write a JNI wrapper for C's `printf` here. The Java folks decided they needed to do `printf` themselves. Apart from what you've already noticed about `%g`, they decided to change the rounding behaviour and truncate output in a curious way. To wi... |
13,749,805 | I have gone through so much code and tried to figure out what I am doing wrong but i am flunked and am wasting time. It would be pretty simple but I cannot figure it out..
I am developing an android app and need to put 2 spinners on one activity. the second spinner will populate based on the entry selected on the firs... | 2012/12/06 | [
"https://Stackoverflow.com/questions/13749805",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1883244/"
] | Well, I ended coding my own functions. Tested with gcc and tcc over all the range of double, gives exactly the same output (except for very few very small values, less than 1E-319)
I post it in case someone finds it useful.
Java:
```
/**
* Returns a double with an adhoc formatting, compatible with its C co... | I created a small library Double2String to address this specific issue:
<https://github.com/coconut2015/double2string> |
13,749,805 | I have gone through so much code and tried to figure out what I am doing wrong but i am flunked and am wasting time. It would be pretty simple but I cannot figure it out..
I am developing an android app and need to put 2 spinners on one activity. the second spinner will populate based on the entry selected on the firs... | 2012/12/06 | [
"https://Stackoverflow.com/questions/13749805",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1883244/"
] | If you really want base-10 floating-point output, it's probably easiest to write a JNI wrapper for C's `printf` here. The Java folks decided they needed to do `printf` themselves. Apart from what you've already noticed about `%g`, they decided to change the rounding behaviour and truncate output in a curious way. To wi... | I created a small library Double2String to address this specific issue:
<https://github.com/coconut2015/double2string> |
140,375 | We are testing Percona 5.6.28 at the moment, during our testing we found out even though the innodb\_buffer\_pool\_populate is set to ON, it doesn't populate the memory(buffer pool) during mysql start.
There is the new parameter that was added in 5.6.27, innodb\_numa\_interleave, even with that ON the buffer pool doesn... | 2016/06/03 | [
"https://dba.stackexchange.com/questions/140375",
"https://dba.stackexchange.com",
"https://dba.stackexchange.com/users/96134/"
] | Amit, the problem is that this variable is set to reload a copy of the buffer pool dumped to disk during a stop/restart process.
In order to achieve this you need to set innodb\_buffer\_pool\_dump\_at\_shutdown to ON prior to restart your server, please check this link for further info: <https://dev.mysql.com/doc/refm... | NUMA is not unrelated to buffer pool preallocation. That is the reason why innodb\_buffer\_pool\_populate was introduced in the first place.
See <https://blog.jcole.us/2012/04/16/a-brief-update-on-numa-and-mysql/>
That is also the reason why it took around 7-8 minutes to start mysql with the older Percona release. No... |
140,375 | We are testing Percona 5.6.28 at the moment, during our testing we found out even though the innodb\_buffer\_pool\_populate is set to ON, it doesn't populate the memory(buffer pool) during mysql start.
There is the new parameter that was added in 5.6.27, innodb\_numa\_interleave, even with that ON the buffer pool doesn... | 2016/06/03 | [
"https://dba.stackexchange.com/questions/140375",
"https://dba.stackexchange.com",
"https://dba.stackexchange.com/users/96134/"
] | According to release docs innodb\_buffer\_pool\_populate was mapped to innodb\_numa\_interleave starting with Percona 5.6.27-75.0, so based on what you see, it appears it is no longer preallocating the buffer pool, only setting the numa policy.
Regarding innodb\_buffer\_pool\_dump\_at\_shutdown and load at startup, you... | NUMA is not unrelated to buffer pool preallocation. That is the reason why innodb\_buffer\_pool\_populate was introduced in the first place.
See <https://blog.jcole.us/2012/04/16/a-brief-update-on-numa-and-mysql/>
That is also the reason why it took around 7-8 minutes to start mysql with the older Percona release. No... |
2,836,705 | Each time i launch the properties panel i get this error:
>
> Could not accept change: the currently
> displayed page contains invalid
> values.
>
>
>
I have tried to use a fresh new workspace & a new install of eclipse without any result.
I am on mac OS X.
Any help wellcome
screen captures of the problem:
... | 2010/05/14 | [
"https://Stackoverflow.com/questions/2836705",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30871/"
] | >
> Here is another example of the querystring vs. the data i get from $\_REQUEST:
>
>
> originally encoded url in querystring:
> searcharg=mammals&url=http%3A%2F%2Fexample.com%2Fsearch%7ES10%3F%2FXmammals%26searchscope%3D10%26SORT%3DD%2FXmammals%26searchscope%3D10%26SORT%3DD%26SUBKEY%3Dmammals%2F51%252C1114%252C111... | The [comma (U+002C) is a reserved character in the query](https://www.rfc-editor.org/rfc/rfc2396#section-3.4) and thus must be encoded with `%2C`:
>
> 3.4. Query Component
>
>
> The query component is a string of information to be interpreted by
> the resource.
>
>
>
> ```
> query = *uric
>
> ```
>
>... |
68,769 | Assume you have a single-linked list of length n. The list is immutable. A node `node` has a method `next` and `node.next()` returns a reference to the successor of `node`. `node.print()` prints the value of node `node` or does some other stuff, such etails don't matter.
Is it possible to print the nodes of the list i... | 2017/01/15 | [
"https://cs.stackexchange.com/questions/68769",
"https://cs.stackexchange.com",
"https://cs.stackexchange.com/users/1010/"
] | The Range Tree is made from the input array. The array is sorted and then the tree is built. This means that in the standard construction we have started with the array, this may indicate the leaves. And this BST comes from the sorted array, so there is no point in changing it to e.g. self-balancing trees in the standa... | I can only guess at the intentions of whoever came up with that graphic, but here is an observation.
The leaves always point to the next node you have to visit in an in-order traversal. Therefore, if implemented as pointers (so they don't take up any extra space!), you can traverse the tree in in-order without a stack... |
68,769 | Assume you have a single-linked list of length n. The list is immutable. A node `node` has a method `next` and `node.next()` returns a reference to the successor of `node`. `node.print()` prints the value of node `node` or does some other stuff, such etails don't matter.
Is it possible to print the nodes of the list i... | 2017/01/15 | [
"https://cs.stackexchange.com/questions/68769",
"https://cs.stackexchange.com",
"https://cs.stackexchange.com/users/1010/"
] | I can only guess at the intentions of whoever came up with that graphic, but here is an observation.
The leaves always point to the next node you have to visit in an in-order traversal. Therefore, if implemented as pointers (so they don't take up any extra space!), you can traverse the tree in in-order without a stack... | It's probably just for visual purposes, since actually doing what the first diagram does would effectively double the amount of space needed, really, unnecessarily and there are other deficiencies of such a design compared to regular BSTs with a range query. It is probably just for visualization purposes,(as seen here:... |
68,769 | Assume you have a single-linked list of length n. The list is immutable. A node `node` has a method `next` and `node.next()` returns a reference to the successor of `node`. `node.print()` prints the value of node `node` or does some other stuff, such etails don't matter.
Is it possible to print the nodes of the list i... | 2017/01/15 | [
"https://cs.stackexchange.com/questions/68769",
"https://cs.stackexchange.com",
"https://cs.stackexchange.com/users/1010/"
] | The Range Tree is made from the input array. The array is sorted and then the tree is built. This means that in the standard construction we have started with the array, this may indicate the leaves. And this BST comes from the sorted array, so there is no point in changing it to e.g. self-balancing trees in the standa... | It's probably just for visual purposes, since actually doing what the first diagram does would effectively double the amount of space needed, really, unnecessarily and there are other deficiencies of such a design compared to regular BSTs with a range query. It is probably just for visualization purposes,(as seen here:... |
38,513,923 | I have a d3 tree based on the following...
<http://bl.ocks.org/mbostock/1093025>
How would I get a count of all the children? I have tried this however it counts all the rows in the tree...
```
$(".tree_badge").text(tree.links(nodes).length);
```
So in the example it should count all the children where children wo... | 2016/07/21 | [
"https://Stackoverflow.com/questions/38513923",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/264735/"
] | I actually had a similar problem where I had to grab all of the descriptions from a tree below a particular node. The answer in my case and yours is to recursively descend the tree and do something on the way down. Should look something like this.
```
var count;
function count_leaves(node){
if(node.children){
... | Just use the `leaves` method
[](https://i.stack.imgur.com/a1K4b.png)
Since I've come here from google looking for `how to optimally count each children's descendants`, the solution would be
[ {
}
```
but I need to do this reading multiple times and I need to start from the beginning of the file each time. How can I do that? Is there something like refreshing the stream in perl?
Thanks in... | 2010/11/23 | [
"https://Stackoverflow.com/questions/4261896",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/246414/"
] | If `INP1` is connected to a regular filehandle (not a socket handle or pipe handle), you can also [`seek`](http://search.cpan.org/perldoc?perlfunc#seek) back to the beginning of the file.
```
while(<INP1>) {
...
}
seek INP1, 0, 0;
# do it again
while (<INP1>) {
...
}
```
Another option is to load the entire f... | You can `seek` back to the beginning:
```
use Fcntl;
open INP1, ...
while (<INP1>) {
}
seek INP1, 0, SEEK_SET;
while (<INP1>) {
}
```
This will only work properly if INP1 is a real file (not a pipe or socket). |
4,261,896 | what happens after the eof is reached with <> operator in perl?
I'm reading INP1 line by line with
```
while(<INP1>) {
}
```
but I need to do this reading multiple times and I need to start from the beginning of the file each time. How can I do that? Is there something like refreshing the stream in perl?
Thanks in... | 2010/11/23 | [
"https://Stackoverflow.com/questions/4261896",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/246414/"
] | If `INP1` is connected to a regular filehandle (not a socket handle or pipe handle), you can also [`seek`](http://search.cpan.org/perldoc?perlfunc#seek) back to the beginning of the file.
```
while(<INP1>) {
...
}
seek INP1, 0, 0;
# do it again
while (<INP1>) {
...
}
```
Another option is to load the entire f... | In addition to using [seek](http://perldoc.perl.org/functions/seek.html) to go back to the start of the file, you could use [Tie::File](http://search.cpan.org/perldoc/Tie%3a%3aFile) to treat the file as an array of lines. Depending on your access pattern, this might be more efficient than re-reading the file from the s... |
563,319 | ```
#!/bin/sh
INTERVAL=12
TOTAL=3388888
DURSECS=$(($TOTAL * $INTERVAL))
printf "\n$DURSECS seconds.\n"
printf "\nFormatted as DAYS:HOURS:MINUTES:SECONDS - DDD:HH:MM:SS - the total duration will be:\n"
# these do not do it
# TOTALTIMES=$(($DURSECS/(24*60*60), "ddd:hh:mm:ss"))
# printf "$TOTALTIMES"
# just need days here... | 2020/01/22 | [
"https://unix.stackexchange.com/questions/563319",
"https://unix.stackexchange.com",
"https://unix.stackexchange.com/users/391393/"
] | You might want to reverse the file, take the **first** N lines, then reverse the output of that
```bsh
$ seq 100 > file
$ tac file | sed -n 5,10p | tac
91
92
93
94
95
96
``` | Similar to the other answers, I don't know of a way to do this in one line with sed except maybe by carrying a large buffer, but with two lines this is possible more easily:
```
NUM_LINES=$((`sed -n $= file1.txt`-20)) # or however many lines you want instead of 20
sed -i "$NUM_LINES r file2.txt" file1.txt
```
Argu... |
23,615,276 | I'm trying to build an xml file from data in a Filemaker database. I can get the basic structure of the XML to work but am having issues rendering portal rows in the right way.
Here is the end result of what I'm trying to achieve.
```
<product>
<model>Model</model>
<caliber>Caliber</caliber>
<submodel>Sub Model</subm... | 2014/05/12 | [
"https://Stackoverflow.com/questions/23615276",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1207537/"
] | This isn't so much a PHP vulnerability as it is a "not added" feature to your web server.
You can of course throw in header("X-Frame-Options=SAMEORIGIN"); into every page...but that's not feasible simply read below and add the required data to your HTTPd config file.
<https://developer.mozilla.org/en-US/docs/Web/HTTP... | Not sure why you would class it as a vulnerability, but you can control who is allowed to frame your site:
[How to Block Iframe call](https://stackoverflow.com/questions/5881139/how-to-block-iframe-call)
You would be safest to use:
```
Header always append X-Frame-Options SAMEORIGIN
```
In your htaccess (assuming ... |
24,722,130 | When do I need to use a nested class in C++? What does a nested class provide that cannot be provided by having two classes?
```
class A
{
class B
{
};
};
```
and not:
```
class A
{
};
class B
{
};
``` | 2014/07/13 | [
"https://Stackoverflow.com/questions/24722130",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2468313/"
] | I think you're getting a little confused.
In your first example, class `B` is nested within class `A`. This is a good idea when class `B` is really quite specific to class `A`, and might pollute the namespace. For example:
```
class Tree
{
class Node
{
};
};
```
Depending on what other 3rd-party librari... | A cat is an animal. We can define `Cat` and `Animal` classes as follow:
```
class Animal {};
class Cat {};
```
But we have defined them without any relationship to each other, So a `Cat` is not an `Animal`. We can define an **IS-A** relationship between them (**Inheritance**):
```
class Animal {};
class Cat : publi... |
32,443,646 | clang++ and g++ are ABI incompatible, even for things as core as standard containers, according to, e.g., the clang++ website.
Debian ships with C++ shared libraries, i.e. libboost, etc... that are compiled with ~something and user programs using both compiler generally work, and the library names aren't mangled with ... | 2015/09/07 | [
"https://Stackoverflow.com/questions/32443646",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/139802/"
] | G++ and Clang are for the vast majority completely ABI compatible. Furthermore, ABI incompatibilities for Standard containers are properties of the standard library implementation (libstdc++ or libc++), not the compiler. Therefore, there is no need for any re-compilation.
Clang could never have gotten off the ground i... | This probably will not answer the exact question correctly:
Some time ago I tried to compile some object files wih gcc, another object files with clang. Finally I linked everything together and it worked correctly.
I believe Linux distributions uses gcc, because I examined some Makefile's of Ubuntu and CentOS and the... |
32,443,646 | clang++ and g++ are ABI incompatible, even for things as core as standard containers, according to, e.g., the clang++ website.
Debian ships with C++ shared libraries, i.e. libboost, etc... that are compiled with ~something and user programs using both compiler generally work, and the library names aren't mangled with ... | 2015/09/07 | [
"https://Stackoverflow.com/questions/32443646",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/139802/"
] | >
> even for things as core as standard containers
>
>
>
Standard containers are not all that "core". (For typical implementations) they are implemented entirely in valid C++ in headers, and if you compile the same headers with G++ and Clang++ you'll get ABI compatible output. You should only get incompatibilities... | This probably will not answer the exact question correctly:
Some time ago I tried to compile some object files wih gcc, another object files with clang. Finally I linked everything together and it worked correctly.
I believe Linux distributions uses gcc, because I examined some Makefile's of Ubuntu and CentOS and the... |
32,443,646 | clang++ and g++ are ABI incompatible, even for things as core as standard containers, according to, e.g., the clang++ website.
Debian ships with C++ shared libraries, i.e. libboost, etc... that are compiled with ~something and user programs using both compiler generally work, and the library names aren't mangled with ... | 2015/09/07 | [
"https://Stackoverflow.com/questions/32443646",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/139802/"
] | >
> even for things as core as standard containers
>
>
>
Standard containers are not all that "core". (For typical implementations) they are implemented entirely in valid C++ in headers, and if you compile the same headers with G++ and Clang++ you'll get ABI compatible output. You should only get incompatibilities... | G++ and Clang are for the vast majority completely ABI compatible. Furthermore, ABI incompatibilities for Standard containers are properties of the standard library implementation (libstdc++ or libc++), not the compiler. Therefore, there is no need for any re-compilation.
Clang could never have gotten off the ground i... |
72,181,241 | How do I get each text of label of input:checked with `<span>`?
I tried to use `"<span>" + $(this).next().find('span').text() + "</span>";`
It was not working.
```js
<ul>
<li class="check_cst">
<input type="checkbox" id="detail_cate01" name="chk_datail_category" value="">
<label for="detail_cate01" class="flex_... | 2022/05/10 | [
"https://Stackoverflow.com/questions/72181241",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19022525/"
] | You can create common file using following folder structure, steps included here will be accessible in all the feature files
cypress\integration\common\common-step.ts | Try adding these lines in `package.json` in cypress-cucumber-preprocessor section
`"nonGlobalStepDefinitions": false, "stepDefinitions":"cypress/integration/featureFiles"`
[](https://i.stack.imgur.com/tm2PX.png) |
49,795,886 | I have a conditional that logs the current date the first time it is run.
The second time the conditional is run it overwrites the previous date with the current date and both dates become the current date, however I still want to log the previous date to the file. Is there any way I can save the date when the first c... | 2018/04/12 | [
"https://Stackoverflow.com/questions/49795886",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9519984/"
] | In theory, this is possible: You could take any register that the calling conventions require to be preserved across function calls, and use that for your global variable.
However, there are some problems with this:
* The effect is, that your functions will have one less register for local variables available. This m... | >
> Is this possible to tell the compiler to put a certain global variable in a register?
>
>
>
Not really. There is the `register` storage class, but this only means that the variable should be "as fast as possible". This keyword is mostly obsolete nowadays, it is from a time when compilers were trash.
>
> Thu... |
13,247,069 | This works just fine
```
if [[ -e img.png ]]
then
echo "exist"
else
echo "doesn't exist"
fi
```
but what if I know that there might be imgage with name img but I do not know if the file is .jpg , .gif , .jpeg , .tff and so on.
I do not care what is the extension I just want to know if there is a file with... | 2012/11/06 | [
"https://Stackoverflow.com/questions/13247069",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/706780/"
] | You can do:
```
files=$(ls img.* 2> /dev/null | wc -l)
if [ "$files" != "0" ]
then
echo "exist"
else
echo "doesn't exist"
fi
``` | You can use the following scripts
```
files=`ls img.* 2>/dev/null`
if [ "$files" -a ${#files[@]} ]; then
echo "exist"
else
echo "doesn't exist"
fi
```
In this snippet, you use `ls img.*` to list all the files in current working directory whose name match the pattern `img.*`.
The result is stored into an arra... |
13,247,069 | This works just fine
```
if [[ -e img.png ]]
then
echo "exist"
else
echo "doesn't exist"
fi
```
but what if I know that there might be imgage with name img but I do not know if the file is .jpg , .gif , .jpeg , .tff and so on.
I do not care what is the extension I just want to know if there is a file with... | 2012/11/06 | [
"https://Stackoverflow.com/questions/13247069",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/706780/"
] | You can use the following scripts
```
files=`ls img.* 2>/dev/null`
if [ "$files" -a ${#files[@]} ]; then
echo "exist"
else
echo "doesn't exist"
fi
```
In this snippet, you use `ls img.*` to list all the files in current working directory whose name match the pattern `img.*`.
The result is stored into an arra... | Something like this should do the job:
```
if [[ $(ls img.*) ]]; then
echo "file exist";
else
echo "file does not exist";
fi
```
I recommend to have a look at bash's pattern matching:
<http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_04_03.html> |
13,247,069 | This works just fine
```
if [[ -e img.png ]]
then
echo "exist"
else
echo "doesn't exist"
fi
```
but what if I know that there might be imgage with name img but I do not know if the file is .jpg , .gif , .jpeg , .tff and so on.
I do not care what is the extension I just want to know if there is a file with... | 2012/11/06 | [
"https://Stackoverflow.com/questions/13247069",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/706780/"
] | You can use the following scripts
```
files=`ls img.* 2>/dev/null`
if [ "$files" -a ${#files[@]} ]; then
echo "exist"
else
echo "doesn't exist"
fi
```
In this snippet, you use `ls img.*` to list all the files in current working directory whose name match the pattern `img.*`.
The result is stored into an arra... | Without any external command:
```
$ for i in img.*
> do
> [ -f $i ] && echo exist || echo not exist
> break
> done
```
Check if any file is present. If present print exist , else not exist, and break immediately. The "-f" check is needed because if no files are present, still the loop runs once with i as "img.\*" ... |
13,247,069 | This works just fine
```
if [[ -e img.png ]]
then
echo "exist"
else
echo "doesn't exist"
fi
```
but what if I know that there might be imgage with name img but I do not know if the file is .jpg , .gif , .jpeg , .tff and so on.
I do not care what is the extension I just want to know if there is a file with... | 2012/11/06 | [
"https://Stackoverflow.com/questions/13247069",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/706780/"
] | You can use the following scripts
```
files=`ls img.* 2>/dev/null`
if [ "$files" -a ${#files[@]} ]; then
echo "exist"
else
echo "doesn't exist"
fi
```
In this snippet, you use `ls img.*` to list all the files in current working directory whose name match the pattern `img.*`.
The result is stored into an arra... | ```
shopt -s nullglob
files=( img.* )
if (( ${#files[@]} == 0 )); then
echo "there are no 'img' files"
fi
```
If you don't use `nullglob` then, if there are no such files, the array will have 1 element, the literal string "img.\*". |
13,247,069 | This works just fine
```
if [[ -e img.png ]]
then
echo "exist"
else
echo "doesn't exist"
fi
```
but what if I know that there might be imgage with name img but I do not know if the file is .jpg , .gif , .jpeg , .tff and so on.
I do not care what is the extension I just want to know if there is a file with... | 2012/11/06 | [
"https://Stackoverflow.com/questions/13247069",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/706780/"
] | You can do:
```
files=$(ls img.* 2> /dev/null | wc -l)
if [ "$files" != "0" ]
then
echo "exist"
else
echo "doesn't exist"
fi
``` | Something like this should do the job:
```
if [[ $(ls img.*) ]]; then
echo "file exist";
else
echo "file does not exist";
fi
```
I recommend to have a look at bash's pattern matching:
<http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_04_03.html> |
13,247,069 | This works just fine
```
if [[ -e img.png ]]
then
echo "exist"
else
echo "doesn't exist"
fi
```
but what if I know that there might be imgage with name img but I do not know if the file is .jpg , .gif , .jpeg , .tff and so on.
I do not care what is the extension I just want to know if there is a file with... | 2012/11/06 | [
"https://Stackoverflow.com/questions/13247069",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/706780/"
] | You can do:
```
files=$(ls img.* 2> /dev/null | wc -l)
if [ "$files" != "0" ]
then
echo "exist"
else
echo "doesn't exist"
fi
``` | Without any external command:
```
$ for i in img.*
> do
> [ -f $i ] && echo exist || echo not exist
> break
> done
```
Check if any file is present. If present print exist , else not exist, and break immediately. The "-f" check is needed because if no files are present, still the loop runs once with i as "img.\*" ... |
13,247,069 | This works just fine
```
if [[ -e img.png ]]
then
echo "exist"
else
echo "doesn't exist"
fi
```
but what if I know that there might be imgage with name img but I do not know if the file is .jpg , .gif , .jpeg , .tff and so on.
I do not care what is the extension I just want to know if there is a file with... | 2012/11/06 | [
"https://Stackoverflow.com/questions/13247069",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/706780/"
] | You can do:
```
files=$(ls img.* 2> /dev/null | wc -l)
if [ "$files" != "0" ]
then
echo "exist"
else
echo "doesn't exist"
fi
``` | ```
shopt -s nullglob
files=( img.* )
if (( ${#files[@]} == 0 )); then
echo "there are no 'img' files"
fi
```
If you don't use `nullglob` then, if there are no such files, the array will have 1 element, the literal string "img.\*". |
91,027 | Sipser in his book provided the following proof for undecidability of REGULAR$\_{TM}$:
>
> S = “On input $<M,w>$, where $M$ is a TM and w is a string:
>
>
> 1. Construct the following TM $M\_2$.
>
>
> $M\_2$= “On input $x$:
>
>
> 1. If $x$ has the form $0^n1^n$, accept .
> 2. If $x $ does not have this form, ... | 2018/04/22 | [
"https://cs.stackexchange.com/questions/91027",
"https://cs.stackexchange.com",
"https://cs.stackexchange.com/users/12532/"
] | Note $M\_2$ is constructed based on $\langle M,w\rangle$. That is to say, different $\langle M,w\rangle$ may result in different $M\_2$.
If $M$ accepts $w$, then $M\_2$ will accept any string (if the input has the form $0^n1^n$, $M\_2$ accepts it at the first step, otherwise $M\_2$ accepts it at the second step), thus... | >
> Note that the TM 2 is not constructed for the purposes of actually
> running it on some input.
>
>
>
I think the statement above is wrong, because:
On input <,>, the input which is feed to 2 could be always a string without the form 01, for example, always be 1, then S still can decide on . |
25,257,100 | I have a .csv file with hundreds of rows and many columns. i want to read specific columns from the file. These are the column names i have.
productId title imageUrlStr mrp price productUrl categories productBrand
from this i want to read all the columns i did it by this way
```
final String DELIMITER = ",";
... | 2014/08/12 | [
"https://Stackoverflow.com/questions/25257100",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2765845/"
] | You can also scrap using Cognito and use the Access Key/Secret:
```
AWSStaticCredentialsProvider *credentialsProvider = [AWSStaticCredentialsProvider credentialsWithAccessKey:ACCESS_KEY_ID secretKey:SECRET_KEY];
AWSServiceConfiguration *configuration = [AWSServiceConfiguration configurationWithRegion:AWSRegionUSWest2
... | I recommend you follow the README and run the [S3TransferManager sample app](https://github.com/awslabs/aws-sdk-ios-samples/tree/master/S3TransferManager-Sample). In the [Amazon Cognito console](https://console.aws.amazon.com/cognito/), you can get the information you need to instantiate the credentials provider.
Also... |
25,257,100 | I have a .csv file with hundreds of rows and many columns. i want to read specific columns from the file. These are the column names i have.
productId title imageUrlStr mrp price productUrl categories productBrand
from this i want to read all the columns i did it by this way
```
final String DELIMITER = ",";
... | 2014/08/12 | [
"https://Stackoverflow.com/questions/25257100",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2765845/"
] | You can also scrap using Cognito and use the Access Key/Secret:
```
AWSStaticCredentialsProvider *credentialsProvider = [AWSStaticCredentialsProvider credentialsWithAccessKey:ACCESS_KEY_ID secretKey:SECRET_KEY];
AWSServiceConfiguration *configuration = [AWSServiceConfiguration configurationWithRegion:AWSRegionUSWest2
... | For your convenience, I left the version in Swift
```
let credentialsProvider = AWSStaticCredentialsProvider(accessKey:"YOUR_ACCESS_KEY", secretKey: "YOUR_SECRET_KEY")
let defaultServiceConfiguration = AWSServiceConfiguration(region: AWSRegionType.EUWest1, credentialsProvider: credentialsProvider)
defaultServiceConfi... |
56,628,142 | My javascript class is loaded before the render of my page. So the `querySelectorAll` return `0`.
How to load my class after the Angular render ?
**page.ejs**
```
<body ng-app="GestiawebApp">
<script src="myclass.js"></script>
<!-- ng repeat <a href="#" data-dialog="true">....-->
</body>
```
**myclass.js**
``... | 2019/06/17 | [
"https://Stackoverflow.com/questions/56628142",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2056779/"
] | The `>` redirects STDOUT, but you can also have STDERR output from containers. To redirect that, you can use:
```
docker logs filebeat > filebeat.log 2> filebeat.err
```
or send both to the same file:
```
docker logs filebeat > filebeat.log 2>&1
``` | You should run the container with the -t flag which will allocate a pseudo-tty for the container. Example:
`docker run -td --rm --name test store/elastic/filebeat:7.1.1`
`docker logs test > test.txt`
This will store the output to the file. When running without the -t flag it will simply dump the logs in your termina... |
10,357 | In vim I can use for instance `1``0``j` to go 10 lines down. And I can use `.` to repeat the last deletion.
Now, in bash script I have many commented lines like this:
```
# ...
# ...
# ...
# ...
# ...
# ...
# ...
# ...
# ...
etc...
```
Say, there are 52 such lines. Is there a way to combine moving `52j` and repeati... | 2016/11/21 | [
"https://vi.stackexchange.com/questions/10357",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/9409/"
] | I do approve @mMontu comment suggesting to use a comment plugin ([vim-commentary](https://github.com/tpope/vim-commentary/) is an option but [NERDCommenter](https://github.com/scrooloose/nerdcommenter) has my preference over vim-commentary).
But you could do it in other ways:
* First if all your `#` are aligned on th... | I like the approaches statox suggested. Here's another one:
```
52:norm x
```
This only works if the `#` is the first character on each line. Otherwise, I would do
```
52:s/#
```
These two work very similarly. Essentially, what `<count>:` is doing, is setting up a range so that the next ex command is applied to t... |
10,357 | In vim I can use for instance `1``0``j` to go 10 lines down. And I can use `.` to repeat the last deletion.
Now, in bash script I have many commented lines like this:
```
# ...
# ...
# ...
# ...
# ...
# ...
# ...
# ...
# ...
etc...
```
Say, there are 52 such lines. Is there a way to combine moving `52j` and repeati... | 2016/11/21 | [
"https://vi.stackexchange.com/questions/10357",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/9409/"
] | I do approve @mMontu comment suggesting to use a comment plugin ([vim-commentary](https://github.com/tpope/vim-commentary/) is an option but [NERDCommenter](https://github.com/scrooloose/nerdcommenter) has my preference over vim-commentary).
But you could do it in other ways:
* First if all your `#` are aligned on th... | ### Having a space with the commenting character?
**Assumptions** : *commented lines are **continuous** and commenting character (`#` in your case) is at beginning of all those lines.*
1. Come to the beginning of the first commented line.
2. Press `Ctrl`+`v` *switches to **visual-block mode***.
3. Type `5``2``j` ***s... |
10,357 | In vim I can use for instance `1``0``j` to go 10 lines down. And I can use `.` to repeat the last deletion.
Now, in bash script I have many commented lines like this:
```
# ...
# ...
# ...
# ...
# ...
# ...
# ...
# ...
# ...
etc...
```
Say, there are 52 such lines. Is there a way to combine moving `52j` and repeati... | 2016/11/21 | [
"https://vi.stackexchange.com/questions/10357",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/9409/"
] | I like the approaches statox suggested. Here's another one:
```
52:norm x
```
This only works if the `#` is the first character on each line. Otherwise, I would do
```
52:s/#
```
These two work very similarly. Essentially, what `<count>:` is doing, is setting up a range so that the next ex command is applied to t... | ### Having a space with the commenting character?
**Assumptions** : *commented lines are **continuous** and commenting character (`#` in your case) is at beginning of all those lines.*
1. Come to the beginning of the first commented line.
2. Press `Ctrl`+`v` *switches to **visual-block mode***.
3. Type `5``2``j` ***s... |
14,953,348 | I have a web control panel with links to sensitive informations (like credit card number).
When the user clicks (who got logged in before) on one of these link, I need to check his credntials.
How can I make sure on the server side when he requests ("/sensitive-informations.aspx") that he just entered his credentials... | 2013/02/19 | [
"https://Stackoverflow.com/questions/14953348",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/277067/"
] | There are a few ways to do this. For instance, after the user enters his credentials, save them in the [Session object](http://msdn.microsoft.com/en-us/library/ms178581%28v=vs.100%29.aspx).
Then, in the `Page_Load` of *sensitive-informations.aspx* make sure the Session object exists.
To better illustrate this:
In yo... | You can check the `UrlReferrer` in the `Page_Load` event of `sensitive-informations.aspx`:
```
if (Request.UrlReferrer != null)
{
if (Request.UrlReferrer.AbsolutePath.ToLower().Contains("you-login-page"))
{
//User came from the login page
}
}
```
**UPDATE**
Based on your comment, you should ch... |
24,429,569 | ```
`include "bcd.v"
module bcd_4(A,B,Cin,S,Cout);
input [15:0] A,B;
input Cin;
output [15:0] S;
output Cout;
wire w1,w2,w3;
bcd_adder U1(.A(A[3:0]),.B(B[3:0]),.Cin(Cin),.S(S[3:0]),.Cout(w1));
bcd_adder U2(.A(A[7:4]),.B(B[7:4]),.Cin(w1),.S(S[7:4]),.Cout(w2));
bcd_adder U3(.A(A[11:8]),.B(B[11:8]),.Cin(w2),.S(S[11:8]),... | 2014/06/26 | [
"https://Stackoverflow.com/questions/24429569",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3331420/"
] | The inputs of your adder do not take hexadecimal values. They are 16-bit inputs which represent 4 BCD digits of 4 bits each. The input for each digit can range from 0 to 15 in decimal, but since they are BCD any value greater than 9 would be invalid.
The inputs can be specified in any base (binary, octal, decimal or h... | I got it. I can write it using following function
```
function integer hexatodecimal;
input [16:0] a;
integer b;
begin
b=a[3:0]+a[7:4]*10+a[11:8]*100+a[15:12]*1000+a[16]*10000;
hexatodecimal=b;
end
endfunction
```
I can call this function to convert `{Cout,S}` into hexadecimal. |
16,572,731 | I'm using i18next-node for localization of my app.
I have two languages: `en-CA` and `fr-CA`
I'm using this to init the app:
```
i18next.init({
saveMissing: true,
sendMissingTo : 'all',
ignoreRoutes: ['img/','images/', 'public/', 'css/', 'js/'],
debug: true,
lng: 'en-CA'
});
```
The problem is,... | 2013/05/15 | [
"https://Stackoverflow.com/questions/16572731",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/157503/"
] | Turns out you can set `fallbackLng : 'en-CA'` and that will work. Kind of a hack though. | Try to read the detect language section under <http://i18next.com/node/pages/doc_init.html>
i18next detects during the request the language from your browser-settings (if not set by any other methode - cookie, querystring). That's why language is set to 'en-US'.
You can set the supported languages on init:
i18n.init(... |
56,677,765 | I have a simple Makefile:
```
git_repo := some_git_repo
repo:
if [ -v $(git_repo) ]; then \
echo "exists!" \
else \
echo "not exist!" \
fi;
clean: repo
```
Running `make clean` gives me an error:
```
/bin/sh: -c: line 4: syntax error: unexpected end of file
make: *** [repo] Error 2
`... | 2019/06/20 | [
"https://Stackoverflow.com/questions/56677765",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3728233/"
] | try this.
```
var _html = "<p>" + ${new_data[i].name}: ${new_data[i].val} + "</p>";
``` | Try this:
```
<p>
<span style="display:block">${new_data[i].name}:</span> ${new_data[i].val}
</p>
``` |
45,319,365 | i am trying to include the view page in angularjs but it is working.
Here is my code
**rootService.js**
```
var viewCustomerModule = angular.module('viewCustomer',['ngRoute','ngResource']);
viewCustomerModule.config(function($routProvider){
$routeProvider
.when('/CustomerList',{
templateUrl:... | 2017/07/26 | [
"https://Stackoverflow.com/questions/45319365",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3270329/"
] | You are concatenating Quantity and String (txtAddQty.Text)
```
"UPDATE tblproducts SET Quantity = Quantity + " + Convert.ToInt32(txtAddQty.Text) +
" WHERE ProductId='" + txtProductId.Text + "'"
```
**Caution**
1. Above SQL Statement fails if txtAddQty.Text gives alphabets instead of numeric value.
2. Also will fai... | imho, `Quantity=Quantity+'"+txtAddQty.Text+"'` will not work.
you need to remove those `'` since you would add a varchar to an int
edit: You also could use a debugger to check the output of your string. |
45,319,365 | i am trying to include the view page in angularjs but it is working.
Here is my code
**rootService.js**
```
var viewCustomerModule = angular.module('viewCustomer',['ngRoute','ngResource']);
viewCustomerModule.config(function($routProvider){
$routeProvider
.when('/CustomerList',{
templateUrl:... | 2017/07/26 | [
"https://Stackoverflow.com/questions/45319365",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3270329/"
] | imho, `Quantity=Quantity+'"+txtAddQty.Text+"'` will not work.
you need to remove those `'` since you would add a varchar to an int
edit: You also could use a debugger to check the output of your string. | Try removing the single quotes as you are trying to add it as a number. Only use quotes for strings.
Example:
```
UPDATE tblproducts SET Quantity=Quantity+"+txtAddQty.Text+" WHERE ProductId='"+txtProductId.Text+"' "
``` |
45,319,365 | i am trying to include the view page in angularjs but it is working.
Here is my code
**rootService.js**
```
var viewCustomerModule = angular.module('viewCustomer',['ngRoute','ngResource']);
viewCustomerModule.config(function($routProvider){
$routeProvider
.when('/CustomerList',{
templateUrl:... | 2017/07/26 | [
"https://Stackoverflow.com/questions/45319365",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3270329/"
] | You are concatenating Quantity and String (txtAddQty.Text)
```
"UPDATE tblproducts SET Quantity = Quantity + " + Convert.ToInt32(txtAddQty.Text) +
" WHERE ProductId='" + txtProductId.Text + "'"
```
**Caution**
1. Above SQL Statement fails if txtAddQty.Text gives alphabets instead of numeric value.
2. Also will fai... | I guess `Quantity` is numeric, so you should remove the apostrophes `'` in your string.
And please do not generate SQL-queries with string concatenation.
Use parameterized queries: [How do I create a parameterized SQL query? Why Should I?](https://stackoverflow.com/questions/542510/how-do-i-create-a-parameterized-sq... |
45,319,365 | i am trying to include the view page in angularjs but it is working.
Here is my code
**rootService.js**
```
var viewCustomerModule = angular.module('viewCustomer',['ngRoute','ngResource']);
viewCustomerModule.config(function($routProvider){
$routeProvider
.when('/CustomerList',{
templateUrl:... | 2017/07/26 | [
"https://Stackoverflow.com/questions/45319365",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3270329/"
] | I guess `Quantity` is numeric, so you should remove the apostrophes `'` in your string.
And please do not generate SQL-queries with string concatenation.
Use parameterized queries: [How do I create a parameterized SQL query? Why Should I?](https://stackoverflow.com/questions/542510/how-do-i-create-a-parameterized-sq... | Try removing the single quotes as you are trying to add it as a number. Only use quotes for strings.
Example:
```
UPDATE tblproducts SET Quantity=Quantity+"+txtAddQty.Text+" WHERE ProductId='"+txtProductId.Text+"' "
``` |
45,319,365 | i am trying to include the view page in angularjs but it is working.
Here is my code
**rootService.js**
```
var viewCustomerModule = angular.module('viewCustomer',['ngRoute','ngResource']);
viewCustomerModule.config(function($routProvider){
$routeProvider
.when('/CustomerList',{
templateUrl:... | 2017/07/26 | [
"https://Stackoverflow.com/questions/45319365",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3270329/"
] | You are concatenating Quantity and String (txtAddQty.Text)
```
"UPDATE tblproducts SET Quantity = Quantity + " + Convert.ToInt32(txtAddQty.Text) +
" WHERE ProductId='" + txtProductId.Text + "'"
```
**Caution**
1. Above SQL Statement fails if txtAddQty.Text gives alphabets instead of numeric value.
2. Also will fai... | Try removing the single quotes as you are trying to add it as a number. Only use quotes for strings.
Example:
```
UPDATE tblproducts SET Quantity=Quantity+"+txtAddQty.Text+" WHERE ProductId='"+txtProductId.Text+"' "
``` |
1,589,669 | How do I show that the differential equation $x'=x^2$ has unstable solutions when $x(0)\geq 0$ but asymptotically stable solutions when $x(0)\leq0$?
Usually, I look at the eigenvalues of the matrix to determine stability of solutions, but since there is no matrix here, how do I approach this?
Edit: the solutions are ... | 2015/12/26 | [
"https://math.stackexchange.com/questions/1589669",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/301048/"
] | Your $f$ doesn't satisfy intermediate value theorem. We have $f(-0.5)=0.5,f(0.5)=-0.5$, so intermediate value theorem (if it held in this case) would tell us that there is a number $\alpha$ between $-0.5$ and $0.5$ such that $f(\alpha)=0$, since $0$ is between $f(-0.5)$ and $f(0.5)$, but this isn't true. | The function $f$ is not a derivative. (!) Precisely, there exists no differentiable function $F$ on $[-2, 2]$ satisfying $F'(x) = f(x)$ for all $x$ in $[-2, 2]$. (The problematic point is $x = 0$.) |
1,503 | Maybe this seems like a peculiar thing to ask, but out of curiosity, is it possible to link the URL `maths.stackexchange.com` to the current `math.stackexchange.com` site?
As an Australian, it's "maths" not "math". | 2011/01/07 | [
"https://math.meta.stackexchange.com/questions/1503",
"https://math.meta.stackexchange.com",
"https://math.meta.stackexchange.com/users/139/"
] | We have added the alias - it will be active after our next deployment. | We'll look at this, as a redirect synonym for the URL. |
55,788,368 | I want to change a table row background color when clicked and back to what it was originally when another row clicked.
I tried something like this:
index.js
```
state = {
color: []
}
render(){
return (
<Table>
<thead>
<tr>
<th>name</th>
<th>a... | 2019/04/22 | [
"https://Stackoverflow.com/questions/55788368",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11392803/"
] | You can maintain a `selectedRow` in the `state` and add a class name to the row based on matching index.
```
className={this.state.selectedRow === i ? "tableSelected" : "" }
```
Full working code below
```js
class App extends React.Component {
state = {
selectedRow: -1
};
render() {
return (
... | You can just set the index to your state and if the index equals what is set then add your color like so:
```
class YourComponent extends Component {
state = {
isActive: null
};
toggleActive = i => {
//Remove the if statement if you don't want to unselect an already selected item
if (i === this.stat... |
29,943,441 | I have the following data in PowerQuery:
```
| ParentX | A |
| ParentY | A |
| ParentZ | A |
| ParentY | B |
| ParentZ | B |
| ParentX | C |
| ParentY | C |
| ParentZ | C |
```
I want to add an index column that counts the number of parents for an element:
```
| ParentX | A | 3 |
| ParentY | A | 2 |
| ParentZ | A |... | 2015/04/29 | [
"https://Stackoverflow.com/questions/29943441",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6171/"
] | Here's the query I used to generate the index column in the question:
```
let
// This has the original parent/child column
Source = #"Parent Child Query",
// Count the number of parents per child
#"Grouped Rows" = Table.Group(Source, {"Attribute:id"}, {{"Count", each Table.RowCount(_), type number}}),... | 1. Create an Excel Table with 2 Columns (`Parents`, `Child`)
2. Use this Table in Power Query
3. Insert function `Combiner.CombineTextByDelimiter(";")` (See Line3)
4. Group by `Child` and use function above (See Line 4)
5. Split result (Line 5)
**The code:**
```
let
Quelle = Excel.CurrentWorkbook(){[Name="Tabe... |
47,488 | I'm diving in to Domain Driven Design and some of the concepts i'm coming across make a lot of sense on the surface, but when I think about them more I have to wonder if that's really a good idea.
The concept of Aggregates, for instance makes sense. You create small domains of ownership so that you don't have to deal ... | 2011/02/13 | [
"https://softwareengineering.stackexchange.com/questions/47488",
"https://softwareengineering.stackexchange.com",
"https://softwareengineering.stackexchange.com/users/4368/"
] | Don't use your Domain Model and aggregates for querying.
In fact, what you are asking is a common enough question that a set of principles and patterns has been established to avoid just that. It is called [CQRS](https://web.archive.org/web/20150118024058/http://cre8ivethought.com/blog/2009/11/12/cqrs--la-greg-young). | My use of DDD may not be considered "pure" DDD but I have adapted the following real world strategies using DDD against a DB data store.
* A aggregate root has an associated
repository
* The associated repository
is only used by that aggregate root
(it is not publicly available)
* A repository can contain query calls... |
47,488 | I'm diving in to Domain Driven Design and some of the concepts i'm coming across make a lot of sense on the surface, but when I think about them more I have to wonder if that's really a good idea.
The concept of Aggregates, for instance makes sense. You create small domains of ownership so that you don't have to deal ... | 2011/02/13 | [
"https://softwareengineering.stackexchange.com/questions/47488",
"https://softwareengineering.stackexchange.com",
"https://softwareengineering.stackexchange.com/users/4368/"
] | Don't use your Domain Model and aggregates for querying.
In fact, what you are asking is a common enough question that a set of principles and patterns has been established to avoid just that. It is called [CQRS](https://web.archive.org/web/20150118024058/http://cre8ivethought.com/blog/2009/11/12/cqrs--la-greg-young). | I don't think your GetOrderHeaders method defeats the purpose of the repository at all.
DDD is concerned (among other things) with ensuring that you get what you need by way of the aggregate root (you wouldn't have a OrderDetailsRepository, for instance), but it doesn't limit you in the way you are mentioning.
If an... |
47,488 | I'm diving in to Domain Driven Design and some of the concepts i'm coming across make a lot of sense on the surface, but when I think about them more I have to wonder if that's really a good idea.
The concept of Aggregates, for instance makes sense. You create small domains of ownership so that you don't have to deal ... | 2011/02/13 | [
"https://softwareengineering.stackexchange.com/questions/47488",
"https://softwareengineering.stackexchange.com",
"https://softwareengineering.stackexchange.com/users/4368/"
] | I struggled, and am still struggling, with how to best use the repository pattern in a Domain Driven Design. After using it now for the first time, I came up with the following practices:
1. A repository should be simple; it is only responsible for storing domain objects and retrieving them. All other logic should be ... | I know this is an old question but I appear to have come to a different answer.
When I make a Repository it's generally wrapping some **cached** queries.
>
> Fowler defines a repository as a data store that uses collection semantics, and is generally kept in-memory. This means creating an entire object graph.
>
>
... |
47,488 | I'm diving in to Domain Driven Design and some of the concepts i'm coming across make a lot of sense on the surface, but when I think about them more I have to wonder if that's really a good idea.
The concept of Aggregates, for instance makes sense. You create small domains of ownership so that you don't have to deal ... | 2011/02/13 | [
"https://softwareengineering.stackexchange.com/questions/47488",
"https://softwareengineering.stackexchange.com",
"https://softwareengineering.stackexchange.com/users/4368/"
] | Your domain model contains your business logic in its purest form. All the relationships and operations that support business operations. What you're missing from your conceptual map is the idea of the [Application Service Layer](http://martinfowler.com/eaaCatalog/serviceLayer.html) the service layer wraps around the d... | I know this is an old question but I appear to have come to a different answer.
When I make a Repository it's generally wrapping some **cached** queries.
>
> Fowler defines a repository as a data store that uses collection semantics, and is generally kept in-memory. This means creating an entire object graph.
>
>
... |
47,488 | I'm diving in to Domain Driven Design and some of the concepts i'm coming across make a lot of sense on the surface, but when I think about them more I have to wonder if that's really a good idea.
The concept of Aggregates, for instance makes sense. You create small domains of ownership so that you don't have to deal ... | 2011/02/13 | [
"https://softwareengineering.stackexchange.com/questions/47488",
"https://softwareengineering.stackexchange.com",
"https://softwareengineering.stackexchange.com/users/4368/"
] | Don't use your Domain Model and aggregates for querying.
In fact, what you are asking is a common enough question that a set of principles and patterns has been established to avoid just that. It is called [CQRS](https://web.archive.org/web/20150118024058/http://cre8ivethought.com/blog/2009/11/12/cqrs--la-greg-young). | Your domain model contains your business logic in its purest form. All the relationships and operations that support business operations. What you're missing from your conceptual map is the idea of the [Application Service Layer](http://martinfowler.com/eaaCatalog/serviceLayer.html) the service layer wraps around the d... |
47,488 | I'm diving in to Domain Driven Design and some of the concepts i'm coming across make a lot of sense on the surface, but when I think about them more I have to wonder if that's really a good idea.
The concept of Aggregates, for instance makes sense. You create small domains of ownership so that you don't have to deal ... | 2011/02/13 | [
"https://softwareengineering.stackexchange.com/questions/47488",
"https://softwareengineering.stackexchange.com",
"https://softwareengineering.stackexchange.com/users/4368/"
] | My use of DDD may not be considered "pure" DDD but I have adapted the following real world strategies using DDD against a DB data store.
* A aggregate root has an associated
repository
* The associated repository
is only used by that aggregate root
(it is not publicly available)
* A repository can contain query calls... | I know this is an old question but I appear to have come to a different answer.
When I make a Repository it's generally wrapping some **cached** queries.
>
> Fowler defines a repository as a data store that uses collection semantics, and is generally kept in-memory. This means creating an entire object graph.
>
>
... |
47,488 | I'm diving in to Domain Driven Design and some of the concepts i'm coming across make a lot of sense on the surface, but when I think about them more I have to wonder if that's really a good idea.
The concept of Aggregates, for instance makes sense. You create small domains of ownership so that you don't have to deal ... | 2011/02/13 | [
"https://softwareengineering.stackexchange.com/questions/47488",
"https://softwareengineering.stackexchange.com",
"https://softwareengineering.stackexchange.com/users/4368/"
] | Don't use your Domain Model and aggregates for querying.
In fact, what you are asking is a common enough question that a set of principles and patterns has been established to avoid just that. It is called [CQRS](https://web.archive.org/web/20150118024058/http://cre8ivethought.com/blog/2009/11/12/cqrs--la-greg-young). | I know this is an old question but I appear to have come to a different answer.
When I make a Repository it's generally wrapping some **cached** queries.
>
> Fowler defines a repository as a data store that uses collection semantics, and is generally kept in-memory. This means creating an entire object graph.
>
>
... |
47,488 | I'm diving in to Domain Driven Design and some of the concepts i'm coming across make a lot of sense on the surface, but when I think about them more I have to wonder if that's really a good idea.
The concept of Aggregates, for instance makes sense. You create small domains of ownership so that you don't have to deal ... | 2011/02/13 | [
"https://softwareengineering.stackexchange.com/questions/47488",
"https://softwareengineering.stackexchange.com",
"https://softwareengineering.stackexchange.com/users/4368/"
] | Don't use your Domain Model and aggregates for querying.
In fact, what you are asking is a common enough question that a set of principles and patterns has been established to avoid just that. It is called [CQRS](https://web.archive.org/web/20150118024058/http://cre8ivethought.com/blog/2009/11/12/cqrs--la-greg-young). | I struggled, and am still struggling, with how to best use the repository pattern in a Domain Driven Design. After using it now for the first time, I came up with the following practices:
1. A repository should be simple; it is only responsible for storing domain objects and retrieving them. All other logic should be ... |
47,488 | I'm diving in to Domain Driven Design and some of the concepts i'm coming across make a lot of sense on the surface, but when I think about them more I have to wonder if that's really a good idea.
The concept of Aggregates, for instance makes sense. You create small domains of ownership so that you don't have to deal ... | 2011/02/13 | [
"https://softwareengineering.stackexchange.com/questions/47488",
"https://softwareengineering.stackexchange.com",
"https://softwareengineering.stackexchange.com/users/4368/"
] | I struggled, and am still struggling, with how to best use the repository pattern in a Domain Driven Design. After using it now for the first time, I came up with the following practices:
1. A repository should be simple; it is only responsible for storing domain objects and retrieving them. All other logic should be ... | Your domain model contains your business logic in its purest form. All the relationships and operations that support business operations. What you're missing from your conceptual map is the idea of the [Application Service Layer](http://martinfowler.com/eaaCatalog/serviceLayer.html) the service layer wraps around the d... |
47,488 | I'm diving in to Domain Driven Design and some of the concepts i'm coming across make a lot of sense on the surface, but when I think about them more I have to wonder if that's really a good idea.
The concept of Aggregates, for instance makes sense. You create small domains of ownership so that you don't have to deal ... | 2011/02/13 | [
"https://softwareengineering.stackexchange.com/questions/47488",
"https://softwareengineering.stackexchange.com",
"https://softwareengineering.stackexchange.com/users/4368/"
] | I struggled, and am still struggling, with how to best use the repository pattern in a Domain Driven Design. After using it now for the first time, I came up with the following practices:
1. A repository should be simple; it is only responsible for storing domain objects and retrieving them. All other logic should be ... | I don't think your GetOrderHeaders method defeats the purpose of the repository at all.
DDD is concerned (among other things) with ensuring that you get what you need by way of the aggregate root (you wouldn't have a OrderDetailsRepository, for instance), but it doesn't limit you in the way you are mentioning.
If an... |
52,749,754 | How do I concatenate two shortest path responses from igraph so that they make one path? i.e.
```
set.seed(6857)
g <- sample_smallworld(1, 100, 5, 0.05) #Building a random graph
sp <- get.shortest.paths(g, 5, 70, output = "both")
sp1 <- get.shortest.paths(g, 70, 80, output = "both")
```
then something like:
`sp <- ... | 2018/10/10 | [
"https://Stackoverflow.com/questions/52749754",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5380809/"
] | ***Option 1***
If you need to store the results in a list, you can use unpacking and arithmetic:
```
>>> [[*range(i*x, i*x+x)] for i in range(y)]
[[0, 1, 2, 3, 4], [5, 6, 7, 8, 9]]
```
***Option 2***
If you're just interested in printing the values, you don't need to waste space by creating the intermediate subli... | You could use numpy. As you simply count in the range of `[0, x*y[` and just want to have it plotted in a certain shape, numpy can exactly do that in a one liner:
```
import numpy as np
x = 5
y = 2
np.arange(x*y).reshape(y, x)
```
Result:
```
array([[0, 1, 2, 3, 4],
[5, 6, 7, 8, 9]])
``` |
52,749,754 | How do I concatenate two shortest path responses from igraph so that they make one path? i.e.
```
set.seed(6857)
g <- sample_smallworld(1, 100, 5, 0.05) #Building a random graph
sp <- get.shortest.paths(g, 5, 70, output = "both")
sp1 <- get.shortest.paths(g, 70, 80, output = "both")
```
then something like:
`sp <- ... | 2018/10/10 | [
"https://Stackoverflow.com/questions/52749754",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5380809/"
] | ***Option 1***
If you need to store the results in a list, you can use unpacking and arithmetic:
```
>>> [[*range(i*x, i*x+x)] for i in range(y)]
[[0, 1, 2, 3, 4], [5, 6, 7, 8, 9]]
```
***Option 2***
If you're just interested in printing the values, you don't need to waste space by creating the intermediate subli... | It looks like you're just trying to print things, rather than store them (if you want to store them, the other answers look good). You can do it manually with this sort of loop:
```
for i,v in enumerate(range(y*x)):
if (i+1)%x == 0:
print(v)
else:
print(v,end=' ')
```
Output:
```
0 1 2 3 4
5... |
52,749,754 | How do I concatenate two shortest path responses from igraph so that they make one path? i.e.
```
set.seed(6857)
g <- sample_smallworld(1, 100, 5, 0.05) #Building a random graph
sp <- get.shortest.paths(g, 5, 70, output = "both")
sp1 <- get.shortest.paths(g, 70, 80, output = "both")
```
then something like:
`sp <- ... | 2018/10/10 | [
"https://Stackoverflow.com/questions/52749754",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5380809/"
] | ***Option 1***
If you need to store the results in a list, you can use unpacking and arithmetic:
```
>>> [[*range(i*x, i*x+x)] for i in range(y)]
[[0, 1, 2, 3, 4], [5, 6, 7, 8, 9]]
```
***Option 2***
If you're just interested in printing the values, you don't need to waste space by creating the intermediate subli... | You can compose various itertools iterators to create your own generator:
```
>>> from itertools import count, islice
>>> def foo(x, y):
... elements = count()
... for _ in range(y):
... yield list(islice(elements, x))
...
>>> for es in foo(5, 2):
... print(*es)
...
0 1 2 3 4
5 6 7 8 9
``` |
52,749,754 | How do I concatenate two shortest path responses from igraph so that they make one path? i.e.
```
set.seed(6857)
g <- sample_smallworld(1, 100, 5, 0.05) #Building a random graph
sp <- get.shortest.paths(g, 5, 70, output = "both")
sp1 <- get.shortest.paths(g, 70, 80, output = "both")
```
then something like:
`sp <- ... | 2018/10/10 | [
"https://Stackoverflow.com/questions/52749754",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5380809/"
] | ***Option 1***
If you need to store the results in a list, you can use unpacking and arithmetic:
```
>>> [[*range(i*x, i*x+x)] for i in range(y)]
[[0, 1, 2, 3, 4], [5, 6, 7, 8, 9]]
```
***Option 2***
If you're just interested in printing the values, you don't need to waste space by creating the intermediate subli... | EDIT: Thanks to @juanpa.arrivillaga this "range-with-offset"-idea became a serious approach in the end:
```
for i in range(y):
print(*range(i*x, (i+1)*x))
0 1 2 3 4
5 6 7 8 9
``` |
11,074,993 | I'm building a tutorialsystem with codeigniter and would like to achieve the following URL structure:
* /tutorials --> an introduction page with the list of all the categories
* /tutorials/{a category as string} --> this will give a list of tutorials for the given category, e.g. /tutorials/php
* /tutorials/{a category... | 2012/06/17 | [
"https://Stackoverflow.com/questions/11074993",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1358858/"
] | Your routing rules could be in this order:
```
$route['tutorials/add'] = "tutorials/add"; //assuming you have an add() method
$route['tutorials/(:any)'] = "tutorials/index"; //this will comply with anything which is not tutorials/add
```
Then in your controller's index() method you should be able to work out whether... | A few minutes after posting, I think I've found a possible solution for this. (Shame on me).
In pseudo code:
```
public function index($cat = FALSE, $id = FALSE)
{
if($cat !== FALSE) {
if($cat === 'add') {
$this->add();
} else {
if($id !== FALSE) {
// Fetch ... |
11,074,993 | I'm building a tutorialsystem with codeigniter and would like to achieve the following URL structure:
* /tutorials --> an introduction page with the list of all the categories
* /tutorials/{a category as string} --> this will give a list of tutorials for the given category, e.g. /tutorials/php
* /tutorials/{a category... | 2012/06/17 | [
"https://Stackoverflow.com/questions/11074993",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1358858/"
] | I do think that a remap must be of more use to your problem in case you want to add more methods to your controller, not just 'add'. This should do the task:
```
function _remap($method)
{
if (method_exists($this, $method))
{
$this->$method();
}
else {
$this->index($method);
}
}
``` | A few minutes after posting, I think I've found a possible solution for this. (Shame on me).
In pseudo code:
```
public function index($cat = FALSE, $id = FALSE)
{
if($cat !== FALSE) {
if($cat === 'add') {
$this->add();
} else {
if($id !== FALSE) {
// Fetch ... |
11,074,993 | I'm building a tutorialsystem with codeigniter and would like to achieve the following URL structure:
* /tutorials --> an introduction page with the list of all the categories
* /tutorials/{a category as string} --> this will give a list of tutorials for the given category, e.g. /tutorials/php
* /tutorials/{a category... | 2012/06/17 | [
"https://Stackoverflow.com/questions/11074993",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1358858/"
] | Your routing rules could be in this order:
```
$route['tutorials/add'] = "tutorials/add"; //assuming you have an add() method
$route['tutorials/(:any)'] = "tutorials/index"; //this will comply with anything which is not tutorials/add
```
Then in your controller's index() method you should be able to work out whether... | I do think that a remap must be of more use to your problem in case you want to add more methods to your controller, not just 'add'. This should do the task:
```
function _remap($method)
{
if (method_exists($this, $method))
{
$this->$method();
}
else {
$this->index($method);
}
}
``` |
23,155,135 | I have this record.
```
id performer end_time
300135 testuser 15-OCT-13
300135 testuser 14-OCT-13
300135 testuser 12-OCT-13
300137 newuser 14-OCT-13
300137 newuser 18-OCT-13
... | 2014/04/18 | [
"https://Stackoverflow.com/questions/23155135",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/764446/"
] | You need GROUP BY
```
select id, performer, max(END_TIME) from workstep where workstep_name = 'Review' and status ='W_COMPLETED' group by id,performer
``` | When you ask for unique row of 3 columns (id, performer, END\_TIME )
you will get rows where combination of all 3 columns is unique (your first data listing)
There is simply not enough conditions to get from your first listing to the second one.
I assume that you want distint IDs, and for that IDs, you want to select... |
1,238,449 | is there a way with jTemplates to escape {$, so i can use inline javascript in my onBlur like
```
<a href="http://www.telegraaf.nl" onclick="if ( a ) {$('#something').css ('display','none');alert('some msg');}">telegraaf</a>
```
which gets this after processTemplate:
```
<a onclick="if ( a ) " href="http://www... | 2009/08/06 | [
"https://Stackoverflow.com/questions/1238449",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47354/"
] | Actually, in my opinion, I think its best to attach the event unobtrusively :
```
$(function () {
$(".alink").click(function () {
//if ( a ) {
$('#something').css('display','none');
alert('some msg');
//}
});
});
<a class="alink" href="http://www.telegraaf.nl">
``` | If you're using jQuery then the $ is essentially just a shortcut to saying jQuery(expression) so in your case you can use:
```
<a href="http://www.telegraaf.nl" onclick="if ( a ) {jQuery('#something').css ('display','none');alert('some msg');}">telegraaf</a>
```
You can read up on the selector shortcut at <http:... |
1,238,449 | is there a way with jTemplates to escape {$, so i can use inline javascript in my onBlur like
```
<a href="http://www.telegraaf.nl" onclick="if ( a ) {$('#something').css ('display','none');alert('some msg');}">telegraaf</a>
```
which gets this after processTemplate:
```
<a onclick="if ( a ) " href="http://www... | 2009/08/06 | [
"https://Stackoverflow.com/questions/1238449",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47354/"
] | Actually, in my opinion, I think its best to attach the event unobtrusively :
```
$(function () {
$(".alink").click(function () {
//if ( a ) {
$('#something').css('display','none');
alert('some msg');
//}
});
});
<a class="alink" href="http://www.telegraaf.nl">
``` | ```
var test = function(el) {
if ( a ) {
$('#something').css('display','none');
alert('some msg');
}
});
<a onclick="test(this);" href="http://www.telegraaf.nl">
``` |
1,238,449 | is there a way with jTemplates to escape {$, so i can use inline javascript in my onBlur like
```
<a href="http://www.telegraaf.nl" onclick="if ( a ) {$('#something').css ('display','none');alert('some msg');}">telegraaf</a>
```
which gets this after processTemplate:
```
<a onclick="if ( a ) " href="http://www... | 2009/08/06 | [
"https://Stackoverflow.com/questions/1238449",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47354/"
] | Actually, in my opinion, I think its best to attach the event unobtrusively :
```
$(function () {
$(".alink").click(function () {
//if ( a ) {
$('#something').css('display','none');
alert('some msg');
//}
});
});
<a class="alink" href="http://www.telegraaf.nl">
``` | If you don't want to move your JS to separate secion or external file then you can always use `jQuery` "keyword" instead of `$`
```
<a href="http://www.telegraaf.nl" onclick="if( a ) {jQuery('#something').css('display','none');alert('some msg');}">telegraaf</a>
```
This way `$` won't be interpreted as a template var... |
1,238,449 | is there a way with jTemplates to escape {$, so i can use inline javascript in my onBlur like
```
<a href="http://www.telegraaf.nl" onclick="if ( a ) {$('#something').css ('display','none');alert('some msg');}">telegraaf</a>
```
which gets this after processTemplate:
```
<a onclick="if ( a ) " href="http://www... | 2009/08/06 | [
"https://Stackoverflow.com/questions/1238449",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47354/"
] | jTemplates has a {#literal} ... {#/literal} tag that should prevent your curly braces from being affected.
```
<a href="http://www.telegraaf.nl" onclick="{#literal}if ( a ) {$('#something').css ('display','none');alert('some msg');}{#/literal}">telegraaf</a>
``` | Actually, in my opinion, I think its best to attach the event unobtrusively :
```
$(function () {
$(".alink").click(function () {
//if ( a ) {
$('#something').css('display','none');
alert('some msg');
//}
});
});
<a class="alink" href="http://www.telegraaf.nl">
``` |
1,238,449 | is there a way with jTemplates to escape {$, so i can use inline javascript in my onBlur like
```
<a href="http://www.telegraaf.nl" onclick="if ( a ) {$('#something').css ('display','none');alert('some msg');}">telegraaf</a>
```
which gets this after processTemplate:
```
<a onclick="if ( a ) " href="http://www... | 2009/08/06 | [
"https://Stackoverflow.com/questions/1238449",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47354/"
] | jTemplates has a {#literal} ... {#/literal} tag that should prevent your curly braces from being affected.
```
<a href="http://www.telegraaf.nl" onclick="{#literal}if ( a ) {$('#something').css ('display','none');alert('some msg');}{#/literal}">telegraaf</a>
``` | If you're using jQuery then the $ is essentially just a shortcut to saying jQuery(expression) so in your case you can use:
```
<a href="http://www.telegraaf.nl" onclick="if ( a ) {jQuery('#something').css ('display','none');alert('some msg');}">telegraaf</a>
```
You can read up on the selector shortcut at <http:... |
1,238,449 | is there a way with jTemplates to escape {$, so i can use inline javascript in my onBlur like
```
<a href="http://www.telegraaf.nl" onclick="if ( a ) {$('#something').css ('display','none');alert('some msg');}">telegraaf</a>
```
which gets this after processTemplate:
```
<a onclick="if ( a ) " href="http://www... | 2009/08/06 | [
"https://Stackoverflow.com/questions/1238449",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47354/"
] | jTemplates has a {#literal} ... {#/literal} tag that should prevent your curly braces from being affected.
```
<a href="http://www.telegraaf.nl" onclick="{#literal}if ( a ) {$('#something').css ('display','none');alert('some msg');}{#/literal}">telegraaf</a>
``` | ```
var test = function(el) {
if ( a ) {
$('#something').css('display','none');
alert('some msg');
}
});
<a onclick="test(this);" href="http://www.telegraaf.nl">
``` |
1,238,449 | is there a way with jTemplates to escape {$, so i can use inline javascript in my onBlur like
```
<a href="http://www.telegraaf.nl" onclick="if ( a ) {$('#something').css ('display','none');alert('some msg');}">telegraaf</a>
```
which gets this after processTemplate:
```
<a onclick="if ( a ) " href="http://www... | 2009/08/06 | [
"https://Stackoverflow.com/questions/1238449",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47354/"
] | jTemplates has a {#literal} ... {#/literal} tag that should prevent your curly braces from being affected.
```
<a href="http://www.telegraaf.nl" onclick="{#literal}if ( a ) {$('#something').css ('display','none');alert('some msg');}{#/literal}">telegraaf</a>
``` | If you don't want to move your JS to separate secion or external file then you can always use `jQuery` "keyword" instead of `$`
```
<a href="http://www.telegraaf.nl" onclick="if( a ) {jQuery('#something').css('display','none');alert('some msg');}">telegraaf</a>
```
This way `$` won't be interpreted as a template var... |
23,458,310 | I have this country table:
```
+----+-----------+
| ID | Country |
+----+-----------+
| 1 | Indonesia |
| 2 | Malaysia |
| 3 | Brunei |
+----+-----------+
```
and this form:
```
<form action="search.php" method="post" accept-charset="utf-8">
<label>From:</label>
<select name="from_country">
... | 2014/05/04 | [
"https://Stackoverflow.com/questions/23458310",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3110574/"
] | Use jQuery as PHP is server side.
```
<form action="search.php" method="post" accept-charset="utf-8">
<label>From:</label>
<select name="from_country" id='from'>
<option value="1">Indonesia</option>
<option value="2">Malaysia</option>
<option value="3">Brunei</option>
</select>
<label>To:</label>
<select... | i have test it, works as you required
```
<form action="search.php" method="post" accept-charset="utf-8">
<label>From:</label>
<select name="from_country" id='from'>
<option value="1">Indonesia</option>
<option value="2">Malaysia</option>
<option value="3">Brunei</option>
</select>... |
29,379,698 | Can anyone tell me why I'm getting the following error:
```
exception 'Symfony\Component\Debug\Exception\FatalErrorException' with message 'Class 'PayPal\Rest\ApiContext' not found'
```
Here is my Controller code:
```
<?php
use PayPal\Rest\ApiContext;
use PayPal\Auth\OAuthTokenCredential;
use PayPal\Api\Amount;
us... | 2015/03/31 | [
"https://Stackoverflow.com/questions/29379698",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/337806/"
] | I just installed the package from composer on a L5 installation and it worked, so here's what I think will help you:
If you're not using composer, remove everything related to paypal and use it, it helps.. a lot.
Remove the paypal package from `composer.json`, `composer update`, `composer dumpautoload`, `php artisan ... | If you are using [composer](https://github.com/paypal/PayPal-PHP-SDK/wiki/Installation-Composer) to download the PayPal-PHP-SDK, you would need to add the `include` statement to add all the classes, as shown below:
```
// 1. Autoload the SDK Package. This will include all the files and classes to your autoloader
requi... |
55,690 | In *Das Schwarze Auge* (4.1), when do I have to announce that I want to parry my enemy's attack? Do I have to declare that before his attack is rolled and I know if he hits me or not, or can I wait to declare it after? I can't find the page in the rules where this is stated. My guess would be to announce it after the a... | 2015/01/21 | [
"https://rpg.stackexchange.com/questions/55690",
"https://rpg.stackexchange.com",
"https://rpg.stackexchange.com/users/18056/"
] | As easy as this question sounds, it is possibly one of the most discussed and overruled things in the DSA Ruleset... partially because it is so damn confusing/bad. Lets look at the rulebooks - Wege des Schwerts is the relevant one.
Since you asked for Rules as Written, let me translate that section from the book on pa... | The only thing you have to announce at the beginning of a combat round, is the number of attack/defensive actions (ie 2/0, 1/1, 0/2, or later even more)
There is a special feat, that allows you to instantly change that (without having to announce at the beginning of the combat round), to use opportunities from e.g. th... |
55,690 | In *Das Schwarze Auge* (4.1), when do I have to announce that I want to parry my enemy's attack? Do I have to declare that before his attack is rolled and I know if he hits me or not, or can I wait to declare it after? I can't find the page in the rules where this is stated. My guess would be to announce it after the a... | 2015/01/21 | [
"https://rpg.stackexchange.com/questions/55690",
"https://rpg.stackexchange.com",
"https://rpg.stackexchange.com/users/18056/"
] | As easy as this question sounds, it is possibly one of the most discussed and overruled things in the DSA Ruleset... partially because it is so damn confusing/bad. Lets look at the rulebooks - Wege des Schwerts is the relevant one.
Since you asked for Rules as Written, let me translate that section from the book on pa... | As a Naheulbeuk DM and player, a french RPG based on DSA, here how we fight a combat round :
1. The attacker (PC or NPC) do an Attack roll while announcing where he tries to hit. If it succeeds, then :
2. The target announces a parry or evade try. Evade is usually easier because it's a Dexterity/Agility roll but you'l... |
55,690 | In *Das Schwarze Auge* (4.1), when do I have to announce that I want to parry my enemy's attack? Do I have to declare that before his attack is rolled and I know if he hits me or not, or can I wait to declare it after? I can't find the page in the rules where this is stated. My guess would be to announce it after the a... | 2015/01/21 | [
"https://rpg.stackexchange.com/questions/55690",
"https://rpg.stackexchange.com",
"https://rpg.stackexchange.com/users/18056/"
] | The only thing you have to announce at the beginning of a combat round, is the number of attack/defensive actions (ie 2/0, 1/1, 0/2, or later even more)
There is a special feat, that allows you to instantly change that (without having to announce at the beginning of the combat round), to use opportunities from e.g. th... | As a Naheulbeuk DM and player, a french RPG based on DSA, here how we fight a combat round :
1. The attacker (PC or NPC) do an Attack roll while announcing where he tries to hit. If it succeeds, then :
2. The target announces a parry or evade try. Evade is usually easier because it's a Dexterity/Agility roll but you'l... |
8,536,364 | I want to write a function which employs openMP parallelism but should work whether called from within a parallel region or not. So I used the `if` clause to suppress parallelism, but this doesn't work as I thought:
```
#include <omp.h>
#include <stdio.h>
int m=0,s=0;
void func()
{
bool p = omp_in_parallel();
//... | 2011/12/16 | [
"https://Stackoverflow.com/questions/8536364",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1023390/"
] | The OpenMP constructs will always bind to the innermost containing construct, even if it isn't active. So I don't think it's possible while retaining the `#pragma omp parallel` for both code paths (At least with the provided informations about the problem).
Note that it is a good think that it behaves like this, becau... | I had a look at the openMP standard. The `if` clause is actually somewhat misleadingly coined, for the `#pragma omp parallel` directive is not conditional (as I originally thought). Instead the `if` clause may restrict the number of threads to 1 thereby suppressing parallelisation.
However, this implies `omp single` o... |
38,763,775 | my current coding style is like
```
import xxx
def fun1()
def fun2()
...
if __name__ == '__main__':
task = sys.argv[1]
if task =='task1':
do task1
elif task == 'task2':
do task2
...
```
my problem is that the part of the code under
```
if __name__ == '__main__':
```
is quite... | 2016/08/04 | [
"https://Stackoverflow.com/questions/38763775",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4260762/"
] | Like BusyAnt said, the common way to do it is
```
import xxx
def fun1()
def fun2()
...
def main():
task = sys.argv[1]
if task =='task1':
do task1
elif task == 'task2':
do task2
...
if __name__ == '__main__':
main()
```
The upside of this is it does not run on `import`, but `ma... | **It is not forbidden** to write a lot of things under `if __name__ == '__main__'`, though it is considered better and more readable to **wrap everything up in a `main()` function**. This way, the code in `main()` isn't executed when you `import` this module in another module, **but** you can still choose to run it, by... |
16,032,534 | So i have been trying to use stdarg for indefinite arguments. For int it works great but now i am trying this with char pointer. This is my code:
```
void updateValue(char *parameter, parameterTypes type, ...)
{
va_list arg_list;
U32 value;
char* stringValue;
va_start(arg_list, typ... | 2013/04/16 | [
"https://Stackoverflow.com/questions/16032534",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1847357/"
] | You're supposed to *use* the `type` argument to figure out the type of the variable part. You seem to be accessing *both* a `U32` and a `char*`, when only passing a single argument.
You need something like:
```
if( type == stringType )
{
char *stringValue = va_arg(arg_list, char *);
print("got string '%s'\n", str... | With these two lines
```
value = va_arg(arg_list, U32);
stringValue = va_arg(arg_list, char*);
```
you try to get *two* values from the stack, but you only pass *one* argument for the va-list. This means that when you try to get the string you will go outside the parameter list on the stack, and get a seemingly rand... |
11,761,639 | I am trying to call the `$_SESSION` `username` variable so that It will show in a URL like
```
/users/USERNAME/
```
I know there's a way to do this, but I must be doing it wrong because here's the error I get: Parse error: syntax error,
```
unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or
T_VARIABLE o... | 2012/08/01 | [
"https://Stackoverflow.com/questions/11761639",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1476205/"
] | Wrong mixing of `"` and `'` and one `"` missing
```
move_uploaded_file( $_FILES['md']['tmp_name'], "users/".$_SESSION['username']."/".$_FILES['md']['name'] );
``` | You have a parse error.
```
"users/"
```
not
```
"users/'
``` |
11,761,639 | I am trying to call the `$_SESSION` `username` variable so that It will show in a URL like
```
/users/USERNAME/
```
I know there's a way to do this, but I must be doing it wrong because here's the error I get: Parse error: syntax error,
```
unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or
T_VARIABLE o... | 2012/08/01 | [
"https://Stackoverflow.com/questions/11761639",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1476205/"
] | Wrong mixing of `"` and `'` and one `"` missing
```
move_uploaded_file( $_FILES['md']['tmp_name'], "users/".$_SESSION['username']."/".$_FILES['md']['name'] );
``` | You're not closing your string before concatenation.
```
move_uploaded_file( $_FILES['md']['tmp_name'], "users/" . $_SESSION['username'] . $_FILES['md']['name'] );
``` |
11,761,639 | I am trying to call the `$_SESSION` `username` variable so that It will show in a URL like
```
/users/USERNAME/
```
I know there's a way to do this, but I must be doing it wrong because here's the error I get: Parse error: syntax error,
```
unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or
T_VARIABLE o... | 2012/08/01 | [
"https://Stackoverflow.com/questions/11761639",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1476205/"
] | Wrong mixing of `"` and `'` and one `"` missing
```
move_uploaded_file( $_FILES['md']['tmp_name'], "users/".$_SESSION['username']."/".$_FILES['md']['name'] );
``` | you have a bug in code, try this
```
move_uploaded_file( $_FILES['md']['tmp_name'],"users/".$_SESSION['username'].$_FILES['md']['name'] );
```
or
```
move_uploaded_file( $_FILES['md']['tmp_name'],"users/".$_SESSION['username']."/".$_FILES['md']['name'] );
``` |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.