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 |
|---|---|---|---|---|---|
397,817 | Recently [a post on MathOverflow](https://mathoverflow.net/questions/128935/hahns-embedding-theorem-and-the-oldest-open-question-in-set-theory) connected a theorem about ordered abelian groups to the axiom of choice, and it made me want to try and play with these objects a bit.
But it appears to me that I don't know e... | 2013/05/21 | [
"https://math.stackexchange.com/questions/397817",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/622/"
] | **Hint:** Use the fact $$\int\_0^a f(x)dx = \int\_0^a f(a-x)dx$$ You can show this by letting $u = a-x$. | Set $t = \pi/2-x$ and make use of the fact that $\displaystyle \int\_a^b f(y) dy = - \int\_b^a f(y) dy$ to conclude what you want. |
397,817 | Recently [a post on MathOverflow](https://mathoverflow.net/questions/128935/hahns-embedding-theorem-and-the-oldest-open-question-in-set-theory) connected a theorem about ordered abelian groups to the axiom of choice, and it made me want to try and play with these objects a bit.
But it appears to me that I don't know e... | 2013/05/21 | [
"https://math.stackexchange.com/questions/397817",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/622/"
] | **Hint:** Use the fact $$\int\_0^a f(x)dx = \int\_0^a f(a-x)dx$$ You can show this by letting $u = a-x$. | $$I=\int\_0^{\dfrac{\pi}{2}}\log\sin x\,dx\cdots \tag 1 $$
use this property:$$\int\_0^a f(x)dx = \int\_0^a f(a-x)dx$$
$$I=\int\_0^{\dfrac{\pi}{2}}\log\cos x\,dx\cdots \tag 2$$
Add both eqn:
$$2I=\int\_0^{\dfrac{\pi}{2}}\log\sin x+\log\cos x\,dx$$
$$2I=\int\_0^{\dfrac{\pi}{2}}\log({\sin x\cdot\cos x})\,dx$$
$$2I=\int\... |
11,142,003 | Salesforce attachment file size is officially limited to 5MB ([doc](http://na1.salesforce.com/help/doc/en/collab_files_size_limits.htm)) but if requested they can increase this limit on a one to one cases.
My question: Can I retrieve this newly allowed file size limit using the API.
Context: Non-Profits are applying ... | 2012/06/21 | [
"https://Stackoverflow.com/questions/11142003",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1303988/"
] | You can call the `getUserInfo()` function in the [SOAP API](http://www.salesforce.com/us/developer/docs/api/index_Left.htm#StartTopic=Content/sforce_api_calls_getuserinfo.htm), part of the returned data includes the field `orgAttachmentFileSizeLimit` (this appears to be missing from the docs, but is in the WSDL) | I'll recommend going away from Salesforce to store files, more if you'r expecting to hit limits, also there is a limit on the space for storing organization wide, a useful service like Amazon S3 would be very useful, you can then attach the S3 url to your record in case it is needed, it'll be also available for externa... |
55,942 | So I think that I'm finally at a point where I can say that my sign up form for desktop users is pretty much done.
I've tried to make it user friendly at first sight by keeping it as short as possible based on my requirements. And also by having a bit of text under each input that explains what it will be used for.
I... | 2014/04/18 | [
"https://ux.stackexchange.com/questions/55942",
"https://ux.stackexchange.com",
"https://ux.stackexchange.com/users/46613/"
] | How about this:

1. Intro text adds nothing
2. Name is not essential to create account, or at least make it one field
3. Re-enter email is redundant
4. The way you aligned labels is not optimal
5. New password? I don't have any existing password at t... | Quoting a respected member of the User Experience community I can recommend some things to further enhance user experience.
Note: I think the form already is very clear and probably user friendly.

[resource article link](http:/... |
56,319,361 | I am using flask-sqlalchemy to implement many to many relationship. Tried many options but unable to query all children for a parent.
```
class Participant(db.Model):
__tablename__='participant'
__table_args__ = {'extend_existing': True}
id = db.Column(db.Integer, primary_key=True)
email = db.Column(... | 2019/05/27 | [
"https://Stackoverflow.com/questions/56319361",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5943094/"
] | Try using the updater form of `setState` which takes a function:
```
function handleChange(event) {
// event.target wont be available when fn is run in setState
// so we save them in our own local variables here
const { name, value } = event.target;
setValues(prev => ({
...prev,
[name]: value
}));
}... | Your `areEqual` method translates to
>
> Re-render my Input ONLY when the `value` changes.
>
>
>
But in reality, your `handleChange` function from the hook is also changing. Also, you use the same `handleChange` for both the inputs. So, the `Input` "remembers" only the `handleChange` from the last time `value` ha... |
50,260 | I am trying to do the following problem:
>
> *Freezing of water at $273~\mathrm K$ and $1~\mathrm{atm}$*
>
>
> Which of the following is true for the above thermodynamics process?
>
>
> p) $q=0$
>
>
> q) $w=0$
>
>
> r) $\Delta S\_\mathrm{sys}<0$
>
>
> s) $\Delta U=0$
>
>
> t) $\Delta G=0$
>
>
>
My ans... | 2016/04/27 | [
"https://chemistry.stackexchange.com/questions/50260",
"https://chemistry.stackexchange.com",
"https://chemistry.stackexchange.com/users/22813/"
] | >
> Is this only because the overall structure will not be consistent, because sp-hybridization will make the COC line straight, and thus the OCC angles would have to be lesser than the carbons' sp2-hybridization would allow?
>
>
>
Yes, this is the correct answer. A very common misconception is that hybridisation ... | I think [bon's answer](https://chemistry.stackexchange.com/a/50245/5017) is excellent, but I wanted to comment about one piece of your question:
>
> Is this a general pattern - if an adjacent atom is $\mathrm{sp^2}$-hybridized, and if there's at least one electron pair, then our atom it $\mathrm{sp^2}$-hybridized as ... |
50,260 | I am trying to do the following problem:
>
> *Freezing of water at $273~\mathrm K$ and $1~\mathrm{atm}$*
>
>
> Which of the following is true for the above thermodynamics process?
>
>
> p) $q=0$
>
>
> q) $w=0$
>
>
> r) $\Delta S\_\mathrm{sys}<0$
>
>
> s) $\Delta U=0$
>
>
> t) $\Delta G=0$
>
>
>
My ans... | 2016/04/27 | [
"https://chemistry.stackexchange.com/questions/50260",
"https://chemistry.stackexchange.com",
"https://chemistry.stackexchange.com/users/22813/"
] | >
> Is this only because the overall structure will not be consistent, because sp-hybridization will make the COC line straight, and thus the OCC angles would have to be lesser than the carbons' sp2-hybridization would allow?
>
>
>
Yes, this is the correct answer. A very common misconception is that hybridisation ... | Hybridization is driven by geometry, so ask whether a geometry that drives $sp$ hybridization on the oxygen, **including a bond angle of 180°**, is plausible in this small ring. I'm guessing you might find such a geometry would be a bit destabilized by angle strain. |
50,260 | I am trying to do the following problem:
>
> *Freezing of water at $273~\mathrm K$ and $1~\mathrm{atm}$*
>
>
> Which of the following is true for the above thermodynamics process?
>
>
> p) $q=0$
>
>
> q) $w=0$
>
>
> r) $\Delta S\_\mathrm{sys}<0$
>
>
> s) $\Delta U=0$
>
>
> t) $\Delta G=0$
>
>
>
My ans... | 2016/04/27 | [
"https://chemistry.stackexchange.com/questions/50260",
"https://chemistry.stackexchange.com",
"https://chemistry.stackexchange.com/users/22813/"
] | I think [bon's answer](https://chemistry.stackexchange.com/a/50245/5017) is excellent, but I wanted to comment about one piece of your question:
>
> Is this a general pattern - if an adjacent atom is $\mathrm{sp^2}$-hybridized, and if there's at least one electron pair, then our atom it $\mathrm{sp^2}$-hybridized as ... | Hybridization is driven by geometry, so ask whether a geometry that drives $sp$ hybridization on the oxygen, **including a bond angle of 180°**, is plausible in this small ring. I'm guessing you might find such a geometry would be a bit destabilized by angle strain. |
53,970,587 | I'm on Windows 10.
I tried to install [channels](https://channels.readthedocs.io/en/latest/installation.html) to use websockets with Django but it doesn't work. I got the following error :
**Failed building wheel for Twisted**
I have still not succeeded to install channels.
But now I have a new problem, I can no an... | 2018/12/29 | [
"https://Stackoverflow.com/questions/53970587",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4108531/"
] | don't use jquery for this. the platform is powerful enough nowadays.
short description:
* get all `.group_table`s and call the `sortByPoints()` function
* get all `.team`s and turn the nodeList into an Array.
* `parseInt()` the contents of the points and sort your Array by it.
* for each item in the now resulting sor... | using jQuery
```js
jQuery.fn.orderBy = function(keySelector) {
$(this).sort(function(a, b) {
return parseInt($(a).find(keySelector).text()) > parseInt($(b).find(keySelector).text());
}).appendTo($(this).parent());
};
$("#sort").on('click', function(event) {
$(".group_table").each(function() {
$(... |
226,811 | I recently played on the new 'Snowplow' map for TF2, and while it seems easy enough to make the train go forward for Blu team, I wasn't actually making it go forward myself - I assume my teammates were doing something while I was busy taking out sentry nests as a spy - so the map has left me a little confused.
Even m... | 2015/07/06 | [
"https://gaming.stackexchange.com/questions/226811",
"https://gaming.stackexchange.com",
"https://gaming.stackexchange.com/users/55285/"
] | As stated in the map name, cp\_snowplow is a Control Point map. Specifically, it's an Attack/Defend Control Points map, similar to Dustbowl.
It consists of 2 stages with 3 control points per stage.
After setup is done, there will be about 15 seconds before the train gates near BLU spawn come down and the train speeds... | In Snowplow, the objective for team A is to get the train across the map, and team B must stop them. There are three control points that must be captured to gain clearance for the train to move forward, and upon team A's capturing of the point, it will speed towards the subsequent one. Every 30 seconds that team B defe... |
16,317,834 | I have a table with 3 columns including a timestamp called `startson`:
>
> events ( **eventid** number, **name** varchar2, **startson** timestamp )
>
>
>
I have a variable that is a number which is an offset that says what the `startson` boundry should be in my where clause.
For example:
```
if my_var = 0 (sele... | 2013/05/01 | [
"https://Stackoverflow.com/questions/16317834",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1310814/"
] | Here you have a minus sign after your multiplication sign.
```
(sysdate-(10*-my_var))
```
In your case you will end up with something like
```
(sysdate -(10 * -1)) that will give you (sysdate + 10 days)
```
Maybe you should have something more like
```
(sysdate-(10*my_var))
```
And you should invert the "<="... | Here's the basic formula if I understood the problem correctly:
```
-- between last 10 days --
WHERE startson BETWEEN trunc(SYSDATE) AND (trunc(SYSDATE) - INTERVAL '10' DAY)
```
To get all intervals in a single select:
```
SELECT start_date, ten_days_ago, twenty_days_ago, thirty_days_ago, fourty_days_ago
FROM
(
... |
10,864,708 | I have an activity where I dynamically replace fragments:
```
private void goToFragment(Fragment newFragment, String tag) {
FragmentTransaction ft = getFragmentManager().beginTransaction();
ft.replace(R.id.fragment_container, newFragment, tag);
ft.addToBackStack(null);
ft.commit();
}
```
Now, I want ... | 2012/06/02 | [
"https://Stackoverflow.com/questions/10864708",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1380710/"
] | `FragmentTransaction` isn't applied instantly after calling `commit()`. You may force update manually:
```
...
mFragmentManager.executePendingTransactions();
```
AFAIK event callbacks' purpose is custom communication with `Fragment` beyond it's usual lifecycle. | The *correct* way to do it would be to define an interface for `Activity` classes wishing to display your `Fragment` should implement. That way, on `onAttach` you don't cast to a specific `Activity` but to your interface.
See for instance: <http://developer.android.com/guide/topics/fundamentals/fragments.html#EventCal... |
10,864,708 | I have an activity where I dynamically replace fragments:
```
private void goToFragment(Fragment newFragment, String tag) {
FragmentTransaction ft = getFragmentManager().beginTransaction();
ft.replace(R.id.fragment_container, newFragment, tag);
ft.addToBackStack(null);
ft.commit();
}
```
Now, I want ... | 2012/06/02 | [
"https://Stackoverflow.com/questions/10864708",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1380710/"
] | `FragmentTransaction` isn't applied instantly after calling `commit()`. You may force update manually:
```
...
mFragmentManager.executePendingTransactions();
```
AFAIK event callbacks' purpose is custom communication with `Fragment` beyond it's usual lifecycle. | You should use `onActivityCreated` to set the values.
Set references in `onCreateView` and then set values to them in `onActivityCreated`. |
6,157,506 | I want to ask if someone measured impact of some javascript obfuscators on the resulted code. I am aiming mobile users so the speed is cruicial. And I am especially trying to run 2 or 3 different obfuscators on same code in a row, which obfuscates the code very well, but I am afraid that it will have some speed impact. | 2011/05/27 | [
"https://Stackoverflow.com/questions/6157506",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/385264/"
] | it shouldn't. Compiler/interpreters couldn't care less about what your *symbols* are, as long as they are correct. | Your question really needs an analysis on your own javascript in order to arrive at a useful answer.
Often though, obfuscation actually speeds up javascript since the file sizes are reduced (faster loading) and symbols get small names (less to compare against). |
6,157,506 | I want to ask if someone measured impact of some javascript obfuscators on the resulted code. I am aiming mobile users so the speed is cruicial. And I am especially trying to run 2 or 3 different obfuscators on same code in a row, which obfuscates the code very well, but I am afraid that it will have some speed impact. | 2011/05/27 | [
"https://Stackoverflow.com/questions/6157506",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/385264/"
] | it shouldn't. Compiler/interpreters couldn't care less about what your *symbols* are, as long as they are correct. | If the obfuscator is doing some encoding and calling eval, like some do, then there will be a performance penalty at script load time. After that is run, there should be no difference and, as stated before, it may speedup your code due to slower size. |
6,157,506 | I want to ask if someone measured impact of some javascript obfuscators on the resulted code. I am aiming mobile users so the speed is cruicial. And I am especially trying to run 2 or 3 different obfuscators on same code in a row, which obfuscates the code very well, but I am afraid that it will have some speed impact. | 2011/05/27 | [
"https://Stackoverflow.com/questions/6157506",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/385264/"
] | it shouldn't. Compiler/interpreters couldn't care less about what your *symbols* are, as long as they are correct. | That depends on what you mean by obfuscation.
If you're referring to minification, using a tool like JSMin, then the effect is nil.
If you're talking about something like Packer, the eval process actually does have an impact on how long it takes for the code to execute. On a slow device, that impact can be significan... |
6,157,506 | I want to ask if someone measured impact of some javascript obfuscators on the resulted code. I am aiming mobile users so the speed is cruicial. And I am especially trying to run 2 or 3 different obfuscators on same code in a row, which obfuscates the code very well, but I am afraid that it will have some speed impact. | 2011/05/27 | [
"https://Stackoverflow.com/questions/6157506",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/385264/"
] | Your question really needs an analysis on your own javascript in order to arrive at a useful answer.
Often though, obfuscation actually speeds up javascript since the file sizes are reduced (faster loading) and symbols get small names (less to compare against). | That depends on what you mean by obfuscation.
If you're referring to minification, using a tool like JSMin, then the effect is nil.
If you're talking about something like Packer, the eval process actually does have an impact on how long it takes for the code to execute. On a slow device, that impact can be significan... |
6,157,506 | I want to ask if someone measured impact of some javascript obfuscators on the resulted code. I am aiming mobile users so the speed is cruicial. And I am especially trying to run 2 or 3 different obfuscators on same code in a row, which obfuscates the code very well, but I am afraid that it will have some speed impact. | 2011/05/27 | [
"https://Stackoverflow.com/questions/6157506",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/385264/"
] | Most JavaScript obfuscators only *minifies* and rename local variables, which is extremely easy to reverse-engineer with a beautifier.
The best combination I've found is the [DojoToolkit](http://www.dojotoolkit.org) and the Closure Compiler in Advanced Mode.
Closure in Advanced Mode makes JavaScript code almost impos... | Your question really needs an analysis on your own javascript in order to arrive at a useful answer.
Often though, obfuscation actually speeds up javascript since the file sizes are reduced (faster loading) and symbols get small names (less to compare against). |
6,157,506 | I want to ask if someone measured impact of some javascript obfuscators on the resulted code. I am aiming mobile users so the speed is cruicial. And I am especially trying to run 2 or 3 different obfuscators on same code in a row, which obfuscates the code very well, but I am afraid that it will have some speed impact. | 2011/05/27 | [
"https://Stackoverflow.com/questions/6157506",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/385264/"
] | If the obfuscator is doing some encoding and calling eval, like some do, then there will be a performance penalty at script load time. After that is run, there should be no difference and, as stated before, it may speedup your code due to slower size. | That depends on what you mean by obfuscation.
If you're referring to minification, using a tool like JSMin, then the effect is nil.
If you're talking about something like Packer, the eval process actually does have an impact on how long it takes for the code to execute. On a slow device, that impact can be significan... |
6,157,506 | I want to ask if someone measured impact of some javascript obfuscators on the resulted code. I am aiming mobile users so the speed is cruicial. And I am especially trying to run 2 or 3 different obfuscators on same code in a row, which obfuscates the code very well, but I am afraid that it will have some speed impact. | 2011/05/27 | [
"https://Stackoverflow.com/questions/6157506",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/385264/"
] | Most JavaScript obfuscators only *minifies* and rename local variables, which is extremely easy to reverse-engineer with a beautifier.
The best combination I've found is the [DojoToolkit](http://www.dojotoolkit.org) and the Closure Compiler in Advanced Mode.
Closure in Advanced Mode makes JavaScript code almost impos... | If the obfuscator is doing some encoding and calling eval, like some do, then there will be a performance penalty at script load time. After that is run, there should be no difference and, as stated before, it may speedup your code due to slower size. |
6,157,506 | I want to ask if someone measured impact of some javascript obfuscators on the resulted code. I am aiming mobile users so the speed is cruicial. And I am especially trying to run 2 or 3 different obfuscators on same code in a row, which obfuscates the code very well, but I am afraid that it will have some speed impact. | 2011/05/27 | [
"https://Stackoverflow.com/questions/6157506",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/385264/"
] | Most JavaScript obfuscators only *minifies* and rename local variables, which is extremely easy to reverse-engineer with a beautifier.
The best combination I've found is the [DojoToolkit](http://www.dojotoolkit.org) and the Closure Compiler in Advanced Mode.
Closure in Advanced Mode makes JavaScript code almost impos... | That depends on what you mean by obfuscation.
If you're referring to minification, using a tool like JSMin, then the effect is nil.
If you're talking about something like Packer, the eval process actually does have an impact on how long it takes for the code to execute. On a slow device, that impact can be significan... |
273,433 | I fitted a **multinomial probit** model with one independent categorical variable **Y** (levels 1,2,3) and two explanatory variables **X1** and **X2**.
Using mlogit package in R like this:
```
library(mlogit)
df = read.csv("https://gitlab.com/cristiandavidarteaga/rtraining/raw/b40daf27a52bf01ce58d0ea32c5e4854f5b2383... | 2017/04/12 | [
"https://stats.stackexchange.com/questions/273433",
"https://stats.stackexchange.com",
"https://stats.stackexchange.com/users/132099/"
] | >
> For example, If I have these coefficients, How can I manually predict (by hand, not using R) the outcome (1, 2 or 3) for x1 = 26 and x2 = 55 ?
>
>
>
You cannot do it by hand. The conditional probabilities are given by 2D integrals with the integrand being a multivariate normal distribution density function. Th... | In the Multinomial Probit model, recall that the probability of individual $i$ choosing alternative $j$, expressed as $\pi\_{ij}$, is given by:
$$P(Y = y\_{ij}) = \pi\_{ij} = \Phi(\beta\_0 + \beta\_1x\_{1i} + \beta\_2x\_{2i} + \theta\_j)$$
where
$\Phi(z)$ = the standard normal cumulative density function, expressed as:... |
136,582 | I got a 5.8" eink display from Pervasive Displays and cannot get it to work, I feel that only a little bit is missing. After a lot of struggle I managed to run it via their sample C code, but the ported code to Python doesn't work. First the hardware details:
I connected it as described here: <https://embeddedcomputin... | 2022/03/14 | [
"https://raspberrypi.stackexchange.com/questions/136582",
"https://raspberrypi.stackexchange.com",
"https://raspberrypi.stackexchange.com/users/144946/"
] | Not sure how quickly you want the program to start after boot but I use the following code in a bash file to start a python3 daemon:
**starttest.sh**
```
sleep 10
nohup python3 -u /home/pi/bin/test.py > "/tmp/nohup.out" &
pid=$!
echo "kill $pid" >/tmp/killpopup.sh
```
and I start it from a .desktop file in `/home/... | rc.local is an obsolete SysV concept and should not be used to start programs. There are dozens (if not hundreds) of similar questions with suggested solutions.
Without knowing what your program is supposed to do it is impossible to say which you should use. |
136,582 | I got a 5.8" eink display from Pervasive Displays and cannot get it to work, I feel that only a little bit is missing. After a lot of struggle I managed to run it via their sample C code, but the ported code to Python doesn't work. First the hardware details:
I connected it as described here: <https://embeddedcomputin... | 2022/03/14 | [
"https://raspberrypi.stackexchange.com/questions/136582",
"https://raspberrypi.stackexchange.com",
"https://raspberrypi.stackexchange.com/users/144946/"
] | Not sure how quickly you want the program to start after boot but I use the following code in a bash file to start a python3 daemon:
**starttest.sh**
```
sleep 10
nohup python3 -u /home/pi/bin/test.py > "/tmp/nohup.out" &
pid=$!
echo "kill $pid" >/tmp/killpopup.sh
```
and I start it from a .desktop file in `/home/... | As @Milliways said, the first rule is, "Don't use rc.local" because it is deprecated, and its behavior is not documented. This is true for RPi OS, but may not be true for all distros.
You *apparently* have two programs: `program.py` & what I'll call `somethingelse.py`. Your question doesn't *seem* to indicate what you... |
433,333 | What does it mean?
```
(root) CMD ( [ -x /usr/lib/php5/maxlifetime ] && [ -d /var/lib/php5 ] && find /var/lib/php5/ -depth -mindepth 1 -maxdepth 1 -type f -cmin +$(/usr/lib/php5/maxlifetime) ! -execdir fuser -s {} 2>/dev/null \; -delete)
```
Found it in system.log. | 2014/03/12 | [
"https://askubuntu.com/questions/433333",
"https://askubuntu.com",
"https://askubuntu.com/users/49044/"
] | You chopped up part of the log line, which would provide more context about what this means.
It would be something like:
```
syslog:Mar 12 10:17:01 hostname CRON[4154]: (root) CMD ( [ -x /usr/lib/php5/maxlifetime ] && [ -d /var/lib/php5 ] && find /var/lib/php5/ -depth -mindepth 1 -maxdepth 1 -type f -cmin +$(/usr/li... | This cron job is scheduled in `/etc/cron.d/php5` file. |
18,105,941 | I have Kendo Grid and a ForeignKey column on a page. ForeignKey column is populated using ViewData as described below.
```
column.ForeignKey(x => x.ProductID, (List<Product>)ViewData["products"], "ID", "ProdName");
```
The Grid is editable in batch(InCell) mode as show below...
```
.Editable(editable => editable.Mo... | 2013/08/07 | [
"https://Stackoverflow.com/questions/18105941",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2608298/"
] | I figured out how to filter the Product drop-down using an EditorTemplate for the foreign key column.
Here is my **column definition** for the Product.
```
c.ForeignKey(x => x.ProductID, (List<Product>)ViewData["products"], "ID", "ProdName").EditorTemplateName("ProductIDEditor");
```
Here is the **editor template**... | You don't need the Editor Template. It will bind to a dropdown without it. You can use this, like you had, just minus the template:
```
c.ForeignKey(x => x.ProductID, (List<Product>)ViewData["products"], "ID", "ProdName")
```
or
```
c.ForeignKey(x => x.ProductID, (System.Collections.IEnumerable)ViewData["products"... |
34,807,934 | I have a following JPA entity:
```
@Entity
@Table(name = "sessions")
public class Session extends BaseEntity implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Integer id;
@OneToOne
@JoinColumn(name = "user_id")
private User user;
...
}
```
In order to i... | 2016/01/15 | [
"https://Stackoverflow.com/questions/34807934",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1219755/"
] | The intent of [AutoCloseable](https://docs.oracle.com/javase/7/docs/api/java/lang/AutoCloseable.html) is to automatically perform cleanups when it is *no longer used*.
So it would violate the principle of least astonishment to use the object after the try-with-resources block. | Thanks to @Tunaki, he gave me very useful link to the related question: [Why is declaration required in Java's try-with-resource](https://stackoverflow.com/questions/13836486/why-is-declaration-required-in-javas-try-with-resource)
I was doubted not about **why** this restriction exists, but I was thinking that my idea... |
32,843,507 | I have a video tag and a movie cutted in parts of 10 seconds each, with name: 1.webm, 2.webm ....... 1535.webm. I tried to make a js code which find when the video is ended and play the next one, but I have a problem: the screen flashes and the movie is not playing continuously. I need to play it exactly as a movie, wi... | 2015/09/29 | [
"https://Stackoverflow.com/questions/32843507",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2571001/"
] | It becomes very difficult if you are changing the `src` of the video as it will load the entire video once `src` changes and hence you are facing flashing screen effect. It seems impossible to get seamless video by using video parts yet you can try it this way:
Pre-load all the videos using different `elements` for ea... | May be this will help you we make two video tags and set first 10 sec movie on first video tag, second movie on second video tag and third on again first video tag this process done one by one.
check my link <http://jsfiddle.net/qoch687a/2/>
There is timeupdate event which triggers every sec and we check duration
`... |
22,087,698 | How key is recognized by dictionary object in VBSCript, I mean to say it consider "ABC" and "BCA" as a same Key...??
means I am trying this it is giving me an error that this key already exists so anyone can please give some details about it. | 2014/02/28 | [
"https://Stackoverflow.com/questions/22087698",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3355618/"
] | Not an answer, but I need formatting to point out a pecularity of VBScript's dictionary/dispute AutomatedChaos' claim. A Scripting.Dictionary accepts keys of all simple/scalar data types and even objects. So having two keys 42 and "42" is no problem:
```
>> set dic = CreateObject("Scripting.Dictionary")
>> dic.Add "42... | The dictionary.key is the indicator for a stored item under the Dictionary object.
[Microsoft Dictionary.Key Example:](http://msdn.microsoft.com/en-us/library/1ex01tte%28v=vs.84%29.aspx)
```
'Dictionary.Item("{key}") returns the item information.
'Dictionary.Key("{oldkey}") = "{newkey}" stores a new key for a Dictio... |
29,872,087 | So I just want to understand how I could do this, very simple example:
My html is
```
<div id = "pie"> eee </div>
<input type="text" name="item1" size="5">
```
and my javascript is
```
var q = parseFloat("10");
document.getElementById("pie").innerHTML = q ;
```
and basically what I want to do is call up whate... | 2015/04/25 | [
"https://Stackoverflow.com/questions/29872087",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4833194/"
] | I don't think you need to have `$account` as static, that wouldn't make sense with the way you're probably going to be using this code, try having `public $account;` and then use `["column_account" => $this->account]`
So:
```
class acc{
// Attributes
public $account;
public $pw;
protected $error;
public function ac... | You are calling a variable that doesn't exist.
You declared $accout as public and static.
But you attempt calling $account.
Replace:
```
$my_acc->account = 'Luci';
```
With:
```
$my_acc->accout = 'Luci';
``` |
29,872,087 | So I just want to understand how I could do this, very simple example:
My html is
```
<div id = "pie"> eee </div>
<input type="text" name="item1" size="5">
```
and my javascript is
```
var q = parseFloat("10");
document.getElementById("pie").innerHTML = q ;
```
and basically what I want to do is call up whate... | 2015/04/25 | [
"https://Stackoverflow.com/questions/29872087",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4833194/"
] | I don't think you need to have `$account` as static, that wouldn't make sense with the way you're probably going to be using this code, try having `public $account;` and then use `["column_account" => $this->account]`
So:
```
class acc{
// Attributes
public $account;
public $pw;
protected $error;
public function ac... | Vex is right. Take off the `static` keyword and use `["column_account" => $this->account]` instead.
Bests,
B. |
71,276,105 | I'm having difficulties testing Combine. I'm following:
* <https://www.swiftbysundell.com/articles/unit-testing-combine-based-swift-code/>
Which tests:
```swift
final class ViewModel {
@Published private(set) var tokens = [String]()
@Published var string = ""
private let tokenizer = Tokenizer()
ini... | 2022/02/26 | [
"https://Stackoverflow.com/questions/71276105",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11076699/"
] | What is happening here is that `numpy` automatically ["broadcasts"](https://numpy.org/doc/stable/user/basics.broadcasting.html) the lower-dimensional array to match the shape of the higher-dimensional array.
In this concrete instance the `b` array gets broadcasted into a matrix where each row is a copy of the original... | Consider your transposed array `a` and `b`:
```
[[ 0. 1. 0. ]
[ 0. 1. 0. ]
[ 0. -2.234 0. ]]
[ 1. 1. -2.234]
```
What `np.isclose` is doing is literally comparing (within a given tolerance) each element in each row of `a` with each element in `b` based on broadcasting, which resul... |
71,276,105 | I'm having difficulties testing Combine. I'm following:
* <https://www.swiftbysundell.com/articles/unit-testing-combine-based-swift-code/>
Which tests:
```swift
final class ViewModel {
@Published private(set) var tokens = [String]()
@Published var string = ""
private let tokenizer = Tokenizer()
ini... | 2022/02/26 | [
"https://Stackoverflow.com/questions/71276105",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11076699/"
] | Consider your transposed array `a` and `b`:
```
[[ 0. 1. 0. ]
[ 0. 1. 0. ]
[ 0. -2.234 0. ]]
[ 1. 1. -2.234]
```
What `np.isclose` is doing is literally comparing (within a given tolerance) each element in each row of `a` with each element in `b` based on broadcasting, which resul... | [`np.isclose`](https://numpy.org/doc/stable/reference/generated/numpy.isclose.html) just checks that the values are close enough that you can consider them equal with a given threshold
By doing:
```
np.isclose(np.transpose(a), b)
```
you compare each column of a.T with each column of b.
The first column `[0,0,0]` i... |
71,276,105 | I'm having difficulties testing Combine. I'm following:
* <https://www.swiftbysundell.com/articles/unit-testing-combine-based-swift-code/>
Which tests:
```swift
final class ViewModel {
@Published private(set) var tokens = [String]()
@Published var string = ""
private let tokenizer = Tokenizer()
ini... | 2022/02/26 | [
"https://Stackoverflow.com/questions/71276105",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11076699/"
] | What is happening here is that `numpy` automatically ["broadcasts"](https://numpy.org/doc/stable/user/basics.broadcasting.html) the lower-dimensional array to match the shape of the higher-dimensional array.
In this concrete instance the `b` array gets broadcasted into a matrix where each row is a copy of the original... | [`np.isclose`](https://numpy.org/doc/stable/reference/generated/numpy.isclose.html) just checks that the values are close enough that you can consider them equal with a given threshold
By doing:
```
np.isclose(np.transpose(a), b)
```
you compare each column of a.T with each column of b.
The first column `[0,0,0]` i... |
52,441,290 | I'm trying to loop two arrays by using one \*ngFor but it doesn't show any element on the browser. I have sample of HTML file below also initialized arrays in component file.
HTML file:
```html
<tbody *ngIf="feedbacks.length">
<ng-container *ngFor="let fd of feedbacks;let res of results;let i=index">
... | 2018/09/21 | [
"https://Stackoverflow.com/questions/52441290",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7793546/"
] | The `ngFor` structural directive only accepts a single iterable as input. It won't accept more than one array. Instead of trying to loop through two separate arrays, I would suggest creating a single array (provided both arrays are of the same length).
```
// HTML
<tbody *ngIf="feedbacks.length">
<ng-container *ng... | You should modify your template a bit:
`<tbody *ngIf="feedbacks.length">
<ng-container *ngFor="let feedback of feedbacks;let i=index">
<tr>
<td>{{ i }}</td>
<td>{{feedback}}</td>
<td colspan="2">
<ul>
<div *ngFor="let result of results[i]">
<td>Test: {{result.score}}</td>
</div>
</ul>
</td>
</tr>
</ng-con... |
52,441,290 | I'm trying to loop two arrays by using one \*ngFor but it doesn't show any element on the browser. I have sample of HTML file below also initialized arrays in component file.
HTML file:
```html
<tbody *ngIf="feedbacks.length">
<ng-container *ngFor="let fd of feedbacks;let res of results;let i=index">
... | 2018/09/21 | [
"https://Stackoverflow.com/questions/52441290",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7793546/"
] | use `let obj of results[i]` for this.
```
<tbody *ngIf="feedbacks.length">
<ng-container *ngFor="let fd of feedbacks;let i=index">
<tr>
<td>{{ i }}</td>
<td>{{fd}}</td>
<td colspan="2">
<ul>
<div *ngFor="let obj of results[i]">
... | The `ngFor` structural directive only accepts a single iterable as input. It won't accept more than one array. Instead of trying to loop through two separate arrays, I would suggest creating a single array (provided both arrays are of the same length).
```
// HTML
<tbody *ngIf="feedbacks.length">
<ng-container *ng... |
52,441,290 | I'm trying to loop two arrays by using one \*ngFor but it doesn't show any element on the browser. I have sample of HTML file below also initialized arrays in component file.
HTML file:
```html
<tbody *ngIf="feedbacks.length">
<ng-container *ngFor="let fd of feedbacks;let res of results;let i=index">
... | 2018/09/21 | [
"https://Stackoverflow.com/questions/52441290",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7793546/"
] | The `ngFor` structural directive only accepts a single iterable as input. It won't accept more than one array. Instead of trying to loop through two separate arrays, I would suggest creating a single array (provided both arrays are of the same length).
```
// HTML
<tbody *ngIf="feedbacks.length">
<ng-container *ng... | ```
<ng-container *ngFor="let fd of feedbacks;index as i">
<ng-container *ngFor="let res of results;index as j>
<ng-container *ngIf="i===j">
{{Here You can access fd and res of same index}}
<ng-container>
</ng-container>
</ng-container>
```
Tried similar code on angular11 and it was working. |
52,441,290 | I'm trying to loop two arrays by using one \*ngFor but it doesn't show any element on the browser. I have sample of HTML file below also initialized arrays in component file.
HTML file:
```html
<tbody *ngIf="feedbacks.length">
<ng-container *ngFor="let fd of feedbacks;let res of results;let i=index">
... | 2018/09/21 | [
"https://Stackoverflow.com/questions/52441290",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7793546/"
] | use `let obj of results[i]` for this.
```
<tbody *ngIf="feedbacks.length">
<ng-container *ngFor="let fd of feedbacks;let i=index">
<tr>
<td>{{ i }}</td>
<td>{{fd}}</td>
<td colspan="2">
<ul>
<div *ngFor="let obj of results[i]">
... | You should modify your template a bit:
`<tbody *ngIf="feedbacks.length">
<ng-container *ngFor="let feedback of feedbacks;let i=index">
<tr>
<td>{{ i }}</td>
<td>{{feedback}}</td>
<td colspan="2">
<ul>
<div *ngFor="let result of results[i]">
<td>Test: {{result.score}}</td>
</div>
</ul>
</td>
</tr>
</ng-con... |
52,441,290 | I'm trying to loop two arrays by using one \*ngFor but it doesn't show any element on the browser. I have sample of HTML file below also initialized arrays in component file.
HTML file:
```html
<tbody *ngIf="feedbacks.length">
<ng-container *ngFor="let fd of feedbacks;let res of results;let i=index">
... | 2018/09/21 | [
"https://Stackoverflow.com/questions/52441290",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7793546/"
] | try this
```
<tbody>
<tr *ngFor="let fd of feedbacks;let i=index">
<td>{{ i }} </td>
<td>{{fd}} {{results[i].score}}</td>
<td>{{fd}} {{results[i].tone_id}}</td>
<td>{{fd}} {{results[i].tone_name}}</td>
</tr>
</tbody>
``` | You should modify your template a bit:
`<tbody *ngIf="feedbacks.length">
<ng-container *ngFor="let feedback of feedbacks;let i=index">
<tr>
<td>{{ i }}</td>
<td>{{feedback}}</td>
<td colspan="2">
<ul>
<div *ngFor="let result of results[i]">
<td>Test: {{result.score}}</td>
</div>
</ul>
</td>
</tr>
</ng-con... |
52,441,290 | I'm trying to loop two arrays by using one \*ngFor but it doesn't show any element on the browser. I have sample of HTML file below also initialized arrays in component file.
HTML file:
```html
<tbody *ngIf="feedbacks.length">
<ng-container *ngFor="let fd of feedbacks;let res of results;let i=index">
... | 2018/09/21 | [
"https://Stackoverflow.com/questions/52441290",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7793546/"
] | use `let obj of results[i]` for this.
```
<tbody *ngIf="feedbacks.length">
<ng-container *ngFor="let fd of feedbacks;let i=index">
<tr>
<td>{{ i }}</td>
<td>{{fd}}</td>
<td colspan="2">
<ul>
<div *ngFor="let obj of results[i]">
... | ```
<ng-container *ngFor="let fd of feedbacks;index as i">
<ng-container *ngFor="let res of results;index as j>
<ng-container *ngIf="i===j">
{{Here You can access fd and res of same index}}
<ng-container>
</ng-container>
</ng-container>
```
Tried similar code on angular11 and it was working. |
52,441,290 | I'm trying to loop two arrays by using one \*ngFor but it doesn't show any element on the browser. I have sample of HTML file below also initialized arrays in component file.
HTML file:
```html
<tbody *ngIf="feedbacks.length">
<ng-container *ngFor="let fd of feedbacks;let res of results;let i=index">
... | 2018/09/21 | [
"https://Stackoverflow.com/questions/52441290",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7793546/"
] | use `let obj of results[i]` for this.
```
<tbody *ngIf="feedbacks.length">
<ng-container *ngFor="let fd of feedbacks;let i=index">
<tr>
<td>{{ i }}</td>
<td>{{fd}}</td>
<td colspan="2">
<ul>
<div *ngFor="let obj of results[i]">
... | try this
```
<tbody>
<tr *ngFor="let fd of feedbacks;let i=index">
<td>{{ i }} </td>
<td>{{fd}} {{results[i].score}}</td>
<td>{{fd}} {{results[i].tone_id}}</td>
<td>{{fd}} {{results[i].tone_name}}</td>
</tr>
</tbody>
``` |
52,441,290 | I'm trying to loop two arrays by using one \*ngFor but it doesn't show any element on the browser. I have sample of HTML file below also initialized arrays in component file.
HTML file:
```html
<tbody *ngIf="feedbacks.length">
<ng-container *ngFor="let fd of feedbacks;let res of results;let i=index">
... | 2018/09/21 | [
"https://Stackoverflow.com/questions/52441290",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7793546/"
] | try this
```
<tbody>
<tr *ngFor="let fd of feedbacks;let i=index">
<td>{{ i }} </td>
<td>{{fd}} {{results[i].score}}</td>
<td>{{fd}} {{results[i].tone_id}}</td>
<td>{{fd}} {{results[i].tone_name}}</td>
</tr>
</tbody>
``` | ```
<ng-container *ngFor="let fd of feedbacks;index as i">
<ng-container *ngFor="let res of results;index as j>
<ng-container *ngIf="i===j">
{{Here You can access fd and res of same index}}
<ng-container>
</ng-container>
</ng-container>
```
Tried similar code on angular11 and it was working. |
25,004,641 | I am trying to get my followers to display on the **pages/friends** however, I keep getting multiple errors like an ***undefined method `each' for nil:NilClass*** in my Pages#friends error. I am following Michael Harlts tutorials on follow/unfollow however, I needed to tweak a couple of things because I did not follow ... | 2014/07/28 | [
"https://Stackoverflow.com/questions/25004641",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3853466/"
] | The error `undefined method 'each' for nil:NilClass` means that you're calling `.each` on an object that is `nil`.
For example, here, `@users` could be `nil`:
```
def index
@users = User.paginate(page: params[:page], :per_page => 5)
end
```
If you then call `<% @users.each ... %>`, you'll get the `undefined metho... | As you're new, I'll give you another opinion. What I'm going to write is similar to `Sam`'s answer; I intend to help you appreciate how Rails works, to further your experience
---
**Objects**
You must remember that Rails is built on top of Ruby - an [*object-orientated* language](http://www.tutorialspoint.com/ruby/r... |
101,933 | When I package my app in Managed Package for outside world, the other org gets "Internal Server Error" when the Lightning Component Tab is loaded in S1 or new Lightning Experience interface.
I worked out myself to see if I missed namespaces. While doing that I'm trying to work namespaces according to this document -
... | 2015/12/09 | [
"https://salesforce.stackexchange.com/questions/101933",
"https://salesforce.stackexchange.com",
"https://salesforce.stackexchange.com/users/1205/"
] | Have you done anything as far as setting access so that your component (and any necessary resources it uses) are accessible outside of the package namespace?
I am not an expert at this, but when you build a package, and you need to make features (components, Apex classes, VF pages) accessible to the installing org to... | The correction in the first case is correct you need to use `__` to separate [namespace](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_namespace_prefix.htm) of an object.
Regarding to the second correction try to specify `type="List"` as there are a some core issues that broke s... |
101,933 | When I package my app in Managed Package for outside world, the other org gets "Internal Server Error" when the Lightning Component Tab is loaded in S1 or new Lightning Experience interface.
I worked out myself to see if I missed namespaces. While doing that I'm trying to work namespaces according to this document -
... | 2015/12/09 | [
"https://salesforce.stackexchange.com/questions/101933",
"https://salesforce.stackexchange.com",
"https://salesforce.stackexchange.com/users/1205/"
] | After `Spring '16` deployment the same component started working fine.
SFDC support was also not able to pin point the cause. They were able to reproduce it but have not suggested it as a bug (strange!).
Though `Spring '16` deployment have magically fixed that. I'm now able to run my same old code without any modif... | The correction in the first case is correct you need to use `__` to separate [namespace](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_namespace_prefix.htm) of an object.
Regarding to the second correction try to specify `type="List"` as there are a some core issues that broke s... |
101,933 | When I package my app in Managed Package for outside world, the other org gets "Internal Server Error" when the Lightning Component Tab is loaded in S1 or new Lightning Experience interface.
I worked out myself to see if I missed namespaces. While doing that I'm trying to work namespaces according to this document -
... | 2015/12/09 | [
"https://salesforce.stackexchange.com/questions/101933",
"https://salesforce.stackexchange.com",
"https://salesforce.stackexchange.com/users/1205/"
] | After `Spring '16` deployment the same component started working fine.
SFDC support was also not able to pin point the cause. They were able to reproduce it but have not suggested it as a bug (strange!).
Though `Spring '16` deployment have magically fixed that. I'm now able to run my same old code without any modif... | Have you done anything as far as setting access so that your component (and any necessary resources it uses) are accessible outside of the package namespace?
I am not an expert at this, but when you build a package, and you need to make features (components, Apex classes, VF pages) accessible to the installing org to... |
28,642,253 | For an assignment, I'm supposed to create a script called `my_which.sh` that will "do the same thing as the Unix command, but do it using a for loop over an if." I am also not allowed to call which in my script.
I'm brand new to this, and have been reading tutorials, but I'm pretty confused on how to start. Doesn't `w... | 2015/02/21 | [
"https://Stackoverflow.com/questions/28642253",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3427023/"
] | ```
#!/bin/bash
#Get the user's first argument to this script
exe_name=$1
#Set the field separator to ":" (this is what the PATH variable
# uses as its delimiter), then read the contents of the PATH
# into the array variable "paths" -- at the same time splitting
# the PATH by ":"
IFS=':' read -a paths <<< $PATH ... | This is similar to the accepted answer with the difference that it does not set the IFS and checks if the execute bits are set.
```
#!/bin/bash
for i in $(echo "$PATH" | tr ":" "\n")
do
find "$i" -name "$1" -perm +111 -maxdepth 1
done
```
Save this as `my_which.sh` (or some other name) and run... |
28,642,253 | For an assignment, I'm supposed to create a script called `my_which.sh` that will "do the same thing as the Unix command, but do it using a for loop over an if." I am also not allowed to call which in my script.
I'm brand new to this, and have been reading tutorials, but I'm pretty confused on how to start. Doesn't `w... | 2015/02/21 | [
"https://Stackoverflow.com/questions/28642253",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3427023/"
] | 1. Split your `PATH` variable *safely*. This is a general method to split a string at delimiters, that is 100% safe regarding any possible characters (including newlines):
```
IFS=: read -r -d '' -a paths < <(printf '%s:\0' "$PATH")
```
We artificially added `:` because if `PATH` ends with a trailing `:`, then it is... | This is similar to the accepted answer with the difference that it does not set the IFS and checks if the execute bits are set.
```
#!/bin/bash
for i in $(echo "$PATH" | tr ":" "\n")
do
find "$i" -name "$1" -perm +111 -maxdepth 1
done
```
Save this as `my_which.sh` (or some other name) and run... |
28,642,253 | For an assignment, I'm supposed to create a script called `my_which.sh` that will "do the same thing as the Unix command, but do it using a for loop over an if." I am also not allowed to call which in my script.
I'm brand new to this, and have been reading tutorials, but I'm pretty confused on how to start. Doesn't `w... | 2015/02/21 | [
"https://Stackoverflow.com/questions/28642253",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3427023/"
] | 1. Split your `PATH` variable *safely*. This is a general method to split a string at delimiters, that is 100% safe regarding any possible characters (including newlines):
```
IFS=: read -r -d '' -a paths < <(printf '%s:\0' "$PATH")
```
We artificially added `:` because if `PATH` ends with a trailing `:`, then it is... | ```
#!/bin/bash
#Get the user's first argument to this script
exe_name=$1
#Set the field separator to ":" (this is what the PATH variable
# uses as its delimiter), then read the contents of the PATH
# into the array variable "paths" -- at the same time splitting
# the PATH by ":"
IFS=':' read -a paths <<< $PATH ... |
28,642,253 | For an assignment, I'm supposed to create a script called `my_which.sh` that will "do the same thing as the Unix command, but do it using a for loop over an if." I am also not allowed to call which in my script.
I'm brand new to this, and have been reading tutorials, but I'm pretty confused on how to start. Doesn't `w... | 2015/02/21 | [
"https://Stackoverflow.com/questions/28642253",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3427023/"
] | ```
#!/bin/bash
#Get the user's first argument to this script
exe_name=$1
#Set the field separator to ":" (this is what the PATH variable
# uses as its delimiter), then read the contents of the PATH
# into the array variable "paths" -- at the same time splitting
# the PATH by ":"
IFS=':' read -a paths <<< $PATH ... | For a **complete, rock-solid implementation**, see [gniourf\_gniourf's answer](https://stackoverflow.com/a/28647323/45375).
Here's a more concise alternative that makes do with a ***single* invocation of `find`** [per name to investigate].
The OP later clarified that an `if` statement should be used in a loop, but th... |
28,642,253 | For an assignment, I'm supposed to create a script called `my_which.sh` that will "do the same thing as the Unix command, but do it using a for loop over an if." I am also not allowed to call which in my script.
I'm brand new to this, and have been reading tutorials, but I'm pretty confused on how to start. Doesn't `w... | 2015/02/21 | [
"https://Stackoverflow.com/questions/28642253",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3427023/"
] | 1. Split your `PATH` variable *safely*. This is a general method to split a string at delimiters, that is 100% safe regarding any possible characters (including newlines):
```
IFS=: read -r -d '' -a paths < <(printf '%s:\0' "$PATH")
```
We artificially added `:` because if `PATH` ends with a trailing `:`, then it is... | For a **complete, rock-solid implementation**, see [gniourf\_gniourf's answer](https://stackoverflow.com/a/28647323/45375).
Here's a more concise alternative that makes do with a ***single* invocation of `find`** [per name to investigate].
The OP later clarified that an `if` statement should be used in a loop, but th... |
29,832,410 | I would like to be able to use dictionary keys as function names, but I'm not sure if it's possible. As a quick example, instead of `class().dothis(dictkey, otherstuff)`, I'd like to have an option for `class().dictkey(otherstuff)`. Here's a not working code example to give an idea of what I was thinking of.
```
class... | 2015/04/23 | [
"https://Stackoverflow.com/questions/29832410",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2403000/"
] | The only "correct" way I can think of to do this looks like this:
```
class SomeClass(object):
def __init__(self, *args, **kwargs):
funcs = {'funcname': 'returnvalue', ...}
for func, ret_val in funcs.iteritems():
setattr(self, func, self.make_function(ret_val))
@staticmethod
de... | Are you looking for a way to call a function residing inside the current module through a string with its name? If so,
```
def stuff(arg):
return 5
d = {"stuff":"value","stuff2":"value2"}
print globals()["stuff"](d["stuff"])
```
will print 5. |
29,832,410 | I would like to be able to use dictionary keys as function names, but I'm not sure if it's possible. As a quick example, instead of `class().dothis(dictkey, otherstuff)`, I'd like to have an option for `class().dictkey(otherstuff)`. Here's a not working code example to give an idea of what I was thinking of.
```
class... | 2015/04/23 | [
"https://Stackoverflow.com/questions/29832410",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2403000/"
] | The only "correct" way I can think of to do this looks like this:
```
class SomeClass(object):
def __init__(self, *args, **kwargs):
funcs = {'funcname': 'returnvalue', ...}
for func, ret_val in funcs.iteritems():
setattr(self, func, self.make_function(ret_val))
@staticmethod
de... | I would look into partial functions using [`functools.partial`](https://docs.python.org/2/library/functools.html#functools.partial), in conjunction with `__getattribute__`:
```
class Foo:
def __init__(self):
self.a = 5
self.b = 6
def funca(self, x):
print(self.a + x)
def funcb(sel... |
57,852,731 | I am working on my android app for which i am using POST request
I am getting 400 bad request error
I think maybe their is a model class error i am not sure please respond
RetrofitInstance
```
public class RetrofitInstance {
private static Retrofit retrofit = null;
private static String BASE_URL = "http://<your ip ... | 2019/09/09 | [
"https://Stackoverflow.com/questions/57852731",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5116739/"
] | You have to make your values the same type as the required
```
@FormUrlEncoded
@POST("api/movie")
Call<Movie> setMovie(@Field("title") String title,
@Field("genreId") String genreId,
@Field("numberInStock") String numberInStock,
@Field("dailyRentalRate") String dailyRentalRate);... | Change your interface call :
```
Call<Movie> setMovie(@Field("title") String title,
@Field("genreId") String genreId,
@Field("numberInStock") String numberInStock, // Needs String
@Field("dailyRentalRate") String dailyRentalRate);
}
```
and call wil... |
57,852,731 | I am working on my android app for which i am using POST request
I am getting 400 bad request error
I think maybe their is a model class error i am not sure please respond
RetrofitInstance
```
public class RetrofitInstance {
private static Retrofit retrofit = null;
private static String BASE_URL = "http://<your ip ... | 2019/09/09 | [
"https://Stackoverflow.com/questions/57852731",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5116739/"
] | You have to make your values the same type as the required
```
@FormUrlEncoded
@POST("api/movie")
Call<Movie> setMovie(@Field("title") String title,
@Field("genreId") String genreId,
@Field("numberInStock") String numberInStock,
@Field("dailyRentalRate") String dailyRentalRate);... | You can try like below.
```
JsonObject requestBody = new JsonObject();
requestBody.addProperty("title", "intelRPG");
requestBody.addProperty("genreId", "5d7398d2bdc4d04960d60845");
requestBody.addProperty("numberInStock", "20");
requestBody.addProperty("dailyRentalRate",... |
23,831,228 | If i want to deploy one application on different servers like Open Source Glassfish or TomEE. How can I achieve that without having to include different libraries for each application server? As an example if would like to use Jersey as the rest framework and eclipselink as the persistence framework i have to make sure... | 2014/05/23 | [
"https://Stackoverflow.com/questions/23831228",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2215136/"
] | NotificationManager doesn't give you a way to find existing notifications by ID. If you want to update a notification, post a new notification but use the same ID. It will either show it as new or update the existing notification with that ID. | You can get active notification list from NotificationManager.
```
@RequiresApi(api = Build.VERSION_CODES.M)
public Notification getActiveNotification(int notificationId) {
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
StatusBarNotification[] ba... |
36,869,503 | I have an HTML structure like this:
```
<div contenteditable="true">This is some plain, boring content.</div>
```
I also have this function that allows me to set the caret position to anywhere I want within the div:
```
// Move caret to a specific point in a DOM element
function SetCaretPosition(object, pos)
{
... | 2016/04/26 | [
"https://Stackoverflow.com/questions/36869503",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5981288/"
] | So, I was experiencing the same issue and decided to write my own routine quickly, it walks through all the child nodes recursively and set the position.
Note how this takes a DOM node as argument, not a jquery object as your original post does
```
// Move caret to a specific point in a DOM element
function SetCaretPo... | It only work for **object Text** childNodes(0).So you have to make it.Here is not so very standard code,but works.Goal is that (p) id of (we) will output object text.If it does then it might work.
```
<div id="editable" contenteditable="true">dddddddddddddddddddddddddddd<p>dd</p>psss<p>dd</p><p>dd</p>
<p>text text te... |
36,975,451 | I have a one string.
>
> $a = '[{"size":"6Y","quantity":15}]';
>
>
>
I want to store 6Y and 15 in array.
Please help me. | 2016/05/02 | [
"https://Stackoverflow.com/questions/36975451",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6233633/"
] | Use [json\_decode()](http://php.net/manual/en/function.json-decode.php)
You have a json encoded string.
And need to decode it and assign size and quantity to an array.
**Working example:**
```
<?php
$a = '[{"size":"6Y","quantity":15}]';
$b = json_decode($a, TRUE);
$c = array();
if (! empty($b[0])) {
foreach ($b... | Try this, use json\_decode:
```
<?php
$a = '[{"size":"6Y","quantity":15}]';
$a = substr($a, 1, -1);
print_r((array)json_decode($a));
?>
``` |
36,975,451 | I have a one string.
>
> $a = '[{"size":"6Y","quantity":15}]';
>
>
>
I want to store 6Y and 15 in array.
Please help me. | 2016/05/02 | [
"https://Stackoverflow.com/questions/36975451",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6233633/"
] | Use [json\_decode()](http://php.net/manual/en/function.json-decode.php)
You have a json encoded string.
And need to decode it and assign size and quantity to an array.
**Working example:**
```
<?php
$a = '[{"size":"6Y","quantity":15}]';
$b = json_decode($a, TRUE);
$c = array();
if (! empty($b[0])) {
foreach ($b... | Use [call\_user\_func\_array](http://php.net/manual/en/function.call-user-func-array.php) with [array\_merge](http://php.net/manual/en/function.array-merge.php)
1. Json decode your string
2. Flatten the array
like this:
```
<?php
$a = '[{"size":"6Y","quantity":15}]';
$b = call_user_func_array('array_merge', json_dec... |
36,975,451 | I have a one string.
>
> $a = '[{"size":"6Y","quantity":15}]';
>
>
>
I want to store 6Y and 15 in array.
Please help me. | 2016/05/02 | [
"https://Stackoverflow.com/questions/36975451",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6233633/"
] | Use [json\_decode()](http://php.net/manual/en/function.json-decode.php)
You have a json encoded string.
And need to decode it and assign size and quantity to an array.
**Working example:**
```
<?php
$a = '[{"size":"6Y","quantity":15}]';
$b = json_decode($a, TRUE);
$c = array();
if (! empty($b[0])) {
foreach ($b... | ```
$a = '[{"size":"6Y","quantity":15}]';
$v = json_decode($a);
print_r(array_values($v));
``` |
36,975,451 | I have a one string.
>
> $a = '[{"size":"6Y","quantity":15}]';
>
>
>
I want to store 6Y and 15 in array.
Please help me. | 2016/05/02 | [
"https://Stackoverflow.com/questions/36975451",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6233633/"
] | Use [call\_user\_func\_array](http://php.net/manual/en/function.call-user-func-array.php) with [array\_merge](http://php.net/manual/en/function.array-merge.php)
1. Json decode your string
2. Flatten the array
like this:
```
<?php
$a = '[{"size":"6Y","quantity":15}]';
$b = call_user_func_array('array_merge', json_dec... | Try this, use json\_decode:
```
<?php
$a = '[{"size":"6Y","quantity":15}]';
$a = substr($a, 1, -1);
print_r((array)json_decode($a));
?>
``` |
36,975,451 | I have a one string.
>
> $a = '[{"size":"6Y","quantity":15}]';
>
>
>
I want to store 6Y and 15 in array.
Please help me. | 2016/05/02 | [
"https://Stackoverflow.com/questions/36975451",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6233633/"
] | Use [call\_user\_func\_array](http://php.net/manual/en/function.call-user-func-array.php) with [array\_merge](http://php.net/manual/en/function.array-merge.php)
1. Json decode your string
2. Flatten the array
like this:
```
<?php
$a = '[{"size":"6Y","quantity":15}]';
$b = call_user_func_array('array_merge', json_dec... | ```
$a = '[{"size":"6Y","quantity":15}]';
$v = json_decode($a);
print_r(array_values($v));
``` |
72,328,032 | I have this rough code in Javascript, I want to implement this code in my react application but I am not sure how to implement them in react.
**Overview of my requirement** --
>
> I want to clear a particular token from local storage unless the user **closes all the tabs or
> exits the browser**, so the next time us... | 2022/05/21 | [
"https://Stackoverflow.com/questions/72328032",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17030676/"
] | Probably backed is not able to send proper HTTP headers like “content-disposition: attachment”. Trying to fix it on UI side we left with code that tries to simulate click on the link so browser will start fetching the resource.
Building link and clicking on it is not related to React self. Author just tried to fix mis... | This is likely because they are creating a new element in the DOM, then invoking the `download` attribute, before deleting the element again. Certainly isn’t the best practice but seems to get the job done |
72,328,032 | I have this rough code in Javascript, I want to implement this code in my react application but I am not sure how to implement them in react.
**Overview of my requirement** --
>
> I want to clear a particular token from local storage unless the user **closes all the tabs or
> exits the browser**, so the next time us... | 2022/05/21 | [
"https://Stackoverflow.com/questions/72328032",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17030676/"
] | Without reaching the author, we will never know why they deemed it hacky. I deem this code hacky for two reasons:
1. The code creates a `<a>` element, sets a link, automatically clicks it, and then deletes it. Manually triggering clicks on elements is very hacky, as we should not take control of the user’s actions. Ra... | This is likely because they are creating a new element in the DOM, then invoking the `download` attribute, before deleting the element again. Certainly isn’t the best practice but seems to get the job done |
493,142 | On Windows, Google Chrome has the option to create a shortcut on the desktop for each Chrome user. For example, I have my personal Google Account and I also have my company Google Account. So, I setup Google Chrome with two users and I created two shortcuts on desktop for each user.
On Ubuntu, I also created two users... | 2014/07/08 | [
"https://askubuntu.com/questions/493142",
"https://askubuntu.com",
"https://askubuntu.com/users/251793/"
] | It is quite simple to do this in [Windows](https://superuser.com/a/723145) but not the same in Ubuntu.
For Ubuntu, I found two ways. Personally I recommend method 2 because you don't need to install anything. It also allows you to access the second profile from "Activities" (Ubuntu) without using any commands.
Please... | 1. Create a data directory for profile.
Example: Create a directory called `in-softs` in the `home` directory.
Create a directory called `uv` in the that `in-softs` directory.
2. Create a new file named `MyChrome.desktop` on the desktop and copy following content into that file.
```
[Desktop Entry]
Version=1.0
Name=... |
493,142 | On Windows, Google Chrome has the option to create a shortcut on the desktop for each Chrome user. For example, I have my personal Google Account and I also have my company Google Account. So, I setup Google Chrome with two users and I created two shortcuts on desktop for each user.
On Ubuntu, I also created two users... | 2014/07/08 | [
"https://askubuntu.com/questions/493142",
"https://askubuntu.com",
"https://askubuntu.com/users/251793/"
] | It is quite simple to do this in [Windows](https://superuser.com/a/723145) but not the same in Ubuntu.
For Ubuntu, I found two ways. Personally I recommend method 2 because you don't need to install anything. It also allows you to access the second profile from "Activities" (Ubuntu) without using any commands.
Please... | Edit the main shortcut file:
```
/usr/share/applications/google-chrome.desktop
```
The section `[Desktop Entry]` find the option `Actions=` and add your new action (use semi-colon to separate and at the end):
```
Actions=new-window;new-private-window;new-window-myprofile;
```
Create a new section with the same na... |
493,142 | On Windows, Google Chrome has the option to create a shortcut on the desktop for each Chrome user. For example, I have my personal Google Account and I also have my company Google Account. So, I setup Google Chrome with two users and I created two shortcuts on desktop for each user.
On Ubuntu, I also created two users... | 2014/07/08 | [
"https://askubuntu.com/questions/493142",
"https://askubuntu.com",
"https://askubuntu.com/users/251793/"
] | This is what I did to achieve the same thing:
```
sudo apt-get install gnome-panel
gnome-desktop-item-edit ~/Desktop/ --create-new
```
to create the first "Application Launcher" with the `Command`:
```
google-chrome --user-data-dir=/home/XXXXX/.config/google-chrome/Profile\ 1
```
Then drag the icon created from t... | All the other answers have a caveat: the shortcut will open tabs or new windows and group them with the official Google Chrome shortcut.
I wanted to make the new shortcut to open windows in its own icon, so I can place both icons in my dock and easily switch between the different Chromes.
I discovered that you basica... |
493,142 | On Windows, Google Chrome has the option to create a shortcut on the desktop for each Chrome user. For example, I have my personal Google Account and I also have my company Google Account. So, I setup Google Chrome with two users and I created two shortcuts on desktop for each user.
On Ubuntu, I also created two users... | 2014/07/08 | [
"https://askubuntu.com/questions/493142",
"https://askubuntu.com",
"https://askubuntu.com/users/251793/"
] | It is quite simple to do this in [Windows](https://superuser.com/a/723145) but not the same in Ubuntu.
For Ubuntu, I found two ways. Personally I recommend method 2 because you don't need to install anything. It also allows you to access the second profile from "Activities" (Ubuntu) without using any commands.
Please... | Here's how I did it in Linux Mint, which is based on Ubuntu:
Install Chrome by whatever guide you'd like to follow. If it's already installed, that's fine.
Once Chrome is installed, copy the Chrome launcher icon to the desktop by right-clicking the Chrome icon in the 'start' menu and then selecting 'Add to Desktop"
... |
493,142 | On Windows, Google Chrome has the option to create a shortcut on the desktop for each Chrome user. For example, I have my personal Google Account and I also have my company Google Account. So, I setup Google Chrome with two users and I created two shortcuts on desktop for each user.
On Ubuntu, I also created two users... | 2014/07/08 | [
"https://askubuntu.com/questions/493142",
"https://askubuntu.com",
"https://askubuntu.com/users/251793/"
] | It is quite simple to do this in [Windows](https://superuser.com/a/723145) but not the same in Ubuntu.
For Ubuntu, I found two ways. Personally I recommend method 2 because you don't need to install anything. It also allows you to access the second profile from "Activities" (Ubuntu) without using any commands.
Please... | This is what I did to achieve the same thing:
```
sudo apt-get install gnome-panel
gnome-desktop-item-edit ~/Desktop/ --create-new
```
to create the first "Application Launcher" with the `Command`:
```
google-chrome --user-data-dir=/home/XXXXX/.config/google-chrome/Profile\ 1
```
Then drag the icon created from t... |
493,142 | On Windows, Google Chrome has the option to create a shortcut on the desktop for each Chrome user. For example, I have my personal Google Account and I also have my company Google Account. So, I setup Google Chrome with two users and I created two shortcuts on desktop for each user.
On Ubuntu, I also created two users... | 2014/07/08 | [
"https://askubuntu.com/questions/493142",
"https://askubuntu.com",
"https://askubuntu.com/users/251793/"
] | This is what I did to achieve the same thing:
```
sudo apt-get install gnome-panel
gnome-desktop-item-edit ~/Desktop/ --create-new
```
to create the first "Application Launcher" with the `Command`:
```
google-chrome --user-data-dir=/home/XXXXX/.config/google-chrome/Profile\ 1
```
Then drag the icon created from t... | Edit the main shortcut file:
```
/usr/share/applications/google-chrome.desktop
```
The section `[Desktop Entry]` find the option `Actions=` and add your new action (use semi-colon to separate and at the end):
```
Actions=new-window;new-private-window;new-window-myprofile;
```
Create a new section with the same na... |
493,142 | On Windows, Google Chrome has the option to create a shortcut on the desktop for each Chrome user. For example, I have my personal Google Account and I also have my company Google Account. So, I setup Google Chrome with two users and I created two shortcuts on desktop for each user.
On Ubuntu, I also created two users... | 2014/07/08 | [
"https://askubuntu.com/questions/493142",
"https://askubuntu.com",
"https://askubuntu.com/users/251793/"
] | It is quite simple to do this in [Windows](https://superuser.com/a/723145) but not the same in Ubuntu.
For Ubuntu, I found two ways. Personally I recommend method 2 because you don't need to install anything. It also allows you to access the second profile from "Activities" (Ubuntu) without using any commands.
Please... | Create your chrome profile folder. (You may also place them elsewhere, and `ln -s` them to here)
```
cd ~/.config/google-chrome
mkdir chrome-foo
```
create a start file in `/usr/bin`:
```
sudo touch /usr/bin/chrome-foo
sudo pluma /usr/bin/chrome-foo
```
in `pluma` (or `geany` or `nano` or `vi`...)
```
#!/u... |
493,142 | On Windows, Google Chrome has the option to create a shortcut on the desktop for each Chrome user. For example, I have my personal Google Account and I also have my company Google Account. So, I setup Google Chrome with two users and I created two shortcuts on desktop for each user.
On Ubuntu, I also created two users... | 2014/07/08 | [
"https://askubuntu.com/questions/493142",
"https://askubuntu.com",
"https://askubuntu.com/users/251793/"
] | All the other answers have a caveat: the shortcut will open tabs or new windows and group them with the official Google Chrome shortcut.
I wanted to make the new shortcut to open windows in its own icon, so I can place both icons in my dock and easily switch between the different Chromes.
I discovered that you basica... | Here's how I did it in Linux Mint, which is based on Ubuntu:
Install Chrome by whatever guide you'd like to follow. If it's already installed, that's fine.
Once Chrome is installed, copy the Chrome launcher icon to the desktop by right-clicking the Chrome icon in the 'start' menu and then selecting 'Add to Desktop"
... |
493,142 | On Windows, Google Chrome has the option to create a shortcut on the desktop for each Chrome user. For example, I have my personal Google Account and I also have my company Google Account. So, I setup Google Chrome with two users and I created two shortcuts on desktop for each user.
On Ubuntu, I also created two users... | 2014/07/08 | [
"https://askubuntu.com/questions/493142",
"https://askubuntu.com",
"https://askubuntu.com/users/251793/"
] | Edit the main shortcut file:
```
/usr/share/applications/google-chrome.desktop
```
The section `[Desktop Entry]` find the option `Actions=` and add your new action (use semi-colon to separate and at the end):
```
Actions=new-window;new-private-window;new-window-myprofile;
```
Create a new section with the same na... | 1. Create a data directory for profile.
Example: Create a directory called `in-softs` in the `home` directory.
Create a directory called `uv` in the that `in-softs` directory.
2. Create a new file named `MyChrome.desktop` on the desktop and copy following content into that file.
```
[Desktop Entry]
Version=1.0
Name=... |
493,142 | On Windows, Google Chrome has the option to create a shortcut on the desktop for each Chrome user. For example, I have my personal Google Account and I also have my company Google Account. So, I setup Google Chrome with two users and I created two shortcuts on desktop for each user.
On Ubuntu, I also created two users... | 2014/07/08 | [
"https://askubuntu.com/questions/493142",
"https://askubuntu.com",
"https://askubuntu.com/users/251793/"
] | Edit the main shortcut file:
```
/usr/share/applications/google-chrome.desktop
```
The section `[Desktop Entry]` find the option `Actions=` and add your new action (use semi-colon to separate and at the end):
```
Actions=new-window;new-private-window;new-window-myprofile;
```
Create a new section with the same na... | Create your chrome profile folder. (You may also place them elsewhere, and `ln -s` them to here)
```
cd ~/.config/google-chrome
mkdir chrome-foo
```
create a start file in `/usr/bin`:
```
sudo touch /usr/bin/chrome-foo
sudo pluma /usr/bin/chrome-foo
```
in `pluma` (or `geany` or `nano` or `vi`...)
```
#!/u... |
59,256,398 | I'm working on a text editing UwP Desktop application that needs to add a line when the user presses ENTER, and perform another procedure when the user presses CTRL + ENTER. The problem is to delete the new line that is also created in the second case. How to prevent this from happening?
```
KeyEventHandler keyeve... | 2019/12/09 | [
"https://Stackoverflow.com/questions/59256398",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10664966/"
] | Two versions:
```
#include <cstdio> // std::rename
#include <string>
int main() {
std::string c;
std::string oldname = "D:\\subasta\\"+ c +".txt";
std::string newname = "D:\\subasta\\open\\" + c + ".txt";
std::rename(oldname.c_str(), newname.c_str());
}
```
```
#include <filesystem> // std::filesyst... | Try to write like this.
```
string c; //your original string
char variable[]; //your convert variable
strcpy(variable, c.c_str());
cout<<"What file should be moved?"<<endl;
getline(cin,c);
char oldname[] = "D:\\subasta\\"+ variable +".txt";
char newname[] = "D:\\subast... |
425,924 | All,
Thanks in advance for your help. There're a lot of "low hanging fruit" problems at work I need to tackle as a tech-level employee. One of them is curve-fitting 6 data points to a cubic curve, and the other regression questions don't address it as well.
The specific application is calibration of pressure sensor... | 2013/06/21 | [
"https://math.stackexchange.com/questions/425924",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/83306/"
] | Our goal is to find a function of the form $a+bx+cx^2+dx^3$ that gives us the least-squares approximation to a set of data points $\{(x\_1,y\_1),(x\_2,y\_2),\dots,(x\_n,y\_n)\}$
Let $A$ be the matrix
$$
A=\begin{bmatrix}
1 & x\_1 & {x\_1}^2 & {x\_1}^3\\
1 & x\_2 & {x\_2}^2 & {x\_2}^3\\
\,& \vdots & \vdots & \, \\
1 &... | If you tabulate your data in Excel and plot it, you can ask it to Add Trendline, select a degree 3 polynomial, and show trendline equation. That is probably the least work to get to a solution. I don't know how to read the coefficients off in machine-readable form.
Any numerical analysis text will have a whole section... |
46,215 | [Looking at the question](https://ell.stackexchange.com/questions/46214/how-do-i-instruct-my-daughter-to-drink-water-from-a-bottle-from-up) "How do I instruct my daughter to drink water from a bottle from 'up'!", I suddenly struck a question.
If that girl has drunk water by touching her lips and then if any other pers... | 2015/01/09 | [
"https://ell.stackexchange.com/questions/46215",
"https://ell.stackexchange.com",
"https://ell.stackexchange.com/users/12300/"
] | As a native speaker, I wonder: is the problem with the water, or with the bottle?
That said, a few expressions come to mind. The first one is the most direct:
>
> You might not want to drink from that bottle; **Ann already had her mouth on it**.
>
>
>
The second is more of a euphemism than a scientific fact:
>... | If you want to embarrass your daughter (as a mild punishment for drinking directly out of the bottle), you could say something (to the other person who wants what is in the bottle) like:
>
> Oooh, gross! Ann just drank out of that bottle!
>
>
> |
9,861,733 | I have two threads communicating via DatagramSockets. I would now like a third thread to be able to listen to the communication. After reading [Broadcasting to Multiple Recipients](http://docs.oracle.com/javase/tutorial/networking/datagrams/broadcasting.html) it seems that two MulticastSockets on the third thread is wh... | 2012/03/25 | [
"https://Stackoverflow.com/questions/9861733",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/879896/"
] | With the help of some of the answers and comments here I have solved it by doing the following.
I changed the 2 original threads to use Multicast sockets to communicate, and the third thread now has 2 Mulitcast sockets bound to these ports so it can listen to the communication. Probably not the most beautiful solutio... | Well, your getting the exception because you cannot bind multiple sockets to the same port. If you want to support both point to point and multicast then you will need to designate different ports for each. Otherwise if you are always doing multicast broadcast then you can just drop the regular datagram sockets altoget... |
9,861,733 | I have two threads communicating via DatagramSockets. I would now like a third thread to be able to listen to the communication. After reading [Broadcasting to Multiple Recipients](http://docs.oracle.com/javase/tutorial/networking/datagrams/broadcasting.html) it seems that two MulticastSockets on the third thread is wh... | 2012/03/25 | [
"https://Stackoverflow.com/questions/9861733",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/879896/"
] | With the help of some of the answers and comments here I have solved it by doing the following.
I changed the 2 original threads to use Multicast sockets to communicate, and the third thread now has 2 Mulitcast sockets bound to these ports so it can listen to the communication. Probably not the most beautiful solutio... | You have two threads in the same program communicating via socket? How about creating a [queue](http://docs.oracle.com/javase/6/docs/api/java/util/concurrent/LinkedBlockingQueue.html) for them so it is just in process communication? |
48,287,725 | I'm wondering if there's a easy way to handle this question: find one pattern from the right-hand side of a string, and then replace the right side of it.
For example:
```
PATTERN='bin'
REPLACE_TO='dev/zero'
STRING='/bin/bash/bin/test/test1.txt'
```
We found the last index of PATTERN in STRING is 2, and then replace... | 2018/01/16 | [
"https://Stackoverflow.com/questions/48287725",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3514137/"
] | You can do:
```
PATTERN='bin'
REPLACE_TO='dev/zero'
STRING='/bin/bash/bin/test/test1.txt'
echo "${STRING%$PATTERN*}$REPLACE_TO"
/bin/bash/dev/zero
```
`${STRING%$PATTERN*}` will remove right hand side of `$STRING` that starts with `$PATTERN`. | With sed:
```
#!/bin/bash
PATTERN='bin'
REPLACE_TO='dev/zero'
STRING='/bin/bash/bin/test/test1.txt'
#Escape PATTERN and REPLACE_TO
PATTERN=$(sed -e 's/[][\/&*?+.^${}]/\\&/g' <<< "$PATTERN")
REPLACE_TO=$(sed -e 's/[][\/&*?+.^${}]/\\&/g' <<< "$REPLACE_TO")
sed -r "s/(.*)$PATTERN.*/\1$REPLACE_TO/" <<< "$STRING"
```
I... |
30,575,950 | Has anyone succeeded in using Protractor to detect an ionicPopup alert?
I've tried all the workarounds suggested [here](https://github.com/angular/protractor/issues/1486) but no luck.
I need Protractor to detect the alert and check the text in the alert. | 2015/06/01 | [
"https://Stackoverflow.com/questions/30575950",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1659476/"
] | I've tested Ionic popups successfully by setting the popup variable as follows:
```
var popup = element(by.css('.popup-container.popup-showing.active'));
```
And in the test:
```
expect(popup.isDisplayed()).toBeTruthy();
``` | Ionic Popups are just made of DOM elements, so you should be able to use normal locators to find/test them. Because they're not made of alerts, the workarounds in the issue you linked to are probably not useful. |
30,575,950 | Has anyone succeeded in using Protractor to detect an ionicPopup alert?
I've tried all the workarounds suggested [here](https://github.com/angular/protractor/issues/1486) but no luck.
I need Protractor to detect the alert and check the text in the alert. | 2015/06/01 | [
"https://Stackoverflow.com/questions/30575950",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1659476/"
] | Here's the class I wrote to test that the popup exists and to ensure the text is correct in the header and body:
```
var TestUtilities = function(){
this.popup = element(by.css('.popup-container.popup-showing.active'));
//Tests to see if $ionicPopup.alert exists
this.popupShouldExist = function() {
... | Ionic Popups are just made of DOM elements, so you should be able to use normal locators to find/test them. Because they're not made of alerts, the workarounds in the issue you linked to are probably not useful. |
30,575,950 | Has anyone succeeded in using Protractor to detect an ionicPopup alert?
I've tried all the workarounds suggested [here](https://github.com/angular/protractor/issues/1486) but no luck.
I need Protractor to detect the alert and check the text in the alert. | 2015/06/01 | [
"https://Stackoverflow.com/questions/30575950",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1659476/"
] | I've tested Ionic popups successfully by setting the popup variable as follows:
```
var popup = element(by.css('.popup-container.popup-showing.active'));
```
And in the test:
```
expect(popup.isDisplayed()).toBeTruthy();
``` | I got it - I saw a lot of issues out there trying to do it in very complex ways, but in the end I tried this and it turns out to be this simple.
Inspect your element and find its ng-repeat value, then
`var button = element(by.repeater('button in buttons')).getText()`
You also need to have the browser sit out someho... |
30,575,950 | Has anyone succeeded in using Protractor to detect an ionicPopup alert?
I've tried all the workarounds suggested [here](https://github.com/angular/protractor/issues/1486) but no luck.
I need Protractor to detect the alert and check the text in the alert. | 2015/06/01 | [
"https://Stackoverflow.com/questions/30575950",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1659476/"
] | Here's the class I wrote to test that the popup exists and to ensure the text is correct in the header and body:
```
var TestUtilities = function(){
this.popup = element(by.css('.popup-container.popup-showing.active'));
//Tests to see if $ionicPopup.alert exists
this.popupShouldExist = function() {
... | I got it - I saw a lot of issues out there trying to do it in very complex ways, but in the end I tried this and it turns out to be this simple.
Inspect your element and find its ng-repeat value, then
`var button = element(by.repeater('button in buttons')).getText()`
You also need to have the browser sit out someho... |
30,575,950 | Has anyone succeeded in using Protractor to detect an ionicPopup alert?
I've tried all the workarounds suggested [here](https://github.com/angular/protractor/issues/1486) but no luck.
I need Protractor to detect the alert and check the text in the alert. | 2015/06/01 | [
"https://Stackoverflow.com/questions/30575950",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1659476/"
] | Here's the class I wrote to test that the popup exists and to ensure the text is correct in the header and body:
```
var TestUtilities = function(){
this.popup = element(by.css('.popup-container.popup-showing.active'));
//Tests to see if $ionicPopup.alert exists
this.popupShouldExist = function() {
... | I've tested Ionic popups successfully by setting the popup variable as follows:
```
var popup = element(by.css('.popup-container.popup-showing.active'));
```
And in the test:
```
expect(popup.isDisplayed()).toBeTruthy();
``` |
187,421 | I am using a List Control to display a representation of elements within a vector. When the list is clicked on another control shows information about that element. The index of the element is currently determined by its index in the control, however if I wish to sort or filter the results this will no longer work.
I ... | 2008/10/09 | [
"https://Stackoverflow.com/questions/187421",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18664/"
] | Frankly - tying data (the position in your data vector) to the presentation of the data in the list control (the position in the list ctrl) is something I would stay away from.
In MFC each control has a "Data" DWORD member variable - when coding in MFC I Always called "SetItemData" for each item added and passed in a ... | To use a virtual list control, set the LVS\_OWNERDATA style. You then need to handle the LVN\_GETDISPINFO notification message (which is sent via WM\_NOTIFY).
If you do this, you are entirely responsible for the data, including the order in which it is shown. Therefore it is up to you to handle sorting and so forth.
... |
187,421 | I am using a List Control to display a representation of elements within a vector. When the list is clicked on another control shows information about that element. The index of the element is currently determined by its index in the control, however if I wish to sort or filter the results this will no longer work.
I ... | 2008/10/09 | [
"https://Stackoverflow.com/questions/187421",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18664/"
] | Frankly - tying data (the position in your data vector) to the presentation of the data in the list control (the position in the list ctrl) is something I would stay away from.
In MFC each control has a "Data" DWORD member variable - when coding in MFC I Always called "SetItemData" for each item added and passed in a ... | It really depends on the performance you require.
I have personally seen MAJOR increases in performance for lists holding **massive amount** of data. However it is **much more work** to implement, thus for simple uses with not so many data I recommend staying away from it.
Basically, what happens with virtual list c... |
187,421 | I am using a List Control to display a representation of elements within a vector. When the list is clicked on another control shows information about that element. The index of the element is currently determined by its index in the control, however if I wish to sort or filter the results this will no longer work.
I ... | 2008/10/09 | [
"https://Stackoverflow.com/questions/187421",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18664/"
] | Frankly - tying data (the position in your data vector) to the presentation of the data in the list control (the position in the list ctrl) is something I would stay away from.
In MFC each control has a "Data" DWORD member variable - when coding in MFC I Always called "SetItemData" for each item added and passed in a ... | The purpose of virtual list controls is totally different: You should use it for performance reason when you have A LOT of items in your list (I'd say 2500+).
In your case, all you need is to store the vector index in the list item data as NotJarvis explains. |
28,010,152 | I want to return an integer from "total\_recods"(query type) on this method getDataCount().How to get total\_recods as an integer?
I edit my code but it return 0 while I have some data in my database.
```
@Override
public int getDataCount() {
// TODO Auto-generated method stub
Query query=null;
... | 2015/01/18 | [
"https://Stackoverflow.com/questions/28010152",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3617417/"
] | You discarded the result. This is how you should do it:
```
query= em.createNativeQuery("SELECT count(*) FROM Data");
int count = ((Number) query.getSingleResult()).intValue();
```
Noticed that I used `Number`, because some database return `Long` while other return a `BigDecimal`. | You may write `query.getParameter("total_recods",Integer.class);`
For more details read this <http://docs.oracle.com/javaee/6/api/javax/persistence/Query.html#getParameter%28java.lang.String,%20java.lang.Class%29> |
28,010,152 | I want to return an integer from "total\_recods"(query type) on this method getDataCount().How to get total\_recods as an integer?
I edit my code but it return 0 while I have some data in my database.
```
@Override
public int getDataCount() {
// TODO Auto-generated method stub
Query query=null;
... | 2015/01/18 | [
"https://Stackoverflow.com/questions/28010152",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3617417/"
] | You discarded the result. This is how you should do it:
```
query= em.createNativeQuery("SELECT count(*) FROM Data");
int count = ((Number) query.getSingleResult()).intValue();
```
Noticed that I used `Number`, because some database return `Long` while other return a `BigDecimal`. | The query does NOT have a PARAMETER called *total\_recods*. It is a NATIVE query that has NO parameters. JPQL can have (named) PARAMETERS. This is SQL, and that uses NUMBERED PARAMETERS ONLY (and your SQL doesn't have any).
If you meant to get the result of the query then look at the `query.getSingleResult` return va... |
6,914,138 | I have a select list that contains a number of options. The user can select multiple options and 'assign' them to another select list. The problem I am having is how can I check to make sure one or more of the selected options are not part of the list being copied to? I understand I can use the following code to determ... | 2011/08/02 | [
"https://Stackoverflow.com/questions/6914138",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/874876/"
] | I have figured it out now. Here's what happen. Everytime I input the '**supplier ID**', it will call my ajax and check my supplier table (only under that ID) if the fruits is granted or not. If i see a fruit that is **granted**, it will loop all the checkboxes I have and check the **fruitsID** if it exist. If found, th... | While creating the markup for these checkboxes you can add a selected="selected attribute in the input tag for those items where Granted == "Y". You dont have to do this through jquery on page load. |
6,914,138 | I have a select list that contains a number of options. The user can select multiple options and 'assign' them to another select list. The problem I am having is how can I check to make sure one or more of the selected options are not part of the list being copied to? I understand I can use the following code to determ... | 2011/08/02 | [
"https://Stackoverflow.com/questions/6914138",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/874876/"
] | I have figured it out now. Here's what happen. Everytime I input the '**supplier ID**', it will call my ajax and check my supplier table (only under that ID) if the fruits is granted or not. If i see a fruit that is **granted**, it will loop all the checkboxes I have and check the **fruitsID** if it exist. If found, th... | ```
IF Granted="Y"
<input checked="checked" />
```
just add **checked="checked"** wherever you want the checkbox to be checked by default. |
6,914,138 | I have a select list that contains a number of options. The user can select multiple options and 'assign' them to another select list. The problem I am having is how can I check to make sure one or more of the selected options are not part of the list being copied to? I understand I can use the following code to determ... | 2011/08/02 | [
"https://Stackoverflow.com/questions/6914138",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/874876/"
] | I have figured it out now. Here's what happen. Everytime I input the '**supplier ID**', it will call my ajax and check my supplier table (only under that ID) if the fruits is granted or not. If i see a fruit that is **granted**, it will loop all the checkboxes I have and check the **fruitsID** if it exist. If found, th... | You could try this (not tested) -
```
$.each(results, function() {
if (this.Granted === 'Y') $('input:checkbox[id=' + this.fruit_name + ']').attr('checked',true);
});
``` |
6,914,138 | I have a select list that contains a number of options. The user can select multiple options and 'assign' them to another select list. The problem I am having is how can I check to make sure one or more of the selected options are not part of the list being copied to? I understand I can use the following code to determ... | 2011/08/02 | [
"https://Stackoverflow.com/questions/6914138",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/874876/"
] | I have figured it out now. Here's what happen. Everytime I input the '**supplier ID**', it will call my ajax and check my supplier table (only under that ID) if the fruits is granted or not. If i see a fruit that is **granted**, it will loop all the checkboxes I have and check the **fruitsID** if it exist. If found, th... | You will need to scan your table and check the box for each found row.
```
$('#table tr').each(function() {
var name = $(this).find('td.eq(2)').text();
var granted = $(this).find('td.eq(3)').text();
var chk = $('#fCheck #'+name); //$('#fCheck input[value="'+name+'"]');
if (granded.toLowerCase() == 'y') {... |
30,432 | The [quantity theory of money](https://en.wikipedia.org/wiki/Quantity_theory_of_money) states the price level is proportional to the amount of money in circulation. That is, if the quantity of money increases by some factor $k$, the price level will increase by the same factor $k$. My question is simple: in which econo... | 2019/08/07 | [
"https://economics.stackexchange.com/questions/30432",
"https://economics.stackexchange.com",
"https://economics.stackexchange.com/users/-1/"
] | In the chapter 4 of the graduate textbook [Lectures on Macroeconomics](https://rads.stackoverflow.com/amzn/click/com/0262022834) there is *"The Overlapping Generation with Money"*. In that case we have a model which is microfounded (i.e. accounts for how our consumers interact with money on the microeconomic level). T... | Well, I'm not sure the claim "raise M by factor k and P will also rise by factor k" is valid unless one also stipulates that V and Y are held fixed. Indeed, interest rate policy relies on the assumption that movements in key interest rates will shift Y more than they do P, with some of that action arising from a shift ... |
435,088 | Нужна ли запятая перед союзом "пока"?
*Пожалуйста, обратите внимание на то, что данное приглашение действительно(,) пока есть свободные места.* | 2017/11/03 | [
"https://rus.stackexchange.com/questions/435088",
"https://rus.stackexchange.com",
"https://rus.stackexchange.com/users/178695/"
] | Запятая нужна, т. к. это союз. | Пока — наречие, выражающее обстоятельство времени. Разве "пока" — это союз? |
435,088 | Нужна ли запятая перед союзом "пока"?
*Пожалуйста, обратите внимание на то, что данное приглашение действительно(,) пока есть свободные места.* | 2017/11/03 | [
"https://rus.stackexchange.com/questions/435088",
"https://rus.stackexchange.com",
"https://rus.stackexchange.com/users/178695/"
] | **Данное приглашение действительно, пока есть свободные места.**
Это сложноподчинённое предложение, "есть свободные места" - придаточное, "пока" - подчинительный союз. Придаточные предложения отделяются от главного запятыми.
Примеры.
Литература существует, п. она понятна. Сердце любит до тех пор, п. не истратит св... | Запятая нужна, т. к. это союз. |
435,088 | Нужна ли запятая перед союзом "пока"?
*Пожалуйста, обратите внимание на то, что данное приглашение действительно(,) пока есть свободные места.* | 2017/11/03 | [
"https://rus.stackexchange.com/questions/435088",
"https://rus.stackexchange.com",
"https://rus.stackexchange.com/users/178695/"
] | **Данное приглашение действительно, пока есть свободные места.**
Это сложноподчинённое предложение, "есть свободные места" - придаточное, "пока" - подчинительный союз. Придаточные предложения отделяются от главного запятыми.
Примеры.
Литература существует, п. она понятна. Сердце любит до тех пор, п. не истратит св... | Пока — наречие, выражающее обстоятельство времени. Разве "пока" — это союз? |
18,012,532 | I have a JavaEE project with several entities with the following `persistence.xml` file:
```
...
<properties>
<!-- Scan for annotated classes -->
<property name="hibernate.archive.autodetection" value="class"/>
...
```
And it seems to work. The project is then deployed as a JAR to two different projects. In ... | 2013/08/02 | [
"https://Stackoverflow.com/questions/18012532",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | If I read you correctly, in the case where it does not work, the entities are in a *different* JAR than the persistence.xml that's used, right?
I think you're correct that's the problem. You need to tell Hibernate which JAR(s) to scan using the **jar-file** element.
See the explanation and examples in the Hibernate d... | I think Hibernate only scans for JPA Entities inside jar files, and not in classes/ folders for example, or it only scans in the jar with the persistence.xml, or something like that. Instead of trying to bend the Hibernate scanner, I felt it would be easier to scan for entities myself. It is a lot easier than I anticip... |
18,012,532 | I have a JavaEE project with several entities with the following `persistence.xml` file:
```
...
<properties>
<!-- Scan for annotated classes -->
<property name="hibernate.archive.autodetection" value="class"/>
...
```
And it seems to work. The project is then deployed as a JAR to two different projects. In ... | 2013/08/02 | [
"https://Stackoverflow.com/questions/18012532",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | If I read you correctly, in the case where it does not work, the entities are in a *different* JAR than the persistence.xml that's used, right?
I think you're correct that's the problem. You need to tell Hibernate which JAR(s) to scan using the **jar-file** element.
See the explanation and examples in the Hibernate d... | Using the empty element `<jar-file></jar-file>` works e.g. with WildFly 8.2.1.Final (Hibernate 4.3.7.Final) :) as mentioned [here](https://stackoverflow.com/a/25908447/1915920).
(`<property name="hibernate.archive.autodetection" value="class, hbm" />` did not work)
(but it did not work outside of WildFly for Eclipse-r... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.