qid int64 1 74.7M | question stringlengths 0 58.3k | date stringlengths 10 10 | metadata list | response_j stringlengths 2 48.3k | response_k stringlengths 2 40.5k |
|---|---|---|---|---|---|
31,004,962 | I have a json schema defining several properties. I've moved 2 of the properties to definitions and I make references to them. I did this because I wanted to group them together and do some testing for these properties in a generic way. This works fine and all the json data is handled as before.
But, I noticed that w... | 2015/06/23 | [
"https://Stackoverflow.com/questions/31004962",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3884280/"
] | There are a lot of problems with how you reference your definitions.
###JSON objects can not have duplicate properties
All properties in a JSON or JavaScript object are unique. The second one will overwrite the first. Consider the syntax for accessing a property to understand why. When you read your JSON into a JavaSc... | This has nothing to do with `require`, object keys are not unique (in that you may declare them several times in one object), but they are overwritable (in the same way that a variable declared twice is overwritable). You will only receive the last value declared on two keys with the same name.
I'd suggesting giving t... |
56,887,520 | I'm fetching github repositories from api.github.com/users/ncesar/repos and i wanna get only 10 items, then after scrolling, load more items. I have tried to implement myself but i dont know how to adapt it to array slice(that is limiting my array length to 2, just for testings).
This is my current code
```
class Se... | 2019/07/04 | [
"https://Stackoverflow.com/questions/56887520",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8402168/"
] | You could use the empty line as a loop-breaker:
```
while (s.hasNextLine()){ //no need for "== true"
String read = s.nextLine();
if(read == null || read.isEmpty()){ //if the line is empty
break; //exit the loop
}
in.add(read);
[...]
}
``` | You could end the loop with something like below. Here, the String "END" (case-insenstive) is used to signify end of the multi-line content:
```
public static void main(String[] args) {
ArrayList<String> in = new ArrayList<String>();
Scanner s = new Scanner(System.in);
while (s.hasNextLine())... |
56,887,520 | I'm fetching github repositories from api.github.com/users/ncesar/repos and i wanna get only 10 items, then after scrolling, load more items. I have tried to implement myself but i dont know how to adapt it to array slice(that is limiting my array length to 2, just for testings).
This is my current code
```
class Se... | 2019/07/04 | [
"https://Stackoverflow.com/questions/56887520",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8402168/"
] | You could use the empty line as a loop-breaker:
```
while (s.hasNextLine()){ //no need for "== true"
String read = s.nextLine();
if(read == null || read.isEmpty()){ //if the line is empty
break; //exit the loop
}
in.add(read);
[...]
}
``` | You can use this code. It returns when the user press `Enter` on an empty line.
```
import java.util.Scanner;
import java.util.ArrayList;
public class Main {
public static void main(String[] args){
Scanner scanner = new Scanner(System.in);
ArrayList<String> arrayLines = new ArrayList<>();
... |
56,887,520 | I'm fetching github repositories from api.github.com/users/ncesar/repos and i wanna get only 10 items, then after scrolling, load more items. I have tried to implement myself but i dont know how to adapt it to array slice(that is limiting my array length to 2, just for testings).
This is my current code
```
class Se... | 2019/07/04 | [
"https://Stackoverflow.com/questions/56887520",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8402168/"
] | You could use the empty line as a loop-breaker:
```
while (s.hasNextLine()){ //no need for "== true"
String read = s.nextLine();
if(read == null || read.isEmpty()){ //if the line is empty
break; //exit the loop
}
in.add(read);
[...]
}
``` | You can do somthing like this:
```
while (s.hasNextLine() == true){
String line = s.nextLine();
if ("".equals(line)) {
break;
}
in.add(line);
//infinite loop
}
``` |
201,138 | Wrote a long story about me moving my mothers washing machine but decided to keep it short:
Machine 8 years old, aesthetically in perfect condition other than some exposed sheet metal on the side due to a scratch. Reportedly a few of its programs don't work.
The room where I installed it was (according to the previou... | 2020/08/15 | [
"https://diy.stackexchange.com/questions/201138",
"https://diy.stackexchange.com",
"https://diy.stackexchange.com/users/51018/"
] | Well, don't be confused by what happens in North America. There, some very silly things were done to dryers regarding bootlegging ground off neutral, and so dryers are a holy terror. Not Your Problem.
Your washer hooks up just like a normal appliance - Hot, Neutral and Earth.
I suspect the root of your problem is thi... | I would verify the polarization is correct. When I was a kid all of my grand mothers house outlets were non polarized. I remember getting the tingle touching the metal toaster. My grandma pulled the cord out flipped it over and plugged it back in. I remember trying that as I got older with socks on then with shoes unti... |
11,420,224 | According to this quirksmode article, <http://www.quirksmode.org/css/display.html>
>
> A block has some whitespace above and below it and tolerates no HTML
> elements next to it, except when ordered
>
>
>
Are the whitespace above or below stated in pixels or is it just 'whitespace'?. | 2012/07/10 | [
"https://Stackoverflow.com/questions/11420224",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/492293/"
] | In the given context, "whitespace" is a gross misnomer. Whitespace in terms of text should *never* directly interfere with the layout of non-inline block boxes; what you should see between block boxes are *margins* (usually of said boxes), which are completely different.
Margins are indeed stated in pixels. In fact, t... | The 'whitespace' is the element's margin and can be controlled via any standard CSS unit (e.g. px, em, %, etc.) |
11,420,224 | According to this quirksmode article, <http://www.quirksmode.org/css/display.html>
>
> A block has some whitespace above and below it and tolerates no HTML
> elements next to it, except when ordered
>
>
>
Are the whitespace above or below stated in pixels or is it just 'whitespace'?. | 2012/07/10 | [
"https://Stackoverflow.com/questions/11420224",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/492293/"
] | The 'whitespace' is the element's margin and can be controlled via any standard CSS unit (e.g. px, em, %, etc.) | You can use the padding or margin properties of a CSS element to specify such a thing (in any CSS unit, including pixels). You many specify something like:
```
.class
{
padding-left: 4px;
padding-top: 3px;
}
```
The difference between padding and margin has to do with display. The padding property puts some '... |
11,420,224 | According to this quirksmode article, <http://www.quirksmode.org/css/display.html>
>
> A block has some whitespace above and below it and tolerates no HTML
> elements next to it, except when ordered
>
>
>
Are the whitespace above or below stated in pixels or is it just 'whitespace'?. | 2012/07/10 | [
"https://Stackoverflow.com/questions/11420224",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/492293/"
] | In the given context, "whitespace" is a gross misnomer. Whitespace in terms of text should *never* directly interfere with the layout of non-inline block boxes; what you should see between block boxes are *margins* (usually of said boxes), which are completely different.
Margins are indeed stated in pixels. In fact, t... | You can use the padding or margin properties of a CSS element to specify such a thing (in any CSS unit, including pixels). You many specify something like:
```
.class
{
padding-left: 4px;
padding-top: 3px;
}
```
The difference between padding and margin has to do with display. The padding property puts some '... |
8,029,871 | I am working on a webapp in WinXP, Eclipse Indigo and Google web plugin.
I have a simple form that takes a value from user (e.g email) , passes it to a servlet named `SignIn.java` that processes it and saves the email value to the session.
The `SignIn` code is very simple , here is what its `doGet` mostly does:
```
... | 2011/11/06 | [
"https://Stackoverflow.com/questions/8029871",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1032663/"
] | If your `SignIn` servlet is only saving a request parameter (email), then you could also replace the servlet with a [filter](https://stackoverflow.com/tags/servlet-filters/info), e.g. `SignInFilter`.
`SignInFilter` would contain the same logic as your `SignIn` servlet (copying the email from the request parameters to ... | As far as my knowledge, sendRedirect() just redirects the control to another page without transfering the associated request & response object of parent page, but RequestDispatcher(object) will dispatch the ServletRequest and ServletResponse to the page mentioned in path argument { getServletContext().getRequestDispatc... |
7,483,233 | My question is a continuation of [How to serialize a TimeSpan to XML](https://stackoverflow.com/questions/637933/net-how-to-serialize-a-timespan-to-xml)
I have many DTO objects which pass `TimeSpan` instances around. Using the hack described in the original post works, but it requires me to repeat the same bulk of cod... | 2011/09/20 | [
"https://Stackoverflow.com/questions/7483233",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/80002/"
] | Change `[XmlElement("Value")]` to `[XmlText]`. Then, if you serialize something like this:
```
[Serializable]
public class TestEntity
{
public string Name { get; set; }
public TimeSpanWrapper Time { get; set; }
}
```
You will get XML like this:
```
<TestEntity>
<Name>Hello</Name>
<Time>3723000</Time... | You will need to implement IXmlSerializable:
```
[Serializable,XmlSchemaProvider("TimeSpanSchema")]
public class TimeSpanWrapper : IXmlSerializable
{
private TimeSpan _value;
public TimeSpanWrapper()
{
_value = TimeSpan.Zero;
}
public TimeSpanWrapper(TimeSpan value)
{
_value =... |
44,210,547 | I've got a static-hosting enable S3 bucket. There's also a cloudfront distribution that is being powered by that bucket.
I've added a CNAME entry to the cloudfront distribution for "mywebsite.com"
and when I go to load "mywebsite.com" in my browser, it redirects to `http://my-bucket.s3-us-west-2.amazonaws.com/index.h... | 2017/05/26 | [
"https://Stackoverflow.com/questions/44210547",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/680578/"
] | The issue here is a side effect of a misconfiguration. This specific behavior may go away within a few minutes or hours of bucket creation, but the underlying issue won't be resolved.
When configuring a static website hosting enabled bucket behind CloudFront, you don't want to select the bucket name from the list of b... | From AWS support <https://forums.aws.amazon.com/thread.jspa?threadID=216814>
---
>
> This is an expected behavior when you create a new bucket. The
> following pages explains the concept:
> <http://docs.aws.amazon.com/AmazonS3/latest/dev/VirtualHosting.html>
>
>
> "Amazon S3 routes any virtual hosted–style request... |
11,077,426 | I've got a ruby hash like this
```
[{user_id: 3, purchase: {amount: 2, type_id:3, name:"chocolate"},
{user_id: 4, purchase: {amount: 1, type_id:3, name: "chocolate"},
{user_id: 5, purchase: {amount: 10, type_id:4, name: "penny-candy"}]
```
I want to take the array and merge by the type\_id, sum the amounts, conne... | 2012/06/18 | [
"https://Stackoverflow.com/questions/11077426",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48067/"
] | It's a group\_by problem. I'll give you 2:
```
new_array = old_array.group_by{|x| x[:purchase][:type_id]}.values.map do |group|
{:type_id => group[0][:purchase][:type_id], :total_amounts => group.map{|g| g[:purchase][:amount]}.reduce(&:+)}
end
```
and leave the other 2 as an exercise | I would first simplify it:
```
old_arr = [
{user_id: 3, purchase: {amount: 2, type_id:3, name:"chocolate"}},
{user_id: 4, purchase: {amount: 1, type_id:3, name: "chocolate"}},
{user_id: 5, purchase: {amount: 10, type_id:4, name: "penny-candy"}}]
intermediate_arr = old_arr.map{ |h| [h[:user_id], h[:purchase][:amou... |
664,955 | I know it's not perhaps in the true spirit of MVC, but I just want to have a single global controller that always gets called no matter *what* the url looks like. For example, it could be:
<http://myserver.com/anything/at/all/here.fun?happy=yes&sad=no#yippie>
...and I want that to be passed to my single controller. I... | 2009/03/20 | [
"https://Stackoverflow.com/questions/664955",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/238948/"
] | How about:
```
routes.MapRoute("Global", "{*url}", new { controller = "Global", action = "Index" } );
```
from [this](https://stackoverflow.com/questions/19941/aspnet-mvc-catch-exception-when-non-existant-controller-is-requested) question | You have not removed the default have you? You need to keep that one. Maybe try:
```
routes.MapRoute("Global", "/", new { controller = "Global", action = "Index" });
``` |
62,988,547 | How can one get the AWS::StackName without the random generate part?
I create a stack: `aws cloudformation create-stack --stack-name test`
The stack name returned when evaluated using `AWS:StackName` will included a random generated part, e.g. `test-KB0IKRIHP9PH`
What I really want returned is the parameter without ... | 2020/07/20 | [
"https://Stackoverflow.com/questions/62988547",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/919918/"
] | I test this with a simple template:
```yaml
AWSTemplateFormatVersion: 2010-09-09
Resources:
Bucket:
Type: AWS::S3::Bucket
Outputs:
Stack:
Value: !Sub ${AWS::StackName}
```
The **Stack** output variable exactly matched the name of the stack that I created. There were *no* random characters.
I launche... | If `AWS::StackName` is in the form of `test-KB0IKRIHP9PH`, then you can get `test` and perform the Join as follows:
```
Environment:
- Name: ENVIRONMENT_VAR
Value: !Join ["", ["CD_", !Select [0, !Split ['-', !Ref "AWS::StackName"] ] ] ]
``` |
62,988,547 | How can one get the AWS::StackName without the random generate part?
I create a stack: `aws cloudformation create-stack --stack-name test`
The stack name returned when evaluated using `AWS:StackName` will included a random generated part, e.g. `test-KB0IKRIHP9PH`
What I really want returned is the parameter without ... | 2020/07/20 | [
"https://Stackoverflow.com/questions/62988547",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/919918/"
] | **Nested Stack Names** contain a random hash.
To overcome the problem, pass the `AWS::StackName` as a parameter to the nested stack, from the root/master stack.
---
In the example below, the `AWS::StackName` is passed as a parameter.
**master.yaml**
```
Resources:
S3:
Type: AWS::CloudFormation::Stack
Pro... | If `AWS::StackName` is in the form of `test-KB0IKRIHP9PH`, then you can get `test` and perform the Join as follows:
```
Environment:
- Name: ENVIRONMENT_VAR
Value: !Join ["", ["CD_", !Select [0, !Split ['-', !Ref "AWS::StackName"] ] ] ]
``` |
78,354 | From time to time (quite randomly), Nemo on my Linux Mint 14 Cinnamon starts looking like this

When usually it looks like this: 
Restarting Cinnamon (`Alt`+`F2`, `r`, `Enter`) doesn... | 2013/06/05 | [
"https://unix.stackexchange.com/questions/78354",
"https://unix.stackexchange.com",
"https://unix.stackexchange.com/users/17765/"
] | It seems that `cinnamon-settings-daemon`/`gnome-settings-daemon` is not running.
You can put it in startup aplications to make sure it starts when you log in. | finally i got solution.
Simply open **Startup Applications** from *Control Center*, check the option **MATE Settings Daemon** or **Cinnamon Settings Daemon** (according to your Desktop Environment) and that’s it.
Now login again and problem solved. |
10,772,686 | to be able to add annotations to a pdf file in linux, i have to reset the "Commenting" security setting in the pdf document.
`qpdf --decrypt input.pdf output.pdf` should remove any passwords or "encryption" ([according to this post](https://superuser.com/questions/216616/does-pdftk-respect-pdf-security-flags))
`pdft... | 2012/05/27 | [
"https://Stackoverflow.com/questions/10772686",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/989762/"
] | The command `qpdf --decrypt input.pdf output.pdf` removes the 'owner' password. But it only works if there is no 'user' password set.
Once the owner password is removed, the `output.pdf` should already have unset *all* security protection and have allowed commenting. Needless to run your extra `pdftk ...` command then... | The question is a common one and the answer is simple. Do not use acroread to check a document's security settings. qpdf is correctly removing the restrictions, but acroread does not know that.
Acroread is purposefully limited by Adobe so that it will not compete with Acrobat. (For example, you can type in forms, but ... |
35,181,472 | I faced the problem that I dont understand how itertools.takewhile() code works.
```
import itertools
z = [3,3,9,4,1]
zcycle = itertools.cycle(z)
next_symbol = zcycle.next()
y = list(itertools.takewhile(lambda symbol: symbol == next_symbol or symbol == 9, zcycle))
print y
```
my code suppose to give me elements of... | 2016/02/03 | [
"https://Stackoverflow.com/questions/35181472",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5366684/"
] | You removed the first `3` from the sequence here:
```
next_symbol = zcycle.next()
```
That advances `zcycle` to the next element, so it'll yield one more `3`, not two.
Don't call `next()` on the `zcycle` object; perhaps use `z[0]` instead:
```
next_symbol = z[0]
```
Now `zcycle` will yield `3`, then another `3`,... | it is possible to do it with tee an groupby if you had an actul iterator:
```
from itertools import tee, groupby, cycle
z = [3, 3, 9, 4, 1]
zcycle = cycle(z)
a, b = tee(zcycle)
next_symbol = next(b)
grps = groupby(a, key=lambda symbol: symbol in {9, next(b), next_symbol})
g = next(grps)
if g[0]:
print(list(g[1]))... |
55,022,363 | I making a ASP.NET CORE 2.1 website. The database in Visual studio works fine, but when i deployed to the IIS which on another computer, the database not work.
In log, the error:
```
fail: Microsoft.EntityFrameworkCore.Query[10100]
An exception occurred in the database while iterating the results of a query for cont... | 2019/03/06 | [
"https://Stackoverflow.com/questions/55022363",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7850219/"
] | Oh my jesus... I figured out the answer.. Just one f\*... word... In connenction strig DONT USE *database*, the correct word is **Initial Catalog** and maybe use user id instead of id.
Correct string:
```
"DefaultConnection": "Server=.\\SQLEXPRESS;Initial Catalog=XXX;Trusted_Connection=False;user id=XXX;pwd=XXX;Mu... | Based on my research if the server have morethan one databases .net core suffers to identify if the dabtase is mentioned in connection string.
This is not a problem if you use .Net framework, instead of .Net Core. |
59,164 | Um hervorzuheben, dass ein Wort euphemistisch gebraucht wird oder, dass es eigentlich nicht ganz seinen normalerweise zugedachten Inhalt widerspiegelt, kann man Anführungszeichen nutzen:
>
> Hans "arbeitet" schwer im Home-Office. (Hans schaut eigentlich eine Serie auf Netflix)
>
>
>
>
> Hans hat gestern seine Wo... | 2020/06/30 | [
"https://german.stackexchange.com/questions/59164",
"https://german.stackexchange.com",
"https://german.stackexchange.com/users/30455/"
] | Ignoriere die pedantischen Angriffe gegen die Vorstellung von Ironie in der Sprache. Wenn man ein Verb durch Anführungszeichen hervorhebt, egal zu welchem Zweck, und das Verb geteilt wird, dann stehen die Anführungszeichen natürlich um beide Teile, also ist a) richtig.
(Am Rande: Davon unabhängig muß man natürlich dar... | Weder, noch und schon gar nicht.
>
> Hans räumt morgen seine Wohnung auf.
>
>
>
Wenn es Ironie sein soll, und man will diese unbedingt mit Anführungszeichen ausdrücken, dann kommt der ganze Satzteil in solche:
>
> Hans "räumt morgen seine Wohnung auf".
>
>
>
Es ist für den Leser natürlich nicht ersichtlich,... |
16,966,812 | I use this layout :
```
<?xml version="1.0" encoding="UTF-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/scroller"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true"
android:background="#00868B">
<Relati... | 2013/06/06 | [
"https://Stackoverflow.com/questions/16966812",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/583464/"
] | I just had problem getting SASS source maps getting to work on my host.... I had completely no idea what could be the solution because the map-file was generated, the sourceMappingURL-tag was present and everything was fine, Chrome was configured and I even used the canary-version..... but then I got it:
I used a deve... | For anyone who has tried everything and can't get css source maps to work, make sure the source map is actually accessible via URL. In my case, rewrite rules were not exposing the source map. Once I changed that, it worked immediately. |
16,966,812 | I use this layout :
```
<?xml version="1.0" encoding="UTF-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/scroller"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true"
android:background="#00868B">
<Relati... | 2013/06/06 | [
"https://Stackoverflow.com/questions/16966812",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/583464/"
] | Try following the tutorial in [this link](http://net.tutsplus.com/tutorials/html-css-techniques/developing-with-sass-and-chrome-devtools/). I just set this up this morning and it's working fine for me.
This will let you inspect an element and then find what the corresponding SCSS declaration is. | As @gerryster said, Chrome now supports `source maps proposal v 3`. I wrote blog post about [Debugging Rails 4 CoffeeScript and Sass source files in Google Chrome](http://blog.vhyza.eu/blog/2013/09/22/debugging-rails-4-coffeescript-and-sass-source-files-in-google-chrome/). |
16,966,812 | I use this layout :
```
<?xml version="1.0" encoding="UTF-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/scroller"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true"
android:background="#00868B">
<Relati... | 2013/06/06 | [
"https://Stackoverflow.com/questions/16966812",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/583464/"
] | For anyone who has tried everything and can't get css source maps to work, make sure the source map is actually accessible via URL. In my case, rewrite rules were not exposing the source map. Once I changed that, it worked immediately. | In case anyone else ends up here after struggling to make Chrome work with Sass, you need to run a different command to generate source maps via command line: `sass --watch --sourcemap sass/styles.scss:styles.css` instead of `--debug-info`. The newer versions of Chrome now support source maps instead of the in-css debu... |
16,966,812 | I use this layout :
```
<?xml version="1.0" encoding="UTF-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/scroller"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true"
android:background="#00868B">
<Relati... | 2013/06/06 | [
"https://Stackoverflow.com/questions/16966812",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/583464/"
] | As @gerryster said, Chrome now supports `source maps proposal v 3`. I wrote blog post about [Debugging Rails 4 CoffeeScript and Sass source files in Google Chrome](http://blog.vhyza.eu/blog/2013/09/22/debugging-rails-4-coffeescript-and-sass-source-files-in-google-chrome/). | In case anyone else ends up here after struggling to make Chrome work with Sass, you need to run a different command to generate source maps via command line: `sass --watch --sourcemap sass/styles.scss:styles.css` instead of `--debug-info`. The newer versions of Chrome now support source maps instead of the in-css debu... |
16,966,812 | I use this layout :
```
<?xml version="1.0" encoding="UTF-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/scroller"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true"
android:background="#00868B">
<Relati... | 2013/06/06 | [
"https://Stackoverflow.com/questions/16966812",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/583464/"
] | The problem is that Chrome developer tools recently changed what version of source maps it supports. The article you mention details how to set up an older style of CSS source maps. However, Chrome now supports [version 3 source maps](https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit#... | For anyone who has tried everything and can't get css source maps to work, make sure the source map is actually accessible via URL. In my case, rewrite rules were not exposing the source map. Once I changed that, it worked immediately. |
16,966,812 | I use this layout :
```
<?xml version="1.0" encoding="UTF-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/scroller"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true"
android:background="#00868B">
<Relati... | 2013/06/06 | [
"https://Stackoverflow.com/questions/16966812",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/583464/"
] | Try following the tutorial in [this link](http://net.tutsplus.com/tutorials/html-css-techniques/developing-with-sass-and-chrome-devtools/). I just set this up this morning and it's working fine for me.
This will let you inspect an element and then find what the corresponding SCSS declaration is. | For anyone who has tried everything and can't get css source maps to work, make sure the source map is actually accessible via URL. In my case, rewrite rules were not exposing the source map. Once I changed that, it worked immediately. |
16,966,812 | I use this layout :
```
<?xml version="1.0" encoding="UTF-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/scroller"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true"
android:background="#00868B">
<Relati... | 2013/06/06 | [
"https://Stackoverflow.com/questions/16966812",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/583464/"
] | I just had problem getting SASS source maps getting to work on my host.... I had completely no idea what could be the solution because the map-file was generated, the sourceMappingURL-tag was present and everything was fine, Chrome was configured and I even used the canary-version..... but then I got it:
I used a deve... | As @gerryster said, Chrome now supports `source maps proposal v 3`. I wrote blog post about [Debugging Rails 4 CoffeeScript and Sass source files in Google Chrome](http://blog.vhyza.eu/blog/2013/09/22/debugging-rails-4-coffeescript-and-sass-source-files-in-google-chrome/). |
16,966,812 | I use this layout :
```
<?xml version="1.0" encoding="UTF-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/scroller"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true"
android:background="#00868B">
<Relati... | 2013/06/06 | [
"https://Stackoverflow.com/questions/16966812",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/583464/"
] | The problem is that Chrome developer tools recently changed what version of source maps it supports. The article you mention details how to set up an older style of CSS source maps. However, Chrome now supports [version 3 source maps](https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit#... | In case anyone else ends up here after struggling to make Chrome work with Sass, you need to run a different command to generate source maps via command line: `sass --watch --sourcemap sass/styles.scss:styles.css` instead of `--debug-info`. The newer versions of Chrome now support source maps instead of the in-css debu... |
16,966,812 | I use this layout :
```
<?xml version="1.0" encoding="UTF-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/scroller"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true"
android:background="#00868B">
<Relati... | 2013/06/06 | [
"https://Stackoverflow.com/questions/16966812",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/583464/"
] | Try following the tutorial in [this link](http://net.tutsplus.com/tutorials/html-css-techniques/developing-with-sass-and-chrome-devtools/). I just set this up this morning and it's working fine for me.
This will let you inspect an element and then find what the corresponding SCSS declaration is. | I just had problem getting SASS source maps getting to work on my host.... I had completely no idea what could be the solution because the map-file was generated, the sourceMappingURL-tag was present and everything was fine, Chrome was configured and I even used the canary-version..... but then I got it:
I used a deve... |
16,966,812 | I use this layout :
```
<?xml version="1.0" encoding="UTF-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/scroller"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true"
android:background="#00868B">
<Relati... | 2013/06/06 | [
"https://Stackoverflow.com/questions/16966812",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/583464/"
] | The problem is that Chrome developer tools recently changed what version of source maps it supports. The article you mention details how to set up an older style of CSS source maps. However, Chrome now supports [version 3 source maps](https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit#... | As @gerryster said, Chrome now supports `source maps proposal v 3`. I wrote blog post about [Debugging Rails 4 CoffeeScript and Sass source files in Google Chrome](http://blog.vhyza.eu/blog/2013/09/22/debugging-rails-4-coffeescript-and-sass-source-files-in-google-chrome/). |
24,472,223 | Consider HTML code below. In that code I am dynamically adding a DIV with a class "dynamic" and I am expecting that it would pick up the CSS attributes defined for that class which in turn would show a black square. The black square, however, never appears. Am I doing anything wrong here? If not, then is there a way to... | 2014/06/29 | [
"https://Stackoverflow.com/questions/24472223",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2128461/"
] | In your class, you spelled background incorrectly:
```
.dynamic {
background-color: black;
width: 100px;
height: 130px;
left: 10px;
top: 10px;
}
```
I also recommend jQuery's `.addClass()` instead of `.attr()`
```
$("<div/>").addClass("dynamic")
```
<http://jsbin.com/qufeq/1/> | You have misspelled `background-color`. You might want to double-check your spelling in the future, because it is much easier to fix these trivial bugs than to wait for answers. |
56,769,100 | I am using officeGen to generate word documents.
>
> generateDocumentService.js
>
>
>
```
var generateReportFromTableData = function (tableData) {
console.log('tableData: ', tableData);
var docx = officegen({
type: 'docx',
orientation: 'portrait',
pageMargins: {
top: 1000,
left: 1000,
... | 2019/06/26 | [
"https://Stackoverflow.com/questions/56769100",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11379139/"
] | You can try out with below code in your configuration
```
var tableStyle = {
sz: 20
tableColWidth: 4261,
tableSize: 72,
tableColor: 'ada',
tableAlign: 'left',
tableFontFamily: 'Comic Sans MS',
borders: true
}
```
**sz: 20** - this value will divide by 2 and it sets the font size ie. if ... | I have done this using only 'column headers' for multiple rows in the table |
35,134,394 | Let's say that I have six different classes and three of them should use the same constant value. What can we do? We either:
* Define as global variable
```
A = 1
class B:
def __init__(self):
self.a = A
class C:
def __init__(self):
self.a = A
class D:
def __init__(self):
self.a ... | 2016/02/01 | [
"https://Stackoverflow.com/questions/35134394",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3434076/"
] | Use class inheritance:
```
class Holder:
a = 4
class A(Holder):
pass
print A().a
``` | You could use inheritance, using `B` as the base class
```
class B:
A = 1
def __init__(self):
self.b = 2
class C(B):
def __init__(self):
B.__init__(self)
self.a = B.A
self.b = 3
b = B()
c = C()
print c.a
``` |
72,859,168 | I have a pandas data frame from which I'm trying to create a dictionary based on a users age, where age is the key and the data associated with it is the value. So lets say users with age 10 will be in a dictionary {Age:10, Data:[Pole, Carl]}
[Table Image](https://i.stack.imgur.com/utCnQ.png) | 2022/07/04 | [
"https://Stackoverflow.com/questions/72859168",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19480593/"
] | Did you try explicitly deleting the l-value overload?
```
template <typename T>
auto f(T &&) {}
template <typename T>
auto f(T &) = delete;
``` | You can use `static_assert` if you don't need SFINAE:
```
template<typename T>
auto f(T&&) {
static_assert(std::is_rvalue_reference_v<T&&>);
}
``` |
72,859,168 | I have a pandas data frame from which I'm trying to create a dictionary based on a users age, where age is the key and the data associated with it is the value. So lets say users with age 10 will be in a dictionary {Age:10, Data:[Pole, Carl]}
[Table Image](https://i.stack.imgur.com/utCnQ.png) | 2022/07/04 | [
"https://Stackoverflow.com/questions/72859168",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19480593/"
] | As @HolyBlackCat commented, you can use concepts to simplify the function signature
```
#include <type_traits>
template<typename T>
requires (!std::is_lvalue_reference_v<T>)
auto f(T&&) {}
```
Or detect lvalue or rvalue by checking the validity of a lambda expression that accepts an lvalue reference
```
#include... | You can use `static_assert` if you don't need SFINAE:
```
template<typename T>
auto f(T&&) {
static_assert(std::is_rvalue_reference_v<T&&>);
}
``` |
13,055 | I'm looking for a clear, concise and accurate answer.
Ideally as the actual answer, although links to good explanations welcome. | 2008/08/16 | [
"https://Stackoverflow.com/questions/13055",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/905/"
] | Boxing & unboxing is the process of converting a primitive value into an object oriented wrapper class (boxing), or converting a value from an object oriented wrapper class back to the primitive value (unboxing).
For example, in java, you may need to convert an `int` value into an `Integer` (boxing) if you want to sto... | The language-agnostic meaning of a box is just "an object contains some other value".
Literally, *boxing* is an operation to put some value into the box. More specifically, it is an operation to *create* a new box containing the value. After boxing, the boxed value can be accessed from the box object, by *unboxing*.
... |
13,055 | I'm looking for a clear, concise and accurate answer.
Ideally as the actual answer, although links to good explanations welcome. | 2008/08/16 | [
"https://Stackoverflow.com/questions/13055",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/905/"
] | from [C# 3.0 In a Nutshell](http://books.google.com/books?id=_Y0rWd-Q2xkC&pg=PA81&vq=boxing&source=gbs_search_r&cad=1_1&sig=ACfU3U0SIw4v8UZzMH3f5xImIyHZHD90sA#PPA82,M1):
>
> Boxing is the act of casting a value
> type into a reference type:
>
>
>
```
int x = 9;
object o = x; // boxing the int
```
>
> unboxin... | The language-agnostic meaning of a box is just "an object contains some other value".
Literally, *boxing* is an operation to put some value into the box. More specifically, it is an operation to *create* a new box containing the value. After boxing, the boxed value can be accessed from the box object, by *unboxing*.
... |
13,055 | I'm looking for a clear, concise and accurate answer.
Ideally as the actual answer, although links to good explanations welcome. | 2008/08/16 | [
"https://Stackoverflow.com/questions/13055",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/905/"
] | In .Net:
Often you can't rely on what the type of variable a function will consume, so you need to use an object variable which extends from the lowest common denominator - in .Net this is `object`.
However `object` is a class and stores its contents as a reference.
```
List<int> notBoxed = new List<int> { 1, 2, 3 }... | The language-agnostic meaning of a box is just "an object contains some other value".
Literally, *boxing* is an operation to put some value into the box. More specifically, it is an operation to *create* a new box containing the value. After boxing, the boxed value can be accessed from the box object, by *unboxing*.
... |
13,055 | I'm looking for a clear, concise and accurate answer.
Ideally as the actual answer, although links to good explanations welcome. | 2008/08/16 | [
"https://Stackoverflow.com/questions/13055",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/905/"
] | The .NET FCL generic collections:
```
List<T>
Dictionary<TKey, UValue>
SortedDictionary<TKey, UValue>
Stack<T>
Queue<T>
LinkedList<T>
```
were all designed to overcome the performance issues of boxing and unboxing in previous collection implementations.
For more, see chapter 16, [*CLR via C# (2nd Edition)*](http://... | Boxing and unboxing facilitates value types to be treated as objects. Boxing means converting a value to an instance of the object reference type. For example, `Int` is a class and `int` is a data type. Converting `int` to `Int` is an exemplification of boxing, whereas converting `Int` to `int` is unboxing. The concept... |
13,055 | I'm looking for a clear, concise and accurate answer.
Ideally as the actual answer, although links to good explanations welcome. | 2008/08/16 | [
"https://Stackoverflow.com/questions/13055",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/905/"
] | from [C# 3.0 In a Nutshell](http://books.google.com/books?id=_Y0rWd-Q2xkC&pg=PA81&vq=boxing&source=gbs_search_r&cad=1_1&sig=ACfU3U0SIw4v8UZzMH3f5xImIyHZHD90sA#PPA82,M1):
>
> Boxing is the act of casting a value
> type into a reference type:
>
>
>
```
int x = 9;
object o = x; // boxing the int
```
>
> unboxin... | Boxing and unboxing facilitates value types to be treated as objects. Boxing means converting a value to an instance of the object reference type. For example, `Int` is a class and `int` is a data type. Converting `int` to `Int` is an exemplification of boxing, whereas converting `Int` to `int` is unboxing. The concept... |
13,055 | I'm looking for a clear, concise and accurate answer.
Ideally as the actual answer, although links to good explanations welcome. | 2008/08/16 | [
"https://Stackoverflow.com/questions/13055",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/905/"
] | Boxing & unboxing is the process of converting a primitive value into an object oriented wrapper class (boxing), or converting a value from an object oriented wrapper class back to the primitive value (unboxing).
For example, in java, you may need to convert an `int` value into an `Integer` (boxing) if you want to sto... | In .Net:
Often you can't rely on what the type of variable a function will consume, so you need to use an object variable which extends from the lowest common denominator - in .Net this is `object`.
However `object` is a class and stores its contents as a reference.
```
List<int> notBoxed = new List<int> { 1, 2, 3 }... |
13,055 | I'm looking for a clear, concise and accurate answer.
Ideally as the actual answer, although links to good explanations welcome. | 2008/08/16 | [
"https://Stackoverflow.com/questions/13055",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/905/"
] | Boxed values are [data structures](http://en.wikipedia.org/wiki/Data_structure) that are minimal wrappers around [primitive types](http://en.wikipedia.org/wiki/Primitive_type)\*. Boxed values are typically stored as pointers to objects on [the heap](http://en.wikipedia.org/wiki/Dynamic_memory_allocation).
Thus, boxed ... | `Boxing` is the process of conversion of a value type into a reference type. Whereas `Unboxing` is the conversion of a reference type into a value type.
```
EX: int i = 123;
object o = i;// Boxing
int j = (int)o;// UnBoxing
```
Value Types are: `int`, `char` and `structures`, `enumerations`.
Reference Types ... |
13,055 | I'm looking for a clear, concise and accurate answer.
Ideally as the actual answer, although links to good explanations welcome. | 2008/08/16 | [
"https://Stackoverflow.com/questions/13055",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/905/"
] | Boxing & unboxing is the process of converting a primitive value into an object oriented wrapper class (boxing), or converting a value from an object oriented wrapper class back to the primitive value (unboxing).
For example, in java, you may need to convert an `int` value into an `Integer` (boxing) if you want to sto... | Boxing and unboxing facilitates value types to be treated as objects. Boxing means converting a value to an instance of the object reference type. For example, `Int` is a class and `int` is a data type. Converting `int` to `Int` is an exemplification of boxing, whereas converting `Int` to `int` is unboxing. The concept... |
13,055 | I'm looking for a clear, concise and accurate answer.
Ideally as the actual answer, although links to good explanations welcome. | 2008/08/16 | [
"https://Stackoverflow.com/questions/13055",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/905/"
] | Boxed values are [data structures](http://en.wikipedia.org/wiki/Data_structure) that are minimal wrappers around [primitive types](http://en.wikipedia.org/wiki/Primitive_type)\*. Boxed values are typically stored as pointers to objects on [the heap](http://en.wikipedia.org/wiki/Dynamic_memory_allocation).
Thus, boxed ... | The .NET FCL generic collections:
```
List<T>
Dictionary<TKey, UValue>
SortedDictionary<TKey, UValue>
Stack<T>
Queue<T>
LinkedList<T>
```
were all designed to overcome the performance issues of boxing and unboxing in previous collection implementations.
For more, see chapter 16, [*CLR via C# (2nd Edition)*](http://... |
13,055 | I'm looking for a clear, concise and accurate answer.
Ideally as the actual answer, although links to good explanations welcome. | 2008/08/16 | [
"https://Stackoverflow.com/questions/13055",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/905/"
] | Boxing & unboxing is the process of converting a primitive value into an object oriented wrapper class (boxing), or converting a value from an object oriented wrapper class back to the primitive value (unboxing).
For example, in java, you may need to convert an `int` value into an `Integer` (boxing) if you want to sto... | Like anything else, autoboxing can be problematic if not used carefully. The classic is to end up with a NullPointerException and not be able to track it down. Even with a debugger. Try this:
```
public class TestAutoboxNPE
{
public static void main(String[] args)
{
Integer i = null;
// .. do ... |
17,314,513 | I want to create a software:
- Input as a video stream H264 ( from another software)
- Output as a webcam for my friends can watch in skype, yahoo, or something like that.
I knows I need to create directshow filter to do that, but I dont know what type filter I must to create.
And when I have a filter, I dont know ... | 2013/06/26 | [
"https://Stackoverflow.com/questions/17314513",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2376873/"
] | You need to create a virtual video source/camera filter. There have been a dozen of questions like this on SO, so I will just link to some of them:
* [How to write an own capture filter?](https://stackoverflow.com/questions/10086897/how-to-write-an-own-capture-filter/10087276#10087276)
* [Set byte stream as live sourc... | You should start here : [Writing DirectShow Filters](http://msdn.microsoft.com/en-us/library/windows/desktop/dd391013%28v=vs.85%29.aspx) or here : [Introduction to DirectShow Filter Development](http://msdn.microsoft.com/en-us/library/windows/desktop/dd390354%28v=vs.85%29.aspx)
I assume you already have Windows SDK fo... |
22,830,387 | I don't know why and how, but my jQuery code appears to be firing twice on any event.
Here's a part of my code:
`commmon.js`:
```
$(document).ready(function() {
$(".fpbtn-one").click(function() {
console.log("Click recorded!"); // Gets logged twice on click
$(this).parent().next().slideToggle();... | 2014/04/03 | [
"https://Stackoverflow.com/questions/22830387",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1999681/"
] | be careful for beginning use good practice when calling jquery :
```
!function( $ ) {
your code
}( jQuery )
```
like that you avoid conflict...
Then be careful when adding js script in html, you can add it twice, for example you call one js in a html file, ok but in the js you load in callback for example anoth... | Your relevant code is required, but from the snippets above; try putting all the codes in the document ready method. |
22,830,387 | I don't know why and how, but my jQuery code appears to be firing twice on any event.
Here's a part of my code:
`commmon.js`:
```
$(document).ready(function() {
$(".fpbtn-one").click(function() {
console.log("Click recorded!"); // Gets logged twice on click
$(this).parent().next().slideToggle();... | 2014/04/03 | [
"https://Stackoverflow.com/questions/22830387",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1999681/"
] | Try putting the stuff in the body inside divs.
example. `<div id = "menu"><script type="text/javascript" src="/assets/custom/files/js/jquery-mmenu-min.js"></script> </div>`
I hope that works. :) | It might be event bubbling. Use `event.preventDefault()`, it will prevent the default event from occuring or `event.stopPropagation()` will prevent the event from bubbling up.
```
$(document).ready(function() {
$(".fpbtn-one").click(function(event) {
event.stopPropagation();
console.log("Click rec... |
22,830,387 | I don't know why and how, but my jQuery code appears to be firing twice on any event.
Here's a part of my code:
`commmon.js`:
```
$(document).ready(function() {
$(".fpbtn-one").click(function() {
console.log("Click recorded!"); // Gets logged twice on click
$(this).parent().next().slideToggle();... | 2014/04/03 | [
"https://Stackoverflow.com/questions/22830387",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1999681/"
] | May be you have included your script file `commmon.js` twice. Check your references to it in your code. | Your relevant code is required, but from the snippets above; try putting all the codes in the document ready method. |
22,830,387 | I don't know why and how, but my jQuery code appears to be firing twice on any event.
Here's a part of my code:
`commmon.js`:
```
$(document).ready(function() {
$(".fpbtn-one").click(function() {
console.log("Click recorded!"); // Gets logged twice on click
$(this).parent().next().slideToggle();... | 2014/04/03 | [
"https://Stackoverflow.com/questions/22830387",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1999681/"
] | Could it be that your code was manipulating the element that the code was loading into?
This answer may be the reason why it was happening:
[jQuery $(document).ready () fires twice](https://stackoverflow.com/questions/10727002/jquery-document-ready-fires-twice) | It might be event bubbling. Use `event.preventDefault()`, it will prevent the default event from occuring or `event.stopPropagation()` will prevent the event from bubbling up.
```
$(document).ready(function() {
$(".fpbtn-one").click(function(event) {
event.stopPropagation();
console.log("Click rec... |
22,830,387 | I don't know why and how, but my jQuery code appears to be firing twice on any event.
Here's a part of my code:
`commmon.js`:
```
$(document).ready(function() {
$(".fpbtn-one").click(function() {
console.log("Click recorded!"); // Gets logged twice on click
$(this).parent().next().slideToggle();... | 2014/04/03 | [
"https://Stackoverflow.com/questions/22830387",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1999681/"
] | be careful for beginning use good practice when calling jquery :
```
!function( $ ) {
your code
}( jQuery )
```
like that you avoid conflict...
Then be careful when adding js script in html, you can add it twice, for example you call one js in a html file, ok but in the js you load in callback for example anoth... | It might be event bubbling. Use `event.preventDefault()`, it will prevent the default event from occuring or `event.stopPropagation()` will prevent the event from bubbling up.
```
$(document).ready(function() {
$(".fpbtn-one").click(function(event) {
event.stopPropagation();
console.log("Click rec... |
22,830,387 | I don't know why and how, but my jQuery code appears to be firing twice on any event.
Here's a part of my code:
`commmon.js`:
```
$(document).ready(function() {
$(".fpbtn-one").click(function() {
console.log("Click recorded!"); // Gets logged twice on click
$(this).parent().next().slideToggle();... | 2014/04/03 | [
"https://Stackoverflow.com/questions/22830387",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1999681/"
] | Try putting the stuff in the body inside divs.
example. `<div id = "menu"><script type="text/javascript" src="/assets/custom/files/js/jquery-mmenu-min.js"></script> </div>`
I hope that works. :) | Your relevant code is required, but from the snippets above; try putting all the codes in the document ready method. |
22,830,387 | I don't know why and how, but my jQuery code appears to be firing twice on any event.
Here's a part of my code:
`commmon.js`:
```
$(document).ready(function() {
$(".fpbtn-one").click(function() {
console.log("Click recorded!"); // Gets logged twice on click
$(this).parent().next().slideToggle();... | 2014/04/03 | [
"https://Stackoverflow.com/questions/22830387",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1999681/"
] | May be you have included your script file `commmon.js` twice. Check your references to it in your code. | It might be event bubbling. Use `event.preventDefault()`, it will prevent the default event from occuring or `event.stopPropagation()` will prevent the event from bubbling up.
```
$(document).ready(function() {
$(".fpbtn-one").click(function(event) {
event.stopPropagation();
console.log("Click rec... |
22,830,387 | I don't know why and how, but my jQuery code appears to be firing twice on any event.
Here's a part of my code:
`commmon.js`:
```
$(document).ready(function() {
$(".fpbtn-one").click(function() {
console.log("Click recorded!"); // Gets logged twice on click
$(this).parent().next().slideToggle();... | 2014/04/03 | [
"https://Stackoverflow.com/questions/22830387",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1999681/"
] | Try putting the stuff in the body inside divs.
example. `<div id = "menu"><script type="text/javascript" src="/assets/custom/files/js/jquery-mmenu-min.js"></script> </div>`
I hope that works. :) | The simplest explanation is that you have included the common.js twice by mistake.
Look into individual scripts and see if you have referenced common.js on top of your main file. |
22,830,387 | I don't know why and how, but my jQuery code appears to be firing twice on any event.
Here's a part of my code:
`commmon.js`:
```
$(document).ready(function() {
$(".fpbtn-one").click(function() {
console.log("Click recorded!"); // Gets logged twice on click
$(this).parent().next().slideToggle();... | 2014/04/03 | [
"https://Stackoverflow.com/questions/22830387",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1999681/"
] | Could it be that your code was manipulating the element that the code was loading into?
This answer may be the reason why it was happening:
[jQuery $(document).ready () fires twice](https://stackoverflow.com/questions/10727002/jquery-document-ready-fires-twice) | Your relevant code is required, but from the snippets above; try putting all the codes in the document ready method. |
22,830,387 | I don't know why and how, but my jQuery code appears to be firing twice on any event.
Here's a part of my code:
`commmon.js`:
```
$(document).ready(function() {
$(".fpbtn-one").click(function() {
console.log("Click recorded!"); // Gets logged twice on click
$(this).parent().next().slideToggle();... | 2014/04/03 | [
"https://Stackoverflow.com/questions/22830387",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1999681/"
] | Could it be that your code was manipulating the element that the code was loading into?
This answer may be the reason why it was happening:
[jQuery $(document).ready () fires twice](https://stackoverflow.com/questions/10727002/jquery-document-ready-fires-twice) | The simplest explanation is that you have included the common.js twice by mistake.
Look into individual scripts and see if you have referenced common.js on top of your main file. |
31,646,520 | Here is my code:
```
private void textBox1_TextChanged(object sender, EventArgs e)
{
DateTime myDate = DateTime.ParseExact(textBox1.Text, "yyyy-MM-dd H:m:s",
System.Globalization.CultureInfo.InvariantCulture);
TimeChangedHandler(myDate);
}
```
If I delete 1 number from hours then it works fine, but ... | 2015/07/27 | [
"https://Stackoverflow.com/questions/31646520",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4551943/"
] | If you want to indicate that the date/time is invalid, use `DateTime.TryParseExact` to *check* whether or not it's valid, without throwing an exception. Use the return value (true/false) to determine the validity.
Basically, you shouldn't expect that the value is always valid while the user is editing - just like whil... | Since it is on `TextChanged` event handler, you may wanna try to add, a `try...catch` handling during real time edits.
```
try
{
DateTime myDate = DateTime.ParseExact(textBox1.Text, "yyyy-MM-dd H:m:s",
System.Globalization.CultureInfo.InvariantCulture);
TimeChangedHandler(myDate);
}catch( Exception ex )
{... |
31,646,520 | Here is my code:
```
private void textBox1_TextChanged(object sender, EventArgs e)
{
DateTime myDate = DateTime.ParseExact(textBox1.Text, "yyyy-MM-dd H:m:s",
System.Globalization.CultureInfo.InvariantCulture);
TimeChangedHandler(myDate);
}
```
If I delete 1 number from hours then it works fine, but ... | 2015/07/27 | [
"https://Stackoverflow.com/questions/31646520",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4551943/"
] | You may benefit from using DateTime.TryParse method to check what of two formats your date is :
```
private void textBox1_TextChanged(object sender, EventArgs e)
{
DateTime myDate = default(DateTime);
if(!DateTime.TryParseExact(textBox1.Text, "yyyy-MM-dd H:m:s",
System.Globalization.CultureInfo.Invarian... | Since it is on `TextChanged` event handler, you may wanna try to add, a `try...catch` handling during real time edits.
```
try
{
DateTime myDate = DateTime.ParseExact(textBox1.Text, "yyyy-MM-dd H:m:s",
System.Globalization.CultureInfo.InvariantCulture);
TimeChangedHandler(myDate);
}catch( Exception ex )
{... |
31,646,520 | Here is my code:
```
private void textBox1_TextChanged(object sender, EventArgs e)
{
DateTime myDate = DateTime.ParseExact(textBox1.Text, "yyyy-MM-dd H:m:s",
System.Globalization.CultureInfo.InvariantCulture);
TimeChangedHandler(myDate);
}
```
If I delete 1 number from hours then it works fine, but ... | 2015/07/27 | [
"https://Stackoverflow.com/questions/31646520",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4551943/"
] | you shouldn't expect that the value is always valid while the user is editing - just like while I'm editing code, it won't always be syntactically correct.
this code need to be placed inside try catch as you want flexible values something like this
```
private void textBox1_TextChanged(object sender, EventArgs e)
{
... | Since it is on `TextChanged` event handler, you may wanna try to add, a `try...catch` handling during real time edits.
```
try
{
DateTime myDate = DateTime.ParseExact(textBox1.Text, "yyyy-MM-dd H:m:s",
System.Globalization.CultureInfo.InvariantCulture);
TimeChangedHandler(myDate);
}catch( Exception ex )
{... |
31,646,520 | Here is my code:
```
private void textBox1_TextChanged(object sender, EventArgs e)
{
DateTime myDate = DateTime.ParseExact(textBox1.Text, "yyyy-MM-dd H:m:s",
System.Globalization.CultureInfo.InvariantCulture);
TimeChangedHandler(myDate);
}
```
If I delete 1 number from hours then it works fine, but ... | 2015/07/27 | [
"https://Stackoverflow.com/questions/31646520",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4551943/"
] | If you want to indicate that the date/time is invalid, use `DateTime.TryParseExact` to *check* whether or not it's valid, without throwing an exception. Use the return value (true/false) to determine the validity.
Basically, you shouldn't expect that the value is always valid while the user is editing - just like whil... | You may benefit from using DateTime.TryParse method to check what of two formats your date is :
```
private void textBox1_TextChanged(object sender, EventArgs e)
{
DateTime myDate = default(DateTime);
if(!DateTime.TryParseExact(textBox1.Text, "yyyy-MM-dd H:m:s",
System.Globalization.CultureInfo.Invarian... |
31,646,520 | Here is my code:
```
private void textBox1_TextChanged(object sender, EventArgs e)
{
DateTime myDate = DateTime.ParseExact(textBox1.Text, "yyyy-MM-dd H:m:s",
System.Globalization.CultureInfo.InvariantCulture);
TimeChangedHandler(myDate);
}
```
If I delete 1 number from hours then it works fine, but ... | 2015/07/27 | [
"https://Stackoverflow.com/questions/31646520",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4551943/"
] | If you want to indicate that the date/time is invalid, use `DateTime.TryParseExact` to *check* whether or not it's valid, without throwing an exception. Use the return value (true/false) to determine the validity.
Basically, you shouldn't expect that the value is always valid while the user is editing - just like whil... | you shouldn't expect that the value is always valid while the user is editing - just like while I'm editing code, it won't always be syntactically correct.
this code need to be placed inside try catch as you want flexible values something like this
```
private void textBox1_TextChanged(object sender, EventArgs e)
{
... |
40,798,676 | I'm using a table layout for my website. It's working in IE and Chrome, even IE 8 perfectly. My entire website is in one table with three cells. The top navbar, the content, and the bottom footer navbar. The table's width and min-height is set to 100%, and the middle cell is set to height: auto. This makes the footer g... | 2016/11/25 | [
"https://Stackoverflow.com/questions/40798676",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6283055/"
] | Problem exists in the following styles:
```
#tablecontainer {
min-height: 100%; /* change min-height to height */
width: 100%;
}
.table-panel {
display: table;
}
```
`min-height: 100%` property doesn't work properly with `min-height` always. Change `min-height` to `height` and it will work.
***Note***: `HTML... | On Firefox, `min-height` is not interpreted on `display: table;` instead of using `min-height` use `height:100%;`
```
#tablecontainer{
width: 100%;
height:100%;
}
```
[updated fiddle](https://jsfiddle.net/4Lr0esn4/3/) |
58,919,766 | I registered Moment.js as a plugin, like this:
```
import Vue from 'vue'
import moment from 'moment'
moment.locale('pt_BR')
Vue.use({
install (Vue) {
Vue.prototype.$moment = moment
}
})
```
Now, I need to use this in my `main.js` filters
```
import './plugins/moment'
Vue.filter('formatDate', value => {
... | 2019/11/18 | [
"https://Stackoverflow.com/questions/58919766",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3691686/"
] | Looks like you can not access `this` like in the `vue` components for filter methods.
[By Evan You](https://github.com/vuejs/vue/issues/5998#issuecomment-311965292)
>
> This is intentional in 2.x. Filters should be pure functions and should not be dependent on this context. If you need this you should use a compute... | Vue.filter() creates a global filter before the Vue instance is created, a global filter does not have access to the Vue instance therefore you can not access this.$moment. If you need to access the vue instance, you'll need to register a local filter on components.
However, you could rectify this by directly referenc... |
172,288 | Multiple times I've found myself in a situation in a meeting where I'm laying out my plans for a project I've been assigned and either my manager or a co-worker identify something to be impossible and therefore I should do something else (taking the time to explain how to do it). Instead of trying to convince them that... | 2021/05/08 | [
"https://workplace.stackexchange.com/questions/172288",
"https://workplace.stackexchange.com",
"https://workplace.stackexchange.com/users/81043/"
] | >
> If this is bad etiquette, what should I do when someone is trying to
> guide my project using known incorrect reasoning?
>
>
>
Make your case. If they reject your suggestions, ideas, and opinions then do what your boss tells you to do. It isn't your company. It isn't your decision. At the end of the day, they ... | In the future, present your ideas privately one-on-one to the usual meeting participants before you bring them up to the entire group in the larger meeting.
Group dynamics are weird, and it's much easier to correct your idea or convince someone of your idea when you're dealing with them one-on-one.
Do the same with y... |
172,288 | Multiple times I've found myself in a situation in a meeting where I'm laying out my plans for a project I've been assigned and either my manager or a co-worker identify something to be impossible and therefore I should do something else (taking the time to explain how to do it). Instead of trying to convince them that... | 2021/05/08 | [
"https://workplace.stackexchange.com/questions/172288",
"https://workplace.stackexchange.com",
"https://workplace.stackexchange.com/users/81043/"
] | >
> If this is bad etiquette, what should I do when someone is trying to
> guide my project using known incorrect reasoning?
>
>
>
Make your case. If they reject your suggestions, ideas, and opinions then do what your boss tells you to do. It isn't your company. It isn't your decision. At the end of the day, they ... | >
> I instead after the meeting go and create a proof of concept to show that it is possible and present it the next time
>
>
>
Do this before the first meeting. Meeting dynamics are things to learn from. If you want something to happen a certain way you prepare for the meeting and have your strategies in place be... |
172,288 | Multiple times I've found myself in a situation in a meeting where I'm laying out my plans for a project I've been assigned and either my manager or a co-worker identify something to be impossible and therefore I should do something else (taking the time to explain how to do it). Instead of trying to convince them that... | 2021/05/08 | [
"https://workplace.stackexchange.com/questions/172288",
"https://workplace.stackexchange.com",
"https://workplace.stackexchange.com/users/81043/"
] | >
> I instead after the meeting go and create a proof of concept to show that it is possible and present it the next time
>
>
>
Do this before the first meeting. Meeting dynamics are things to learn from. If you want something to happen a certain way you prepare for the meeting and have your strategies in place be... | In the future, present your ideas privately one-on-one to the usual meeting participants before you bring them up to the entire group in the larger meeting.
Group dynamics are weird, and it's much easier to correct your idea or convince someone of your idea when you're dealing with them one-on-one.
Do the same with y... |
65,891,422 | I want to retrieve the original index of the column with the largest sum at each iteration after the previous column with the largest sum is removed. Meanwhile, the row of the same index of the deleted column is also deleted from the matrix at each iteration.
For example, in a 10 by 10 matrix, the 5th column has the l... | 2021/01/25 | [
"https://Stackoverflow.com/questions/65891422",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10865571/"
] | python solution:
```py
import numpy as np
mat = np.random.rand(5, 5)
n_remove = 3
original = np.arange(len(mat)).tolist()
removed = []
for i in range(n_remove):
col_sum = np.sum(mat, axis=0)
col_rm = np.argsort(col_sum)[-1]
removed.append(original.pop(col_rm))
mat = np.delete(np.delete(mat, col_rm, ... | A simpler way to code the problem would be to replace elements in the selected column with a significantly small number instead of deleting the column. This approach avoids the use of "sort" and "pop" to improve code efficiency.
```
import numpy as np
n = 1000
mat = np.random.rand(n, n)
n_remove = 500
removed = []
f... |
24,235,183 | I feel like I have a pretty good grasp on using decorators when dealing with regular functions, but between using methods of base classes for decorators in derived classes, and passing parameters to said decorators, I cannot figure out what to do next.
Here is a snippet of code.
```
class ValidatedObject:
...
... | 2014/06/16 | [
"https://Stackoverflow.com/questions/24235183",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/431333/"
] | In case someone stumbled on this later.
To extract the data you can use regex, while for the custom median filter you can have a look [here](https://gist.github.com/bhawkins/3535131).
I will leave a copy down here in case it is removed:
```
def medfilt (x, k):
"""Apply a length-k median filter to a 1D array x.
... | *scipy.signal.medfilt* accepts 1D kernels:
```
import pandas as pd
import scipy.signal
def median_filter(file_name, new_file_name, kernel_size):
with open(file_name, 'r') as f:
df = pd.read_csv(f, header=None)
signal = df.iloc[:, 1].values
median = scipy.signal.medfilt(signal, kernel_size)
d... |
49,481,364 | I have an array of strings. Some of elements are empty, i.e. `''` (there are no `null`, `undefined` or strings containing only white space characters). I need to remove these empty elements, but only from the (right) end of array. Empty elements that come before non-empty elements should remain. If there are only empty... | 2018/03/25 | [
"https://Stackoverflow.com/questions/49481364",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3552063/"
] | I'd use reduce and only add an element if it isn't an empty string or the array already has entries in it
```js
console.log(removeFromEnd(['a', 'b', '', 'c', '', '']));
console.log(removeFromEnd(['a', '', '']));
console.log(removeFromEnd(['', '', '', '', 'c']));
console.log(removeFromEnd(['', '', '', '']));
funct... | >
> is there a way that does not require all these ifs? Can I do it without creating in-memory copy of array?
>
>
>
Probably not very functional, but a very straight forward implementation:
```js
function removeFromEnd(arr) {
let i = arr.length - 1;
while (arr[i] === "") i--;
return arr.slice(0, ... |
49,481,364 | I have an array of strings. Some of elements are empty, i.e. `''` (there are no `null`, `undefined` or strings containing only white space characters). I need to remove these empty elements, but only from the (right) end of array. Empty elements that come before non-empty elements should remain. If there are only empty... | 2018/03/25 | [
"https://Stackoverflow.com/questions/49481364",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3552063/"
] | An alternative is using the function **[`reduceRight`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/ReduceRight)** along with the **[`Spread syntax`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax)**.
```js
let removeFromEnd = (arr) =... | You can reverse the array and remove elements until you reach a non empty string.
Here is an example:
```js
function removeFromEnd(arr){
return arr.reverse().filter(function(v){
if(v !== ""){
this.stopRemoving = true;
}
return this.stopRemoving;
}, {stopRemoving: false}).reverse();
... |
49,481,364 | I have an array of strings. Some of elements are empty, i.e. `''` (there are no `null`, `undefined` or strings containing only white space characters). I need to remove these empty elements, but only from the (right) end of array. Empty elements that come before non-empty elements should remain. If there are only empty... | 2018/03/25 | [
"https://Stackoverflow.com/questions/49481364",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3552063/"
] | An alternative is using the function **[`reduceRight`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/ReduceRight)** along with the **[`Spread syntax`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax)**.
```js
let removeFromEnd = (arr) =... | >
> is there a way that does not require all these ifs? Can I do it without creating in-memory copy of array?
>
>
>
Probably not very functional, but a very straight forward implementation:
```js
function removeFromEnd(arr) {
let i = arr.length - 1;
while (arr[i] === "") i--;
return arr.slice(0, ... |
49,481,364 | I have an array of strings. Some of elements are empty, i.e. `''` (there are no `null`, `undefined` or strings containing only white space characters). I need to remove these empty elements, but only from the (right) end of array. Empty elements that come before non-empty elements should remain. If there are only empty... | 2018/03/25 | [
"https://Stackoverflow.com/questions/49481364",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3552063/"
] | Here's a tail recursive implementation of `removeFromEnd`. Our implementation:
* does not mutate its input
* does not unnecessarily calculate the `reverse` of the input
* does not unnecessarily search the input using `find` or `findIndex`
* does not iterate thru the input more than once
* does not require `Array.proto... | I'd use reduce and only add an element if it isn't an empty string or the array already has entries in it
```js
console.log(removeFromEnd(['a', 'b', '', 'c', '', '']));
console.log(removeFromEnd(['a', '', '']));
console.log(removeFromEnd(['', '', '', '', 'c']));
console.log(removeFromEnd(['', '', '', '']));
funct... |
49,481,364 | I have an array of strings. Some of elements are empty, i.e. `''` (there are no `null`, `undefined` or strings containing only white space characters). I need to remove these empty elements, but only from the (right) end of array. Empty elements that come before non-empty elements should remain. If there are only empty... | 2018/03/25 | [
"https://Stackoverflow.com/questions/49481364",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3552063/"
] | Here's a tail recursive implementation of `removeFromEnd`. Our implementation:
* does not mutate its input
* does not unnecessarily calculate the `reverse` of the input
* does not unnecessarily search the input using `find` or `findIndex`
* does not iterate thru the input more than once
* does not require `Array.proto... | You could do this with `reduceRight` and change one value when you find first elements that is not empty string.
```js
function removeFromEnd(arr) {
return arr.reduceRight((r, e) => {
if (e) r.match = true;
if (r.match) r.arr.unshift(e)
return r;
}, {arr: []}).arr
}
console.log(removeFromEnd(['... |
49,481,364 | I have an array of strings. Some of elements are empty, i.e. `''` (there are no `null`, `undefined` or strings containing only white space characters). I need to remove these empty elements, but only from the (right) end of array. Empty elements that come before non-empty elements should remain. If there are only empty... | 2018/03/25 | [
"https://Stackoverflow.com/questions/49481364",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3552063/"
] | Here's a tail recursive implementation of `removeFromEnd`. Our implementation:
* does not mutate its input
* does not unnecessarily calculate the `reverse` of the input
* does not unnecessarily search the input using `find` or `findIndex`
* does not iterate thru the input more than once
* does not require `Array.proto... | >
> is there a way that does not require all these ifs? Can I do it without creating in-memory copy of array?
>
>
>
Probably not very functional, but a very straight forward implementation:
```js
function removeFromEnd(arr) {
let i = arr.length - 1;
while (arr[i] === "") i--;
return arr.slice(0, ... |
49,481,364 | I have an array of strings. Some of elements are empty, i.e. `''` (there are no `null`, `undefined` or strings containing only white space characters). I need to remove these empty elements, but only from the (right) end of array. Empty elements that come before non-empty elements should remain. If there are only empty... | 2018/03/25 | [
"https://Stackoverflow.com/questions/49481364",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3552063/"
] | You could do this with `reduceRight` and change one value when you find first elements that is not empty string.
```js
function removeFromEnd(arr) {
return arr.reduceRight((r, e) => {
if (e) r.match = true;
if (r.match) r.arr.unshift(e)
return r;
}, {arr: []}).arr
}
console.log(removeFromEnd(['... | >
> is there a way that does not require all these ifs? Can I do it without creating in-memory copy of array?
>
>
>
Probably not very functional, but a very straight forward implementation:
```js
function removeFromEnd(arr) {
let i = arr.length - 1;
while (arr[i] === "") i--;
return arr.slice(0, ... |
49,481,364 | I have an array of strings. Some of elements are empty, i.e. `''` (there are no `null`, `undefined` or strings containing only white space characters). I need to remove these empty elements, but only from the (right) end of array. Empty elements that come before non-empty elements should remain. If there are only empty... | 2018/03/25 | [
"https://Stackoverflow.com/questions/49481364",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3552063/"
] | An alternative is using the function **[`reduceRight`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/ReduceRight)** along with the **[`Spread syntax`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax)**.
```js
let removeFromEnd = (arr) =... | You could do this with `reduceRight` and change one value when you find first elements that is not empty string.
```js
function removeFromEnd(arr) {
return arr.reduceRight((r, e) => {
if (e) r.match = true;
if (r.match) r.arr.unshift(e)
return r;
}, {arr: []}).arr
}
console.log(removeFromEnd(['... |
49,481,364 | I have an array of strings. Some of elements are empty, i.e. `''` (there are no `null`, `undefined` or strings containing only white space characters). I need to remove these empty elements, but only from the (right) end of array. Empty elements that come before non-empty elements should remain. If there are only empty... | 2018/03/25 | [
"https://Stackoverflow.com/questions/49481364",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3552063/"
] | You could do this with `reduceRight` and change one value when you find first elements that is not empty string.
```js
function removeFromEnd(arr) {
return arr.reduceRight((r, e) => {
if (e) r.match = true;
if (r.match) r.arr.unshift(e)
return r;
}, {arr: []}).arr
}
console.log(removeFromEnd(['... | You can reverse the array and remove elements until you reach a non empty string.
Here is an example:
```js
function removeFromEnd(arr){
return arr.reverse().filter(function(v){
if(v !== ""){
this.stopRemoving = true;
}
return this.stopRemoving;
}, {stopRemoving: false}).reverse();
... |
49,481,364 | I have an array of strings. Some of elements are empty, i.e. `''` (there are no `null`, `undefined` or strings containing only white space characters). I need to remove these empty elements, but only from the (right) end of array. Empty elements that come before non-empty elements should remain. If there are only empty... | 2018/03/25 | [
"https://Stackoverflow.com/questions/49481364",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3552063/"
] | An alternative is using the function **[`reduceRight`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/ReduceRight)** along with the **[`Spread syntax`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax)**.
```js
let removeFromEnd = (arr) =... | I'd use reduce and only add an element if it isn't an empty string or the array already has entries in it
```js
console.log(removeFromEnd(['a', 'b', '', 'c', '', '']));
console.log(removeFromEnd(['a', '', '']));
console.log(removeFromEnd(['', '', '', '', 'c']));
console.log(removeFromEnd(['', '', '', '']));
funct... |
62,069,673 | Say that I have this part of code. If user does not enter the file names as command line arguments I want to ask him again so as to enter them now but as it seems I cannot have access in argv[1] and argv[2]. For example when the first scanf is executed segmentation fault occurs. But in this case how can I read the argu... | 2020/05/28 | [
"https://Stackoverflow.com/questions/62069673",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | You don't. As the popular phrase goes, every problem in computer science can be solved by an extra layer of indirection. In this case the indirection is that you define a clean interface for opening a file and pass it a `char const*`. But this pointer doesn't have to be `argv[1]`.
You have to malloc your own buffer (b... | `Argv` is passed from console and you pass it while executing your program.
First, you have to compile it with, for example:
`gcc program.c -o program`
And then execute it with arguments, for example:
`./program arg1 arg2`
If you wish to wait for a user to enter parameters for your program through the console you ... |
62,069,673 | Say that I have this part of code. If user does not enter the file names as command line arguments I want to ask him again so as to enter them now but as it seems I cannot have access in argv[1] and argv[2]. For example when the first scanf is executed segmentation fault occurs. But in this case how can I read the argu... | 2020/05/28 | [
"https://Stackoverflow.com/questions/62069673",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | A segmentation fault occurs because length of the argv array is determined when the user runs the program. If you run a program like this:
```
./programName
```
argv is only 1 element long. It's impossible to access argv[1] or argv[2] after that. Still, You can get the necessary data and save them in regular variabl... | `Argv` is passed from console and you pass it while executing your program.
First, you have to compile it with, for example:
`gcc program.c -o program`
And then execute it with arguments, for example:
`./program arg1 arg2`
If you wish to wait for a user to enter parameters for your program through the console you ... |
62,069,673 | Say that I have this part of code. If user does not enter the file names as command line arguments I want to ask him again so as to enter them now but as it seems I cannot have access in argv[1] and argv[2]. For example when the first scanf is executed segmentation fault occurs. But in this case how can I read the argu... | 2020/05/28 | [
"https://Stackoverflow.com/questions/62069673",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | You don't. As the popular phrase goes, every problem in computer science can be solved by an extra layer of indirection. In this case the indirection is that you define a clean interface for opening a file and pass it a `char const*`. But this pointer doesn't have to be `argv[1]`.
You have to malloc your own buffer (b... | Note that `argv[1]` and `argv[2]` are only valid if `argc >= 3`.
Thus accessing them is of course wrong.
Then if you want to read the arguments from stdin, you must make sure that you have memory where those strings are kept.
You might use something like
```
char filename1[20], filename2[20];
char *f1, *f2;
if (argc ... |
62,069,673 | Say that I have this part of code. If user does not enter the file names as command line arguments I want to ask him again so as to enter them now but as it seems I cannot have access in argv[1] and argv[2]. For example when the first scanf is executed segmentation fault occurs. But in this case how can I read the argu... | 2020/05/28 | [
"https://Stackoverflow.com/questions/62069673",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | You don't. As the popular phrase goes, every problem in computer science can be solved by an extra layer of indirection. In this case the indirection is that you define a clean interface for opening a file and pass it a `char const*`. But this pointer doesn't have to be `argv[1]`.
You have to malloc your own buffer (b... | You can't do this because `argv[1]` and `argv[2]` are NULL pointers (if they even exist in the array), so you can't access them.
You need to approach the problem from a different way.
Instead of trying to change members of `argv`, assign them to other variables that hold the file names.
```
int main (int argc, char ... |
62,069,673 | Say that I have this part of code. If user does not enter the file names as command line arguments I want to ask him again so as to enter them now but as it seems I cannot have access in argv[1] and argv[2]. For example when the first scanf is executed segmentation fault occurs. But in this case how can I read the argu... | 2020/05/28 | [
"https://Stackoverflow.com/questions/62069673",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | You don't. As the popular phrase goes, every problem in computer science can be solved by an extra layer of indirection. In this case the indirection is that you define a clean interface for opening a file and pass it a `char const*`. But this pointer doesn't have to be `argv[1]`.
You have to malloc your own buffer (b... | Placing them in `argv` is the wrong approach. Much better to do something like this:
```
int main (int argc, char **argv)
{
char f1[255];
char f2[255];
if (argc != 3)
{
printf("You did not enter two files.\n");
printf("You can now enter those two files.\n");
printf("file 1: ");
... |
62,069,673 | Say that I have this part of code. If user does not enter the file names as command line arguments I want to ask him again so as to enter them now but as it seems I cannot have access in argv[1] and argv[2]. For example when the first scanf is executed segmentation fault occurs. But in this case how can I read the argu... | 2020/05/28 | [
"https://Stackoverflow.com/questions/62069673",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | You don't. As the popular phrase goes, every problem in computer science can be solved by an extra layer of indirection. In this case the indirection is that you define a clean interface for opening a file and pass it a `char const*`. But this pointer doesn't have to be `argv[1]`.
You have to malloc your own buffer (b... | A segmentation fault occurs because length of the argv array is determined when the user runs the program. If you run a program like this:
```
./programName
```
argv is only 1 element long. It's impossible to access argv[1] or argv[2] after that. Still, You can get the necessary data and save them in regular variabl... |
62,069,673 | Say that I have this part of code. If user does not enter the file names as command line arguments I want to ask him again so as to enter them now but as it seems I cannot have access in argv[1] and argv[2]. For example when the first scanf is executed segmentation fault occurs. But in this case how can I read the argu... | 2020/05/28 | [
"https://Stackoverflow.com/questions/62069673",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | A segmentation fault occurs because length of the argv array is determined when the user runs the program. If you run a program like this:
```
./programName
```
argv is only 1 element long. It's impossible to access argv[1] or argv[2] after that. Still, You can get the necessary data and save them in regular variabl... | Note that `argv[1]` and `argv[2]` are only valid if `argc >= 3`.
Thus accessing them is of course wrong.
Then if you want to read the arguments from stdin, you must make sure that you have memory where those strings are kept.
You might use something like
```
char filename1[20], filename2[20];
char *f1, *f2;
if (argc ... |
62,069,673 | Say that I have this part of code. If user does not enter the file names as command line arguments I want to ask him again so as to enter them now but as it seems I cannot have access in argv[1] and argv[2]. For example when the first scanf is executed segmentation fault occurs. But in this case how can I read the argu... | 2020/05/28 | [
"https://Stackoverflow.com/questions/62069673",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | A segmentation fault occurs because length of the argv array is determined when the user runs the program. If you run a program like this:
```
./programName
```
argv is only 1 element long. It's impossible to access argv[1] or argv[2] after that. Still, You can get the necessary data and save them in regular variabl... | You can't do this because `argv[1]` and `argv[2]` are NULL pointers (if they even exist in the array), so you can't access them.
You need to approach the problem from a different way.
Instead of trying to change members of `argv`, assign them to other variables that hold the file names.
```
int main (int argc, char ... |
62,069,673 | Say that I have this part of code. If user does not enter the file names as command line arguments I want to ask him again so as to enter them now but as it seems I cannot have access in argv[1] and argv[2]. For example when the first scanf is executed segmentation fault occurs. But in this case how can I read the argu... | 2020/05/28 | [
"https://Stackoverflow.com/questions/62069673",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | A segmentation fault occurs because length of the argv array is determined when the user runs the program. If you run a program like this:
```
./programName
```
argv is only 1 element long. It's impossible to access argv[1] or argv[2] after that. Still, You can get the necessary data and save them in regular variabl... | Placing them in `argv` is the wrong approach. Much better to do something like this:
```
int main (int argc, char **argv)
{
char f1[255];
char f2[255];
if (argc != 3)
{
printf("You did not enter two files.\n");
printf("You can now enter those two files.\n");
printf("file 1: ");
... |
42,372,532 | I need to open an existing \*.xlsx Excel file, make some modifications, and then save it as a new file (or stream it to the frontend without saving). The original file must remain unchanged.
For Memory reasons, I avoid using FileInputStream (as described here: <http://poi.apache.org/spreadsheet/quick-guide.html#FileIn... | 2017/02/21 | [
"https://Stackoverflow.com/questions/42372532",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6426882/"
] | X and y labels are bound to an axes in matplotlib. So it makes little sense to use `xlabel` or `ylabel` commands for the purpose of labeling several subplots.
What is possible though, is to create a simple text and place it at the desired position. `fig.text(x,y, text)` places some text at coordinates `x` and `y` in ... | This will create an invisible 111 axis where you can set the general x and y labels:
```
import pandas as pd
import matplotlib.pyplot as plt
df = pd.DataFrame({'A': [0.3, 0.2, 0.5, 0.2], 'B': [0.1, 0.0, 0.3, 0.1],
'C': [0.2, 0.5, 0.0, 0.7], 'D': [0.6, 0.3, 0.4, 0.6]},
index=list('... |
42,372,532 | I need to open an existing \*.xlsx Excel file, make some modifications, and then save it as a new file (or stream it to the frontend without saving). The original file must remain unchanged.
For Memory reasons, I avoid using FileInputStream (as described here: <http://poi.apache.org/spreadsheet/quick-guide.html#FileIn... | 2017/02/21 | [
"https://Stackoverflow.com/questions/42372532",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6426882/"
] | X and y labels are bound to an axes in matplotlib. So it makes little sense to use `xlabel` or `ylabel` commands for the purpose of labeling several subplots.
What is possible though, is to create a simple text and place it at the desired position. `fig.text(x,y, text)` places some text at coordinates `x` and `y` in ... | Another solution: create a big subplot and then set the common labels. Here is what I got.
[enter image description here](https://i.stack.imgur.com/tiDKH.png)
-------------------------------------------------------------------
The source code is below.
```
import pandas as pd
import matplotlib.pyplot as plt
fig = p... |
42,372,532 | I need to open an existing \*.xlsx Excel file, make some modifications, and then save it as a new file (or stream it to the frontend without saving). The original file must remain unchanged.
For Memory reasons, I avoid using FileInputStream (as described here: <http://poi.apache.org/spreadsheet/quick-guide.html#FileIn... | 2017/02/21 | [
"https://Stackoverflow.com/questions/42372532",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6426882/"
] | X and y labels are bound to an axes in matplotlib. So it makes little sense to use `xlabel` or `ylabel` commands for the purpose of labeling several subplots.
What is possible though, is to create a simple text and place it at the desired position. `fig.text(x,y, text)` places some text at coordinates `x` and `y` in ... | **New: Recent matplotlib** (v3.4+; use `pip --upgrade matplotlib`) also has figure-level x- and y-labels:
```
fig.supxlabel('my general x-label')
fig.supylabel('my general y-label')
```
While this is an important option to know about, it's not by default quite the same as having the font size and location matched as... |
52,076,282 | I am using @ngx/translate core for lang change.
I want to define sass on the basic of
```
<body lang="en">
```
or
```
<body lang="fr">
```
by if else condition.
```
Inside my component sass i want to do something like this
@if( bodylang = en)
/these rules
else
// these rules
```
How can i achieve this? | 2018/08/29 | [
"https://Stackoverflow.com/questions/52076282",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9419166/"
] | As it is SCSS you are able to use CSS attribute selectors for this, for example:
```
a[target="_blank"] {
background-color: yellow;
}
```
Which in your case would be:
```
body[lang="en"] {
// Your code
}
body[lang="fr"] {
// Your code
}
```
You can also nest them like such:
```
body {
backgroun... | If you want to do it in your component SCSS file you have to do something like bellow code:
```
:host-context([lang="en"]){
// Your code
}
:host-context([lang="fa"]){
// Your code
}
```
If you are doing it in your styles.scss file you can achieve your goal with following code:
```
[lang="en"] {
// You... |
52,076,282 | I am using @ngx/translate core for lang change.
I want to define sass on the basic of
```
<body lang="en">
```
or
```
<body lang="fr">
```
by if else condition.
```
Inside my component sass i want to do something like this
@if( bodylang = en)
/these rules
else
// these rules
```
How can i achieve this? | 2018/08/29 | [
"https://Stackoverflow.com/questions/52076282",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9419166/"
] | As it is SCSS you are able to use CSS attribute selectors for this, for example:
```
a[target="_blank"] {
background-color: yellow;
}
```
Which in your case would be:
```
body[lang="en"] {
// Your code
}
body[lang="fr"] {
// Your code
}
```
You can also nest them like such:
```
body {
backgroun... | rsangin's answer is the correct one.
If you want to select every language that is not en, you can just use `:not([lang="en"])` |
52,076,282 | I am using @ngx/translate core for lang change.
I want to define sass on the basic of
```
<body lang="en">
```
or
```
<body lang="fr">
```
by if else condition.
```
Inside my component sass i want to do something like this
@if( bodylang = en)
/these rules
else
// these rules
```
How can i achieve this? | 2018/08/29 | [
"https://Stackoverflow.com/questions/52076282",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9419166/"
] | If you want to do it in your component SCSS file you have to do something like bellow code:
```
:host-context([lang="en"]){
// Your code
}
:host-context([lang="fa"]){
// Your code
}
```
If you are doing it in your styles.scss file you can achieve your goal with following code:
```
[lang="en"] {
// You... | rsangin's answer is the correct one.
If you want to select every language that is not en, you can just use `:not([lang="en"])` |
62,101 | Just what the title says. Suppose I know the feature that I want to be used for splitting for the root node in a tree model in XGBoost; is there a way for me to tell XGBoost to split on this feature at the root node? | 2019/10/22 | [
"https://datascience.stackexchange.com/questions/62101",
"https://datascience.stackexchange.com",
"https://datascience.stackexchange.com/users/84189/"
] | I do not have the whole answer, but I believe that xgboost allows warm-starting, which implies starting from a provided point.
```
xgb.train(…,xgb_model=model_to_start_from)
``` | Could you enforce this using [feature interactions](https://xgboost.readthedocs.io/en/stable/tutorials/feature_interaction_constraint.html)? Maybe create two sets of features with only that one feature in common? I’m not sure if it will guarantee that that shared feature is the one on which the first split is made. |
62,101 | Just what the title says. Suppose I know the feature that I want to be used for splitting for the root node in a tree model in XGBoost; is there a way for me to tell XGBoost to split on this feature at the root node? | 2019/10/22 | [
"https://datascience.stackexchange.com/questions/62101",
"https://datascience.stackexchange.com",
"https://datascience.stackexchange.com/users/84189/"
] | It's hard to prove a negative, but I think the answer is no. Especially in xgboost compared to other tree-model packages, it's rather hard to even access the base trees, let alone modify their build. | Could you enforce this using [feature interactions](https://xgboost.readthedocs.io/en/stable/tutorials/feature_interaction_constraint.html)? Maybe create two sets of features with only that one feature in common? I’m not sure if it will guarantee that that shared feature is the one on which the first split is made. |
54,882,263 | The text of button is not displaying in Safari,I can return the text using jquery in the console. But it is recognising the click event e.g
```html
<div class="btn-group btn-group-lg">
<button onclick="change();" id="face-btn" type="button" class="btn btn-primary">Face</button>
``` | 2019/02/26 | [
"https://Stackoverflow.com/questions/54882263",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7430286/"
] | I couldn't write a comment that why am writing a suggestion here,
try to add a height to your button style
This answer is based on this Articel: [Button-not-displaying-well-in-Safari](https://www.sitepoint.com/forums/showthread.php?597261-Button-not-displaying-well-in-Safari) | I am using Safari browser and I can see the text in the button.
For better support use `value` attribute to provide support for all browsers.
```html
<div class="btn-group btn-group-lg">
<button onclick="change();" id="face-btn" type="button" value="Face" class="btn btn-primary">Face</button>
```
Hope it helps. |
54,882,263 | The text of button is not displaying in Safari,I can return the text using jquery in the console. But it is recognising the click event e.g
```html
<div class="btn-group btn-group-lg">
<button onclick="change();" id="face-btn" type="button" class="btn btn-primary">Face</button>
``` | 2019/02/26 | [
"https://Stackoverflow.com/questions/54882263",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7430286/"
] | Issue was with the line -webkit-text-fill-color: transparent; | I am using Safari browser and I can see the text in the button.
For better support use `value` attribute to provide support for all browsers.
```html
<div class="btn-group btn-group-lg">
<button onclick="change();" id="face-btn" type="button" value="Face" class="btn btn-primary">Face</button>
```
Hope it helps. |
95,170 | I was curious if the half life of Gold is 186 Days, then why does it 'Last forever' ... Wouldn't the ancient Egyptian gold artifacts be decayed to lighter elements by now like platinum? I know gold was able to withstand corrosion very well, but the relatively short half-life is kinda throwing off my understanding of wh... | 2018/04/14 | [
"https://chemistry.stackexchange.com/questions/95170",
"https://chemistry.stackexchange.com",
"https://chemistry.stackexchange.com/users/62802/"
] | Gold has only one stable isotope, $\ce{^197Au}$, which has $100\%$ natural abundance, thus considered to be one of monoisotopic elements (one of 26 chemical elements which have only a single stable isotope). As a matter of facts, it is now considered to be the heaviest monoisotopic element. For more info, read [Isotope... | Gold has a [number of isotopes](https://en.wikipedia.org/wiki/Isotopes_of_gold). $\ce{^{197}Au}$ is stable and is the only isotope which is. So all the gold that is mined is $\ce{^{197}Au}$. |
107,732 | I've tried researching this question myself, but the only data I can find is over huge timescales, like situations where the continents have reformed back into a Neo-Pangea.
I'm not looking for any real drastic changes in positioning, just relatively minor things like seas disappearing or continents slightly shrinking... | 2018/03/23 | [
"https://worldbuilding.stackexchange.com/questions/107732",
"https://worldbuilding.stackexchange.com",
"https://worldbuilding.stackexchange.com/users/48871/"
] | A millennium is a blink of an eye on a geological scale. But interesting things can happen in a blink of an eye. Even disegarding the changes which may happen as a result of the present climatological instability, small but important modification can occur here and there.
I have no idea of the geographical changes bet... | >
> Would there be any noteworthy changes at all,
>
>
> just assume humanity suddenly stopped existing today for the purposes of the question
>
>
>
Global Warming would continue for a while, if for no other reason than approximately 2.5% of CO2 is sequestered per annum.
<http://euanmearns.com/the-half-life-of-c... |
107,732 | I've tried researching this question myself, but the only data I can find is over huge timescales, like situations where the continents have reformed back into a Neo-Pangea.
I'm not looking for any real drastic changes in positioning, just relatively minor things like seas disappearing or continents slightly shrinking... | 2018/03/23 | [
"https://worldbuilding.stackexchange.com/questions/107732",
"https://worldbuilding.stackexchange.com",
"https://worldbuilding.stackexchange.com/users/48871/"
] | >
> Would there be any noteworthy changes at all,
>
>
> just assume humanity suddenly stopped existing today for the purposes of the question
>
>
>
Global Warming would continue for a while, if for no other reason than approximately 2.5% of CO2 is sequestered per annum.
<http://euanmearns.com/the-half-life-of-c... | In addition to the previously noted changes due to climate and normal geology, the sudden removal of humans a la Discovery Channel's [Life After People](https://www.history.com/shows/life-after-people) would quickly lead to the breakdown of electrical and mechanical infrastructure, including pumping stations (e.g., the... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.