qid int64 1 74.7M | question stringlengths 15 58.3k | date stringlengths 10 10 | metadata list | response_j stringlengths 4 30.2k | response_k stringlengths 11 36.5k |
|---|---|---|---|---|---|
32,102,800 | I haven API-Controller serving files via GET-Requests. I'm using the PushStreamContentResponse and that works well.
I can also set the Content-Length-Header on the response object.
Now I also want to support HEAD-Requests. I've tried <http://www.strathweb.com/2013/03/adding-http-head-support-to-asp-net-web-api/> and ... | 2015/08/19 | [
"https://Stackoverflow.com/questions/32102800",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/507257/"
] | In the end, it was really simple.
1. Create a handler for the HEAD request
2. Return a Body with at least one byte content, set the Content-Length-Header of the response to the desired length. Using a Body with zero length won't work.
3. This is the critical part: Disable Outputbuffering for the response.
The WebAPI ... | Another solution would be to create a custom `HttpContent` that will does this job for you. Also a customised `IHttpActionResult` is needed if you want to stick to the guidelines.
Let's say you have a controller that return a `HEAD` action for a given resource like that:
```
[RoutePrefix("resources")]
public class Re... |
32,102,800 | I haven API-Controller serving files via GET-Requests. I'm using the PushStreamContentResponse and that works well.
I can also set the Content-Length-Header on the response object.
Now I also want to support HEAD-Requests. I've tried <http://www.strathweb.com/2013/03/adding-http-head-support-to-asp-net-web-api/> and ... | 2015/08/19 | [
"https://Stackoverflow.com/questions/32102800",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/507257/"
] | While this might have been an issue in 2015, today (2017 onwards), you can just do this
```
[RoutePrefix("api/webhooks")]
public class WebhooksController : ApiController
{
[HttpHead]
[Route("survey-monkey")]
public IHttpActionResult Head()
{
return Ok();
}
[HttpPost]
[Route("survey... | Another solution would be to create a custom `HttpContent` that will does this job for you. Also a customised `IHttpActionResult` is needed if you want to stick to the guidelines.
Let's say you have a controller that return a `HEAD` action for a given resource like that:
```
[RoutePrefix("resources")]
public class Re... |
1,514,457 | Trying to translate [some methods](https://stackoverflow.com/questions/110344/algorithm-to-calculate-the-number-of-divisors-of-a-given-number/118712#118712) written in Python over into C#. The line looks like this:
```
d[p] = d.setdefault(p, 0) + 1
```
What exactly does setdefault do? And is there anything similar I... | 2009/10/03 | [
"https://Stackoverflow.com/questions/1514457",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39321/"
] | From the [Python docs](http://docs.python.org/library/stdtypes.html):
>
> `setdefault(key[, default])`
>
>
> If key is in the dictionary, return its value. If not, insert key with a value of default and return default. default defaults to None.
>
>
>
There is no direct implementation of this in the .NET framewo... | d.setdefault(p, 0) will return the value of the entry with key p if it exists and if it does not then it will set the value for the key p to 0. |
1,514,457 | Trying to translate [some methods](https://stackoverflow.com/questions/110344/algorithm-to-calculate-the-number-of-divisors-of-a-given-number/118712#118712) written in Python over into C#. The line looks like this:
```
d[p] = d.setdefault(p, 0) + 1
```
What exactly does setdefault do? And is there anything similar I... | 2009/10/03 | [
"https://Stackoverflow.com/questions/1514457",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39321/"
] | From the [Python docs](http://docs.python.org/library/stdtypes.html):
>
> `setdefault(key[, default])`
>
>
> If key is in the dictionary, return its value. If not, insert key with a value of default and return default. default defaults to None.
>
>
>
There is no direct implementation of this in the .NET framewo... | **Edit** -- warning: the following works only for this *specific* case, **not** for the general case -- see below.
```
int value = 0;
d.TryGetValue(p, out value);
d[p] = value + 1;
```
this is equivalent to the following Python snippet (which is better than the one you show):
```
d[p] = d.get(p, 0) + 1
```
`setde... |
1,514,457 | Trying to translate [some methods](https://stackoverflow.com/questions/110344/algorithm-to-calculate-the-number-of-divisors-of-a-given-number/118712#118712) written in Python over into C#. The line looks like this:
```
d[p] = d.setdefault(p, 0) + 1
```
What exactly does setdefault do? And is there anything similar I... | 2009/10/03 | [
"https://Stackoverflow.com/questions/1514457",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39321/"
] | From the [Python docs](http://docs.python.org/library/stdtypes.html):
>
> `setdefault(key[, default])`
>
>
> If key is in the dictionary, return its value. If not, insert key with a value of default and return default. default defaults to None.
>
>
>
There is no direct implementation of this in the .NET framewo... | If you want to have the item default to the default instance of object, you might want to consider this (from [here](http://neofight.wordpress.com/2010/08/06/setdefault-for-c-dictionary-idictionary/))
```
public static TValue SetDefault<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, TKey key)
{
TValue re... |
1,514,457 | Trying to translate [some methods](https://stackoverflow.com/questions/110344/algorithm-to-calculate-the-number-of-divisors-of-a-given-number/118712#118712) written in Python over into C#. The line looks like this:
```
d[p] = d.setdefault(p, 0) + 1
```
What exactly does setdefault do? And is there anything similar I... | 2009/10/03 | [
"https://Stackoverflow.com/questions/1514457",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39321/"
] | From the [Python docs](http://docs.python.org/library/stdtypes.html):
>
> `setdefault(key[, default])`
>
>
> If key is in the dictionary, return its value. If not, insert key with a value of default and return default. default defaults to None.
>
>
>
There is no direct implementation of this in the .NET framewo... | I know I'm 3 years late to the party, but a variation that works and is useful:
```
public static TV SetDefault<TK, TV>(this IDictionary<TK, TV> dict, TK key) where TV: new() {
TV value;
if (!dict.TryGetValue(key, out value)) dict.Add(key, value = new TV());
return value;
}
```
That is, for value types t... |
1,514,457 | Trying to translate [some methods](https://stackoverflow.com/questions/110344/algorithm-to-calculate-the-number-of-divisors-of-a-given-number/118712#118712) written in Python over into C#. The line looks like this:
```
d[p] = d.setdefault(p, 0) + 1
```
What exactly does setdefault do? And is there anything similar I... | 2009/10/03 | [
"https://Stackoverflow.com/questions/1514457",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39321/"
] | **Edit** -- warning: the following works only for this *specific* case, **not** for the general case -- see below.
```
int value = 0;
d.TryGetValue(p, out value);
d[p] = value + 1;
```
this is equivalent to the following Python snippet (which is better than the one you show):
```
d[p] = d.get(p, 0) + 1
```
`setde... | d.setdefault(p, 0) will return the value of the entry with key p if it exists and if it does not then it will set the value for the key p to 0. |
1,514,457 | Trying to translate [some methods](https://stackoverflow.com/questions/110344/algorithm-to-calculate-the-number-of-divisors-of-a-given-number/118712#118712) written in Python over into C#. The line looks like this:
```
d[p] = d.setdefault(p, 0) + 1
```
What exactly does setdefault do? And is there anything similar I... | 2009/10/03 | [
"https://Stackoverflow.com/questions/1514457",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39321/"
] | If you want to have the item default to the default instance of object, you might want to consider this (from [here](http://neofight.wordpress.com/2010/08/06/setdefault-for-c-dictionary-idictionary/))
```
public static TValue SetDefault<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, TKey key)
{
TValue re... | d.setdefault(p, 0) will return the value of the entry with key p if it exists and if it does not then it will set the value for the key p to 0. |
1,514,457 | Trying to translate [some methods](https://stackoverflow.com/questions/110344/algorithm-to-calculate-the-number-of-divisors-of-a-given-number/118712#118712) written in Python over into C#. The line looks like this:
```
d[p] = d.setdefault(p, 0) + 1
```
What exactly does setdefault do? And is there anything similar I... | 2009/10/03 | [
"https://Stackoverflow.com/questions/1514457",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39321/"
] | **Edit** -- warning: the following works only for this *specific* case, **not** for the general case -- see below.
```
int value = 0;
d.TryGetValue(p, out value);
d[p] = value + 1;
```
this is equivalent to the following Python snippet (which is better than the one you show):
```
d[p] = d.get(p, 0) + 1
```
`setde... | If you want to have the item default to the default instance of object, you might want to consider this (from [here](http://neofight.wordpress.com/2010/08/06/setdefault-for-c-dictionary-idictionary/))
```
public static TValue SetDefault<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, TKey key)
{
TValue re... |
1,514,457 | Trying to translate [some methods](https://stackoverflow.com/questions/110344/algorithm-to-calculate-the-number-of-divisors-of-a-given-number/118712#118712) written in Python over into C#. The line looks like this:
```
d[p] = d.setdefault(p, 0) + 1
```
What exactly does setdefault do? And is there anything similar I... | 2009/10/03 | [
"https://Stackoverflow.com/questions/1514457",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39321/"
] | **Edit** -- warning: the following works only for this *specific* case, **not** for the general case -- see below.
```
int value = 0;
d.TryGetValue(p, out value);
d[p] = value + 1;
```
this is equivalent to the following Python snippet (which is better than the one you show):
```
d[p] = d.get(p, 0) + 1
```
`setde... | I know I'm 3 years late to the party, but a variation that works and is useful:
```
public static TV SetDefault<TK, TV>(this IDictionary<TK, TV> dict, TK key) where TV: new() {
TV value;
if (!dict.TryGetValue(key, out value)) dict.Add(key, value = new TV());
return value;
}
```
That is, for value types t... |
1,514,457 | Trying to translate [some methods](https://stackoverflow.com/questions/110344/algorithm-to-calculate-the-number-of-divisors-of-a-given-number/118712#118712) written in Python over into C#. The line looks like this:
```
d[p] = d.setdefault(p, 0) + 1
```
What exactly does setdefault do? And is there anything similar I... | 2009/10/03 | [
"https://Stackoverflow.com/questions/1514457",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39321/"
] | If you want to have the item default to the default instance of object, you might want to consider this (from [here](http://neofight.wordpress.com/2010/08/06/setdefault-for-c-dictionary-idictionary/))
```
public static TValue SetDefault<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, TKey key)
{
TValue re... | I know I'm 3 years late to the party, but a variation that works and is useful:
```
public static TV SetDefault<TK, TV>(this IDictionary<TK, TV> dict, TK key) where TV: new() {
TV value;
if (!dict.TryGetValue(key, out value)) dict.Add(key, value = new TV());
return value;
}
```
That is, for value types t... |
101,229 | Introduction
------------
[Dobble/SpotIt](https://boardgamegeek.com/boardgame/63268/spot-it) is a card game, where people have to spot same symbol on pair of cards in shortest time, indicate it and move to next pair. Each card has multiple symbols (8 in normal version), but exactly one is common between each pair of ... | 2016/11/27 | [
"https://codegolf.stackexchange.com/questions/101229",
"https://codegolf.stackexchange.com",
"https://codegolf.stackexchange.com/users/60310/"
] | [Python 2](https://docs.python.org/2/), ~~192~~ 162 bytes
=========================================================
I have an argument that this produces the maximum set of cards for every scenario and it does handle the 3 test cases.
```py
from itertools import*
def m(a,s):
C=["".join(x)for x in combinations(a,s... | Haskell, ~~175~~ 156 bytes
==========================
My first take at golfing, let me know if I've messed something up.
```
import Data.List
f 0_=[[]]
f n a=g$c n a
c n a=[a!!i:x|i<-[0..(length a)-1],x<-f(n-1)(drop(i+1)a)]
g[]=[]
g(x:t)=x:g(filter(\z->length(z`intersect`x)<= 1)t)
```
[Try it online!](https://tio.r... |
101,229 | Introduction
------------
[Dobble/SpotIt](https://boardgamegeek.com/boardgame/63268/spot-it) is a card game, where people have to spot same symbol on pair of cards in shortest time, indicate it and move to next pair. Each card has multiple symbols (8 in normal version), but exactly one is common between each pair of ... | 2016/11/27 | [
"https://codegolf.stackexchange.com/questions/101229",
"https://codegolf.stackexchange.com",
"https://codegolf.stackexchange.com/users/60310/"
] | [Python 2](https://docs.python.org/2/), ~~192~~ 162 bytes
=========================================================
I have an argument that this produces the maximum set of cards for every scenario and it does handle the 3 test cases.
```py
from itertools import*
def m(a,s):
C=["".join(x)for x in combinations(a,s... | [Perl 6](https://github.com/nxadm/rakudo-pkg), ~~88~~ 77 bytes
==============================================================
```perl6
{+(combinations($^a,$^n),{my \d=.[0];say d.join;grep *∩d==1,.[1..*]}...!*)}
```
[Try it online!](https://tio.run/##K0gtyjH7n1upoJamYPu/WlsjOT83KTMvsSQzP69YQyUuUUclLk9TpxqoIibFVi/aINa... |
101,229 | Introduction
------------
[Dobble/SpotIt](https://boardgamegeek.com/boardgame/63268/spot-it) is a card game, where people have to spot same symbol on pair of cards in shortest time, indicate it and move to next pair. Each card has multiple symbols (8 in normal version), but exactly one is common between each pair of ... | 2016/11/27 | [
"https://codegolf.stackexchange.com/questions/101229",
"https://codegolf.stackexchange.com",
"https://codegolf.stackexchange.com/users/60310/"
] | Haskell, ~~175~~ 156 bytes
==========================
My first take at golfing, let me know if I've messed something up.
```
import Data.List
f 0_=[[]]
f n a=g$c n a
c n a=[a!!i:x|i<-[0..(length a)-1],x<-f(n-1)(drop(i+1)a)]
g[]=[]
g(x:t)=x:g(filter(\z->length(z`intersect`x)<= 1)t)
```
[Try it online!](https://tio.r... | [Perl 6](https://github.com/nxadm/rakudo-pkg), ~~88~~ 77 bytes
==============================================================
```perl6
{+(combinations($^a,$^n),{my \d=.[0];say d.join;grep *∩d==1,.[1..*]}...!*)}
```
[Try it online!](https://tio.run/##K0gtyjH7n1upoJamYPu/WlsjOT83KTMvsSQzP69YQyUuUUclLk9TpxqoIibFVi/aINa... |
12,785,971 | >
> **Possible Duplicate:**
>
> [Terminated Thread Revival](https://stackoverflow.com/questions/5411509/terminated-thread-revival)
>
>
>
```
Thread threadWait = new Thread()
{
@Override
public void run() {
try {
sleep(10000);
sync = false;
... | 2012/10/08 | [
"https://Stackoverflow.com/questions/12785971",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1341849/"
] | Fixing your makefile in three places:
```
target = all
files := $(wildcard Abc/*.abc)
bltfiles := $(files) $(patsubst %.abc,%.built,$(files))
all: $(bltfiles)
#Abc/%.abc.built: Abc/%.abc Abc/%.abc.md5
%.built: %.abc %.abc.md5
@echo "Building $*"
@ #Command that generates code from a .abc file
@touch $... | As sehe fixed but didn't explain: Makefile syntax isn't the same as shell syntax. By default (for reasons lost to history) make variables are only one character long. If you want a longer variable name, you have to put it in parenthesis so it parses correctly. Writing `$files`, for example, actually expands the string ... |
35,204 | I am used to using the Firebug extension "Omnibug" with Firefox to check that Google Analytics Tracking Code is firing on my website. This application works very well and has minimal overhead.
I am now testing the website on an iPad and would like to know if there is a way to check that the GATC is firing on the iPad ... | 2012/10/02 | [
"https://webmasters.stackexchange.com/questions/35204",
"https://webmasters.stackexchange.com",
"https://webmasters.stackexchange.com/users/14473/"
] | If it's local development why not just add additional JS code at the beginning of your GATC script, like an `alert('GATC fired');` ?
Or: See this discussion [on monitoring HTTP traffic](https://serverfault.com/questions/84750/monitoring-http-traffic-using-tcpdump) on serverfault. Some of the mentioned tools are availa... | Use a debugging tool like Charles to send requests made on iPad via proxy to the desktop software. Here's a basic overview: <http://www.charlesproxy.com/documentation/faqs/using-charles-from-an-iphone/>
This allows for records to be saved and analysed later. Another benefit is that actual and not emulated user page in... |
35,204 | I am used to using the Firebug extension "Omnibug" with Firefox to check that Google Analytics Tracking Code is firing on my website. This application works very well and has minimal overhead.
I am now testing the website on an iPad and would like to know if there is a way to check that the GATC is firing on the iPad ... | 2012/10/02 | [
"https://webmasters.stackexchange.com/questions/35204",
"https://webmasters.stackexchange.com",
"https://webmasters.stackexchange.com/users/14473/"
] | If it's local development why not just add additional JS code at the beginning of your GATC script, like an `alert('GATC fired');` ?
Or: See this discussion [on monitoring HTTP traffic](https://serverfault.com/questions/84750/monitoring-http-traffic-using-tcpdump) on serverfault. Some of the mentioned tools are availa... | Could you not just check the Google Analytics live view section on a desktop when your iPad is on each page, that would show you if you're collecting data. |
35,204 | I am used to using the Firebug extension "Omnibug" with Firefox to check that Google Analytics Tracking Code is firing on my website. This application works very well and has minimal overhead.
I am now testing the website on an iPad and would like to know if there is a way to check that the GATC is firing on the iPad ... | 2012/10/02 | [
"https://webmasters.stackexchange.com/questions/35204",
"https://webmasters.stackexchange.com",
"https://webmasters.stackexchange.com/users/14473/"
] | If it's local development why not just add additional JS code at the beginning of your GATC script, like an `alert('GATC fired');` ?
Or: See this discussion [on monitoring HTTP traffic](https://serverfault.com/questions/84750/monitoring-http-traffic-using-tcpdump) on serverfault. Some of the mentioned tools are availa... | Visit the website on your ipad and go on analytics, under the tab home go to real-time overview. |
35,204 | I am used to using the Firebug extension "Omnibug" with Firefox to check that Google Analytics Tracking Code is firing on my website. This application works very well and has minimal overhead.
I am now testing the website on an iPad and would like to know if there is a way to check that the GATC is firing on the iPad ... | 2012/10/02 | [
"https://webmasters.stackexchange.com/questions/35204",
"https://webmasters.stackexchange.com",
"https://webmasters.stackexchange.com/users/14473/"
] | Use a debugging tool like Charles to send requests made on iPad via proxy to the desktop software. Here's a basic overview: <http://www.charlesproxy.com/documentation/faqs/using-charles-from-an-iphone/>
This allows for records to be saved and analysed later. Another benefit is that actual and not emulated user page in... | Visit the website on your ipad and go on analytics, under the tab home go to real-time overview. |
35,204 | I am used to using the Firebug extension "Omnibug" with Firefox to check that Google Analytics Tracking Code is firing on my website. This application works very well and has minimal overhead.
I am now testing the website on an iPad and would like to know if there is a way to check that the GATC is firing on the iPad ... | 2012/10/02 | [
"https://webmasters.stackexchange.com/questions/35204",
"https://webmasters.stackexchange.com",
"https://webmasters.stackexchange.com/users/14473/"
] | Could you not just check the Google Analytics live view section on a desktop when your iPad is on each page, that would show you if you're collecting data. | Visit the website on your ipad and go on analytics, under the tab home go to real-time overview. |
8,692,321 | I am trying to implement machines learning in java or scala environment. Can anybody please recommend me a good library to study and use?
So far, the algorithm that I am going to use will be logistic regression and SVN.
Thanks | 2012/01/01 | [
"https://Stackoverflow.com/questions/8692321",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/113037/"
] | Have a look at [scala0-recog](http://code.google.com/p/scala-recog/) or if you want a big toolbox then try [scalaNLP](http://www.scalanlp.org/) | There is also a lib build on top of hadoop called Mahout that might help you. It has use cases in distributed computing and parallelization. Hth |
64,486,625 | Consider the following dataframe created from a dictionary
```
d = { 'p_symbol': ['A','B','C','D','E']
, 'p_volume': [0,0,0,0,0]
, 'p_exchange': ['IEXG', 'ASE', 'PSE', 'NAS', 'NYS']
, 'p_volume_rh': [1000,1000,1000,1000,1000]
, 'p_volume.1': [2000,2000,2000,2000,2000]
, 'p_volume.2': [3000,300... | 2020/10/22 | [
"https://Stackoverflow.com/questions/64486625",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14501412/"
] | Looks like you're looking for a redirect to the task detail page with the PK, so:
for function view:
return redirect('task-detail', pk=pk)
Update: for class based view:
return redirect('task-detail', self.kwargs['pk']) | Thanks to @Ed Kohler I found out, you gave me the correct line of thought! Thanks!
```
class CommentCreate(CreateView):
model = Comment
fields = ['body']
def form_valid(self, form):
form.instance.task_id = self.kwargs['pk']
form.instance.author = self.request.user
form.instance.created = timezone.now()
... |
19,099,907 | I've got an app with a UIView hierarchy that looks something like this:
```
mainView (is always rotated appropriately for the user)
topView1
thumbnail1.1
thumbnail1.2
thumbnail1.3
topView2
thumbnail2.1
thumbnail2.2
thumbnail2.3
topView3
thumbnail3.1
... | 2013/09/30 | [
"https://Stackoverflow.com/questions/19099907",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1476269/"
] | You should only call `setNeedsDisplay` and set the image from the main thread. All UI changes must be done on the main thread. | setNeedsDisplay method supposed to ensure that:
```
[view setNeedsDisplay];
``` |
6,816,264 | How to programmatically create script component of dataflow task in MS SQL Server 2008. | 2011/07/25 | [
"https://Stackoverflow.com/questions/6816264",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/670082/"
] | Below given link contains the Microsoft hands-on lab to create a custom transformation component in SSIS. The document pertains to SSIS 2005 but the logic should be applicable to SSIS 2008 as well.
[`SQL Server Integration Services (SSIS) Hands on Training - Creating Custom Components`](http://www.microsoft.com/downlo... | This is the Code for creating a ScriptTask Programmatically.
```
Package pkg = new Package();
pkg.Executables.Add("STOCK:ScriptTask");
TaskHost th = (TaskHost)exec;
ScriptTask task = (ScriptTask)th.InnerObject;
task.ScriptProjectName = "YourProjectName.csproj”; // (or vbproj)
th.Name = name;
task.ScriptLanguage = CS... |
19,197,416 | I want to know that if I can implement `or,and` functions using only `xor`. I think It is impossible but I need to prove that. Any ideas?
Thanks in advance. | 2013/10/05 | [
"https://Stackoverflow.com/questions/19197416",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1916553/"
] | You cannot implement OR or AND gate only by using XOR because it is not a universal gate.
*Also the XOR function can't tell the difference between '1,1' and '0,0' at it's inputs. Inverting the inputs/output in whatever combination makes a new gate with an XOR or XNOR function.*
>
> Here is an argument against XOR an... | Yes, we can make other Gates using just XOR gate. But its inadvisable as each XOR gate will use atleast 6 to 8 MOSFETS. Also, I will be assuming Open Drain gate designs so that we can use wired ANDing. Else it is impossible to make any Gate apart from NOT and XNOR using just XOR gates.
Coming back to your question:
NO... |
74,055,543 | I have created a middleware which logs requests/response data in the database.
I want this middleware to work only when I want to troubleshoot defect or unwanted exception. The middleware should not log rest of the time.
I want a switch button which I can on or off on any controller without making any code changes and ... | 2022/10/13 | [
"https://Stackoverflow.com/questions/74055543",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2327358/"
] | In Program.cs, you can add conditionally a middleware like :
```cs
var builder = WebApplication.CreateBuilder(args);
...
var app = builder.Build();
if (app.Configuration.Get<bool>("MiddlewareLog.Enable"))
{
app.UseCustomeLoggerMiddleware();
}
...
```
To enable/disable the middleware, you only need to update the ... | A solution is to enable/disable the middleware from a global setting. Then the controller's action can modify this global setting to enable/disable the middleware.
```cs
public class LoggerMiddleware
{
public static volatile bool Enable;
private readonly RequestDelegate _next;
public LoggerMiddleware(Req... |
13,107,722 | The problem
===========
Hi there,
I'm developing an application where the user specifies some pictures and how long they are going to be on the screen.So sometimes he wants to create something like a small animation or viewing the images for a small amount of time.The problem is that after some time the images are no... | 2012/10/28 | [
"https://Stackoverflow.com/questions/13107722",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1123347/"
] | Probably the issue is in increasing heap size when it loads additional images. I would suggest You to do some [profiling](http://developer.android.com/tools/debugging/debugging-tracing.html) so things will be much clearer and You'll get full picture of timings for the app. | First you are missing a null check at here:
```
ImageMap.get(String.valueOf(NumOfFrame))
```
And you do not recycle the old bitmap at here:
```
theImage.recycle(); // missing line
theImage = Bitmap.createScaledBitmap(theImage,
display.getWidth(), display.getHeight() - 140, true);
```
It ma... |
18,395,892 | It happens that your application encounters a directory path that is relative to current folder or uses double dot for navigation, e.g. `C:\A\B\..\C`. This obviously is equivalent to the *canonical path* `C:\A\C`. How can one resolve the path to its canonical form? | 2013/08/23 | [
"https://Stackoverflow.com/questions/18395892",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1292374/"
] | The simplest way I know to convert a path to its canonical form is using [`cd`](http://www.mathworks.se/help/matlab/ref/cd.html) command:
```
oPath = cd(cd(iPath));
```
Note that this would fail if the path does not exist on your file system. | Another way of doing it, without potentially throwing an exception, is using the [what](https://fr.mathworks.com/help/matlab/ref/what.html) command:
```
pathInfo = what(iPath);
if ~isempty(pathInfo)
iPath = pathInfo.path;
end
``` |
18,395,892 | It happens that your application encounters a directory path that is relative to current folder or uses double dot for navigation, e.g. `C:\A\B\..\C`. This obviously is equivalent to the *canonical path* `C:\A\C`. How can one resolve the path to its canonical form? | 2013/08/23 | [
"https://Stackoverflow.com/questions/18395892",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1292374/"
] | This one uses the java io interface:
```
jFile=java.io.File(iPath);
oPath=jFile.getCanonicalPath;
```
It wouldn't need to change matlab's directory. It has other useful methods that may be found [here](http://docs.oracle.com/javase/6/docs/api/java/io/File.html). | Another way of doing it, without potentially throwing an exception, is using the [what](https://fr.mathworks.com/help/matlab/ref/what.html) command:
```
pathInfo = what(iPath);
if ~isempty(pathInfo)
iPath = pathInfo.path;
end
``` |
8,693,196 | I need to transfer some images through Network, I saved images with Jpeg and 40% quality as following:
```
public void SaveJpeg(string path, Image image, int quality) {
if((quality < 0) || (quality > 100)) {
string error = string.Format("Jpeg image quality must be
between 0 and 100, with 100 bein... | 2012/01/01 | [
"https://Stackoverflow.com/questions/8693196",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1020476/"
] | With image compression, there's a fine line between creating a small file and creating a poor quality image. JPEG is a lossy compression format which means that data is removed when compressed, which is why constantly re-encoding a JPEG file will continually decrease its quality.
On the other hand, PNG files are lossl... | I have a method for creating and saving the thumbnail of an uploaded picture, I think `NewImageSize` method might help you.It also handles the quality issue.
```
public Size NewImageSize(int OriginalHeight, int OriginalWidth, double FormatSize)
{
Size NewSize;
double tempval;
... |
61,087,034 | Here is the request I should call:
[listing library contents](https://developers.google.com/photos/library/guides/list#listing-library-contents)
>
> GET <https://photoslibrary.googleapis.com/v1/mediaItems>
> Content-type: application/json
> Authorization: Bearer oauth2-token
> {
> "pageSize": "100",
> }
>
>
> ... | 2020/04/07 | [
"https://Stackoverflow.com/questions/61087034",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2904718/"
] | I think you need to send a param along with this request
You can try this request in postman using this query
<https://photoslibrary.googleapis.com/v1/mediaItems?pageSize=100>
and pass the token in the authentication section.
Here you can do something like -
```
eg
URI uri = new URIBuilder("https://photoslibrar... | I think the documentation is wrong and you're supposed to use a POST request instead of GET.
Also there is an error in the documented JSON request body: there is a trailing comma that should not be there. Use the following:
```
String body2 = "{\"pageSize\": \"100\"}";
``` |
14,376,657 | `design.php` file:
```
<script>
$(".colr_sldr li img").click(function(){
var src = $(this).attr('src');
var value=src.substring(src.lastIndexOf('/')+1);
<?php $var = "<script>document.write('" + value + "')</script>";?>
});
</script>
```
and use this variable in `index.php` file:
```
<?php... | 2013/01/17 | [
"https://Stackoverflow.com/questions/14376657",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1859372/"
] | I'd suggest to follow EAFP and catch an exception instead of using `isinstance`. Also, never miss an opportunity to make a function a bit more generic:
```
def rreplace(it, old, new):
try:
return it.replace(old, new)
except AttributeError:
return [rreplace(x, old, new) for x in it]
```
Exampl... | ```
def removespace(lst):
if type(lst) is str:
return lst.replace(" ","")
else:
return [removespace(elem) for elem in lst]
lst = [' apple', 'pie ', ['sth', ['banana', 'asd', [' sdfdsf', ['fgg']]]]]
print removespace(lst)
```
prints
```
['apple', 'pie', ['sth', ['banana', 'asd', ['sdfdsf', [... |
14,376,657 | `design.php` file:
```
<script>
$(".colr_sldr li img").click(function(){
var src = $(this).attr('src');
var value=src.substring(src.lastIndexOf('/')+1);
<?php $var = "<script>document.write('" + value + "')</script>";?>
});
</script>
```
and use this variable in `index.php` file:
```
<?php... | 2013/01/17 | [
"https://Stackoverflow.com/questions/14376657",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1859372/"
] | ```
def removespace(a):
if type(a) is str:
return a.replace(" ", "")
elif type(a) is list:
return [removespace(x) for x in a]
elif type(a) is set:
return {removespace(x) for x in a}
else:
return a
```
Here is a sample:
```
>>> removespace([["a ",[" "]],{"b ","c d"},"... | ```
def removespace(lst):
if type(lst) is str:
return lst.replace(" ","")
else:
return [removespace(elem) for elem in lst]
lst = [' apple', 'pie ', ['sth', ['banana', 'asd', [' sdfdsf', ['fgg']]]]]
print removespace(lst)
```
prints
```
['apple', 'pie', ['sth', ['banana', 'asd', ['sdfdsf', [... |
14,376,657 | `design.php` file:
```
<script>
$(".colr_sldr li img").click(function(){
var src = $(this).attr('src');
var value=src.substring(src.lastIndexOf('/')+1);
<?php $var = "<script>document.write('" + value + "')</script>";?>
});
</script>
```
and use this variable in `index.php` file:
```
<?php... | 2013/01/17 | [
"https://Stackoverflow.com/questions/14376657",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1859372/"
] | ```
def removespace(a):
if type(a) is str:
return a.replace(" ", "")
elif type(a) is list:
return [removespace(x) for x in a]
elif type(a) is set:
return {removespace(x) for x in a}
else:
return a
```
Here is a sample:
```
>>> removespace([["a ",[" "]],{"b ","c d"},"... | I'd suggest to follow EAFP and catch an exception instead of using `isinstance`. Also, never miss an opportunity to make a function a bit more generic:
```
def rreplace(it, old, new):
try:
return it.replace(old, new)
except AttributeError:
return [rreplace(x, old, new) for x in it]
```
Exampl... |
14,376,657 | `design.php` file:
```
<script>
$(".colr_sldr li img").click(function(){
var src = $(this).attr('src');
var value=src.substring(src.lastIndexOf('/')+1);
<?php $var = "<script>document.write('" + value + "')</script>";?>
});
</script>
```
and use this variable in `index.php` file:
```
<?php... | 2013/01/17 | [
"https://Stackoverflow.com/questions/14376657",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1859372/"
] | I'd suggest to follow EAFP and catch an exception instead of using `isinstance`. Also, never miss an opportunity to make a function a bit more generic:
```
def rreplace(it, old, new):
try:
return it.replace(old, new)
except AttributeError:
return [rreplace(x, old, new) for x in it]
```
Exampl... | Though you may experiment with recursive solution, but you can try your hand on a wonderful library Python provides, to transform a well formed Python literal from string to Python literal.
* Just convert you list to string
* remove any necessary spaces
* and then reconvert to the recursive list structure using [ast.... |
14,376,657 | `design.php` file:
```
<script>
$(".colr_sldr li img").click(function(){
var src = $(this).attr('src');
var value=src.substring(src.lastIndexOf('/')+1);
<?php $var = "<script>document.write('" + value + "')</script>";?>
});
</script>
```
and use this variable in `index.php` file:
```
<?php... | 2013/01/17 | [
"https://Stackoverflow.com/questions/14376657",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1859372/"
] | ```
def removespace(a):
if type(a) is str:
return a.replace(" ", "")
elif type(a) is list:
return [removespace(x) for x in a]
elif type(a) is set:
return {removespace(x) for x in a}
else:
return a
```
Here is a sample:
```
>>> removespace([["a ",[" "]],{"b ","c d"},"... | Though you may experiment with recursive solution, but you can try your hand on a wonderful library Python provides, to transform a well formed Python literal from string to Python literal.
* Just convert you list to string
* remove any necessary spaces
* and then reconvert to the recursive list structure using [ast.... |
14,454,405 | I have table in my data base with these specs:
* one PK
* 3 fields with foreign key
* some statistic fields
problem is here:
In every row only one FK field will be filled.
What is the best solution A or B?
A- define 3 FK for my table
B- define one field as FK\_TYPE and one field as DEMAND\_FK and use checking on ... | 2013/01/22 | [
"https://Stackoverflow.com/questions/14454405",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/635473/"
] | Option A - if you've got to have this design, you'll need a separate column for each foreign key. There's no (standard) way to define a "conditional" foreign key.
If your system supports check constraints, include a check constraint so that exactly one of the FK columns is not null. If it doesn't support check constra... | If I am not wrong, B can not be possible in any relational database. Foreign key can only reference to only one primary key of a table. If you use B then you have to add the constrain in application level. Otherwise use A. |
9,979,428 | I'm trying to deploy a asp.net mvc 4 application taht uses a ApiController.
But when i try to access the web api, i'm getting this error.
>
> Could not load type 'System.Web.Razor.Parser.SyntaxTree.CodeSpan' from assembly >'System.Web.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
>
>
>... | 2012/04/02 | [
"https://Stackoverflow.com/questions/9979428",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1058256/"
] | Check the web.config file in Views folder AND the line
```
<add assembly="System.Web.WebPages, Version=1.0.0.0 ...
```
in the root web.config. See my note in [this this thread](https://stackoverflow.com/questions/7668252/migrating-my-mvc-3-application-to-mvc-4/15142264#15142264). | I finally just create a new asp.net mvc 4 project from scratch and move in all my code. |
5,019,586 | Here's a pretty silly question, but we want to do this. Is there an easy way to take a 2.0 project or 2.0 source code and convert it back 1.1. Obviously we have the 2.0 source and for compatibility reasons we want to create a 1.1 version. Any thoughts. | 2011/02/16 | [
"https://Stackoverflow.com/questions/5019586",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/620072/"
] | No, there is no automated way but this is how you do it:
Recreate the solution and project files, add your existing source code, clean up any code that does not compile, and you are set to go (or to test, rather).
Might take a long time to accomplish, but that's how you'd do it.
**EDIT:** Applied suggested change in... | If you give it a thought yourself then you will also realize that it's not even logical to have such kind of tool... How the code will change .Net 2.0 specific syntax, API calls and translate it to .Net 1.1... can you think of any such mapping :)..
The only thing you can hope is to create the project in 1.1 add your c... |
5,019,586 | Here's a pretty silly question, but we want to do this. Is there an easy way to take a 2.0 project or 2.0 source code and convert it back 1.1. Obviously we have the 2.0 source and for compatibility reasons we want to create a 1.1 version. Any thoughts. | 2011/02/16 | [
"https://Stackoverflow.com/questions/5019586",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/620072/"
] | Eek.
The simplest thing to do would be to add a SupportedRuntime attribute to your XML config. Documentation here: <http://msdn.microsoft.com/en-us/library/w4atty68.aspx>. Be advised that this does NOT guarantee the code will work against the 1.1 framework; it only tells the .NET 1.1 CLR that it can TRY.
A more compr... | If you give it a thought yourself then you will also realize that it's not even logical to have such kind of tool... How the code will change .Net 2.0 specific syntax, API calls and translate it to .Net 1.1... can you think of any such mapping :)..
The only thing you can hope is to create the project in 1.1 add your c... |
30,615,190 | could someone explain me few points in the sample from cppreference site?
The technique describes functions overloading depends of iterator type.
First two typedefs with "using" are clear for understanding.
The questions relate to alg functions:
1. in the list of template parameters -"typename = ..." without paramete... | 2015/06/03 | [
"https://Stackoverflow.com/questions/30615190",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2920614/"
] | 1. `typename = ...` declares an unnamed template parameter. Client code could still override it, but the parameter can't be used in the function definition. This is used here because the second template parameter is used to leverage SFINAE rather than to work out a type to use in the definition.
2. Correct, if the iter... | 1. No, the user is able to overwrite the parameter. Naming a parameter
is optional. You don't have to do it if you won't use it.
2. Yes. The tag has to be equal to `std::bidirectional_iterator_tag`
for the first overload to kick in, and `std::random_access_iterator_tag` for
the second one.
3. Without the third template... |
7,384,199 | I have problems to check syntax of ruby scripts that has rails script/runner on its shebang.
Here are two example scripts and how they responses to ruby syntax checking:
Script `hello_world_runner.rb`:
```
#!/usr/bin/env script/runner
p "Hello world!"
```
Script `hello_world.rb`
```
#!/usr/bin/env ruby
p "Hello w... | 2011/09/12 | [
"https://Stackoverflow.com/questions/7384199",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/241495/"
] | You can try this
```
tail -n +2 hellow_world_runner.rb | ruby -c
```
Not ideal but should work. | You can rewrite your script like this:
Rails 2:
```
#!/usr/bin/env ruby
require File.expand_path(Dir.pwd + '/config/boot', __FILE__)
require RAILS_ROOT + '/config/environment'
p "Hello world!"
```
Rails 3:
```
#!/usr/bin/env ruby
require File.expand_path(Dir.pwd + '/config/boot', __FILE__)
require File.expand_pa... |
7,384,199 | I have problems to check syntax of ruby scripts that has rails script/runner on its shebang.
Here are two example scripts and how they responses to ruby syntax checking:
Script `hello_world_runner.rb`:
```
#!/usr/bin/env script/runner
p "Hello world!"
```
Script `hello_world.rb`
```
#!/usr/bin/env ruby
p "Hello w... | 2011/09/12 | [
"https://Stackoverflow.com/questions/7384199",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/241495/"
] | You can rewrite your script like this:
Rails 2:
```
#!/usr/bin/env ruby
require File.expand_path(Dir.pwd + '/config/boot', __FILE__)
require RAILS_ROOT + '/config/environment'
p "Hello world!"
```
Rails 3:
```
#!/usr/bin/env ruby
require File.expand_path(Dir.pwd + '/config/boot', __FILE__)
require File.expand_pa... | I would highly recommend that you factor the majority of the code in those scripts into your core domain models/lib directory/etc. This will allow you to test the script logic the same way you test the rest of your application (which will also end up checking syntax) and reduce the actual content of your executable fil... |
7,384,199 | I have problems to check syntax of ruby scripts that has rails script/runner on its shebang.
Here are two example scripts and how they responses to ruby syntax checking:
Script `hello_world_runner.rb`:
```
#!/usr/bin/env script/runner
p "Hello world!"
```
Script `hello_world.rb`
```
#!/usr/bin/env ruby
p "Hello w... | 2011/09/12 | [
"https://Stackoverflow.com/questions/7384199",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/241495/"
] | You can rewrite your script like this:
Rails 2:
```
#!/usr/bin/env ruby
require File.expand_path(Dir.pwd + '/config/boot', __FILE__)
require RAILS_ROOT + '/config/environment'
p "Hello world!"
```
Rails 3:
```
#!/usr/bin/env ruby
require File.expand_path(Dir.pwd + '/config/boot', __FILE__)
require File.expand_pa... | Here is a little cheat:
```
$ ruby -wc <(cat <(echo ruby) hello_world_runner.rb)
Syntax OK
```
Basically `ruby` syntax checker expect the `ruby` word in the first line (shebang). |
7,384,199 | I have problems to check syntax of ruby scripts that has rails script/runner on its shebang.
Here are two example scripts and how they responses to ruby syntax checking:
Script `hello_world_runner.rb`:
```
#!/usr/bin/env script/runner
p "Hello world!"
```
Script `hello_world.rb`
```
#!/usr/bin/env ruby
p "Hello w... | 2011/09/12 | [
"https://Stackoverflow.com/questions/7384199",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/241495/"
] | You can try this
```
tail -n +2 hellow_world_runner.rb | ruby -c
```
Not ideal but should work. | I would highly recommend that you factor the majority of the code in those scripts into your core domain models/lib directory/etc. This will allow you to test the script logic the same way you test the rest of your application (which will also end up checking syntax) and reduce the actual content of your executable fil... |
7,384,199 | I have problems to check syntax of ruby scripts that has rails script/runner on its shebang.
Here are two example scripts and how they responses to ruby syntax checking:
Script `hello_world_runner.rb`:
```
#!/usr/bin/env script/runner
p "Hello world!"
```
Script `hello_world.rb`
```
#!/usr/bin/env ruby
p "Hello w... | 2011/09/12 | [
"https://Stackoverflow.com/questions/7384199",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/241495/"
] | You can try this
```
tail -n +2 hellow_world_runner.rb | ruby -c
```
Not ideal but should work. | The ruby command line has these 2 flags that might assist you, I use:
```
ruby -wc test.rb
``` |
7,384,199 | I have problems to check syntax of ruby scripts that has rails script/runner on its shebang.
Here are two example scripts and how they responses to ruby syntax checking:
Script `hello_world_runner.rb`:
```
#!/usr/bin/env script/runner
p "Hello world!"
```
Script `hello_world.rb`
```
#!/usr/bin/env ruby
p "Hello w... | 2011/09/12 | [
"https://Stackoverflow.com/questions/7384199",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/241495/"
] | You can try this
```
tail -n +2 hellow_world_runner.rb | ruby -c
```
Not ideal but should work. | Here is a little cheat:
```
$ ruby -wc <(cat <(echo ruby) hello_world_runner.rb)
Syntax OK
```
Basically `ruby` syntax checker expect the `ruby` word in the first line (shebang). |
7,384,199 | I have problems to check syntax of ruby scripts that has rails script/runner on its shebang.
Here are two example scripts and how they responses to ruby syntax checking:
Script `hello_world_runner.rb`:
```
#!/usr/bin/env script/runner
p "Hello world!"
```
Script `hello_world.rb`
```
#!/usr/bin/env ruby
p "Hello w... | 2011/09/12 | [
"https://Stackoverflow.com/questions/7384199",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/241495/"
] | The ruby command line has these 2 flags that might assist you, I use:
```
ruby -wc test.rb
``` | I would highly recommend that you factor the majority of the code in those scripts into your core domain models/lib directory/etc. This will allow you to test the script logic the same way you test the rest of your application (which will also end up checking syntax) and reduce the actual content of your executable fil... |
7,384,199 | I have problems to check syntax of ruby scripts that has rails script/runner on its shebang.
Here are two example scripts and how they responses to ruby syntax checking:
Script `hello_world_runner.rb`:
```
#!/usr/bin/env script/runner
p "Hello world!"
```
Script `hello_world.rb`
```
#!/usr/bin/env ruby
p "Hello w... | 2011/09/12 | [
"https://Stackoverflow.com/questions/7384199",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/241495/"
] | The ruby command line has these 2 flags that might assist you, I use:
```
ruby -wc test.rb
``` | Here is a little cheat:
```
$ ruby -wc <(cat <(echo ruby) hello_world_runner.rb)
Syntax OK
```
Basically `ruby` syntax checker expect the `ruby` word in the first line (shebang). |
9,955,273 | I am following a tutorial on Android Development, their video shows "layout lines" in the graphical layout. Such as when you place a LinearLayout you can see a light line around it so that it is obvious on screen.
The tutorial shows a button alongside the Zoom buttons above the editor that turns these lines on and off... | 2012/03/31 | [
"https://Stackoverflow.com/questions/9955273",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/508401/"
] | I have had my question answered on another site, so I will provide the answer here also for anyone who stumbles across this page.
It seems that the feature I was seeking has actually been removed from the more recent (v16 and v17) copies of the ADT. I do not know why as it is actually a useful feature, but ours is not... | It is a functionality of the newer ADTs. Upgrade your Adt to the latest one and you would start seeing this feature. |
148,634 | I received an informal offer from a software company which included 0 hours of PTO. I countered the offer and was promised 10 days (80 hours) of PTO. With this apparent "signing bonus" as the deciding factor I accepted the offer.
Here is the verbatim verbiage of the contract with regard to PTO:
```
The following bene... | 2019/11/25 | [
"https://workplace.stackexchange.com/questions/148634",
"https://workplace.stackexchange.com",
"https://workplace.stackexchange.com/users/38341/"
] | >
> Several months into the employment I'm now being told, of the 80 hours
> I was promised, I have only accrued ~28.
>
>
>
Well you had several months to read and understand the Employee Handbook containing the accrual policy. So it really shouldn't be a surprise now.
>
> I understand that accrual of PTO is a... | **Check yourself. You may be getting a better deal than you thought you were.**
You thought you were negotiating for a one-time sum of 80 hours of leave. The company appears to be granting you 80 hours of leave per year. If you wind up working there for more than a year, is this not better? Best not to make too big a ... |
148,634 | I received an informal offer from a software company which included 0 hours of PTO. I countered the offer and was promised 10 days (80 hours) of PTO. With this apparent "signing bonus" as the deciding factor I accepted the offer.
Here is the verbatim verbiage of the contract with regard to PTO:
```
The following bene... | 2019/11/25 | [
"https://workplace.stackexchange.com/questions/148634",
"https://workplace.stackexchange.com",
"https://workplace.stackexchange.com/users/38341/"
] | Legalities aside, as I don't think you want to go that route to solve this anyway.
I understand that you are surprised by the fact that PTO accrues, they probably are as surprised by your surprise, as this is fairly normal thing in tech in many modern countries (US, UK, and Australia from my own experience). But is th... | This is how it usually works. You earn a certain amount of holidays over a year. During half a year you earn half that. If you leave the company, they have to pay you for the accrued leave that you haven't taken yet, or you have to pay back the money for leave that you have taken that wasn't accrued yet. (In the USA, y... |
148,634 | I received an informal offer from a software company which included 0 hours of PTO. I countered the offer and was promised 10 days (80 hours) of PTO. With this apparent "signing bonus" as the deciding factor I accepted the offer.
Here is the verbatim verbiage of the contract with regard to PTO:
```
The following bene... | 2019/11/25 | [
"https://workplace.stackexchange.com/questions/148634",
"https://workplace.stackexchange.com",
"https://workplace.stackexchange.com/users/38341/"
] | Legalities aside, as I don't think you want to go that route to solve this anyway.
I understand that you are surprised by the fact that PTO accrues, they probably are as surprised by your surprise, as this is fairly normal thing in tech in many modern countries (US, UK, and Australia from my own experience). But is th... | You've tagged your location as United States.
PTO accrual is typical in the US. PTO is typically quoted annually (X hours or X days per year), but you start with a zero or a near-zero amount, and it is "earned" either every paycheck or every month (or some other schedule of a similar scale). In effect, your X days of ... |
148,634 | I received an informal offer from a software company which included 0 hours of PTO. I countered the offer and was promised 10 days (80 hours) of PTO. With this apparent "signing bonus" as the deciding factor I accepted the offer.
Here is the verbatim verbiage of the contract with regard to PTO:
```
The following bene... | 2019/11/25 | [
"https://workplace.stackexchange.com/questions/148634",
"https://workplace.stackexchange.com",
"https://workplace.stackexchange.com/users/38341/"
] | It sounds like a very normal business practice. Vacation is usually quoted in terms of days per year. Vacation usually accrues over time, generally with each paycheck. It would be very unusual to have an 80 hour vacation balance on day 1 with no restrictions on how you use it. The wording in the offer letter doesn't se... | **Check yourself. You may be getting a better deal than you thought you were.**
You thought you were negotiating for a one-time sum of 80 hours of leave. The company appears to be granting you 80 hours of leave per year. If you wind up working there for more than a year, is this not better? Best not to make too big a ... |
148,634 | I received an informal offer from a software company which included 0 hours of PTO. I countered the offer and was promised 10 days (80 hours) of PTO. With this apparent "signing bonus" as the deciding factor I accepted the offer.
Here is the verbatim verbiage of the contract with regard to PTO:
```
The following bene... | 2019/11/25 | [
"https://workplace.stackexchange.com/questions/148634",
"https://workplace.stackexchange.com",
"https://workplace.stackexchange.com/users/38341/"
] | Legalities aside, as I don't think you want to go that route to solve this anyway.
I understand that you are surprised by the fact that PTO accrues, they probably are as surprised by your surprise, as this is fairly normal thing in tech in many modern countries (US, UK, and Australia from my own experience). But is th... | **Check yourself. You may be getting a better deal than you thought you were.**
You thought you were negotiating for a one-time sum of 80 hours of leave. The company appears to be granting you 80 hours of leave per year. If you wind up working there for more than a year, is this not better? Best not to make too big a ... |
148,634 | I received an informal offer from a software company which included 0 hours of PTO. I countered the offer and was promised 10 days (80 hours) of PTO. With this apparent "signing bonus" as the deciding factor I accepted the offer.
Here is the verbatim verbiage of the contract with regard to PTO:
```
The following bene... | 2019/11/25 | [
"https://workplace.stackexchange.com/questions/148634",
"https://workplace.stackexchange.com",
"https://workplace.stackexchange.com/users/38341/"
] | I've known a lot of people who have negotiated some PTO from the outset\* when switching to companies that do PTO accrual instead of a flat number of eligible days per year. I have never known someone who was then told that they had to accrue the promised days, because it defeats the purpose of the negotiation. The onl... | This is how it usually works. You earn a certain amount of holidays over a year. During half a year you earn half that. If you leave the company, they have to pay you for the accrued leave that you haven't taken yet, or you have to pay back the money for leave that you have taken that wasn't accrued yet. (In the USA, y... |
148,634 | I received an informal offer from a software company which included 0 hours of PTO. I countered the offer and was promised 10 days (80 hours) of PTO. With this apparent "signing bonus" as the deciding factor I accepted the offer.
Here is the verbatim verbiage of the contract with regard to PTO:
```
The following bene... | 2019/11/25 | [
"https://workplace.stackexchange.com/questions/148634",
"https://workplace.stackexchange.com",
"https://workplace.stackexchange.com/users/38341/"
] | You've tagged your location as United States.
PTO accrual is typical in the US. PTO is typically quoted annually (X hours or X days per year), but you start with a zero or a near-zero amount, and it is "earned" either every paycheck or every month (or some other schedule of a similar scale). In effect, your X days of ... | It sounds like a very normal business practice. Vacation is usually quoted in terms of days per year. Vacation usually accrues over time, generally with each paycheck. It would be very unusual to have an 80 hour vacation balance on day 1 with no restrictions on how you use it. The wording in the offer letter doesn't se... |
148,634 | I received an informal offer from a software company which included 0 hours of PTO. I countered the offer and was promised 10 days (80 hours) of PTO. With this apparent "signing bonus" as the deciding factor I accepted the offer.
Here is the verbatim verbiage of the contract with regard to PTO:
```
The following bene... | 2019/11/25 | [
"https://workplace.stackexchange.com/questions/148634",
"https://workplace.stackexchange.com",
"https://workplace.stackexchange.com/users/38341/"
] | This is how it usually works. You earn a certain amount of holidays over a year. During half a year you earn half that. If you leave the company, they have to pay you for the accrued leave that you haven't taken yet, or you have to pay back the money for leave that you have taken that wasn't accrued yet. (In the USA, y... | **Check yourself. You may be getting a better deal than you thought you were.**
You thought you were negotiating for a one-time sum of 80 hours of leave. The company appears to be granting you 80 hours of leave per year. If you wind up working there for more than a year, is this not better? Best not to make too big a ... |
148,634 | I received an informal offer from a software company which included 0 hours of PTO. I countered the offer and was promised 10 days (80 hours) of PTO. With this apparent "signing bonus" as the deciding factor I accepted the offer.
Here is the verbatim verbiage of the contract with regard to PTO:
```
The following bene... | 2019/11/25 | [
"https://workplace.stackexchange.com/questions/148634",
"https://workplace.stackexchange.com",
"https://workplace.stackexchange.com/users/38341/"
] | You've tagged your location as United States.
PTO accrual is typical in the US. PTO is typically quoted annually (X hours or X days per year), but you start with a zero or a near-zero amount, and it is "earned" either every paycheck or every month (or some other schedule of a similar scale). In effect, your X days of ... | **Check yourself. You may be getting a better deal than you thought you were.**
You thought you were negotiating for a one-time sum of 80 hours of leave. The company appears to be granting you 80 hours of leave per year. If you wind up working there for more than a year, is this not better? Best not to make too big a ... |
148,634 | I received an informal offer from a software company which included 0 hours of PTO. I countered the offer and was promised 10 days (80 hours) of PTO. With this apparent "signing bonus" as the deciding factor I accepted the offer.
Here is the verbatim verbiage of the contract with regard to PTO:
```
The following bene... | 2019/11/25 | [
"https://workplace.stackexchange.com/questions/148634",
"https://workplace.stackexchange.com",
"https://workplace.stackexchange.com/users/38341/"
] | Legalities aside, as I don't think you want to go that route to solve this anyway.
I understand that you are surprised by the fact that PTO accrues, they probably are as surprised by your surprise, as this is fairly normal thing in tech in many modern countries (US, UK, and Australia from my own experience). But is th... | It sounds like a very normal business practice. Vacation is usually quoted in terms of days per year. Vacation usually accrues over time, generally with each paycheck. It would be very unusual to have an 80 hour vacation balance on day 1 with no restrictions on how you use it. The wording in the offer letter doesn't se... |
237,542 | I'm using GCC; \_\_FILE\_\_ returns the current source file's entire path and name: `/path/to/file.cpp`. Is there a way to get just the file's name `file.cpp` (without its path) at compile time? Is it possible to do this in a portable way? Can template meta programming be applied to strings?
I am using this in an erro... | 2008/10/26 | [
"https://Stackoverflow.com/questions/237542",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3175/"
] | I don't know of a direct way. You could use:
```
#line 1 "filename.c"
```
at the top of the source file to set the value of `__FILE__`, but I'm not sure that that's much better than hard coding it. or just using a #define to create your own macro.
Another option might be to pass the name from your Makefile using -D... | Taking the idea from Glomek, it can be automated like this:
Source file x.c
```
#line 1 MY_FILE_NAME
#include <stdio.h>
int main(void)
{
puts(__FILE__);
return(0);
}
```
Compilation line (beware the single quotes outside the double quotes):
```
gcc -DMY_FILE_NAME='"abcd.c"' -o x x.c
```
The output is '`... |
237,542 | I'm using GCC; \_\_FILE\_\_ returns the current source file's entire path and name: `/path/to/file.cpp`. Is there a way to get just the file's name `file.cpp` (without its path) at compile time? Is it possible to do this in a portable way? Can template meta programming be applied to strings?
I am using this in an erro... | 2008/10/26 | [
"https://Stackoverflow.com/questions/237542",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3175/"
] | If you're using a `make` program, you should be able to munge the filename beforehand and pass it as a macro to `gcc` to be used in your program. For example, in your `makefile`, change the line:
```
file.o: file.c
gcc -c -o file.o src/file.c
```
to:
```
file.o: src/file.c
gcc "-DMYFILE=\"`basename $<`\"" -... | The question is already 12 years old and back in 2008 this solution wasn't available, but
Starting with GCC 8 and CLANG 10, one can use the option [-fmacro-prefix-map](https://gcc.gnu.org/onlinedocs/gcc/Preprocessor-Options.html#index-fmacro-prefix-map).
Acording to GCC Manual:
>
> -fmacro-prefix-map=old=new
> ... |
237,542 | I'm using GCC; \_\_FILE\_\_ returns the current source file's entire path and name: `/path/to/file.cpp`. Is there a way to get just the file's name `file.cpp` (without its path) at compile time? Is it possible to do this in a portable way? Can template meta programming be applied to strings?
I am using this in an erro... | 2008/10/26 | [
"https://Stackoverflow.com/questions/237542",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3175/"
] | Consider this simple source code:
```
#include <stdio.h>
int main(void)
{
puts(__FILE__);
return(0);
}
```
On Solaris, with GCC 4.3.1, if I compile this using:
```
gcc -o x x.c && ./x
```
the output is '`x.c`' If I compile it using:
```
gcc -o x $PWD/x.c && ./x
```
then \_\_FILE\_\_ maps to the full pa... | Just got the same issue; found a different resolution, just thought I'd share it:
In a header file included in all my other files:
```
static char * file_bname = NULL;
#define __STRIPPED_FILE__ (file_bname ?: (file_bname = basename(__FILE__)))
```
Hope this is useful to someone else as well :) |
237,542 | I'm using GCC; \_\_FILE\_\_ returns the current source file's entire path and name: `/path/to/file.cpp`. Is there a way to get just the file's name `file.cpp` (without its path) at compile time? Is it possible to do this in a portable way? Can template meta programming be applied to strings?
I am using this in an erro... | 2008/10/26 | [
"https://Stackoverflow.com/questions/237542",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3175/"
] | I don't know of a direct way. You could use:
```
#line 1 "filename.c"
```
at the top of the source file to set the value of `__FILE__`, but I'm not sure that that's much better than hard coding it. or just using a #define to create your own macro.
Another option might be to pass the name from your Makefile using -D... | What does your error logging macro do? I would presume at some point the macro eventually calls a function of some kind in order to do the logging, why not have the called function strip off the path component at runtime?
```
#define LOG(message) _log(__FILE__, message)
void _log(file, message)
{
#ifndef DEBUG
st... |
237,542 | I'm using GCC; \_\_FILE\_\_ returns the current source file's entire path and name: `/path/to/file.cpp`. Is there a way to get just the file's name `file.cpp` (without its path) at compile time? Is it possible to do this in a portable way? Can template meta programming be applied to strings?
I am using this in an erro... | 2008/10/26 | [
"https://Stackoverflow.com/questions/237542",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3175/"
] | It is easy with cmake.
`DefineRelativeFilePaths.cmake`
```
function (cmake_define_relative_file_paths SOURCES)
foreach (SOURCE IN LISTS SOURCES)
file (
RELATIVE_PATH RELATIVE_SOURCE_PATH
${PROJECT_SOURCE_DIR} ${SOURCE}
)
set_source_files_properties (
${SOURCE} PROPERTIES
COMPILE... | You can assign `__FILE__` to a string, and then call \_splitpath() to rip the pieces out of it. This might be a Windows/MSVC-only solution, honestly I don't know.
I know you were looking for a compile-time solution and this is a run-time solution, but I figured since you were using the filename to do (presumably run-... |
237,542 | I'm using GCC; \_\_FILE\_\_ returns the current source file's entire path and name: `/path/to/file.cpp`. Is there a way to get just the file's name `file.cpp` (without its path) at compile time? Is it possible to do this in a portable way? Can template meta programming be applied to strings?
I am using this in an erro... | 2008/10/26 | [
"https://Stackoverflow.com/questions/237542",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3175/"
] | I don't know of a direct way. You could use:
```
#line 1 "filename.c"
```
at the top of the source file to set the value of `__FILE__`, but I'm not sure that that's much better than hard coding it. or just using a #define to create your own macro.
Another option might be to pass the name from your Makefile using -D... | Just got the same issue; found a different resolution, just thought I'd share it:
In a header file included in all my other files:
```
static char * file_bname = NULL;
#define __STRIPPED_FILE__ (file_bname ?: (file_bname = basename(__FILE__)))
```
Hope this is useful to someone else as well :) |
237,542 | I'm using GCC; \_\_FILE\_\_ returns the current source file's entire path and name: `/path/to/file.cpp`. Is there a way to get just the file's name `file.cpp` (without its path) at compile time? Is it possible to do this in a portable way? Can template meta programming be applied to strings?
I am using this in an erro... | 2008/10/26 | [
"https://Stackoverflow.com/questions/237542",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3175/"
] | I don't know of a direct way. You could use:
```
#line 1 "filename.c"
```
at the top of the source file to set the value of `__FILE__`, but I'm not sure that that's much better than hard coding it. or just using a #define to create your own macro.
Another option might be to pass the name from your Makefile using -D... | You can assign `__FILE__` to a string, and then call \_splitpath() to rip the pieces out of it. This might be a Windows/MSVC-only solution, honestly I don't know.
I know you were looking for a compile-time solution and this is a run-time solution, but I figured since you were using the filename to do (presumably run-... |
237,542 | I'm using GCC; \_\_FILE\_\_ returns the current source file's entire path and name: `/path/to/file.cpp`. Is there a way to get just the file's name `file.cpp` (without its path) at compile time? Is it possible to do this in a portable way? Can template meta programming be applied to strings?
I am using this in an erro... | 2008/10/26 | [
"https://Stackoverflow.com/questions/237542",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3175/"
] | I don't know of a direct way. You could use:
```
#line 1 "filename.c"
```
at the top of the source file to set the value of `__FILE__`, but I'm not sure that that's much better than hard coding it. or just using a #define to create your own macro.
Another option might be to pass the name from your Makefile using -D... | It is easy with cmake.
`DefineRelativeFilePaths.cmake`
```
function (cmake_define_relative_file_paths SOURCES)
foreach (SOURCE IN LISTS SOURCES)
file (
RELATIVE_PATH RELATIVE_SOURCE_PATH
${PROJECT_SOURCE_DIR} ${SOURCE}
)
set_source_files_properties (
${SOURCE} PROPERTIES
COMPILE... |
237,542 | I'm using GCC; \_\_FILE\_\_ returns the current source file's entire path and name: `/path/to/file.cpp`. Is there a way to get just the file's name `file.cpp` (without its path) at compile time? Is it possible to do this in a portable way? Can template meta programming be applied to strings?
I am using this in an erro... | 2008/10/26 | [
"https://Stackoverflow.com/questions/237542",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3175/"
] | You can assign `__FILE__` to a string, and then call \_splitpath() to rip the pieces out of it. This might be a Windows/MSVC-only solution, honestly I don't know.
I know you were looking for a compile-time solution and this is a run-time solution, but I figured since you were using the filename to do (presumably run-... | Just got the same issue; found a different resolution, just thought I'd share it:
In a header file included in all my other files:
```
static char * file_bname = NULL;
#define __STRIPPED_FILE__ (file_bname ?: (file_bname = basename(__FILE__)))
```
Hope this is useful to someone else as well :) |
237,542 | I'm using GCC; \_\_FILE\_\_ returns the current source file's entire path and name: `/path/to/file.cpp`. Is there a way to get just the file's name `file.cpp` (without its path) at compile time? Is it possible to do this in a portable way? Can template meta programming be applied to strings?
I am using this in an erro... | 2008/10/26 | [
"https://Stackoverflow.com/questions/237542",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3175/"
] | You might be able to do it with template metaprogramming, but there's no built-in way to do it.
EDIT: Hm, correction. According to [one page I just saw](http://coding.derkeiler.com/Archive/C_CPP/comp.lang.c/2006-02/msg00698.html), GCC uses the path that it's given for the file. If it's given the full name, it'll embed... | Just got the same issue; found a different resolution, just thought I'd share it:
In a header file included in all my other files:
```
static char * file_bname = NULL;
#define __STRIPPED_FILE__ (file_bname ?: (file_bname = basename(__FILE__)))
```
Hope this is useful to someone else as well :) |
42,218,999 | Im unable to run the generated jar file with my spring-boot with jersey project.
exception that i encounter is:
```
Error starting Tomcat context. Exception: org.springframework.beans.factory.UnsatisfiedDependencyException. Message: Error creating bean with name 'org.springframework.boot.autoconfigure.jersey.JerseyAu... | 2017/02/14 | [
"https://Stackoverflow.com/questions/42218999",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/887040/"
] | This is more of a workaround than an actual valid solution to use
packages(true, "my.package");
in reference to Anton's answer, i settled with this solution with the limitation that it requires resources with class level @Path or @Provider annotation:
```
ClassPathScanningCandidateComponentProvider provider = new Cla... | I had this problem, I did not want to complicate things too much so I just registered all my jersey controllers individually.
```
@Configuration
public class JerseyConfig extends ResourceConfig {
JerseyConfig() {
// my old version that does not play well with spring boot fat jar
/*
... |
42,218,999 | Im unable to run the generated jar file with my spring-boot with jersey project.
exception that i encounter is:
```
Error starting Tomcat context. Exception: org.springframework.beans.factory.UnsatisfiedDependencyException. Message: Error creating bean with name 'org.springframework.boot.autoconfigure.jersey.JerseyAu... | 2017/02/14 | [
"https://Stackoverflow.com/questions/42218999",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/887040/"
] | This is more of a workaround than an actual valid solution to use
packages(true, "my.package");
in reference to Anton's answer, i settled with this solution with the limitation that it requires resources with class level @Path or @Provider annotation:
```
ClassPathScanningCandidateComponentProvider provider = new Cla... | Alternatively you could do,
```
@Configuration
public class JerseyConfig extends ResourceConfig {
JerseyConfig() {
BeanConfig beanConfig = new BeanConfig();
beanConfig.setResourcePackage("com.mycompany.api.resources");
}
}
``` |
42,218,999 | Im unable to run the generated jar file with my spring-boot with jersey project.
exception that i encounter is:
```
Error starting Tomcat context. Exception: org.springframework.beans.factory.UnsatisfiedDependencyException. Message: Error creating bean with name 'org.springframework.boot.autoconfigure.jersey.JerseyAu... | 2017/02/14 | [
"https://Stackoverflow.com/questions/42218999",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/887040/"
] | I had this problem, I did not want to complicate things too much so I just registered all my jersey controllers individually.
```
@Configuration
public class JerseyConfig extends ResourceConfig {
JerseyConfig() {
// my old version that does not play well with spring boot fat jar
/*
... | Alternatively you could do,
```
@Configuration
public class JerseyConfig extends ResourceConfig {
JerseyConfig() {
BeanConfig beanConfig = new BeanConfig();
beanConfig.setResourcePackage("com.mycompany.api.resources");
}
}
``` |
63,213,775 | I want to use Excel to generate random numbers between 1 and 10 and then count how many numbers were generated for each number to be generated.
I know how to generate random numbers, i.e. =RANDBETWEEN(1,10)
and then just pull down the corner.
But it's a bit of work to manually go through the list checking when all t... | 2020/08/02 | [
"https://Stackoverflow.com/questions/63213775",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2948187/"
] | Assuming you have a header you could use:
[](https://i.stack.imgur.com/zlxMf.png)
Formula in `A2`:
```
=IF(SUM(--ISNUMBER(MATCH(ROW($1:$10),A$1:A1,0)))=10,"Done: "&ROW()-2&" numbers made",RANDBETWEEN(1,10))
```
Note that this is an array formula a... | If you have an existing list of random numbers in the range 1 to 10 and want to check it to see at what point all of the numbers in that range have been generated, you could use a formula like this:
```
=MATCH(10,MMULT(SIGN(COUNTIF(OFFSET(A1,0,0,ROW(1:100)),COLUMN(A:J))),ROW(1:10)^0),0)
```
assuming that there are u... |
17,333,057 | Why does the following code block not work?
```
int *p1 = malloc(128);
int main(void) {
char *p2 = malloc(128);
}
``` | 2013/06/27 | [
"https://Stackoverflow.com/questions/17333057",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1443642/"
] | initializer of a global variable must be constant, so the first `malloc` will cause a compile time error. | you can't use malloc to initialize p1 outside of the a code block like that, just do it inside main like p2 |
17,333,057 | Why does the following code block not work?
```
int *p1 = malloc(128);
int main(void) {
char *p2 = malloc(128);
}
``` | 2013/06/27 | [
"https://Stackoverflow.com/questions/17333057",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1443642/"
] | you can't use malloc to initialize p1 outside of the a code block like that, just do it inside main like p2 | 1st, the basic error is that your main method must return some int value
```
int main(void) {
char *p2 = malloc(128);
return 0;
}
```
or try
```
void main(){
char *p2 = malloc(128);
}
```
2nd, you may want to specify what kind of buffer that your pointer is, otherwise, it will be a (void\*) type pointer, so I su... |
17,333,057 | Why does the following code block not work?
```
int *p1 = malloc(128);
int main(void) {
char *p2 = malloc(128);
}
``` | 2013/06/27 | [
"https://Stackoverflow.com/questions/17333057",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1443642/"
] | initializer of a global variable must be constant, so the first `malloc` will cause a compile time error. | You can't call a function in the initialization of a global variable. This is the line it's complaining about:
```
int *p1 = malloc(128);
```
Change this to NULL and then in main, initialize it. |
17,333,057 | Why does the following code block not work?
```
int *p1 = malloc(128);
int main(void) {
char *p2 = malloc(128);
}
``` | 2013/06/27 | [
"https://Stackoverflow.com/questions/17333057",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1443642/"
] | You can't call a function in the initialization of a global variable. This is the line it's complaining about:
```
int *p1 = malloc(128);
```
Change this to NULL and then in main, initialize it. | 1st, the basic error is that your main method must return some int value
```
int main(void) {
char *p2 = malloc(128);
return 0;
}
```
or try
```
void main(){
char *p2 = malloc(128);
}
```
2nd, you may want to specify what kind of buffer that your pointer is, otherwise, it will be a (void\*) type pointer, so I su... |
17,333,057 | Why does the following code block not work?
```
int *p1 = malloc(128);
int main(void) {
char *p2 = malloc(128);
}
``` | 2013/06/27 | [
"https://Stackoverflow.com/questions/17333057",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1443642/"
] | initializer of a global variable must be constant, so the first `malloc` will cause a compile time error. | 1st, the basic error is that your main method must return some int value
```
int main(void) {
char *p2 = malloc(128);
return 0;
}
```
or try
```
void main(){
char *p2 = malloc(128);
}
```
2nd, you may want to specify what kind of buffer that your pointer is, otherwise, it will be a (void\*) type pointer, so I su... |
319,825 | When dividing variables, does each term in the numerator have to have a variable for it to be divided? For example if the problem is
$$\frac{9x+8x^2+1}{x}$$
can it be simplified to
$$9+8x+1?$$
Or does there need to be an variable with the 1 in this case? | 2013/03/03 | [
"https://math.stackexchange.com/questions/319825",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/62252/"
] | Yes, the 1 cannot vanish. In your case, using the distributive law,
$$\begin{align}
\frac{9x + 8x^2 +1}{x} & = \frac{9x}{x} + \frac{8x^2}{x} + \frac{1}{x} \\
& = 9 + 8x + \frac{1}{x} \\
& \neq 9 + 8x + 1 \\
\end{align}$$ | Another way to look at "1" is that it is $1\cdot x^0$.
In general, to get a non-negative power of $x$
when dividing $x^a$ by $x^b$,
you must have $b \le a$, and the result
will be $x^{a-b}$.
So, $\frac{1}{x} =\frac{1\cdot x^0}{x^1}
=1\cdot x^{0-1} = x^{-1}$. |
319,825 | When dividing variables, does each term in the numerator have to have a variable for it to be divided? For example if the problem is
$$\frac{9x+8x^2+1}{x}$$
can it be simplified to
$$9+8x+1?$$
Or does there need to be an variable with the 1 in this case? | 2013/03/03 | [
"https://math.stackexchange.com/questions/319825",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/62252/"
] | Yes, the 1 cannot vanish. In your case, using the distributive law,
$$\begin{align}
\frac{9x + 8x^2 +1}{x} & = \frac{9x}{x} + \frac{8x^2}{x} + \frac{1}{x} \\
& = 9 + 8x + \frac{1}{x} \\
& \neq 9 + 8x + 1 \\
\end{align}$$ | You can easily check your work: what is $x\times(9+8x+1)$?
$$
x(9+8x+1) = 9x+8x²+x\ne 9x+8x²+1
$$ |
319,825 | When dividing variables, does each term in the numerator have to have a variable for it to be divided? For example if the problem is
$$\frac{9x+8x^2+1}{x}$$
can it be simplified to
$$9+8x+1?$$
Or does there need to be an variable with the 1 in this case? | 2013/03/03 | [
"https://math.stackexchange.com/questions/319825",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/62252/"
] | You can easily check your work: what is $x\times(9+8x+1)$?
$$
x(9+8x+1) = 9x+8x²+x\ne 9x+8x²+1
$$ | Another way to look at "1" is that it is $1\cdot x^0$.
In general, to get a non-negative power of $x$
when dividing $x^a$ by $x^b$,
you must have $b \le a$, and the result
will be $x^{a-b}$.
So, $\frac{1}{x} =\frac{1\cdot x^0}{x^1}
=1\cdot x^{0-1} = x^{-1}$. |
30,729,386 | I have a main module `main` which contains a service `mainService`. I have then injected another module `moduleA` in my main module. I randomly called `mainService` in `moduleA` without injecting `main` module and was amazed to see it is working fine.
```
angular.module('main', ['moduleA']);
angular.module('main').ser... | 2015/06/09 | [
"https://Stackoverflow.com/questions/30729386",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3887593/"
] | Yes you can use the service of main because of parent child relationship. "main" is a parent module and "moduleA" its child/dependency module.
Any serivce, controller, directive defined in "main" module will be available with "moduleA"
Lets understand this concept with a more complex scenario
```
angular.module('mai... | Injecting something like a service in the parent, makes it available to all its children. |
30,729,386 | I have a main module `main` which contains a service `mainService`. I have then injected another module `moduleA` in my main module. I randomly called `mainService` in `moduleA` without injecting `main` module and was amazed to see it is working fine.
```
angular.module('main', ['moduleA']);
angular.module('main').ser... | 2015/06/09 | [
"https://Stackoverflow.com/questions/30729386",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3887593/"
] | Yes you can use the service of main because of parent child relationship. "main" is a parent module and "moduleA" its child/dependency module.
Any serivce, controller, directive defined in "main" module will be available with "moduleA"
Lets understand this concept with a more complex scenario
```
angular.module('mai... | Worth reading <http://michalostruszka.pl/blog/2015/05/21/angular-dependencies-naming-clash/> to know few more things about modules.
Summary from the post:
>
> It turns out AngularJS doesn’t really care where it takes things to inject from as long as the name matches
>
>
> In AngularJS there is no such thing as mod... |
30,729,386 | I have a main module `main` which contains a service `mainService`. I have then injected another module `moduleA` in my main module. I randomly called `mainService` in `moduleA` without injecting `main` module and was amazed to see it is working fine.
```
angular.module('main', ['moduleA']);
angular.module('main').ser... | 2015/06/09 | [
"https://Stackoverflow.com/questions/30729386",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3887593/"
] | Injecting something like a service in the parent, makes it available to all its children. | Worth reading <http://michalostruszka.pl/blog/2015/05/21/angular-dependencies-naming-clash/> to know few more things about modules.
Summary from the post:
>
> It turns out AngularJS doesn’t really care where it takes things to inject from as long as the name matches
>
>
> In AngularJS there is no such thing as mod... |
20,581,387 | I am trying to make a vertical navigation bar, I am using bootstrap 3.0,
I searched for any example and could only find [this](http://d.alistapart.com/horizdropdowns/horizontal2.htm)
```
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">About</a>
<ul>
<li><a href="#">History</a></li>
<li><a href="#">... | 2013/12/14 | [
"https://Stackoverflow.com/questions/20581387",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2413621/"
] | ```
DELETE FROM tbl_rate WHERE
From_LocationID NOT IN(
select
a.Route_LocationID from_loc_id
from tbl_route a
inner join tbl_route b on a.Route_ID = b.Route_ID and a.Route_Seq < b.Route_Seq and a.Route_ID = 3
inner join tbl_location la on la.Location_ID = a.Route_LocationID
inner join tbl_location lb on lb.L... | Try to add `DISTINCT` because `mySQL` is super-cautious in subqueries, like:
```
SELECT DISTINCT Rate_ID FROM tbl_rate WHERE ....
```
So, it would be like:
```
DELETE FROM tbl_rate WHERE Rate_ID ( SELECT DISTINCT Rate_ID FROM tbl_rate WHERE .... )
```
Another way is to make an alias of your subquery like:
```
D... |
20,581,387 | I am trying to make a vertical navigation bar, I am using bootstrap 3.0,
I searched for any example and could only find [this](http://d.alistapart.com/horizdropdowns/horizontal2.htm)
```
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">About</a>
<ul>
<li><a href="#">History</a></li>
<li><a href="#">... | 2013/12/14 | [
"https://Stackoverflow.com/questions/20581387",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2413621/"
] | If you want to use a subquery in `DELETE` with the same table you're deleting from all you have to do is to wrap your query in additional outer select
```
DELETE
FROM tbl_rate
WHERE Rate_ID IN
(
SELECT Rate_ID
FROM
(
SELECT Rate_ID... --- Your original query goes here
) q
);
```
Here is **[SQLFi... | ```
DELETE FROM tbl_rate WHERE
From_LocationID NOT IN(
select
a.Route_LocationID from_loc_id
from tbl_route a
inner join tbl_route b on a.Route_ID = b.Route_ID and a.Route_Seq < b.Route_Seq and a.Route_ID = 3
inner join tbl_location la on la.Location_ID = a.Route_LocationID
inner join tbl_location lb on lb.L... |
20,581,387 | I am trying to make a vertical navigation bar, I am using bootstrap 3.0,
I searched for any example and could only find [this](http://d.alistapart.com/horizdropdowns/horizontal2.htm)
```
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">About</a>
<ul>
<li><a href="#">History</a></li>
<li><a href="#">... | 2013/12/14 | [
"https://Stackoverflow.com/questions/20581387",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2413621/"
] | If you want to use a subquery in `DELETE` with the same table you're deleting from all you have to do is to wrap your query in additional outer select
```
DELETE
FROM tbl_rate
WHERE Rate_ID IN
(
SELECT Rate_ID
FROM
(
SELECT Rate_ID... --- Your original query goes here
) q
);
```
Here is **[SQLFi... | Try to add `DISTINCT` because `mySQL` is super-cautious in subqueries, like:
```
SELECT DISTINCT Rate_ID FROM tbl_rate WHERE ....
```
So, it would be like:
```
DELETE FROM tbl_rate WHERE Rate_ID ( SELECT DISTINCT Rate_ID FROM tbl_rate WHERE .... )
```
Another way is to make an alias of your subquery like:
```
D... |
10,540,698 | I have this code in version sencha touch 1.1, how to make it works in Version 2?. "load" is not working
Html:
```
<img src="" id="previewImage"/>
```
Code:
```
this.domImage=Ext.get("previewImage");
this.domImage.on("load",function(){
debugger; // not working
a.sizePhotoInContainer();
a.resizePhoto()
}... | 2012/05/10 | [
"https://Stackoverflow.com/questions/10540698",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/999525/"
] | `load` is ***not a property*** for `image` component in ST2. It's an `event` that will be fired when image is loaded.
So, you need to `listen` for `load` event of `image` component in Sencha Touch 2.
Do it like this,
```
var img = Ext.create('Ext.Img', {
src: 'http://www.sencha.com/assets/images/sencha-avatar-64... | I don't have much experience with Sencha, but I think it would be something like this...
```
// create image
var img = Ext.create('Ext.Img', {
src: 'http://www.sencha.com/example.png'
});
// callback on load
img.load = function() {
}
```
Or
```
var img = Ext.create('Ext.Img', {
src: 'http://www.sencha.com/e... |
35,333,889 | Is there a way to use extract from date in format `YYYY-MM-DD` how many days were in this month?
example:
for `2016-02-05` it will give `29` (Feb 2016 has 29 days)
for `2016-03-12` it will give `31`
for `2015-02-05` it will give `28` (Feb 2015 had 28 days)
I'm using PostgreSQL
**EDIT:**
[LAST\_DAY function in p... | 2016/02/11 | [
"https://Stackoverflow.com/questions/35333889",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1712099/"
] | One way to achieve this would be to subtract the beginning of the following month from the beginning of the current month:
```
db=> SELECT DATE_TRUNC('MONTH', '2016-02-05'::DATE + INTERVAL '1 MONTH') -
DATE_TRUNC('MONTH', '2016-02-05'::DATE);
?column?
----------
29 days
(1 row)
``` | You can try next:
```
SELECT
DATE_PART('days',
DATE_TRUNC('month', TO_DATE('2016-02-05', 'YYYY-MM-DD'))
+ '1 MONTH'::INTERVAL
- DATE_TRUNC('month', TO_DATE('2016-02-05', 'YYYY-MM-DD'))
);
```
Note: there date is used twice. And used convert function `TO_DATE` |
35,333,889 | Is there a way to use extract from date in format `YYYY-MM-DD` how many days were in this month?
example:
for `2016-02-05` it will give `29` (Feb 2016 has 29 days)
for `2016-03-12` it will give `31`
for `2015-02-05` it will give `28` (Feb 2015 had 28 days)
I'm using PostgreSQL
**EDIT:**
[LAST\_DAY function in p... | 2016/02/11 | [
"https://Stackoverflow.com/questions/35333889",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1712099/"
] | One way to achieve this would be to subtract the beginning of the following month from the beginning of the current month:
```
db=> SELECT DATE_TRUNC('MONTH', '2016-02-05'::DATE + INTERVAL '1 MONTH') -
DATE_TRUNC('MONTH', '2016-02-05'::DATE);
?column?
----------
29 days
(1 row)
``` | Just needed this today and seems that I came up with pretty much the same as Mureinik, just that I needed it numeric. (PostgreSQL couldn't convert from interval to number directly)
**previous month**:
```
select CAST(to_char(date_trunc('month', current_date) - (date_trunc('month', current_date) - interval '1 month'),... |
35,333,889 | Is there a way to use extract from date in format `YYYY-MM-DD` how many days were in this month?
example:
for `2016-02-05` it will give `29` (Feb 2016 has 29 days)
for `2016-03-12` it will give `31`
for `2015-02-05` it will give `28` (Feb 2015 had 28 days)
I'm using PostgreSQL
**EDIT:**
[LAST\_DAY function in p... | 2016/02/11 | [
"https://Stackoverflow.com/questions/35333889",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1712099/"
] | Just needed this today and seems that I came up with pretty much the same as Mureinik, just that I needed it numeric. (PostgreSQL couldn't convert from interval to number directly)
**previous month**:
```
select CAST(to_char(date_trunc('month', current_date) - (date_trunc('month', current_date) - interval '1 month'),... | You can try next:
```
SELECT
DATE_PART('days',
DATE_TRUNC('month', TO_DATE('2016-02-05', 'YYYY-MM-DD'))
+ '1 MONTH'::INTERVAL
- DATE_TRUNC('month', TO_DATE('2016-02-05', 'YYYY-MM-DD'))
);
```
Note: there date is used twice. And used convert function `TO_DATE` |
2,071,595 | I'm sorry if the title question isn't very clear but i don't think i can expalain my problem in a single sentance.
I have a table with a number of different types of events in it all recorded against a date.
I'm querying the table and grouping based on a subset of the date (month and year).
```
SELECT DATENAME(MONTH... | 2010/01/15 | [
"https://Stackoverflow.com/questions/2071595",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1458933/"
] | The usual approach for this is to just have a table of dates in your database and do LEFT JOINs from it to your data. | You could insert a list of all the months you're interested in, into a table variable and then do an OUTER join from that onto the table containing your data. |
2,071,595 | I'm sorry if the title question isn't very clear but i don't think i can expalain my problem in a single sentance.
I have a table with a number of different types of events in it all recorded against a date.
I'm querying the table and grouping based on a subset of the date (month and year).
```
SELECT DATENAME(MONTH... | 2010/01/15 | [
"https://Stackoverflow.com/questions/2071595",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1458933/"
] | The usual approach for this is to just have a table of dates in your database and do LEFT JOINs from it to your data. | ```
WITH months (d) AS
(
SELECT CAST('2009-01-01' AS DATETIME)
UNION ALL
SELECT DATEADD(month, d, 1)
FROM months
WHERE d <= '2015-01-01'
)
SELECT d, COUNT(reason)
FROM months
JOIN blacklist_history bh
ON event_date_time >= d
AND event... |
56,546 | Here is a zoomed-in example of an [image](https://i.stack.imgur.com/enX4q.jpg) I shot that has a bit of discoloration due to the chromatic aberration of the lens.

What's the easiest way to fix this problem using only free software such as GIMP? I'd like to for the m... | 2014/11/08 | [
"https://photo.stackexchange.com/questions/56546",
"https://photo.stackexchange.com",
"https://photo.stackexchange.com/users/28383/"
] | 
[Darktable](http://www.darktable.org/) can remove chromatic aberrations if you are shooting raw. Your example image is a JPEG so I can't demonstrate how it works with that, but above is a screenshot of it removing the chromatic aberrations from a photo of a ... | [Rawtherapee](http://rawtherapee.com/) can do it to processed images. For some reason, "Defringe" is located on the detail tab, and you can specify what colors you want to take care of. |
56,546 | Here is a zoomed-in example of an [image](https://i.stack.imgur.com/enX4q.jpg) I shot that has a bit of discoloration due to the chromatic aberration of the lens.

What's the easiest way to fix this problem using only free software such as GIMP? I'd like to for the m... | 2014/11/08 | [
"https://photo.stackexchange.com/questions/56546",
"https://photo.stackexchange.com",
"https://photo.stackexchange.com/users/28383/"
] | 
[Darktable](http://www.darktable.org/) can remove chromatic aberrations if you are shooting raw. Your example image is a JPEG so I can't demonstrate how it works with that, but above is a screenshot of it removing the chromatic aberrations from a photo of a ... | You can use [Lensfun](http://lensfun.sourceforge.net/). Lensfun is a free/open-source (LGPL) library for fixing a number of defects from lenses.
Check the list of supported lenses here: [Lensfun coverage](http://wilson.bronger.org/lensfun_coverage.html).
See the "TCA" column, they are the lenses where data is availabl... |
56,625,895 | I want to find urls in a html content String in Java. This urls should have some conditions.
As an Example consider below String.
```
"background-image: url("https://mmbiz.qpic.cn/mmbiz_gif/uMa5Y2rQ8PkXuk9veIibUjBk1iaxlKqoAeBKejmFicic0C3lZuG58rYIPAHzsR6icicecc58OacuXeZ9CUicvG1d5ib3v/0?wx_fmt=gif") style="display: fl... | 2019/06/17 | [
"https://Stackoverflow.com/questions/56625895",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9353766/"
] | Using [`REGEXP`](https://dev.mysql.com/doc/refman/5.7/en/regexp.html#operator_regexp) this is possbile:
```
select *
from apple
where `name` REGEXP '^applej[0-9]'
```
[**Demo on db<>fiddle**](https://dbfiddle.uk/?rdbms=mysql_8.0&fiddle=2323b644523c89a4b28ebb9df0af68e7).
---
**Update:**
If the `name` has data as... | You can use a regular expression, this will include all rows containing 'applej' + 0 or 1 more character
```
SELECT * FROM test WHERE col1 REGEXP '^applej.?$'
```
This one will find all rows containing 'applej' + exactly 1 more character
```
SELECT * FROM test WHERE col1 REGEXP '^applej.{1}$'
```
And if the num... |
56,625,895 | I want to find urls in a html content String in Java. This urls should have some conditions.
As an Example consider below String.
```
"background-image: url("https://mmbiz.qpic.cn/mmbiz_gif/uMa5Y2rQ8PkXuk9veIibUjBk1iaxlKqoAeBKejmFicic0C3lZuG58rYIPAHzsR6icicecc58OacuXeZ9CUicvG1d5ib3v/0?wx_fmt=gif") style="display: fl... | 2019/06/17 | [
"https://Stackoverflow.com/questions/56625895",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9353766/"
] | You can use a regular expression, this will include all rows containing 'applej' + 0 or 1 more character
```
SELECT * FROM test WHERE col1 REGEXP '^applej.?$'
```
This one will find all rows containing 'applej' + exactly 1 more character
```
SELECT * FROM test WHERE col1 REGEXP '^applej.{1}$'
```
And if the num... | i found the solution with
```
SELECT * FROM apple WHERE MATCH(name) AGAINST('applej')
``` |
56,625,895 | I want to find urls in a html content String in Java. This urls should have some conditions.
As an Example consider below String.
```
"background-image: url("https://mmbiz.qpic.cn/mmbiz_gif/uMa5Y2rQ8PkXuk9veIibUjBk1iaxlKqoAeBKejmFicic0C3lZuG58rYIPAHzsR6icicecc58OacuXeZ9CUicvG1d5ib3v/0?wx_fmt=gif") style="display: fl... | 2019/06/17 | [
"https://Stackoverflow.com/questions/56625895",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9353766/"
] | Using [`REGEXP`](https://dev.mysql.com/doc/refman/5.7/en/regexp.html#operator_regexp) this is possbile:
```
select *
from apple
where `name` REGEXP '^applej[0-9]'
```
[**Demo on db<>fiddle**](https://dbfiddle.uk/?rdbms=mysql_8.0&fiddle=2323b644523c89a4b28ebb9df0af68e7).
---
**Update:**
If the `name` has data as... | You can try this,
```
SELECT * FROM apple where name LIKE '%applej_'
```
'\_' is used to represent a single character in SQL server.
For MS Access you can try this
```
SELECT * FROM apple where name LIKE '*applej?'
``` |
56,625,895 | I want to find urls in a html content String in Java. This urls should have some conditions.
As an Example consider below String.
```
"background-image: url("https://mmbiz.qpic.cn/mmbiz_gif/uMa5Y2rQ8PkXuk9veIibUjBk1iaxlKqoAeBKejmFicic0C3lZuG58rYIPAHzsR6icicecc58OacuXeZ9CUicvG1d5ib3v/0?wx_fmt=gif") style="display: fl... | 2019/06/17 | [
"https://Stackoverflow.com/questions/56625895",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9353766/"
] | Using [`REGEXP`](https://dev.mysql.com/doc/refman/5.7/en/regexp.html#operator_regexp) this is possbile:
```
select *
from apple
where `name` REGEXP '^applej[0-9]'
```
[**Demo on db<>fiddle**](https://dbfiddle.uk/?rdbms=mysql_8.0&fiddle=2323b644523c89a4b28ebb9df0af68e7).
---
**Update:**
If the `name` has data as... | i found the solution with
```
SELECT * FROM apple WHERE MATCH(name) AGAINST('applej')
``` |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.