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 |
|---|---|---|---|---|---|
44,440,680 | I am new to node and am trying to using [A node.js library for the Pardot API](https://www.npmjs.com/package/node-pardot)
This I pass my `userKey`, `email` and `password` to pardot, this returns my `api_key`.
I am using the following code to authenticate, then when I run my node server I can see the api\_key being p... | 2017/06/08 | [
"https://Stackoverflow.com/questions/44440680",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2975042/"
] | Looking at the source of node-pardot [here](https://github.com/Datahero/node-pardot/blob/development/lib/pardot/PardotAPI_v3.js#L23) and [here](https://github.com/Datahero/node-pardot/blob/development/lib/pardot/PardotAPI_v3.js#L50), it looks like the API Key is at `client.apiKey`
Also, you should always check for the... | It seems like you're trying to assign the value of an undeclared variable to itself in
```
var api_key = api_key;
```
You should be assigning it the value in the response, i.e.
```
var api_key = client.api_key;
``` |
10,794,566 | Can anyone suggest a good open source app that uses django-guardian? I'm not having trouble understanding the API, but I'd love to see an example to get a feel for implementation best practice (database design, etc.) | 2012/05/29 | [
"https://Stackoverflow.com/questions/10794566",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1133318/"
] | If you clone the [django-guardian](https://github.com/lukaszb/django-guardian) source code you have a working example of how to use it.
And in this [link](https://github.com/lukaszb/django-guardian/blob/master/docs/userguide/admin-integration.rst) are the instructions for integrating it with django admin | Django userena uses Django-guardian: <https://github.com/bread-and-pepper/django-userena> |
35,136,197 | I have an interesting mathematical problem that I just cant figure out.
I am building a watch face for android wear and need to work out the angle of rotation for the hands based on the time.
Ordinarily this would be simple but here's the kicker: the hands are not central on the clock.
Lets say I have a clock face th... | 2016/02/01 | [
"https://Stackoverflow.com/questions/35136197",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1408221/"
] | Ok, with the help Nico's answer I've manage to make tweaks and get a working example.
The main changes that needed to be incorporated were changing the order of inputs to the atan calculation as well as making tweaks because of android's insistence to do coordinate systems upside down.
Please see my code below.
```
... | Just calculate the angle based on the direction vector.
First, calculate the target position. For the minute hand, this could be:
```
targetX = radius * sin(2 * Pi / 60 * minutes)
targetY = radius * cos(2 * Pi / 60 * minutes)
```
Then calculate the direction vector from the hand's pivot to the target:
```
directio... |
1,961,436 | I'm trying to work on a proof by induction. The statement is:
Let n be even. Then, $(x+1)^n = x^n + 1$ for $n\in\mathbb{N}\cup{0}$ and $(x^n+1) \in \mathbb{F}\_2[x]$
Base case: $n=0$ and $n=2$ both satisfy the condition, fairly trivially. I include the $n=2$ case specifically to draw upon later.
We suppose true fo... | 2016/10/09 | [
"https://math.stackexchange.com/questions/1961436",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/376838/"
] | After multiplying things out, one gets
\begin{align}
h\_{ii}=\frac{1}{nS\_{xx}}\left(\sum\_{j=1}^{n} x\_{j}^{2}-2n\bar{x}x\_{i}+nx\_{i}^{2}\right)&=\frac{1}{nS\_{xx}}\left(\sum\_{j=1}^{n} x\_{j}^{2}-n\bar{x}^{2}+[n\bar{x}^{2}-2n\bar{x}x\_{i}+nx\_{i}^{2}]\right)\\
&=\frac{1}{nS\_{xx}}\left(\sum\_{j=1}^{n} x\_{j}^{2}-n\b... | \begin{align}
h\_{ii}&=\frac{1}{nS\_{xx}}(\sum\_{j=1}^n x\_j^2 -2n\bar{x}x\_i+nx\_i^2+n\bar{x}^2\_n-n\bar{x}^2\_n)\\
&=\frac{1}{nS\_{xx}}\left((\sum\_{j=1}^n x\_j^2 -n\bar{x}^2\_n)+n(-2\bar{x}x\_i+x\_i^2+\bar{x}^2\_n)\right)\\
&=\frac{1}{n}+\frac{(x\_i-\bar{x}\_n)^2}{S\_{xx}}
\end{align} |
101,961 | Each term in the squaring sequence, \$x\_n\$, is created by taking \$x\_{n-1}\$, squaring it, and removing all but the first four digits.
The sequence always begins with \$x\_1 = 1111\$. Squaring this yields \$1234321\$, so \$x\_2 = 1234\$
The first few terms are:
```
1111
1234
1522
2316
5363
...
```
---
The Chal... | 2016/12/02 | [
"https://codegolf.stackexchange.com/questions/101961",
"https://codegolf.stackexchange.com",
"https://codegolf.stackexchange.com/users/60919/"
] | Python 2, ~~44~~ 41 bytes
=========================
-3 bytes thanks to xnor (use an integer division to avoid `and`)
```python
f=lambda n:int(1/n*1111or`f(n-1)**2`[:4])
```
**[repl.it](https://repl.it/EenM/1)**
1-based recursive function.
When `n>1` the integer division, `1/n`, results in `0`, then `0*1111=0` whi... | [q](https://code.kx.com/home/), 26 bytes
========================================
```
{"J"$4#string x*x}/[;1111]
```
k, 18 bytes
===========
```
{.:4#$x*x}/[;1111]
``` |
101,961 | Each term in the squaring sequence, \$x\_n\$, is created by taking \$x\_{n-1}\$, squaring it, and removing all but the first four digits.
The sequence always begins with \$x\_1 = 1111\$. Squaring this yields \$1234321\$, so \$x\_2 = 1234\$
The first few terms are:
```
1111
1234
1522
2316
5363
...
```
---
The Chal... | 2016/12/02 | [
"https://codegolf.stackexchange.com/questions/101961",
"https://codegolf.stackexchange.com",
"https://codegolf.stackexchange.com/users/60919/"
] | Haskell, 40 bytes
-----------------
```
((iterate(read.take 4.show.(^2))1111)!!)
```
It's a 0-based sequence. Usage example: `((iterate(read.take 4.show.(^2))1111)!!) 79` -> `4717`.
How it works:
```
iterate ( ) 1111 -- repeatedly apply a function starting
-- with 1... | [Husk](https://github.com/barbuz/Husk), 11 bytes
================================================
```
¡öd↑4d□1111
```
[Try it online!](https://tio.run/##yygtzv7//9DCw9tSHrVNNEl5NG2hIRD8/w8A "Husk – Try It Online") |
101,961 | Each term in the squaring sequence, \$x\_n\$, is created by taking \$x\_{n-1}\$, squaring it, and removing all but the first four digits.
The sequence always begins with \$x\_1 = 1111\$. Squaring this yields \$1234321\$, so \$x\_2 = 1234\$
The first few terms are:
```
1111
1234
1522
2316
5363
...
```
---
The Chal... | 2016/12/02 | [
"https://codegolf.stackexchange.com/questions/101961",
"https://codegolf.stackexchange.com",
"https://codegolf.stackexchange.com/users/60919/"
] | C, 56 bytes
===========
```
a;s(n){for(a=1111;--n;)a=a*a/(a>3162?1e4:1e3);return a;}
```
One-indexed. | Java, ~~79~~ ~~67~~ ~~66~~ 64 bytes
===================================
* Version 2.2/**64** bytes:
Thanks to @Oliver Grégoire.
```
int a(int i){i=i<2?1111:a(--i);for(i*=i;i>1e4;)i/=10;return i;}
```
* Version 2.1/**66** bytes:
Thanks to @ETHProduction.
```
long a(long i){i=i<2?1111:a(--i);for(i*=i;i>1e4;)i/=10;... |
101,961 | Each term in the squaring sequence, \$x\_n\$, is created by taking \$x\_{n-1}\$, squaring it, and removing all but the first four digits.
The sequence always begins with \$x\_1 = 1111\$. Squaring this yields \$1234321\$, so \$x\_2 = 1234\$
The first few terms are:
```
1111
1234
1522
2316
5363
...
```
---
The Chal... | 2016/12/02 | [
"https://codegolf.stackexchange.com/questions/101961",
"https://codegolf.stackexchange.com",
"https://codegolf.stackexchange.com/users/60919/"
] | [Japt](https://github.com/ETHproductions/japt) [`-mh`](https://codegolf.meta.stackexchange.com/a/14339/), 9 [bytes](https://en.wikipedia.org/wiki/ISO/IEC_8859-1)
==============================================================================================================================================================... | [C++ (clang)](http://clang.llvm.org/), 52 bytes
===============================================
```cpp
void s(int&n){n=--n?s(n),n*n/1e3/(n<3163?:10):1111;}
```
Port of [Lynn's C answer](https://codegolf.stackexchange.com/a/102003/112488) using recursion, is 1 indexed and returns via out parameter.
[Try it online!](... |
101,961 | Each term in the squaring sequence, \$x\_n\$, is created by taking \$x\_{n-1}\$, squaring it, and removing all but the first four digits.
The sequence always begins with \$x\_1 = 1111\$. Squaring this yields \$1234321\$, so \$x\_2 = 1234\$
The first few terms are:
```
1111
1234
1522
2316
5363
...
```
---
The Chal... | 2016/12/02 | [
"https://codegolf.stackexchange.com/questions/101961",
"https://codegolf.stackexchange.com",
"https://codegolf.stackexchange.com/users/60919/"
] | Ruby, 47 bytes
==============
First golf! Saves bytes with `-n` option (but still count as 1! :)).
```
a=1111;$_.to_i.times{a="#{a*a}"[0,4].to_i};p a
```
0-indexed.
To run it:
```
ruby -ne 'a=1111;$_.to_i.times{a="#{a*a}"[0,4].to_i};p a' <<< 80
``` | Java, ~~79~~ ~~67~~ ~~66~~ 64 bytes
===================================
* Version 2.2/**64** bytes:
Thanks to @Oliver Grégoire.
```
int a(int i){i=i<2?1111:a(--i);for(i*=i;i>1e4;)i/=10;return i;}
```
* Version 2.1/**66** bytes:
Thanks to @ETHProduction.
```
long a(long i){i=i<2?1111:a(--i);for(i*=i;i>1e4;)i/=10;... |
101,961 | Each term in the squaring sequence, \$x\_n\$, is created by taking \$x\_{n-1}\$, squaring it, and removing all but the first four digits.
The sequence always begins with \$x\_1 = 1111\$. Squaring this yields \$1234321\$, so \$x\_2 = 1234\$
The first few terms are:
```
1111
1234
1522
2316
5363
...
```
---
The Chal... | 2016/12/02 | [
"https://codegolf.stackexchange.com/questions/101961",
"https://codegolf.stackexchange.com",
"https://codegolf.stackexchange.com/users/60919/"
] | Python 2, ~~44~~ 41 bytes
=========================
-3 bytes thanks to xnor (use an integer division to avoid `and`)
```python
f=lambda n:int(1/n*1111or`f(n-1)**2`[:4])
```
**[repl.it](https://repl.it/EenM/1)**
1-based recursive function.
When `n>1` the integer division, `1/n`, results in `0`, then `0*1111=0` whi... | brev, 66 bytes
==============
```
(fn(eif x(strse*((fn(* x x))(f(- x 1)))"^...."(m 0)0)1111))
```
There's no `square` unless I import the math lib so `(fn(* x x))` had to do. Using a regex to yank the first four digits.
This is zero-indexed. |
101,961 | Each term in the squaring sequence, \$x\_n\$, is created by taking \$x\_{n-1}\$, squaring it, and removing all but the first four digits.
The sequence always begins with \$x\_1 = 1111\$. Squaring this yields \$1234321\$, so \$x\_2 = 1234\$
The first few terms are:
```
1111
1234
1522
2316
5363
...
```
---
The Chal... | 2016/12/02 | [
"https://codegolf.stackexchange.com/questions/101961",
"https://codegolf.stackexchange.com",
"https://codegolf.stackexchange.com/users/60919/"
] | [Jelly](http://github.com/DennisMitchell/jelly), ~~12~~ 9 bytes
===============================================================
-3 bytes thanks to Dennis using 1-based indexing and the `ṁ` mold/reshape atom. Golfing suggestions welcome! [Try it online!](http://jelly.tryitonline.net/#code=wrJE4bmBNOG4jAoxw4fCoQ&input=&... | [Brachylog](http://github.com/JCumin/Brachylog), 18 bytes
=========================================================
```
,1111:?:{^@[.l4,}i
```
[Try it online!](http://brachylog.tryitonline.net/#code=LDExMTE6Pzp7XkBbLmw0LH1p&input=Nzk&args=Wg)
This answer is 0-indexed.
### Explanation
```
,1111:?:{ }i I... |
101,961 | Each term in the squaring sequence, \$x\_n\$, is created by taking \$x\_{n-1}\$, squaring it, and removing all but the first four digits.
The sequence always begins with \$x\_1 = 1111\$. Squaring this yields \$1234321\$, so \$x\_2 = 1234\$
The first few terms are:
```
1111
1234
1522
2316
5363
...
```
---
The Chal... | 2016/12/02 | [
"https://codegolf.stackexchange.com/questions/101961",
"https://codegolf.stackexchange.com",
"https://codegolf.stackexchange.com/users/60919/"
] | [Javagony](https://esolangs.org/wiki/Javagony) - 153 bytes
==========================================================
Javagony is a restricted version of Java, that doesn't allow any control flow except recursion and `try-catch`, no for loops, while loops, or if's. Coding in it is a pretty fun exercise, but frustratin... | [CJam](https://sourceforge.net/p/cjam), 15 bytes
------------------------------------------------
```
'14*ri{i2#s4<}*
```
Uses 0-based indexing.
[Try it online!](https://tio.run/nexus/cjam#@69uaKJVlFmdaaRcbGJTq/X/vwkA "CJam – TIO Nexus") |
101,961 | Each term in the squaring sequence, \$x\_n\$, is created by taking \$x\_{n-1}\$, squaring it, and removing all but the first four digits.
The sequence always begins with \$x\_1 = 1111\$. Squaring this yields \$1234321\$, so \$x\_2 = 1234\$
The first few terms are:
```
1111
1234
1522
2316
5363
...
```
---
The Chal... | 2016/12/02 | [
"https://codegolf.stackexchange.com/questions/101961",
"https://codegolf.stackexchange.com",
"https://codegolf.stackexchange.com/users/60919/"
] | Pyke, 10 bytes
--------------
```
1RVX`4*4<b
```
[Try it here!](http://pyke.catbus.co.uk/?code=1RVX%604%2a4%3Cb&input=5) | [><>](https://esolangs.org/wiki/Fish), ~~40~~ 36 bytes
======================================================
```
"e"b*>$1-:@?!n:*v
%1:,av? (*"dd":<-
```
[Try it online!](https://tio.run/##S8sszvj/XylVKUnLTsVQ18rBXjHPSquMS9XQSiexzF5BQUNLKSVFycpG9////7plFgA "><> – Try It Online")
**Explanation**
```
... |
101,961 | Each term in the squaring sequence, \$x\_n\$, is created by taking \$x\_{n-1}\$, squaring it, and removing all but the first four digits.
The sequence always begins with \$x\_1 = 1111\$. Squaring this yields \$1234321\$, so \$x\_2 = 1234\$
The first few terms are:
```
1111
1234
1522
2316
5363
...
```
---
The Chal... | 2016/12/02 | [
"https://codegolf.stackexchange.com/questions/101961",
"https://codegolf.stackexchange.com",
"https://codegolf.stackexchange.com/users/60919/"
] | Ruby, 47 bytes
==============
First golf! Saves bytes with `-n` option (but still count as 1! :)).
```
a=1111;$_.to_i.times{a="#{a*a}"[0,4].to_i};p a
```
0-indexed.
To run it:
```
ruby -ne 'a=1111;$_.to_i.times{a="#{a*a}"[0,4].to_i};p a' <<< 80
``` | [C++ (clang)](http://clang.llvm.org/), 52 bytes
===============================================
```cpp
void s(int&n){n=--n?s(n),n*n/1e3/(n<3163?:10):1111;}
```
Port of [Lynn's C answer](https://codegolf.stackexchange.com/a/102003/112488) using recursion, is 1 indexed and returns via out parameter.
[Try it online!](... |
29,253,102 | ```
<asp:ImageButton ID="imgbtn_RoleGuideWin8" runat="server" ImageUrl="~/Images/Windows Logo.png" Width="215px" OnClick="imgbtn_RoleGuideWeb_Click" OnClientClick="fnOnWin8ButtonClick()" />
```
I have this code using asp.net.I want to convert it to HTML. For doing that I have written this code:
```
<input type="ima... | 2015/03/25 | [
"https://Stackoverflow.com/questions/29253102",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1259705/"
] | `*((U*) &data)` will violate strict aliasing if this is a `reinterpret_cast` and the type `U` is not permitted to alias the type `T`. The permitted types appear in [this list](https://stackoverflow.com/a/7005988/1505939).
The rule refers to [both reading and writing](https://stackoverflow.com/questions/29001319/in-c-w... | >
> However, I am never using a pointer to *write* data [...]
>
>
>
The language in the standard is more general than this; **[basic.life]**/7 has:
>
> [...] a pointer that
> pointed to the original object, a reference that referred to the original object, or the name of the original
> object [...]
>
>
>
I... |
14,128,595 | Let G be DAG with n vertices and m edges given by adjacency matrix. I need to calculate it's closure in form of a matrix as well. We have a computer that each word is b bits. and I need to find an algorithm that calculate the transitive closure in `(n^2+nm/b)`
I'm not really sure I understand what `bits` means and how... | 2013/01/02 | [
"https://Stackoverflow.com/questions/14128595",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1320292/"
] | You say you don't know what *bits* mean, so let's start with that.
* **Bit** is the smallest unit of digital information - a 0 or a 1
* **Word** is the unit of data processed by a computer at once. Processors don't take and process individual bits, but small chunks of them. Most today's computer architectures use word... | For a simple graph, each entry in the adjacency matrix is either 0 or 1 and can be represented by one bit. This allows a compact representation of the matrix by packing `b` entries into each computer word. The challenge then is to implement matrix multiplication (to compute the closure) using the correct bit manipulati... |
55,269,508 | I'd like to obtain all *unique* products for a given vector.
For example, given `a`:
```
a = [4,10,12,3,6]
```
I want to obtain a matrix that contains the results of:
```
4*10
4*12
4*3
4*6
10*12
10*3
10*6
12*3
12*6
3*6
```
Is there a short and/or quick way of doing this in MATLAB?
**EDIT**: `a` may contain dup... | 2019/03/20 | [
"https://Stackoverflow.com/questions/55269508",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4030463/"
] | Given:
```
a =
4 10 12 3 6
```
Construct the matrix of *all* pairwise products:
```
>> all_products = a .* a.'
all_products =
16 40 48 12 24
40 100 120 30 60
48 120 144 36 72
12 30 36 9 18
24 60 72 18 36
```
Now, constru... | Try starting with this. Have the unique function filter out the result of multiplying a by itself.
```
b = unique(a*a')
``` |
55,269,508 | I'd like to obtain all *unique* products for a given vector.
For example, given `a`:
```
a = [4,10,12,3,6]
```
I want to obtain a matrix that contains the results of:
```
4*10
4*12
4*3
4*6
10*12
10*3
10*6
12*3
12*6
3*6
```
Is there a short and/or quick way of doing this in MATLAB?
**EDIT**: `a` may contain dup... | 2019/03/20 | [
"https://Stackoverflow.com/questions/55269508",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4030463/"
] | One option involves [`nchoosek`](https://www.mathworks.com/help/matlab/ref/nchoosek.html), which returns all combinations of `k` elements out of a vector, each row is one combination. `prod` computes the product of rows or columns:
```
a = [4,10,12,3,6];
b = nchoosek(a,2);
b = prod(b,2); % 2 indicates rows
``` | Try starting with this. Have the unique function filter out the result of multiplying a by itself.
```
b = unique(a*a')
``` |
55,269,508 | I'd like to obtain all *unique* products for a given vector.
For example, given `a`:
```
a = [4,10,12,3,6]
```
I want to obtain a matrix that contains the results of:
```
4*10
4*12
4*3
4*6
10*12
10*3
10*6
12*3
12*6
3*6
```
Is there a short and/or quick way of doing this in MATLAB?
**EDIT**: `a` may contain dup... | 2019/03/20 | [
"https://Stackoverflow.com/questions/55269508",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4030463/"
] | If you have the Statistics Toolbox, you can abuse [`pdist`](https://www.mathworks.com/help/stats/pdist.html), which considers only one of the two possible orders for each pair:
```
result = pdist(a(:), @times);
``` | Try starting with this. Have the unique function filter out the result of multiplying a by itself.
```
b = unique(a*a')
``` |
55,269,508 | I'd like to obtain all *unique* products for a given vector.
For example, given `a`:
```
a = [4,10,12,3,6]
```
I want to obtain a matrix that contains the results of:
```
4*10
4*12
4*3
4*6
10*12
10*3
10*6
12*3
12*6
3*6
```
Is there a short and/or quick way of doing this in MATLAB?
**EDIT**: `a` may contain dup... | 2019/03/20 | [
"https://Stackoverflow.com/questions/55269508",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4030463/"
] | Given:
```
a =
4 10 12 3 6
```
Construct the matrix of *all* pairwise products:
```
>> all_products = a .* a.'
all_products =
16 40 48 12 24
40 100 120 30 60
48 120 144 36 72
12 30 36 9 18
24 60 72 18 36
```
Now, constru... | One option involves [`nchoosek`](https://www.mathworks.com/help/matlab/ref/nchoosek.html), which returns all combinations of `k` elements out of a vector, each row is one combination. `prod` computes the product of rows or columns:
```
a = [4,10,12,3,6];
b = nchoosek(a,2);
b = prod(b,2); % 2 indicates rows
``` |
55,269,508 | I'd like to obtain all *unique* products for a given vector.
For example, given `a`:
```
a = [4,10,12,3,6]
```
I want to obtain a matrix that contains the results of:
```
4*10
4*12
4*3
4*6
10*12
10*3
10*6
12*3
12*6
3*6
```
Is there a short and/or quick way of doing this in MATLAB?
**EDIT**: `a` may contain dup... | 2019/03/20 | [
"https://Stackoverflow.com/questions/55269508",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4030463/"
] | Given:
```
a =
4 10 12 3 6
```
Construct the matrix of *all* pairwise products:
```
>> all_products = a .* a.'
all_products =
16 40 48 12 24
40 100 120 30 60
48 120 144 36 72
12 30 36 9 18
24 60 72 18 36
```
Now, constru... | If you have the Statistics Toolbox, you can abuse [`pdist`](https://www.mathworks.com/help/stats/pdist.html), which considers only one of the two possible orders for each pair:
```
result = pdist(a(:), @times);
``` |
24,018,577 | I have a text that i need to parse in python.
It is a string where i would like to split it to a list of lines,
however, if the newlines (\n) is inside quotes then we should ignore it.
for example:
```
abcd efgh ijk\n1234 567"qqqq\n---" 890\n
```
should be parsed into a list of the following lines:
```
abcd efgh... | 2014/06/03 | [
"https://Stackoverflow.com/questions/24018577",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2476373/"
] | You can split it, then reduce it to put together the elements that have an odd number of `"` :
```
txt = 'abcd efgh ijk\n1234 567"qqqq\n---" 890\n'
s = txt.split('\n')
reduce(lambda x, y: x[:-1] + [x[-1] + '\n' + y] if x[-1].count('"') % 2 == 1 else x + [y], s[1:], [s[0]])
# ['abcd efgh ijk', '1234 567"qqqq\n---" 890'... | Ok, this seems to work (assuming quotes are properly balanced):
```
rx = r"""(?x)
\n
(?!
[^"]*
"
(?=
[^"]*
(?:
" [^"]* "
[^"]*
)*
$
)
)
"""
```
Test:
```
str = """\
first
second "qqq
qqq
... |
24,018,577 | I have a text that i need to parse in python.
It is a string where i would like to split it to a list of lines,
however, if the newlines (\n) is inside quotes then we should ignore it.
for example:
```
abcd efgh ijk\n1234 567"qqqq\n---" 890\n
```
should be parsed into a list of the following lines:
```
abcd efgh... | 2014/06/03 | [
"https://Stackoverflow.com/questions/24018577",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2476373/"
] | You can split it, then reduce it to put together the elements that have an odd number of `"` :
```
txt = 'abcd efgh ijk\n1234 567"qqqq\n---" 890\n'
s = txt.split('\n')
reduce(lambda x, y: x[:-1] + [x[-1] + '\n' + y] if x[-1].count('"') % 2 == 1 else x + [y], s[1:], [s[0]])
# ['abcd efgh ijk', '1234 567"qqqq\n---" 890'... | There are many ways to accomplish that. I came up with a very simple one:
```
splitted = [""]
for i, x in enumerate(re.split('"', text)):
if i % 2 == 0:
lines = x.split('\n')
splitted[-1] += lines[0]
splitted.extend(lines[1:])
else:
splitted[-1] += '"{0}"'.format(x)
``` |
24,018,577 | I have a text that i need to parse in python.
It is a string where i would like to split it to a list of lines,
however, if the newlines (\n) is inside quotes then we should ignore it.
for example:
```
abcd efgh ijk\n1234 567"qqqq\n---" 890\n
```
should be parsed into a list of the following lines:
```
abcd efgh... | 2014/06/03 | [
"https://Stackoverflow.com/questions/24018577",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2476373/"
] | Here's a much easier solution.
Match groups of `(?:"[^"]*"|.)+`. Namely, "things in quotes or things that aren't newlines".
Example:
```
import re
re.findall('(?:"[^"]*"|.)+', text)
```
---
**NOTE:** This coalesces several newlines into one, as blank lines are ignored. To avoid that, give a null case as well: `(?... | You can split it, then reduce it to put together the elements that have an odd number of `"` :
```
txt = 'abcd efgh ijk\n1234 567"qqqq\n---" 890\n'
s = txt.split('\n')
reduce(lambda x, y: x[:-1] + [x[-1] + '\n' + y] if x[-1].count('"') % 2 == 1 else x + [y], s[1:], [s[0]])
# ['abcd efgh ijk', '1234 567"qqqq\n---" 890'... |
24,018,577 | I have a text that i need to parse in python.
It is a string where i would like to split it to a list of lines,
however, if the newlines (\n) is inside quotes then we should ignore it.
for example:
```
abcd efgh ijk\n1234 567"qqqq\n---" 890\n
```
should be parsed into a list of the following lines:
```
abcd efgh... | 2014/06/03 | [
"https://Stackoverflow.com/questions/24018577",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2476373/"
] | Here's a much easier solution.
Match groups of `(?:"[^"]*"|.)+`. Namely, "things in quotes or things that aren't newlines".
Example:
```
import re
re.findall('(?:"[^"]*"|.)+', text)
```
---
**NOTE:** This coalesces several newlines into one, as blank lines are ignored. To avoid that, give a null case as well: `(?... | Ok, this seems to work (assuming quotes are properly balanced):
```
rx = r"""(?x)
\n
(?!
[^"]*
"
(?=
[^"]*
(?:
" [^"]* "
[^"]*
)*
$
)
)
"""
```
Test:
```
str = """\
first
second "qqq
qqq
... |
24,018,577 | I have a text that i need to parse in python.
It is a string where i would like to split it to a list of lines,
however, if the newlines (\n) is inside quotes then we should ignore it.
for example:
```
abcd efgh ijk\n1234 567"qqqq\n---" 890\n
```
should be parsed into a list of the following lines:
```
abcd efgh... | 2014/06/03 | [
"https://Stackoverflow.com/questions/24018577",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2476373/"
] | Here's a much easier solution.
Match groups of `(?:"[^"]*"|.)+`. Namely, "things in quotes or things that aren't newlines".
Example:
```
import re
re.findall('(?:"[^"]*"|.)+', text)
```
---
**NOTE:** This coalesces several newlines into one, as blank lines are ignored. To avoid that, give a null case as well: `(?... | There are many ways to accomplish that. I came up with a very simple one:
```
splitted = [""]
for i, x in enumerate(re.split('"', text)):
if i % 2 == 0:
lines = x.split('\n')
splitted[-1] += lines[0]
splitted.extend(lines[1:])
else:
splitted[-1] += '"{0}"'.format(x)
``` |
97,822 | *You can find the other Vowelburger™ Riddles [here](https://puzzling.stackexchange.com/search?q=vowelburger+is%3Aquestion)*
I ordered 5 Vowelburgers™ with buns and meat only at the **linguistic restaurant** - help me identify each one from the description on the menu!
The buns are [pulmonic consonants](https://en.w... | 2020/05/03 | [
"https://puzzling.stackexchange.com/questions/97822",
"https://puzzling.stackexchange.com",
"https://puzzling.stackexchange.com/users/63414/"
] | I think the buns are
>
> [S](https://en.wikipedia.org/wiki/Voiceless_alveolar_fricative#Voiceless_alveolar_sibilant) and [M](https://en.wikipedia.org/wiki/Voiced_bilabial_nasal)
>
>
>
graveyard
>
> CEM (short for cemetry)
>
>
>
aggregate
>
> SUM
>
>
>
card
>
> SIM
>
>
>
look
>
> SEEM (the... | I think
>
> the first consonant is /s/ and the second one is /z/
>
>
>
and the words are:
*graveyard*
>
> ???
>
>
>
*aggregate*
>
> SIZE
>
>
>
*card*
>
> ???
>
>
>
*look*
>
> SEES
>
>
>
*states*
>
> SAYS
>
>
> |
21,671,272 | I'm getting a segmentation error (core dump) when I try to run this. It compiles perfectly but I get the error, and I don't know why. I've tried to edit my code in all possible ways, but am still getting this error. I'm out of ideas already. Any help would be great. Thanks!
```
unsigned short *reg = NULL;
int... | 2014/02/10 | [
"https://Stackoverflow.com/questions/21671272",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3291818/"
] | You are passing a `NULL` `reg` into `crc_byte()`, which passes it to `crc_bit()`, which then tries to dereference it.
Change the function like so:
```
unsigned short reg = 0; /* replace 0 with whatever value is appropriate */
...
for (byte = 0; byte < num_bytes; byte++){
...
crc_byte(®, key, next_byte); ... | `reg` is `NULL` in `crc_message`. This gets passed on to `crc_byte` which gets passed on to `crc_bit`. Then use access a location which has an address `NULL`. |
21,671,272 | I'm getting a segmentation error (core dump) when I try to run this. It compiles perfectly but I get the error, and I don't know why. I've tried to edit my code in all possible ways, but am still getting this error. I'm out of ideas already. Any help would be great. Thanks!
```
unsigned short *reg = NULL;
int... | 2014/02/10 | [
"https://Stackoverflow.com/questions/21671272",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3291818/"
] | Compile with debugging info:
```
> gcc -o myprog myprog.c -ggdb
```
Run in a debugger
```
> gdb myprog
(gdb) run
```
Debugger tells you where the segfault occurred:
```
Program received signal SIGSEGV, Segmentation fault.
0x0040133d in crc_bit (reg=0x0, key=12345, next_bit=0) at rrr.c:4
4 unsigned int ... | You are passing a `NULL` `reg` into `crc_byte()`, which passes it to `crc_bit()`, which then tries to dereference it.
Change the function like so:
```
unsigned short reg = 0; /* replace 0 with whatever value is appropriate */
...
for (byte = 0; byte < num_bytes; byte++){
...
crc_byte(®, key, next_byte); ... |
21,671,272 | I'm getting a segmentation error (core dump) when I try to run this. It compiles perfectly but I get the error, and I don't know why. I've tried to edit my code in all possible ways, but am still getting this error. I'm out of ideas already. Any help would be great. Thanks!
```
unsigned short *reg = NULL;
int... | 2014/02/10 | [
"https://Stackoverflow.com/questions/21671272",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3291818/"
] | You are passing a `NULL` `reg` into `crc_byte()`, which passes it to `crc_bit()`, which then tries to dereference it.
Change the function like so:
```
unsigned short reg = 0; /* replace 0 with whatever value is appropriate */
...
for (byte = 0; byte < num_bytes; byte++){
...
crc_byte(®, key, next_byte); ... | For me, your segmentation fault problem comes from the reg pointer which is NULL.
This means that you will modify an unisgned hsort value located at address zero. On most operating systems, this is not allowed.
Why don't you do the following thing ?
```
unsigned short crc_message(unsigned int key, char *message, int ... |
21,671,272 | I'm getting a segmentation error (core dump) when I try to run this. It compiles perfectly but I get the error, and I don't know why. I've tried to edit my code in all possible ways, but am still getting this error. I'm out of ideas already. Any help would be great. Thanks!
```
unsigned short *reg = NULL;
int... | 2014/02/10 | [
"https://Stackoverflow.com/questions/21671272",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3291818/"
] | Compile with debugging info:
```
> gcc -o myprog myprog.c -ggdb
```
Run in a debugger
```
> gdb myprog
(gdb) run
```
Debugger tells you where the segfault occurred:
```
Program received signal SIGSEGV, Segmentation fault.
0x0040133d in crc_bit (reg=0x0, key=12345, next_bit=0) at rrr.c:4
4 unsigned int ... | `reg` is `NULL` in `crc_message`. This gets passed on to `crc_byte` which gets passed on to `crc_bit`. Then use access a location which has an address `NULL`. |
21,671,272 | I'm getting a segmentation error (core dump) when I try to run this. It compiles perfectly but I get the error, and I don't know why. I've tried to edit my code in all possible ways, but am still getting this error. I'm out of ideas already. Any help would be great. Thanks!
```
unsigned short *reg = NULL;
int... | 2014/02/10 | [
"https://Stackoverflow.com/questions/21671272",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3291818/"
] | For me, your segmentation fault problem comes from the reg pointer which is NULL.
This means that you will modify an unisgned hsort value located at address zero. On most operating systems, this is not allowed.
Why don't you do the following thing ?
```
unsigned short crc_message(unsigned int key, char *message, int ... | `reg` is `NULL` in `crc_message`. This gets passed on to `crc_byte` which gets passed on to `crc_bit`. Then use access a location which has an address `NULL`. |
21,671,272 | I'm getting a segmentation error (core dump) when I try to run this. It compiles perfectly but I get the error, and I don't know why. I've tried to edit my code in all possible ways, but am still getting this error. I'm out of ideas already. Any help would be great. Thanks!
```
unsigned short *reg = NULL;
int... | 2014/02/10 | [
"https://Stackoverflow.com/questions/21671272",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3291818/"
] | Compile with debugging info:
```
> gcc -o myprog myprog.c -ggdb
```
Run in a debugger
```
> gdb myprog
(gdb) run
```
Debugger tells you where the segfault occurred:
```
Program received signal SIGSEGV, Segmentation fault.
0x0040133d in crc_bit (reg=0x0, key=12345, next_bit=0) at rrr.c:4
4 unsigned int ... | For me, your segmentation fault problem comes from the reg pointer which is NULL.
This means that you will modify an unisgned hsort value located at address zero. On most operating systems, this is not allowed.
Why don't you do the following thing ?
```
unsigned short crc_message(unsigned int key, char *message, int ... |
69,239,091 | Ok so eventually I will have let's say 100 products in mysql database. The product page pulls all info from database (such as partnumber, material, color, etc...) and inputs it into the areas of the page that I designate it, all this using php. The previous page will show all 100 products and when user click's on one p... | 2021/09/18 | [
"https://Stackoverflow.com/questions/69239091",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16403360/"
] | This could be a merge/join operation,
```r
merge(TableB, TableA, by.x = "Description", by.y = "Code", all.x = TRUE)
# Description Description.y
# 1 1 Apple
# 2 2 Banana
# 3 3 <NA>
```
(For more info on merge/join, see [How to join (merge) data frames (inner, ou... | You could use the `elucidate::translate()` function, which provides a more readable syntax for the match() solution posted by [r2evans](https://stackoverflow.com/users/3358272/r2evans).
```
tableA <- data.frame(code = c(001, 002),
Description = c("Apple", "Banana"))
tableB <- data.frame(Descripti... |
28,977,509 | I have downloaded latest version of cocos2d-x from this [link](https://github.com/cocos2d/cocos2d-x).
And worked on Visual Studio Environment and finished.
Now I am going to build it to Android and IOS for extra processes.
What can I do? | 2015/03/11 | [
"https://Stackoverflow.com/questions/28977509",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4556344/"
] | I had the same issue. It turns out the href causes the problem. If you don't want the page to scroll at all when you collapse/expand, which is what I wanted, then simply remove the href altogether. Leaving it as # still made the screen scroll to the top for me.
did not work for me:
```
<a data-toggle="collapse" data-... | Another option is to use buttons instead of anchor links, so that no `href` is triggered in the first place. For example, instead of the first `<a>`:
```
<button data-toggle="collapse" data-target="#collapseOne"
aria-expanded="true" aria-controls="collapseOne">
First list
</button>
```
There are lots of examples... |
28,977,509 | I have downloaded latest version of cocos2d-x from this [link](https://github.com/cocos2d/cocos2d-x).
And worked on Visual Studio Environment and finished.
Now I am going to build it to Android and IOS for extra processes.
What can I do? | 2015/03/11 | [
"https://Stackoverflow.com/questions/28977509",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4556344/"
] | Replace the `href` properties on the `a` elements to `#` rather than, for example, `#collapseOne`
instead of this:
```
<a data-toggle="collapse" data-target="#collapseTwo" href="#collapseTwo"
aria-expanded="true" aria-controls="collapseTwo">
```
do this
```
<a data-toggle="collapse" data-target="#collapseTwo"... | I had the same problem and I found my solution with this answer on another post.
Nothing else worked except for this tiny piece of Javascript added to my custom .js file. It smoothly brings the focus back to the selected panel title. The only thing I changed to suit my design was the distance to the top, on line 6.
... |
28,977,509 | I have downloaded latest version of cocos2d-x from this [link](https://github.com/cocos2d/cocos2d-x).
And worked on Visual Studio Environment and finished.
Now I am going to build it to Android and IOS for extra processes.
What can I do? | 2015/03/11 | [
"https://Stackoverflow.com/questions/28977509",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4556344/"
] | I had same problem (jump to the top on click to the link which was triggering the collapse toggle)
the `href="#"` was changed to `href="javascript:void(0);"` and it is working great (toggling collapse without any scrolling to the top) | This would definitely work if you are out of options:
```js
$('.panel-group').on('click', function(){
$('html,body').stop();
});
``` |
28,977,509 | I have downloaded latest version of cocos2d-x from this [link](https://github.com/cocos2d/cocos2d-x).
And worked on Visual Studio Environment and finished.
Now I am going to build it to Android and IOS for extra processes.
What can I do? | 2015/03/11 | [
"https://Stackoverflow.com/questions/28977509",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4556344/"
] | Replace the `href` properties on the `a` elements to `#` rather than, for example, `#collapseOne`
instead of this:
```
<a data-toggle="collapse" data-target="#collapseTwo" href="#collapseTwo"
aria-expanded="true" aria-controls="collapseTwo">
```
do this
```
<a data-toggle="collapse" data-target="#collapseTwo"... | Another option is to use buttons instead of anchor links, so that no `href` is triggered in the first place. For example, instead of the first `<a>`:
```
<button data-toggle="collapse" data-target="#collapseOne"
aria-expanded="true" aria-controls="collapseOne">
First list
</button>
```
There are lots of examples... |
28,977,509 | I have downloaded latest version of cocos2d-x from this [link](https://github.com/cocos2d/cocos2d-x).
And worked on Visual Studio Environment and finished.
Now I am going to build it to Android and IOS for extra processes.
What can I do? | 2015/03/11 | [
"https://Stackoverflow.com/questions/28977509",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4556344/"
] | I had same problem (jump to the top on click to the link which was triggering the collapse toggle)
the `href="#"` was changed to `href="javascript:void(0);"` and it is working great (toggling collapse without any scrolling to the top) | Another option is to use buttons instead of anchor links, so that no `href` is triggered in the first place. For example, instead of the first `<a>`:
```
<button data-toggle="collapse" data-target="#collapseOne"
aria-expanded="true" aria-controls="collapseOne">
First list
</button>
```
There are lots of examples... |
28,977,509 | I have downloaded latest version of cocos2d-x from this [link](https://github.com/cocos2d/cocos2d-x).
And worked on Visual Studio Environment and finished.
Now I am going to build it to Android and IOS for extra processes.
What can I do? | 2015/03/11 | [
"https://Stackoverflow.com/questions/28977509",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4556344/"
] | I had the same problem and I found my solution with this answer on another post.
Nothing else worked except for this tiny piece of Javascript added to my custom .js file. It smoothly brings the focus back to the selected panel title. The only thing I changed to suit my design was the distance to the top, on line 6.
... | Another option is to use buttons instead of anchor links, so that no `href` is triggered in the first place. For example, instead of the first `<a>`:
```
<button data-toggle="collapse" data-target="#collapseOne"
aria-expanded="true" aria-controls="collapseOne">
First list
</button>
```
There are lots of examples... |
28,977,509 | I have downloaded latest version of cocos2d-x from this [link](https://github.com/cocos2d/cocos2d-x).
And worked on Visual Studio Environment and finished.
Now I am going to build it to Android and IOS for extra processes.
What can I do? | 2015/03/11 | [
"https://Stackoverflow.com/questions/28977509",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4556344/"
] | I had same problem (jump to the top on click to the link which was triggering the collapse toggle)
the `href="#"` was changed to `href="javascript:void(0);"` and it is working great (toggling collapse without any scrolling to the top) | I had the same problem and I found my solution with this answer on another post.
Nothing else worked except for this tiny piece of Javascript added to my custom .js file. It smoothly brings the focus back to the selected panel title. The only thing I changed to suit my design was the distance to the top, on line 6.
... |
28,977,509 | I have downloaded latest version of cocos2d-x from this [link](https://github.com/cocos2d/cocos2d-x).
And worked on Visual Studio Environment and finished.
Now I am going to build it to Android and IOS for extra processes.
What can I do? | 2015/03/11 | [
"https://Stackoverflow.com/questions/28977509",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4556344/"
] | Another option is to use buttons instead of anchor links, so that no `href` is triggered in the first place. For example, instead of the first `<a>`:
```
<button data-toggle="collapse" data-target="#collapseOne"
aria-expanded="true" aria-controls="collapseOne">
First list
</button>
```
There are lots of examples... | You can override the click handler and use the `preventDefault()` method on the click event:
```
$('.aHandler').click( function(event) {
event.preventDefault();
...
});
```
Where the 'aHandler' is a class on your 'a' tags: `<a class="aHandler" ...>...</a>`, or is any other valid [jquery selector](https://api... |
28,977,509 | I have downloaded latest version of cocos2d-x from this [link](https://github.com/cocos2d/cocos2d-x).
And worked on Visual Studio Environment and finished.
Now I am going to build it to Android and IOS for extra processes.
What can I do? | 2015/03/11 | [
"https://Stackoverflow.com/questions/28977509",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4556344/"
] | I had same problem (jump to the top on click to the link which was triggering the collapse toggle)
the `href="#"` was changed to `href="javascript:void(0);"` and it is working great (toggling collapse without any scrolling to the top) | I had the same issue. It turns out the href causes the problem. If you don't want the page to scroll at all when you collapse/expand, which is what I wanted, then simply remove the href altogether. Leaving it as # still made the screen scroll to the top for me.
did not work for me:
```
<a data-toggle="collapse" data-... |
28,977,509 | I have downloaded latest version of cocos2d-x from this [link](https://github.com/cocos2d/cocos2d-x).
And worked on Visual Studio Environment and finished.
Now I am going to build it to Android and IOS for extra processes.
What can I do? | 2015/03/11 | [
"https://Stackoverflow.com/questions/28977509",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4556344/"
] | I had same problem (jump to the top on click to the link which was triggering the collapse toggle)
the `href="#"` was changed to `href="javascript:void(0);"` and it is working great (toggling collapse without any scrolling to the top) | You can override the click handler and use the `preventDefault()` method on the click event:
```
$('.aHandler').click( function(event) {
event.preventDefault();
...
});
```
Where the 'aHandler' is a class on your 'a' tags: `<a class="aHandler" ...>...</a>`, or is any other valid [jquery selector](https://api... |
12,051,527 | I'm using git-annex to manage my files. Some of my remotes are available using 2 or 3 methods, for example ssh and nfs, but the nfs access is only possible on my local network, of course. Then, git-annex chooses the fastest method to sync or get the files (nfs, if available, ssh instead, using scores to choose). For no... | 2012/08/21 | [
"https://Stackoverflow.com/questions/12051527",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | It's definitely possible to hide a process; you're talking about designing a **[rootkit](http://en.wikipedia.org/wiki/Rootkit)**. If that's actually what you want to do, see [this question](https://stackoverflow.com/questions/187983/how-do-i-hide-a-process-in-task-manager-in-c).
It's usually not the right way to appro... | Hide it in plain sight : make it run as a service with name that looks like it should be part of windows.
Then have another service that watches for the this one shutting down and restart it. |
12,051,527 | I'm using git-annex to manage my files. Some of my remotes are available using 2 or 3 methods, for example ssh and nfs, but the nfs access is only possible on my local network, of course. Then, git-annex chooses the fastest method to sync or get the files (nfs, if available, ssh instead, using scores to choose). For no... | 2012/08/21 | [
"https://Stackoverflow.com/questions/12051527",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | It's definitely possible to hide a process; you're talking about designing a **[rootkit](http://en.wikipedia.org/wiki/Rootkit)**. If that's actually what you want to do, see [this question](https://stackoverflow.com/questions/187983/how-do-i-hide-a-process-in-task-manager-in-c).
It's usually not the right way to appro... | That's what Windows security is for. Define user account's permission in a way that he/she cannot manage services or kill processes.
If the case is as you described in comments under Colin's answer, then you can run a service-level process that respawns user process every time it is killed (by user). This way it is ev... |
3,131,303 | I am looking to go from the process name to the windows title.
e.g
'winamp.exe' -> '1. Britney Spears - Hit me baby one more time'
Thanks
Solution:
```
Dim p As Process
For Each p In Process.GetProcessesByName("winamp")
MsgBox(p.MainWindowTitle.ToString)
Next
``` | 2010/06/28 | [
"https://Stackoverflow.com/questions/3131303",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/366252/"
] | Have a look at the [`System.Diagnostics.Process`](http://msdn.microsoft.com/en-US/library/system.diagnostics.process_members(v=VS.80).aspx) class:
```
Process p = <Get process>
Console.WriteLine(p.MainWindowTitle)
``` | Here's how to get the Filename as displayed in the Main Title Bar. This is the filename without the extension. Let's say that my Excel Workbook was named "ThisWorks.xlsx" This code returns "ThisWorks" without the file extension.
```
Function OpenAppFileNames(ByVal exeName As String) As String
Dim p() As Process =... |
12,196,688 | I'm working on a project where you can draw on the screen using touch. I thought of using OpenGL for it, however I came across two examples; one using OpenGL and the other using Quartz2D.
[Example project from Apple, GLPaint, using OpenGL](http://developer.apple.com/library/ios/#samplecode/GLPaint/Introduction/Intro.... | 2012/08/30 | [
"https://Stackoverflow.com/questions/12196688",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/281057/"
] | It is a well known fact that on the simulator, Quartz 2D can be about 5x faster than OpenGLES, because OpenGLES isn't hardware accelerated there (different chipsets, ARM vs i386).
I would encourage you strongly to test using OpenGLES on the device and compare that to Quartz 2D, and then you should experience about a ... | OpenGL can definitely reach a level beyond what Quartz can but being such a low level it often takes an expert to reach that level. Quartz was already written by experts and as long as you can live inside its limitations it should be a perfect API for your drawing app.
In my own experience I've often turned to customi... |
45,666,232 | I am having a 2 controller PayerController and BusinessController.
Both Controller constructors takes EntityManager as a parameter which is an abstract class.
I would like to resolve Each Manager class depending on the controller I am using.
For PayerController I would like to inject PayerManager class and for Busine... | 2017/08/14 | [
"https://Stackoverflow.com/questions/45666232",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2209468/"
] | I don't understand why you think you need conditional dependency injection in this situation because the solution to make it work is very simple.
You can change your controllers to inject the correct type of dependency that they need.
```
public class PayerController
{
private PayerManager Manager { get; }
pub... | Make interface for each concrete class and Injecting interface in the controller
**Startup.cs**
```
services.AddScoped<IPayerManager, PayerManager>();
services.AddScoped<IBusinessManager, BusinessManager>();
```
**Controllers**
```
public class PayerController
{
private IPayerManager _entityManager{get;}
... |
45,666,232 | I am having a 2 controller PayerController and BusinessController.
Both Controller constructors takes EntityManager as a parameter which is an abstract class.
I would like to resolve Each Manager class depending on the controller I am using.
For PayerController I would like to inject PayerManager class and for Busine... | 2017/08/14 | [
"https://Stackoverflow.com/questions/45666232",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2209468/"
] | I don't understand why you think you need conditional dependency injection in this situation because the solution to make it work is very simple.
You can change your controllers to inject the correct type of dependency that they need.
```
public class PayerController
{
private PayerManager Manager { get; }
pub... | @Maxspan, my suggestion:
Put all interfaces in Contracts folder and this folder inside your Models/Entities folder (Models/Entities folder - Contracts folder)
IEntityManager Interface
```
namespace WebApplication1.Entities.Contracts
{
public interface IEntityManager
{
//Method signature only
... |
45,666,232 | I am having a 2 controller PayerController and BusinessController.
Both Controller constructors takes EntityManager as a parameter which is an abstract class.
I would like to resolve Each Manager class depending on the controller I am using.
For PayerController I would like to inject PayerManager class and for Busine... | 2017/08/14 | [
"https://Stackoverflow.com/questions/45666232",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2209468/"
] | Make interface for each concrete class and Injecting interface in the controller
**Startup.cs**
```
services.AddScoped<IPayerManager, PayerManager>();
services.AddScoped<IBusinessManager, BusinessManager>();
```
**Controllers**
```
public class PayerController
{
private IPayerManager _entityManager{get;}
... | @Maxspan, my suggestion:
Put all interfaces in Contracts folder and this folder inside your Models/Entities folder (Models/Entities folder - Contracts folder)
IEntityManager Interface
```
namespace WebApplication1.Entities.Contracts
{
public interface IEntityManager
{
//Method signature only
... |
68,166,465 | I have a presentation made with vanilla javascript. And I have a for loop that creates sliders.
In this for loop I have to
```
for (var i = 0; i < prod_lorem.img; i++) {
inhtml += "<div class="swiper-slide"><div class="img"><img src="assets/img/products/' + products_cat + '/' + prod_lorem.img + '/' + i + '.png" al... | 2021/06/28 | [
"https://Stackoverflow.com/questions/68166465",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13998918/"
] | As Timo Hahn said, use minValue attribute and managed bean to get today's date.
Something like that should do:
`<af:inputdate minValue="#{myRequestScopeBean.today}" ... />`
```java
public class MyRequestScopeBean {
public java.util.Date getToday() { return new java.util.Date(); }
}
``` | User, tell us your exact JDev version, please!
The af:choosedate and af:inputdate both have a property minValue (see <https://docs.oracle.com/cd/E29542_01/apirefs.1111/e12419/tagdoc/af_inputDate.html>) Set this to the current date and you got your use case. |
56,829,751 | I want to create a 2 column, 3 row image square image gallery.
For some reason when writing code, the height of the boxes are Not filling up grid. How do I make the height of images become square with width?
Code , CSS and HTML below. Images should be touching edge to edge and **would like to refrain from naming Pixel ... | 2019/07/01 | [
"https://Stackoverflow.com/questions/56829751",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | If you want to fill up the box height. You should use align-items "**stretch**" property to the grid container.
```
.grid-container {
display: grid;
grid-template-columns: repeat(2, 1fr);.
grid-template-columns: repeat(3, 1fr);
grid-gap: 0;
padding: 0px;
align-items: str... | Try Following code.
```css
.grid-container {
display: grid;
grid-template-columns: repeat(3, 1fr);
}
img {
width: 100%;
height: 140px;
}
```
```html
<div class="grid-container">
<img src="https://www.woodlandtrust.org.uk/media/100078482/Sycamore01.jpg?cb=-11897985&preset=gallery-tab-ma... |
56,829,751 | I want to create a 2 column, 3 row image square image gallery.
For some reason when writing code, the height of the boxes are Not filling up grid. How do I make the height of images become square with width?
Code , CSS and HTML below. Images should be touching edge to edge and **would like to refrain from naming Pixel ... | 2019/07/01 | [
"https://Stackoverflow.com/questions/56829751",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | If you want to fill up the box height. You should use align-items "**stretch**" property to the grid container.
```
.grid-container {
display: grid;
grid-template-columns: repeat(2, 1fr);.
grid-template-columns: repeat(3, 1fr);
grid-gap: 0;
padding: 0px;
align-items: str... | This is your solution and when you resize your window then images will automatically resize.
```css
.grid-container {
display: grid;
grid-template-columns: repeat(2, 1fr);
grid-gap: 0;
padding: 0px;
align-items: stretch; /* Default. Items are stretched to fit the container */
}
img {
w... |
65,062,482 | I want to group my recyclerview by date in android studio without using any library, I did something but I am not getting what I wanted. I have uploaded my result image so I want to group it with "getDateSection". But here DateSection is displaying above each item not according to the dates. I just want to show each da... | 2020/11/29 | [
"https://Stackoverflow.com/questions/65062482",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11955527/"
] | You need to use nested recycleview for that. Parent recycleview for your header (i.e dates) and the child for the content.
For reference: <https://www.geeksforgeeks.org/how-to-create-a-nested-recyclerview-in-android/> | If you just want to show date at the first item then check if recycler view item position is at the top then set date text visibility to visible else visibility gone
I cannot add code I'm on a mobile device |
65,062,482 | I want to group my recyclerview by date in android studio without using any library, I did something but I am not getting what I wanted. I have uploaded my result image so I want to group it with "getDateSection". But here DateSection is displaying above each item not according to the dates. I just want to show each da... | 2020/11/29 | [
"https://Stackoverflow.com/questions/65062482",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11955527/"
] | There's a clever workaround that you can try. Just check the date for each entry; in the meanwhile declare a global variable to store the date. Whenever the date changes for an entry which will obviously be the first entry for that date, then only the date label will be displayed using setVisibility() method, else it w... | If you just want to show date at the first item then check if recycler view item position is at the top then set date text visibility to visible else visibility gone
I cannot add code I'm on a mobile device |
11,156 | How can someone estimate the number of years needed to factor an RSA key based on the advancement of technology if followed Moore's law? | 2013/10/19 | [
"https://crypto.stackexchange.com/questions/11156",
"https://crypto.stackexchange.com",
"https://crypto.stackexchange.com/users/8899/"
] | It is hard. Main problem is that RSA key breaking relies on [integer factorization](http://en.wikipedia.org/wiki/Integer_factorization), for which the most efficient (known) algorithms use CPU but also RAM, with constraints on parallel computation. [Moore's law](http://en.wikipedia.org/wiki/Moore%27s_law) is already a ... | Start with this formula: <http://en.wikipedia.org/wiki/Integer_factorization#Difficulty_and_complexity>
and either invert the formula or use newtons approximation.
as for the offset to work on:
<http://en.wikipedia.org/wiki/RSA_numbers>
the number RSA 1024 appears to not have been factorized, but many companies alr... |
11,156 | How can someone estimate the number of years needed to factor an RSA key based on the advancement of technology if followed Moore's law? | 2013/10/19 | [
"https://crypto.stackexchange.com/questions/11156",
"https://crypto.stackexchange.com",
"https://crypto.stackexchange.com/users/8899/"
] | It is hard. Main problem is that RSA key breaking relies on [integer factorization](http://en.wikipedia.org/wiki/Integer_factorization), for which the most efficient (known) algorithms use CPU but also RAM, with constraints on parallel computation. [Moore's law](http://en.wikipedia.org/wiki/Moore%27s_law) is already a ... | Additionally the discussion on this topic from the NIST standards is very beneficial. They explain thoroughly the means by which they establish their standards and the manner in which it is possible to abstract a more general notion of security and compare strengths of symmetric and asymmetric cryptosystems reliably. H... |
78,497 | 1. I am either your love or a ghost
2. I am a synonym for thin
3. I am all, but not the whole
4. I am the earth
5. I am the sun
And altogether, I am either true or false | 2019/01/16 | [
"https://puzzling.stackexchange.com/questions/78497",
"https://puzzling.stackexchange.com",
"https://puzzling.stackexchange.com/users/56461/"
] | Adding on to @Pugmonkey's answer:
>
> It's Boolean Algebra.
>
>
>
Either your love or a ghost:
>
> Boo
>
>
>
A synonym for thin:
>
> lean
>
>
>
All, but not the whole:
>
> al(the last letter is missing)
>
>
>
The earth:
>
> geb(the god of earth)
>
>
>
The sun:
>
> ra(the god of sun)
>
... | Partial Answer:
1. I am either your love or a ghost
>
> Boo
>
>
>
2. I am a synonym for thin
>
> Lean
>
>
>
3.I am all, but not the whole
4.I am the earth
5.I am the sun
And altogether, I am either true or false
>
> Boolean \_\_\_\_\_\_\_\_\_\_\_\_\_\_
>
>
> |
54,994,961 | I have been resurrecting an old project for new uses and running it on new PHP versions has resulted in this error:
>
> **Deprecated: Non-static** method Database::connect() should not be called statically, assuming $this from incompatible context in **/home/user/public\_html/app/models/mainmodel.php** on line **108*... | 2019/03/05 | [
"https://Stackoverflow.com/questions/54994961",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1554501/"
] | Props to /u/bobbykjack on /r/PHPhelp for finding the problem.
The issue is the query function was using procedural calls vs object method which caused the object not to update the insert\_id variable.
Old Code:
```
public function query($str) {
$this->results = mysqli_query(self::$db, $str);
if($this->results===... | I suppose, that your class Database doesn't have the property insert\_id and maybe the class hasn't to have it, because insert\_id is the property of **mysqli-object**.
See:
```
$mysqli = new mysqli(host, user, pass, database_name); //create new mysqli object
$query = "write your own INSERT query";
$mysqli->query($que... |
13,603 | Just out of curiosity, if your name consisted of words which exist in an English dictionary, would you translate it as you would those words? Or would you translate it letter-by-letter?
For example, I used to work with someone called Lance Fox, would that be 矛狐狸? I know a Matt Brown, would that be 亚光褐色? | 2015/05/23 | [
"https://chinese.stackexchange.com/questions/13603",
"https://chinese.stackexchange.com",
"https://chinese.stackexchange.com/users/11034/"
] | The norm is to make it:
a) similar in sound
b) follow Chinese naming conventions
and optionally also choose characters with a relevant or good meaning.
But just as authors can choose pen names such as 矛盾 and 莫言, a westerner can pick a name by your criteria. 矛狐狸 is rather elegant in this perspective, but would be con... | The last name Fox is translated 福克斯 as in the Fox Channel.
Lance is 兰斯 (like 兰斯‧阿姆斯特朗, the athlete)。So most likely, your name is translated as 兰斯‧福克斯。That's what happens if a news reporter would translate the name.
When you are talking about choosing a Chinese name based on your original name, you can go by your tas... |
9,324,852 | I can't help but wonder if namespaces or project folder structure effect the performance of the assembly. My gut says *"no, but it may possibly effect compile time"*.
Thinking about performance always get's in the way, especially if you're a novice. I can't help it! So, I thought I'd ask my fellow game developers who... | 2012/02/16 | [
"https://Stackoverflow.com/questions/9324852",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Answer: No, your project folder structure and namespaces will not have an appreciable effect on performance.
A word about performance.
It is written:
Premature Optimization is the Root of All Evil.
I recall being a novice.
I wanted to have the best code ever.
I see you want the same thing.
However, worrying abou... | The organization of your source files on disk will not affect the performance of the compiled assembly. Nor will the depth or breadth of your namespaces use within the source code.
When you look at the ECMA standard for the CLI (#335), specifically Partition II chapter 22 thereof, you can find the metadata format used... |
9,324,852 | I can't help but wonder if namespaces or project folder structure effect the performance of the assembly. My gut says *"no, but it may possibly effect compile time"*.
Thinking about performance always get's in the way, especially if you're a novice. I can't help it! So, I thought I'd ask my fellow game developers who... | 2012/02/16 | [
"https://Stackoverflow.com/questions/9324852",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Everyone has explained how premature optimization is a bad idea (which it is): however I will explain why it actually makes no difference whatsoever (except for cases where you use reflection - more on that later).
Static Reference In Code
========================
The CLR (and therefore MSIL - which is what C# compil... | Answer: No, your project folder structure and namespaces will not have an appreciable effect on performance.
A word about performance.
It is written:
Premature Optimization is the Root of All Evil.
I recall being a novice.
I wanted to have the best code ever.
I see you want the same thing.
However, worrying abou... |
9,324,852 | I can't help but wonder if namespaces or project folder structure effect the performance of the assembly. My gut says *"no, but it may possibly effect compile time"*.
Thinking about performance always get's in the way, especially if you're a novice. I can't help it! So, I thought I'd ask my fellow game developers who... | 2012/02/16 | [
"https://Stackoverflow.com/questions/9324852",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Everyone has explained how premature optimization is a bad idea (which it is): however I will explain why it actually makes no difference whatsoever (except for cases where you use reflection - more on that later).
Static Reference In Code
========================
The CLR (and therefore MSIL - which is what C# compil... | The organization of your source files on disk will not affect the performance of the compiled assembly. Nor will the depth or breadth of your namespaces use within the source code.
When you look at the ECMA standard for the CLI (#335), specifically Partition II chapter 22 thereof, you can find the metadata format used... |
10,490,678 | I've noticed that frequently people simply write
```
<?php if($_SESSION['username']) {...} ?>
```
while I have been using:
```
<?php if(isset($_SESSION['username'])) {...} ?>
```
Could someone explain the difference when checking if a variable is set (that's what I'd be using it for)? | 2012/05/07 | [
"https://Stackoverflow.com/questions/10490678",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1166285/"
] | In PHP, if a variable does not exist (is "unset") then PHP will spit out an `E_NOTICE` error, create the missing variable, and assign it to `NULL`.
If you do not want your scripts filled with annoying error messages that leak information about your server and script - then use `isset()` to test before trying to access... | say you set a variable = to false...
```
$variable = false;
```
This will not return anything, because it is making sure that the variable is not null, false or empty('')...
```
if($variable){
echo'something';
}
```
This will work regardless of what we set the variable to, as long as we set it... It can be ... |
10,490,678 | I've noticed that frequently people simply write
```
<?php if($_SESSION['username']) {...} ?>
```
while I have been using:
```
<?php if(isset($_SESSION['username'])) {...} ?>
```
Could someone explain the difference when checking if a variable is set (that's what I'd be using it for)? | 2012/05/07 | [
"https://Stackoverflow.com/questions/10490678",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1166285/"
] | According to PHP.net, isset() does the following:
>
> Determine if a variable is set and is not NULL.
>
>
>
When writing:
```
<?php if($_SESSION['username']) {...} ?>
```
You are checking to see if $\_SESSION['username'] is equal to true. In other words, you are checking if the value does not equal false.
Ac... | In PHP, if a variable does not exist (is "unset") then PHP will spit out an `E_NOTICE` error, create the missing variable, and assign it to `NULL`.
If you do not want your scripts filled with annoying error messages that leak information about your server and script - then use `isset()` to test before trying to access... |
10,490,678 | I've noticed that frequently people simply write
```
<?php if($_SESSION['username']) {...} ?>
```
while I have been using:
```
<?php if(isset($_SESSION['username'])) {...} ?>
```
Could someone explain the difference when checking if a variable is set (that's what I'd be using it for)? | 2012/05/07 | [
"https://Stackoverflow.com/questions/10490678",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1166285/"
] | According to PHP.net, isset() does the following:
>
> Determine if a variable is set and is not NULL.
>
>
>
When writing:
```
<?php if($_SESSION['username']) {...} ?>
```
You are checking to see if $\_SESSION['username'] is equal to true. In other words, you are checking if the value does not equal false.
Ac... | say you set a variable = to false...
```
$variable = false;
```
This will not return anything, because it is making sure that the variable is not null, false or empty('')...
```
if($variable){
echo'something';
}
```
This will work regardless of what we set the variable to, as long as we set it... It can be ... |
32,837,761 | I follow the book **Operating Systems: Three Easy Pieces**, the code in [introduction chapter](http://pages.cs.wisc.edu/~remzi/OSTEP/intro.pdf),
```
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <assert.h>
#include "common.h"
int
main(int argc, char *argv[])
{
if (argc != 2)
{
fprintf(... | 2015/09/29 | [
"https://Stackoverflow.com/questions/32837761",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2909677/"
] | Your declaration of main function should follow that declared in `common.h`:
```
#include <stdio.h>
#include "common.h"
// not this:
//int main(int argc, char *argv[]) {
// but:
int main(int argc, char *argv[], char *argv2[]) {
return 0;
}
```
and compile your code with something like:
```
gcc cpu.c common.h -... | common.h is not standard header to be added. If you want to compile and run this piece of code whether find common.h which contains Spin() or compile and run your code with out Spin() and common. Omitting Spin() and common.h will not have effect on the understanding of discussion provided in the book |
32,837,761 | I follow the book **Operating Systems: Three Easy Pieces**, the code in [introduction chapter](http://pages.cs.wisc.edu/~remzi/OSTEP/intro.pdf),
```
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <assert.h>
#include "common.h"
int
main(int argc, char *argv[])
{
if (argc != 2)
{
fprintf(... | 2015/09/29 | [
"https://Stackoverflow.com/questions/32837761",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2909677/"
] | The `"common.h"` header for this problem is linked as a tgz bundle in the table of contents for the course next to chapter 1: <http://pages.cs.wisc.edu/~remzi/OSTEP/>
Drop it next to your source file and try compiling again. | Your declaration of main function should follow that declared in `common.h`:
```
#include <stdio.h>
#include "common.h"
// not this:
//int main(int argc, char *argv[]) {
// but:
int main(int argc, char *argv[], char *argv2[]) {
return 0;
}
```
and compile your code with something like:
```
gcc cpu.c common.h -... |
32,837,761 | I follow the book **Operating Systems: Three Easy Pieces**, the code in [introduction chapter](http://pages.cs.wisc.edu/~remzi/OSTEP/intro.pdf),
```
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <assert.h>
#include "common.h"
int
main(int argc, char *argv[])
{
if (argc != 2)
{
fprintf(... | 2015/09/29 | [
"https://Stackoverflow.com/questions/32837761",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2909677/"
] | Here is what you are looking for. All the other answers don't understand that you were working from an OS book. Please refer to the link provided on the site.
<http://pages.cs.wisc.edu/~remzi/OSTEP/Code/code.intro.tgz>
```c
#ifndef __common_h__
#define __common_h__
#include <sys/time.h>
#include <assert.h>
#include ... | Your declaration of main function should follow that declared in `common.h`:
```
#include <stdio.h>
#include "common.h"
// not this:
//int main(int argc, char *argv[]) {
// but:
int main(int argc, char *argv[], char *argv2[]) {
return 0;
}
```
and compile your code with something like:
```
gcc cpu.c common.h -... |
32,837,761 | I follow the book **Operating Systems: Three Easy Pieces**, the code in [introduction chapter](http://pages.cs.wisc.edu/~remzi/OSTEP/intro.pdf),
```
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <assert.h>
#include "common.h"
int
main(int argc, char *argv[])
{
if (argc != 2)
{
fprintf(... | 2015/09/29 | [
"https://Stackoverflow.com/questions/32837761",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2909677/"
] | The `"common.h"` header for this problem is linked as a tgz bundle in the table of contents for the course next to chapter 1: <http://pages.cs.wisc.edu/~remzi/OSTEP/>
Drop it next to your source file and try compiling again. | common.h is not standard header to be added. If you want to compile and run this piece of code whether find common.h which contains Spin() or compile and run your code with out Spin() and common. Omitting Spin() and common.h will not have effect on the understanding of discussion provided in the book |
32,837,761 | I follow the book **Operating Systems: Three Easy Pieces**, the code in [introduction chapter](http://pages.cs.wisc.edu/~remzi/OSTEP/intro.pdf),
```
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <assert.h>
#include "common.h"
int
main(int argc, char *argv[])
{
if (argc != 2)
{
fprintf(... | 2015/09/29 | [
"https://Stackoverflow.com/questions/32837761",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2909677/"
] | Here is what you are looking for. All the other answers don't understand that you were working from an OS book. Please refer to the link provided on the site.
<http://pages.cs.wisc.edu/~remzi/OSTEP/Code/code.intro.tgz>
```c
#ifndef __common_h__
#define __common_h__
#include <sys/time.h>
#include <assert.h>
#include ... | common.h is not standard header to be added. If you want to compile and run this piece of code whether find common.h which contains Spin() or compile and run your code with out Spin() and common. Omitting Spin() and common.h will not have effect on the understanding of discussion provided in the book |
32,837,761 | I follow the book **Operating Systems: Three Easy Pieces**, the code in [introduction chapter](http://pages.cs.wisc.edu/~remzi/OSTEP/intro.pdf),
```
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <assert.h>
#include "common.h"
int
main(int argc, char *argv[])
{
if (argc != 2)
{
fprintf(... | 2015/09/29 | [
"https://Stackoverflow.com/questions/32837761",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2909677/"
] | The `"common.h"` header for this problem is linked as a tgz bundle in the table of contents for the course next to chapter 1: <http://pages.cs.wisc.edu/~remzi/OSTEP/>
Drop it next to your source file and try compiling again. | Here is what you are looking for. All the other answers don't understand that you were working from an OS book. Please refer to the link provided on the site.
<http://pages.cs.wisc.edu/~remzi/OSTEP/Code/code.intro.tgz>
```c
#ifndef __common_h__
#define __common_h__
#include <sys/time.h>
#include <assert.h>
#include ... |
4,752,349 | I have a `full_name` field in a mysql database and I need to parse out the first and last names because I am now transferring the data into `first_name` and `last_name` fields
So the names are like this; some have middle names and some don't:
```
James K. Dillon
Mark Holder
Tiffini lynn Jones
```
I found the php fu... | 2011/01/20 | [
"https://Stackoverflow.com/questions/4752349",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/223367/"
] | To put it short, you're pretty much doomed.
Some people have just first and last name: `John Smith`
Some have first, middle and last: `John Philip Smith`
Some have first name, but their last name consist of two parts: `John Smith Parker` (and yes, some people do not use a hyphen for that)
Some cultures put last (i.... | Another option is to use [explode](http://es2.php.net/manual/en/function.explode.php) using the delimiter space ' '
```
$name = "James K. Dillon"
$array = explode($name,' ');
// $array = {'James', 'K.', 'Dillon'}
```
Edit: I've just see slandau answer, so using his idea and mine:
```
$name = "James K. Dillon"
$arr... |
4,752,349 | I have a `full_name` field in a mysql database and I need to parse out the first and last names because I am now transferring the data into `first_name` and `last_name` fields
So the names are like this; some have middle names and some don't:
```
James K. Dillon
Mark Holder
Tiffini lynn Jones
```
I found the php fu... | 2011/01/20 | [
"https://Stackoverflow.com/questions/4752349",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/223367/"
] | To put it short, you're pretty much doomed.
Some people have just first and last name: `John Smith`
Some have first, middle and last: `John Philip Smith`
Some have first name, but their last name consist of two parts: `John Smith Parker` (and yes, some people do not use a hyphen for that)
Some cultures put last (i.... | Jason Priem wrote an excellent [Human Name Parser](https://github.com/jasonpriem/HumanNameParser.php) that takes names of various complexities and formats like:
* J. Walter Weatherman
* de la Cruz, Lupe
* George Oscar “Gob” Bluth, Jr.
and parses out the:
* leading initial (Like “J.” in “J. Walter Weatherman”)
* firs... |
4,752,349 | I have a `full_name` field in a mysql database and I need to parse out the first and last names because I am now transferring the data into `first_name` and `last_name` fields
So the names are like this; some have middle names and some don't:
```
James K. Dillon
Mark Holder
Tiffini lynn Jones
```
I found the php fu... | 2011/01/20 | [
"https://Stackoverflow.com/questions/4752349",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/223367/"
] | Jason Priem wrote an excellent [Human Name Parser](https://github.com/jasonpriem/HumanNameParser.php) that takes names of various complexities and formats like:
* J. Walter Weatherman
* de la Cruz, Lupe
* George Oscar “Gob” Bluth, Jr.
and parses out the:
* leading initial (Like “J.” in “J. Walter Weatherman”)
* firs... | Use `explode(" ",$name)` and then take the first and last indexes from the array. |
4,752,349 | I have a `full_name` field in a mysql database and I need to parse out the first and last names because I am now transferring the data into `first_name` and `last_name` fields
So the names are like this; some have middle names and some don't:
```
James K. Dillon
Mark Holder
Tiffini lynn Jones
```
I found the php fu... | 2011/01/20 | [
"https://Stackoverflow.com/questions/4752349",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/223367/"
] | To put it short, you're pretty much doomed.
Some people have just first and last name: `John Smith`
Some have first, middle and last: `John Philip Smith`
Some have first name, but their last name consist of two parts: `John Smith Parker` (and yes, some people do not use a hyphen for that)
Some cultures put last (i.... | Use `explode(" ",$name)` and then take the first and last indexes from the array. |
4,752,349 | I have a `full_name` field in a mysql database and I need to parse out the first and last names because I am now transferring the data into `first_name` and `last_name` fields
So the names are like this; some have middle names and some don't:
```
James K. Dillon
Mark Holder
Tiffini lynn Jones
```
I found the php fu... | 2011/01/20 | [
"https://Stackoverflow.com/questions/4752349",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/223367/"
] | Well.. identifying names may be pretty hard, in particular if users are prone to typos.
A good approach that may not work in 100% of cases (let's say at least 90% or for all the few examples you shown) is to divide the string into an array and get the first and last element.
```
$name_parts = explode(' ', $name);
$fi... | Use `explode(" ",$name)` and then take the first and last indexes from the array. |
4,752,349 | I have a `full_name` field in a mysql database and I need to parse out the first and last names because I am now transferring the data into `first_name` and `last_name` fields
So the names are like this; some have middle names and some don't:
```
James K. Dillon
Mark Holder
Tiffini lynn Jones
```
I found the php fu... | 2011/01/20 | [
"https://Stackoverflow.com/questions/4752349",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/223367/"
] | Why don't you search for the number of spaces.
If there is one space, you know it's two names, first/last, if two spaces, you know there's 3 names, and you can do what you want with the middle name or keep it and attach it to one of the others. | Another option is to use [explode](http://es2.php.net/manual/en/function.explode.php) using the delimiter space ' '
```
$name = "James K. Dillon"
$array = explode($name,' ');
// $array = {'James', 'K.', 'Dillon'}
```
Edit: I've just see slandau answer, so using his idea and mine:
```
$name = "James K. Dillon"
$arr... |
4,752,349 | I have a `full_name` field in a mysql database and I need to parse out the first and last names because I am now transferring the data into `first_name` and `last_name` fields
So the names are like this; some have middle names and some don't:
```
James K. Dillon
Mark Holder
Tiffini lynn Jones
```
I found the php fu... | 2011/01/20 | [
"https://Stackoverflow.com/questions/4752349",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/223367/"
] | Well.. identifying names may be pretty hard, in particular if users are prone to typos.
A good approach that may not work in 100% of cases (let's say at least 90% or for all the few examples you shown) is to divide the string into an array and get the first and last element.
```
$name_parts = explode(' ', $name);
$fi... | since you're deviding the name into first\_name and last\_name fields i assume the middle name if available should be within the last\_name field?
if so explode will work but would require a limit of 2, otherwise the last\_name would be left out
```
<?php
$name="Peter L. Panda";
$temp=explode(" ",$name,2);
$firstname... |
4,752,349 | I have a `full_name` field in a mysql database and I need to parse out the first and last names because I am now transferring the data into `first_name` and `last_name` fields
So the names are like this; some have middle names and some don't:
```
James K. Dillon
Mark Holder
Tiffini lynn Jones
```
I found the php fu... | 2011/01/20 | [
"https://Stackoverflow.com/questions/4752349",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/223367/"
] | To put it short, you're pretty much doomed.
Some people have just first and last name: `John Smith`
Some have first, middle and last: `John Philip Smith`
Some have first name, but their last name consist of two parts: `John Smith Parker` (and yes, some people do not use a hyphen for that)
Some cultures put last (i.... | since you're deviding the name into first\_name and last\_name fields i assume the middle name if available should be within the last\_name field?
if so explode will work but would require a limit of 2, otherwise the last\_name would be left out
```
<?php
$name="Peter L. Panda";
$temp=explode(" ",$name,2);
$firstname... |
4,752,349 | I have a `full_name` field in a mysql database and I need to parse out the first and last names because I am now transferring the data into `first_name` and `last_name` fields
So the names are like this; some have middle names and some don't:
```
James K. Dillon
Mark Holder
Tiffini lynn Jones
```
I found the php fu... | 2011/01/20 | [
"https://Stackoverflow.com/questions/4752349",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/223367/"
] | Jason Priem wrote an excellent [Human Name Parser](https://github.com/jasonpriem/HumanNameParser.php) that takes names of various complexities and formats like:
* J. Walter Weatherman
* de la Cruz, Lupe
* George Oscar “Gob” Bluth, Jr.
and parses out the:
* leading initial (Like “J.” in “J. Walter Weatherman”)
* firs... | since you're deviding the name into first\_name and last\_name fields i assume the middle name if available should be within the last\_name field?
if so explode will work but would require a limit of 2, otherwise the last\_name would be left out
```
<?php
$name="Peter L. Panda";
$temp=explode(" ",$name,2);
$firstname... |
4,752,349 | I have a `full_name` field in a mysql database and I need to parse out the first and last names because I am now transferring the data into `first_name` and `last_name` fields
So the names are like this; some have middle names and some don't:
```
James K. Dillon
Mark Holder
Tiffini lynn Jones
```
I found the php fu... | 2011/01/20 | [
"https://Stackoverflow.com/questions/4752349",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/223367/"
] | Well.. identifying names may be pretty hard, in particular if users are prone to typos.
A good approach that may not work in 100% of cases (let's say at least 90% or for all the few examples you shown) is to divide the string into an array and get the first and last element.
```
$name_parts = explode(' ', $name);
$fi... | Another option is to use [explode](http://es2.php.net/manual/en/function.explode.php) using the delimiter space ' '
```
$name = "James K. Dillon"
$array = explode($name,' ');
// $array = {'James', 'K.', 'Dillon'}
```
Edit: I've just see slandau answer, so using his idea and mine:
```
$name = "James K. Dillon"
$arr... |
6,770,610 | I'm writing an application that connects to twitter and uses the OAuth API, my issue is with storing the consumer\_key and the consumer\_key\_secret
How can I safely store these values so they're difficult for the user to get to but still have ability to use them within my application?
I've had storing them within a ... | 2011/07/21 | [
"https://Stackoverflow.com/questions/6770610",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/855072/"
] | An alternative to DRM (which is what you are describing) is to proxy the secured interaction through a server application on your own, controlled machine. Since you're using OAuth, you can use the same authentication credentials against your own server as you would connecting directly to twitter.
The advantage to this... | I apologize if I am missing something, but what is wrong with [xAuth](https://dev.twitter.com/docs/oauth/xauth)? This seems like the perfect use case for it. Your application would utilize (and therefore store) a consumer key (`oauth_consumer_key`) and there is no way around that: You must have something that uniquely ... |
135,358 | I am asked to rotate the curve $y=\sqrt{4-x^2}$ from $x=-1$ to $x=1$ about the x-axis and find the area of the surface. I was able to use `RevolutionPlot3D` to show the surface.
```
RevolutionPlot3D[Sqrt[4 - x^2], {x, -1, 1},
RevolutionAxis -> {1, 0, 0}]
```
[ to the surface; hence, one can construct
```
reg = ImplicitRegion[z^2 + y^2 == Sqrt[4 - x^2]^2 && -1 <= x <= 1, {x, y, z}]
```
which looks like this:
```
DiscretizeRegion[reg]
```
[![enter image descripti... | The trick is `DiscretizeGraphics`. Turns your graphic into a surface:
```
r = DiscretizeGraphics@
RevolutionPlot3D[Sqrt[4 - x^2], {x, -1, 1},
RevolutionAxis -> {1, 0, 0}]
```
then:
```
In[24]:= Area@r
Out[24]= 25.5411
```
It ain't perfect, but it's close:
```
In[26]:= Area@r / \[Pi]
Out[26]= 8.1299... |
135,358 | I am asked to rotate the curve $y=\sqrt{4-x^2}$ from $x=-1$ to $x=1$ about the x-axis and find the area of the surface. I was able to use `RevolutionPlot3D` to show the surface.
```
RevolutionPlot3D[Sqrt[4 - x^2], {x, -1, 1},
RevolutionAxis -> {1, 0, 0}]
```
[
```
Calculate surface area:
```
Integrate[i, ... |
135,358 | I am asked to rotate the curve $y=\sqrt{4-x^2}$ from $x=-1$ to $x=1$ about the x-axis and find the area of the surface. I was able to use `RevolutionPlot3D` to show the surface.
```
RevolutionPlot3D[Sqrt[4 - x^2], {x, -1, 1},
RevolutionAxis -> {1, 0, 0}]
```
[ from x=-1 to x=1 about x axis surface area",
"Result"]
(* 25.1327 *)
``` |
135,358 | I am asked to rotate the curve $y=\sqrt{4-x^2}$ from $x=-1$ to $x=1$ about the x-axis and find the area of the surface. I was able to use `RevolutionPlot3D` to show the surface.
```
RevolutionPlot3D[Sqrt[4 - x^2], {x, -1, 1},
RevolutionAxis -> {1, 0, 0}]
```
[ to the surface; hence, one can construct
```
reg = ImplicitRegion[z^2 + y^2 == Sqrt[4 - x^2]^2 && -1 <= x <= 1, {x, y, z}]
```
which looks like this:
```
DiscretizeRegion[reg]
```
[![enter image descripti... | Parametrize surface:
```
f[u_, v_] := {u, Cos[v] Sqrt[4 - u^2], Sin[v] Sqrt[4 - u^2]};
```
Area element:
```
i =
FullSimplify[Norm[Cross @@ Transpose[D[f[x, y], {{x, y}}]]],
Assumptions -> {x \[Element] Reals, Abs[x] < 1, 0 < y < 2 Pi}]
```
gives:
```
(*2*)
```
Calculate surface area:
```
Integrate[i, ... |
135,358 | I am asked to rotate the curve $y=\sqrt{4-x^2}$ from $x=-1$ to $x=1$ about the x-axis and find the area of the surface. I was able to use `RevolutionPlot3D` to show the surface.
```
RevolutionPlot3D[Sqrt[4 - x^2], {x, -1, 1},
RevolutionAxis -> {1, 0, 0}]
```
[ to the surface; hence, one can construct
```
reg = ImplicitRegion[z^2 + y^2 == Sqrt[4 - x^2]^2 && -1 <= x <= 1, {x, y, z}]
```
which looks like this:
```
DiscretizeRegion[reg]
```
[![enter image descripti... | >
> Is there some cute way of finding surface area using Mathematica?
>
>
>
I think this fits the bill,
```
WolframAlpha["rotate sqrt(4-x^2) from x=-1 to x=1 about x axis surface area",
"Result"]
(* 25.1327 *)
``` |
135,358 | I am asked to rotate the curve $y=\sqrt{4-x^2}$ from $x=-1$ to $x=1$ about the x-axis and find the area of the surface. I was able to use `RevolutionPlot3D` to show the surface.
```
RevolutionPlot3D[Sqrt[4 - x^2], {x, -1, 1},
RevolutionAxis -> {1, 0, 0}]
```
[ to the surface; hence, one can construct
```
reg = ImplicitRegion[z^2 + y^2 == Sqrt[4 - x^2]^2 && -1 <= x <= 1, {x, y, z}]
```
which looks like this:
```
DiscretizeRegion[reg]
```
[![enter image descripti... | The most direct analog, IMO, to your plot is to use the parametric form of `Area`, where you add a theta variable for the rotation:
```
In[11]:= Area[{x, Sqrt[4 - x^2] Cos[θ], Sqrt[4 - x^2] Sin[θ]},
{x, -1, 1}, {θ, 0, 2 π}]
Out[11]= 8 π
```
Adding a radius variable which gives the distance from the x-axis gives ... |
135,358 | I am asked to rotate the curve $y=\sqrt{4-x^2}$ from $x=-1$ to $x=1$ about the x-axis and find the area of the surface. I was able to use `RevolutionPlot3D` to show the surface.
```
RevolutionPlot3D[Sqrt[4 - x^2], {x, -1, 1},
RevolutionAxis -> {1, 0, 0}]
```
[
```
Calculate surface area:
```
Integrate[i, ... |
135,358 | I am asked to rotate the curve $y=\sqrt{4-x^2}$ from $x=-1$ to $x=1$ about the x-axis and find the area of the surface. I was able to use `RevolutionPlot3D` to show the surface.
```
RevolutionPlot3D[Sqrt[4 - x^2], {x, -1, 1},
RevolutionAxis -> {1, 0, 0}]
```
[ from x=-1 to x=1 about x axis surface area",
"Result"]
(* 25.1327 *)
``` |
360,559 | I am trying to install Debian but i don't know how to partition it. I have an 1tb hard disk. I want to give 60gb for debian files,2gb for swap and want to use the others for media files. What is /,/home,/usr/local? | 2017/04/22 | [
"https://unix.stackexchange.com/questions/360559",
"https://unix.stackexchange.com",
"https://unix.stackexchange.com/users/227559/"
] | My solution to this problem was setting
`force_color_prompt=yes`
in my `.bashrc`. Now my tmux prompt has color. | Your PS1 also gives me black and white output.
However switching back to mine gives me color, so you should be able to figure out the different, I use
```
$ echo $PS1
\[\033[01;31m\]\t \[\033[01;32m\]durrantm \[\033[02;36m\]\h \[\033[01;34m\]`pwd | sed "s#\(/[^/]\{1,\}/[^/]\{1,\}/[^/]\{1,\}/\).*\(/[^/]\{1,\}/[^/]\{1,... |
360,559 | I am trying to install Debian but i don't know how to partition it. I have an 1tb hard disk. I want to give 60gb for debian files,2gb for swap and want to use the others for media files. What is /,/home,/usr/local? | 2017/04/22 | [
"https://unix.stackexchange.com/questions/360559",
"https://unix.stackexchange.com",
"https://unix.stackexchange.com/users/227559/"
] | On my machine the solution is to add
```
set -g default-terminal "xterm-256color"
```
to `~/.tmux.conf`. | Your PS1 also gives me black and white output.
However switching back to mine gives me color, so you should be able to figure out the different, I use
```
$ echo $PS1
\[\033[01;31m\]\t \[\033[01;32m\]durrantm \[\033[02;36m\]\h \[\033[01;34m\]`pwd | sed "s#\(/[^/]\{1,\}/[^/]\{1,\}/[^/]\{1,\}/\).*\(/[^/]\{1,\}/[^/]\{1,... |
360,559 | I am trying to install Debian but i don't know how to partition it. I have an 1tb hard disk. I want to give 60gb for debian files,2gb for swap and want to use the others for media files. What is /,/home,/usr/local? | 2017/04/22 | [
"https://unix.stackexchange.com/questions/360559",
"https://unix.stackexchange.com",
"https://unix.stackexchange.com/users/227559/"
] | Your PS1 also gives me black and white output.
However switching back to mine gives me color, so you should be able to figure out the different, I use
```
$ echo $PS1
\[\033[01;31m\]\t \[\033[01;32m\]durrantm \[\033[02;36m\]\h \[\033[01;34m\]`pwd | sed "s#\(/[^/]\{1,\}/[^/]\{1,\}/[^/]\{1,\}/\).*\(/[^/]\{1,\}/[^/]\{1,... | I had this issue when working on Ubuntu 20.04.
While [Panki's answer](https://unix.stackexchange.com/a/493472/390383) worked for me, I found myself always specifying `source ~/.bashrc` whenever I logged into **Tmux** shell following [evaristegd](https://unix.stackexchange.com/users/324019/evaristegd)'s comment.
**Her... |
360,559 | I am trying to install Debian but i don't know how to partition it. I have an 1tb hard disk. I want to give 60gb for debian files,2gb for swap and want to use the others for media files. What is /,/home,/usr/local? | 2017/04/22 | [
"https://unix.stackexchange.com/questions/360559",
"https://unix.stackexchange.com",
"https://unix.stackexchange.com/users/227559/"
] | Your PS1 also gives me black and white output.
However switching back to mine gives me color, so you should be able to figure out the different, I use
```
$ echo $PS1
\[\033[01;31m\]\t \[\033[01;32m\]durrantm \[\033[02;36m\]\h \[\033[01;34m\]`pwd | sed "s#\(/[^/]\{1,\}/[^/]\{1,\}/[^/]\{1,\}/\).*\(/[^/]\{1,\}/[^/]\{1,... | ### Change $TERM to xterm-256color
No color:
```
$ echo $TERM
screen
```
With color:
```
TERM=xterm-256color
```
Add this to your dotfile.
### Remarks
This may not be the OPs situation but in case anyone else has landed on this page with this situation I'm hoping i... |
360,559 | I am trying to install Debian but i don't know how to partition it. I have an 1tb hard disk. I want to give 60gb for debian files,2gb for swap and want to use the others for media files. What is /,/home,/usr/local? | 2017/04/22 | [
"https://unix.stackexchange.com/questions/360559",
"https://unix.stackexchange.com",
"https://unix.stackexchange.com/users/227559/"
] | On my machine the solution is to add
```
set -g default-terminal "xterm-256color"
```
to `~/.tmux.conf`. | My solution to this problem was setting
`force_color_prompt=yes`
in my `.bashrc`. Now my tmux prompt has color. |
360,559 | I am trying to install Debian but i don't know how to partition it. I have an 1tb hard disk. I want to give 60gb for debian files,2gb for swap and want to use the others for media files. What is /,/home,/usr/local? | 2017/04/22 | [
"https://unix.stackexchange.com/questions/360559",
"https://unix.stackexchange.com",
"https://unix.stackexchange.com/users/227559/"
] | My solution to this problem was setting
`force_color_prompt=yes`
in my `.bashrc`. Now my tmux prompt has color. | I had this issue when working on Ubuntu 20.04.
While [Panki's answer](https://unix.stackexchange.com/a/493472/390383) worked for me, I found myself always specifying `source ~/.bashrc` whenever I logged into **Tmux** shell following [evaristegd](https://unix.stackexchange.com/users/324019/evaristegd)'s comment.
**Her... |
360,559 | I am trying to install Debian but i don't know how to partition it. I have an 1tb hard disk. I want to give 60gb for debian files,2gb for swap and want to use the others for media files. What is /,/home,/usr/local? | 2017/04/22 | [
"https://unix.stackexchange.com/questions/360559",
"https://unix.stackexchange.com",
"https://unix.stackexchange.com/users/227559/"
] | My solution to this problem was setting
`force_color_prompt=yes`
in my `.bashrc`. Now my tmux prompt has color. | ### Change $TERM to xterm-256color
No color:
```
$ echo $TERM
screen
```
With color:
```
TERM=xterm-256color
```
Add this to your dotfile.
### Remarks
This may not be the OPs situation but in case anyone else has landed on this page with this situation I'm hoping i... |
360,559 | I am trying to install Debian but i don't know how to partition it. I have an 1tb hard disk. I want to give 60gb for debian files,2gb for swap and want to use the others for media files. What is /,/home,/usr/local? | 2017/04/22 | [
"https://unix.stackexchange.com/questions/360559",
"https://unix.stackexchange.com",
"https://unix.stackexchange.com/users/227559/"
] | On my machine the solution is to add
```
set -g default-terminal "xterm-256color"
```
to `~/.tmux.conf`. | I had this issue when working on Ubuntu 20.04.
While [Panki's answer](https://unix.stackexchange.com/a/493472/390383) worked for me, I found myself always specifying `source ~/.bashrc` whenever I logged into **Tmux** shell following [evaristegd](https://unix.stackexchange.com/users/324019/evaristegd)'s comment.
**Her... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.