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 |
|---|---|---|---|---|---|
4,111,454 | I need to do a check on a page to check if certain images have loaded ie. not returned 404. If they arent available I want to replace the image with a default images.
I am aware I can assign an onerror handler to the images.
Firstly I need to use a selector to find all the images that have a source which contains th... | 2010/11/06 | [
"https://Stackoverflow.com/questions/4111454",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/373674/"
] | You can use the image's [error handler](http://api.jquery.com/error/) and the [attribute contains selector](http://api.jquery.com/attribute-contains-selector/) like so:
```
$("img[src*=Product]").error(function() {
$(this).attr('src', 'notfound.jpeg');
});
``` | ```
$('img[src*="substring"]')
```
It's an attribute selector. Check it out <http://api.jquery.com/attribute-contains-selector/> |
50,550 | The [2020 Military Strength Rankings](https://www.globalfirepower.com/countries-listing.asp) list Russia's military as #2 in strength:
1. United States
2. Russia
3. China
However, [their defense budget rankings](https://www.globalfirepower.com/defense-spending-budget.asp) show that Russia's only #8 in spending:
1. U... | 2020/02/29 | [
"https://politics.stackexchange.com/questions/50550",
"https://politics.stackexchange.com",
"https://politics.stackexchange.com/users/28994/"
] | I have no experience in the Russian or US military, but my impression is that Russian weapons manufacturers face much greater pressures to charge lower prices.
US weapons manufactures consider the Pentagon a bottomless pit of money and face no pressure to reduce prices. 200 TOW missiles? Let's add a 3 extra zeros to t... | The USA has military posts all over the world, at huge expense.
Russia has almost none in comparison.
Russia has been able to spend money on technology and internal infrastructure and therefore has a world-class military at a fraction of the cost. |
1,004,899 | I have a weird problem when using JQuery call in my ASP.NET MVC project. I found that the Ajax call gives 404 ( resource not found error). But when I use the usual URL GET call, I can successfully call the server without any problem. Any idea why this is so?
This my ASP.NET MVC code
```
public class ViewRecordControl... | 2009/06/17 | [
"https://Stackoverflow.com/questions/1004899",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3834/"
] | ```
$(function() {
$("#username").click(function() {
$.getJSON('<%= Url.Action("GetSoftwareChoice", "ViewRecord")%>',{username: '123'}, function(data) {
alert(data);
});
});
});
``` | Old function :
```
function Chart() {
var url = "../Home/Pie/";
$.ajax({
url: url,
data: {},
cache: false,
type: "POST",
success: function (data) {
var chartData = data;
createChart(chartData);
$(document).bind("kendo:skinChange", cre... |
112,246 | I have a non-daemon server app that my Windows 2003 server needs to run all the time. The problem is, every time the server restarts, be it electricity or windows update, someone needs to press `Ctrl`+`Alt`+`Del` and enter username/password. Then the program starts, as it's in Startup. How do I make Windows 2003 to aut... | 2010/02/12 | [
"https://serverfault.com/questions/112246",
"https://serverfault.com",
"https://serverfault.com/users/3007/"
] | 1. Run `gpedit.msc`
Under `Local Computer Policy > Computer Configuration > Administrative Templates > System`, set "Display Shutdown Event Tracker" to "Not configured".

2. Run `control userpasswords2`
3. Uncheck "User must enter user name and passwo... | 1. Run `control userpasswords2`
2. Uncheck checkbox "User must enter user name and password to use this computer."
3. Run `gpedit.msc`
Computer Configuration > Administrative Templates > System > Display Shutdown Event Tracker > Settings, and select radio button: "Disabled" (or "Not configured"). |
111,760 | How can I explain the relationship of building A to building B where building A is, e.g., on the NW corner of an intersection, and building B is on the SE corner?
Which of the following (if any) is the clearest? If none, is there a clearer way?
>
> The building A would be diagonally opposite the building B.
>
>
> ... | 2013/04/19 | [
"https://english.stackexchange.com/questions/111760",
"https://english.stackexchange.com",
"https://english.stackexchange.com/users/42787/"
] | I assume you are asking about a situation like this:

It is technically and mathematically correct to say that they are on **opposite corners**. However, this can indeed be misconstrued, as you've noted. I do not believe that there are any terms in common usage... | For me, I would say **opposing corners** on xyz street. |
66,527,812 | I have data like the example below. For each participant, if a particular string (`"trial_end"`) is present in the `my_strings` column I would like to remove all the rows after its appearance.
```
library(dplyr)
library(stringr)
library(tibble)
df1 <- tibble::tribble(
~participant_id, ~timestamp, ~my_strings,
... | 2021/03/08 | [
"https://Stackoverflow.com/questions/66527812",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5115721/"
] | One option could be:
```
df1 %>%
group_by(participant_id) %>%
slice(if(all(my_strings != "trial_end")) 1:n() else 1:which(my_strings == "trial_end"))
participant_id timestamp my_strings
<int> <int> <chr>
1 1 1 other_string
2 1 2 other_string
... | You could count the cumulative sum of matches up to the prior row and filter to only include rows up to the first match per participant:
```
df1 %>%
group_by(participant_id) %>%
filter(lag(cumsum(my_strings == "trial_end"), default = 0) < 1) %>%
ungroup()
# A tibble: 9 x 3
participant_id timestamp my_strings ... |
18,731,288 | I am trying to write a directive to deal with changing an icon class for table headers. What I would like is (what I believe anyway) the standard way of dealing with sorting by table headers. The directive would add a link element and upon a user's click sort by desc and change the icon to desc, upon click again sort b... | 2013/09/11 | [
"https://Stackoverflow.com/questions/18731288",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/953088/"
] | What you need to do is for each element using your directive providing both an order and the current order (the one from your controller).
BTW I think your directive will be a better match as an attribute and not a tag. You can check the following code :
```
angular.module('myApp', []).directive("sort", function() {... | Unless you are intent on writing your own directive, you might consider looking at what is available.
[ngmodules.org](http://ngmodules.org) shows some directives that are already set up for table headers.
Here are a couple options with some sample code to give you a feel for both. They both look to be developed and ... |
4,255,154 | Is there some kind of `split()` function in XPath?
Say I have this XML:
```
<root>
<path>C:\folder\filename</path>
</root>
```
And I want to retrieve `filename`, how can I do this? I know I can get the node value like this:
```
//path/text()
```
How can I get only the filename? (I know there is a `concat()` fu... | 2010/11/23 | [
"https://Stackoverflow.com/questions/4255154",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/431879/"
] | If you have an xpath-2.0 capable API, you can solve this in two ways:
**replace technique**
Try using:
```
fn:replace(string,pattern,replace)
```
e.g.
```
fn:replace(//path/text(),".*/","")
```
**tokenize technique**
You may get some mileage from tokenize:
```
fn:tokenize(string,pattern)
```
e.g. (thanks to... | **While I would use**:
```
tokenize(/*/*, '\\')[last()]
```
**there are also numerous other ways to obtain the desired string**:
```
codepoints-to-string
(reverse
(string-to-codepoints
(substring-before
(codepoints-to-string
(reverse
(string-to-c... |
19,280,416 | My xml and xslt file looks like follow. problem is when i apply my transformation file only 2nd one happens 1st one skips. How could i run both on first run. Please help Thanks.
```
//BEFORE TRANSFORMATION
<A>
<B>
<Name>ThisOne</Name>
<Target>abc</Target>
</B>
</A>
```
My XSLT FIle
```
<?xml version="1.0" ... | 2013/10/09 | [
"https://Stackoverflow.com/questions/19280416",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1585883/"
] | There are two types of variable in C#. The first is called a "Value" type. When you assign it a value, the value is copied to that location, so when you write
```
int b = a;
```
You are *copying* the value of a to b.
However, there is also a "Reference" type. This only copies over a *reference* to the variable - in... | In C# Arrays are Reference Types. See [this](http://msdn.microsoft.com/en-us/library/4d43ts61%28v=vs.90%29.aspx)
Though I assumed this would end up being a duplicate question, I do apologize for not expounding further on the link.
In C# you have Value Types and Reference Types. All Arrays (even if they are arrays of ... |
4,501,883 | Can anyone explain me this code split("[ ]+", $s);
thanks
```
$s = "Split this sentence by spaces";
$words = split("[ ]+", $s);
print_r($words);
Output:
Array
(
[0] => Split
[1] => this
[2] => sentence
[3] => by
[4] => spaces
)
``` | 2010/12/21 | [
"https://Stackoverflow.com/questions/4501883",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | The first argument to [split](http://www.php.net/split) is a regex pattern, which in this instance is effectively saying "match the space character as many times as possible".
**N.B.: split is deprecated as of PHP 5.3, so I wouldn't recommend using this.**
You could achieve precisely the same effect via:
```
$words ... | ```
"[ ]+"
```
Is a regex expression. It will split the string according to spaces. |
10,638,951 | So I have this huge tree that is basically a big switch/case with string keys and different function calls on one common object depending on the key and one piece of metadata.
Every entry basically looks like this
```
} else if ( strcmp(key, "key_string") == 0) {
((class_name*)object)->do_something();
} else if (... | 2012/05/17 | [
"https://Stackoverflow.com/questions/10638951",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1034/"
] | Looks like you are missing some semi-colons after your strings as well.
```
if($form_id == "offense") {
$query="INSERT INTO ff_offense (ID, PLAYER, POSITION, TEAM, PASS_YDS, RUSH_YDS, REC_YDS, RECEPTIONS, TD)
VALUES ('NULL','$_POST[PLAYER]','$_POST[POSITION]','$_POST[TEAM]','$_POST[PASS_YDS]','$_POST[RUSH_YDS... | These other answers are right, but there's a missing semicolon at the end of this declaration also, which is what's causing the syntax error:
```
if($form_id ="offense") { $query="INSERT INTO ff_offense (ID, PLAYER, POSITION, TEAM, PASS_YDS, RUSH_YDS, REC_YDS, RECEPTIONS, TD)
VALUES ('NULL','$_POST[PLAYER]','$_PO... |
35,491,089 | I can't seem to get the date-picker working. I'm not sure what im doing wrong. Im pretty sure Im passing the right name but Im not sure if I have it all setup right?
HTML:
```
{% extends "base.html" %}
{% load bootstrap3 %}
{% load static %}{% load staticfiles i18n %}
{% block title %}Jobs{% endblock %}
{% block hea... | 2016/02/18 | [
"https://Stackoverflow.com/questions/35491089",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/699345/"
] | Here is [my solution](http://ideone.com/eWqWeP):
```
$re = "/{{(?<inner>.*?)}}|(?<outer>[^{}]*(?:{(?!{)[^{}]*|}(?!})[^{}]*)*)/";
$str = "{{Friday}}today{{Sunday}}";
preg_match_all($re, $str, $matches);
print_r(array_filter($matches["outer"]));
print_r(array_filter($matches["inner"]));
```
**Why does it look so com... | I have managed it. The problem of empty strings still remains. The single braces do not make a problem.
```
(?<={{)(?P<THINGS>((?<!}}).)+)(?=}})|((?<=}})(?P<AREA>((?<!{{).)+)(?={{))|(?P<AREA2>^((?<!{{).)+)(?={{)|(?<=}})(?P<AREA3>((.)+$))
```
[Debuggex Demo](https://www.debuggex.com/r/vzlA_hbB1LdQbD1y)
The result ar... |
7,570,813 | Can anybody help me with this?
I am taking a table in Excel and exporting it as a web page. I noticed that the webpage rendered things differently -- such as spacing (it's putting in LOTS of white space where there should be none). Also, it's displaying columns that were hidden in my excel file.
Can anybody let me kn... | 2011/09/27 | [
"https://Stackoverflow.com/questions/7570813",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/102398/"
] | Finally it turns out that mustache doesn't handle array of objects sent to the template, so i had to wrap it with other object like this
```
render: function() {
var item_wrapper = {
items : this.collection
}
$(this.el).html(Mustache.to_html(JST.item_template(),item_wrapper ));
}
```
and in t... | Mustache can handle arrays using `{{#.}}{{.}}{{/.}}` |
48,425,043 | I'm trying to migrate a SF 3.3 app to SF 4 with its new directory structure and everything.
I'm struggling on this exception:
>
> The "simplethings\_entityaudit.reader" service or alias has been removed or inlined when the container was compiled. You should either make it public, or stop using the container directly... | 2018/01/24 | [
"https://Stackoverflow.com/questions/48425043",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4994579/"
] | In my case, the error appears in a unit test.
I had a single service, which could not be loaded in tests (Symfony 4.2) while all other services in my project worked well.
I've cleared the cache, but it didn't help. Then I created a simple controller with a route and injected the service as method parameter. Afterward... | In Symfony 4.0, any service that does not specify its visibility is private, <https://github.com/symfony/symfony/pull/24238>.
As far as I can see, the service you mention does not specify the visibility: <https://github.com/simplethings/EntityAuditBundle/blob/1.0/src/SimpleThings/EntityAudit/Resources/config/auditable... |
11,747 | Are micrometeorites just dust grains at high relative speed, or is there some difference between them and cosmic or interstellar or solar nebula dust? Dust as in the clouds which obscure parts of the Milky Way in our night sky. | 2015/09/06 | [
"https://astronomy.stackexchange.com/questions/11747",
"https://astronomy.stackexchange.com",
"https://astronomy.stackexchange.com/users/1030/"
] | I'd like to add more inputs on the physics behind telescope resolution. The telescope resolution is given by its primary mirror size which produces a "quasi" punctual image for each light source it sees, that is called a airy disk. The airy disk size is inversely proportional to the telescope primary mirror diameter an... | Just a small supplementary -- there is no point in building a larger telescope unless you can manufacture a mirror that big without any kind of flaw or deformation and then mount it so that it doesn't change shape as you point it in different directions. This is a whole pile of really hard engineering problems which ha... |
3,160 | I'm starting to learn how to shoot. Up until now I've only used point-and-shoot cameras mostly on automatic settings. My view is there are basically three classes of cameras sold by the major manufacturers:
1. **Point-and-shoot:** for those who want nothing to do with photography
2. **Advanced:** (Canon's *G* series, ... | 2010/09/08 | [
"https://photo.stackexchange.com/questions/3160",
"https://photo.stackexchange.com",
"https://photo.stackexchange.com/users/1208/"
] | No. An SLR is not a must when learning photography.
In fact, I'd even say that an SLR can be a real hindrance. There are so many controls and functions that it can be overwhelming, and it's pretty discouraging to spend $500+ on a camera kit, and turn bad photos. So much that it might make you want to switch back to fu... | I started with an advanced P&S, and moved on to an SLR a few years ago when the P&S died. Two aspects where I saw a huge improvement with the SLR:
* Low light photography. The flash, even the built-in one, works much better. And even without a flash, I can get a much larger aperture with a low-light lens, something th... |
43,181,228 | I'm using jackson lib to add json object into jsonarray then Stringify my jsonarray to save it into my a table as string
```
JsonObject obj = new JsonObject();
obj.put("id",1).put("data","test");
JsonArray arr = new JsonArray();
arr.add(obj);
arr.toString();
//out : [{"map":{"id":1,"data":"test"},"empty":false}]
/... | 2017/04/03 | [
"https://Stackoverflow.com/questions/43181228",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4824279/"
] | In your laravel folder open app/Exceptions/Handler.php paste the following code. That will return custom error page for 403 and 500 error.
```
public function render($request, Exception $exception)
{
if ($exception instanceof CustomException) {
return response()->view('errors.custom_all', [], 500);
}
... | ```
public function authorize()
{
$job_posting_id = $this->route('id');
$job_posting = Job_postings::where('id', $job_posting_id)->where('user_id', user()->id)->exists();
if($job_posting){
return true;
}
return redirect('/error');
}
public function failedAuthorization()
{
return view('errors.dashbo... |
1,972,625 | I am trying to fill a uitableview with multiple sections.
This is my code:
```
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdenti... | 2009/12/29 | [
"https://Stackoverflow.com/questions/1972625",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/229067/"
] | Check you got
```
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
```
in
```
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
``` | In my case i was having the same error because i was missing the alloc/init:
```
if (cell == nil) {
cell = [[UITableViewCell alloc] init];
}
``` |
50,620,511 | How to pass parameters with `Volley` GET method?.
```
private void getData(int ClassIDs){
RequestQueue queue = Volley.newRequestQueue(this);
String url = "";
StringRequest request = new StringRequest(com.android.volley.Requ... | 2018/05/31 | [
"https://Stackoverflow.com/questions/50620511",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7243174/"
] | You can set GET volley request like this
```
StringRequest commonRequest = new StringRequest(Request.Method.GET, url/* URL OF WEBSERVICE*/, new Response.Listener<String>() {
@Override
public void onResponse(String response) {
//HANDLE RESPONSE
}
}, new Response.ErrorListener() ... | Here is the full method I use to get string response using `Volley`. Use POST method if you pass parameters. Define your value and post URL. Get response using `onResponse` method.
```
public void getPostData() {
String value = "value";
String s; //to get response
final String URL = "Your php URL paste her... |
54,683,189 | This is `scripts` section of my `package.json`:
```
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"compile-prebuild": "tsc -p prebuild-tsconfig.json --pretty",
"prebuild": "ts-node --project PreBuild/tsconfig.json PreBuild/prebuild.ts",
"testJs": "node test.js",
"test"... | 2019/02/14 | [
"https://Stackoverflow.com/questions/54683189",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5318303/"
] | The variable `length` is used to limit iterations of both your loops but is never assigned a value. This is undefined behaviour and a bus error is definitely a possible outcome of it.
Did you intend to use `len` for this purpose?
EDIT: `strlen` already does not include the null terminator in its return value. `strle... | The scope of len should be through 'main()'.
So, remove declaration of length and instead declare len there.
Here is the corrected code.
```
#include <stdio.h>
#include <string.h>
#define MAX_BUF 1024
int main ()
{
char buf[MAX_BUF];
int len;
do {
fgets(buf, MAX_BUF, stdin);
... |
17,567 | My kitchen counter top has a small patch that is losing color. The patch is the main area of the countertop where my wife cuts veggies/processes food/other stuff.
I am looking for some fix to get it back in its original color since we live in a rented house, and this thing is not covered in the standard maintenance pr... | 2017/10/10 | [
"https://lifehacks.stackexchange.com/questions/17567",
"https://lifehacks.stackexchange.com",
"https://lifehacks.stackexchange.com/users/21948/"
] | First of all: 400 thread cottons that are "scratchy" should be returned.
Second: [Maneesh's answer](https://lifehacks.stackexchange.com/a/17547/21979) is way better than the current votes reflect. Vinegar is the most effective and safe for most cotton fabrics, most colours, the washing machine and the environment. (It... | I suggest you the following methods:
Wash with Baking Soda and Vinegar in a washing machine(as you have not specified about vinegar, I feel you should try this combination: washing soda and vinegar). More methods are as follows:
* Add a cup of **vinegar** during the rinse cycle of washing machine.
* **Use turpentine*... |
21,639,396 | I have a *windows* machine setup with a something like this:
```
N:\path\to\dir\project1.git
N:\path\to\dir\running_dir
```
where `N:` is a **mapped network drive**.
I'm trying to automatically checkout `project1.git` in my `running_dir` upon pushing to `project1.git`. I have followed [this post on exporting GIT\_... | 2014/02/07 | [
"https://Stackoverflow.com/questions/21639396",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3192193/"
] | Adding absolute paths weren't working - regardless what I tried. Easily fixed by supplying a relative path to `--work-tree` though | Run bash-shell in `N:\path\to\dir\running_dir`, in which perform `pwd`.
Output of this command will be path, translated for bash |
56,044,394 | I'm trying to test a program using Python's `pathlib` module. With the `os` module, you used to be able to access networked drives by just following the same url-like form. But for some reason, you can't do this with `pathlib`. Or at least I can't figure out how to do it.
With the `os` module, all one would have to do... | 2019/05/08 | [
"https://Stackoverflow.com/questions/56044394",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10542930/"
] | The server name by itself is not a valid component of a UNC path. You must also include a share. So `path = Path('//server-01/directory', 'file')` will work. It should `resolve` and return `True` when you run `path.exists()`.
Microsoft docs here: <https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-dfsc/1... | Instantiating `path` as a `PureWindowsPath` should do the trick:
```
path = PureWindowsPath("//server-01", "directory", "file") # '\\\\server-01\\directory\\file'
``` |
9,178 | It's a homework assignment, we were asked to read, understand, and present to our colleagues a short paper/article (suggested 4-6 pages) for our Computability, Decidability or Complexity class.
The articles I was able to find in the past couple days using google scholar a way over what we were taught, plus, 50-100+ pa... | 2013/01/26 | [
"https://cs.stackexchange.com/questions/9178",
"https://cs.stackexchange.com",
"https://cs.stackexchange.com/users/6572/"
] | "By definition" recent research papers usually contain non-trivial results and they often (always?) require a deep knowledge of the argument in order to be well understood, so if you pick a paper at random you'll probably find a bunch of obscure signs in your hands :-)
So my suggestion is to look at "old" research pap... | I'd look at the "further reading" suggestions in your textbook. If the author made some effort here, the papers listed should be on-topic, important, and probably accessible. |
1,860,216 | I have an update statement that updates fields x, y and z where id = xx.
In the table I have a few different x\_created\_datetime fields (for different portions of the record that are maintained/entered by different folks). I'd like to write a single query that will update this field if is null, but leave it alone if ... | 2009/12/07 | [
"https://Stackoverflow.com/questions/1860216",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22216/"
] | You could use COALESCE() wich returns the first NON-NULL value):
```
scan_created_date = COALESCE(scan_created_date, "current_unix_timestamp")
``` | Its like equivalent to Oracle's NVL.
You can use it like below in a prepared statement using parameters
```
UPDATE
tbl_cccustomerinfo
SET
customerAddress = COALESCE(?,customerAddress),
customerName = COALESCE(?,customerName),
description = COALESCE(?,description)
WHERE
contactNumber=?
``` |
14,433,646 | I realized that `iOS` is not working on a form that you can close the application.
I work with `PhoneGap` version 2.2.0 and I do like to have my application exit button,
I thought about the possibility to **move the app to the background and back to the iPhone home page** when you click on the button to exit.
I did... | 2013/01/21 | [
"https://Stackoverflow.com/questions/14433646",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1856206/"
] | In the pattern/action language of AWK, there is an implicit action of printing of $0 when the pattern evaluates to true, but there is no explicit action described. Regarding your challenge, see this example (13 characters):
```
{$0+=$0%2+1}1
```
Hat tip to 'some guy', who was quicker on the draw to post the code tha... | Shorter by two characters:
`'{$0%2?$0+=2:$0+=1}1'`
`1` here instead of `{print $0}`. `1` is pattern, that matches any record. `{print $0}` is default action.
**Edited.** Even better ( -6 characters ):
`{$0+=$0%2?2:1}1` |
12,268 | Does the rule "Don't use the same name/word to refer to two different things" have a name, and, if so, what is that name? | 2011/10/03 | [
"https://ux.stackexchange.com/questions/12268",
"https://ux.stackexchange.com",
"https://ux.stackexchange.com/users/8779/"
] | Maybe **Terminology standardisation**?
In the book [Language, culture and communication in contemporary Europe](http://books.google.co.uk/books?id=whacJr2_JVcC&pg=PA21&lpg=PA21&dq=%22terminology%20standardisation%22&source=bl&ots=EOor-T-Z_W&sig=2VKmDN_X6dk4FkpU29LjUm01Tvk&hl=en&ei=q-OJTqmSKYGY1AW2xOgB&sa=X&oi=book_res... | One form of this two-meanings-for-same-term is known as a [synecdoche](http://en.wikipedia.org/wiki/Synecdoche), and is particularly confusing.
* Part of something is used to refer to the whole thing (*pars pro toto*), or
* A thing (a "whole") is used to refer to part of it (*totum pro parte*), or
* A specific class o... |
10,683,844 | I have used border-radius in my form field. It works fine. But the chrome it appears some line around the filed. Please refer the fiddle.
<http://jsfiddle.net/JKdzc/>
Please help me. | 2012/05/21 | [
"https://Stackoverflow.com/questions/10683844",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1101236/"
] | Are you referring to the orange highlight? If so, add this style:
```
outline:none;
``` | Chrome adds a yellow/orange **outline** when users focus on an input. Remove it like this:
```
input:focus
{
outline: none;
}
``` |
43,159,565 | I've been using the script below to download technical videos for later analysis. The script has worked well for me and retrieves the highest resolution version available for the videos that I have needed.
Now I've come across a [4K YouTube video](https://youtu.be/vzS1Vkpsi5k), and my script only saves an mp4 with 128... | 2017/04/01 | [
"https://Stackoverflow.com/questions/43159565",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3904031/"
] | In Windows you will need to right click a .py, and press Edit to edit the file using IDLE. Since the default action of double clicking a .py is executing the file with python on a shell prompt.
To open just IDLE:
Click on that. `C:\Python36\Lib\idlelib\idle.bat` | My solution to setting options and then invoking Idle on a python script is:
```
Set optn=blah
...
Set optn=blah
start pythonw C:\Users\%USERNAME%\AppData\Local\Programs\Python\Python36-32\Lib\idlelib\idle.py STFxlate.py
```
This allows you to setup the environment prior to invoking idle.
This assumes that pythonw i... |
28,327,081 | I am trying to create this interface :

And here is my actual result :

* The status bar is well transparent and we see my image as background : OK
* The action bar is not transpar... | 2015/02/04 | [
"https://Stackoverflow.com/questions/28327081",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1076026/"
] | You can change your toolbar color to transparent like this:
```
mToolbar.setBackgroundColor(getResources().getColor(android.R.color.transparent));
```
You can change it's background on the XML too:
```
android:background="@android:color/transparent"
```
Or if you're using ActionBar:
```
getSupportActionBar().set... | For API that >= 21, add to theme these lines of code
`<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">@android:color/transparent</item>`
Don't forget to add
`android:fitsSystemWindows="true"` |
11,825,718 | Could anyone please provide me with a regular expression to allow only digits (0-9) excluding even '.' (decimal point) in a textbox in JSP using javascript. I would be using it to replace the resricted characters with '' (empty string).
I tried few but they are not restricitng the DOT.
Thanks in advance | 2012/08/06 | [
"https://Stackoverflow.com/questions/11825718",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1461967/"
] | You need to [anchor](http://www.regular-expressions.info/anchors.html) the regex:
```
/^\d*$/
```
to make sure that the *entire string* consists of digits.
Without `^` and `$`, the regex would match `1` (and `234`) in `1.234`. | I would use the class `\d`, it includes only digits. If you want to replace all non-digits you would need to replace `\D+` with `""`. |
4,578,544 | So here is the problem. There is a HTML/JS code, but I can't read v3 variable. In short anything after `DDDD(D,{"COM":"lng","leaf":145,"AXIS":true});` (which is some kind of predefined random array) is unreadable(or ignored as JS code). Why? And how can i get contents of v3? Is this a javascript parse bug?
```
<html>
... | 2011/01/02 | [
"https://Stackoverflow.com/questions/4578544",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/560333/"
] | I assume that `D` and `DDDD` are defined somewhere? Your code excerpt doesn't define them. If they're defined, I'm not seeing the error; if they aren't, well, that's your problem. | When javascript gets an error in a line (depends the egine) it either breaks or fails to load entirely. And like most people already said before me, the DDDD() has to exist somewhere else is undefined. |
57,247 | Freelance based question.....
**Scenario:** A piece was designed two years ago. In the piece there are several client-supplied photographs. When the original piece was designed, the only image alterations which were made to these client-supplied photos was to extract them and remove the background. This was all built ... | 2015/07/29 | [
"https://graphicdesign.stackexchange.com/questions/57247",
"https://graphicdesign.stackexchange.com",
"https://graphicdesign.stackexchange.com/users/3270/"
] | I think it's more than fair to at least charge a 'archive retrieval' fee. It takes time to locate old work and prep it for delivery. That should be time you bill for. | if all you're doing is emailing them photos.... PLEASE don't be that petty to charge them. sure you could charge them, but little things like this is why our industry suffers the way it does with people coming through the door with a million tricks up their sleeve to screw us around somehow.
If this client RESPECTS yo... |
33,622,445 | I'm setting up SQL access in a newly created OpenEdge 11.5 database.
In checking the contents of the sysdbauth table using "select \* from sysprogress.sysdbauth", I see that there are two users setup by default: sysprogress and a user with the name of the Linux user account that was used to create the database.
I'm l... | 2015/11/10 | [
"https://Stackoverflow.com/questions/33622445",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5544954/"
] | On page 175 of the [Database Administration guide](http://documentation.progress.com/output/OpenEdge115/pdfs/dmadm/dmadm.pdf) you can read about default users and why they are created:
>
> **Tables used from SQL only**
>
>
> An SQL database administrator (DBA) is a person assigned a sysdbauth record in the database... | Yes, in fact Progress kind of expects you to do so. Create a root account and get rid of both. It's fine. |
37,958 | I understand ([ref](https://photo.stackexchange.com/questions/3435/can-i-simulate-active-d-lighting-on-post-processing)) that I can do my own post processing to get the same effect that Active D-Lighting gives.
But does the in-camera ADL get applied to the raw image data or is it only done to the accompanying jpeg (wh... | 2013/04/12 | [
"https://photo.stackexchange.com/questions/37958",
"https://photo.stackexchange.com",
"https://photo.stackexchange.com/users/8573/"
] | ADL doesn't cause any processing to happen to your RAW, but it does affect metering. If you want to replicate the effect then you can set the EC to underexpose.
But rather than just relying on metering and having the camera intentionally underexposure to prevent accidental clipping of highlights, a better approach is ... | If you are taking both jpeg and RAW, ADL will certainly give you better jpegs if you have set the ADL correctly. The RAW files are are usually unaffected, but that depends on the camera. |
116,104 | First of all, I am very new to wordpress and know almost nothing about it.
When I create the page foo using in wp-admin, I get the message that the page is created. When I click on `view page`, it 404s. I've followed the steps on <http://codex.wordpress.org/Pages#Creating_Pages>, but apparently I'm missing something.
... | 2013/09/19 | [
"https://wordpress.stackexchange.com/questions/116104",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38405/"
] | Like Manish, I think the issue is with `AllowOverride`.
The following is based on a Debian server. Ubuntu, if you are not aware, is based on Debian.
In your `apache2/` directory, you should have a `sites-available/` and a `sites-enabled/` directory.
1. Disable your site with `a2dissite`
2. Edit the appropriate fil... | 1. Delete .htaccess file
2. Go To Setting > Permalinks
3. Change your Permalinks type to anything else than current one
4. Save Changes
That will create new .htaccess, hopefully it will be formatted the way WordPress loves! |
44,838,477 | I have the following html element:
```
<a href onClick={() => fields.push()}>Add Email</a>
```
I need the href attribute so bootstrap styles the element with a link styling (color, cursor).
Problem is, if I click that now it causes the browser to redirect. How can I update the above to not redirect the browser onCl... | 2017/06/30 | [
"https://Stackoverflow.com/questions/44838477",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/149080/"
] | Add `e.preventDefault()` to onClick and add `href="#"` attribute
```
<a href="#" onClick={(e) => { e.preventDefault(); fields.push(); }}>Add Email</a>
``` | try this code;
```
<a href={undefined} onClick={() => {/*function code*/}}></a>
```
void(0) returns undefined. so you should write directly undefined on React because javascript:URL deprecated by React.
<https://reactjs.org/blog/2019/08/08/react-v16.9.0.html#deprecating-javascript-urls> |
71,414,598 | If the arguments to functions are passed by value in javascript how come the console.log() below seems to get its input by reference? Shouldn't each time it is invoked inside setTimeout just the value of i be passed and not its reference?
```js
let i;
for (i = 1; i <= 5; i++) {
setTimeout(function timer() {
con... | 2022/03/09 | [
"https://Stackoverflow.com/questions/71414598",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | >
> Shouldn't each time it is invoked inside setTimeout just the value of i be passed and not its reference?
>
>
>
Yes, and this is exactly what is happening. It is passing the value of `i` by value to `console.log(i)`. But, you're passing that value AFTER the entire `for` loop has completed when `i` has its termi... | setTimeOut is an asynchronous function. It means it won't stop execution of other synchronous code. Each Console Log will wait 1 second to execute. But as the value of i has become 6 it will print that 5 times. |
33,397,113 | I'm new to docker. I tried executing the following docker command to created a container,
```
docker run -d -p 9999:80 httpd
```
After this, when i visited the URL <http://127.0.0.1:9999/>, It loads with "It works!" message. So, to change the message, I went inside the httpd container and changed the value of /usr/l... | 2015/10/28 | [
"https://Stackoverflow.com/questions/33397113",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/698072/"
] | Here is the extension I created, first it finds sunday and then it adds one day
```
extension Date {
var startOfWeek: Date? {
let gregorian = Calendar(identifier: .gregorian)
guard let sunday = gregorian.date(from: gregorian.dateComponents([.yearForWeekOfYear, .weekOfYear], from: self)) else { re... | **Swift 4 Solution**
I have figured out according to my requirement, where I have find out dates for following.
```
1. Today
2. Tomorrow
3. This Week
4. This Weekend
5. Next Week
6. Next Weekend
```
So, I have created `Date Extension` to get Dates of *Current Week* and *Next Week*.
**CODE**
```
extension... |
355,670 | Myself and a colleague have a dispute about which of the following is more elegant. I won't say who's who, so it is impartial. Which is more elegant?
```
public function set hitZone(target:DisplayObject):void
{
if(_hitZone != target)
{
_hitZone.removeEventListener(MouseE... | 2008/12/10 | [
"https://Stackoverflow.com/questions/355670",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11911/"
] | In most cases, returning early reduces the complexity and makes the code more readable.
It's also one of the techniques applied in [Spartan programming](http://ssdl-wiki.cs.technion.ac.il/wiki/index.php/Spartan_programming):
>
> **Minimal use of Control**
>
>
> 1. Minimizing the use of conditionals by using specia... | I've had this debate with my own code over the years. I started life favoring one return and slowly have lapsed.
In this case, I prefer option 2 (one return) simply because we're only talking about 7 lines of code wrapped by an if() with no other complexity. It's far more readable and function-like. It flows top to bo... |
54,839,699 | I have two Cloudformation stacks. One of them defines the Dynamodb.
I want the second stack to use the Dynamodb referenced in the first stack. The second stack has a Lambda function which will receive dynamodb stream from stack 1.
How should I export and import dynamodb from one stack to another for Lambda stream con... | 2019/02/23 | [
"https://Stackoverflow.com/questions/54839699",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2297972/"
] | In the DynamoDB table stack, export the [`StreamArn`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping.html) attribute of the table. Use that as the value of the `EventSourceArn` to define an [EventSourceMapping](https://docs.aws.am... | If your lambda stack looks like this
```
functions:
hello:
handler: handler.hello
events:
- stream:
type: dynamodb
arn: dynamoStreamArn
```
and you want to consume the dynamoDB stream arn from the stack where dynamoDB is defined, you can use several different options.
**1. Import... |
136,466 | $T(n) = T(n/3) + T(2n/3) + n$
How can I solve this recurrence formula? | 2021/03/11 | [
"https://cs.stackexchange.com/questions/136466",
"https://cs.stackexchange.com",
"https://cs.stackexchange.com/users/132945/"
] | Look at the recursion from QuickSort for the average case:
$T(n) = T(n/2) + T(n/2) + n$
which ends up in $O (n \log n)$.
Note that $n/2 + n/2$ sums up exactly to $n$. Just like $n/3 + 2n/3$ sums up exactly to $n$. Substitute the formula for $T(n)$ in $T(n/3)$ and $T(2n/3)$ and you'll see it's the sum of $T(x)$ for f... | You can solve recurrences of this form using the [Akra–Bazzi method](https://en.wikipedia.org/wiki/Akra%E2%80%93Bazzi_method). The answer is $O(n\log n)$. |
73,735,688 | Sample output:
Rise\_ID FROM\_LOCATION TO\_LOCATION SEATS\_LEFT
SEATS\_TOTAL RIDE\_PROVIDER START\_ON ENDS \_ON IS\_STARTED IS\_FINISHED 12014 Nandi hills banglore 0 3 11002 13-Nov-20
04.00.13.36 PM. 13-Dec-20 08.02.13.36PM yes yes | 2022/09/15 | [
"https://Stackoverflow.com/questions/73735688",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20006282/"
] | Using **in** (as others have suggested) is incorrect. Because you want to check it as a prefix not merely whether it is contained.
What you want to do is use startswith() for example this:
```
list1 = []
for name in all_quads_names:
if name.startswith('qc1r'):
list1.append(name)
```
The full solution wou... | Try something like this:
```py
prefixes = ['qfg1', … ]
top = [ […], […], … ]
extracted = []
for sublist in top:
if sublist and any(prefix in sublist[0] for prefix in prefixes):
extracted.append(sublist)
``` |
43,230,303 | I have a canvas function which draws a square if I click on the canvas field and move the mouse, that works so far.
My Problem is that if I release the mouse and click at the canvas again the old drawn rectangle vanishes.
How do I make it possible that the old drawn does not get vanished.
My function:
```
function ... | 2017/04/05 | [
"https://Stackoverflow.com/questions/43230303",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7750768/"
] | The old drawn rectangle vanishes on click because, you are clearing the entire canvas each time before drawing a rectangle.
The *easiest* workaround would be to save the entire canvas as an image on mouseup and draw that image before drawing each rectangle.
```js
var canvas;
var _foo = new foo();
canvas.onmousedown... | I'm assuming that the `foo()` function is being called for every frame, either through `setInterval` or `requestAnimationFrame`. If my assumption is right, the reason why your previously drawn square disappears is because you are only storing the x and y coordinates of one rectangle, and every time you click on the can... |
57,513,230 | My goal is to export an extended class called `Entrance` without using curly brackets (Let's say `subclass`).
The problem is I can't access to the `subclass` while I'm using `default` keyword on it and the browser gives me an error such as this:
>
> Uncaught SyntaxError: Duplicate export of 'default'
>
>
>
Code:... | 2019/08/15 | [
"https://Stackoverflow.com/questions/57513230",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11414756/"
] | I adapted your project to Node.js because this is easier for testing. In the browser you can still use the .js extension but you need to reference the files as modules, not as scripts.
For Node.js use the extension .mjs for ECMAScript Modules ('import' and 'export' are a feature of ECMAScript modules).
You only need t... | The error is shown because you are exporting both Terminal and Entrance classes as default.
if you need only Entrance class from terminal.js, remove `export default` from Terminal class. |
56,164,557 | I am trying to import data from elasticsearch to sql server database, I have done import of data from sqlserver to elastic search using logstash, I reversed input and output but its throwing the error as shown in second screen:
[](https://i.stack.imgu... | 2019/05/16 | [
"https://Stackoverflow.com/questions/56164557",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1306094/"
] | I've successfully finished it. You can see my blog or the config.
blog:
[Output to SQL database by Logstash](https://datamansamxiao.wordpress.com/2019/12/25/logstash-data-output-to-sql-database/)
OK. now we need to install the “logstash" output JDBC plug-in. It’s very important if you don’t have the plug-in. Ya! You ... | The error is showing in the log
>
> Couldn't find any output plugin named 'jdbc'.
>
>
>
It is available as a community plugin, though not sure it works with Logstash 7 (yet):
<https://github.com/theangryangel/logstash-output-jdbc> |
23,414,150 | I want to verify broken links on a website and I am using this code:
```
public static int invalidLink;
String currentLink;
String temp;
public static void main(String[] args) throws IOException {
// Launch The Browser
WebDriver driver = new FirefoxDriver();
// Enter URL
... | 2014/05/01 | [
"https://Stackoverflow.com/questions/23414150",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3521843/"
] | I would keep it returning an int, and just have the MalformedURLException be a special case, returning -1.
```
public static int getResponseCode(String urlString) {
try {
URL u = new URL(urlString);
HttpURLConnection h = (HttpURLConnection) u.openConnection();
h.setRequestMethod("GET");
... | You can try below code.
```
public static void main(String[] args) {
WebDriver driver = new FirefoxDriver();
List<String> brokenLinks = getBrokenURLs(driver, "http://mayurshah.in", 2, new ArrayList<String>());
for(String brokenLink : brokenLinks){
System.out.println(brokenLink);
}
}
public static List<String> getBr... |
71,156,797 | *[This is the [Codesandbox](https://codesandbox.io/s/busy-sky-bkczeq?file=/src/Tabs.js) with all of the code that exemplifies the issue I'm having. Sorry, SO doesn't allow for proper React code with TSX, etc.]*
I have some tabs, naturally, whenever I click on each of them, my state changes (namely `selectedTab`) and t... | 2022/02/17 | [
"https://Stackoverflow.com/questions/71156797",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18232568/"
] | Well i dont know what the issue was but changing :
```
l = map(str, l)
```
to this:
```
l = list(map(str, l))
```
fixed the issue | In Python 3 [*map*](https://docs.python.org/3/library/functions.html#map) doesn't return a list. Instead, it returns an iterator object. [*pop*](https://docs.python.org/3/tutorial/datastructures.html#more-on-lists) is the method of the list object. There is no *pop* method of an iterator object, hence it's considered a... |
35,342,543 | I have a gridview that contains inventory data. I am trying to put together a search function that will create a SQL WHERE clause on the fly, based on the contents of each control in the gridview header.
Each column in the gridview is a template field, with the controls added in the Header Template.
This is my code. ... | 2016/02/11 | [
"https://Stackoverflow.com/questions/35342543",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1894918/"
] | Looks like you have to access it through the `HeaderRow` like so
```
CheckBox chkCaseSearch = gvFirearms.HeaderRow.FindControl("chkCaseSearch") as CheckBox;
``` | If you are in a web environment, did you specify the ID tag in your aspx page?
If you are in a Winform app, it will be sufficient the (for example) `this.txtMagazineSearch` invocation to access the control properties. |
1,075,997 | We have an old web app written in classic ASP. We don't have the resources to rewrite the app.
I know that asp and aspx pages can coexist in the same ASP.NET web app, but it appears as those you cannot share Application and probably Session variables across these two groups of page extension types.
I was hoping to do... | 2009/07/02 | [
"https://Stackoverflow.com/questions/1075997",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/109676/"
] | There is no straigthforwad solution for sharing session variables between classic ASP and ASP.NET. I would recommend you to persist sessions into a database, like it is described in this [Microsoft Article](http://msdn.microsoft.com/en-us/library/aa479313.aspx). This way both ASP and ASP.NET can access session variable... | You could create a simple table in your DB to store the "session" info in. Both the classic asp and the .net pages could read and write there. |
60,078,007 | I have the following query:
```
SELECT DISTINCT A + ' ' + B + ' ' + C AS 'ABC', D
FROM Table
ORDER BY A, B
```
This gives the following error message:
```
ORDER BY items must appear in the select list if SELECT DISTINCT is specified.
```
I tried changing the ORDER By to this:
```
ORDER BY A, B, C 'ABC', D
``... | 2020/02/05 | [
"https://Stackoverflow.com/questions/60078007",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11834607/"
] | Thanks to Brock's example of using "row\_number() OVER" i thought of a way to do it myself using PARTISION BY.
```
WITH ordering AS
(
SELECT
A,
B,
C,
D,
row_number() OVER
(
PARTITION BY
A,
B,
C
... | ```
SQL>create table t (id int, c1 varchar(3), c2 varchar(3));
SQL>insert into t values (1,'AX','B');
SQL>insert into t values (2,'AB','D');
SQL>insert into t values (3,'A','XB');
SQL>select concat(c1,c2) from t order by c1, c2;
======
AXB
ABD
AXB
3 rows found
```
You can see above that row 2 ... |
47,049 | I read about 2 methods for initializing WordPress function outside of WordPress files so We can use these functions on any page or website outside the WordPress blog.
Which one of these 2 methods is the correct one? What are the use cases for each method if both are correct? What is the deference between using one met... | 2012/03/27 | [
"https://wordpress.stackexchange.com/questions/47049",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/13285/"
] | wp-blog-header.php will attached a header status, it will return a http status code of 404
wp-load.php will not
Useful to note when using ajax as it checks the http status code | You don't have to call the entire theme to use functions, just use the location for wp-load.php in wordpress directory.
```
<?php
require($_SERVER['DOCUMENT_ROOT'] . '/wordpress/wp-load.php');
?>
``` |
37,629,891 | Currently I have calls like this all over my three controllers:
```
$scope.getCurrentUser = function () {
$http.post("/Account/CurrentUser", {}, postOptions)
.then(function(data) {
var result = angular.fromJson(data.data);
if (result != null) {
$scope.cur... | 2016/06/04 | [
"https://Stackoverflow.com/questions/37629891",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8741/"
] | There are a few reasons why it is good practice in non-trivial applications.
Using a single generic service and passing in the url and parameters doesn't add so much value as you noticed. Instead you would have one method for each type of fetch that you need to do.
Some benefits of using services:
* **Re-usability*... | It would make sense to have your service look like this:
```
app.factory('AccountService', function($http) {
return {
getCurrentUser: function(param1, param2) {
var postOptions = {}; // build the postOptions based on params here
return $http.post("/Account/CurrentUser", {}, postOpti... |
142,355 | Online sources show two supposedly equivalent ways to write an R linear model formula with nested factors:
```
y ~ a/b # b is nested within a
y ~ b %in% a # b is nested within a
```
Yet when you run data through lm() with these two formulas, you get very different results, as if the default contrasts are diff... | 2015/03/18 | [
"https://stats.stackexchange.com/questions/142355",
"https://stats.stackexchange.com",
"https://stats.stackexchange.com/users/71202/"
] | I think there may be a problem in some of the documentation, or at least an opportunity to make things clearer.
In the document ["An Introduction to R"](http://cran.r-project.org/doc/manuals/R-intro.pdf), the first place that we see the `%in%` term for a formula it implies that your 2 formulas give an identical resul... | Which sources? They are wrong. `a/b` is equivalent to `a + a:b` and `a + b %in% a`. |
4,500,232 | I understand why interpretation overhead is expensive, but why are JITted Python implementations (Psyco and PyPy) still so much slower than other JITted languages like C# and Java?
Edit: I also understand that everything is an object, dynamic typing is costly, etc. However, for functions where types can be inferred, ... | 2010/12/21 | [
"https://Stackoverflow.com/questions/4500232",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23903/"
] | Python is a [dynamic language](http://en.wikipedia.org/wiki/Dynamic_programming_language).
This means that much of the work that other static languages (like C# and Java) do at compile time, is done at runtime and this reduces performances.
**EDIT:**
Furthermore, JIT compiler for a dynamic language like python, ca... | >
> I understand why interpretation
> overhead is expensive...
>
>
>
Compare those Python implementations [to non-JIT **interpreted-mode Java**](http://shootout.alioth.debian.org/u32/benchmark.php?test=all&lang=javaxint&lang2=pypy) and think about your question again. |
46,949,954 | As it is said in the title I could use some help regarding a problem I have with my App.
My App scans a Barcode and offers to safe this barcode in a table together with a second String that can be put in which describes the number of times you want to save this barcode.
The customInit of the cell displays this as the... | 2017/10/26 | [
"https://Stackoverflow.com/questions/46949954",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8719318/"
] | First, find the index of the string your looking for, then remove it and insert it at the index.
```
let arr:Array = ["a","b","c"]
let indexOfA = arr.index(of: "a")
arr.remove(at: indexOfA)
arr.insert("YourString", at: indexOfA)
``` | if you only care about the duplication, why don't use Set instead of Array.
```
var barcode:Set = ["972537657","972537651","972537653"]
let result = barcode.insert("972537651")
if result.inserted {
print("insert")
}else {
print("duplication")
}
``` |
64,103,277 | I have two arrays :
```
let channelList = [
{
"channelId": 1,
"channelName": "SMS"
},
{
"channelId": 2,
"channelName": "EMAIL"
},
{
"channelId": 3,
"channelName": "ANDROID"
},
{
"channelId": 4,
"channelName": "IOS"
}
]
```
and
```
let promoList = [
{
"id": 124,
... | 2020/09/28 | [
"https://Stackoverflow.com/questions/64103277",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8643979/"
] | You can do it using `Array.filter`.
```js
let channelList = [
{
"channelId": 1,
"channelName": "SMS"
},
{
"channelId": 2,
"channelName": "EMAIL"
},
{
"channelId": 3,
"channelName": "ANDROID"
},
{
"channelId": 4,
"channelName": "IOS"
}
]
let promoList = [
{
"id": 1... | Extract the items of one of the arrays into a string array.
```js
let channelList = [
{
"channelId": 1,
"channelName": "SMS"
},
{
"channelId": 2,
"channelName": "EMAIL"
},
{
"channelId": 3,
"channelName": "ANDROID"
},
{
"channelId": 4,
"channelName": "IOS"
}
]
let promo... |
41,772 | Sometimes, some of the employees over perform while others perform very badly.
for those who work very hard, **thank you letters and raises** are motivations for them.
As CTO, I have a case that one of my senior staff members is not performing well. I have had a one-to-one meeting with him, I sent him encouraging emai... | 2015/02/22 | [
"https://workplace.stackexchange.com/questions/41772",
"https://workplace.stackexchange.com",
"https://workplace.stackexchange.com/users/32272/"
] | Praise in public, punish in private, for anything short of an immediate-firing offense. | I am writing this on the assumption that you are the line manager. If you are not then the correct thing to do is feed back your concerns to them initially and if that doesn't elicit a satisfactory response, to their line manager.
>
> i tried to discuss it with him by one-to-one meeting, by encouragement email, and f... |
3,187 | I understand, and practice, [bear-safe rules](https://outdoors.stackexchange.com/questions/225/what-precautions-should-i-take-to-protect-myself-and-my-camp-from-bears) like [hanging (or canister-ing)](https://outdoors.stackexchange.com/questions/86/bear-bags-vs-bear-canisters-which-is-better) during summer months, but ... | 2012/11/10 | [
"https://outdoors.stackexchange.com/questions/3187",
"https://outdoors.stackexchange.com",
"https://outdoors.stackexchange.com/users/86/"
] | Bear canister rules are often relaxed in the winter. However, this will depend on where you are camping. On the east coast, in the Adirondacks, the rule is:
>
> NYSDEC Regulation Requires The Use of Bear Resistant Canisters by
> Overnight Users in The Eastern High Peaks Wilderness Between April 1
> And November 30.... | I would suggest following the bear rules year round. In the Canadian Rockies, we still have areas closed due to bear activity in the middle of January. Plus ravens will make short work of anything left accessible, not to mention worrying about attracting cougars and wolves.
Here's a couple links outlining safety for c... |
20,251,162 | I have seen numerous posts on how to display progress bar while the data loads in the background. All suggestions requires we manually place a ProgressBar in the layout xml and then use an `AsyncTask` to show and hide the ProgressBar and the View in question.
However, I would like to make a generic class which creates... | 2013/11/27 | [
"https://Stackoverflow.com/questions/20251162",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/137893/"
] | The PhotoImage method creates an image for the first TK () instance created.
Thus, it seems to have solved to inherit TK () instance by replacing TopLevel ().
This can be solved by specifying the master of the Tk () instance as the option of PhotoImage.
I think this should be changed.:
```
splsh_img = tkinter.PhotoI... | Maybe not for this exact case, but for a similar one, I found that the customary
```
if __name__ == '__main__':
wlcm_scrn() #Call through procedure.
```
solves the problem as well.
This seems to kill the active window and to create a new one each time you re-call the same module. |
9,512,695 | In PHP
If you had an array of one million integers, how would you go to print each integer that contain the number seven(eg..7,17,67..) with out using a loop? | 2012/03/01 | [
"https://Stackoverflow.com/questions/9512695",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/847085/"
] | Try with:
```
function sevens($var) {
return strpos($var, '7') !== false;
}
$input = array( /* one million integers */ );
$output = array_map($input, 'sevens');
``` | I think you can just do
```
WHERE intVal LIKE '%7%'
```
and the integer will automatically be cast to a string. It is worth a go, anyway. |
59,053,189 | When I label images or text for Machine Learning purposes, I often export the results in a `json` format. Then, I can open it in `vim` and simply pretty print using
```
:execute '%!python -m json.tool'
```
I often add `| w` which automatically writes changes to the file.
Is there a way to reverse this process? To c... | 2019/11/26 | [
"https://Stackoverflow.com/questions/59053189",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4723795/"
] | There is no tool that takes a SAS program or step and compiles it into a separate .exe or .dll.
If you are working at a company that has a SAS Server installed you can published your code as a stored process, and other users can run the stored process through a browser when they are logged into the SAS Server.
You ca... | You probably still want to use "a statistics-oriented language," and one possibility that occurs to me is the open-source language **"R."**
<https://en.wikipedia.org/wiki/R_(programming_language)>
Now, this is not a direct "answer" to your question but it might be a pointer in a viable direction. "R" is specifically ... |
1,063 | Which one is correct?
>
> A partir de ahora, voy a hablar en español.
>
>
>
or
>
> Desde ahora, voy a hablar en español.
>
>
>
In meaning I think both are close to "from." Are there any specific instances where one cannot replace the other. | 2011/12/21 | [
"https://spanish.stackexchange.com/questions/1063",
"https://spanish.stackexchange.com",
"https://spanish.stackexchange.com/users/359/"
] | **RAE**:
>
> **partir**:
>
>
> intr. Tomar un hecho, una fecha o cualquier otro antecedente como base para un razonamiento o cómputo.
>
>
> **desde**:
>
>
> prep. Denota el punto, en tiempo o lugar, de que procede, se origina o ha de empezar a contarse una cosa, un hecho o una distancia. Desde la Creación. Desd... | Desde works nearly everywhere, but a partir de only really works with sustantives.
* Desde que te fuiste, nada es lo mismo, you can't really say "a partir de que te fuiste" (I think it's strictly correct, but it screeches), although you could say "A partir del día que te fuiste"
"A partir de" is used frequently for r... |
1,747,744 | We have a large MFC/C++ Visual Studio 2005 solution which currently consists of two projects:
* Code (around 1500 .h/.cpp files, linked dynamically to MFC)
* Resource DLL (we translate the resources using an external tool)
What options do we have (lib, dll, ...)?
Where do we start?
Is there a technical sample of t... | 2009/11/17 | [
"https://Stackoverflow.com/questions/1747744",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/54159/"
] | This depends very much on the quality of you codebase. If you have nicely encapsulated classes/components that interact through well defined interfaces, it should not be to hard to seperate those into different projects.
Also, before you start, think about what you want to achieve. Are there reusable or platform depend... | MFC this or not you have to start from extracting business logic from GUI handlers. Once you done this you can put them inside alib. |
5,041,498 | May you please help me on this: I developed a web application that has Checkboxes and i want to show some controls when the user tick the box and hide them when the user untick the box. I only managed to do the showing part when the user tick the box, now i'm failing to hide them when the user untick the box.
Here is ... | 2011/02/18 | [
"https://Stackoverflow.com/questions/5041498",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/621381/"
] | You need to set the `Visible` property to the checkbox's `Checked` property. | ```
protected void chkboxMentor_CheckedChanged(object sender, EventArgs e)
{
if(chkboxMentor.Checked)
{
lblMentorName.Visible = true;
txtMentorName.Visible = true;
lblMentorStuff.Visible = true;
txtMentorStaffNo.Visible = true;
lblMentorDate.Visible = true;
bt... |
45,594,707 | I've recently seen the `--no-cache-dir` being used in a Docker file. I've never seen that flag before and the help is not explaining it:
```
--no-cache-dir Disable the cache.
```
1. Question: **What is cached?**
2. Question: **What is the cache used for?**
3. Question: **Why would I want to disable it?... | 2017/08/09 | [
"https://Stackoverflow.com/questions/45594707",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/562769/"
] | 1. **Cached is**: store away in hiding or for future use
2. **Used for**
* store the installation files(`.whl`, etc) of the modules that you install through pip
* store the source files (`.tar.gz`, etc) to avoid re-download when not expired
3. **Possible Reason** you might want to disable cache:
* you don't have spa... | Another reason to disable the pip cache - if you run pip as a user that does not yet exist, their home directory will be created, but owned by root.
This happens to us when building Amazon AMIs in a chroot - pip is being run as a user that exists on the builder machine, but not in the chroot jail where the AMI is bein... |
31,945,632 | I have a problem I'm not quite sure how to approach. I have a template that will render a section of text that will itself contain a template tag to be dynamically updated.
```
<ul>
{% for section in sections %}
<li>{{ section.content | safe }}</li>
{% endfor %}
</ul>
```
will render:
```
{{ document.custom... | 2015/08/11 | [
"https://Stackoverflow.com/questions/31945632",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3250984/"
] | The `Object3D` class has a property `userData` where you can *safely* add custom data.
Since the `Mesh` class is derived from `Object3D`, it has that property, too.
Use it like so:
```
mesh.userData.name = "TheName";
```
three.js r.71 | Its still JavaScript so you can add a custom object to the mesh:
```
var building = new THREE.Mesh( [...] );
building.info = { name: "myHouse", lat: 48.12, lng: 8.54, [...] };
console.log( building.info.name ); //myHouse
``` |
11,552,732 | I am trying to accomplish something like this:
I am creating a simple blog. I have set up categories for my blog.
I want that when my user goes to posts/index, he sees a list of all categories.
Example:
Text
Image
Upon clicking on a category, my user gets redirected to the posts/new page, where the category\_id fiel... | 2012/07/19 | [
"https://Stackoverflow.com/questions/11552732",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/731882/"
] | Among some professionals, the single common lookup table is a design error you should avoid. At the very least, it will slow down performance. The reason is that you will have to have a compound primary key for the common table, and lookups via a compound key will take longer than lookups via a simple key.
According ... | You can store them in a text search (ie nosql) database like [Lucene](http://lucene.apache.org). They are ridiculously fast.
I have implemented this to great effect. Note though that there is some initial setup to overcome, but not much. Lucene queries on ids are a snap to write. |
179,270 | I'm trying to set up an ssh tunnel layout where:
1. client A (not ssh-server enabled) initiates ssh connection to server S
2. socks server is opened on server S:yyyy that tunnels all data via client A
3. client B connects socks server on server S, and tcp data routes via client A to the Internet
A possible solution w... | 2015/01/15 | [
"https://unix.stackexchange.com/questions/179270",
"https://unix.stackexchange.com",
"https://unix.stackexchange.com/users/99373/"
] | Don't know whether this helps anyone, here is a diagram for my setup that I managed to construct...
[](https://i.stack.imgur.com/PM6gQ.png)
You will see two processes on MACHINE\_B:
The SSH client connection to MACHINE\_A (olive):
```
ssh... | This is quite straightforward.
On local side (Server S), start your openssh server server. This will start ssh server by default on port 22 - you could change this port in /etc/ssh/sshd\_config file, if necessary.
```
service ssh start
```
On remote side (Client A), start a socks proxy AND set a remote port on t... |
4,635,579 | I want to include the latest news as part of my application, does anybody know any news APIs or sites where they say you can use their news for your app? | 2011/01/08 | [
"https://Stackoverflow.com/questions/4635579",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/561395/"
] | There is a plenty of RSS reader samples on the internet, for Mac OS X or iPhone. You can use custom XML parser or JSON. Check github for samples. | If you want stock news specifically I suggest IEX, Alphavantage or [stocknewsapi](https://www.stocknewsapi.com) I personally use stock news api as it is the most relevant and the images are great quality. Hope this helps! |
6,457,546 | How can i make my laptop to act as a multicast router.
I need to stream video content to other computers with in same network. How can i make my laptop to work as a multicast router. | 2011/06/23 | [
"https://Stackoverflow.com/questions/6457546",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/773054/"
] | If your functions all share the `currentSocket` global variable (and if you can't change them), it is not possible to have multiple connections (as long as the functions are async). If you could change them it would be best just to pass the socket as first parameter to your functions. Another way is to move the definit... | If you want to wrap an established method in JS the way to do it is by renaming & replacing.
e.g.
```
Array.prototype._toString = Array.prototype.toString;
Array.prototype.toString = function(){ return "wrapped["+this._toString()+"]"; };
console.log(["1","2","3"].toString());
```
I'd suggest applying that to you... |
320,049 | I have a Lenovo X201s with i7 L620 @ Ghz and 4Gb Ram
Windows 7 Professional 64bit is installed on it and
all 4Gb is visible from task manager and all other system tools
Virtual memory is set manually for initial 4096Mb and max 8192Mb
There is 22Gb free space on the one and only local disk where its configured.
When m... | 2011/08/07 | [
"https://superuser.com/questions/320049",
"https://superuser.com",
"https://superuser.com/users/89772/"
] | 1. Yes this is normal.
2. If you really want to you can 'fix' this by disabling the page file. There are no good reasons to do that in your situation (and some would argue in any situation), so just leave it alone. | With certain kind of usage patterns it's very much possible to just run out of memory if you have only 4G. Lots of tabs open in browsers, office applications, Photoshop etc use quite a lot of memory these days. |
11,987,289 | When my app receives a notification it handles it like this opening a specific view:
```
UILocalNotification *localNotif = [launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey];
if (localNotif) {
NSLog(@"Recieved Notification didFinishLaunchingWithOptions %@",localNotif);
... | 2012/08/16 | [
"https://Stackoverflow.com/questions/11987289",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/387184/"
] | I found this to access the top most window/view:
```
[[[UIApplication sharedApplication] keyWindow] addSubview:someView]
``` | ```
- (void)applicationDidEnterBackground:(UIApplication *)application{
saveIndex = self.tabBarController.selectedIndex //shows the current index of the viewController of the Array of the tabBarController
//add some stuff to save the integer}
```
You could save this integer when the User quits the App and aft... |
2,111,610 | I just noticed that Intellij has a UML diagram drawer. I am attempting to use it to figure out what is going on in some code that is new to me.
Is there anyway to show the dependencies between all of the classes/interfaces on the screen? Is this a useful feature? It seems to be missing somethings but it might just be... | 2010/01/21 | [
"https://Stackoverflow.com/questions/2111610",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/251589/"
] | Streams are generally quite safe. Under some circumstances, they can be slow and/or clumsy. Slow, mostly stems from the fact that they impose a few extra layers between your code and the OS, and under the wrong circumstance those layers can add overhead. The clumsiness is mostly in comparison to C's printf, not direct ... | There are three alternatives you've mentioned here:
1. C++ streams (ostream, istream, fstream)
2. C stdio (printf, sprintf fprintf)
3. Windows files (ReadFile, WriteFile)
Options 1 & 2 are platform independant. This means you can compile the code for mac, linux, or many other operating systems. Option 3 is Windows o... |
9,780,333 | I'm getting confused about the various options in the [twitter bootstrap grid](http://twitter.github.com/bootstrap/scaffolding.html%5C), and how they go together.
To begin with, you can have an ordinary fixed `container`, or a `container-fluid`.
Then either one can include either an ordinary `row`, or a fluid row, ... | 2012/03/20 | [
"https://Stackoverflow.com/questions/9780333",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/307106/"
] | Interesting discussion. I was asking myself this question too. The main difference between fluid and fixed is simply that the fixed layout has a fixed width in terms of the whole layout of the website (viewport). If you have a 960px width viewport each colum has a fixed width which will never change.
The fluid layout ... | you may use this - <https://github.com/chanakyachatterjee/JSLightGrid> ..JSLightGrid. have a look.. I found this one really very useful. Good performance, very light weight, all important browser friendly and fluid in itself, so you don't really need bootstrap for the grid. |
31,266,953 | I have included given code in my en-US.yml
```
en-US:
date:
formats:
default: "%m-%d-%Y"
long: "%B %d, %Y"
short: "%b %d"
```
and I want to show format short so for this I have given
```
@title= I18n.l (Time.now, format: :short)
```
its not working it gives me
>
> syntax er... | 2015/07/07 | [
"https://Stackoverflow.com/questions/31266953",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2739770/"
] | This cannot be done directly in C#.
You can however implement it in verifiable CIL:
```
.method public hidebysig static bool Test<T>(!!T& a, !!T& b) cil managed
{
.maxstack 8
ldarg.0
ldarg.1
ceq
ret
}
```
**Tests**
```
int a = 4, b = 4, c = 5;
int* aa = &a; // unsafe needed for this
object o = a, p =... | >
>
> >
> > I know, that int is a value type but here it should pass references to the same object.
> >
> >
> >
>
>
>
Yes, the reference passed to the method are the same, but they are boxed *(converted to object/reference type)* in the `ReferenceEquals` method.
That is why the result of your test returns f... |
3,721,999 | Following code is an example of text placed into a textarea from a database.
```
<textarea id="inputPane" cols="80" rows="40" class="pane">
<p>
some text here...
</p>
<p>
more text here...
</p>
</textarea>
```
using jQuery's .trim what is the actual jquery code to remove all leading and trailing whitespace... | 2010/09/15 | [
"https://Stackoverflow.com/questions/3721999",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/335603/"
] | You could try something like this:
```
jQuery(function($) {
var pane = $('#inputPane');
pane.val($.trim(pane.val()).replace(/\s*[\r\n]+\s*/g, '\n')
.replace(/(<[^\/][^>]*>)\s*/g, '$1')
.replace(/\s*(<\/[^>]+>)/g, '$1'));
});
```
Which gives the ... | Try this:
```
var $input = $('#inputPane');
var $container = $('<div>').html( $input.val() );
$('*', $container).text( function(i,txt) {
return $.trim( txt );
});
$input.val( $container.html() );
```
It turns the content of the `textarea` into elements, walks through them and trims the content, then inserts t... |
586,984 | ```
\documentclass{article}
\usepackage[left=3cm,right=2cm,top=2cm,bottom=2cm]{geometry}
\usepackage{listings}
\lstset{basicstyle=\ttfamily\footnotesize,breaklines=true,numbers=left,mathescape}
\begin{document}
\begin{lstlisting}
clear all;
clc;
j=1;
if j~=1
fprintf('j not equal to 1\n');
end
\end{lstlisting}
\end{... | 2021/03/12 | [
"https://tex.stackexchange.com/questions/586984",
"https://tex.stackexchange.com",
"https://tex.stackexchange.com/users/163815/"
] | In fact the solution comes from <https://tex.stackexchange.com/a/130513/231952>, but it is part contained in a comment, so I thought it appropriate to summarize it here. (Other solutions here: [How to insert a nice tilde in a lstlisting?](https://tex.stackexchange.com/questions/17266/how-to-insert-a-nice-tilde-in-a-lst... | THIS?
```
\documentclass{article}
\usepackage[left=3cm,right=2cm,top=2cm,bottom=2cm]{geometry}
\usepackage{listings}
\lstset{basicstyle=\ttfamily\footnotesize,breaklines=true,numbers=left,mathescape}
\usepackage{url}
\usepackage{listings}
\lstset{literate={~}{{\raisebox{-.25em}{\textasciitilde}}}{1}}
\begin{document}
... |
33,695,850 | Given two strings `str1` and `str2` as input, I need to determine whether `str2` occurs within `str1` or not.
Examples:
* Input #1: `occurs("JavaLadders","Java")`
* Output #1: `true`
* Input #2: `occurs("Problem Panel","Panes")`
* Output #2: `false`
In my function I took 2 Strings. In for loop I am checking each cha... | 2015/11/13 | [
"https://Stackoverflow.com/questions/33695850",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5294872/"
] | Your `else if(count==l2)` statement is in a wrong place. In your code, this condition does not check when `ch1 == ch2`. The following may help you:
```
public boolean occurs(String str1, String str2) {
int l1=str1.length();
int l2=str2.length();
int p=0;
int count=0;
int j=0;
for(;j<l1;j++) {
... | There are plenty of things wrong with your code. However, I recommend using one of the built-in string functions that Java provides, like String.indexOf() or String.contains().
* If the first character doesn't match, you return either true or false.
* You don't have a return statement in your method (it shouldn't comp... |
25,673,599 | I'm making a calendar with events in Codeigniter, so I want do build a list of this events sorted by month and year.
In database, I have the list of events and I want to retrieve then by the field date, that uses the DATE datatype.
```
if($year != null and $month != null)
{
$this->db->where('date', '?... | 2014/09/04 | [
"https://Stackoverflow.com/questions/25673599",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3207788/"
] | Assuming that `$this->db->where()` makes a `AND field = value` try this.
```
$this->db->where("DATE_FORMAT(date,'%d')", $month);
$this->db->where("DATE_FORMAT(date,'%Y')", $year );
```
The `DATE_FORMAT()` function is a MYSQL function for manipulating/formating dates so this should equate to
```
WHERE
DATE_FOR... | That query should solve your problem!
```
SELECT * FROM table_name WHERE data_field_name >='01/10/2000'
```
or
```
SELECT * FROM table_name WHERE data_field_name between '01/01/2009' and '01/01/2010'; //FOR YEAR
```
or
```
SELECT * FROM table_name WHERE data_field_name between '01/01/2009' and '01/02/2009'; //F... |
36,722,987 | Im working on webpage that should average values in a given column based on the current year.
Ive got the following code:
```
public function getElecReadings(){
try {
$stmt = $this->dbconn->prepare("SELECT AVG(ElecUsage), DateAdded FROM elec_readings WHERE AccountNumber = '" . $_SESSION['user_ses... | 2016/04/19 | [
"https://Stackoverflow.com/questions/36722987",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1332088/"
] | You basically answered the question yourself:
```
$year = date("Y");
$year = "$year%";
$stmt = $this->dbconn->prepare("SELECT AVG(ElecUsage), DateAdded FROM
elec_readings WHERE AccountNumber = '" . $_SESSION['user_session'] . "'
AND DateAdded LIKE '$year'");
```
That will extract all the account numbers where the... | **its about your query. You have to select avg from the table where year(date) = 'current\_year'**
so your code could be like this :
```
public function getElecReadings(){
try {
$current_year = date('Y');
$stmt = $this->dbconn->prepare("SELECT AVG(ElecUsage),
DateAdded FRO... |
21,782,893 | I'm using the date filter to render a unix timestamp in a certain format. I've noticed the filter adds the local timezone to the output.
Is there any way to simply output the exact timestamp, without adding any timezone information?
Input:
```
talk.content.date_and_time = 1400167800
```
(is 05 / 15 / 14 @ 3:30:00... | 2014/02/14 | [
"https://Stackoverflow.com/questions/21782893",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/453746/"
] | Since version `1.3.0` AngularJS introduced extra filter parameter `timezone`, like following:
```
{{ date_expression | date : format : timezone}}
```
But in versions `1.3.x` only supported timezone is `UTC`, which can be used as following:
```
{{ someDate | date: 'MMM d, y H:mm:ss' : 'UTC' }}
```
Since version `... | The 'Z' is what adds the timezone info. As for output UTC, that seems to be the subject of some confusion -- people seem to gravitate toward [moment.js](http://momentjs.com/).
Borrowing from this [answer](https://stackoverflow.com/questions/948532/how-do-you-convert-a-javascript-date-to-utc#answer-6777470), you could... |
3,700,113 | In the past, I've only developed Java applications. This is my first time attempting an actual web app on my own, so pardon the painfully rookie question.
Should I add the **WEB-INF/web.xml** file to version control? It appears to be a generated file, so my instinct is to add it to the ignore list, but I thought I'd a... | 2010/09/13 | [
"https://Stackoverflow.com/questions/3700113",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/164958/"
] | Generally, `web.xml` should be under version control. And it is not usually generated.
If you are using some "clever" utility to generate the web.xml, then don't put it in version control. But:
* your build process should include the generation as well - your app won't run without this file
* I'd advise against web.x... | it should be. it is where you do configure your web application. |
1,319,129 | i have tried to open some JPEG files in Delphi with TImage component. i also added the Jpeg unit. i can open most of jpg files and there is no problem.
but when i try to open some JPGs, the program just throw an exception.
i also tried to load that images in design mode, but there is some problem. in design mode the... | 2009/08/23 | [
"https://Stackoverflow.com/questions/1319129",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/161640/"
] | The reason you may be encountering this problem is due to the file type. Delphi has issues displaying JPEG images that have been encoded using CMYK, rather than the default RGB encoding. CMYK is a format that is generally used for Print design, try and always encode your images to RGB format to avoid this issue with De... | Check out the Free Image library for alternative JPEG support in Delphi if the native one has problems. Free Image is an open source lib that lets you work with JPEG/PNG/... from Delphi/BCB/and others. Very nice library IMHO.
<http://freeimage.sourceforge.net/> |
592,378 | I am working on a project where I need to drive two LEDs on a PCB (= PCB\_LED) which is 1 meter away from another PCB (= PCB\_MCU).
The PCB\_MCU includes a microcontroller with two LED drivers. Each LED driver is a constant current buck driver. Its output current depends on what the MCU asks it to output. The LED driv... | 2021/10/27 | [
"https://electronics.stackexchange.com/questions/592378",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/294827/"
] | **This is supposed to be a comment but got too long, so I decided to put as an answer.**
What I understood is, you have two PCBs, one having only the LEDs and the other having the MCU and the respective LED drivers for LEDs. So the LED drivers' outputs go to LEDs through a 1-m-long cable. *It is more preferable to see... | Instead of a common VCC wire, consider a separate VCC for each LED. In this case the return current in each VCC wire will exactly match the current in its associated PWM wire, but in the opposite direction of course. Now the EMI can be greatly reduced by using twisted pairs of wire. Cat5 or Cat6 communication cable is ... |
56,427,934 | For app development I download and installed Flutter sdk along with its dependencies Android studio, Java. After installing all I came to an error
for checking `flutter doctor`. The following error came:
```
Android toolchain - develop for Android devices (Android SDK version 28.0.3)
X Android license stat... | 2019/06/03 | [
"https://Stackoverflow.com/questions/56427934",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11593251/"
] | My first choice would be a `std::variant` (it is better then `std::optional` since it can provide extra information in case of error and this is always beneficial in the future):
```
usign ErrorType = int;
using ReturnType = std::variant<std::vector<int>, ErrorType>
ReturnType function() {
std::vector ans;
/... | You can use `std::optional` for it. |
1,949,592 | I have a query like the following:
```
SELECT t1.v3, t2.v2
FROM t1
INNER JOIN t2
ON t1.v1 = t2.v1
WHERE ISNULL(t1.DeleteFlag,'N') = 'N'
```
I have an index in place that I think should result in there being an Index Seek for the `= 'N'` part but instead I am seeing a very expensive Index Scan. Is it possible that th... | 2009/12/22 | [
"https://Stackoverflow.com/questions/1949592",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/226897/"
] | Yes, any function calls in your WHERE clause will likely make the index useless. Try to rewrite it so that the index can be used:
```
SELECT t1.v3, t2.v2
FROM t1
INNER JOIN t2
ON t1.v1 = t2.v1
WHERE NOT t1.DeleteFlag = 'Y'
```
The index makes sense if the number of results you expect from the query is much smaller t... | 1) Does use of ISNULL turn a Seek into a Scan? Yes. Applying a function to a column in general makes the expression non SARG-able (not searchable). In order for an index to be considered for a Seek operation the engine needs to know what value to seek for, as a raw binary value. As soon as you apply a function to the c... |
73,220,323 | I want to extract two pieces of information from a list of filenames using regex.
The two numbers are always located just before the file extension and separated by a dash.
In the example filename below, I would aim for 10 and 11.
To get the digit just before the extension (so 11 in the example), I am using `\d+(?=.raw... | 2022/08/03 | [
"https://Stackoverflow.com/questions/73220323",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12296100/"
] | The current latest version of `hiredis` 2.0 [provides](https://pypi.org/project/hiredis/2.0.0/#files) wheels for Python 3.6-3.9 but not 3.10 or later. Use lower version of Python.
Or install Microsoft Visual C++ 14.0 to compile C/C++ extensions. | The current version of redis does not support Python 3.10
Try using lower versions of python |
177,980 | My supervisor started the e-mail thread of welcoming me to the team/department. Several team members has already replied (including the boss of my supervisor so I'm extra nervous) with a brief but warm welcome message. I was wondering what is the best way to reply in this thread.
This is my first fully remote role so ... | 2021/08/30 | [
"https://workplace.stackexchange.com/questions/177980",
"https://workplace.stackexchange.com",
"https://workplace.stackexchange.com/users/129196/"
] | >
> Would a short reply like "Thanks for the warm welcome, I'm excited to be working with everyone and I'm looking forward meeting you in the upcoming weeks."
>
>
>
Yes
>
> Should I be adding my professional background/main tasks of my role/hobbies/etc. ?
>
>
>
No.
That type of detail is "need/reason to kno... | >
> "Thanks for the warm welcome, I'm excited to be working with everyone and I'm looking forward meeting you in the upcoming weeks."
>
>
>
Your suggested reply is perfect. Stop fretting. |
1,692,206 | For brushing up my C, I'm writing some useful library code. When it came to reading text files, it's always useful to have a convenient tokenization function that does most of the heavy lifting (looping on `strtok` is inconvenient and dangerous).
When I wrote this function, I'm amazed at its intricacy. To tell the tr... | 2009/11/07 | [
"https://Stackoverflow.com/questions/1692206",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8206/"
] | You don't need to strdup() each token; you duplicate the input string, and could let strtok() chop that up. It simplifies releasing the resources afterwards, too - you only have to release the array of pointers and the single string.
I agree with those who say that you need a function to release the data - unless you ... | Just a few things:
1. Using gotos is not intrinsically evil or bad, much like the preprocessor, they are often abused. In cases like yours where you have to exit a function differently depending on how things went, they are appropriate.
2. Provide a functional means of freeing the returned array. I.e. tok\_free(pointe... |
7,340 | I sync email, contacts and calendar to my company's Exchange server. This morning all of my contacts are gone from my iPhone (iPhone 4, iOS 4.2.1). Facts that further explain:
* My contacts were good last night
* I haven't synched to my computer, updated any apps or changed any settings since then
* I'm getting email ... | 2011/01/30 | [
"https://apple.stackexchange.com/questions/7340",
"https://apple.stackexchange.com",
"https://apple.stackexchange.com/users/283/"
] | Maybe you've already tried this but I'll suggest it anyway.
Check Groups
------------
1. Open Contacts
2. Tap the arrow in the upper-left corner labelled Groups if it exists.
3. Ensure you have selected the right group of contacts.
Try Re-Sync
-----------
If you need to re-sync because the above did not work you co... | Above trick worked perfectly for my iPhone 5S. Thank you very much. After my new carrier asked me to reset ALL on my phone, I had lost everything, Google contacts, emails, etc.
If you need to re-sync because the above did not work you could try this:
Open the Settings app
Open the Mail settings. (This is listed as Ma... |
38,376,015 | So im trying to figure out if I can pass a intent extra from a custom adapter to an activity which then passes that intent extra to another activity?
Is something like that possible or is there a better way to do what I want to do? | 2016/07/14 | [
"https://Stackoverflow.com/questions/38376015",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5418948/"
] | ```
Activity A:
Intent intent = new Intent(A.this, B.class);
intent.putExtra("someString", "string");
startActivity(intent):
Activity B:
onCreate(...) {
String myString = getIntent().getStringExtra("someString");
MyAdapter myAdapter = new MyAdapter(B.this, myString);
}
MyAdapter :
Context myContext;
String myStrin... | I assume, that you know how to send intent extras to an activity. And what you are looking for is a way to forward that same intent to another activity. You can do it like this:
```
Intent intent = new Intent(this, SecondActivity.class);
intent.putExtras(getIntent());
``` |
53,608,819 | I just updated my android studio to version 3.2.1 and also updated my gradle via android studio to latest version, but building project faces this error:
>
> Android resource compilation failed Output:
> D:\projects\myProject\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:2577:... | 2018/12/04 | [
"https://Stackoverflow.com/questions/53608819",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9850245/"
] | In my case the problem was that I forgot to escape an apostrophe sign within an item of a `StringArray`.
So in my `strings.xml` I changed
```
<string-array name="questions">
<item>What's the weather today?</item>
</string-array>
```
to
```
<string-array name="questions">
<item>What\'s the weather today?</i... | Try to add
```
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.71'
```
inside project level gradle dependencies, and then add
```
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.2.71'
```
inside your app level gradle.
Maybe one of your libraries require kotlin plugin. |
29,923,370 | I have an issue with the following hierarchy in scala:
```
class ScalaGenericTest {
def getValue[A, B <: Abstract[A]](clazz: B): A = clazz.a
def call: String = {
val sub: Subclass = new Subclass
getValue(sub)
}
}
class Subclass extends Abstract[String] {
def a: String = "STRING"
}
abstract class Abs... | 2015/04/28 | [
"https://Stackoverflow.com/questions/29923370",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4842531/"
] | It's a limitation in Scala's type inference. The issue is described in [SI-2272](https://issues.scala-lang.org/browse/SI-2272) (the example there uses implicits, but the same error occurs when using it explicitly). It's been closed as **won't fix**.
In that issue, Adriaan Moors advises to avoid constraints that have t... | As addition to Justin's and m-z's answers, another way to make similar declaration keeping two type parameters:
```
def getValue[A, B](clazz: B)(implicit evidence: B <:< Abstract[A]): A = clazz.a
``` |
24,214,224 | Using STS, if I import the `"Rest Service"` Getting Started project using the latest Spring Boot and choose `"Run As Spring Boot App"`, it starts up, then immediately shuts down.
Looking at the debug logs, Spring is for some reason deciding the project is not a web application, but I have no idea why.
If I switch f... | 2014/06/13 | [
"https://Stackoverflow.com/questions/24214224",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/780271/"
] | Just add
```
spring.main.web-environment=true
```
in application.properties and restart. | In addition, you should check that you have at least one rest controller in your app (@RestController) and make sure you compile with `spring-boot-starter-tomcat`
```
providedRuntime ('org.springframework.boot:spring-boot-starter-tomcat')
``` |
1,250,933 | Let $V$ be a finite-dimensional vector space and let $W\_{1}, W\_{2}$ be subspaces of $V$. If $\dim (W\_{1} \cap W\_{2}) = \dim W\_{1}$, must $W\_{1} \subset W\_{2}$?
Since $\dim (W\_{1} \cap W\_{2}) = \dim W\_{1},$ every basis $\alpha \subset W\_{1} \cap W\_{2}$ has the same number of vectors as every basis $\beta \s... | 2015/04/25 | [
"https://math.stackexchange.com/questions/1250933",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/155328/"
] | Hint: if $A \subset B$ are vector spaces with $\dim A = \dim B < \infty$ then $A = B$ | No need to reason about bases here. The intersection $W\_1\cap W\_2$ of two subspaces is always a subspace of $W\_1$ (and also of $W\_2$ but that won't be used here). If in addition it has the same (finite) dimension as $W\_1$, then it must be all of $W\_1$, that is $W\_1\cap W\_2=W\_1$. But that means that $W\_1\subse... |
21,386 | Do you honor [Programmers' Day](http://programmerday.info/FAQ.html "They speak English in 'What'?!"), the 256-th day of the year?
It'll fall on 13 September this year, being a non-leaping one and all that jazz. | 2009/09/11 | [
"https://meta.stackexchange.com/questions/21386",
"https://meta.stackexchange.com",
"https://meta.stackexchange.com/users/-1/"
] | No. I use a 0-based index for my days, so I celebrate Day 255. | Programmers day only exists one time in history: October 10th, 2010. Or in binary form 101010. It's quite simply the ultimate answer. |
30,109,554 | I have a tsv, file1, that is structured as follows:
```
col1 col2 col3
1 4 3
22 0 8
3 5
```
so that the last line would look something like `3\t\t5`, if it was printed out. I'd like to replace that empty string with 'NA', so that the line would then be `3\tNA\t5`. What is the easiest way t... | 2015/05/07 | [
"https://Stackoverflow.com/questions/30109554",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2516989/"
] | In these [docs](http://guides.rubyonrails.org/association_basics.html) you have:
>
> When are Objects Saved?
>
>
> When you assign an object to a has\_and\_belongs\_to\_many association, that object is automatically saved (in order to update the join table). If you assign multiple objects in one statement, then the... | I know that this is a pretty old question, but I found a solution that works perfectly for me and hope it could save time to someone else:
```
class A
has_many :bs, class_name 'B'
end
class B
belongs_to :a, class_name: 'A'
end
a.bs.target.clear
new_bs.each {|new_b| a.bs.build new_b.attributes.except('created_at'... |
39,682,143 | Ok, so we all know that you can do the following:
```
array.each{ |value|
puts value
}
```
What if, however, I want to start at element `n` instead of starting at the beginning; *i.e.* `n=0`. | 2016/09/25 | [
"https://Stackoverflow.com/questions/39682143",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6554042/"
] | You can also do
`array.drop(n).each { |v| puts v }` | You can call a subarray with a range like this:
```
array[n..-1].each { |value| puts value }
```
Where n is the index you'd like to start at, and -1 will always point to the last index of an array. |
124,199 | I installed Magento 2.1 on my Centos 7 server, running Nginx 1.10.1, MariaDB 10.1 and PHP7 with SSL. In theory, everything installed just fine and after the installation I got no errors what-so-ever, and "systemctl status nginx" and "systemctl status php-fpm" both show that they should be working fine. But when I try t... | 2016/07/04 | [
"https://magento.stackexchange.com/questions/124199",
"https://magento.stackexchange.com",
"https://magento.stackexchange.com/users/41764/"
] | php package has some `pre|post` installation scenario in its `specfile`, and one of commands is:
```
......
%dir %attr(0770, root, apache) "/var/lib/php/session"
......
```
so im afraid that probably all your changes will be overwritten on the next php upgrade. no need to chmod or change owner anyway.
you have one ... | The problem that user of php-fpm process do not have write access to /var/lib/php/session/\* files. Please find out username and user group and change access on folder
like
```
sudo chown -R www-data:www-data /var/lib/php/
```
or if it developer environment you can simple (**but not secure**) add access for all
`... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.