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 |
|---|---|---|---|---|---|
11,898,647 | I'd like to generate alarms on my Java desktop application :
* alarms set with a specific date/time which can be in 5 minutes or 5 months
* I need to be able to create a SWT application when the alarm is triggered
* I need this to be able to work on any OS. The software users will likely have Windows (90% of them), an... | 2012/08/10 | [
"https://Stackoverflow.com/questions/11898647",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/334493/"
] | Of the available options you have listed, IMHO Option 3 is better.
As you are looking only for an external trigger to execute the application, CRON or Scheduled tasks are better solutions than other options you have listed. By this way, you remove a complexity from your application and also your application need not be... | I believe your scenario is correct. Since services are system specific things, IMHO you should not user a generic package to cover them all, but have a specific mechanism for every system. |
29,921,685 | i am using this example <http://jsfiddle.net/MJTkk/2/> in order to find where the cursor is(left or right in my example). i also have two images and i want the second.png to hover over the other smoothly but to hover on the direction of the cursor(follow the cursor).
```
<div class="box" id="box" style="margin:100px ... | 2015/04/28 | [
"https://Stackoverflow.com/questions/29921685",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4394439/"
] | You should remove your `css` code in the `jquery` function completely for `.under_div`
i updated your [FIDDLE](http://jsfiddle.net/9yj8or2z/3/) if this is what you want to achieve.
**EDIT** i updated the fiddle once again. you got to give the over\_div if it's coming from the right (so in the `else` tag in the firs... | I fixed some issues with it: <http://jsfiddle.net/9yj8or2z/2/>
By adding `left: 0;` and `width: 0px;` to CSS, and also adding `overflow:hidden;`, I could fix that the gray box was moving at the beginning wrongly, but still animates.
I hope this is what you were looking for :) |
3,121,657 | That is, do all the subgroups of, say, S6, look sort of like the subgroup generated by the cycles (123) and (45)?
This seems like an overly simplistic characterization of the Abelian subgroups, but I can't think of any counterexamples. | 2019/02/21 | [
"https://math.stackexchange.com/questions/3121657",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/641262/"
] | What you did is fine. And then you use the fact that\begin{align}1-\cos(x)&=1-\left(\cos^2\left(\frac x2\right)-\sin^2\left(\frac x2\right)\right)\\&=2\sin^2\left(\frac x2\right).\end{align} | Please note how $1-cos(x) = \frac{1}{2} sin^2(\frac{x}{2})$ and $\frac{1}{1-cos(x)} = \frac{1}{2sin^2(\frac{x}{2})}=\frac{csc^2(\frac{x}{2})}{2}$. |
17,117,759 | I want to check if a variable of type guid exist. I used
```
new Db().JobCreate.Any(a => a.GuidVariable1.Equals(GuidVariable2, StringComparison.OrdinalIgnoreCase));
```
but I get the error `Member 'object.Equals(object, object)' cannot be accessed with an instance reference; qualify it with a type name instead`
How... | 2013/06/14 | [
"https://Stackoverflow.com/questions/17117759",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/807223/"
] | I'm assuming you have another instance variable named `GuidVariable2`.
Unless there's something else involved I'd just do the following:
```
new Db().JobCreate.Any(a => a.GuidVariable1 == GuidVariable2);
```
If the variables are actually `string`s I'd do the following:
```
new Db().JobCreate.Any(a => a.GuidVariable... | Here you go:
```
new Db().JobCreate.Any(a => string.Equals(
a.GuidVariable1, GuidVariable2, StringComparison.OrdinalIgnoreCase));
```
(this is of course assuming your so-called GUIDs are actually strings, if you want to compare GUIDs just do this:)
```
new Db().JobCreate.Any(a => a.GuidVariable1.Equals(GuidVari... |
48,578,642 | I really want to reserve a specific set of memory locations with the `MAP_FIXED` option to `mmap`. However, by default `mmap` will `munmap` anything already at those addresses, which would be disastrous.
How can I tell `mmap` to "reserve the memory at this address, but fail if it is already in use"? | 2018/02/02 | [
"https://Stackoverflow.com/questions/48578642",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27074/"
] | According to me usage of noun is not necessary or comes under any standard,but yes it's usage helps your endpoint to be more specific and simple to understand.
So if any nomenclature is making your URL more human readable or easy to understand then that type or URL I usually prefer to create and keep things simple. It... | >
> For a restfull service, does the noun can be omitted and discarded?
>
>
>
Yes. REST doesn't care what spelling you use for your resource identifiers.
URL shorteners *work* just fine.
Choices of spelling are dictated by local convention, they are much like variables in that sense.
Ideally, the spellings are ... |
8,193,525 | I'm wondering how to create the Jquery Nivo Slider transition effect, not creating the entire plugin. I tried playing with CSS's `clip` property but I couldn't get it to create the effect where part of the image fades or moves out block by block until the next slide shows.
If anyone has a general idea or specific code... | 2011/11/19 | [
"https://Stackoverflow.com/questions/8193525",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/701510/"
] | The generic idea is following:
You have div with first image and then you have big number of divs with second image, you spawn them adjusting css properties
Each second image div is just a small piece of it with adjusted background, so it overlays previous image, part of it
With this method you can spawn pieces in an... | Just dropped to this page via Google while finding a solution to my NivoSlider problem.
NivoSlider, basically just create some div element as image replacement, then take the image URL to be used as background image with different background position for each pieces that will be animated later:
```
// Set the slices ... |
43,316,459 | There are several attempts to optimize calculation of HOG descriptor with using of SIMD instructions: [OpenCV](https://github.com/opencv/opencv/blob/master/modules/objdetect/src/hog.cpp), [Dlib](https://github.com/davisking/dlib/blob/master/dlib/image_transforms/fhog.h), and [Simd](https://github.com/ermig1979/Simd/blo... | 2017/04/10 | [
"https://Stackoverflow.com/questions/43316459",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2831104/"
] | I have found solution. It is a temporal buffer. At first we sum histogram to temporary buffer (and this operation can be vectorized). Then we add the sum from buffer to output histogram (and this operation also can be vectorized):
```
float histogram[height/8][width/8][18];
float ky[height], kx[width];
int idx[size];
... | You can do a partial optimisation by using SIMD to calculate all the (flattened) histogram indices and the bin increments. Then process these in a scalar loop afterwards. You probably also want to strip-mine this such that you process one row at a time, in order to keep the temporary bin indices and increments in cache... |
51,087,151 | I've been wondering about a coding practice I've had for some time and I wanted to know if:
* it had some importance
* there was a better way to do so
Imagine you have an update loop and two various states, A and B. In state A, you need a specific variable V that you wish to clear when exiting state A (or entering st... | 2018/06/28 | [
"https://Stackoverflow.com/questions/51087151",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8153539/"
] | The discussion is still on, and here you can find some answers and opinions, even directly from the Angular developers:
<https://github.com/ngx-translate/core/issues/495>
Personally, I would structure the app with the official i18n and eventually add some dedicated translation in the code with the ngx-translate librar... | It is understandable why developers like an ngx-translate like library to take care of internationalization. After all it makes our lives so easy by making the translation problem a 1v1 mapping. Unfortunately this is not how it works with human languages. One has two know more than one language to better understand the... |
11,321,790 | Nginx 1.1.4+ can serve upstream connection with HTTP1.1 **keepalive** directive, see the [official documentation](http://nginx.org/en/docs/http/ngx_http_upstream_module.html#keepalive) (it's not the same as keepalived clients' connections). So the Unicorn configuration can look like as below:
```
upstream unicorn {
... | 2012/07/04 | [
"https://Stackoverflow.com/questions/11321790",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/290338/"
] | Yes, it's valid. There's no difference between UNIX-socket and TCP/IP-socket in terms of HTTP Keepalive. | Unicorn doesn't support persistent (keep-alive) connection by design. So, you shouldn't try to use persistent (keep-alive) connection to unicorn backend. |
12,073,116 | I have simple hide and show function but it is not working. any help would be appreciated
```
<head>
<script type="text/javascript">
$(function(){
$('a').click(function(){
var visible= false;
if(visible){
$('div').hide('slow')
}
else {
$('div').show('slow')
}
visible=!visible;
})
})
</... | 2012/08/22 | [
"https://Stackoverflow.com/questions/12073116",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2917268/"
] | Declare and initialise `visible` **outside** the event handler:
```
var visible= false;
$('a').click(function(){
if(visible){
$('div').hide('slow')
}
else {
$('div').show('slow')
}
visible=!visible;
});
```
Otherwise you are initialising `visible` with `false` *ev... | Try using `toggle` instead. Check out the second example here:
<http://api.jquery.com/toggle/>
Here's the example:
```
<!DOCTYPE html>
<html>
<head>
<style>
p { background:#dad;
font-weight:bold;
font-size:16px;
}
</style>
<script src="http://code.jquery.com/jquery-latest.js"></script>
... |
50,463,059 | I have a column vector `X` of size *N*-by-*1* with two values: `10` and `25`. I want to switch those values, i.e. every element with value `10` should become `25` and vice versa.
Pseudo-code:
```
A = [ 10; 25; 25; 10; 25; 25; 10]
NewNew = find(A == 10)
NewNew2 = find(A == 25)
NewNew3 = [ ];
for NewNew3
if NewNew
... | 2018/05/22 | [
"https://Stackoverflow.com/questions/50463059",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8269433/"
] | ```
N=10;
X = randi([1 2],N,1);
A = zeros(size(X)); % create output vector
A(X==2)=1; % whenever X==2, set A=1
A(X==1) = 2; % whenever X==1, set A=2
[X A]
ans =
1 2
2 1
2 1
1 2
2 1
1 2
1 2
2 1
2 1
2 1
```
You can do this with... | There are some other options you can consider.
1.) (Irrelevant option. Use ibancg's option, cleaner and faster.)
If you have just those two values, a simpler and faster solution would be to initialize to one of these two numbers and flip just a subset of the numbers:
```
A = [ 10; 25; 25; 10; 25; 25; 10];
X = ones(si... |
19,711 | I am using [this](https://tfhub.dev/google/Wiki-words-250/2) model for word embeddings trained using word2vec, I want to get the embedding using GloVe to compare the performance. The model is trained using the English Wikipedia corpus, nevertheless, I have not found such a dataset online. Does anyone knows where can I ... | 2021/05/11 | [
"https://opendata.stackexchange.com/questions/19711",
"https://opendata.stackexchange.com",
"https://opendata.stackexchange.com/users/28258/"
] | As [one of the comments](https://opendata.stackexchange.com/questions/19681/seeking-elevation-data#comment20067_19681) mentioned, you can use the 30m-resolution data from the [Shuttle Radar Topography Mission](https://en.wikipedia.org/wiki/Shuttle_Radar_Topography_Mission) that can be downloaded from various sites. Spe... | Find in this [comment](https://opendata.stackexchange.com/a/19757/1614) information concerning the newly published (2021) Copernicus DEM - Global and European Digital Elevation Model (COP-DEM). |
54,615,285 | I have function defined for getting the data from JSON and passing it in render. But I had to put 2 different condition to process the data.
Below is the function:
```
filterItems = () => {
let result = [];
const { searchInput } = this.state;
const filterbrandsnew = this.props.tvfilter.brand;
if (filterbrandsnew... | 2019/02/10 | [
"https://Stackoverflow.com/questions/54615285",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1328423/"
] | This is quite a common problem with the prevalence of bots.
To mitigate this in an efficient manner you can use either of two AWS services that are on offer which can effectively reduce if not completely stop this.
1. Route your traffic through an **Elastic Load Balancer** to the EC2 instance - Elastic Load balance... | From your shared nginx log, there is so many bot service request are come to the EC2 instance. The bot service are trying to crawl your web site like "YandexBot/3.0" may use the EC2 instance bandwidth heavily. |
15,059,576 | I am trying to enter the first and last name in one string and then display the first and last name on separate lines. I thought the nextLine(); command would work but is not displaying the first and last name on separate lines
```
String full_name;
System.out.println("Please enter your first and last name?")... | 2013/02/25 | [
"https://Stackoverflow.com/questions/15059576",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2105902/"
] | You could try ...
```
System.out.print("Your name is: "+ full_name.replace(" ", "\n"));
``` | Presuming that `c` is a `Scanner` set to listen to `System.in`, then by virtue of it being on the input stream, it wouldn't have an effect on the output stream.
Instead, if you wanted to print the first and last name that was entered, and we presume that a first and last name is separated by a single space (may want l... |
10,678,441 | I have a boolean list in Python
```
mylist = [True , True, False,...]
```
which I want to change to the logical opposite `[False, False, True , ...]`
Is there an inbuilt way to do this in Python (something like a call `not(mylist)` ) without a hand-written loop to reverse the elements? | 2012/05/21 | [
"https://Stackoverflow.com/questions/10678441",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/505306/"
] | The unary tilde operator (~) will do this for a numpy.ndarray. So:
```
>>> import numpy
>>> mylist = [True, True, False]
>>> ~numpy.array(mylist)
array([False, False, True], dtype=bool)
>>> list(~numpy.array(mylist))
[False, False, True]
```
Note that the elements of the flipped list will be of type numpy.bool\_ not... | ```
>>> import operator
>>> mylist = [True , True, False]
>>> map(operator.not_, mylist)
[False, False, True]
``` |
18,860,620 | I'm using ActivePython 2.7.2.5 on Windows 7.
While trying to connect to a sql-server database with the pyodbc module using the below code, I receive the subsequent Traceback. Any ideas on what I'm doing wrong?
CODE:
```
import pyodbc
driver = 'SQL Server'
server = '**server-name**'
db1 = 'CorpApps'
tcon = 'yes'
unam... | 2013/09/17 | [
"https://Stackoverflow.com/questions/18860620",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2668737/"
] | You're using a connection string of `'DRIVER={SQL Server};SERVER=server;DATABASE=db1;UID=uname;PWD=pword;Trusted_Connection=yes'`, you're trying to connect to a server called `server`, a database called `db1`, etc. It doesn't use the variables you set before, they're not used.
It's possible to pass the connection stri... | ```
cnxn = pyodbc.connect(driver='{SQL Server}', host=server, database=db1,
user=uname, password=pword)
print(cnxn)
```
I removed "Trusted\_Connection" part and it worked for me. |
12,027,656 | For some reason I cannot use functions attached to the object I want to use. I added a comment to the line that is not working. As an error I get "Error; pointer to incomplete class type is not allowed" Please help
This is code in dokter.ccp
```
int counter = 0;
for (list<Wielrenner*>::iterator it = wielrenne... | 2012/08/19 | [
"https://Stackoverflow.com/questions/12027656",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1346462/"
] | One thing to check for...
If your class is defined as a typedef:
```
typedef struct myclass { };
```
Then you try to refer to it as `struct myclass` anywhere else, you'll get Incomplete Type errors left and right. It's sometimes a mistake to forget the class/struct was typedef'ed. If that's the case, remove "struct... | Check out if you are missing some import. |
555,418 | Electric potential at a point is defined as the amount of work done in bringing a test charge from infinity to that point..my question is that if we don't know where this point of infinity lies then how can we calculate the potential at a point in influence of electric field and if we do know where it lies can you tell... | 2020/05/28 | [
"https://physics.stackexchange.com/questions/555418",
"https://physics.stackexchange.com",
"https://physics.stackexchange.com/users/265825/"
] | By [Bertrand's theorem,](https://en.wikipedia.org/wiki/Bertrand%27s_theorem) if the strength force is inveresly proportional to the square of the distance then the orbit will be closed, in that will return to the exact same spot each time.
Which means that, in this case $$ \dfrac{m}{n} \pi =2\pi$$
Though however, this... | In messy systems, like the solar system, orbits aren't closed. When you look at the [this page](https://en.wikipedia.org/wiki/Tests_of_general_relativity#Perihelion_precession_of_Mercury) on wikipedia (Tests\_of\_general\_relativity#Perihelion\_precession\_of\_Mercury) you see that the precession of mercury is only a s... |
18,933,107 | I'm sure this is a duplicate, but I can not find an answer to this. For whatever reason, I can not query my database.
Simply I am trying to call a function but I get the error...
```
Warning: mysqli_query() expects parameter 1 to be mysqli, null given in ... on line 12
```
My dbConnect.php file has
```
$adConn = ... | 2013/09/21 | [
"https://Stackoverflow.com/questions/18933107",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2802080/"
] | Because `$adConn` is declared outside of the function is not in scope. That means you do not have access to it inside the function. To have access to it you need to pass it as aparameter of the function.
```
function GetGamesCount($wID, $adConn){
``` | `$adConn` is in the global scope and you cannot access it from the function, if you change `$adConn` to `$GLOBALS['adConn']` it should work. |
19,474,712 | I'm doing a Node.js project that contains sub projects. One sub project will have one Mongodb database and Mongoose will be use for wrapping and querying db. But the problem is
* Mongoose doesn't allow to use multiple databases in single mongoose instance as the models are build on one connection.
* To use multiple m... | 2013/10/20 | [
"https://Stackoverflow.com/questions/19474712",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/763868/"
] | One thing you can do is, you might have subfolders for each projects. So, install mongoose in that subfolders and require() mongoose from own folders in each sub applications. Not from the project root or from global. So one sub project, one mongoose installation and one mongoose instance.
```
-app_root/
--foo_app/
--... | As an alternative approach, Mongoose does export a constructor for a new instance on the default instance. So something like this is possible.
```
var Mongoose = require('mongoose').Mongoose;
var instance1 = new Mongoose();
instance1.connect('foo');
var instance2 = new Mongoose();
instance2.connect('bar');
```
Thi... |
35,963 | I'm using RESTassured with Java. Getting response in compressed from UTF16 format. Response varies from developer tool to code debugging in Chrome/Firefox, here variation means some character got changed.
**Steps:**
1. Loaded the URL
2. Opened developer tool by pressing `F12`
3. Selected the API and checked the resp... | 2018/10/09 | [
"https://sqa.stackexchange.com/questions/35963",
"https://sqa.stackexchange.com",
"https://sqa.stackexchange.com/users/13179/"
] | Resolved this issue by following:
```
String x=respe.asString();
JSONParser par = new JSONParser();
String st = (String) par.parse(x);
``` | I guess the trivial way to handle this is convert the charset to unicode and verify. Java String supports unicode by-default.
The below article states how to convert to and from unicode charset:
<http://tutorials.jenkov.com/java-internationalization/unicode.html>
Coming to the second part of the question. Below are... |
56,790,261 | I use the **pd.pivot\_table()** method to create a user-item matrix by pivoting the user-item activity data. However, the dataframe is so large that I got complain like this:
>
> Unstacked DataFrame is too big, causing **int32 overflow**
>
>
>
Any suggestions on solving this problem? Thanks!
```
r_matrix = df.pi... | 2019/06/27 | [
"https://Stackoverflow.com/questions/56790261",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11708377/"
] | **Some Solutions:**
* You can downgrade your pandas version to 0.21 which is no problem with pivot table with big size datas.
* You can set your data to dictionary format like `df.groupby('EVENT_ID')['DIAGNOSIS'].apply(list).to_dict()` | If you want **movieId** as your columns, first sort the dataframe using movieId as the key.
Then divide (half) the dataframe such that each subset contains all the ratings for a particular movie.
```
subset1 = df[:n]
subset2 = df[n:]
```
Now, apply to each of the subsets
```
matrix1 = subset1.pivot_table(values='... |
59,962 | In an alternate history I am designing, France wins the Seven Years War and does not lose their land claims in America. A problem I have reached though is explaining why land east of the Mississippi winds up in American control.
How can I explain why the land east of the Mississippi (represented by the red line) woul... | 2016/10/29 | [
"https://worldbuilding.stackexchange.com/questions/59962",
"https://worldbuilding.stackexchange.com",
"https://worldbuilding.stackexchange.com/users/11049/"
] | The American Revolution Happened Earlier
----------------------------------------
The reason that the French won the 7 Years War is that the America Revolution happened in the midst of it, and France recognized the territory of the newly independent USA in exchange for a cessation of hostilities on that front. | No explanation needed
=====================
These were claims, not territory. There were no permanent French inhabitants, just a few soldiers, traders, and trappers. There were no settlers and families like there was in English North America.
If American settlers just moved in an occupied the land, the ownership wou... |
102,065 | Inspired by Paulo Cereda's [question](https://tex.stackexchange.com/questions/101813/helping-cardinals-elect-the-new-pope) here, I would like to draw tally marks using PSTricks (or TikZ, if no one can help with PSTricks).
I have no idea how to start, so I cannot even present a try myself. `:(` (This is not good, I kno... | 2013/03/12 | [
"https://tex.stackexchange.com/questions/102065",
"https://tex.stackexchange.com",
"https://tex.stackexchange.com/users/15874/"
] | You mentioned that a Ti*k*Z solution might be acceptable (if Herbert's excellent answer wasn't present). Also, I prefer the "box method" (I din't know if it has a proper name) for such counting tasks, so I did this here. I don't know if the lines ought to be jittery, it could be added, but so far I did not. The command... | Simplest way I found was to use `\usepackage[misc]{ifsym}` and then use commands `\StrokeFive`, `\StrokeFour`, `\StrokeOne`, etc. accordingly
[](https://i.stack.imgur.com/3F60l.jpg) |
55,521,723 | I am trying to sort an array of names alphabetically by using `compareTo()` and a method `String addSort(String name)` but I get an error when compiling at the line "return name", saying that my "variable "name" may not be initialized" when it already is.
I've made the method and the code for sorting alphabetically wh... | 2019/04/04 | [
"https://Stackoverflow.com/questions/55521723",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11310989/"
] | The reason that you are getting the compile error is because you never set a value to the `String name` before trying to use it.
You should be passing in the value like you have in your description `addSort(String name)`. This will remove that error.
I do not see a reason why you are returning the `String` in your f... | You need to include your variable name, that holds the names, inside addSort
```
SimpleDataStructure sorted = new SimpleDataStructure();
System.out.println("Sorted:");
System.out.println(Arrays.toString(sorted.addSort(**HERE**)));
``` |
43,026 | I read the following on the internet:
>
> According to my present understanding of Dhamma, nobody will be able
> to shake my faith.
>
>
>
Can a puthujjana (unenlightened commoner still immersed in self instinct) have unshakable faith in the Buddha-Dhamma?
What happens if a puthujjana does a meditation retreat an... | 2020/10/25 | [
"https://buddhism.stackexchange.com/questions/43026",
"https://buddhism.stackexchange.com",
"https://buddhism.stackexchange.com/users/8157/"
] | Right view arises with two conditions:
>
> [AN2.126:1.1](https://suttacentral.net/an2.118-129/en/sujato#an2.126:1.1): “There are two conditions for the arising of right view. What two? The words of another and proper attention. These are the two conditions for the arising of right view.”
>
>
>
Unshakeable faith h... | This question is well answered by [MN 27](https://www.accesstoinsight.org/tipitaka/mn/mn.027.than.html) and the commentary of its translator, Ven. Thanissaro.
According to the sutta, the one who attains the four jhanas, the knowledge of past lives/ abodes recollection and the knowledge of beings passing away and reapp... |
17,137,827 | If I want to see if one substring equals any of several other substrings. Is this possible to do without putting each case beside each other:
Current way:
```
if ( substr.equals("move") || substr.equals("mv") || substr.equals("mov") ){…}
```
Shorter version (not working):
```
if ( substr.equals("move" || "mv" || "... | 2013/06/16 | [
"https://Stackoverflow.com/questions/17137827",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1234721/"
] | I can think of at least 3 different ways to do this:
1. Use a `Set<String>` to hold all the possible matches and use `Set<String>.contains()` in your if statmeent.
2. If you are using JDK 1.7, you can use a `switch` statement:
```
switch (substr) {
case "move":
case "mv":
case "mov":
// ...
... | Try:
```
private static final Set<String> SUBSTRINGS = new HashSet<>(Arrays.asList("move", "mv", "mov"));
...
SUBSTRINGS.contains(substr);
``` |
34,796,901 | I know I am not the first to ask about this, but I can't find an answer in the previous questions. I have this in one component
```html
<div class="col-sm-5">
<laps
[lapsData]="rawLapsData"
[selectedTps]="selectedTps"
(lapsHandler)="lapsHandler($event)">
</laps>
</div>
<map
[lapsDa... | 2016/01/14 | [
"https://Stackoverflow.com/questions/34796901",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1923190/"
] | I stumbled upon the same need. And I read a lot on this so, here is my copper on the subject.
If you want your change detection on push, then you would have it when you change a value of an object inside right ? And you also would have it if somehow, you remove objects.
As already said, use of changeDetectionStrategy... | Here's an example using [IterableDiffer](https://angular.io/api/core/IterableDiffer) with ngDoCheck. IterableDiffer is especially useful if you need to track changes over time as it lets you do things like iterate over only added/changed/removed values etc.
A simple example not using all advantages of IterableDiffer, ... |
615,961 | Imagine, a deep empty universe consisting of only one particle muon. Will it decay?
As there isn't any change in its surroundings and thus time will lose its meaning. But if the muon will decay in that situation, doesn't it prove that time is something deeper than our experience or what a clock shows! | 2021/02/20 | [
"https://physics.stackexchange.com/questions/615961",
"https://physics.stackexchange.com",
"https://physics.stackexchange.com/users/285359/"
] | There isn't such a thing as "otherwise empty space".
If the quantum fields that permeate spacetime, permit only muons, and no decay to anything else, then only muons can exist.
If they permit anything else, eventually some muons will decay (tunnel, transform...) Into some of those other things.
Or at least, that's o... | A muon is a kind of clock in relativity theory. But in an empty universe there would be no other clock to compare it to and no relativity. . Without relativity the universe as we know it is not defined and cannot exist.The answer to your question is therefore no |
19,748,806 | Reading a C++ book I encountered the following example on using iterators:
```
vector<string::iterator> find_all(string& s, char c)
{
vector<string::iterator> res;
for(auto p = s.begin(); p != s.end(); ++p)
if(*p == c)
res.push_back(p);
return res;
}
void test()
{
string m {"Mary h... | 2013/11/03 | [
"https://Stackoverflow.com/questions/19748806",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1948945/"
] | This answer is 2 years late, still for the benefit of others I'd like to point out that the accepted answer unnecessarily extends from AnyVal.
There is just a minor bug that needs to be fixed in the original answer. The `def **` method needs only one parameter, i.e. the exponent as the base is already passed in the c... | This is my solution using recursion (so I don't need `import scala.Math.pow`):
```
object RichInt {
implicit class PowerInt(val base:Double) {
def ** (pow:Double):Double = if (pow==0) 1 else base*(base**(pow-1))
}
def main(args:Array[String]){
println(2.0**3.0) //8.0
println(2.0**0... |
23,628,114 | I would like to know if it is possible to generate diagonal lines in css or svg to cover a div which will allow the background colour of the div to show through. Something like the following.
If anyone has an example that would be helpful.
 | 2014/05/13 | [
"https://Stackoverflow.com/questions/23628114",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/96854/"
] | You can use base64 data as a png image. For example:
```
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAQElEQVQYV2NkIAKckTrzn5GQOpAik2cmjHgVwhSBDMOpEFkRToXoirAqxKYIQyEuRSgK8SmCKySkCKyQGEUghQD+Nia8BIDCEQAAAABJRU5ErkJggg==);
```
[This is a good generator](http://www.pattern... | There's a tool called stripe generator which solely purposes to create striped images.
<http://www.stripegenerator.com/index.php>
When done, tweak as required using the following css:
```
.stripes {
background-image: url(/assets/images/stripe.png);
background-position: 4px 0;
background-size: 16px;
}
``` |
601,489 | When I started to recover the wifi key using reaver 1.4, after writing the command
```
root@kunjesh-Ideapad-Z570:~/reaver-1.4/src# reaver -i mon0 -b <USSID>
```
it is giving the error
```
Reaver v1.4 WiFi Protected Setup Attack Tool
Copyright (c) 2011, Tactical Network Solutions, Craig Heffner <cheffner@tacnetsol.c... | 2015/03/26 | [
"https://askubuntu.com/questions/601489",
"https://askubuntu.com",
"https://askubuntu.com/users/200461/"
] | Had the same problem, and after a few hours I realized that I'm not running reaver as root (run with `sudo`) | mon0 is not a terribly likely name for a wireless interface. I know it's the one in their screenshot, that doesn't mean it's right for your system.
Try `ifconfig` to see what yours is called.
Incidentally, mine runs with `wlan0` BUT wants to be told my own mac address with `-m` switch, & doesn't like `mon0` at all. |
14,376,535 | Timestamp data type cannot take or store this date format “ Thursday 17th of January 2013 at 11:47:49 AM “ yet this is the format I would like to store in the db because the client likes that format . I can store it using varchar or text but those data types cannot allow me make some minutes calculations using TIMESTAM... | 2013/01/17 | [
"https://Stackoverflow.com/questions/14376535",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1984108/"
] | Finally I found a solution.
We can use the pm utility for that.
If you put any shell script in /etc/pm/sleep.d folder it will be executed automatically just before the system going to sleep and after the system is resumed.
The content will be like
```
#!/bin/bash
case $1 in
suspend)
#suspending to RAM
/ho... | AFAIK there's no such signal in Linux, but you can try
a) `acpid` daemon hooks, if its present, acpid configs are usually in `/etc/acpi`
b) [DBus daemon hooks](https://serverfault.com/questions/191381/what-dbus-signal-is-sent-on-system-suspend), again if its presend on a system
c) reading `acpid` sources to see... |
6,024,677 | I try (without success) to make a regex for find a submit button even if button code is in one two or more lines.
I use now this patter
`/<(button|input)(.*type=['\"](submit|button)['\"].*)?>/i`
and works fine if the button code is in one line
`<input type="submit" name="mybutton" class="button_class" value="Subm... | 2011/05/16 | [
"https://Stackoverflow.com/questions/6024677",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/756520/"
] | Add `s` (not `m`) as a [modifier](http://pt2.php.net/manual/en/reference.pcre.pattern.modifiers.php):
```
/<(button|input)(.*type=['\"](submit|button)['\"].*)?>/is
```
>
> **s (PCRE\_DOTALL)**
>
>
> If this modifier is set, a dot
> metacharacter in the pattern matches
> all characters, including newlines.
> Wi... | Add `/s` to the end of the regular expression to make `.` match any character, including newlines.
It's also a good idea to change greedy `.*` to lazy `.*?` in order to stop it matching whole chunks of the HTML.
It's still not recommended to use regex for parsing HTML. |
796,768 | i am searching for a series with this condition that $\prod 1+a\_n$ converges but $\Sigma a\_n$ diverges.
i know that if $a\_n = n^{\frac{1}{2}}$ then $\Sigma a\_n$ diverges but i dont know it is exactly what i want, does $\prod 1+a\_n$ converges?
i really don't know how to check the divergence or convergence of a p... | 2014/05/16 | [
"https://math.stackexchange.com/questions/796768",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/115608/"
] | According to the usual definition (as mentioned by Bruno), "convergence" for an infinite product means "convergence of the partial products to a *nonzero* limit". So, assuming $a\_n>-1$ for all $n$, the convergence of $\prod (1+a\_n)$ is equivalent to the convergence of the series $\sum\log(1+a\_n)$.
Hence, the questi... | The [usual definition](http://en.wikipedia.org/wiki/Infinite_product) of convergence for infinite products rules out such a possibility by definition.
In any case, if the $a\_n\geq 0$, then the product converges to a finite limit if and only if $\sum a\_n<\infty$.
If you consider a product which converges to $0$ to b... |
26,901,466 | I'm working on a sidebar for my personal website and I'm looking to show/hide a Facebook follow button when visitors click on a Facebook icon. I am wondering if it is possible with stricly HTML/CSS and if not, what would be the easiest way to do it with JavaScript. I've seen many jQuery solutions around but I have yet ... | 2014/11/13 | [
"https://Stackoverflow.com/questions/26901466",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2431414/"
] | Html
```
<label for="toggle-1"> Button </label>
<input type="checkbox" id="toggle-1">
<div class="facebook"> Facebook Content</div>
```
CSS
```
/* Checkbox Hack */
input[type=checkbox] {
position: absolute;
top: -9999px;
left: -9999px;
}
label {
-webkit-appearance: push-button;
-moz-appearance: butto... | We had a similar need for a CSS-only solution, and found that this works with these conditions: (1) the checkbox "button" and items to be toggled are all within the same overall container, such as body or div or p, and items to be toggled are not separated by being in a sub-container, and (2) the label and checkbox inp... |
57,220,006 | I have been trying to **scrape** user reviews from DM website without any luck.
An example page: <https://www.dm.de/l-oreal-men-expert-men-expert-vita-lift-vitalisierende-feuchtigkeitspflege-p3600523606276.html>
I have tried to load the product-detail pages with *beautifulsoup4* and *scrapy*.
```py
from bs4 import Be... | 2019/07/26 | [
"https://Stackoverflow.com/questions/57220006",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6899607/"
] | I don't have time to play around with the params, but it's all there in the request url to get back that json.
```
import requests
import json
url = "https://api.bazaarvoice.com/data/batch.json?"
num_reviews = 100
query = 'passkey=caYXUVe0XKMhOqt6PdkxGKvbfJUwOPDhKaZoAyUqWu2KE&apiversion=5.5&displaycode=18357-de_de&r... | As most modern websites it seems dm.de only loads content through javascript after the page initially loaded. This is problematic because pythons requests library and scrapy only deal with http, but do not load any javascript.
The same thing happens on amazon, but there it is detected and you get a javascript-free ver... |
332,006 | When editing Stack Exchange posts, a whole ton of them don't have [alt text](https://en.wikipedia.org/wiki/Alt_attribute) on images. Alt text is important so the visually impaired that have to rely on screen readers can experience and value Stack Exchange’s content as much as anyone with normal sight can.
To be clear,... | 2019/08/08 | [
"https://meta.stackexchange.com/questions/332006",
"https://meta.stackexchange.com",
"https://meta.stackexchange.com/users/399694/"
] | For me, adding alt text is really important. Historically I didn't understand why it was important but I've since learned better - people accessing the site using screen readers or otherwise text-only should have the best experience that we can offer them, so if you're editing someone's work that has an image and the a... | I posited a similar question to chat some years ago as I was finding myself creating somewhat elaborate bits of text to describe the picture in the eponymous thousands words or so. I was informed that that was bad form (screen readers sometimes read all of that text in an unskippable manner, and most people won't see i... |
58,187,763 | I have his route defined in app.module
```
{path:'empleados/:año/:mes', component:ListaEmpleadosComponent},
```
Then in my app.component.ts that bootstrap the application I have this
```
export class AppComponent {
tituloPagina = 'Parte de Horas';
fechaActual:Date=new Date();
mesActual:number=this.fechaActual.getM... | 2019/10/01 | [
"https://Stackoverflow.com/questions/58187763",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3367720/"
] | Your syntax is wrong you should pass variable without the quote like this
```
[routerLink]="['/empleados', añoActual, mesActual]"
```
But I would recommend you change your variable `añoActual` to become alphabet variable witout having speacial character | You should pass the route parameters like this,
```
<a class='nav-link'
[routerLink]="['/empleados', añoActual, mesActual]">Empleados</a>
```
Don't analyze the URL. Let the router do it.
The router extracts the route parameters from the URL and supplies it to the ListaEmpleadosComponent via the ActivatedRoute ser... |
19,493,876 | I am editing this code from cSipSimple: <https://code.google.com/p/csipsimple/source/browse/trunk/CSipSimple/src/com/csipsimple/ui/incall/InCallCard.java?spec=svn2170&r=2170>
And wish to add this method:
```
public void pushtotalk2(final View view) {
final boolean on = ((ToggleButton) view).isChecked();
... | 2013/10/21 | [
"https://Stackoverflow.com/questions/19493876",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1803007/"
] | Since you want to run something in the UI Thread from a non `Activity` class, you can use a `Handler` instead.
```
new Handler().post(new Runnable() {
public void run() {
((ToggleButton) view).setBackgroundResource(R.drawable.btn_blue_glossy);
((ToggleButton) view).setEnabled(true);
}
});
... | runOnUiThread is not defined for Views. Only for Activities. And InCallCard is just a view.
You can use the post(Runnable) method instead of runOnUiThread(). |
4,267,760 | I started using Ant, that ships with Eclipse. It annoys me, that I get hundreds of warnings in the lines of:
>
> [javac] warning:
> java\io\BufferedInputStream.class(java\io:BufferedInputStream.class):
> major version 51 is newer than 50, the
> highest major version supported by
> this compiler.
>
> [javac] I... | 2010/11/24 | [
"https://Stackoverflow.com/questions/4267760",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/97754/"
] | Major version 51 is Java 7 - looks like you're developing against a preview Java 7 API library but compiling with a Java 6 javac. Either make sure ant uses the Java 7 compiler, or use a Java 6 API library to compile against. | I solved my warning with answer from Bao.
I had JDK1.6 installed before.
Then installed JDK1.7 and ant was stil using JKD1.6 for compiling.
What I have changed is also set the JDK for the project:
right click on project > properties > Java Build Path
If you have JDK1.6 here, try to change it to JDK1.7. |
289,163 | I would like to use the source code of "fill sinks (wang and liu)".
I checked through QGIS3 folders, but could not find much related to it.
Anyone know where the code could be? | 2018/07/11 | [
"https://gis.stackexchange.com/questions/289163",
"https://gis.stackexchange.com",
"https://gis.stackexchange.com/users/123876/"
] | Fill Sinks (Wang and Liu) is a QGIS processing algorithm that calls an external (3rd party) tool SAGA.
The code to call SAGA is in [SagaAlgorithm.py](https://github.com/qgis/QGIS/blob/master/python/plugins/processing/algs/saga/SagaAlgorithm.py).
The source for the SAGA command is either:
* [FillSinks\_WL.cpp](https:... | In addition to the Groovy-based implementation that Chris mentioned (a Whitebox GAT plugin), there is also a newer and more efficient [Rust](https://www.rust-lang.org/en-US/)-based open-source implementation of the Wang and Lui depression filling method available in [`WhiteboxTools`](https://www.uoguelph.ca/~hydrogeo/W... |
17,026,982 | I've been trying to pass this array to the function but i keep on getting,
**error C2664: 'correctans' : cannot convert parameter 2 from 'std::string [3][3]' to 'std::string \*\*'** , don;t mind the silly questions in the code its just random for testing.
code:
```
#include <iostream>
#include <string>
... | 2013/06/10 | [
"https://Stackoverflow.com/questions/17026982",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2471413/"
] | Here you go
int correctans(string \*arr1, string (&arr2)[3][3], int \*arr3, int questions, int choices)` | Well, as compiler said `std::string [3][3]` can not be converted to `std::string **`.
You can try this
```
int correctans(string *arr1, string (* arr2)[ 3 ], int *arr3, int questions, int choices)
```
or this
```
int correctans(string *arr1, string arr2[][ 3 ], int *arr3, int questions, int choices)
```
But bett... |
97,516 | I ran sp\_spaceused and Disk Usage by Top Tables standard report for a table.
The results for sp\_spaceused are:
***name rows reserved data index\_size unused***
SomeTable <1301755> <7691344 KB> <3931672 KB> <3673840 KB> <85832 KB>
However Disk Usage by Top Tables report shows:
```
Table Name # Records Rese... | 2015/04/10 | [
"https://dba.stackexchange.com/questions/97516",
"https://dba.stackexchange.com",
"https://dba.stackexchange.com/users/49056/"
] | Frankly, I wouldn't use either. You can find your biggest tables immediately - with more flexibility - and not worry about where `@updateusage` has been set.
```
CREATE PROCEDURE dbo.TopTables
@NumberOfObjects INT = 100,
@MinimumSizeInMB INT = 10
AS
BEGIN
SET NOCOUNT ON;
SELECT TOP (@NumberOfObjects)
[obj... | This post might give you an alternative approach.
I have found sys.database\_files is pretty much reliable.
<https://stackoverflow.com/questions/9630279/listing-information-about-all-database-files-in-sql-server>
```
Select
DB_NAME() AS [DatabaseName],
Name,
physical_name,
Cast(Cast(Round(cast(siz... |
57,638,226 | I added the font-awesome CDN Html link from the website and placed in the head, and still, the icon wouldn't show. I'm new to Html and need specific instructions on how to fix this.
I even tried downloading it and linking the file locally but that didn't work.
```html
<head>
<title>Social Media</title>
<link h... | 2019/08/24 | [
"https://Stackoverflow.com/questions/57638226",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11971117/"
] | The problem here is that the icon `fas fa-search` is from Fontawesome version 5, but you are loading Fontawesome version 4.7.
Fontawesome 4.7 has instead the `fa fa-search` icon. | ```html
<head>
<title>Social Media</title>
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">
</head>
<ul>
<li>
<i class="fa f... |
30,070,810 | I ve been learning JQuery, and everything was clear. Until I reached the strings.
So far I knew that when you want to call something you do it this way `$('callSomething')`. Now Im learning how to move html elements around, and it was written to call something with double comment lines `$("callSomething")`.
I started ... | 2015/05/06 | [
"https://Stackoverflow.com/questions/30070810",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4801627/"
] | This can help,
I wouldn't say there is a preferred method, you can use either. However If you are using one form of quote in the string, you might want to use the other as the literal.
```
alert('Say "Hello"');
alert("Say 'Hello'");
```
The most likely reason is programmer preference / API consistency.
[When to us... | Both are equivalent, it's mainly a matter of preference and code legibility. If your string contains a single quote, you'll probably want to enclose it in double quotes and vice versa, so you don't have to escape your quotes, e.g.
`"It's nice"` vs `'It\'s nice'`
or
`'And she said "Oh my God"'` vs `"And she said \"Oh... |
10,490,860 | Assume I have an array:
```
$elements = array('foo', 'bar', 'tar', 'dar');
```
Then I want to build up a `DELETE IN` SQL query:
```
$SQL = "DELETE FROM elements
WHERE id IN ('" . implode(',', $elements) . "')";
```
The problem is that the ids in the elements array aren't quoted each individually.... | 2012/05/08 | [
"https://Stackoverflow.com/questions/10490860",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/425964/"
] | You can run a simple array\_map() function to wrap the strings in quotes and then wrap that around the implode() to add the commas:
```
$array = ["one", "two", "three", "four"];
implode(",", array_map(function($string) {
return '"' . $string . '"';
}, $array));
``` | You can do like this as well
```
$elements = array('foo', 'bar', 'tar', 'dar');
$data = '"' . implode('", "', $elements) . '"';
echo $data; // "foo", "bar", "tar", "dar"
``` |
50,974 | Sometimes I hear examples of paradoxes, like The Grandfather Paradox: if you went back in time and killed your grandfather then you wouldn't have been born, so you couldn't go back to kill your grandfather, which means you couldn't have killed your grandfather, so you would have been born so you could go back and kill ... | 2018/04/13 | [
"https://philosophy.stackexchange.com/questions/50974",
"https://philosophy.stackexchange.com",
"https://philosophy.stackexchange.com/users/-1/"
] | The Grandfather paradox comes up in science fiction.
There are four solutions that I found in science fiction:
1. The time loop. You go back in the past, make changes, and somehow the changes affect the future in exactly the right way to make you go back in the past, make the same changes etc etc etc.
2. The impossib... | The Grandfather paradox is not actually a paradox because that situation is not possible.
Time travel is a movie concept and that's it.
"Going back in time" is not possible not due to a possible paradox resulting from that but because time is was a concept created to be able to measure the speed differences in state ... |
59,490,169 | I am trying to mock `resultset` in scala using mockito like below
`val resultset = mock[java.util.ResultSet]`
However when i try to mock `getString` method like below i am getting **ambiguous reference to overloaded definition error** as getString can accept either string or int
`(resultset.getString _).expects(any[... | 2019/12/26 | [
"https://Stackoverflow.com/questions/59490169",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7688538/"
] | This is an known issue with Java/Scala interop, please migrate to [mockito-scala](https://github.com/mockito/mockito-scala) which solves it.
Then you can use the examples amer has posted (just use the methods from the traits and not from the `Mockito` class) or you can try the scala syntax
```
resultset.getString(*) ... | Try something like this maybe:
```
Mockito.when(resultset.getString(any())) thenReturn "test"
```
or
```
Mockito.when(resultset.getString(anyString())) thenReturn "test"
``` |
1,113,353 | ```
- (void)mouseDragged:(NSEvent *)theEvent {
NSSize dynamicImageSize;
dynamicImageSize = [[self image] size];
NSSize contentSize = [(NSScrollView*)[[self superview] superview] contentSize];
if(dynamicImageSize.height > contentSize.height || dynamicImageSize.width > contentSize.width)
{
flo... | 2009/07/11 | [
"https://Stackoverflow.com/questions/1113353",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/132117/"
] | In my app, I set the `clipView`'s `boundsOrigin` using its animator:
```
[NSAnimationContext beginGrouping];
NSClipView* clipView = [[myView enclosingScrollView] contentView];
NSPoint newOrigin = [clipView bounds].origin;
newOrigin.x = my_new_origin.x;
[[clipView animator] setBoundsOrigin:newOrigin];
[NSAnimationConte... | I'm not sure if this is a supported animation type, but have you tried calling through the `animator` proxy object?
eg. `[[self animator] scrollPoint:NSMakePoint(x, y)];` |
1,311,810 | So I'm looking to modify the CLSQL abstractions to suit my own needs. I've been using the clsql-sys package and that's suited most of my needs. However, I can't seem to find how to get a list of field names and field types from the result set. In fact, I just seem can't to find anything ANYWHERE to get types (names I c... | 2009/08/21 | [
"https://Stackoverflow.com/questions/1311810",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/118843/"
] | You do:
```
.article {
margin-left: 100px; /* example */
}
.col-left {
width: 100px; /* same as margin-left above, might not work with percentage */
}
``` | may be add clear: right; to .col-left?
--edited
You can pack all divs on the right in a new div called .col-right and make it floats right aswell as giving it a width property. Then add clear:right; to your .col-left style. That would have the effect that the right column won't continue under the left one. I tested it... |
28,030,268 | when I insert an array in the db, I get the error "unidentified index" in some of the variables even though they all have their corresponding values. Tried using print\_r, and it returned an array with values, but when I try to insert the array, the values become null. I dont understand why and I can't see the error in... | 2015/01/19 | [
"https://Stackoverflow.com/questions/28030268",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3400419/"
] | In your model. Change values as follows
```
$data = array(
'resto_id' => $values['resto_id'],
'diner_id' => $values['diner_id'],
'date' => date('Y-m-d'),
'start_time' => $values['start_time'],
'end_time' ... | I just replaced my model with this. Thanks everyone!
```
$data = array(
'resto_id' => $values['resto_id'],
'diner_id' => $values['diner_id'],
'date' => date('Y-m-d'),
'start_time' => $values['start_time'],
... |
18,710,734 | I am new to android development and I was just wondering how can I create three evenly spaced buttons at the bottom of the screen. I was also wondering what style I could use to make these buttons appear neat and tidy.
The code I have written so far.
```
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns... | 2013/09/10 | [
"https://Stackoverflow.com/questions/18710734",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2318535/"
] | Keep your three button in a different layout(Linear layout with orientation horizontal) at the bottom and give weight to each button and layout\_width as zero. | **Try this way**
```
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:id="@+id/Button1"
android:layout_width="0dp"
android:layout_height="wrap_content"... |
11,905 | Q: How can I best search the web for **exact** LaTeX commands (e.g., `\show` as opposed to `show`)?
It appears that Google will not allow us to escape the `\` character. So, searches for `\show` are interpreted as `show`. Needless to say, results would be tremendously more helpful if the search were interpreted as the... | 2011/02/24 | [
"https://tex.stackexchange.com/questions/11905",
"https://tex.stackexchange.com",
"https://tex.stackexchange.com/users/3762/"
] | [Google code search](http://www.google.com/codesearch) will let you search by regular expression and, if you like, restrict your search to TeX/LaTeX source files only. | You can use this site: <http://detexify.kirelabs.org/classify.html>
This site is really handy as you can just draw the symbol and it guesses perfectly. |
69,741,870 | I'm trying to compare time pasted to form with time saved in DB for deleting this record. I don't understand why it's not working when in DB is stored `8:15:00` and the user pasted `08:15`. The field in DB is `TimeField` and for comparing I'm using `.filter(time__contains=t)` where `t` is string pasted from form. Only ... | 2021/10/27 | [
"https://Stackoverflow.com/questions/69741870",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14986336/"
] | I've only seen [`contains`](https://docs.djangoproject.com/en/3.2/ref/models/querysets/#contains) used with `CharField`. There is no reason to use it here. Just use the field name:
```
print(WateringSchedule.objects.filter(time=t).count())
```
Here I assume Django will parse the input string into a `datetime.time` o... | You should try `icontains` instead of `contains`. |
799,731 | I want to create a method that changes enabled property. How do I pass the contorl name and property to a method.
If the following were my original method:
```
public void ChangeProperties()
{
btnAcesScore.Enabled = true;
}
```
I want to be able to change the "btnAcesScore" each time I call this method. How d... | 2009/04/28 | [
"https://Stackoverflow.com/questions/799731",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Try this :
```
public void ChangeProperties(Control ctrl)
{
ctrl.Enabled = true;
}
```
and call it like that :
```
ChangeProperties(btnAcesScore);
``` | ```
Main()
{
ChangeProperties(ref category,True); //Where Category is the ID of the Textbox control i.e <asp:textbox ID="Category "></textbox>
}
public void ChangeProperties(ref TextBox category,bool val)
{
category.Enabled = val;
}
``` |
29,794,553 | I have two vectors
```
x <- c(2, 3, 4)
y <- rep(0, 5)
```
I want to get the following output:
```
> z
2, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0
```
How can I create `z`? I have tried to use `paste` and `c` but nothing seems to work. The only thing I can think of is using a `for()` and it is terribly sl... | 2015/04/22 | [
"https://Stackoverflow.com/questions/29794553",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3458788/"
] | You could also try to vectorize as follows
```
len <- length(x)
c(rbind(x, matrix(rep(y, len), ncol = len)))
## [1] 2 0 0 0 0 0 3 0 0 0 0 0 4 0 0 0 0 0
```
A more compact, but potentially slower option (contributed by @akrun) would be
```
c(rbind(x, replicate(len, y)))
## [1] 2 0 0 0 0 0 3 0 0 0 0 0 4 0 0 0 0 0
``... | Here's another way:
```
options(scipen=100)
as.numeric(unlist(strsplit(as.character(x * 10^5), "")))
```
And some benchmarks:
```
microbenchmark({as.numeric(unlist(strsplit(as.character(x*10^5), "")))}, {unlist(t(matrix(c(as.list(x),rep(list(y),length(x))),ncol=2)))}, {unlist(sapply(x, FUN = function(x) c(x,y), sim... |
18,480,521 | I have create a sample program in Asp.net which updates time on a button click. This time is shown in a label. Button and and label both are inside update panel say upd1.
Following is the aspx code
```
<script type="text/javascript" >
function fnhn() {
__doPostBack("upd1","");
return false;
}
</script>
</hea... | 2013/08/28 | [
"https://Stackoverflow.com/questions/18480521",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/833228/"
] | 1. Add new numeric column.
2. Copy from old char column to new column with trim and conversion.
3. Drop old char column.
4. Rename numeric column to old column name.
This worked for me (with decimals but I suppose it will work with ints):
```
alter table MyTable add MyColNum decimal(15,2) null
go
update MyTable set M... | 1. *Create a temp column*
`ALTER TABLE MYTABLE ADD MYNEWCOLUMN NUMBER(20,0) NULL;`
2. *Copy and casts the data from the old column to the new one*
`UPDATE MYTABLE SET MYNEWCOLUMN=CAST(MYOLDCOLUMN AS NUMBER(20,0));`
3. *Delete the old column*
`ALTER TABLE MYTABLE DROP COLUMN MYOLDCOLUMN;`
4. *Rename the new one to ma... |
22,867 | From *Spiegel Magazine*:
>
> Das ist eine Vermutung, nicht unbegründet, aber eben eine Vermutung. Um **sich** der Wahrheit weiter anzunähern, wird es auf die Ermittler ankommen.
>
>
>
Am I correct in understanding that **sich** here is impersonal, i.e., does not refer to anyone in particular? Is it similar to som... | 2015/04/15 | [
"https://german.stackexchange.com/questions/22867",
"https://german.stackexchange.com",
"https://german.stackexchange.com/users/5478/"
] | If you aim at an ironic effect (not a literal translation), you can also say
>
> Nicht so zahlreich!
>
>
> | You may also say "Ist ja wie auf einer Beerdigung hier." which is a sloppy phrase for the mood/silence is like being on a funeral where there shouldn't be. |
26,403 | I know he wears a hat on the cover of every book in the series. But, does it ever actually mention him wearing a hat in the books? | 2012/11/01 | [
"https://scifi.stackexchange.com/questions/26403",
"https://scifi.stackexchange.com",
"https://scifi.stackexchange.com/users/6911/"
] | The [publisher is responsible for the hat](http://www.tor.com/blogs/2008/07/chris-mcgrath-and-the-dresden-files). The logic was evidently 'Wizard + P.I. = Duster, Staff, Fedora.' The fact that this contradicts the book is a non-issue for them - cover art is more a marketing item than anything else and the author has li... | HE DOESN'T WEAR A HAT! EVER! He categorically states that he hates them several time throughout several books- I think due to the black hood on his head during the trial re Justin DuMornes death and subsequent doom of damacales as his sentence note he rips the hood of molly during her trial and always says how his head... |
47,665,410 | I am trying to push items from one Array to another depending on the order that is supplied. Essentially i have a 2d array with a name and a price :
```
var myArray = [['Apples',22],['Orange',55],['Berry',23]];
```
Another array with the order it should be in :
```
var myOrder = [0,2,1];
```
My resulting array w... | 2017/12/06 | [
"https://Stackoverflow.com/questions/47665410",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7516811/"
] | This is a simple `map()` that doesn't require anything else
```js
var myArray = [['Apples',22],['Orange',55],['Berry',23]];
var myOrder = [0,2,1];
let final = myOrder.map(i => myArray[i])
console.log(final)
``` | ```
function reorder(arr, order) {
return order.map(function(i) {
return arr[i];
});
}
var myArray = [['Apples',22],['Orange',55],['Berry',23]];
var myOrder = [0,2,1];
reorder(myArray, myOrder); // => [["Apples",22],["Berry",23],["Orange",55]]
``` |
51,530 | I am learning solidity & web3js and am able to make a decent DAPP with it using ReactJS as front end. Most of the online tutorials, online blogs etc - they all show very simple DAPP like this which are easy to explain. But in real life applications should be very complex in nature.
For ex: Lets assume I am creating a ... | 2018/06/19 | [
"https://ethereum.stackexchange.com/questions/51530",
"https://ethereum.stackexchange.com",
"https://ethereum.stackexchange.com/users/40597/"
] | If it is text information surely you can store it on Ethereum. Represent it the way you want using structs and maps or arrays (whatever you are looking for) and code them in Solidity.
Web3.js is a very useful library to interact with you Ethereum node and invoking smart contracts. You will be able to get a lot of inf... | Depends on your requirements:
1. If you want to guarantee (without any centralized authority) that the data is stored and is accessible, you the best place would be logs and events- it's a cheap storage than the contract memory in the blockchain itself.
2. If it's all for your app's requirements and you control a give... |
59,218,057 | I have multiple .xls (~100MB) files from which I would like to load multiple sheets (from each) into R as a dataframe. I have tried various functions, such as `xlsx::xlsx2` and `XLConnect::readWorksheetFromFile`, both of which always run for a very long time (>15 mins) and never finish and I have to force-quit RStudio ... | 2019/12/06 | [
"https://Stackoverflow.com/questions/59218057",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8865518/"
] | I found that I was unable to open the file with `read_xl` immediately after downloading it, but if I opened the file in Excel, saved it, and closed it again, then `read_xl` was able to open it without issue.
My suggested workaround for handling hundreds of files is to build a little C# command line utility that opens,... | I was seeing a similar error and wanted to share a short-term solution.
```
library(readxl)
download.file("https://mjwebster.github.io/DataJ/spreadsheets/MLBpayrolls.xls", "MLBPayrolls.xls")
MLBpayrolls <- read_excel("MLBpayrolls.xls", sheet = "MLB Payrolls", na = "n/a")
```
Yields (on some systems in my classroom b... |
33,995,244 | I have a service where I pass some data on click what works great, but now I wanna pull that data from the service and add it to a scope in another controller and just log everytime there is something added with the $watch function.
My service:
```
app.service('infoService', function() {
var currentInfo = [];
... | 2015/11/30 | [
"https://Stackoverflow.com/questions/33995244",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3607118/"
] | Indeed the information is scattered around so it seems to make no sense. But there is a [precious hint in the doc](http://doc.qt.io/qt-4.8/qprogressdialog.html#details) :
>
> QProgressDialog ... estimates the time the operation will take
> (***based on time for steps***), and only shows itself if that
> estimate is... | I tested this on OS X, with Qt 5 and get the same results
Looking closer at the documentation for [setValue](http://doc.qt.io/qt-5/qprogressdialog.html#value-prop), it states: -
>
> For the progress dialog to work as expected, you should initially set this property to QProgressDialog::minimum() and finally set it to... |
66,979,516 | I have a string `2021-04-07T13:51:39.664+11:00` which I use to create a `Date` object: `d = new Date('2021-04-07T13:51:39.664+03:00')`.
After that, `d` is an instance to represent the date time. Now I'd like to get the timezone offset from `d`, but `d.getTimezoneOffset()` always return local timezone offset which is `... | 2021/04/07 | [
"https://Stackoverflow.com/questions/66979516",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5421539/"
] | This is probably not the best possible approach, but it is portable and quite useful if you are in control of the application environment.
```js
friendlyDate = function( x ){
var label = "Day Month Date Year Time Offset".split(" "),
d = x ? new Date(x) : new Date(),
s = ( d + "" ) .split( / / );
... | [How to initialize a JavaScript Date to a particular time zone](https://stackoverflow.com/questions/15141762/how-to-initialize-a-javascript-date-to-a-particular-time-zone)
>
> There is no time zone or string format stored in the Date object itself.
>
>
>
Seems like either string parsing or a library (there are li... |
73,549,816 | I am working on a long running multi-module Maven Java project. I tried to update the PMD plugin from 3.17.0 to 3.18.0, but I get a java.lang.NoSuchMethodError from PMD almost immediately. The 3.17.0 version of the PMD plugin works fine on this project and I havent found anything in the release notes that helps me unde... | 2022/08/31 | [
"https://Stackoverflow.com/questions/73549816",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10454072/"
] | Please see the discussion here: <https://issues.apache.org/jira/browse/MPMD-353>
In short, you have the following options:
* Upgrade to maven 3.8.6 or later
* Stay on maven-pmd-plugin 3.17.0
* ~~Wait until a new version of maven-pmd-plugin is released with a fix for that problem, that makes it working again with old ... | Did you also try to upgrade `pmd.version` to `6.48.0` or `6.50.0`? I was having the similar problem for the pmd plugin version `3.19.0` and I've upgraded the `pmd-java` and `pmd-core` version to the latest one and worked like a charm. |
26,330,492 | I would like to apply a filter to a photo from the user's library then write it back to disk. I'm using `UIImageJPEGRepresentation`. This function takes a `UIImage` and a `compressionQuality` value between 0.0 and 1.0. Because I want to preserve the original quality, I set it to 1.0. But I found this actually creates a... | 2014/10/12 | [
"https://Stackoverflow.com/questions/26330492",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1795356/"
] | FWIW, I converted the same 600x800 image using AsJPEG() with these compressions to see the sizes & gauge the visible quality loss:
1.0: 642KB
0.9: 212KB
0.7: 144KB
0.5: 86KB
Visible quality didn't suffer much, even at 0.5 (!).
I'll be using these on a webpage where visible perfection isn't critical, so I... | You can convert image in PNG representation for original image quality.
```
UIImagePNGRepresentation(image)
``` |
4,194,581 | There is a lot to commend MVC, but one problem I keep getting is ID name collisions.
I first noticed it when generating a grid using a foreach loop. With the help of SO I found the solution was to use Editor Templates.
Now I have the same problem with tabs.
I used this reference to find out how to use tabs; <http://blo... | 2010/11/16 | [
"https://Stackoverflow.com/questions/4194581",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/125673/"
] | Most obvious answer missing? Netbeans - > Services - > Glassfish -> Properties -> Password show? | First, login to the Administration Console using admin/adminadmin and then change the password. After that, you will be able to connect from Netbeans. I did that with Netbeans 8. |
21,661,444 | I need to generate a text container that contains something like this:
This is **some** random text
where a **few** of the words are
**coloured** and **clickable**
The clickable words should have different actions bound to them and should be in a certain colour. The container will have a fixed width and I need... | 2014/02/09 | [
"https://Stackoverflow.com/questions/21661444",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/970952/"
] | To answer your question, you need the following after the sizes are changed to make sure the layout manager is invoked:
```
filler.revalidate();
```
However that is NOT a good solution as your entire approach to the problem is wrong. You should not be manually calculating sizes of components like that. That is the j... | It wouldn't let me put a long enough comment under your answer camickr :( I wanted to add that after posting this I also found this, similar but not identical problem with resizing BorderLayouts, and they describe a similar situation of NORTH/SOUTH positioned controls not paying attention to vertical sizing - [Java Swi... |
149,533 | * The bird has two yellow spots on its wings.
versus
* The bird has a yellow spot on both wings.
Do they mean the same?
Which one describes more accurately the yellow spots of the following bird?

(Other alternatives are welcomed... | 2014/02/03 | [
"https://english.stackexchange.com/questions/149533",
"https://english.stackexchange.com",
"https://english.stackexchange.com/users/4070/"
] | As a long-time birder, I'd reject both in favor of "...yellow patch evident on wings during flight." But I'm guessing you just selected 'birds' as a random "prop" for your usage question. | >
> “Two yellow spots on its wings”
>
>
>
This is vague, as it could mean two spots on each wing, or two spots in total, on its wings. Replace the word "two" with "three" and it'd be even more confusing: three spots on each, or two on one, one on the other?
>
> “a yellow spot on both wings?”
>
>
>
This is al... |
6,887,336 | I know what CSS Reset is, but recently I heard about this new thing called Normalize.css
What is the difference between the [Normalize.css](https://necolas.github.io/normalize.css/) and [Reset CSS](http://meyerweb.com/eric/tools/css/reset/)?
What is the difference between normalizing CSS and resetting CSS?
Is it jus... | 2011/07/31 | [
"https://Stackoverflow.com/questions/6887336",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/84201/"
] | Normalize.css is mainly a set of styles, based on what its author thought would look good, and make it look consistent across browsers. Reset basically strips styling from elements so you have more control over the styling of everything.
I use both.
Some styles from Reset, some from Normalize.css. For example, from N... | resetting seems a necessity to meet custom design specifications, especially on complex, non-boilerplate type design projects. It sounds as though normalizing is a good way to proceed with purely web programming in mind, but oftentimes websites are a marriage between web programming and UI/UX design rules. |
94,674 | I have been in contact with a **supplier** for a project. We are the client.
Things have been going OK up to a point, then I received a rude and mildly abusive email from one of the people (Bob) I've been in contact with. His manager (Alice) is aware, and will deal with it when Bob is back from a work trip. Hence I wa... | 2017/07/10 | [
"https://workplace.stackexchange.com/questions/94674",
"https://workplace.stackexchange.com",
"https://workplace.stackexchange.com/users/70250/"
] | This is a fairly simple one I would have thought;
>
> Good Afternoon Alice, Bob,
>
>
> I hope you're both well.
>
>
> It's come to my attention that there are some further technical documents you need for the current project, which you'll find attached.
>
>
> If you have any questions please let me know,
>
>
... | Beware, you are facing serious dangers!
It is not about your personal anger (which is reasonable), there is a contact between two companies, both are important to your bosses and you can't see all of the circumstances!
For example, it is possible that your company mis-uses currently an old company relation on a way, ... |
101,270 | So throughout *Infinity War* and in the current *Endgame*, the Time Stone was never touched with bare hands, it seemed to be surrounded by a certain aura and gets transferred from person to person untouched.
Is there a special reason behind it?
[](... | 2019/05/28 | [
"https://movies.stackexchange.com/questions/101270",
"https://movies.stackexchange.com",
"https://movies.stackexchange.com/users/64925/"
] | There are no official sources for this, just some theories and speculations:
One speculation says **it can be touched**, but just like the power stone, you will suffer the effects of touching an infinity stone (Maybe it kills you, vaporizes you, etc).
And that's why the [Eye of Agamotto](https://marvelcinematicuniver... | Not all the Infinity Stones are harmful to human touch. As seen on screen only the power, reality and space stones have been shown to be damaging to touch. And the space stone is only harmful when taken out of working machinery while it was being actively used.
With that said its possible that the time stone has the m... |
31,870,063 | I have a Rabbit struct, and CrazyRabbit struct that inherits it.
When I execute this code:
```
#include <iostream>
using namespace std;
struct Rabbit {
virtual void sayCry() {
cout << "..." << endl;
}
};
struct CrazyRabbit : Rabbit {
void sayCry() { cout <<"Moo"<< endl; }
};
void foo(Rabbit... | 2015/08/07 | [
"https://Stackoverflow.com/questions/31870063",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/260127/"
] | When I store data:
1. User preference data: Settings,Accounts... - **NSUserDefaults**
2. Security data:passwords - **KeyChain**
3. Small amount of data that do not need complex query - **Plist,Archiver**
4. Big amount of data which need Structured Query - **Coredata/SQLite(FMDB)**. | If you want to use operations of a database like `adding, deleting or updating` data later on then its recommended to use database libraries like `CoreData Or Sqlite` Otherwise if your data is not that big and it is mostly static then it is totally fine to use `NSUserDefaults` . |
20,256,062 | How to make my computer as a server so I run the application on IDE and be accessible by other computers on same network via their browsers? | 2013/11/28 | [
"https://Stackoverflow.com/questions/20256062",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2209477/"
] | Each subdomain is generally treated as a separate site and requires their own robots.txt file. | If your test folder is configured as a virtual host, you need robots.txt in your test folder as well. (This is the most common usage).
But if you move your web traffic from subdomain via `.htaccess` file, you could modify it to always use robots.txt from the root of your main domain.
Anyway - from my experience it's b... |
174,345 | I'd like to directly control custom properties of my empties and bones in Animation Nodes tree, to avoid location, scale and rotation manipulation. "Object Attribute Input" doesn't work, even after using copy data path.
My workaround is to create empty with scale controlled by custom properties, and this scale attribu... | 2020/04/13 | [
"https://blender.stackexchange.com/questions/174345",
"https://blender.stackexchange.com",
"https://blender.stackexchange.com/users/53826/"
] | You can use expression node to control property of object. Use `ctrl`+`shift`+`alt`+`c` on a property to get code. use that code inside expression node to get or set the data.
For example an object Empty has two custom properties `A` and `B`. We can get value of `A`
using `bpy.data.objects["Empty"]["A"]`. Similarly we... | the default Animation Nodes do not have 'Bone' sockets, [ClockMender](https://clockmender.uk/blender/animation-nodes/) wrote some nodes that would be useful for that. |
3,185 | In other words does it make a difference in the event that a recipe calls for a Red wine you use a Merlot, Cabernet, Shiraz ect..? | 2010/07/25 | [
"https://cooking.stackexchange.com/questions/3185",
"https://cooking.stackexchange.com",
"https://cooking.stackexchange.com/users/177/"
] | I tend to disagree a little bit on this. Cooking removes almost all of the subtlety from a wine, especially long cooking like in a reduction-based sauce. I'd like to see a double-blind taste of several reduced red varietals to see if you could tell much of a difference. | I am not a wine connoisseur. I actively *dislike* most red wines; I'm not a fan of tannins. So if a recipe calls for red wine as an important ingredient (Beef Bourguignon, for example), I simply won't make the recipe. Sometimes though, like in a risotto or a Chinese sauce, a bit of wine is a lovely touch. Sauvignon Bla... |
3,026,059 | I'd like to have Ant automatically include or import resources matching a particular pattern, but I'm really struggling with the syntax. Here's what I've tried:
```
<import>
<fileset dir="${basedir}" includes="*-graph.xml" />
</import>
```
However, I just get the error message
```
import requires file attribute... | 2010/06/11 | [
"https://Stackoverflow.com/questions/3026059",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/361319/"
] | There are numerous Open Source licenses, but the ones I'd recommend are either BSD-style or the GPL. You'll have to decide which you like. Should people be able to take what you've done and wrap them into proprietary software and sell it, without necessarily giving back their changes? Up to you. A BSD-type license migh... | [TL;DR Legal](http://www.tldrlegal.com "TL;DRLegal") allows you to look up open source software licenses and get a summary, in plain English, of what you Can, Can't and Must do with the software. It also allows you to see the affects of combining two licenses, although that option is misleadingly called "Compare Licens... |
39,411,108 | In the interface I have an abstract method
```
Server launchInstance(
Instance instance,
String name,
Set<String> network,
String userData)
throws Exception;
```
Now in my class that implements the previous interface, I am overriding this method but I do not need... | 2016/09/09 | [
"https://Stackoverflow.com/questions/39411108",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4508310/"
] | That's not possible with Java.
An interface defines method that all implementing classes must support, in order to have a *unifying* API.
One purpose is to be able to *exchange* implementations.
I see a couple of options:
* Add a second method to the interface with fewer parameters.
But this requires, of course, tha... | nope, you just can break the compromisse behind the override... you will need to redesign the method signature for something a little bit more abstract... |
10,396,404 | I want to create a 2D Binary (Bit) Array in Python in a space and time efficient way as my 2D bitarray would be around 1 Million(rows) \* 50000(columns of 0's or 1's) and also I would be performing bitwise operations over these huge elements. My array would look something like:
```
0 1 0 1
1 1 1 0
1 0 0 0
...
```
I... | 2012/05/01 | [
"https://Stackoverflow.com/questions/10396404",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/741442/"
] | As per my comment, you may be able to use sets
```
0 1 0 1
1 1 1 0
1 0 0 0
```
can be represented as
```
set([(1,0), (3,0), (0,1), (1,1), (2, 1), (0,2)])
```
or
```
{(1,0), (3,0), (0,1), (1,1), (2, 1), (0,2)}
```
an AND is equivalent to an intersection of 2 sets
OR is the union of the 2 sets | How about the following:
```
In [11]: from bitarray import bitarray
In [12]: arr = [bitarray(50) for i in xrange(10)]
```
This creates a 10x50 bit array, which you can access as follows:
```
In [15]: arr[0][1] = True
In [16]: arr[0][1]
Out[16]: True
```
Bear in mind that a 1Mx50K array would require about 6GB o... |
47,712,102 | I have an micro SD card, that was in a Galaxy J5 with Android 7, and all the files are messed up now. (jpg, pdf, mp3)
Following characters can be found in the beginning in all of the files, with minor changes in each one.
>
> <ŕ’Ż4i“µŢî Ś- `6Sĺş§uť?ŃÖ0Ü]@Î.0€Ň(QlüŚíď¦îRíb\_CONSOLE sżăm:Ń ..
>
>
>
.. and then a l... | 2017/12/08 | [
"https://Stackoverflow.com/questions/47712102",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3442907/"
] | I have seen it several times, it appears file based encryption. It is not limited to Android Linux, some NAS devices use it (- eCryptFS file-level encryption).
[](https://i.stack.imgur.com/5ZGMy.png) | Seems the OS has written something along the lines of a table into the start of file/a way to read them. I am pretty sure the data is still there, just not visible. Try opening them via a hex editor and check if the NULL's are really null bytes or unreadable data |
17,083,790 | In my script, I am taking a text file and going through the file line by line and replacing the string "test" with "true", then redirect it to a new file. Here's my code:
```
cat $FILENAME | while read LINE
do
echo "$LINE" | sed -e `s/test/true/g` > $NEWFILE
done
```
However when I execute the script I get the foll... | 2013/06/13 | [
"https://Stackoverflow.com/questions/17083790",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1557816/"
] | For errors like this, put `set -x` in the line before `echo "$LINE" | sed -e 's/test/true/g' > $NEWFILE`
```
set +x
echo "$LINE" | sed -e `s/test/true/g` > $NEWFILE
```
Bash will then print the command line before it executes it, quoting the arguments. This should give you an idea why it fails.
Make sure you use t... | When using sed, you should quote replacement parameters in single or double quotes.
For example, this should work:
```
echo "$LINE" | sed -e "s/test/true/g" > $NEWFILE
``` |
7,211 | What was the first home computer and file system that allowed users to choose freely between 3rd party applications?
I was under the impression that early PC (manufacturer) bundled their own applications (like word processor or spreadsheet program) without any means to have another application be used instead. Was thi... | 2018/08/07 | [
"https://retrocomputing.stackexchange.com/questions/7211",
"https://retrocomputing.stackexchange.com",
"https://retrocomputing.stackexchange.com/users/10296/"
] | >
> which allowed the user to choose freely between 3rd party applications in opening data files.
>
>
>
and (from a comment)
>
> I was under the impression that early PCs bundled their own applications (like word processor or spreadsheet program) without any means to have another application be used in its place... | While there were a few systems that associated data closely to integrated applications, they were few and far between, and generally speaking were, for the most part, not what you'd usually consider a "home computer".
The best known, I suspect, was the [Xerox Star](https://en.wikipedia.org/wiki/Xerox_Star). The Star w... |
115,664 | >
> I exist just before your eyes but you can't touch me
>
> You can be anywhere but I will be nowhere
>
> I can be bought but no one truly owns me
>
> People buy me but I don't truly exist
>
> I am 3 on a 2
>
> Some consider me an investment some consider me nothing
>
> Some say I am the future, som... | 2022/04/07 | [
"https://puzzling.stackexchange.com/questions/115664",
"https://puzzling.stackexchange.com",
"https://puzzling.stackexchange.com/users/78801/"
] | Are you
>
> Bitcoin?
>
>
>
*I exist just before your eyes but you can't touch me*
*You can be anywhere but I will be nowhere*
>
> You can see it on a screen anywhere, but it doesn't truly 'exist'.
>
>
>
*I can be bought but no one truly owns me*
*People buy me but I don't truly exist*
>
> People can ... | Answer:
>
> Zuck Bucks
>
>
>
I exist just before your eyes but you can't touch me
>
> zuck bucks are virtual
>
>
>
You can be anywhere but I will be nowhere
>
> you can take zuck bucks anywhere but they're nowhere
>
>
>
I can be bought but no one truly owns me
>
> you can buy zuck bucks but don'... |
47,460,613 | It is crazy but the following code:
```js
import { Component, Inject } from '@angular/core';
import { MatDialog, MatDialogRef, MatDialogConfig, MAT_DIALOG_DATA } from '@angular/material';
@Component({
selector: 'decline',
templateUrl: './decline.component.html',
styleUrls: ['../../../styles/main.css']
})
... | 2017/11/23 | [
"https://Stackoverflow.com/questions/47460613",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1642344/"
] | **Step 4 of Angular Material getting started.**
```
// Add this line to style.css of your app.
@import "~@angular/material/prebuilt-themes/indigo-pink.css";
```
[Step 4](https://i.stack.imgur.com/mEZ49.png)
Be sure that you made all steps before.
[Angular Material - Getting started](https://material.angular.io/gui... | Define your config as follows:
```js
config: MatDialogConfig = {
disableClose: false,
hasBackdrop: true,
backdropClass: '',
width: '250px',
height: '',
position: {
top: '50vh',
left: '50vw'
},
panelClass:'makeItMiddle', //Class Name that can be defined in styles.css as f... |
42,933,704 | I want to create a global shortToast and longToast method to use it dynamically in all other activities I have, so I don't have to define the Toast method in every activity.
I've tried this, but Android Studio tells me that this is a memory leak:
```
public static Activity thisActivity = null;
@Override
protected vo... | 2017/03/21 | [
"https://Stackoverflow.com/questions/42933704",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2829128/"
] | Create a Utils class:
```
public class Utils {
public static void showToast(String msg, Context ctx) {
Toast.makeText(ctx, msg, Toast.LENGTH_SHORT).show();
}
}
```
use it from Activity:
```
Utils.showToast("Message", this);
```
From Fragment:
```
Utils.showToast("Message", getActivity());
``` | Pass the `Activity` as a parameter to `shortToast()` and `longToast()`.
Or, put these methods in a subclass of `Activity`, and have all your activities inherit from it. Then, you can get rid of the `static` keyword from the methods and the `thisActivity` field, and simply use `this`. |
34,635,740 | *(I originally asked this question in [this comment](https://stackoverflow.com/questions/7905110/logging-aspect-oriented-programming-and-dependency-injection-trying-to-make?lq=1#comment56990956_7906547), but Mark Seemann asked me to create a new question instead.)*
I'm starting a new app (.NET Core, if that matters), ... | 2016/01/06 | [
"https://Stackoverflow.com/questions/34635740",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6884/"
] | >
> checking the value is business logic and not intfastructure, so to me it belongs in the same class where the config file is read.
>
>
>
Obviously, I don't know your domain well enough to dispute the truth of that assertion, but that *logging* is part of the domain model sounds strange to me. Anyway, for the sa... | Don't take SRP so seriously, otherwise you'll end up with functional programming. If you afraid of getting your class cluttered by putting log statements inside it, then you have two options. The first one you already mentioned which is using a Decorator class but you can't access/log the private stuff. The second opti... |
7,277,296 | I have a fullCalendar page that I am using qTip (v2) on. The problem is that the qTip tip is REALLY slow and sometime does seem to get the mouseover event so that I have to re-mouseover and then it fire. I have an ajax call in that I thought might be slowing it down but when I removed the ajax call there was no differe... | 2011/09/01 | [
"https://Stackoverflow.com/questions/7277296",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/886591/"
] | You mean like this?
```
foreach ( $_POST as $key => $value )
{
echo "$key : $value <br>";
}
```
you can also use [`array_keys`](http://php.net/manual/en/function.array-keys.php) if you just want an array of the keys to iterate over.
You can also use [`array_walk`](http://www.php.net/manual/en/function.array-walk.... | For just the keys:
>
> $array = array\_keys($\_POST);
>
>
>
Output them with:
>
> var\_dump($array);
>
>
>
-or-
>
> print\_r($array);
>
>
> |
9,517 | When I was in school in Romania I remember my history teacher saying that historically Romania has seen a lot of invaders (referring mainly from the middle ages-present) because it used to have a lot of natural resources. To what extent is this true? I know that Hitler used to get a part of his oil from a city in Roman... | 2013/07/12 | [
"https://history.stackexchange.com/questions/9517",
"https://history.stackexchange.com",
"https://history.stackexchange.com/users/2332/"
] | A full answer would have to do a detailed comparison of resources and relative numbers of invasions across time and territories, which is a bit much, or else track down the motivations of leaders for each particular war, which someone might offer here. **Let me get at your question in two ways: 1) What resources were t... | I believe Romania's chief misfortune during the Middle Ages was to be right next to Eurasian Steppe, in an era when settled communities really had no military answer to the expert horse archers that steppe country naturally incubated.

Another view (... |
53,940,373 | I have created a common ajax call function for my application for optimizing code. the problem is while I call the function its freeze page. Please check below JS:
```
$(fuction(){
$('.btn').click(function(){
var data = getData('myaction/getinfo', []);
})
});
function getData(url, data) {
var resu... | 2018/12/27 | [
"https://Stackoverflow.com/questions/53940373",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5961782/"
] | ```js
var arr = [1,2,3,4,5];
console.log(arr.map((e)=> e + 2))
``` | You can always use the `.map()` operator to modify element values. For example,
```
let increaseByTwo = [1,2,3,4,5];
increaseByTwo = increaseByTwo.map(num=>num+2);
console.log(increaseByTwo);
```
Or, if you really want to use a `for` loop, you can use this:
```
let increaseByTwo = [1,2,3,4,5];
for(let i = 0;i<incre... |
664,189 | I am working on finding the general solution to a disc colliding with a thin spinning rod in two dimensions floating in free space. The collision is perfectly elastic. The width of the rod is negligible.
Shown below is the situation and known variables. Omega is the angular velocity of the rod spinning about its cente... | 2021/09/04 | [
"https://physics.stackexchange.com/questions/664189",
"https://physics.stackexchange.com",
"https://physics.stackexchange.com/users/274939/"
] | [](https://i.stack.imgur.com/8hJSz.png)
here are the equations :
$$m\_1\left(v\_{1xf}-v\_{1xi}\right)=p\,\sin(\alpha)$$
$$m\_1\left(v\_{1yf}-v\_{1yi}\right)=-p\,\cos(\alpha)$$
$$m\_2\left(v\_{2xf}-v\_{2xi}\right)=-p\,\sin(\alpha)$$
$$m\_2\left(v\_{2y... | In a complex collision, you frequently need to know something about the conditions after the collision. That reduces the number of unknowns, and appears to the case in this situation. In this case, you might make the (questionable) assumption that the angle of reflection for the disk is the same as the angle of inciden... |
2,968,289 | I'd like to ensure that certain maintenance tasks are executed "eventually". For example, after I detect that some resources might no longer be used in a cache, I might call:
[self performSelector:@selector(cleanupCache) withObject:nil afterDelay:0.5];
However, there might be numerous places where I detect this, and ... | 2010/06/03 | [
"https://Stackoverflow.com/questions/2968289",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51503/"
] | The sequence of columns is really irrelevant in a strict (functional) sense, in any RDBMS - it's just a "nicety" to have for documentation or humans to look at.
SQL Server doesn't support any T-SQL commands to order the columns in any way. So there is no syntax in T-SQL to accomplish this.
The only way to change tha... | This is a *safe* work around without using temp table. After you add the column towards the end, simply go to SQL Sever Management Studio. Click on the table, select -> Design (or Modify) **and drag the last column to where ever position you want**.
This way you do not have to worry about loosing data and indexes. Th... |
45,976,463 | I know it allows a third party to have access to the user's data of the another website. If I just want to make an e-commerce website with Facebook login, and it'll only be used by my customer, is it an overkill to use OAuth? | 2017/08/31 | [
"https://Stackoverflow.com/questions/45976463",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5241511/"
] | Disabling *auto* update is not required, and is actually *counter productive*.
Keep in mind that people have legitimate reasons to continue using JREs or JDKs for Java 8 (probably *several* years into the future).
It is very much the same as with previous major releases of Java: ideally you *plan* about moving forwar... | I believe no,
as JAVA 9 has SO BIG change caused by its jigsaw(the change is so huge and make java 9 delay again and again ), such big chance has potential to break your current java application.
BTW: java 9 will finally release in this month. |
4,486 | Say I've got two 1-dimensional lists
```
A = {1,2,3}
B = {a,b,c}
```
How do I
1. create a list of all pairs from list `A` such that the result looks like `{{1,2},{1,3},{2,3}}`?
2. create a list of all pairs from lists `A` and `B` such that the result looks like `{{1,a},{1,b},{1,c},{2,a},{2,b},{2,c},{3,a},{3,b},{3,... | 2012/04/19 | [
"https://mathematica.stackexchange.com/questions/4486",
"https://mathematica.stackexchange.com",
"https://mathematica.stackexchange.com/users/1044/"
] | **Ad. 1**
ordering not valid:
```
Subsets[A, {2}]
```
>
>
> ```
> {{1, 2}, {1, 3}, {2, 3}}
>
> ```
>
>
or with ordering
```
Permutations[A, {2}]
```
**Ad. 2**
```
Outer[List, A, B]
```
>
>
> ```
> {{{1, a}, {1, b}, {1, c}}, {{2, a}, {2, b}, {2, c}}, {{3, a}, {3, b}, {3, c}}}
>
> ```
>
>
or exactly... | Here's an answer for a variant of question #2 for those who were looking for something slightly different, as I was.
The original question #2 is asking for a generalized outer product (matching up every element of the first list with every element of the second list), which is why Artes correctly gives `Outer[List, A,... |
63,746,006 | I am developing an app for iOS and also using Mac Catalyst to run on my Mac. The app runs fine on my iPhone but always shows an error on Catalyst. The code used to run fine before updating to Big Sur Beta 6 from Beta 5. Here's a screenshot of the error: [ My App had been developed as iOS / iPadOS with Mac support. All has been working great throughout macOS 11 beta builds. Until today that is, when I, as you, updated to Beta 6. Upon attempting to run for macOS target I get the same... |
11,959,110 | Ok, so I have an array:
```
numbers = ["2", "3", "4", "5"]
```
and I need to split the array into two arrays with a conditional
```
numbers.reject!{|x| x > 4 }
```
and what i need is one array `numbers` to contain `numbers = ["5"]` and another array with the rejects `rejects = ["2", "3", "4"]`
How do I do this? ... | 2012/08/14 | [
"https://Stackoverflow.com/questions/11959110",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/223367/"
] | Check out [`Enumerable#partition`](http://ruby-doc.org/core-1.9.3/Enumerable.html#method-i-partition)
```
arr = ["2", "3", "4", "5"]
numbers, rejects = arr.partition{ |x| x.to_i > 4 }
# numbers = ["5"]
# rejects = ["2", "3", "4"]
``` | ```
numbers = [2, 3, 4, 5]
n_gt_four = numbers.select{|n| n > 4}
n_all_else = numbers - n_gt_four
puts "Original array: " + numbers.join(", ")
puts "Numbers > 4: " + n_gt_four.join(", ")
puts "All else: " + n_all_else.join(", ")
```
Outputs:
```
Original array: 2, 3, 4, 5
Numbers > 4: 5
All else: 2, 3, 4... |
13,821,314 | I am trying to find a regular expression that will recognize files with the pattern as az.4.0.0.119.tgz. I have tried the regular expression below:
```
([a-z]+)[.][0-9]{0,3}[.][0-9]{0,3}[.][0-9]{0,3}[.]tgz
```
But, no luck. Can anyone please point me in the right direction.
Regards,
Shreyas | 2012/12/11 | [
"https://Stackoverflow.com/questions/13821314",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1308500/"
] | Better to use a simple regex like this:
```
^([a-z]+)\.(?:[0-9]+\.)+tgz$
``` | Your pattern has 4 chiffers group, your regexp only 3. |
66,644,472 | Anyone could explain why the console logs below produce different output while I expected them to be exactly the same?
```
'use strict';
const objectSelected = document.querySelector('.message');
console.log(`${objectSelected}`);
console.log(objectSelected);
``` | 2021/03/15 | [
"https://Stackoverflow.com/questions/66644472",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15402917/"
] | The console will log any type of value: objects, arrays, functions, booleans, numbers, etc. Any time you put a non-string inside a string or concatenate a non-string with a string, JavaScript will call `.toString()` on the the thing which is not a string:
```
var obj = { foo: 'bar' }
console.log(obj) //-> ... | When passing an object in a string template, it will be converted to a string. That's why the first statement will result in `[object <something>]`.
The second will print the value as is (as an object). When passing an object to console.log, it will be printed as the full object. |
46,767,885 | it is easy to read the first value in the array below - but how to read the last value without deleting or looping with e.g. foreach?
```
$message_rate_array[0]['messages']
```
sample array (real size is not foreseeable):
```
Array
(
[0] => Array
(
[messages] => 30584709
[time] =... | 2017/10/16 | [
"https://Stackoverflow.com/questions/46767885",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8613418/"
] | Using `end()` you can get the last value of array.
**Working Demo: <https://eval.in/880691>**
```
<?php
$people = array("Peter", "Joe", "Glenn", "Cleveland");
echo end($people);
?>
```
**Output:** `Cleveland` | Refer from <http://php.net/manual/en/function.end.php> you can do this as the easy and clear way.
```
$ArrayList = array();
echo end($ArrayList);
``` |
31,851,416 | I have a string like this:
```
mystring = "A:\"" + var1 + var2 + var3 + "\"";
```
var1 var2 and var3 sometimes get null, sometimes getting string. When variables getting string, mystring returning like this:
```
A:"var1valuevar2valuevar3value"
```
I need to show like this:
```
A:"var1value var2value var3value"
... | 2015/08/06 | [
"https://Stackoverflow.com/questions/31851416",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4124087/"
] | You could use LINQ to filter out the empties, and use `string.Join` to concatenate them:
```
string s = string.Join( " "
, new string [] {var1, var2, var3}
.Where(x => !string.IsNullOrEmpty(x))
)
``` | Use below
```
string mystring = "A:\"" + AddSpace(var1) + AddSpace(var2) + var3 + "\"";
public string AddSpace(String var)
{
return var == null ? "" : var + " ";
}
``` |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.