qid int64 10 74.7M | question stringlengths 15 26.2k | date stringlengths 10 10 | metadata list | response_j stringlengths 27 28.1k | response_k stringlengths 23 26.8k |
|---|---|---|---|---|---|
27,091,781 | I want to bind datalist from code behind in asp.net
i am taking product id's from a list and selecting all products on their bases
Following is my code:
```
List<string> r_items_grid = (List<string>)Session["recent_items"];
for(int i=0; i < r_items_grid.Count; i++)
{
OleDbCommand cmd_r_items= new OleDbCommand(... | 2014/11/23 | [
"https://Stackoverflow.com/questions/27091781",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2842311/"
] | If I am not wrong you are trying put string list in a session. When you traversing the whole list each and every time you bind the datalist (DataList3) with a new string based on list index value. So it shows always the last string value of the list. If you want to fetch all data according your list, you might use this... | **There is No Need to For Loop**
You can use comma separated List
```
string commaSepara = String.Join(",", r_items_grid);
OleDbParameters commaSepara=new OleDbParameters("@commaSepara",SqlDbType.NVarchar,-1);
commaSepara.Value=commaSepara;
OleDbCommand cmd_r_items= new OleDbCommand(@"SELECT product_id,product_name... |
27,510,037 | How should we measure the execution time of a function in the OCaml toplevel? | 2014/12/16 | [
"https://Stackoverflow.com/questions/27510037",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3195698/"
] | As @user3075773 says, you can use `Sys.time`. However note that it returns processor time (CPU time). More often I want to know the wall clock time (elapsed time). You can get this from `Unix.gettimeofday`:
```
let time f x =
let t = Unix.gettimeofday () in
let fx = f x in
Printf.printf "execution elapsed ... | Using `gettimeofday` like the accepted answer suggests is not a good idea as it is sensitive to calendar time operating system adjustements (e.g. via `ntp`).
If you just want CPU time then using `Sys.time` is fine. If you want wall-clock time, then a monotonic time source should be used. One is available for OCaml in... |
42,879,594 | [sar man page](https://linux.die.net/man/1/sar) says that one can specify the resolution in seconds for its output.
However, I am not able to get a second level resolution by the following command.
```
sar -i 1 -f /var/log/sa/sa18
11:00:01 AM CPU %user %nice %system %iowait %steal %idle
11:1... | 2017/03/18 | [
"https://Stackoverflow.com/questions/42879594",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2250246/"
] | I think the exist sar report file 'sa18' collected with an interval 10 mins. So we don't get the output in seconds.
Please check the /etc/cron.d/sysstat file.
```
[root@testserver ~]# cat /etc/cron.d/sysstat
#run system activity accounting tool every 10 minutes
*/10 * * * * root /usr/lib64/sa/sa1 1 1
#generate a da... | The /var/log/sa directory has all of the information already.
The sar command serves here as a parser, and reads all data in the sa file.
So you can use `sar -f /var/log/sa/<sa file>` to see first-level results, and use other flags, like '-r', for other results.
```
# sar -f /var/log/sa/sa02
12:00:01 CPU %user %... |
48,943,510 | Here's my code:
```
class LoginUserResponse : Codable {
var result: String = ""
var data: LoginUserResponseData?
var mess: [String] = []
}
public class LoginUserResponseData : Codable {
var userId = "0"
var name = ""
}
```
Now, calling the server API I'm parsing response like this (using Stuff l... | 2018/02/23 | [
"https://Stackoverflow.com/questions/48943510",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1264375/"
] | This is what your implementation of `init(from: Decoder)` should look like.
**Note:** You should consider changing `LoginUserResponse` from a class to a struct, since all it does is store values.
```
struct LoginUserResponse: Codable {
var result: String
var data: LoginUserResponseData?
var mess: [String... | First time I was facing this, normally backend would send nil but I was receiving empty data.
Just make the data inside User data optional and it will work out of the box.
Looks like tedious to be unwrapping when needed, but if you have your API Layer, and your Business Model Layer which you would build from your API ... |
37,115 | I'm looking at solving systems with the FEM discretization
$$
-\int\_\Omega (\Delta u) v = \int\_\Omega \nabla u \cdot \nabla v - \int\_\Gamma (n\cdot\nabla u) v.
$$
*without* applying Dirichlet- or Neumann-type boundary conditions. The resulting matrix is generally not self-adjoint (except in for 1D meshes).
The kern... | 2021/03/28 | [
"https://scicomp.stackexchange.com/questions/37115",
"https://scicomp.stackexchange.com",
"https://scicomp.stackexchange.com/users/3980/"
] | As others have pointed out, (algebraic) multigrid can actually be a good preconditioner in this scenario. Below is a proof-of-concept implementation with [scikit-fem](https://github.com/kinnala/scikit-fem) and [pyamg](https://github.com/pyamg/pyamg/). It shows that pyamg's preconditioner makes the number of GMRES itera... | Here is at least an idea, whether it works is a different question.
Let's say you sort unknowns so that you have the ones in the interior of the domain first, and then all those at the boundary. Then the matrix that corresponds to your problem decomposes in the following way:
$$
A =
\begin{pmatrix}
A^{\circ\circ} ... |
160,068 | Clam found this file named "kworker34" in the /tmp directory on my Ubuntu linux machine. I promptly deleted this file. Also found a shell file, kws.sh in there. Looks like it is connecting to 2 IP addresses - one in Russia and one in Ukraine.
Anyone seen this?
This is the content of kwa.sh -
```
#!/bin/sh
ps -fe|... | 2017/05/21 | [
"https://security.stackexchange.com/questions/160068",
"https://security.stackexchange.com",
"https://security.stackexchange.com/users/148968/"
] | Yes, recently there was discovered some Jenkins vulnerability which allows to execute some code on the outdated Jenkins instance, usually mining Monero cryptocurrency programs.
Check these links for more information:
<http://jenkins-ci.361315.n4.nabble.com/cryptonight-exploit-td4898258.html>
<https://twitter.com/jen... | I found out that the process runs with my jenkins build server user credentials, so that could be one way of infection. |
20,434,514 | I am trying to make the tooltip load an image based on an attribute from the element, however there are multiple elements with different images so I am attempting to load the image based on an attribute.
**HTML:**
```
<a class="item" href="#" title="" image="images/1.png">image 1.</a>
</br>
<a class="item" href="#" ... | 2013/12/06 | [
"https://Stackoverflow.com/questions/20434514",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1380520/"
] | ```
$(".item" ).each(function() {
$(this).tooltip({ content:'<img src="'+this.getAttribute('image')+'" />' });
});
```
Using a data attribute, as in data-image, would be more appropriate, and more valid
```
<a class="item" href="#" title="" data-image="images/1.png">image 1.</a>
```
and then
```
$(".item" ).... | ***[JSFIDDLE DEMO](http://jsfiddle.net/vvVwD/328/)***
```
$(".item").tooltip({
content: function () {
return $(this).attr('image');
}
});
```
If you need an image, just wrap the return value with image tags like below.
```
return '<img src="' + $(this).attr("image") + '">';
``` |
72,740 | >
> This is a sister question to: [Is it bad to use Unicode characters in variable names?](https://softwareengineering.stackexchange.com/questions/16010/is-it-bad-to-use-unicode-characters-in-variable-names)
>
>
>
As is my wont, I'm working on a language project. The thought came to me that allowing multi-token id... | 2011/05/01 | [
"https://softwareengineering.stackexchange.com/questions/72740",
"https://softwareengineering.stackexchange.com",
"https://softwareengineering.stackexchange.com/users/2107/"
] | I once worked with USL which allowed a space as part of a name. The combinatorial possibilities became a nightmare. Is "LAST LEFT TURN" one identifier? Or two ("LAST LEFT" and "TURN") or two identifiers ("LAST" and "LEFT TURN") or three? And is "RIGHT TURN" (one blank) the same as "RIGHT TURN" (two blanks) even though ... | I'm not sure about spaces but it must be possible. I do think it means you have to give up on spaces in other places, and that's a decision you should weigh. In curly-style languages spaces are usually only necessary for separating keywords from identifier and separating types from identifiers (int x, new Y).
Hmm. Wh... |
28,076,109 | I'm new to learning how to program. And I'm wondering what the best way is to handle the problem where you got a double if statement, with both having the same Else result.
Take for instance the following double if statement.
```
if (isset($x)) {
$y = doSomething($x);
if ($y == "something") {
do resul... | 2015/01/21 | [
"https://Stackoverflow.com/questions/28076109",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3881236/"
] | ```
if (isset($x) && doSomething($x) == 'something') {
// do result A;
}
else {
// do result B;
}
```
Important: `doSomething($x)` will only be calculated if `isset($x)` evaluates to true. Otherwise, checking the condition is aborted directly and the else-branch will be executed. So you don't have to worry ab... | Thank you for your help all.
I found the following to be the easiest and most clear way to solve this. Now result B is only written once instead of multiple times. Especially if result B gets long, this keeps it easy to read.
```
$failure = false;
if (isset($x)) {
$y = doSomething($x);
if ($y == "something")... |
5,147,460 | I'm following the [ASP.NET MVC Tutorial](http://www.asp.net/mvc/tutorials/mvc-music-store-part-3) and having started in VB.NET I'm having trouble converting the following razor code:

I have got
```
<ul>
@For Each g As MvcApplication1.Genre In M... | 2011/02/28 | [
"https://Stackoverflow.com/questions/5147460",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/436028/"
] | Put an @ before the `li`:
```
<ul>
@For Each g As MvcApplication1.Genre In Model
@<li>@g.Name</li>
Next
</ul>
```
I would recommend you the [following article](http://www.asp.net/webmatrix/tutorials/asp-net-web-pages-visual-basic). | Try using the text tag, which will tell razor views that the following is normal html markup, they are not actually rendered:
```
<ul>
@For Each g As MvcApplication1.Genre In Model
<text><li> @g.Name </li></text>
Next
</ul>
``` |
17,285,537 | I have a folder "model" with files named like:
```
a_EmployeeData
a_TableData
b_TestData
b_TestModel
```
I basically need to drop the underscore and make them:
```
aEmployeeData
aTableData
bTestData
bTestModel
```
Is there away in the Unix Command Line to do so? | 2013/06/24 | [
"https://Stackoverflow.com/questions/17285537",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1057413/"
] | ```
for f in model/* ; do mv "$f" `echo "$f" | sed 's/_//g'` ; done
```
Edit: modified a few things thanks to suggestions by others, but I'm afraid my code is still bad for strange filenames. | In zsh:
```
autoload zmv # in ~/.zshrc
cd model && zmv '(**/)(*)' '$1${2//_}'
``` |
859,760 | So, say an object that is 10 feet tall is 100 feet away. If I hold up a ruler 3 feet away, then the object in the distance would correspond to about how many inches?
Tried using this guy: <http://www.1728.org/angsize.htm>
to calculate the angle, which ends up being 5.7248 degrees
Then, if I solve for size using 5.724... | 2014/07/08 | [
"https://math.stackexchange.com/questions/859760",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/162229/"
] | Thanks to the [intercept theorem](https://en.wikipedia.org/wiki/Intercept_theorem) this is indeed a simple ratio:
$$\frac{x}{3\,\text{feet}}=\frac{10\,\text{feet}}{100\,\text{feet}}
\qquad\implies\qquad x=0.3\,\text{feet}$$
If you want to also involve the angles, you have
\begin{align\*}
2\tan\frac\alpha2=\frac{10\,... | It seems to me that x/3 =10/100 shows that x= 0.3 right so far, but .3 of a foot is 3.6 inches not 4.8 right? So that may account for the difference in perceived size at 100' and 50'. Thanks |
45,958,566 | I am getting output from a database. Sometimes I am getting 2 div and sometimes I am getting 3 div so I have to set the equal width of the div. I mean if there are 2 div then set 50% of each and if there are 3 div then set 33.33% of each. Would you help me in this?
```css
#container1
{
width: 100%;
displ... | 2017/08/30 | [
"https://Stackoverflow.com/questions/45958566",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6928258/"
] | Use `flex: 1 100%` and remove the width:
```css
#container1
{
width: 100%;
display: inline-flex;
}
#container1 div{
color: #fff;
display: inline-block;
height: 100%;
flex: 1 100%;
background: #24252A;
text-align: center;
cursor: default;
padding: 2em 0;
}
... | Just Use `flex-grow: 1;` in child element. check updated snippet below
```css
#container1
{
width: 100%;
display: flex;
}
#container1 div{
color: #fff;
display: inline-block;
height: 100%;
background: #24252A;
text-align: center;
cursor: default;
padding: 2em 0;
... |
265,146 | I'm sure this is a stupid question but I can't find the answer.
iPhones have roughly a 6-7 Watt Hour battery according to multiple sources online.
They can also use a 5W or 10W charger (1Amp x 5V - or 2A x 5V) for charging - which I have observed that they reliably draw for the first few hours of charging (then of co... | 2016/10/23 | [
"https://electronics.stackexchange.com/questions/265146",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/68498/"
] | There are at least three things you are not considering:
- As Turbo pointed out in a comment, the phone is using some power while the battery is being charged. Not all the power from the charger goes to charging the battery.
- Batteries aren't 100% efficient. More energy needs to be put into them when charging than w... | Ballpark efficiency fort Li-ion batteries are according to wikipedia 80-90% <https://en.wikipedia.org/wiki/Lithium-ion_battery#cite_note-PHEV1-4>
You might be interested in testing charge time with phone turned off, or in power save mode. WiFi and blue-tooth tend to consume a lot of power.
Cables do vary a lot, desig... |
37,659,066 | I'm trying to just click 'North America' and 'US', at the following URL:
<http://www.nike.com/language_tunnel>
Here are the steps I have were working for a few weeks, but now seem to not work.
```
# choose country/region
driver.find_element_by_xpath("(//button[@type='button'])[2]").click()
wait.until(EC.visibility_of... | 2016/06/06 | [
"https://Stackoverflow.com/questions/37659066",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6397668/"
] | As you can see, locating the element by index in this case is not quite reliable. Things like the order of elements tend to change frequently. Instead, use the `data-region` attribute, for instance:
```
driver.find_element_by_css_selector("button[data-region=n-america]").click()
``` | If you might want to change the country name tomorrow, you can use the following snippet :
```
countryToSearch = "North America" // you can change this accordingly, rest should work fine
for countries in driver.find_elements_by_xpath("(//button[@type='button'])"):
countryName = countries.text
if countryName ... |
210,990 | In *Avengers: Infinity War*...
>
> Doctor Strange peers into the future and finds the only one where they win, then gives up the Time Stone.
>
>
>
In *Avengers: Endgame*...
>
> Bruce tries to get the Time Stone from The Ancient One, but she refuses, until Bruce mentions that Strange gave up the Time Stone wil... | 2019/04/27 | [
"https://scifi.stackexchange.com/questions/210990",
"https://scifi.stackexchange.com",
"https://scifi.stackexchange.com/users/1755/"
] | She can
=======
In *Doctor Strange* The Ancient One comments that she looks into the future.
>
> **The Ancient One:** I've spent so many years peering through time, looking at this exact moment. But I can't see past it. I've prevented countless terrible futures and after each one there's always another, and they all... | **She can, but only to a point.**
In *Doctor Strange*, she says
>
> I've spent so many years peering through time, looking at this exact moment. But I can't see past it.
>
>
>
The "it" in question is
>
> the moment of her death.
>
>
>
Doctor Strange gave up the Time Stone quite some time after the "it".
... |
3,560,652 | ```
<table>
<tr style="background:#CCCCCC">
<td>
<input id="Radio1" name="G1M" value="1" type="radio" /><br />
<input id="Radio2" name="G1M" value="2" type="radio" /><br />
<input id="Radio3" name="G1M" value="3"... | 2010/08/24 | [
"https://Stackoverflow.com/questions/3560652",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/558594/"
] | Maybe you should use more columns to your table, and more rows as well. And you should be using something else (like CSS instead), but don't get me started on that.
```
<table>
<tr>
<td><input id="Radio1" name="G1M" value="1" type="radio" /></td>
<td><input id="Radio5" name="G1L" value="1" type="ra... | Put them in separate `<tr>`s. |
31,274,329 | My website is serving a lot of pictures from `/assets/photos/` folder. How can I get a list of the files in that folder with Javascript? | 2015/07/07 | [
"https://Stackoverflow.com/questions/31274329",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1279844/"
] | The current code will give a list of all files in a folder, assuming it's on the server side you want to list all files:
```
var fs = require('fs');
var files = fs.readdirSync('/assets/photos/');
``` | As others' answers suggest it seems impossible on client side, so I solved it on server side as following:
Client side by js
```js
get_file(conf.data_address).then(imgs => { // get_file is wrapper of fetch API
let img = new Image();
img.src = `./files/Blackpink/${imgs[0]}`; // e.g. load the first img
img.... |
13,672,588 | I am trying to loop through letters rather than numbers.
I am trying to do this using chr and the number equivalent but it doesn't seem to be happening!
I want four letter loop.
So AAAA, AAAB, AAAC etc through to ZZZZ - and yes I know this will likely take a while to execute! | 2012/12/02 | [
"https://Stackoverflow.com/questions/13672588",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/887515/"
] | Why don't you make an array of letters and then use nested loops:
```
$letters = range('A', 'Z');
foreach ($letters as $one) {
foreach ($letters as $two) {
foreach ($letters as $three) {
foreach ($letters as $four) {
echo "$one$two$three$four";
}
}
}
}
``` | Another way to solve this
```
$i = 'AAAA';
do {
echo $i . "\n";
$i++;
} while( $i !== 'AAAAA');
``` |
119,824 | I have a question that is slighly related to [this question](https://meta.stackexchange.com/questions/64419/what-processes-made-stack-overflow-the-website-it-is-today), but rather looks into the future and the specifics of Stack Exchange. I wonder:
**Where are the processes of Stack Exchange that shape the rules here ... | 2012/01/21 | [
"https://meta.stackexchange.com/questions/119824",
"https://meta.stackexchange.com",
"https://meta.stackexchange.com/users/159748/"
] | **The Official StackExchange Process™** \*
1. User asks question, reports a bug, or makes a feature request here.
2. Said bug report/feature request either
a. Gets downvoted mercilessly because it's been beaten to death here already, or
b. Gets wildly upvoted because it's the best idea ever.
3. Feature/bug request g... | **Required reading**
On Stack Overflow:
* [About](https://stackoverflow.com/about)
* [Frequently Asked Questions](https://stackoverflow.com/faq)
* [How to Ask](https://stackoverflow.com/questions/how-to-ask)
* [How to Answer](https://stackoverflow.com/questions/how-to-answer)
* [Privileges](https://stackoverflow.com/... |
9,615,845 | I would like to find all occurrences of a substring in a NSString, and iterate one by one to do some changes to that NSString. How should I do it? | 2012/03/08 | [
"https://Stackoverflow.com/questions/9615845",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1097480/"
] | If you want to do changes, you could use:
`- (NSString *)stringByReplacingOccurrencesOfString:(NSString *)target withString:(NSString *)replacement`
but if that doesn't fit your needs try this:
`- (void)enumerateSubstringsInRange:(NSRange)range options:(NSStringEnumerationOptions)opts usingBlock:(void (^)(NSString *... | You might want to have a look on [NSString class Documentation](https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/Reference/NSString.html).
**Finding Characters and Substrings**
```
– rangeOfCharacterFromSet:
– rangeOfCharacterFromSet:options:
– rangeOfCharacterF... |
37,734,021 | I am using the below code to loop through each row however I only want to loop through visible cells in Column B (as I have filtered out the values I want to ignore) ranging from Row 10 -194. Does anyone know how I would do this?
```
For X = 192 to 10 Step -1
If Range("B" & X).Text = "" Then **This needs to change... | 2016/06/09 | [
"https://Stackoverflow.com/questions/37734021",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4915723/"
] | You need a second loop to iterate through the [Range.Areas](https://msdn.microsoft.com/en-us/library/office/ff196243.aspx) of [Range.SpecialCells(](https://msdn.microsoft.com/en-us/library/office/ff196157.aspx)[xlCellTypeVisible](https://msdn.microsoft.com/en-us/library/office/ff836534.aspx)). Each Area could be one or... | ```
Dim hiddenColumn: hiddenColumn = "B"
For i = 1 To 10
If Range(hiddenColumn & i).EntireRow.Hidden = False Then
'logic goes here....
End If
Next
``` |
182,371 | I am trying to override following file
>
> module-bundle/view/adminhtml/layout/sales\_order\_creditmemo\_new.xml
>
>
>
```
<?xml version="1.0"?>
<!--
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xs... | 2017/07/06 | [
"https://magento.stackexchange.com/questions/182371",
"https://magento.stackexchange.com",
"https://magento.stackexchange.com/users/44817/"
] | You can use `setChild()` to replace a block by its alias. First create the new block with a name, then call `setChild()` via `<action>`:
```
<referenceBlock name="order_items">
<block class="Vendor\App\Block\Adminhtml\Sales\Order\Items\Renderer" name="custom_renderer" template="Vendor_App::sales/creditmemo/create/... | Please check my answer here: <https://magento.stackexchange.com/a/239387/14403>
I believe that is the same solution you are looking for. |
28,700,110 | I'm working on a project, in Node.js, express module, jade files, MongoDB-Mongoose and more..
I've a problem to implement json details from the database to the jade page.
I tried to figure out the problem, unsuccessfully.
I would like someone to help me find and fix it.
Thanks.
**That's the Error message:**
```
Type... | 2015/02/24 | [
"https://Stackoverflow.com/questions/28700110",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4601770/"
] | I found the problem,
The jade is rendered on server while i tried to get details to the jade from the JS on client side.
I fixed it by render the details directly from the server because it's more suitable my needs but there's another option, send just an empty template jade to client and insert details to html by JS.... | Don't know Jade, but the problem seems to come from the data.
It seems *projects* is undefined so the parser cannot read it (I guess it tries to get its length before looping through its children, and an error is thrown).
So the first thing to do would be to check the data you receive from the database. |
3,767,128 | In my page, I'm using a javascript function
```
<script>
function redirect(){
window.location="hurray.php";
}
</script>
```
Calling the function from the line below.
```
<input id="search_box" name="textbox" type="text" size="50" maxlength="100" onkeypress="redirect()" />
```
Now I want to make it sure that... | 2010/09/22 | [
"https://Stackoverflow.com/questions/3767128",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/383393/"
] | Make an AJAX call to a PHP function that will set a variable in the session. When the AJAX call returns response redirect the user to this page and check for the session variable. You can delete it if you do not want the user to be able to visit it again for this session. | You cannot do this using javascript alone, I don't think.
You need to intercept this on the server and handle it accordingly.
Your probably going to need a token to be sent along with the redirect, you can then validate this token server side and allow the redirect to complete or do some other action if the user has ... |
21,135,302 | My goal is to autosave a form after is valid and update it with timeout.
I set up like:
```
(function(window, angular, undefined) {
'use strict';
angular.module('nodblog.api.article', ['restangular'])
.config(function (RestangularProvider) {
RestangularProvider.setBaseUrl('/api');
... | 2014/01/15 | [
"https://Stackoverflow.com/questions/21135302",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/356380/"
] | Looking at the code I can see is that the $watch will not be re-fired if current input is valid and the user changes anything that is valid too. This is because watch functions are only executed if the value has changed.
You should also check the dirty state of the form and reset it when the form data has been persiste... | Here's a variation of Null's directive, created because I started seeing "Infinite $digest Loop" errors. (I suspect something changed in Angular where cancelling/creating a $timeout() now triggers a digest.)
This variation uses a proper $watch expression - watching for the form to be dirty and valid - and then calls $... |
45,005,034 | I want to split string on every third space. For example :
```
var str = 'Lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor incididunt';
//result will be:
var result = ["Lorem ipsum dolor ", "sit amet consectetur ", "adipiscing elit sed ", "do eiusmod tempor ", "incididunt"];
```
Please he... | 2017/07/10 | [
"https://Stackoverflow.com/questions/45005034",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8009175/"
] | Use regex for splitting the string.
```js
var str = 'Lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor incididunt';
var splited = str.match(/\b[\w']+(?:[^\w\n]+[\w']+){0,2}\b/g);
console.log(splited);
```
**Regex description:**
```none
1. \b assert position at a word boundary (^\w|\w$|\... | ```js
var str = 'Lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor incididunt';
var splitString = str.match(/(.*?\s){3}/g);
console.log(splitString);
``` |
36,935,614 | ```
var obj = [{
id: 1,
child:[2,4],
data : "hello"
},{
id: 2,
child:[3],
data : "I m second"
},
{
id: 3,
child:[],
data : "I m third"
},
{
id: 4,
child:[6],
data : "I m fourth"
},{
id: 5,
child:[],
data : "I m fifth"
},{
id: 6,
child:[],
data :... | 2016/04/29 | [
"https://Stackoverflow.com/questions/36935614",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4353531/"
] | No, it's not possible using the HTML `title` attribute only.
If you want to add an image in a tooltip you would need to use a third party tooltip library which generates HTML tooltips, such as [Qtip2](http://qtip2.com/) | If I understood correctly, you are looking for a way to include **favicon** in your page, the image that lays on the left side of the page title in web browsers?
You can add favicon easily and I assume you'd be able to change it with jQuery as well (the source of the image at least).
Simply put this in between your `... |
5,046,897 | I'd like to add a message to be displayed in Visual Studio 2010 test results.
I can post a message out if the test fails, but not true. Is there anyway to do this?
For example:
```
dim quoteNumber as string = Sales.CreateQuote(foo)
assert.IsTrue(quoteNumber <> "")
'I would like to make this something like this:
as... | 2011/02/18 | [
"https://Stackoverflow.com/questions/5046897",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/544193/"
] | I don't know what unit test framework you're using, but with the Visual Studio unit tests, you can do the following:
```
Assert.IsTrue(quoteNumber <> "", "Quote number must be non-empty")
'I would like to make this something like this:
Console.WriteLine("Quote number " & quoteNumber & " created")
``` | I think you are looking for `Assert.IsFalse`. Maybe
```
Assert.IsFalse(quoteNumber = "", "Quote number " & quoteNumber & " created")
``` |
47,379 | I am trying to send and receive radio signals using my Raspberry, but I am already stuck at the first step :)
My Radio module uses UART for communication but I have failed to set up my serial communication correctly. I found out Bluetooth is somehow interfering, so I disabled it. Now my program is at least able to ste... | 2016/05/15 | [
"https://raspberrypi.stackexchange.com/questions/47379",
"https://raspberrypi.stackexchange.com",
"https://raspberrypi.stackexchange.com/users/42529/"
] | >
> `port='/dev/ttyAMA0'`
>
>
>
I believe the default device node on the Pi 3 is different. Try:
`port='/dev/ttyS0'`
---
You may also need to disable the serial console. The easiest way to do this is via `raspi-config` under **Advanced Options -> Enable/Disable shell and kernel messages on the serial connection... | I don't know how Raspbian Python handles the serial timeout, but if I were coding it, I would still start out putting a delay of at least a couple of milliseconds between the transmit code and the receive code (I'd start with 5 ms). Your receiver can't flag the first received byte until the data has shifted 10 bits com... |
12,680,948 | how can i count elements with the class item which is contained in a variable
so far <http://jsfiddle.net/jGj4B/>
```
var post = '<div/><div class="item"></div><div class="item"></div><div class="item"></div><div class="item"></div>';
alert($(post).find('.item').length); // i have tried .size() in place of .length
... | 2012/10/01 | [
"https://Stackoverflow.com/questions/12680948",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1742280/"
] | You want `filter` instead of `find`:
```
$(post).filter('.item').length
```
`find` looks for descendent element, and there are none.
If you want both top-level items and descendants, you could do this:
```
$(post).find('.item').andSelf().filter(".item").length
```
Though wrapping it in a span as suggested in an... | Best way to do this is to create a DOM object without actually appending it to the DOM. Something like:
```
var post = '<div/><div class="item"></div><div class="item"></div><div class="item"></div><div class="item"></div>';
// Create a dummy element:
var temp = $("<span />");
// Populate the HTML of that element wi... |
422,152 | HAProxy has a very nice status page showing me which webservers are up and which ones are down on the backend. I am trying to debug some issues and need to know which servers nginx thinks are up and which ones it thinks are down. Is there a web page or something that you can configure for nginx so I can just hit a url ... | 2012/08/28 | [
"https://serverfault.com/questions/422152",
"https://serverfault.com",
"https://serverfault.com/users/97353/"
] | Unfortunately this is almost impossible out of the box. vanila nginx has not global state for upstream by design so this information is local for every worker process.
Take a look at this module seems may be useful for you <http://wiki.nginx.org/NginxHttpHealthcheckModule> | A year late to this reply but ustats module for nginx looks pretty impressive:
<https://code.google.com/p/ustats/>
moved to github <https://github.com/0xc0dec/ustats>
Unfortunately doesn't seem maintained after 1.2 but might still work.
Found a maintained fork <https://github.com/nginx-modules/ngx_ustats_module>
1... |
1,654,217 | When we define a probability distribution function, we say:
$f\_X(x)=P(X=x)$ and thats equal to some function such as a gaussian
But isn't $P(X=x)=0$ for a continuous random variable $X$.
Is it correct that the height of the pdf function at a specific x represents the likelihood of this $x$. | 2016/02/14 | [
"https://math.stackexchange.com/questions/1654217",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/182585/"
] | Putting probablyme's answer in words, similar to yours:
The height of the pdf function at a specific $x$ is proportional to the probability of being in the neighbourhood of that $x$.
The main difference being "in the neighbourhood of $x$", instead of "at $x$". Also "proportional", not "the value"
A remark: in Englis... | What you are confusing is discrete and continuous case. We do not define densities in that way when we are talking about continuous random variables. Actually, we say that $X$ is continuous random variable if there is $f$ such that $$P(a\leq X\leq b) = \int\_a^b f(x)\, dx$$ Directly from that definition we do get your ... |
6,162,994 | I'm running a server and a client. i'm testing my program on my computer.
this is the funcion in the server that sends data to the client:
```
int sendToClient(int fd, string msg) {
cout << "sending to client " << fd << " " << msg <<endl;
int len = msg.size()+1;
cout << "10\n";
/* send msg size */
... | 2011/05/28 | [
"https://Stackoverflow.com/questions/6162994",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/419889/"
] | You're getting SIGPIPE because of a "feature" in Unix that raises SIGPIPE when trying to send on a socket that the remote peer has closed. Since you don't handle the signal, the default signal-handler is called, and it aborts/crashes your program.
To get the behavior your want (i.e. make send() return with an error, i... | If you are on Linux, try to run the server inside `strace`. This will write lots of useful data to a log file.
```
strace -f -o strace.out ./server
```
Then have a look at the end of the log file. Maybe it's obvious what the program did and when it crashed, maybe not. In the latter case: Post the last lines here. |
23,423,326 | Looking at the ActiveRecord has\_one and has\_many relations in Rails, this is probably a general (and very likely obvious) question.
If I have two tables, say Husbands and Wives, and it is a monogamous all married couples database, then each husband has a wife, and each wife has a husband. So it would make sense to t... | 2014/05/02 | [
"https://Stackoverflow.com/questions/23423326",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1143539/"
] | It depends.
If:
1. you are only interested in the couples,
2. individual people don't hold any data,
3. everyone HAS a spouse,
then, yes, using a single table might make sense.
However, if any of the above is false, you will want to use individual records.
You should declare the associations like this:
```
class ... | I learned from the answers, but most of them took my example of couples too literally. It was meant just an example. The question was about any A has\_one B, B has\_one A relationship.
sevenseacat's third comment "A relationship between entities is just that - a relationship" really gave me the idea about the second p... |
13,687,223 | I'm trying to create a function within a namespace that will get me a new object instance.
I get syntax error trying to do the following:
```
var namespace = {
a : function(param){
this.something = param;
},
a.prototype.hi = function(){
alert('hi');
},
b : function(){
var ... | 2012/12/03 | [
"https://Stackoverflow.com/questions/13687223",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/428704/"
] | >
> I don't want to declare the namespace first.
>
>
>
You can do weird things like this:
```
var namespace = {
init: function() {
a.prototype.whatever = function(){};
},
a: function(x) {
this.x = x;
}
}
namespace.init();
var myA = new namespace.a("x");
```
But why not try the... | I do not exactly know what you want, but this works:
```
var namespace = {
a: function() {
function a() {
}
a.prototype.hi = function() {
console.log("hi");
}
return new a;
}
}
var obj = new namespace.a();
obj.hi()
// -> 'hi'
``` |
6,720,485 | i'm developing a PHP web application and the main focus of the app is security. Until now i've stored the authentication data into 2 cookies:
* one cookie for a unique hash string (30 chars)
* one cookie for a unique id (the primary key of the mysql database table which holds the cookie info and user id)
Db tables lo... | 2011/07/16 | [
"https://Stackoverflow.com/questions/6720485",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/785990/"
] | You have 3 idioms:
1/ I don't care if my child process dies:
```
spawn(...)
```
2/ I want to crash if my child process crashes:
```
spawn_link(...)
```
3/ I want to receive a message if my child process terminates (normally or not):
```
process_flag(trap_exit, true),
spawn_link(...)
```
Please see this exampl... | In Erlang, processes can be *linked* together. These links are bi-directional. Whenever a process dies, it sends an *exit signal* to all linked processes. Each of these processes will have the *trapexit flag* enabled or disabled. If the flag is disabled (default), the linked process will crash as soon as it gets the ex... |
34,797,955 | I want to implement pull to refresh effect but on `UITableView` bottom using `UIRefreshControl` ?
Any ideas? | 2016/01/14 | [
"https://Stackoverflow.com/questions/34797955",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5010426/"
] | Just try this
```
<div name="description" ....>
<pre>
.....
here your content
.....
</pre>
</div>
```
if not work let me know | Take a look at HTML Purifier. Pretty good at cleaning up dirty input.
[http://htmlpurifier.org/](http://htmlpurifier.org) |
3,720 | I use the [Mist](https://github.com/ethereum/mist) wallet.
I would like to know:
* How I can get the private key of my account.
* How I can use this private key to sign messages. | 2016/05/08 | [
"https://ethereum.stackexchange.com/questions/3720",
"https://ethereum.stackexchange.com",
"https://ethereum.stackexchange.com/users/1400/"
] | I'm assuming your mist client runs a geth node in background.
>
> Export of unencrypted key is not supported on purpose after deliberating the risk to end users. [#1054](https://github.com/ethereum/go-ethereum/issues/1054#issuecomment-107398095)
>
>
>
Unfortunately it seems not to be possible to extract the unen... | You could also use the [wallet functionality](https://ethtools.com/mainnet/wallet/load/) on EthTools.com.
This tool loads details about your address from your keyfile and displays them in an easily consumable manner.
***The load wallet screen***
[](https:/... |
74,537,251 | I'm trying to implement a function that will count how many 'n' of rooks can there be in a chess board of 'n' size without colliding in a position that can be attacked by another rook.
I have used as a base a 4\*4 grid. I'm struggling with the concept to create the array and how to proceed with the recursion (it has to... | 2022/11/22 | [
"https://Stackoverflow.com/questions/74537251",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19153279/"
] | In one sense, this is an extremely trivial problem, because we can see the answer at a glance. On an `n x n` board, when we place a Rook anywhere, we have blocked the placement of any other Rook on that row or that column, reducing the problem to `(n - 1) x (n - 1)`, and trivially we can note that therefore on an `n x ... | This part of recursively
```
while (n > 1) {
// update solution var?
solutions += n * recursively(n -1);
}
```
Is either never going to do anything or will never escape the loop, because if n is greater than 1 you are not changing it in the function. |
15,903,798 | ```
BETWEEN CAST(GETDATE() AS DATE) AND DATEADD(WEEK, 4, CAST(GETDATE() AS DATE))
```
This is how you do it in mssql. How can I do it using dynamic linq (or whatever it's called - like not C#, but strings).
I'll appreciate any help. | 2013/04/09 | [
"https://Stackoverflow.com/questions/15903798",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1999756/"
] | ```
var qryResult = (from tbl in dbcontext.Yourtable
where tbl.CheckDate >= DateTime.Today
&& tbl.CheckDate <= System.Globalization.CultureInfo.InvariantCulture.Calendar.AddWeeks(DateTime.Today, 4) )
select tbl
).ToList();
``` | If you just need to know how to compare date in C# then:
Create an extension:
```
public static DateTime AddWeeks(this DateTime date, int weeks)
{
return date.AddDays(7*weeks);
}
```
And so in Linq:
```
var now = DateTime.Now;
whatever.Where(d => now.AddWeeks(-4) < d && d < now)
``` |
18,463,213 | That works on displaying the items from database in the listbox but i need that if i select a value in the listbox it displays information about that person back to the textboxes. Thats the thing that i can't get to work.
```
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Dat... | 2013/08/27 | [
"https://Stackoverflow.com/questions/18463213",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2721172/"
] | Description
===========
This expression will:
* require the string to start with a `-` character
* allows the `#` to appear at most 1 time in the string
* prevents a space from appearing in the string
* allows one or more of `a-z0-9` characters
* allows the `#` character to appear anywhere in the string, including th... | what you can do is call `'your line'.match(/#/g).length` in you method and if the length is greater than 1 you can exclude those results. after that perform your match if this condition satisfies, by chaining. |
10,668,539 | I have a crawler which crawls a site for a specific value, this value is not directly located inside of a class div but of course has a parent div with is specified by a class.
this value is located in the 3rd div of the parent div (if you look below you will see what i mean).
**code**
```
if($page->find('div.mbcCont... | 2012/05/19 | [
"https://Stackoverflow.com/questions/10668539",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1131217/"
] | This is correct, as long as you have drawables in all 4 density buckets you are covered. A common practice is to make a custom drawable in /res/drawable which refers your density spanning drawables.
For example, you may want a button with different states for pressed and unpressed. First, you would include a drawable... | If your resource is added for all the four densities, then you're correct that you don't *have* to add the drawable to the folder `/res/drawable`. However, you've guessed correctly that it is best to have something in the default folder in the case if a new qualifier appears. Therefore, I recommend to place mdpi resour... |
70,886,039 | I've been trying to modify the `Stream_Autocomplete` cache file in Outlook (deleting all autocomplete with a certain domain), but I can't figure out how `:/`...
1. First my plan was to get the cache file from `RoamCache` folder, decode it, rewrite it without the users I don't want, and then save it where it was before... | 2022/01/27 | [
"https://Stackoverflow.com/questions/70886039",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18031675/"
] | This is because every time you call the method, `currentJobIndex = 0;` is executed again, so you do not go to the next position in the array, but always write to `jobs[0]`. `currentJobIndex` needs to be a global variable, like this:
```java
public class Job(){
private int[] jobs = new int[5]; // Specify length of a... | This is because currentJobIndex doesn't increment when you add a new job.
You can fix this by adding:
```
public static void addJob() { currentJobIndex = 0;
jobs[currentJobIndex] = new Job();
jobs[currentJobIndex].getInformation();
jobs[currentJobIndex].calculateCost();
jobs[currentJobIndex].display(... |
45,321,050 | I have a pattern string with a wild card say X (E.g.: abc\*).
Also I have a set of strings which I have to match against the given pattern.
E.g.:
abf - false
abc\_fgh - true
abcgafa - true
fgabcafa - false
I tried using regex for the same, it didn't work.
Here is my code
```
String pattern = "abc*";
String st... | 2017/07/26 | [
"https://Stackoverflow.com/questions/45321050",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1180711/"
] | Just use bash style pattern to Java style pattern converter:
```
public static void main(String[] args) {
String patternString = createRegexFromGlob("abc*");
List<String> list = Arrays.asList("abf", "abc_fgh", "abcgafa", "fgabcafa");
list.forEach(it -> System.out.println(it.matches(patternStr... | you can use stringVariable.startsWith("abc") |
18,350,353 | I was using the function below to create a heatmap from a matrix of 48 columns X 32 rows:
```
heatmap.2(all.data,Rowv = FALSE, Colv = FALSE, trace="none",main="All data",col=colorRampPalette(c("green","yellow","red")))
```
It was giving me some warnings because of the removal of the dendograms, but still it gave me ... | 2013/08/21 | [
"https://Stackoverflow.com/questions/18350353",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2702364/"
] | If your plot has been working in the past and is now throwing the `invalid graphics state` error, try resetting the graphics device by calling `dev.off()`. This was suggested by RStudio's help site. | Figured it out, it was just a mistake with the display, if I automatically save the plot instead of asking RStudio to show it to me is, the graph is ok |
12,016,321 | I have some css and html that I am trying to modify, to make it so a div expands horizontally into a scollable div, but all I get is "stacking" once the width is reached.
[fiddle](http://jsfiddle.net/cWpGS/46/)
The absolute positioning is pretty important in the document structure, so I will need to keep most of the... | 2012/08/18 | [
"https://Stackoverflow.com/questions/12016321",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/872034/"
] | add `white-space:nowrap;` in "mli" class
fiddle <http://jsfiddle.net/cWpGS/51/> | If I understand you correctly, the text is extending fully into the container. Your problem was that the container only extended to the end of its parent div, which had a very small width assigned. Changing the width of the container div makes the text not wrap as much:
[**jsFiddle**](http://jsfiddle.net/Snowsickle/cW... |
14,639,280 | I am building a web application that will generate charts and graphs using a 3rd party charting component. This charting component requires it receive an XML file containing the design parameters and data in order to render the chart. The application may render up to 10 to 20 charts per page view. I am looking for sugg... | 2013/02/01 | [
"https://Stackoverflow.com/questions/14639280",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1867791/"
] | Thanks for your suggestions everyone.
I created a test application that ran x number of trials for each of the suggested methods to see which performed best. As it turns out, building the XML string directly using StringBuilder was orders of magnitude faster, unsurprisingly.
Involving an XmlDocument in any way grea... | I am pretty sure you can tell the compiler to bundle those XML files inside your CLR exe. Reading from these would not imply a noticeable performance hit as they would be already in memory. You will need to research a bit as i cant get the code out of my head right now, too sleepy.
EDIT.
<http://msdn.microsoft.com/en... |
87,182 | [Shannon's entropy](http://en.wikipedia.org/wiki/Entropy_%28information_theory%29) is the negative of the sum of the probabilities of each outcome multiplied by the logarithm of probabilities for each outcome. What purpose does the logarithm serve in this equation?
An intuitive or visual answer (as opposed to a deeply... | 2014/02/19 | [
"https://stats.stackexchange.com/questions/87182",
"https://stats.stackexchange.com",
"https://stats.stackexchange.com/users/10598/"
] | Shannon entropy is a quantity satisfying a set of relations.
In short, logarithm is to make it growing linearly with system size and "behaving like information".
The first means that entropy of tossing a coin $n$ times is $n$ times entropy of tossing a coin once:
$$
- \sum\_{i=1}^{2^n} \frac{1}{2^n} \log\left(\tfrac... | Here's an off-the-cuff explanation. You could say 2 books of the same size have twice as much information as 1 book, right? (Considering a book to be a string of bits.) Well, if a certain outcome has probability P, then you could say its information content is about the number of bits you need to write out 1/P. (e.g. i... |
67,037,406 | I have code below which transposes column values from one particular workbook (Activeworkbook - columns O,AH and I) over to another workbook ("loader file.xls" - columns A,B,C). It works perfectly for my needs
```
Sub PullTrackerInfo()
'Pull info from respective column into correct column on loader file
Dim wb_mth As... | 2021/04/10 | [
"https://Stackoverflow.com/questions/67037406",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14314515/"
] | I was getting the same error and I could solved it with the last two steps of the following (make sure you have covered all of them):
1. Add SHA1 in the firebase project
2. Add SHA-256 in the firebase project
3. Enable Phone option in Sign-in method under Firebase Authentication
4. Make sure to download and add the la... | Adding up to @fred answer, be sure the SHA-1 and SHA-256 signatures are added to the console, but be sure which signatures you are adding, beacuse if it is a release version, you should get the SHA's from Developer Console, remember Google signs your app with a key stored on google servers.
Additional to this, I had t... |
1,011,460 | I've been having this problem for months, and for a while I was ignoring it.
It all started when I wanted to share my HP Deskjet 1050, connected to my desktop via usb, over my network to use on laptops, etc. I followed the usual procedure of going to devices and printers and preparing to share it, but to my surprise i... | 2015/12/10 | [
"https://superuser.com/questions/1011460",
"https://superuser.com",
"https://superuser.com/users/267245/"
] | Some people reported display port cables causing issues so I changed my display port cable and my problem seems to be fixed.
**OLD CABLE (gave problems):**
I was using this cable which had decent reviews on Amazon:
Cable Matters Gold Plated DisplayPort to DisplayPort Cable 10 Feet - 4K Resolution Ready
[http://www.a... | For my situation, following worked
1. Remove HDMI cable connected to monitor from computer's HDMI port.
2. Wait 5 seconds till display is shown on laptop main screen (not sure how this will work for desktop).
3. Reconnect the HDMI cable disconnected in step 1.
4. Maximum resolution is correctly shown.
Unfortunately t... |
40,124,051 | This is my code:
```
<?php
$date_db = "2017-10-12 12:00:00";
setlocale(LC_ALL, "de_DE.UTF-8");
$date_db = strtotime($date_db);
$date_db = strftime("%e. %B %Y, %A, %k:%M Uhr", $date_db);
$date_db = str_replace(":00","",$date_db);
echo $date_db;
?>
```
The output is: `12. Oktober 2017, Donnerstag, 12 Uhr`
This i... | 2016/10/19 | [
"https://Stackoverflow.com/questions/40124051",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | ```
$date_db = "2017-10-12 10:00:00";
setlocale(LC_ALL, "de_DE.UTF-8");
$date_db = strtotime($date_db);
$date_db = strftime("%e. %B %Y, %A, %k:%M Uhr", $date_db);
$date_db = str_replace(":00","",$date_db);
//check if string contains O Uhr then only trim
if(preg_match("/ 0 Uhr/", $date_db)){
$date_db = str_replace(... | ```
<?php
$string = '12. Oktober 2017, Donnerstag, 0 Uhr';
$string = str_replace(", 0 Uhr", "", $string);
echo $string;
``` |
10,835,687 | I've just started teaching myself JavaScript and am doing some basic exercises. Right now I'm trying to make a function that takes in three values and prints out the largest. However, the function refuses to fire upon button click. I tried making a separate, very simple function just for debugging and it refuses to fir... | 2012/05/31 | [
"https://Stackoverflow.com/questions/10835687",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1427033/"
] | ```
v2 = Number(p2):
```
should be
```
v2 = Number(p2);
```
Also, look into the developer tools for whatever browser you are using to find simple syntax errors like this. (In most browsers you can press F12). | Your javascript functions are commented out with `<!-- -->` |
51,102,009 | I am using `loopback` as a backend now I wish to be able to search across all fields in the table
For instance, take the following table fields:
```
id, name, title, created, updated
```
Now say I want to search across the table using the following string "`nomad`"
However, I am unsure how to structure the query
... | 2018/06/29 | [
"https://Stackoverflow.com/questions/51102009",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1647457/"
] | Loopback is not where you need to look at. It's just a framework with universal ORM / ODM to connect to your DB and expose is with a query language over rest. You probably need in your case to add a `text` index in your postgresql database. By indexing all your desired properties into a text index, you'll be able to pe... | You can try using **RegExp** :
```
let searchField = "nomad";
var search = new RegExp(searchField, 'i');
{"where": {"id":search,"name" : search}
```
I have use **Aggregate** in **LookUp** to **Search** .
Example :
```
let searchField = "anyname";
var searchCond = [];
if (searchField) {
... |
67,438 | I've been reading documents, viewing videos, etc. on how to create a Wordpress plugin. I've learned how to filter a post, add txt to a post, use conditionals to see if the page is a single post as not to display text throughout the entire site, etc.
The part that I'm not understanding is how to create a plugin, with i... | 2012/10/07 | [
"https://wordpress.stackexchange.com/questions/67438",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/21190/"
] | If you want a frontend page you'll have to create one with your plugin's shortcode as the content. Then you display your plugin's output in-place of that shortcode:
```
/*
Plugin Name: WPSE67438 Page plugin
*/
class wpse67438_plugin {
const PAGE_TITLE = 'WPSE67438'; //set the page title here.
const SHORTCODE =... | you'll need some plugin options at the very least to allow users to decide how/where your plugin page is accessed. some users may be using `wp_list_pages` to output a menu, others may use a `wp_nav_menu` instance to enable navigation, and in that case they could have multiple menus registered, and then there's the matt... |
38,716,459 | Let's say I have this code:
```
for (int i = 0; i < x.size(); i++) {
auto &in = input[i];
auto &func = functions[i];
auto &out = output[i];
// pseudo-code from here:
unaccessiable(i);
i = func(in); // error, i is not declared
out = func(i); // error, i is not declared
// useful when you... | 2016/08/02 | [
"https://Stackoverflow.com/questions/38716459",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4211034/"
] | Despite the fact the restriction you want to apply to a loop does not make sense, I would rewrite your loop to ensure noone use the counter by mistake:
```
for(int i = 0;;) //whatever guard
{
DoRequiredAction(i);
}
```
Then your `DoRequiredAction` method would not have to modify the loop counter. | Here's another way - rather than use index addressing, use a zip iterator:
This way, after plumbing, the problem may be expressed thus:
```
extern std::vector<int> input;
extern std::vector<int> output;
extern std::vector<int (*)(int)> functions;
void test()
{
for (auto values : zip(input, functions, output))
... |
20,568 | Recently I read a book which described about gradient. It says
$${\rm d}T~=~ \nabla T \cdot {\rm d}{\bf r},$$
and suddenly they concluded that $\nabla T$ is the maximum rate of change of $f(T)$ where $T$ stands for Temperature. I did not understand. How gradient is the maximum rate of change of a function?
Please exp... | 2012/02/05 | [
"https://physics.stackexchange.com/questions/20568",
"https://physics.stackexchange.com",
"https://physics.stackexchange.com/users/7527/"
] | Consider an $n$-dimensional space (two dimension in the picture), and let $f(\vec x)$ be a non-constant scalar function, like a temperature distribution in your case. Let $\vec y(t)$ be any curve in the space such that the function $f(\vec y(t))=c$ is constant along that trajectory (the colored lines).
Now compute the... | Formally, we have the symbolic equation
$$
\nabla T\cdot\mathrm d\mathbf r =
\begin{pmatrix} \frac{\partial T}{\partial x^1} & \cdots & \frac{\partial T}{\partial x^n} \end{pmatrix}
\begin{pmatrix} \mathrm dx^1 \\ \vdots \\ \mathrm dx^n \end{pmatrix} =
\sum\_i \frac{\partial T}{\partial x^i}\mathrm dx^i = \mathrm dT
$$... |
55,900,958 | I develop at php Laravel.
I receiving GuzzleHttp response from Mailgun as Object and can't to get from it the status.
the Object is:
`O:8:"stdClass":2:{s:18:"http_response_body";O:8:"stdClass":2:{s:6:"member";O:8:"stdClass":4:{s:7:"address";s:24:"test_of_json-4@zapara.fr";s:4:"name";s:10:"not filled";s:10:"subscribe... | 2019/04/29 | [
"https://Stackoverflow.com/questions/55900958",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9870932/"
] | To take the response status code you can use the function **getStatusCode** :
```
$response = $client->request();
$statusCode = $response->getStatusCode();
```
while to take the body of response you can use :
```
$contents = $response->getBody()->getContents();
``` | I found that 'mailgun/mailgun' package uses its own HTTP client which also uses 'RestClient' and these classes are return stdObject.
In that Object there is property 'http\_response\_code' containing HTTP response code like 200, 400, 401 etc.
**This property accessible by standard way `$object->property` and it's a s... |
15,253,406 | I'm trying to take the last three chracters of any string and save it as another String variable. I'm having some tough time with my thought process.
```
String word = "onetwotwoone"
int length = word.length();
String new_word = id.getChars(length-3, length, buffer, index);
```
I don't know how to use the getChars m... | 2013/03/06 | [
"https://Stackoverflow.com/questions/15253406",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1193321/"
] | Here is a method I use to get the last xx of a string:
```
public static String takeLast(String value, int count) {
if (value == null || value.trim().length() == 0 || count < 1) {
return "";
}
if (value.length() > count) {
return value.substring(value.length() - count);
} else {
... | This method will return the x amount of characters from the end.
```
public static String lastXChars(String v, int x) {
return v.length() <= x ? v : v.substring(v.length() - x);
}
```
//usage
```
System.out.println(lastXChars("stackoverflow", 4)); // flow
``` |
13,987,211 | I am working on a project on which there is a header which contain login link . There are two header on my project header.php and header1.php. header.php is included on index.php and header1.php is on rest of the page.
When I am going to my site www.example.com which contain header.php and login it show me that I am l... | 2012/12/21 | [
"https://Stackoverflow.com/questions/13987211",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1455354/"
] | This problem may due to the reason below
The same variable name in header and in other files. The variable may be used in header
```
$_SESSION['userid']
```
The variable **$userid** is used in some other files may be. If you find that this issue will clear i think | Simply use `session_start();` at the top of every page using it. |
628,192 | Does anybody know if Python has an equivalent to Java's SortedSet interface?
Heres what I'm looking for: lets say I have an object of type `foo`, and I know how to compare two objects of type `foo` to see whether `foo1` is "greater than" or "less than" `foo2`. I want a way of storing many objects of type `foo` in a li... | 2009/03/09 | [
"https://Stackoverflow.com/questions/628192",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/75857/"
] | If you're looking for an implementation of an efficient container type for Python implemented using something like a balanced search tree (A Red-Black tree for example) then it's not part of the standard library.
I was able to find this, though:
<http://www.brpreiss.com/books/opus7/>
The source code is available her... | Do you have the possibility of using Jython? I just mention it because using TreeMap, TreeSet, etc. is trivial. Also if you're coming from a Java background and you want to head in a Pythonic direction Jython is wonderful for making the transition easier. Though I recognise that use of TreeSet in this case would not be... |
1,392,348 | How, in a .NET, do you search a sorted collection for a key, and get the index, or if it doesn't exist, get the **index of the next highest item**?
For example there is a list that contains elements {1,5,8,10}. I search for 7. It doesn't exist, but the next highest key that does exist is 8 with an index of **2**.
Exa... | 2009/09/08 | [
"https://Stackoverflow.com/questions/1392348",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/165754/"
] | A modified binary search would be the fastest way. A binary search is an O(log n) operation, so it's much faster than looping through all the items to find a match.
```
public int IndexOfKeyOrNext(SortedList<int,int> list, int find) {
int first = 0;
int last = list.Count - 1;
while (first < last) {
int ... | ```
int yourValue = 5;
var item = list.FirstOrDefault(x => x >= yourValue);
if(item != null)
{
var index = list.IndexOf(item);
}
```
This assumes your list is presorted, and that you're able to use Linq. |
1,568,850 | I'm trying to read in a 24 GB XML file in C, but it won't work. I'm printing out the current position using ftell() as I read it in, but once it gets to a big enough number, it goes back to a small number and starts over, never even getting 20% through the file. I assume this is a problem with the range of the variable... | 2009/10/14 | [
"https://Stackoverflow.com/questions/1568850",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/190164/"
] | I don't know of any way to do this in one file, a bit of a hack but if splitting the file up properly isn't a real option, you could write a few functions that temp split the file, one that uses ftell() to move through the file and swaps ftell() to a new file when its reaching the split point, then another that stitche... | Even if the ftell() in the Microsoft C library returns a 32-bit value and thus obviously will return bogus values once you reach 2 GB, just reading the file should still work fine. Or do you need to seek around in the file, too? For that you need \_ftelli64() and \_fseeki64().
Note that unlike some Unix systems, you d... |
63,985,332 | A function in C that I wrote works like this:
```c
int filepath_from_request(obj **context) {
strncpy(*context->request_filepath, *context->request, 1024));
}
```
The `obj` object itself is defined as
```c
typedef struct obj {
int socket;
char request[1024];
char request_filepath[1024];
} obj;
... | 2020/09/21 | [
"https://Stackoverflow.com/questions/63985332",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7214539/"
] | It's just an operator precedence thing. Consider (\*context)->request or context[0]->request, depending on which makes more sense in your situation. | As (\*) has more precedence than (->), program is considering
```
strncpy(*context->request_filepath, *context->request
```
as
```
strncpy(*(context->request_filepath), *context->request
```
And showing a fatal error to you. You can change precedence by applying the bracket as
```
strncpy((*context)->request_fil... |
38,825,369 | I have the following string
```
String path = "(tags:homepage).(tags:project mindshare).(tags:5.5.x).(tags:project 5.x)";
```
I used following code,
```
String delims = "\\.";
String[] tokens = path.split(delims);
int tokenCount = tokens.length;
for (int j = 0; j < tokenCount; j++) {
System.out.println("Split ... | 2016/08/08 | [
"https://Stackoverflow.com/questions/38825369",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/976278/"
] | You can use a *positive lookbehind* to achieve this :
```
String path = "(tags:homepage).(tags:project mindshare).(tags:5.5.x).(tags:project 5.x)";
String newPath = path.replaceAll("(?<=\\))\\.", ""); // look for periods preceeded by `)`
System.out.println(newPath);
```
O/P :
```
(tags:homepage)(tags:project mindsh... | You can do this without using a regular expression, in a clean and simple way, that even supports nested parentheses (for the day you'll need to support them).
What you want to do here is to keep everything that is inside parentheses, so we can just loop over the characters and keep a count of open parentheses. If thi... |
37,961,354 | How can I write my SQL query in Symfony2's query builder?
```
(
SELECT t2.`year_defence`, 'advisor_id' AS col, t2.advisor_id AS val, COUNT(*) AS total
FROM projects t2
GROUP BY t2.`year_defence`, t2.advisor_id
)
UNION
(
SELECT t2.`year_defence`, 'type_id' AS col, t2.type_id AS val, COUNT(*) AS total
FROM projec... | 2016/06/22 | [
"https://Stackoverflow.com/questions/37961354",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6422381/"
] | If you are looking to have login form on front end then there are multiple plugins available out there. Checkout **UserPro** plugin.
Also Free plugin like **'Theme My Login (TML)'** can be used to provide login functionality on front end. These are just examples, there are many others as well.
Let me know if this hel... | **This is very well possible.** You can even do this without any advanced coding skills, but it requires some (very popular) plugins.
Use the 'sidebar login widget' to let people login on any part of your website and use 'login redirect' to send them to a specific private(!) page, based on their role.
I can recomme... |
4,360,847 | Σ from i=1 to n of(n)(n+1)/2
What is the upper limit of computation for a give n? is it O(n^3) O(n^2)?
Example:
```
n=1 , sum =1
n=2 , sum= 1+ 1+2 , sum = 4
n=3, sum= 1+1+2+1+2+3, sum = 10
n=4, sum = 1 + 1+2 + 1+2+3 + 1+2+3+4 = 20
n= 5, sum = 1+ 1+2 +1+2+3 +1+2+3+4 + 1+2+3+4+5 , sum = 35
...
n=10, sum = ..... ,... | 2010/12/05 | [
"https://Stackoverflow.com/questions/4360847",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/505238/"
] | We can approximate `n(n+1)/2` to `n^2`. So our sum is `1^2 + 2^2 + ... + n^2`, and that is `n(n+1)(2n+1)/6`, which can be approximated to `n^3`. So the upper bound is `n^3`. | The exact formula for the sum is `1/6*n*(n+1)*(n+2)`, which is `O(n^3)`. |
1,161,043 | I was asked to modify some existing code to add some additional functionality. I have searched on Google and cannot seem to find the answer. I have something to this effect...
```
%first_hash = gen_first_hash();
%second_hash = gen_second_hash();
do_stuff_with_hashes(%first_hash, %second_hash);
sub do_stuff_with_hashe... | 2009/07/21 | [
"https://Stackoverflow.com/questions/1161043",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | The hashes are being collapsed into flat lists when you pass them into the function. So, when you shift off a value from the function's arguments, you're only getting one value. What you want to do is pass the hashes by reference.
```
do_stuff_with_hashes(\%first_hash, \%second_hash);
```
But then you have to work w... | A bit late but,
As have been stated, you must pass references, not hashes.
```
do_stuff_with_hashes(\%first_hash, \%second_hash);
```
But if you need/want to use your hashes as so, you may dereference them imediatly.
```
sub do_stuff_with_hashes {
my %first_hash = %{shift()};
my %second_hash = %{shift()};
... |
10,098,410 | Look at my code below, I get memory error after I click "back" button, the problem will be fixed if I deleted [aboutView release]
Why is that? and how I should release aboutView?
```
-(IBAction)swichView {
AboutView *aboutView = [[AboutView alloc] init];
[aboutView.view setAlpha:0];
[self.view addSubview:a... | 2012/04/11 | [
"https://Stackoverflow.com/questions/10098410",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/929751/"
] | You wouldn't believe how much overhead a realized lazy seq imposes. I tested this on a 64-bit OS: it's something like 120 bytes. That's pure overhead for every lazy seq member. The vector, on the other hand, has quite a low overhead and is basically the same as a Java array, given a large enough vector. So try replacin... | It's hard to utilize laziness and to encapsulate `with-open` at the same time. Laziness is important in your case, because it makes it possible to have only the "relevant" part of the line or int-vector sequence in memory.
One solution to the problem is don't encapsulate `with-open` and to contain the whole line-proce... |
225,515 | In a book I found these sentences:
1. Solve the assignments using what you have learned.
2. Tom showed up wearing a suit.
I can understand the meaning. But I do not know why *using* and *wearing* are used without a preposition like by or with.
I have learned participles are used as adjectives or nouns. But in the ci... | 2015/02/04 | [
"https://english.stackexchange.com/questions/225515",
"https://english.stackexchange.com",
"https://english.stackexchange.com/users/108529/"
] | ambiguous looks a simple word to describe 'there is no complete description of what "everything" encompasses'. At the same time, 'unreasonable' does not fit here. | It could be a *[Sisyphean](http://www.oxforddictionaries.com/us/definition/american_english/Sisyphean) task*.
>
> (Of a task) such that it can never be completed.
>
>
>
This refers to the Greek myth of [Sisyphus](http://en.wikipedia.org/wiki/Sisyphus), who was punished by the gods by being ordered to to push a bo... |
32,751,130 | Here is what I have mustered up:
```
from graphics import *
from random import *
from math import *
```
class Ball(Circle):
def **init**(self, win\_width, win\_high, point, r, vel1, vel2):
Circle.**init**(self, point, r)
```
self.width = win_width
self.high = win_high
self.vecti1 = vel1
self.vecti... | 2015/09/23 | [
"https://Stackoverflow.com/questions/32751130",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4522468/"
] | I added some names to the df to make it easier and split everything out into separate layers in ggplot to make manipulation easier, imho.
```
library(ggplot2)
x <- seq(0,10,.1)
y <- as.matrix(cbind(rnorm(101,x,1),rep(x,length(x)),rep(1,length(x))))
z <- as.matrix(cbind(rnorm(101,x+3,1),rep(x,length(x)),rep(0,length(x)... | With qplot:
```
qplot(x = data[, 2], y = data[, 1], col = as.factor(data[, 3]),
geom = c("point", "smooth"), method="lm", se = FALSE)
```
[](https://i.stack.imgur.com/0qA9y.jpg)
With ggplot:
```
data_df <- data.frame(y = data[, 1], x = data[... |
56,034,612 | Class definition
```java
@Entity
@Table(name = "t_domain")
public class Domain(){
@Id
String id;
String fieldA;
String fieldB;
String fieldC;
List<String> operations;
}
```
Table definition
```sql
CREATE TABLE `t_domain` (
`id` varchar(38) ,
`fieldA` varchar(255) ,
`fieldB` varchar(255) ,
`fieldC` varch... | 2019/05/08 | [
"https://Stackoverflow.com/questions/56034612",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8223302/"
] | This is what the reduce functions do here
```
var maxVerticalPipCount:CGFloat = 0
for rark in pipsPerRowForRank {
if CGFloat(rark.count) > maxVerticalPipCount {
maxVerticalPipCount = CGFloat(rark.count)
}
}
var maxHorizontalPipCount:CGFloat = 0
for rark in pipsPerRowForRank {
if CGFloat(rark.max() ... | The reduce function loops over every item in a collection, and combines them into one value. Think of it as literally reducing multiple values to one value. [[Source](https://learnappmaking.com/map-reduce-filter-swift-programming/#reduce)]
From [Apple Docs](https://developer.apple.com/documentation/swift/array/2298686... |
24,411 | I'm unclear if this is something that should be done only when a lawn has problems, or as part of normal maintenance every X years? I guess you could even do it every spring but I imagine that's overkill and puts the lawn out of use for a few weeks just as you want to start enjoying it! | 2016/04/30 | [
"https://gardening.stackexchange.com/questions/24411",
"https://gardening.stackexchange.com",
"https://gardening.stackexchange.com/users/14517/"
] | Well it all depends on what kind of lawn you want and the effort you want to put into it. If your ambition is to have Perfect grass: perfectly flat, no weeds, no dead spots then over seed twice a year, every year.
This keeps the turf thick, helps out compete weeds and doesn't take very long to do.
If you don't care ... | You don't overseed the lawn, you let it grow long (say 6 inches), then cut it back drastically (say 3 inches), but not so drastically that it will kill it off (say 1.5 inch), because if you do that the grass can evaporate from the surface a lot quicker than the grass can take it in. It will fill in the gaps that are in... |
32,271,241 | So I installed xampp and tried to start but Apache was giving the usual error of port busy and I changed the port address to 8080 and also the localhost to 8080 in the httpd.conf file.
Now,localhost just shows a blank page,no files I save in the htdocs folder show up.It's just a blank page and nothing happens.Any sugg... | 2015/08/28 | [
"https://Stackoverflow.com/questions/32271241",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4564579/"
] | Try: "localhost:8080" instead of "localhost" in URL area. | I Have Already Face This issue. First Of All Save Your File Like First.php And Then Run .And keep In Mind Do Not Keep File Name Index.php |
11,646,047 | When I debug my project, I get following error:
>
> "Unable to copy file "obj\Debug\My Dream.exe" to "bin\Debug\My Dream.exe". The process cannot access the file 'bin\Debug\My Dream.exe' because it is being used by another process."
>
>
>
Using Process Explorer, I see that MyApplication.exe was out but System pro... | 2012/07/25 | [
"https://Stackoverflow.com/questions/11646047",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1526922/"
] | Worked for me.
Task Manager -> Name of project -> End task. (i had 3 same processes with my project name);
VS 2013; Win 8; | Another kludge, ugh, but it's easy and works for me in VS 2013. Click on the project. In the properties panel should be an entry named Project File with a value
(your project name).vbproj
Change the project name - such as adding an -01 to the end. The original .zip file that was locked is still there, but no longer ... |
11,546,152 | I am trying to use foreach statment to run through a function that preg\_replaces using regular expression. Can someone help, because my method doesn't work..
```
$reg_sent is an array
function reg_sent($i){
$reg_sent = "/[^A-Za-z0-9.,\n\r ]/";
return preg_replace($reg_sent, '', $i);
}
foreach($reg_sent as $key=... | 2012/07/18 | [
"https://Stackoverflow.com/questions/11546152",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | You *can* choose a file to put the output of dumpdata into if you call it from within Python using `call_command`, for example:
```
from django.core.management import call_command
output = open(output_filename,'w') # Point stdout at a file for dumping data to.
call_command('dumpdata','model_name',format='json',indent... | You can dump all database models data by using below code
```py
from django.core.management import call_command
with open("data.json", "w", encoding="utf-8") as fp:
call_command("dumpdata", format="json", indent=2, stdout=fp)
```
This will create a file (`data.json`) in the root of your project folder. |
100,861 | It is well known that one can use $\chi^2$ distribution to estimate the variance of normal distribution (i.e., $N(0,\sigma^2$)).
Is there a particular reason of using $\chi^2$ distribution? Or can we say that it is the "most accurate" way to estimate the variance of a normal distribution? Or does this "most accurate" ... | 2014/06/02 | [
"https://stats.stackexchange.com/questions/100861",
"https://stats.stackexchange.com",
"https://stats.stackexchange.com/users/42701/"
] | Recall the [definition](http://en.wikipedia.org/wiki/Chi-squared_distribution) of the $\chi^2$-distribution with $n$ degress of freedom. If
$X\_i$ are $iid$ standard normal then
$$
Z = \sum\_{i=1}^n X\_i^2
$$
has a $\chi^2$-distribution with $n$ degrees of freedom.
Thus it is natural to apply this distribution for the... | The other responses adequately explain the relationship between the sample variance of a normal distribution and $\chi^2-$distributions.
However, from your latest comment, it seems like you're interested in the strength of the estimator.
To address this, I'll point out two things:
* $\chi^2$-distribution doesn't pr... |
437,278 | Basically we'd want to create a SyncML server that we can hookup to our own custom data source, all the component would do is listen for client connections and notify and request data from our code return the data back to the client. Looking primarily to sync Contact data from our app with various mobile devices. | 2009/01/12 | [
"https://Stackoverflow.com/questions/437278",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23822/"
] | Command-line form:
```
corflags application.exe /32BIT+
``` | If you go to Configuration Manager in Visual Studio you can set the platform to x86 or x64. |
5,236,431 | I have a string `arraylist`. Need to get the index values of all elements if its value equals a specific character.
For eg need to get the index value of element if its value = "."
with `indexOf()` & `lastIndexOf()` i am able to find only the index value of 1st and last occurrence respectively.
```
ArrayList<String>... | 2011/03/08 | [
"https://Stackoverflow.com/questions/5236431",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/646256/"
] | well... you can easily do this linearly with a loop:
```
private int[] getIndexe(String searchFor,List<String> sourceArray) {
List<Integer> intArray = new ArrayList<Integer>();
int index = 0;
for(String val:sourceArray) {
if(val.equals(searchFor)) {
intArray.add(index);
}
index++;
}
return intArray.toA... | Use `String.indexOf( mychar, fromIndex)`.
Iterate starting with fromIndex 0, then use the previous result as your fromIndex until you get a -1. |
29,379,623 | Sorry for what it seems to be a redundant question but i do have many options,
and despite my effort reading dozen of threads, i'm not able to understand what to do.
I do have a java application which job is to :
1. get datas from a SOAP WS (XML),
2. do some logic ( incoming deliverydate will become datebl )
3. Fina... | 2015/03/31 | [
"https://Stackoverflow.com/questions/29379623",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2243607/"
] | I guess you are using Jersey as a JAX-RS implementation. Have you left some details out from the stacktrace? Reading the stacktrace it seems the Jersey receives a String instead of a Date: `Can not construct instance of java.util.Date from String value 'Thu Jul 31 07:00:00 CEST 2014'`. If your class `com.rest.entities.... | Thanks a lot Jim, Jon.
Thomas.
Even if i found a workaround, i will check what you wrote carefully.
Nevertheless,i finally managed to solve this.
As i was not able to understand if problem was on Serialization(JavaApp) i've decided to have a look on the other side Deserialization(REST WS).
**Quick reminder :**
SOA... |
4,567 | I am writing an essay on **project management** within IT and in my introduction I will give a brief description of project management, to being my essay I was looking at using one of these:
>
> 1. Project management is 'A unique set of co-ordinated activities, with definite starting and finishing points, undertaken ... | 2011/12/07 | [
"https://writers.stackexchange.com/questions/4567",
"https://writers.stackexchange.com",
"https://writers.stackexchange.com/users/2972/"
] | Yes, I suppose, especially, the second quote. By the way, you did not attribute the first quote to anyone. | It is a good idea to begin an essay with some interesting quotes or sentences. You have to make your starting sentence attractive to grab the reader's attention. |
53,565,271 | I am currently developing a Twitter content-based recommender system and have a word2vec model pre-trained on 400 million tweets.
How would I go about using those word embeddings to create a document/tweet-level embedding and then get the user embedding based on the tweets they had posted?
I was initially intending ... | 2018/11/30 | [
"https://Stackoverflow.com/questions/53565271",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8111837/"
] | Averaging the vectors of all the words in a short text is one way to get a summary vector for the text. It often works OK as a quick baseline. (And, if all you have, is word-vectors, may be your main option.)
Such a representation might sometimes improve if you did a weighted average based on some other measure of re... | You are on the right track with averaging the word vectors in a tweet to get a "tweet vector" and then averaging the tweet vectors for each user to get a "user vector". Whether these average vectors will be useful or not depends on your learning task. Hard to say if this average method will work or not without trying s... |
379,453 | My MacBook Pro (15-inch, Retina, Mid 2015, fresh install of latest Catalina) freezes randomly. It requires a hard shutdown (power button for > 5 secs) and then it takes a while to turn on. The MacBook had the logic board, display and lid replaced 18 months ago, has only internal graphics and the SSD is still original.
... | 2020/01/10 | [
"https://apple.stackexchange.com/questions/379453",
"https://apple.stackexchange.com",
"https://apple.stackexchange.com/users/358715/"
] | I know this is an old topic but I have been having the same issue and was finally able to find a solution after trying quite a few different things. For me, **turning off Hardware Acceleration within my browser (Chrome) has completely eliminated the freezing.** It had ramped up to happening almost every day, but since ... | I have exact same issue. Keeps happening for two weeks now and I can't pinpoint what is causing it. But if I leave computer for a while It would be frozen when I'm back. Seem you have tried almost everything without success. |
16,898,069 | The input string in textbox is, say, $10.00 . I call
```
decimal result;
var a = decimal.TryParse(text, NumberStyles.AllowCurrencySymbol, cultureInfo, out result);
```
`cultureInfo` is known (`en-US`). Why does `decimal.tryParse` returns false?
Thank you. | 2013/06/03 | [
"https://Stackoverflow.com/questions/16898069",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1175737/"
] | The problem is you've allowed the currency symbol itself, but you've omitted other properties that are required to parse it correctly (decimal point, for example.) What you really want is `NumberStyles.Currency`:
```
decimal.TryParse("$10.00", NumberStyles.Currency, cultureInfo, out result);
``` | Try this, you need to include `NumberStyles.Number` in the bitwise combination of values for the `style` argument:
```
decimal result;
var a = decimal.TryParse(text, NumberStyles.Number | NumberStyles.AllowCurrencySymbol, cultureInfo, out result);
``` |
55,872,178 | Why does this code throw an invalidAssignmentOperator error on the \* and + operators?
```
public static Function<Integer, Double> tariff = t -> {
if (t = 500) {
t * t;
} else {
t + t;
}
};
``` | 2019/04/26 | [
"https://Stackoverflow.com/questions/55872178",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11416969/"
] | There are several issues with your code:
1. Equality check needs `==` : `t=500` should be `t==500`
2. When you have a complex code as lambda, the `return` statement is not implicit: so `t*t` does not return implicitly.
3. By multiplying/adding two integers you're trying to return a `integer` value while your expected ... | Your function is throwing an invalidAssignmentOperator because you are not actually assigning `t*t` or `t+t` to anything. You can try using `t*=t` and `t+=t` so that it will actually assign to `t`
Your method also is not returning anything and it should. An even better solution to my idea above would be to just retur... |
39,930,671 | With `Firebase` database and user object, it's possible to load every information from the database whenever the user navigates through different activities but to save some time it seems more effective for the data to be loaded on the `MainActivity` and put into one object (like `user.setProfile`) and for that object ... | 2016/10/08 | [
"https://Stackoverflow.com/questions/39930671",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6798995/"
] | You should have a try for the Singleton design pattern, and don't forget about the thread safe problem.
Reference: [Singleton pattern](https://en.wikipedia.org/wiki/Singleton_pattern) | I would like to suggest having a `static` object declared in the launching `Activity`. Then you can get the values from all other `Activity` once its populated with the values fetched from Firebase. |
21,852,754 | I am trying to convert given number of minutes into milliseconds.
For eg: 15mins or 20mins or 44mins should be converted to milliseconds programmatically.
I tried the below:
```
Calendar alarmCalendar = Calendar.getInstance();
alarmCalendar.set(Calendar.MINUTE,15);
long alarmTime = alarmCalendar.getTimeInMillis()... | 2014/02/18 | [
"https://Stackoverflow.com/questions/21852754",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1443051/"
] | ```
int minutes = 42;
long millis = minutes * 60 * 1000;
``` | This gives you the time in milli.
```
long currentTime = System.currentTimeMillis()
Handler handler = new Handler();
long waitTime = currentTime + (15*60*1000);
handler.postDelayed(new Runnable() {
public void run() {
// Alert or do something here.
}
}, waitTime);
```
This piece of code slee... |
136,403 | I've been trying to find tutorials to help me understand direction handles in relation to corner points. The screenshot below shows a corner point and direction handle but it is only on one side? I was following a tutorial of tracing this image and in the video I could see two direction handles on this corner point but... | 2020/04/11 | [
"https://graphicdesign.stackexchange.com/questions/136403",
"https://graphicdesign.stackexchange.com",
"https://graphicdesign.stackexchange.com/users/146139/"
] | Do it like this instead.
1. When you get to a corner anchor, click and drag out the curve handle, do not release the mouse click
2. Then, hold down `Alt / Option`
3. Drag to position the second handle in the direction you want to continue, release both the mouse click and `Alt / Option` key, and carry on
4. With the D... | You can get both handles back with the **Anchor point tool** `Shift` +`C`
Just click on the point and drag
This tool can also move each handle independently
[](https://i.stack.imgur.com/xHUuf.gif) |
43,191,252 | I am currently documenting some advanced simulation tools using Doxygen. I would like to be able to refer to equations within the HTML documentation.
To illustrate the problem. Perform the following
```
doxygen -g Doxyfile
sed -i 's/^EXTRA_PACKAGES.*/EXTRA_PACKAGES = amsmath amsfonts/g' Doxyfile
sed -i 's/^LATEX_BATC... | 2017/04/03 | [
"https://Stackoverflow.com/questions/43191252",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2386026/"
] | You seem to be looking for the [`filter` Array method](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter) that returns an array of the matched elements, instead of an boolean value whether some matched. | The easiest way to do it would be this:
```
keyword_array.filter(keyword => searchString.includes(keyword));
```
You can learn more about `filter` [here](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/filter). I highly recommend learning about how to use `map`, `reduce` and `filt... |
10,440,255 | I need to show a big image that was searched by google throu simple\_html\_dom.php
```
include_once( "simple_html_dom.php" );
$key="alexis";
$html = new simple_html_dom();
$html=file_get_html('http://images.google.com/images?as_q='. $key .'&hl=en&imgtbs=z&btnG=Search+Images&as_epq=&as_oq=&as_eq=&... | 2012/05/03 | [
"https://Stackoverflow.com/questions/10440255",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1373752/"
] | You can use multiple classes in CSS (and Sizzle) selectors like .class1.class2. Just search for elements specifically with both classes and test the length:
```
$(document).ready(function() {
$("form#filterForm").submit(function () {
var type = $("select#typeList option:selected").val();
var style ... | Have you looked into the hasClass JQUERY function?
<http://api.jquery.com/hasClass/>
It sounds like that's what you're looking for...If not let me know and I'll try to help further. |
18,269,065 | I need to make a box using css containing arc as shown in image . I want to do this using pure CSS. I am able to make arcs but not able to draw line. Here is my html and css code.
```html
<style type="text/css">
.left_arc{
border-bottom: 1px soli... | 2013/08/16 | [
"https://Stackoverflow.com/questions/18269065",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/930026/"
] | **[LIVE DEMO](http://jsbin.com/apoyak/4/edit)**

Simplify your HTML markup
and create crazy things using the **CSS pseudo `:before` and `:after` selectors**
**HTML**
```
<div class="main_style">
<div class="text">Canada</div>
</div>
<div cla... | You can just create a border with negative radius for only the top corners. See [this post for more info...](https://stackoverflow.com/questions/11033615/inset-border-radius-with-css3) |
15,744,392 | For POST and PUT requests I use the following syntax:
```
put {
entity(as[CaseClass]) { entity =>
returnsOption(entity).map(result => complete{(Created, result)})
.getOrElse(complete{(NotFound, "I couldn't find the parent resource you're modifying")})
}
}
```
Now for GET requests I'm trying to do the... | 2013/04/01 | [
"https://Stackoverflow.com/questions/15744392",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/291244/"
] | Use *[HttpResponse](https://github.com/spray/spray/blob/master/spray-http/src/main/scala/spray/http/HttpMessage.scala#L225)* like this for example
```
complete{
HttpResponse(StatusCodes.OK, HttpBody(ContentType(`text/html`), "test test: " + System.currentTimeMillis.toString))
}
```
**Update:** I've been using Spra... | This code should work:
```
get {
ctx =>
ctx.complete(returnsOption())
}
```
If don't use `ctx =>` at the start, your code might only be executed at route build time.
Here you can find some explanations: [Understanding the DSL Structure](http://spray.io/documentation/spray-routing/advanced-topics/understan... |
39,302,309 | I am struggling with If Else statement in Python 3.5.2 which I recently installed. I am using IDLE to run my code.
Here is my code below [(screenshot)](https://i.stack.imgur.com/jJOVl.png).
[](https://i.stack.imgur.com/jJOVl.png)
I get syntax error a... | 2016/09/03 | [
"https://Stackoverflow.com/questions/39302309",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6789529/"
] | Take the example of #3:
Python is seeing the code as
```
if x==10:
print("X is 10")
else:
```
The indentation on this is clearly messed up. But it looks right to you, because the `>>>` of the prompt is pushing the first line over a few characters, making it look like it is right. But even though it look... | "elif" is a shorter way of saying "else if". if the "if" statement isnt true, "elif" can be used to tell the computer what to do if the conditions are fulfilled |
167,484 | >
> Could you please what the meaning of "**punch to the gut**" is?
>
>
>
The text is here:
>
> Two hours later Dad had blocked off half the kitchen
> with plywood sheets. The owl convalesced there for several weeks. We
> trapped mice to feed it, but sometimes it didn’t eat them, and we couldn’t
> clear away ... | 2018/05/25 | [
"https://ell.stackexchange.com/questions/167484",
"https://ell.stackexchange.com",
"https://ell.stackexchange.com/users/74396/"
] | A *punch to the gut* (or sometimes called *gut-punch* or *emotional gut punch*) is pretty much synonymous with something that is *gut-wrenching*, which is easier to find in dictionaries. [Collins](https://www.collinsdictionary.com/dictionary/english/gut-wrenching) says that **gut-wrenching events or experiences make yo... | It is a figurative use. The effect of the odor was overpowering, having the force of a punch to the abdomen. It "takes your breath away". |
63,021,476 | Hello this is a problem I want to resolve but I am stuck.
Given a list of urls I want to do the following :
1. extract the name within the url
2. match the name found from the url to a dictionary of existing names
3. have 1 dictionary of all the names found, an split the found names into 2 separate dictionaries, 1 as... | 2020/07/21 | [
"https://Stackoverflow.com/questions/63021476",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11849460/"
] | well ... if i got correctly what u want to do ... here is something what should work
```
for link in links_list:
link_split = link.split('/')
name_list = link_split[2].split('-') # makes from chris-brown-xx => chrisbrownxx
name = ""
for part in name:
name + part
for (key, value) in exi... | Do get you started, here are the steps to make this program:
1. Create a `for` to look through each individual url and using the `split('/')` function break every url into a list and search for the 2 value in that list.
2. Then you can use another `for` loop to go through the keys and values of the `existing_names` di... |
61,026,145 | In my Login Page I want to show error message when user enter wrong email and password without refreshing page. I am trying to send data from view to controller using ajax. But in the controller, `user.Email` and `user.Password` are null when I debug, but the Ajax call works. I want to know what is wrong there?
```htm... | 2020/04/04 | [
"https://Stackoverflow.com/questions/61026145",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13127780/"
] | The issue is because of indentation. Try using a reformat of pubspec file and it will work perfectly. | If you using Windows instead of macOS, try to use file path with back slashes. For example `"assets\fonts\Quicksand-Regular.ttf"` instead of `"assets/fonts/Quicksand-Regular.ttf"` |
26,587,644 | I have a fade-in animation on the main container on page load.
It works fine with all browsers expect IE(9).
Is there a way to detect if the user is using a browser incompatible with CSS3 animations and so disable them, so they can view the page?
HTML
----
---
```
<body>
<span id="splash-title">
<img sr... | 2014/10/27 | [
"https://Stackoverflow.com/questions/26587644",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3041557/"
] | You should look into [Modernizr](http://modernizr.com/) which is a feature detection library.
If you go to the download page, choose features you want to detect and then add the script to your site.
This will give you access to the Modernizr object in javascript and also add classes to the HTML tag (if that option is... | Not to be completely antiquated here, but here's how I'd do it if I didn't want to use Modernizr.
There are probably a ton of different ways to do this but...
If I were trying to target a specific version of IE (regardless of CSS3), I would just use IE conditional comments.
For example:
Style the fade-in div with... |
20,888,366 | It's my timer that counts time. Is it possible when the game gets to the new scene automatically insert the previous scene's best time? what code should i insert in the new scene to expose the best time?
```
/**
* TIMER (JAVASCRIPT)
* Copyright (c) gameDev7
*
* This is an HH:MM:SS count down/up timer
* Includes f... | 2014/01/02 | [
"https://Stackoverflow.com/questions/20888366",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3154526/"
] | Paper.js is not designed to support manual resizing of the canvas, since that will blow up the pixels and cause all kind of internal issues. It will also interfere with HiDPI handling on Retina screens.
but you can resize the canvas using:
`paper.view.viewSize = [width, height];`
I hope this helps! | Umm as Mr. Jürg Lehni stated before, Paper.js is not designed to support manual resizing of the canvas. when paper.view.setViewSize() extends/ shrink the canvas to that size.
If you want to scale the things inside the canvas (e.g. path), you had to apply transformation to every item (with right Matrix) using .transfo... |
55,093,101 | For some reason it is never entering this loop, even though wordSave is exactly the same string as cacheList[0].fileName
```
if (fileNameInCache(wordSave) != -1)
{
printf("File found in cache.\n");
n = write(sock, cacheList[fileNameInCache(wordSave)].fileContent, 4096);
return 0;
}
```
Here's the method ... | 2019/03/10 | [
"https://Stackoverflow.com/questions/55093101",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10555027/"
] | You can specify your local truststore in this file: %jmeter\_home%\bin\system.properties
```
javax.net.ssl.trustStore=C:\\Program Files\\Java\\jdk1.8.0_191\\jre\\lib\\security\\cacerts
javax.net.ssl.trustStorePassword=changeit
``` | Go to Options: SSL Manager --> Just Add the SSL Certificate to your Test.
SSL Certificate should be stored at :jmeter/bin/ApacheJMeterTemporaryRootCA
Issue will be Resolved |
878,851 | After having met yet another person confused by indefinite integrals today, I've finally decided to ask the community.
Do you think it makes sense to teach indefinite integrals? My opinion is that only definite integration should be taught since it is the only one that makes formal sense to me. Of course indefinite in... | 2014/07/26 | [
"https://math.stackexchange.com/questions/878851",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/94157/"
] | Is indefinite integration overrated? Yes, in my opinion.
Is indefinite integration necessary? Yes, in my opinion.
You can't be a mathematician (or a physicist, or an engineer) if you can't compute antiderivatives, and therefore we should teach indefinite integration. We can write $I(f)$ instead of $\int f(x)\, dx$, o... | I will echo [Steven Gubkin](https://math.stackexchange.com/users/34287/steven-gubkin)'s comment and say that it is important for calculus students to be able to recognize the notation $\int f(x) dx$ and understand what it means, because of the existing convention of using it.
However, I can also make the observation t... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.