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
25,648,393
So about a year ago I started a project and like all new developers I didn't really focus too much on the structure, however now I am further along with Django it has started to appear that my project layout mainly my models are horrible in structure. I have models mainly held in a single app and really most of these ...
2014/09/03
[ "https://Stackoverflow.com/questions/25648393", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2848524/" ]
This can be done fairly easily using `migrations.SeparateDatabaseAndState`. Basically, we use a database operation to rename the table concurrently with two state operations to remove the model from one app's history and create it in another's. Remove from old app ------------------- ``` python manage.py makemigratio...
I get nervous hand-coding migrations (as is required by [Ozan's](https://stackoverflow.com/a/26472482/1978687) answer) so the following combines Ozan's and [Michael's](https://stackoverflow.com/a/30784483/1978687) strategies to minimize the amount of hand-coding required: 1. Before moving any models, make sure you're ...
25,648,393
So about a year ago I started a project and like all new developers I didn't really focus too much on the structure, however now I am further along with Django it has started to appear that my project layout mainly my models are horrible in structure. I have models mainly held in a single app and really most of these ...
2014/09/03
[ "https://Stackoverflow.com/questions/25648393", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2848524/" ]
Another hacky alternative if the data is not big or too complicated, but still important to maintain, is to: * Get data fixtures using [manage.py dumpdata](https://docs.djangoproject.com/en/1.11/ref/django-admin/#dumpdata) * Proceed to model changes and migrations properly, without relating the changes * Global replac...
Copied from my answer at <https://stackoverflow.com/a/47392970/8971048> In case you need to move the model and you don't have access to the app anymore (or you don't want the access), you can create a new Operation and consider to create a new model only if the migrated model does not exist. In this example I am pass...
25,648,393
So about a year ago I started a project and like all new developers I didn't really focus too much on the structure, however now I am further along with Django it has started to appear that my project layout mainly my models are horrible in structure. I have models mainly held in a single app and really most of these ...
2014/09/03
[ "https://Stackoverflow.com/questions/25648393", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2848524/" ]
I encountered the same problem. [Ozan's answer](https://stackoverflow.com/a/26472482/2698552) helped me a lot but unfortunately was not enough. Indeed I had several ForeignKey linking to the model I wanted to move. After some headache I found the solution so decided to post it to solve people time. You need 2 more ste...
Another hacky alternative if the data is not big or too complicated, but still important to maintain, is to: * Get data fixtures using [manage.py dumpdata](https://docs.djangoproject.com/en/1.11/ref/django-admin/#dumpdata) * Proceed to model changes and migrations properly, without relating the changes * Global replac...
25,648,393
So about a year ago I started a project and like all new developers I didn't really focus too much on the structure, however now I am further along with Django it has started to appear that my project layout mainly my models are horrible in structure. I have models mainly held in a single app and really most of these ...
2014/09/03
[ "https://Stackoverflow.com/questions/25648393", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2848524/" ]
How I did it (tested on Django==1.8, with postgres, so probably also 1.7) Situation **app1.YourModel** but you want it to go to: **app2.YourModel** 1. Copy YourModel (the code) from app1 to app2. 2. add this to app2.YourModel: ``` Class Meta: db_table = 'app1_yourmodel' ``` 3. $ python manage.py makemigration...
Another hacky alternative if the data is not big or too complicated, but still important to maintain, is to: * Get data fixtures using [manage.py dumpdata](https://docs.djangoproject.com/en/1.11/ref/django-admin/#dumpdata) * Proceed to model changes and migrations properly, without relating the changes * Global replac...
25,648,393
So about a year ago I started a project and like all new developers I didn't really focus too much on the structure, however now I am further along with Django it has started to appear that my project layout mainly my models are horrible in structure. I have models mainly held in a single app and really most of these ...
2014/09/03
[ "https://Stackoverflow.com/questions/25648393", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2848524/" ]
Copied from my answer at <https://stackoverflow.com/a/47392970/8971048> In case you need to move the model and you don't have access to the app anymore (or you don't want the access), you can create a new Operation and consider to create a new model only if the migrated model does not exist. In this example I am pass...
1. change the names of old models to ‘model\_name\_old’ 2. makemigrations 3. make new models named ‘model\_name\_new’ with identical relationships on the related models (eg. user model now has user.blog\_old and user.blog\_new) 4. makemigrations 5. write a custom migration that migrates all the data to the new model ta...
25,648,393
So about a year ago I started a project and like all new developers I didn't really focus too much on the structure, however now I am further along with Django it has started to appear that my project layout mainly my models are horrible in structure. I have models mainly held in a single app and really most of these ...
2014/09/03
[ "https://Stackoverflow.com/questions/25648393", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2848524/" ]
This can be done fairly easily using `migrations.SeparateDatabaseAndState`. Basically, we use a database operation to rename the table concurrently with two state operations to remove the model from one app's history and create it in another's. Remove from old app ------------------- ``` python manage.py makemigratio...
1. change the names of old models to ‘model\_name\_old’ 2. makemigrations 3. make new models named ‘model\_name\_new’ with identical relationships on the related models (eg. user model now has user.blog\_old and user.blog\_new) 4. makemigrations 5. write a custom migration that migrates all the data to the new model ta...
25,648,393
So about a year ago I started a project and like all new developers I didn't really focus too much on the structure, however now I am further along with Django it has started to appear that my project layout mainly my models are horrible in structure. I have models mainly held in a single app and really most of these ...
2014/09/03
[ "https://Stackoverflow.com/questions/25648393", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2848524/" ]
Copied from my answer at <https://stackoverflow.com/a/47392970/8971048> In case you need to move the model and you don't have access to the app anymore (or you don't want the access), you can create a new Operation and consider to create a new model only if the migrated model does not exist. In this example I am pass...
**This is tested roughly, so do not forget to backup your DB!!!** For example, there are two apps: `src_app` and `dst_app`, we want to move model `MoveMe` from `src_app` to `dst_app`. Create empty migrations for both apps: ``` python manage.py makemigrations --empty src_app python manage.py makemigrations --empty d...
25,648,393
So about a year ago I started a project and like all new developers I didn't really focus too much on the structure, however now I am further along with Django it has started to appear that my project layout mainly my models are horrible in structure. I have models mainly held in a single app and really most of these ...
2014/09/03
[ "https://Stackoverflow.com/questions/25648393", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2848524/" ]
I am removing the old answer as may result in data loss. As [ozan mentioned](https://stackoverflow.com/a/26472482/2698552), we can create 2 migrations one in each app. The comments below this post refer to my old answer. First migration to remove model from 1st app. ``` $ python manage.py makemigrations old_app --emp...
How I did it (tested on Django==1.8, with postgres, so probably also 1.7) Situation **app1.YourModel** but you want it to go to: **app2.YourModel** 1. Copy YourModel (the code) from app1 to app2. 2. add this to app2.YourModel: ``` Class Meta: db_table = 'app1_yourmodel' ``` 3. $ python manage.py makemigration...
22,427,342
Here is the scenario, I am getting the result-set from the following code and i am running the following below query after getting the result from cfdump, but it shows empty second dump, do not why? can anyone check what is wrong: ``` <cfif StructKeyExists(URL,'submitsearch') AND URL.submitsearch neq ''> <cfset a...
2014/03/15
[ "https://Stackoverflow.com/questions/22427342", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2485109/" ]
Based on the screenshot provided, the following is suggested ``` <cfif StructKeyExists(URL,'submitsearch') AND URL.submitsearch neq ''> <cfset answers = initial.getSearchResults(URL)> <cfset flag = 'yes'> </cfif> <cfquery dbtype="query" name="qrySummary"> SELECT status, count(status) as strvalue FROM a...
**Copying structs** First off ``` <cfset answers = initial.getSearchResults('#URL#')> ``` Won't work. If we ignore the dangers with this, you can ``` <cfset answers = initial.getSearchResults(URL)> ``` `<cfdump>` can't generate any output inside of a `<cfchart>`. If you want to a dump, it has to be outside of t...
13,432,899
Can you explain what is wrong with this quicksort algorithm implementation in java? ``` static ArrayList<Integer> quickSort(ArrayList<Integer> array){ if (array.size() <=1){ ArrayList<Integer> a = new ArrayList<Integer>(); return a; } int pivotIndex = array.size() / 2; int pivot = a...
2012/11/17
[ "https://Stackoverflow.com/questions/13432899", "https://Stackoverflow.com", "https://Stackoverflow.com/users/847988/" ]
One glaring error is that arrays of size one are not handled correctly. It's important to get this right since this is one of the base cases for the recursion.
The main issue with this algorithm - you're creating new ArrayLists for each invocation of the function. In this way you nullify the best thing about QuickSort - sorting in place without any additional memory. Try to work only with the first given **array**.
13,432,899
Can you explain what is wrong with this quicksort algorithm implementation in java? ``` static ArrayList<Integer> quickSort(ArrayList<Integer> array){ if (array.size() <=1){ ArrayList<Integer> a = new ArrayList<Integer>(); return a; } int pivotIndex = array.size() / 2; int pivot = a...
2012/11/17
[ "https://Stackoverflow.com/questions/13432899", "https://Stackoverflow.com", "https://Stackoverflow.com/users/847988/" ]
instead of ``` if (array.size() <=1) { ArrayList<Integer> a = new ArrayList<Integer>(); return a; } ``` use ``` if (array.size() <=1){ return array } ```
The main issue with this algorithm - you're creating new ArrayLists for each invocation of the function. In this way you nullify the best thing about QuickSort - sorting in place without any additional memory. Try to work only with the first given **array**.
51,330,095
I am currently somewhat new to c#/wpf (and coding in general). I decided to start another project, being a custom made "task manager" of sorts. (While I use binding, this is NOT a MVVM project, so all answers welcome) If you have ever opened task manager, you know that one of the main helpful tools it provides is a ...
2018/07/13
[ "https://Stackoverflow.com/questions/51330095", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9622460/" ]
Instead of looping you could use a timer to periodically poll for the CPU usage. ``` class Test { private System.Timers.Timer _timer; public Test( ) { _timer = new System.Timers.Timer { // Interval set to 1 millisecond. Interval = 1, AutoReset = true, ...
I'd use `Task.Run` instead of a `BackgroundWorker` in your case: ``` private void Grid_Loaded(object sender, RoutedEventArgs e) { //Keep it running for 5 minutes CancellationTokenSource cts = new CancellationTokenSource(new TimeSpan(hours: 0, minutes: 5, seconds: 0)); //Keep it running until user closes t...
7,968,118
I have a feature in visual studio which I have never really understood. I am able to 'right-click' on the App\_Data folder and then I am able to select 'Sql Server Database'. I dont really understand how I can create a db using just an mdf file? I thought the sql service was responsible for manipulating these files? A...
2011/11/01
[ "https://Stackoverflow.com/questions/7968118", "https://Stackoverflow.com", "https://Stackoverflow.com/users/223863/" ]
You're application is still connecting through the SQL Server service but it can instruct the service to attach to a specific mdf file at runtime through a connection string. e.g.: ``` "Server=.\SQLExpress;AttachDbFilename=c:\mydbfile.mdf;Database=dbname; Trusted_Connection=Yes;" ```
All SQL Server databases are represented as one (or more) .mdf files and usually .ldf files as well (ldf is the log file, mdf is the data file.) An .mdf file is a file but it is highly structured and maintained by SQL Server. The way SQL Server uses this file is very different from serving up CSV data, as a simple exam...
7,968,118
I have a feature in visual studio which I have never really understood. I am able to 'right-click' on the App\_Data folder and then I am able to select 'Sql Server Database'. I dont really understand how I can create a db using just an mdf file? I thought the sql service was responsible for manipulating these files? A...
2011/11/01
[ "https://Stackoverflow.com/questions/7968118", "https://Stackoverflow.com", "https://Stackoverflow.com/users/223863/" ]
You're application is still connecting through the SQL Server service but it can instruct the service to attach to a specific mdf file at runtime through a connection string. e.g.: ``` "Server=.\SQLExpress;AttachDbFilename=c:\mydbfile.mdf;Database=dbname; Trusted_Connection=Yes;" ```
When you installed Visual Studio you also installed SQL Server Express. This gives you the ability to create and use SQL Server databases. If you were to deploy your application you would then also need to have a SQL Server (Express) install on the web-server you were using (at least because you don't want to use your...
1,504,326
What is the difference and how can I write these two statements in both forms? > > Not in every hole lives a pigeon. > > > Some pigeon lives in more than one hole. > > > For the first statement I have $∀h∀p [LivesIn(p, h)]$ but I am not sure how to express this in the universal form. I am not sure how to expre...
2015/10/30
[ "https://math.stackexchange.com/questions/1504326", "https://math.stackexchange.com", "https://math.stackexchange.com/users/-1/" ]
For the first, "Not in every hole lives a pigeon", start from the positive assertion, "In every hole lives a pigeon." The one which you're trying to represent is just the negation of that. "In every hole lives a pigeon" is a universal-existential sentence: "for every hole, there's a pigeon that lives in it", or symboli...
The second statement is saying that 'there exists a pidgeon who lives in more than one hole" unless you actually meant to write pidgeons.
1,504,326
What is the difference and how can I write these two statements in both forms? > > Not in every hole lives a pigeon. > > > Some pigeon lives in more than one hole. > > > For the first statement I have $∀h∀p [LivesIn(p, h)]$ but I am not sure how to express this in the universal form. I am not sure how to expre...
2015/10/30
[ "https://math.stackexchange.com/questions/1504326", "https://math.stackexchange.com", "https://math.stackexchange.com/users/-1/" ]
For the first, "Not in every hole lives a pigeon", start from the positive assertion, "In every hole lives a pigeon." The one which you're trying to represent is just the negation of that. "In every hole lives a pigeon" is a universal-existential sentence: "for every hole, there's a pigeon that lives in it", or symboli...
> > Not in every hole lives a pigeon. > > > Negate "in every hole lives a pigeon". $$\neg \;\forall x\;\exists y\; \Big(\operatorname{Hole}(x) \,\to\, \big(\operatorname{Pigeon}(y)\wedge\operatorname{LivesIn}(y, x)\big)\Big)$$ *Remember:* use implication to restrict a universe and conjugation to restrict an exis...
1,504,326
What is the difference and how can I write these two statements in both forms? > > Not in every hole lives a pigeon. > > > Some pigeon lives in more than one hole. > > > For the first statement I have $∀h∀p [LivesIn(p, h)]$ but I am not sure how to express this in the universal form. I am not sure how to expre...
2015/10/30
[ "https://math.stackexchange.com/questions/1504326", "https://math.stackexchange.com", "https://math.stackexchange.com/users/-1/" ]
For the first, "Not in every hole lives a pigeon", start from the positive assertion, "In every hole lives a pigeon." The one which you're trying to represent is just the negation of that. "In every hole lives a pigeon" is a universal-existential sentence: "for every hole, there's a pigeon that lives in it", or symboli...
> > Not in every hole lives a pigeon. > > > $\neg \forall x:[Hole(x)\implies \exists y:[Pigeon(y) \land LivesIn(y,x)]]$ Or equivalently: $\exists x: [Hole(x) \land \forall y: [Pigeon(y)\implies \neg LivesIn(y,x)]]$ > > Some pigeon lives in more than one hole. > > > $\exists x,y,z: [Pigeon(x) \land Hole(y) ...
10,603,982
I believe one can define covariance (at least, for objects) as 'the ability to use a value of a narrower (sub) type in place of a value of some wider (super) type', and that contravariance is the exact opposite of this. Apparently, Scala functions are instances of Function[-A1,...,+B] for contravariant parameter type...
2012/05/15
[ "https://Stackoverflow.com/questions/10603982", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1396545/" ]
Covariance and contravariance are qualities of *the class* not qualities of *the parameters*. (They are qualities that depend on the parameters, but they make statements about the class.) So, `Function1[-A,+B]` means that *a function* that takes superclasses of `A` can be viewed as a subclass of *the original function...
There are two separate ideas at work here. One is using subtyping to allow more specific arguments to be passed to a function (called *subsumption*). The other is how to check subtyping on functions themselves. For type-checking the arguments to a function, you only have to check that the given arguments are subtypes ...
10,603,982
I believe one can define covariance (at least, for objects) as 'the ability to use a value of a narrower (sub) type in place of a value of some wider (super) type', and that contravariance is the exact opposite of this. Apparently, Scala functions are instances of Function[-A1,...,+B] for contravariant parameter type...
2012/05/15
[ "https://Stackoverflow.com/questions/10603982", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1396545/" ]
There are two separate ideas at work here. One is using subtyping to allow more specific arguments to be passed to a function (called *subsumption*). The other is how to check subtyping on functions themselves. For type-checking the arguments to a function, you only have to check that the given arguments are subtypes ...
Covariant means converting from wider (super) to narrower (sub). For example, we have two class: one is animal (super) and the other one is cat then using covariant, we can convert animal to cat. Contra-variant is just the opposite of covariant, which means cat to animal. Invariant means it's unable to convert.
10,603,982
I believe one can define covariance (at least, for objects) as 'the ability to use a value of a narrower (sub) type in place of a value of some wider (super) type', and that contravariance is the exact opposite of this. Apparently, Scala functions are instances of Function[-A1,...,+B] for contravariant parameter type...
2012/05/15
[ "https://Stackoverflow.com/questions/10603982", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1396545/" ]
This question is old, but I think a clearer explanation is to invoke the Liskov Substitution Principle: everything that's true about a superclass should be true of all its subclasses. You should be able to do with a SubFoo everything that you can do with a Foo, and maybe more. Suppose we have Calico <: Cat <: Animal, ...
There are two separate ideas at work here. One is using subtyping to allow more specific arguments to be passed to a function (called *subsumption*). The other is how to check subtyping on functions themselves. For type-checking the arguments to a function, you only have to check that the given arguments are subtypes ...
10,603,982
I believe one can define covariance (at least, for objects) as 'the ability to use a value of a narrower (sub) type in place of a value of some wider (super) type', and that contravariance is the exact opposite of this. Apparently, Scala functions are instances of Function[-A1,...,+B] for contravariant parameter type...
2012/05/15
[ "https://Stackoverflow.com/questions/10603982", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1396545/" ]
There are two separate ideas at work here. One is using subtyping to allow more specific arguments to be passed to a function (called *subsumption*). The other is how to check subtyping on functions themselves. For type-checking the arguments to a function, you only have to check that the given arguments are subtypes ...
A simplified explanation ``` class A class B extends A val printA: A => Unit = { a => println("Blah blah blah") } printA(new A()) //"Blah blah blah" printA(new B()) //"Blah blah blah" ``` contravariance rule: If `B` is a subtype of `A`, then `printA[A]` is a subtype of `printA[B]` Since `printA[B]` is the supe...
10,603,982
I believe one can define covariance (at least, for objects) as 'the ability to use a value of a narrower (sub) type in place of a value of some wider (super) type', and that contravariance is the exact opposite of this. Apparently, Scala functions are instances of Function[-A1,...,+B] for contravariant parameter type...
2012/05/15
[ "https://Stackoverflow.com/questions/10603982", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1396545/" ]
Covariance and contravariance are qualities of *the class* not qualities of *the parameters*. (They are qualities that depend on the parameters, but they make statements about the class.) So, `Function1[-A,+B]` means that *a function* that takes superclasses of `A` can be viewed as a subclass of *the original function...
Covariant means converting from wider (super) to narrower (sub). For example, we have two class: one is animal (super) and the other one is cat then using covariant, we can convert animal to cat. Contra-variant is just the opposite of covariant, which means cat to animal. Invariant means it's unable to convert.
10,603,982
I believe one can define covariance (at least, for objects) as 'the ability to use a value of a narrower (sub) type in place of a value of some wider (super) type', and that contravariance is the exact opposite of this. Apparently, Scala functions are instances of Function[-A1,...,+B] for contravariant parameter type...
2012/05/15
[ "https://Stackoverflow.com/questions/10603982", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1396545/" ]
Covariance and contravariance are qualities of *the class* not qualities of *the parameters*. (They are qualities that depend on the parameters, but they make statements about the class.) So, `Function1[-A,+B]` means that *a function* that takes superclasses of `A` can be viewed as a subclass of *the original function...
This question is old, but I think a clearer explanation is to invoke the Liskov Substitution Principle: everything that's true about a superclass should be true of all its subclasses. You should be able to do with a SubFoo everything that you can do with a Foo, and maybe more. Suppose we have Calico <: Cat <: Animal, ...
10,603,982
I believe one can define covariance (at least, for objects) as 'the ability to use a value of a narrower (sub) type in place of a value of some wider (super) type', and that contravariance is the exact opposite of this. Apparently, Scala functions are instances of Function[-A1,...,+B] for contravariant parameter type...
2012/05/15
[ "https://Stackoverflow.com/questions/10603982", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1396545/" ]
Covariance and contravariance are qualities of *the class* not qualities of *the parameters*. (They are qualities that depend on the parameters, but they make statements about the class.) So, `Function1[-A,+B]` means that *a function* that takes superclasses of `A` can be viewed as a subclass of *the original function...
A simplified explanation ``` class A class B extends A val printA: A => Unit = { a => println("Blah blah blah") } printA(new A()) //"Blah blah blah" printA(new B()) //"Blah blah blah" ``` contravariance rule: If `B` is a subtype of `A`, then `printA[A]` is a subtype of `printA[B]` Since `printA[B]` is the supe...
10,603,982
I believe one can define covariance (at least, for objects) as 'the ability to use a value of a narrower (sub) type in place of a value of some wider (super) type', and that contravariance is the exact opposite of this. Apparently, Scala functions are instances of Function[-A1,...,+B] for contravariant parameter type...
2012/05/15
[ "https://Stackoverflow.com/questions/10603982", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1396545/" ]
This question is old, but I think a clearer explanation is to invoke the Liskov Substitution Principle: everything that's true about a superclass should be true of all its subclasses. You should be able to do with a SubFoo everything that you can do with a Foo, and maybe more. Suppose we have Calico <: Cat <: Animal, ...
Covariant means converting from wider (super) to narrower (sub). For example, we have two class: one is animal (super) and the other one is cat then using covariant, we can convert animal to cat. Contra-variant is just the opposite of covariant, which means cat to animal. Invariant means it's unable to convert.
10,603,982
I believe one can define covariance (at least, for objects) as 'the ability to use a value of a narrower (sub) type in place of a value of some wider (super) type', and that contravariance is the exact opposite of this. Apparently, Scala functions are instances of Function[-A1,...,+B] for contravariant parameter type...
2012/05/15
[ "https://Stackoverflow.com/questions/10603982", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1396545/" ]
A simplified explanation ``` class A class B extends A val printA: A => Unit = { a => println("Blah blah blah") } printA(new A()) //"Blah blah blah" printA(new B()) //"Blah blah blah" ``` contravariance rule: If `B` is a subtype of `A`, then `printA[A]` is a subtype of `printA[B]` Since `printA[B]` is the supe...
Covariant means converting from wider (super) to narrower (sub). For example, we have two class: one is animal (super) and the other one is cat then using covariant, we can convert animal to cat. Contra-variant is just the opposite of covariant, which means cat to animal. Invariant means it's unable to convert.
10,603,982
I believe one can define covariance (at least, for objects) as 'the ability to use a value of a narrower (sub) type in place of a value of some wider (super) type', and that contravariance is the exact opposite of this. Apparently, Scala functions are instances of Function[-A1,...,+B] for contravariant parameter type...
2012/05/15
[ "https://Stackoverflow.com/questions/10603982", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1396545/" ]
This question is old, but I think a clearer explanation is to invoke the Liskov Substitution Principle: everything that's true about a superclass should be true of all its subclasses. You should be able to do with a SubFoo everything that you can do with a Foo, and maybe more. Suppose we have Calico <: Cat <: Animal, ...
A simplified explanation ``` class A class B extends A val printA: A => Unit = { a => println("Blah blah blah") } printA(new A()) //"Blah blah blah" printA(new B()) //"Blah blah blah" ``` contravariance rule: If `B` is a subtype of `A`, then `printA[A]` is a subtype of `printA[B]` Since `printA[B]` is the supe...
46,616,156
In my iOS app, I have 2 `WKWebView` controls to simulate parent/child relationship of 2 tab/window in our web app so that we can reuse all those javascripts. Problem is that there is no generic communication channel between these 2 `WKWebView`s. **Web Architecture**: - The first/master window loads our internal jav...
2017/10/07
[ "https://Stackoverflow.com/questions/46616156", "https://Stackoverflow.com", "https://Stackoverflow.com/users/654016/" ]
You definitely should not return `nil` from `webView:createWebViewWithConfiguration:forNavigationAction:windowFeatures:`, but an instance of your `WKWebView`. Unfortunately, I have no way to verify this right now. But as far as I remember, the trick is also to not ignore `WKWebViewConfiguration` argument from `webView...
A simpler way to accomplish your task will be to have one WKWebView, and use HTML to separate header and detail. The simplest solution is to have one HTML document with the header and all of the details, but if you need to add details dynamically that can also be done use the DOM. Reusing Javascript for both the header...
51,845,399
**Langauge** Java **Application:** Patient Viewer/Creator **Question** 1. How should I handle the objects being created? 2. What are the negatives of saving Patient objects to a structure as they are being created? Any positives? **Current Implementation:** My initial thought was to create an ArrayList or Map an...
2018/08/14
[ "https://Stackoverflow.com/questions/51845399", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Sounds like what you need is string formatting, something like this: ``` def get_sentence(author,pud_date): return "This article was written by {}, who is solely responsible for its content. This article was published on {}.".format(author,pub_date) ``` Assuming you are parsing the variables that make up the strin...
If you have control over the templates I would use `str.format` and a `dict` containing the variables: ``` >>> template = "This {publication} was written by {author}, who is solely responsible for its content." >>> variables = {"publication": "article", "author": "Me"} template.format(**variables) 'This article was wr...
51,845,399
**Langauge** Java **Application:** Patient Viewer/Creator **Question** 1. How should I handle the objects being created? 2. What are the negatives of saving Patient objects to a structure as they are being created? Any positives? **Current Implementation:** My initial thought was to create an ArrayList or Map an...
2018/08/14
[ "https://Stackoverflow.com/questions/51845399", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
With Python 3.6+, you may find formatted string literals ([PEP 498](https://www.python.org/dev/peps/pep-0498/)) efficient: ``` # data from @bohrax d = {"publication": "article", "author": "Me"} template = f"This {d['publication']} was written by {d['author']}, who is solely responsible for its content." print(templa...
If you have control over the templates I would use `str.format` and a `dict` containing the variables: ``` >>> template = "This {publication} was written by {author}, who is solely responsible for its content." >>> variables = {"publication": "article", "author": "Me"} template.format(**variables) 'This article was wr...
51,509,317
How can I generate a authorization request header ? I have read about [authorization request header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Authorization) and I generated one using username and password in base 64, but when I pass it on request header it doesn't work (`"error": "invalid_client`). ...
2018/07/25
[ "https://Stackoverflow.com/questions/51509317", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
You can do ``` new THREE.SphereGeometry(1, 32, 32, 0, 2*Math.PI, 0, Math.PI/2); ```
``` //Here's some code to modify a sphere into a hemisphere var sphereGeom = new THREE.SphereBufferGeometry(1,16,16); let verts = sphereGeom.attributes.position.array for(var i=0;i<verts.length;i+=3){ if(verts[i+1]<0) verts[i+1]=0; } sphereGeom.computeFaceNormals(); sphereGeom.computeVertexNormals(); //sphereGe...
51,509,317
How can I generate a authorization request header ? I have read about [authorization request header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Authorization) and I generated one using username and password in base 64, but when I pass it on request header it doesn't work (`"error": "invalid_client`). ...
2018/07/25
[ "https://Stackoverflow.com/questions/51509317", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
My 5 kopeikas. Hemisphere + circle: ```js var scene = new THREE.Scene(); var camera = new THREE.PerspectiveCamera(60, window.innerWidth / window.innerHeight, 1, 1000); camera.position.set(0, 5, 8); var renderer = new THREE.WebGLRenderer({ antialias: true }); renderer.setSize(window.innerWidth, window.innerHeight); d...
``` //Here's some code to modify a sphere into a hemisphere var sphereGeom = new THREE.SphereBufferGeometry(1,16,16); let verts = sphereGeom.attributes.position.array for(var i=0;i<verts.length;i+=3){ if(verts[i+1]<0) verts[i+1]=0; } sphereGeom.computeFaceNormals(); sphereGeom.computeVertexNormals(); //sphereGe...
24,149,047
I have an issue with WPF `DataGrid`, which drives me crazy. Let's consider this view model: ``` public class ViewModel : INotifyPropertyChanged { public int Id { get; set; } public string Name { get; set; } public bool IsSelected { get { return isSelected; } set { ...
2014/06/10
[ "https://Stackoverflow.com/questions/24149047", "https://Stackoverflow.com", "https://Stackoverflow.com/users/580053/" ]
You need to understand how a HashMap works. When you put a key in a HashMap, containing N buckets, the hashCode of the key is used to find the appropriate bucket. Then each key contained in the bucket is compared, using equals(), with the added key, to know if the key is already in the map. Similarly, when getting th...
First: What do you want to do? Second: The `equals()` is the first problem as it only compares references. See [Here](https://stackoverflow.com/questions/513832/how-do-i-compare-strings-in-java) Third: The `hashCode()` function for `dog` is missing. you should never overwrite only one of `equals()` and `hashCode()` ...
24,149,047
I have an issue with WPF `DataGrid`, which drives me crazy. Let's consider this view model: ``` public class ViewModel : INotifyPropertyChanged { public int Id { get; set; } public string Name { get; set; } public bool IsSelected { get { return isSelected; } set { ...
2014/06/10
[ "https://Stackoverflow.com/questions/24149047", "https://Stackoverflow.com", "https://Stackoverflow.com/users/580053/" ]
You need to understand how a HashMap works. When you put a key in a HashMap, containing N buckets, the hashCode of the key is used to find the appropriate bucket. Then each key contained in the bucket is compared, using equals(), with the added key, to know if the key is already in the map. Similarly, when getting th...
I would strongly suggest you to begin with reading [how hashmap works in java](http://howtodoinjava.com/2012/10/09/how-hashmap-works-in-java/) There are multiple issues here. 1. When you invoke `m.put(d1, "Dog key");`, the hashCode is calculated and a bucket in the hashMap where the object will be stored is determin...
24,149,047
I have an issue with WPF `DataGrid`, which drives me crazy. Let's consider this view model: ``` public class ViewModel : INotifyPropertyChanged { public int Id { get; set; } public string Name { get; set; } public bool IsSelected { get { return isSelected; } set { ...
2014/06/10
[ "https://Stackoverflow.com/questions/24149047", "https://Stackoverflow.com", "https://Stackoverflow.com/users/580053/" ]
I would strongly suggest you to begin with reading [how hashmap works in java](http://howtodoinjava.com/2012/10/09/how-hashmap-works-in-java/) There are multiple issues here. 1. When you invoke `m.put(d1, "Dog key");`, the hashCode is calculated and a bucket in the hashMap where the object will be stored is determin...
First: What do you want to do? Second: The `equals()` is the first problem as it only compares references. See [Here](https://stackoverflow.com/questions/513832/how-do-i-compare-strings-in-java) Third: The `hashCode()` function for `dog` is missing. you should never overwrite only one of `equals()` and `hashCode()` ...
4,406,191
i make a dynamic textbox through javascript now i want to post the data of all dynamically generated textboxes to php script and then insert into a table. how can i do this... ``` <head> <title>Dynamic Form</title> <script language="javascript"> function changeIt() { var i = 1; my_div.innerHTML = my_div.innerHTML +"&...
2010/12/10
[ "https://Stackoverflow.com/questions/4406191", "https://Stackoverflow.com", "https://Stackoverflow.com/users/501751/" ]
In spite of what everyone says, `Silverlight` (and even `Flash`) is not everywhere. There are still a lot of users and browsers that don't have or support `Silverlight`. Of course it will be a great application if built using `Silverlight`, but you cannot just ignore the ones who don't have it installed. If you go with...
I'm not really familiar with Silverlight so I can't judge anything about it. With regards to html I guess Its a better choice if you want it available in many browser. If you heard about html5 I think you'll have a second thought about it. Well it still base on your needs.
4,406,191
i make a dynamic textbox through javascript now i want to post the data of all dynamically generated textboxes to php script and then insert into a table. how can i do this... ``` <head> <title>Dynamic Form</title> <script language="javascript"> function changeIt() { var i = 1; my_div.innerHTML = my_div.innerHTML +"&...
2010/12/10
[ "https://Stackoverflow.com/questions/4406191", "https://Stackoverflow.com", "https://Stackoverflow.com/users/501751/" ]
Guess it depends on your audience. For an admin panel, unless you need the maximum reach to various devices and operating systems, Silverlight is probably fine and will probably allow you to whip something together very quickly using RIA services or WCF Data Services. As far as security goes - you'll want to secure yo...
I'm not really familiar with Silverlight so I can't judge anything about it. With regards to html I guess Its a better choice if you want it available in many browser. If you heard about html5 I think you'll have a second thought about it. Well it still base on your needs.
32,963,159
So far what I have is: ``` base = int(input("Enter a value")) for row in range(base): for colomb in range(row+1): print('*', end='') print() ```
2015/10/06
[ "https://Stackoverflow.com/questions/32963159", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5412716/" ]
You were nearly there. You just need to unindent the last `print()`. Example - ``` for row in range(base): for colomb in range(row+1): print('*', end='') print() ```
Sharon's answer is the quickest solution to make the code you have work, but you could also do fewer runs through `for` loops by just printing (once) the entire string. `"a" * 3` is `"aaa"`, for instance, so you could do: ``` for row in range(1, base+1): # now the range runs [1-base] instead of [0-base-1] print("...
37,506,172
I am trying to load images from a url and I have used Picasso, however I'd like to know how to do it without an external library if possible. I know I have to get an Asynctask going but I'm not sure how to implement it. This is my getview code ``` @Override public View getView(int position, View convertView, ViewGrou...
2016/05/29
[ "https://Stackoverflow.com/questions/37506172", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4907861/" ]
Simply you can use [`java.net.URL`](https://docs.oracle.com/javase/7/docs/api/java/net/URL.html) for loading an image into ImageView like ``` ImageView loadedImage; @override protected Bitmap doInBackground(String... url) { String URL_OF_IMAGE = url[0]; Bitmap bitmap = null; try { ...
You can Use Network Image View instead of Imageview. It surely makes your life easier. ``` <com.android.volley.toolbox.NetworkImageView android:id="@+id/networkImageView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:backgro...
37,506,172
I am trying to load images from a url and I have used Picasso, however I'd like to know how to do it without an external library if possible. I know I have to get an Asynctask going but I'm not sure how to implement it. This is my getview code ``` @Override public View getView(int position, View convertView, ViewGrou...
2016/05/29
[ "https://Stackoverflow.com/questions/37506172", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4907861/" ]
You can write your own code. But using a library handles all the boilerplate code which is associated with a library. Unless otherwise, I also recommend that you use a library. Here are some of the boilerplate things that you need to consider when writing your own code. 1. **Memory management:** External libraries tak...
Simply you can use [`java.net.URL`](https://docs.oracle.com/javase/7/docs/api/java/net/URL.html) for loading an image into ImageView like ``` ImageView loadedImage; @override protected Bitmap doInBackground(String... url) { String URL_OF_IMAGE = url[0]; Bitmap bitmap = null; try { ...
37,506,172
I am trying to load images from a url and I have used Picasso, however I'd like to know how to do it without an external library if possible. I know I have to get an Asynctask going but I'm not sure how to implement it. This is my getview code ``` @Override public View getView(int position, View convertView, ViewGrou...
2016/05/29
[ "https://Stackoverflow.com/questions/37506172", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4907861/" ]
You can write your own code. But using a library handles all the boilerplate code which is associated with a library. Unless otherwise, I also recommend that you use a library. Here are some of the boilerplate things that you need to consider when writing your own code. 1. **Memory management:** External libraries tak...
You can Use Network Image View instead of Imageview. It surely makes your life easier. ``` <com.android.volley.toolbox.NetworkImageView android:id="@+id/networkImageView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:backgro...
38,185,334
I have a REST service on a server A. The service is doing some stuff and logging some messages thanks to log4j. Aside, I have a web page on server B that is calling the service thanks to AJAX and getting the response. Apart from receiving the response (which works fine to me), I would like to print on the page the lo...
2016/07/04
[ "https://Stackoverflow.com/questions/38185334", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6439357/" ]
You don't need to include OpenCV in .cu file. You need a Caller API with raw pointers and basic data types as parameters. main.cpp ``` #include "opencv2/opencv.hpp" #include "medianFilter.h" int main() { cv::Mat inputMat = cv::imread(); ..... cudaMedianCaller (d_inputMat, d_kernelMat); ..... return 0; } `...
Despite the other good answer that suggests separation between C++ and CUDA, there is an alternative way to include OpenCV containers in `.cu` files: CMakeLists.txt ``` cmake_minimum_required(VERSION 3.8) project(test LANGUAGES CXX CUDA) find_package(OpenCV 3.0 REQUIRED) # compile the target add_executable(test_app ...
66,378,462
**UPDATE** I have printed the page's pathname on to the page and discovered it is not reading past the requests. ``` let path = document.querySelector("#path"); path.innerHTML = "Page pathname is: " + location.pathname; ``` so for link `private.php?folderid=0` the pathname is `private.php` discovering this did disa...
2021/02/26
[ "https://Stackoverflow.com/questions/66378462", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13388553/" ]
`location.href` : `http://yourwebsite.com/private.php?folderid=0` `location.origin` : `http://yourwebsite.com/` `location.pathname` : `private.php` So to simply get the pathname with params you can use `.replace` ``` <script> var loc = location.href.replace(location.origin , ''); console.log(location); </...
I am using `location.pathname` where I should be using `window.location` replacing just that gave me my desired outcome. My end script became: ``` if("a[href*='" + window.location + "']") { $("a[href*='" + window.location + "']").parent().addClass("active"); } ```
61,936,484
How can I get the content between two substrings? For example in `"Hello, I have a very expensive car"` I want to find the content between `"Hello, I have"` and `"car"`, no matter what it is. How can I find the substring between the two strings?
2020/05/21
[ "https://Stackoverflow.com/questions/61936484", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
You can try this:- ``` s = 'Hello, I have a very expensive car' s = s.split(' ') print(' '.join(s[s.index('have')+1:s.index('car')])) ``` Output:- ``` 'a very expensive' ```
You could just remove the 2 strings in case there is no other text around ``` value = "Hello, I have a very expensive car" res = re.sub("(Hello, I have|car)", "", value).strip() print(res) # a very expensive ```
61,936,484
How can I get the content between two substrings? For example in `"Hello, I have a very expensive car"` I want to find the content between `"Hello, I have"` and `"car"`, no matter what it is. How can I find the substring between the two strings?
2020/05/21
[ "https://Stackoverflow.com/questions/61936484", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Regular expressions to the rescue: ``` import re text = "Hello, I have a very expensive car" pattern = re.compile(r'(?P<start>Hello, I have)(?P<middle>.+?)(?P<end>car)') match = pattern.search(text) if match: print(match.group('start')) print(match.group('middle')) print(match.group('end')) ``` Which ...
You can try this:- ``` s = 'Hello, I have a very expensive car' s = s.split(' ') print(' '.join(s[s.index('have')+1:s.index('car')])) ``` Output:- ``` 'a very expensive' ```
61,936,484
How can I get the content between two substrings? For example in `"Hello, I have a very expensive car"` I want to find the content between `"Hello, I have"` and `"car"`, no matter what it is. How can I find the substring between the two strings?
2020/05/21
[ "https://Stackoverflow.com/questions/61936484", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Regular expressions to the rescue: ``` import re text = "Hello, I have a very expensive car" pattern = re.compile(r'(?P<start>Hello, I have)(?P<middle>.+?)(?P<end>car)') match = pattern.search(text) if match: print(match.group('start')) print(match.group('middle')) print(match.group('end')) ``` Which ...
You could just remove the 2 strings in case there is no other text around ``` value = "Hello, I have a very expensive car" res = re.sub("(Hello, I have|car)", "", value).strip() print(res) # a very expensive ```
61,936,484
How can I get the content between two substrings? For example in `"Hello, I have a very expensive car"` I want to find the content between `"Hello, I have"` and `"car"`, no matter what it is. How can I find the substring between the two strings?
2020/05/21
[ "https://Stackoverflow.com/questions/61936484", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
try 're' module of Python for regular expressions: ``` import re my_string = 'Hello, I have a very expensive car' res = re.search('Hello, I have(.*)car', my_string) print(res.group(1)) ```
You could just remove the 2 strings in case there is no other text around ``` value = "Hello, I have a very expensive car" res = re.sub("(Hello, I have|car)", "", value).strip() print(res) # a very expensive ```
61,936,484
How can I get the content between two substrings? For example in `"Hello, I have a very expensive car"` I want to find the content between `"Hello, I have"` and `"car"`, no matter what it is. How can I find the substring between the two strings?
2020/05/21
[ "https://Stackoverflow.com/questions/61936484", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Regular expressions to the rescue: ``` import re text = "Hello, I have a very expensive car" pattern = re.compile(r'(?P<start>Hello, I have)(?P<middle>.+?)(?P<end>car)') match = pattern.search(text) if match: print(match.group('start')) print(match.group('middle')) print(match.group('end')) ``` Which ...
try 're' module of Python for regular expressions: ``` import re my_string = 'Hello, I have a very expensive car' res = re.search('Hello, I have(.*)car', my_string) print(res.group(1)) ```
366,614
I have been able to figure out the the distinct equivalence classes. Now I am having difficulties proving the relation IS an equivalence relation. $F$ is the relation defined on $\Bbb Z$ as follows: > > For all $(m, n) \in \Bbb Z^2,\ m F n \iff 4 | (m-n)$ > > > equivalence classes: $\{-8,-4,0,4,8\}, \{-7,-3,1,...
2013/04/19
[ "https://math.stackexchange.com/questions/366614", "https://math.stackexchange.com", "https://math.stackexchange.com/users/72287/" ]
The partition of a set into its equivalence classes *determines* an equivalence relation defined on a set. That is, *equivalence classes partition a set* $\iff \exists$ an equivalence relation determining the partition. In this case, you found the classes (or rather, representatives of those classes)...and hence, the g...
1) reflexivity: $mFm $ since $4|0$ 2) simmetry: $mFn \Rightarrow nFm$ since $4|\pm (m-n)$ 3) transitivity: if $4|(m-n)$ and $4|(n-r)$ then $4|\big((m-n)+(n-r)\big)$ or $4|(m-r)$
46,233,259
Is it ok to use additional url query params to prevent cahing or force update css/js? ``` /style.css?v=1 ``` Or it will be better to change name of file/dir? ``` /style.1.css ``` I heard this something affects the ability of proxy servers to download styles/scripts.
2017/09/15
[ "https://Stackoverflow.com/questions/46233259", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7504461/" ]
From your edit, it sounds like you are just trying to sum the *values* of all the sub-dicts, by the parent dict: ``` In [9]: counts = Counter() In [10]: for dd in data: ...: for k,v in dd.items(): ...: counts[k] += sum(v.values()) ...: In [11]: counts Out[11]: Counter({'25-34': 30, '45-54': 1...
I would use [`defaultdict`](https://docs.python.org/3/library/collections.html#collections.defaultdict) with default of `int`(which is 0): ``` from collections import defaultdict counter = defaultdict(int) for current_dict in data: for key, value in current_dict.items(): counter[key] += sum(value.values()...
46,233,259
Is it ok to use additional url query params to prevent cahing or force update css/js? ``` /style.css?v=1 ``` Or it will be better to change name of file/dir? ``` /style.1.css ``` I heard this something affects the ability of proxy servers to download styles/scripts.
2017/09/15
[ "https://Stackoverflow.com/questions/46233259", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7504461/" ]
I would use [`defaultdict`](https://docs.python.org/3/library/collections.html#collections.defaultdict) with default of `int`(which is 0): ``` from collections import defaultdict counter = defaultdict(int) for current_dict in data: for key, value in current_dict.items(): counter[key] += sum(value.values()...
For your first questions, here's a one-liner. It's not really pretty but it does use `Counter`: ``` sum((Counter({k:v['Clicks'] for k,v in d.items()}) for d in data), Counter()) ``` As an example : ``` data = [ { "25-34": { "Clicks": 10 }, "45-54": { "Clicks": 2 }, }, { "25-34...
46,233,259
Is it ok to use additional url query params to prevent cahing or force update css/js? ``` /style.css?v=1 ``` Or it will be better to change name of file/dir? ``` /style.1.css ``` I heard this something affects the ability of proxy servers to download styles/scripts.
2017/09/15
[ "https://Stackoverflow.com/questions/46233259", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7504461/" ]
I would use [`defaultdict`](https://docs.python.org/3/library/collections.html#collections.defaultdict) with default of `int`(which is 0): ``` from collections import defaultdict counter = defaultdict(int) for current_dict in data: for key, value in current_dict.items(): counter[key] += sum(value.values()...
I did like this: ``` with gzip.open("data/small_fasta.fa.gz", "rt") as handle: aac_count = defaultdict(Counter) for record in SeqIO.parse(handle, "fasta"): aac_count[record.id].update(record.seq) ``` I used biopython for open the fasta file (<https://pt.wikipedia.org/wiki/Formato_FASTA>) that are the...
46,233,259
Is it ok to use additional url query params to prevent cahing or force update css/js? ``` /style.css?v=1 ``` Or it will be better to change name of file/dir? ``` /style.1.css ``` I heard this something affects the ability of proxy servers to download styles/scripts.
2017/09/15
[ "https://Stackoverflow.com/questions/46233259", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7504461/" ]
From your edit, it sounds like you are just trying to sum the *values* of all the sub-dicts, by the parent dict: ``` In [9]: counts = Counter() In [10]: for dd in data: ...: for k,v in dd.items(): ...: counts[k] += sum(v.values()) ...: In [11]: counts Out[11]: Counter({'25-34': 30, '45-54': 1...
For your first questions, here's a one-liner. It's not really pretty but it does use `Counter`: ``` sum((Counter({k:v['Clicks'] for k,v in d.items()}) for d in data), Counter()) ``` As an example : ``` data = [ { "25-34": { "Clicks": 10 }, "45-54": { "Clicks": 2 }, }, { "25-34...
46,233,259
Is it ok to use additional url query params to prevent cahing or force update css/js? ``` /style.css?v=1 ``` Or it will be better to change name of file/dir? ``` /style.1.css ``` I heard this something affects the ability of proxy servers to download styles/scripts.
2017/09/15
[ "https://Stackoverflow.com/questions/46233259", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7504461/" ]
From your edit, it sounds like you are just trying to sum the *values* of all the sub-dicts, by the parent dict: ``` In [9]: counts = Counter() In [10]: for dd in data: ...: for k,v in dd.items(): ...: counts[k] += sum(v.values()) ...: In [11]: counts Out[11]: Counter({'25-34': 30, '45-54': 1...
My variation without list comprehensions: ``` def my_dict_sum(data): """ >>> test_data = [{"25-34": {"Clicks": 10, "Visits": 1}, "45-54": {"Clicks": 2, "Visits": 2}, },{"25-34": {"Clicks": 20, "Visits": 3}, "45-54": {"Clicks": 10, "Visits": 4}, }] >>> my_dict_sum(test_data) {'45-54': {'Clicks': 12, 'Visits': 6}, '25-3...
46,233,259
Is it ok to use additional url query params to prevent cahing or force update css/js? ``` /style.css?v=1 ``` Or it will be better to change name of file/dir? ``` /style.1.css ``` I heard this something affects the ability of proxy servers to download styles/scripts.
2017/09/15
[ "https://Stackoverflow.com/questions/46233259", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7504461/" ]
From your edit, it sounds like you are just trying to sum the *values* of all the sub-dicts, by the parent dict: ``` In [9]: counts = Counter() In [10]: for dd in data: ...: for k,v in dd.items(): ...: counts[k] += sum(v.values()) ...: In [11]: counts Out[11]: Counter({'25-34': 30, '45-54': 1...
I did like this: ``` with gzip.open("data/small_fasta.fa.gz", "rt") as handle: aac_count = defaultdict(Counter) for record in SeqIO.parse(handle, "fasta"): aac_count[record.id].update(record.seq) ``` I used biopython for open the fasta file (<https://pt.wikipedia.org/wiki/Formato_FASTA>) that are the...
46,233,259
Is it ok to use additional url query params to prevent cahing or force update css/js? ``` /style.css?v=1 ``` Or it will be better to change name of file/dir? ``` /style.1.css ``` I heard this something affects the ability of proxy servers to download styles/scripts.
2017/09/15
[ "https://Stackoverflow.com/questions/46233259", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7504461/" ]
My variation without list comprehensions: ``` def my_dict_sum(data): """ >>> test_data = [{"25-34": {"Clicks": 10, "Visits": 1}, "45-54": {"Clicks": 2, "Visits": 2}, },{"25-34": {"Clicks": 20, "Visits": 3}, "45-54": {"Clicks": 10, "Visits": 4}, }] >>> my_dict_sum(test_data) {'45-54': {'Clicks': 12, 'Visits': 6}, '25-3...
For your first questions, here's a one-liner. It's not really pretty but it does use `Counter`: ``` sum((Counter({k:v['Clicks'] for k,v in d.items()}) for d in data), Counter()) ``` As an example : ``` data = [ { "25-34": { "Clicks": 10 }, "45-54": { "Clicks": 2 }, }, { "25-34...
46,233,259
Is it ok to use additional url query params to prevent cahing or force update css/js? ``` /style.css?v=1 ``` Or it will be better to change name of file/dir? ``` /style.1.css ``` I heard this something affects the ability of proxy servers to download styles/scripts.
2017/09/15
[ "https://Stackoverflow.com/questions/46233259", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7504461/" ]
My variation without list comprehensions: ``` def my_dict_sum(data): """ >>> test_data = [{"25-34": {"Clicks": 10, "Visits": 1}, "45-54": {"Clicks": 2, "Visits": 2}, },{"25-34": {"Clicks": 20, "Visits": 3}, "45-54": {"Clicks": 10, "Visits": 4}, }] >>> my_dict_sum(test_data) {'45-54': {'Clicks': 12, 'Visits': 6}, '25-3...
I did like this: ``` with gzip.open("data/small_fasta.fa.gz", "rt") as handle: aac_count = defaultdict(Counter) for record in SeqIO.parse(handle, "fasta"): aac_count[record.id].update(record.seq) ``` I used biopython for open the fasta file (<https://pt.wikipedia.org/wiki/Formato_FASTA>) that are the...
49,701,730
I want to run official example (<http://propelml.org/>), but browser console warns: > > `plot: no output handler.` > > > ``` <html lang="en"> <head> <meta charset="UTF-8"> <title>Hello, propel!</title> <script src="https://unpkg.com/propel@3.3.1"></script> </head> <body> <script> const { grad, linspac...
2018/04/06
[ "https://Stackoverflow.com/questions/49701730", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9325131/" ]
Remove the blank line before `<?php` at the beginning of the `check_address.php` script.
``` jQuery.ajax({ url :url, type : 'post', data : data, success : function (data) { // location.reload(); if (data != 'passed') { jQuery('#payment_errors').html(data); } if (data == 'passed') { // alert('passed'); //clear errors ...
14,121,150
I have two different applications deployed in Tomcat server. The purpose of one application is to call another application which processes data using rule engines. Basically, it calls a static method of another application through reflection. This works perfectly fine in Jboss. But now for some reason, I need to depl...
2013/01/02
[ "https://Stackoverflow.com/questions/14121150", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1942669/" ]
I think you're relying on the classloading structure of each app server. The classloader structure/hierarchy is configurable, but generally the 2 apps will occupy different classloaders, and using reflection across classloaders could well be problematic. Why are you using reflection to communicate between these apps ?...
I doubt the cause of this problem is reflection, but the [classloader hierarchy](http://tomcat.apache.org/tomcat-6.0-doc/class-loader-howto.html). One webapp should **not** call methods of another, this is a major design flaw.
42,169,488
This is my first Stack Overflow question so please bear with me. I have read [this](https://stackoverflow.com/questions/33225947/can-a-website-detect-when-you-are-using-selenium-with-chromedriver/41904453#41904453) SO question, which lead me to wondering, is it possible to make chromedriver completely undetectable? ...
2017/02/10
[ "https://Stackoverflow.com/questions/42169488", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7003958/" ]
In order to use ChromeDriver undetectable to Distil checkpoints (which are described nicely in this [stackoverflow post](https://stackoverflow.com/questions/33225947/can-a-website-detect-when-you-are-using-selenium-with-chromedriver)), you will need to ensure that your browser does not contain any variable in its windo...
You can't use Selenium's WebDriver itself to change UserAgent, which sounds like what you're really trying to do here. However, that doesn't mean it can't be changed. *Enter PhantomJS.* Check out [this answer](https://stackoverflow.com/a/41678604/2172566). You can use that to disguise Selenium as a different browser...
22,630,864
I have n number of text box (n may be any number) with same name. And I want to access the value of all the text box of that name. Ex-: ``` <form method="post" id="create"> <input type="text" name="user[]" /> <input type="text" name="user[]" /> <input type="text" name="user[]" /> <input type="button" id="newFieldBtn"...
2014/03/25
[ "https://Stackoverflow.com/questions/22630864", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2428406/" ]
``` <script> jQuery(document).ready(function($) { $('#newFieldBtn').click(function(){ var count = document.getElementById('count').value; count++; var code = '<input type="text" name="user'+count+'" />'; jQuery('#create').append(code); document.getElementById('count').value ...
Try this one, it will show you the values : ``` <form action="#" method="post"> <input type="text" name="user[]" /> <input type="text" name="user[]" /> <input type="text" name="user[]" /> <input type="submit" value="submit" > </form> <?php if ($_SERVER['REQUEST_METHOD'] == 'POST') { foreach($_POST['user'] as $key =...
38,019,530
I'm new to coding so sorry if this seems like an obvious question. When using bootstrap 1) can I have more than 1 container? if so how do I go about styling them separately if they both have to be called container ? Thanks!
2016/06/24
[ "https://Stackoverflow.com/questions/38019530", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6509775/" ]
Yes, you can have as many `container` or `container-fluid` as needed. Add a custom CSS class to the containers to stylize.. ``` <div class="container-fluid">...</div> <div class="container-fluid someclass">...</div> .someclass { background-color:#eee; } ``` <http://www.codeply.com/go/8vDhaX4kKV>
The Bootstrap website says this > > Easily center a page's contents by wrapping its contents in a .container. Containers set width at various media query breakpoints to match our grid system. > > > Note that, due to padding and fixed widths, containers are not nestable by default. > > > You can have multiple co...
57,118,151
I have an optimization problem modelled and written in IBM ILOG CPLEX Optimization Studio. I want to call .mod and .dat from Java. I found some example to do it. However, I got some error. My code is shown below. I also added all cplex and opl library ``` package cplexJava; import ilog.concert.*; import ilog.cplex....
2019/07/19
[ "https://Stackoverflow.com/questions/57118151", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8947626/" ]
Actually your IDE tells you what the problem is: There are possible IloExceptions thrown and you do not handle them. You need to either surround your code with a try catch block, or your main-method should have a "throws IloException" in the signature: ``` package cplexJava; import ilog.concert.*; import ilog.cplex.*;...
For the OPL Java API, you should only need [oplall.jar](https://www.ibm.com/support/knowledgecenter/SSSA5P_12.9.0/ilog.odms.ide.help/OPL_Studio/usroplinterfaces/topics/opl_interf_intro_java_deploy.html). **SETUP** On my x86-64 Linux machine with Eclipse 3.6, this is done, like so (hopefully it's similar for you): 1....
57,118,151
I have an optimization problem modelled and written in IBM ILOG CPLEX Optimization Studio. I want to call .mod and .dat from Java. I found some example to do it. However, I got some error. My code is shown below. I also added all cplex and opl library ``` package cplexJava; import ilog.concert.*; import ilog.cplex....
2019/07/19
[ "https://Stackoverflow.com/questions/57118151", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8947626/" ]
Actually your IDE tells you what the problem is: There are possible IloExceptions thrown and you do not handle them. You need to either surround your code with a try catch block, or your main-method should have a "throws IloException" in the signature: ``` package cplexJava; import ilog.concert.*; import ilog.cplex.*;...
I also faced the the same problem. After some trial and error I realized that the correct name is `DYLD_LIBRARY_PATH` for macos. [Referral link](https://www.ibm.com/support/knowledgecenter/SSSA5P_12.8.0/ilog.odms.ide.help/OPL_Studio/working_environment/topics/opl_working_env_variables_unix.html)
29,932,896
Hi I have been trying to add a button into my program that when you click the button it displays text in a label, waits so the user can read it, then exits the program. but if I run it and try it it only waits then exits without displaying text. sorry if that was a bad explanation I just got into coding. This is what I...
2015/04/29
[ "https://Stackoverflow.com/questions/29932896", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4844345/" ]
Call `label1.Invalidate()` to force the control to be redrawn. When you call `Thread.Sleep`, the UI thread will be blocked and not update. If this doesn't work, try `label1.Refresh()` or `Application.DoEvents();` ``` private void button3_Click(object sender, EventArgs e) { label1.Text = "Text Here"; label1.In...
Instead of using `Thread.Sleep` which blocks the UI thread (and keeps it from updating with your text), its better to keep the UI responsive. This will keep the UI working and delay then close the application. ``` private void button3_Click(object sender, EventArgs e) { label1.Text = "Text Here"; Task.Delay(50...
49,770,331
I'm building a Shiny App in R and I'm trying to scrub off the web information about the user's selected Pokemon, but I keep running into the problem of 'Error: SLL certificate problem' when trying to use read\_html() ui: ```html sidebarPanel( ui <- fluidPage( selectInput(inputId = "pokemon1",...
2018/04/11
[ "https://Stackoverflow.com/questions/49770331", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9626728/" ]
You are looking for `id=False`. Use this: ``` for ul in content_container.find_all('ul', id=False): for li in ul.find_all('li'): list.append(li.text) print(li.text) ``` This will ignore all tags that have `id` as an attribute. Also, your approach was nearly correct. You just need to check whether...
try this ``` all_uls = content_container.find_all('ul') #assuming that the ul with id is the first ul for i in range(1, len(all_uls)): print(all_uls[i]) ```
2,695,990
How to test website compatibility for iPAD without having iPAD , in both condition Portrait and landscape? on Windows PC -------------
2010/04/23
[ "https://Stackoverflow.com/questions/2695990", "https://Stackoverflow.com", "https://Stackoverflow.com/users/84201/" ]
You'll probably have to use a windows browser to fake the browser-agent header. [This page](http://www.jeffdepascale.com/index.php/general/why-the-ipads-user-agent-string-presents-a-problem/) gives more information as well as the browser agent string. You could use [Chris Pederick's User Agent Switcher](http://chrispe...
also, there is another web-site: <http://ipadpeek.com/> but, if you have a special css file for ipad, this site cannot show it. you should change your main css file with ipad specific one... also, you can rotate your ipad in ipadpeek.com edit: there is an app for looking your layout on ios device [here](http://think...
8,217,938
How can I set a default url/server for all my requests from collections and models in Backbone? Example collection: ``` define([ 'backbone', '../models/communityModel' ], function(Backbone, CommunityModel){ return Backbone.Collection.extend({ url: '/communities', // localhost/communities should be...
2011/11/21
[ "https://Stackoverflow.com/questions/8217938", "https://Stackoverflow.com", "https://Stackoverflow.com/users/824850/" ]
your url takes a string or a function. with your settings ajax call you can store it in a proper location, and go fetch that from the function to use your example: suppose your ajax call, saved the url in a `myApp.Settings.DefaultURL` ``` define([ 'backbone', '../models/communityModel' ], function(Backbone, ...
By over-riding (but not *over-writing*) the `Backbone.sync` method you can achieve the same result without having to add the same code to every single model/collection. ``` define(['underscore', 'backbone', 'myApp'], function (_, Backbone, myApp) { 'use strict'; // Store the original version of Backbone.sync ...
45,590,040
In my project I find timezones by id. Here is an example: ``` (GMT+07:00) Indian, Christmas ``` How can I make it look like this: ``` Indian\Christmas ``` with regular expression?
2017/08/09
[ "https://Stackoverflow.com/questions/45590040", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8282497/" ]
You picked up the logic for set intersection and union but you didn't convert the input into the representation they use the logic on. You can't directly act on the input string. You need to operate on a bit map. Following logic can help you get a bitmap from a string. ``` uint8_t Bitmap1[256] = {0}; uint8_t Bitmap2...
``` un += (source[i] || cible[i]); // allways true you can replace it with un++ in += (source[i] && cible[i]); // allways true you can replace it with in++ ``` In the C every value != 0 is true and zero if the false. So the `source[i] || cible[i]` is always true as source[i] and cible[i] is allways != 0 s...
4,823,785
writing another program, it reads a txt file, and stores all the letter characters and spaces (as \0) in a char array, and ignores everything else. this part works. now what i need it to do is read a user inputted string, and search for that string in the array, then print the word every time it appears. im terrible a...
2011/01/28
[ "https://Stackoverflow.com/questions/4823785", "https://Stackoverflow.com", "https://Stackoverflow.com/users/593034/" ]
``` #include <stdio.h> ... char str [80]; printf ("Enter your word: "); scanf ("%s",str); char* pch=strstr(fileData,str); while (pch!=NULL) { printf ("found at %d\n",pch-fileData+1); pch=strstr(pch+1,str); } ```
1. read in the user inputted string as a char array as well (cause strings are basically char\* anyway in C) 2. use a string matching algorithm like Boyer-Moore or Knutt-Morris-Pratt (more popularly known as KMP) - google for it if you like for C implementations of these - cause they're neat, tried and tested ways of s...
4,823,785
writing another program, it reads a txt file, and stores all the letter characters and spaces (as \0) in a char array, and ignores everything else. this part works. now what i need it to do is read a user inputted string, and search for that string in the array, then print the word every time it appears. im terrible a...
2011/01/28
[ "https://Stackoverflow.com/questions/4823785", "https://Stackoverflow.com", "https://Stackoverflow.com/users/593034/" ]
``` #include <stdio.h> ... char str [80]; printf ("Enter your word: "); scanf ("%s",str); char* pch=strstr(fileData,str); while (pch!=NULL) { printf ("found at %d\n",pch-fileData+1); pch=strstr(pch+1,str); } ```
One for-loop inside another for-loop (called nested loop). Go through all the letters in your array, and for each letter go through all the letters in your input string and find out if that part of the array matches with the input string. If it does, print it.
67,972,601
I would like to edit the model matrix used by predict.lm() in R to predict main effects but not interactions (but using the coefficients and variance from the full model containing interactions). I have tried: ``` data(npk) #example data mod <- lm(yield ~ N*P*K, data=npk, x=T) #run model newmat <- mod$x # acquire mod...
2021/06/14
[ "https://Stackoverflow.com/questions/67972601", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8569109/" ]
TL;DR; ------ The reason this is happening is because **the aggregate is a scalar aggregate.** --- There are two types of aggregates: ---------------------------------- * **Vector aggregates** + Needs a `GROUP BY` clause + Returns no rows at all if the input has no rows * **Scalar aggregates** + No `GROUP BY` ...
> > Does anyone know why that is? > > > Because the query you are APPLYing returns a row whether or not there any matching rows, since it's an aggregate query.
67,972,601
I would like to edit the model matrix used by predict.lm() in R to predict main effects but not interactions (but using the coefficients and variance from the full model containing interactions). I have tried: ``` data(npk) #example data mod <- lm(yield ~ N*P*K, data=npk, x=T) #run model newmat <- mod$x # acquire mod...
2021/06/14
[ "https://Stackoverflow.com/questions/67972601", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8569109/" ]
TL;DR; ------ The reason this is happening is because **the aggregate is a scalar aggregate.** --- There are two types of aggregates: ---------------------------------- * **Vector aggregates** + Needs a `GROUP BY` clause + Returns no rows at all if the input has no rows * **Scalar aggregates** + No `GROUP BY` ...
It seems like you think that an aggregate returns no rows when there are no applicable rows. This isn't true if there is no `GROUP BY` clause. Take the following nonsense query: ```sql SELECT COUNT(*) AS C, SUM(object_ID) AS S, MAX(object_ID) AS M FROM sys.tables WHERE [name]= N'sdfhjklsdgfgjklb807ty3480...
2,821,233
How to compute $\sum\_n (2n - \sqrt{n^2+1}-\sqrt{n^2-1})$? I tried two ways: **1.** \begin{align\*} (2n - \sqrt{n^2+1}-\sqrt{n^2-1}) &= n - \sqrt{n^2+1} + n -\sqrt{n^2-1} \\ &= \frac{1}{n+\sqrt{n^2-1}}-\frac{1}{n-\sqrt{n^2+1}}, \end{align\*} but I don't know how to do later. **2.** \begin{align\*} (2n - \sqrt{n^2+1}-...
2018/06/16
[ "https://math.stackexchange.com/questions/2821233", "https://math.stackexchange.com", "https://math.stackexchange.com/users/377743/" ]
Starting with Sangchul Lee's integral representation (which is a consequence of the Laplace transform) $$ S = \int\_{0}^{+\infty}\frac{I\_1(x)-J\_1(x)}{x(e^x-1)}\,dx = \frac{1}{\pi}\int\_{0}^{+\infty}\int\_{0}^{\pi}\frac{e^{-x\cos\theta}-e^{ix\cos\theta}}{e^x-1}\sin^2\theta\,d\theta\,dx \tag{1}$$ and applying Fubini's ...
Let us assume that you need to compute the infinite summation with $$a\_n=2n - \sqrt{n^2+1}-\sqrt{n^2-1}$$ For large values of $n$, rewrite $$a\_n=n\left(2- \sqrt{1+\frac 1{n^2}}- \sqrt{1-\frac 1{n^2}}\right)$$ and use the binomial expansion or Taylor series to get $$a\_n=\frac{1}{4 n^3}+\frac{5}{64 n^7}+O\left(\frac{1...
51,508,046
I want to run an long running operation in Android. Say the task would run for about 5-10 mins. For this reason I am planning to use a `JobIntentService` and Bind it to an `Activity`. Right now I am using a `AsyncTask`, even though I know `AsyncTask` cannot/should not be used for long running operations hence I am pla...
2018/07/24
[ "https://Stackoverflow.com/questions/51508046", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9155610/" ]
If your `Activity` is in the background then blocking Android from killing your `Activity` doesn't sound like a good idea (and even necessary) to me. Since your `Activity` is in the background it's not visible to the user and there's no need to update the UI during this time. Instead, you could do the following: If ...
No it won't if you BIND the service and manage the binding (through ServiceConnection) in the "OnResume" Lifecycle Method and then you UNBIND the service on the "OnPause" Lifecycle Method. ( Never tryed but I think this will work. Also if you override the return of the OnBind method in a JobIntentService you need to ca...
52,247,213
I'm getting a vague syntax error with the print int(rollval) on line 15. ``` from random import randint roll == 0 def diceroll(roll): def dicenum(userdicenum): userdicenum = int(raw_input("How many dice would you like to roll?")) return userdicenum def dicesides(userdiceside): userdice...
2018/09/09
[ "https://Stackoverflow.com/questions/52247213", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10338692/" ]
``` from random import randint def diceroll(): def dicenum(): userdicenum = int(input("How many dice would you like to roll?")) return userdicenum def dicesides(): userdiceside = int(input("How many sides for each die?")) return userdiceside roll = 0 dicesida = diceside...
One difference between Python3 and Python2 is that in Python3, the print statement is a function in Python3, but a keyword in Python2. The fact that it is a function means that you have to use it like any other function, which is by putting the arguments within parenthesis. Use `print(int(rollval))` You should also h...
7,354,227
I'm writing a service using Microsoft.NET framework 3.5 and I would like to send some status messages/notify on error without using the event log, a log file or by email. Any tips on how I can achieve this/possible/wise?
2011/09/08
[ "https://Stackoverflow.com/questions/7354227", "https://Stackoverflow.com", "https://Stackoverflow.com/users/57731/" ]
Have you thought about [Log4Net](http://logging.apache.org/log4net/) ? It can send email, or store entries on the database, or send messages remotely. Have a look at the options it provides.
You could log the errors into a database or event log, throw together a UI to read the DB/log, then fire off a text message whenever an error occurs. If your text recipients' cell providers offer the feature, sending a text is as simple as sending an e-mail. For example, to send a text to a Verizon phone, just e-mail...
10,568,952
So there are plenty of questions asking how to keep child events from triggering parent events, but I can't seem to find any for the opposite. I toggle a parent event on and off like so: ``` var body_event = function(e){ console.log('test'); }; $('#btn').toggle( function(e){ $('body').bind('click', b...
2012/05/13
[ "https://Stackoverflow.com/questions/10568952", "https://Stackoverflow.com", "https://Stackoverflow.com/users/441935/" ]
This is close, but not quite there. It doesn't check whether the specific function is bound, just whether there are any events bound to the jQuery object. There must be a way to query the events to find if one is bound to click, and then subsequently what function it points too. Hopefully this gets you started though....
event.stopPropagation() can solve this problem, inside body\_event?
20,384,338
The application I'm working on is an internal business application for managers. It's a C# web application. The main office has an instance of this app running and it always has the latest version. Each store has it's own instance of the application running as well, but may not always have the latest version. A manager...
2013/12/04
[ "https://Stackoverflow.com/questions/20384338", "https://Stackoverflow.com", "https://Stackoverflow.com/users/629412/" ]
If you are loading the partial with ajax on the client side explicitly, you can just add a complete function to call: ``` $( "#storeContainer" ).load( "url/for/partial", function () { if ($('.version').length !== 0) { if (parseFloat($('.version').text().slice(5)) > 1.7) { $('.analysis').show(); } else ...
Have you tried using ``` $(document).on("ready", function() { }); ``` in place of $window.load()?
4,662,553
Naturally, `BeginReceive()` will never end if there's no data. MSDN [suggests](http://msdn.microsoft.com/en-us/library/dxkwh6zw.aspx) that calling `Close()` would abort `BeginReceive()`. However, calling `Close()` on the socket also performs a `Dispose()` on it, as figured out in [this great answer](https://stackoverf...
2011/01/11
[ "https://Stackoverflow.com/questions/4662553", "https://Stackoverflow.com", "https://Stackoverflow.com/users/324922/" ]
It seems like this is by (the very dumb) design. You must have this exception thrown and caught in your code. MSDN looks silent about it indeed, but if you look at the documentation of another asynchronous socket method, [BeginConnect()](http://msdn.microsoft.com/en-us/library/tad07yt6.aspx), here's what we find: > ...
For TCP socket connections, you can use the [Connected](https://learn.microsoft.com/en-us/dotnet/api/system.net.sockets.socket.connected?f1url=https%3A%2F%2Fmsdn.microsoft.com%2Fquery%2Fdev15.query%3FappId%3DDev15IDEF1%26l%3DEN-US%26k%3Dk(System.Net.Sockets.Socket.Connected);k(TargetFrameworkMoniker-.NETFramework,Versi...
4,662,553
Naturally, `BeginReceive()` will never end if there's no data. MSDN [suggests](http://msdn.microsoft.com/en-us/library/dxkwh6zw.aspx) that calling `Close()` would abort `BeginReceive()`. However, calling `Close()` on the socket also performs a `Dispose()` on it, as figured out in [this great answer](https://stackoverf...
2011/01/11
[ "https://Stackoverflow.com/questions/4662553", "https://Stackoverflow.com", "https://Stackoverflow.com/users/324922/" ]
I am surprised no one recommended using SocketOptions. Once the stack has the send or receive operation it is bound by the socket options of the socket. Use a small send or receive timeout and use it before the operation so you don't care if it's changed during that same operation to something shorter or longer. T...
For TCP socket connections, you can use the [Connected](https://learn.microsoft.com/en-us/dotnet/api/system.net.sockets.socket.connected?f1url=https%3A%2F%2Fmsdn.microsoft.com%2Fquery%2Fdev15.query%3FappId%3DDev15IDEF1%26l%3DEN-US%26k%3Dk(System.Net.Sockets.Socket.Connected);k(TargetFrameworkMoniker-.NETFramework,Versi...
4,662,553
Naturally, `BeginReceive()` will never end if there's no data. MSDN [suggests](http://msdn.microsoft.com/en-us/library/dxkwh6zw.aspx) that calling `Close()` would abort `BeginReceive()`. However, calling `Close()` on the socket also performs a `Dispose()` on it, as figured out in [this great answer](https://stackoverf...
2011/01/11
[ "https://Stackoverflow.com/questions/4662553", "https://Stackoverflow.com", "https://Stackoverflow.com/users/324922/" ]
In the ReceiveCallback I checked client.Connected within the try block. Now, when data is received after BeginReceive, I can call client.Close(); This way, I do not see exceptions. I send modbus-TCP requests every 200mS, and get responses in time. The console output looks clean. I used a windows forms app, to test this...
I was struggling with this as well but as far as I can tell using a simple boolean flag before calling `.BeginReceive()` will work as well (so there'll be no need for exception handling). Since I already had start/stop handling, this fix was a matter of one `if` statement (scroll down to the bottom of the `OnReceive()`...
4,662,553
Naturally, `BeginReceive()` will never end if there's no data. MSDN [suggests](http://msdn.microsoft.com/en-us/library/dxkwh6zw.aspx) that calling `Close()` would abort `BeginReceive()`. However, calling `Close()` on the socket also performs a `Dispose()` on it, as figured out in [this great answer](https://stackoverf...
2011/01/11
[ "https://Stackoverflow.com/questions/4662553", "https://Stackoverflow.com", "https://Stackoverflow.com/users/324922/" ]
You can read my solution of this problem here(using comment of Pavel Radzivilovsky here): [UdpClient.ReceiveAsync correct early termination](https://stackoverflow.com/questions/41019997/udpclient-receiveasync-correct-early-termination/41041601?noredirect=1#comment69291144_41041601)
I was struggling with this as well but as far as I can tell using a simple boolean flag before calling `.BeginReceive()` will work as well (so there'll be no need for exception handling). Since I already had start/stop handling, this fix was a matter of one `if` statement (scroll down to the bottom of the `OnReceive()`...
4,662,553
Naturally, `BeginReceive()` will never end if there's no data. MSDN [suggests](http://msdn.microsoft.com/en-us/library/dxkwh6zw.aspx) that calling `Close()` would abort `BeginReceive()`. However, calling `Close()` on the socket also performs a `Dispose()` on it, as figured out in [this great answer](https://stackoverf...
2011/01/11
[ "https://Stackoverflow.com/questions/4662553", "https://Stackoverflow.com", "https://Stackoverflow.com/users/324922/" ]
It seems like this is by (the very dumb) design. You must have this exception thrown and caught in your code. MSDN looks silent about it indeed, but if you look at the documentation of another asynchronous socket method, [BeginConnect()](http://msdn.microsoft.com/en-us/library/tad07yt6.aspx), here's what we find: > ...
Another solution would be to send "yourself" a "control message" using a socket bound to a different port. It's not exactly an abort, but it would end your async operation.
4,662,553
Naturally, `BeginReceive()` will never end if there's no data. MSDN [suggests](http://msdn.microsoft.com/en-us/library/dxkwh6zw.aspx) that calling `Close()` would abort `BeginReceive()`. However, calling `Close()` on the socket also performs a `Dispose()` on it, as figured out in [this great answer](https://stackoverf...
2011/01/11
[ "https://Stackoverflow.com/questions/4662553", "https://Stackoverflow.com", "https://Stackoverflow.com/users/324922/" ]
I am surprised no one recommended using SocketOptions. Once the stack has the send or receive operation it is bound by the socket options of the socket. Use a small send or receive timeout and use it before the operation so you don't care if it's changed during that same operation to something shorter or longer. T...
You can read my solution of this problem here(using comment of Pavel Radzivilovsky here): [UdpClient.ReceiveAsync correct early termination](https://stackoverflow.com/questions/41019997/udpclient-receiveasync-correct-early-termination/41041601?noredirect=1#comment69291144_41041601)
4,662,553
Naturally, `BeginReceive()` will never end if there's no data. MSDN [suggests](http://msdn.microsoft.com/en-us/library/dxkwh6zw.aspx) that calling `Close()` would abort `BeginReceive()`. However, calling `Close()` on the socket also performs a `Dispose()` on it, as figured out in [this great answer](https://stackoverf...
2011/01/11
[ "https://Stackoverflow.com/questions/4662553", "https://Stackoverflow.com", "https://Stackoverflow.com/users/324922/" ]
In the ReceiveCallback I checked client.Connected within the try block. Now, when data is received after BeginReceive, I can call client.Close(); This way, I do not see exceptions. I send modbus-TCP requests every 200mS, and get responses in time. The console output looks clean. I used a windows forms app, to test this...
Another solution would be to send "yourself" a "control message" using a socket bound to a different port. It's not exactly an abort, but it would end your async operation.
4,662,553
Naturally, `BeginReceive()` will never end if there's no data. MSDN [suggests](http://msdn.microsoft.com/en-us/library/dxkwh6zw.aspx) that calling `Close()` would abort `BeginReceive()`. However, calling `Close()` on the socket also performs a `Dispose()` on it, as figured out in [this great answer](https://stackoverf...
2011/01/11
[ "https://Stackoverflow.com/questions/4662553", "https://Stackoverflow.com", "https://Stackoverflow.com/users/324922/" ]
It seems like this is by (the very dumb) design. You must have this exception thrown and caught in your code. MSDN looks silent about it indeed, but if you look at the documentation of another asynchronous socket method, [BeginConnect()](http://msdn.microsoft.com/en-us/library/tad07yt6.aspx), here's what we find: > ...
I was struggling with this as well but as far as I can tell using a simple boolean flag before calling `.BeginReceive()` will work as well (so there'll be no need for exception handling). Since I already had start/stop handling, this fix was a matter of one `if` statement (scroll down to the bottom of the `OnReceive()`...
4,662,553
Naturally, `BeginReceive()` will never end if there's no data. MSDN [suggests](http://msdn.microsoft.com/en-us/library/dxkwh6zw.aspx) that calling `Close()` would abort `BeginReceive()`. However, calling `Close()` on the socket also performs a `Dispose()` on it, as figured out in [this great answer](https://stackoverf...
2011/01/11
[ "https://Stackoverflow.com/questions/4662553", "https://Stackoverflow.com", "https://Stackoverflow.com/users/324922/" ]
You can read my solution of this problem here(using comment of Pavel Radzivilovsky here): [UdpClient.ReceiveAsync correct early termination](https://stackoverflow.com/questions/41019997/udpclient-receiveasync-correct-early-termination/41041601?noredirect=1#comment69291144_41041601)
Another solution would be to send "yourself" a "control message" using a socket bound to a different port. It's not exactly an abort, but it would end your async operation.
4,662,553
Naturally, `BeginReceive()` will never end if there's no data. MSDN [suggests](http://msdn.microsoft.com/en-us/library/dxkwh6zw.aspx) that calling `Close()` would abort `BeginReceive()`. However, calling `Close()` on the socket also performs a `Dispose()` on it, as figured out in [this great answer](https://stackoverf...
2011/01/11
[ "https://Stackoverflow.com/questions/4662553", "https://Stackoverflow.com", "https://Stackoverflow.com/users/324922/" ]
I am surprised no one recommended using SocketOptions. Once the stack has the send or receive operation it is bound by the socket options of the socket. Use a small send or receive timeout and use it before the operation so you don't care if it's changed during that same operation to something shorter or longer. T...
Another solution would be to send "yourself" a "control message" using a socket bound to a different port. It's not exactly an abort, but it would end your async operation.
19,179,635
i have a form on which controls are assigned ![enter image description here](https://i.stack.imgur.com/bxWr1.png) and this is the code when i clicked insert button ``` private void btnInsertRArtist_Click(object sender, EventArgs e) { SqlCommand comand = new SqlCommand("InsertRecordingArtists", conect); ...
2013/10/04
[ "https://Stackoverflow.com/questions/19179635", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2702357/" ]
You can't use `DateTimePicker` instance as a query parameter. Use `DateTimePicker.Value` instead: ``` comand.Parameters.AddWithValue("@DateOfBirth", dateTimePicker1.Value); ```
Change your ``` comand.Parameters.AddWithValue("@DateOfBirth", dateTimePicker1); ``` to ``` comand.Parameters.AddWithValue("@DateOfBirth", dateTimePicker1.Text); ``` What you do is you can't add a `DateTimePicker` instance as a parameter. `AddWithValue` method takes string as a second parameter. Use [`Value`](ht...
19,179,635
i have a form on which controls are assigned ![enter image description here](https://i.stack.imgur.com/bxWr1.png) and this is the code when i clicked insert button ``` private void btnInsertRArtist_Click(object sender, EventArgs e) { SqlCommand comand = new SqlCommand("InsertRecordingArtists", conect); ...
2013/10/04
[ "https://Stackoverflow.com/questions/19179635", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2702357/" ]
You can't use `DateTimePicker` instance as a query parameter. Use `DateTimePicker.Value` instead: ``` comand.Parameters.AddWithValue("@DateOfBirth", dateTimePicker1.Value); ```
dateTimePicker1 is a control not a DateTime value. U need to get the DateTime value from: ``` comand.Parameters.AddWithValue("@DateOfBirth", dateTimePicker1.Value.ToString()); ```
19,179,635
i have a form on which controls are assigned ![enter image description here](https://i.stack.imgur.com/bxWr1.png) and this is the code when i clicked insert button ``` private void btnInsertRArtist_Click(object sender, EventArgs e) { SqlCommand comand = new SqlCommand("InsertRecordingArtists", conect); ...
2013/10/04
[ "https://Stackoverflow.com/questions/19179635", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2702357/" ]
You can't use `DateTimePicker` instance as a query parameter. Use `DateTimePicker.Value` instead: ``` comand.Parameters.AddWithValue("@DateOfBirth", dateTimePicker1.Value); ```
You need the value of `dateTimePicker1`, you should change: ``` command.Parameters.AddWithValue("@DateOfBirth", dateTimePicker1); ``` to ``` command.Parameters.AddWithValue("@DateOfBirth", dateTimePicker1.Value); ```
19,179,635
i have a form on which controls are assigned ![enter image description here](https://i.stack.imgur.com/bxWr1.png) and this is the code when i clicked insert button ``` private void btnInsertRArtist_Click(object sender, EventArgs e) { SqlCommand comand = new SqlCommand("InsertRecordingArtists", conect); ...
2013/10/04
[ "https://Stackoverflow.com/questions/19179635", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2702357/" ]
You can't use `DateTimePicker` instance as a query parameter. Use `DateTimePicker.Value` instead: ``` comand.Parameters.AddWithValue("@DateOfBirth", dateTimePicker1.Value); ```
What Dennis said is correct. Additionally you probably want to show an error message if it doesnt work. eg: ``` private void btnInsertRArtist_Click(object sender, EventArgs e) { SqlCommand comand = new SqlCommand("InsertRecordingArtists", conect); comand.CommandType = CommandType.StoredProcedure; ...
19,179,635
i have a form on which controls are assigned ![enter image description here](https://i.stack.imgur.com/bxWr1.png) and this is the code when i clicked insert button ``` private void btnInsertRArtist_Click(object sender, EventArgs e) { SqlCommand comand = new SqlCommand("InsertRecordingArtists", conect); ...
2013/10/04
[ "https://Stackoverflow.com/questions/19179635", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2702357/" ]
Change your ``` comand.Parameters.AddWithValue("@DateOfBirth", dateTimePicker1); ``` to ``` comand.Parameters.AddWithValue("@DateOfBirth", dateTimePicker1.Text); ``` What you do is you can't add a `DateTimePicker` instance as a parameter. `AddWithValue` method takes string as a second parameter. Use [`Value`](ht...
dateTimePicker1 is a control not a DateTime value. U need to get the DateTime value from: ``` comand.Parameters.AddWithValue("@DateOfBirth", dateTimePicker1.Value.ToString()); ```
19,179,635
i have a form on which controls are assigned ![enter image description here](https://i.stack.imgur.com/bxWr1.png) and this is the code when i clicked insert button ``` private void btnInsertRArtist_Click(object sender, EventArgs e) { SqlCommand comand = new SqlCommand("InsertRecordingArtists", conect); ...
2013/10/04
[ "https://Stackoverflow.com/questions/19179635", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2702357/" ]
Change your ``` comand.Parameters.AddWithValue("@DateOfBirth", dateTimePicker1); ``` to ``` comand.Parameters.AddWithValue("@DateOfBirth", dateTimePicker1.Text); ``` What you do is you can't add a `DateTimePicker` instance as a parameter. `AddWithValue` method takes string as a second parameter. Use [`Value`](ht...
You need the value of `dateTimePicker1`, you should change: ``` command.Parameters.AddWithValue("@DateOfBirth", dateTimePicker1); ``` to ``` command.Parameters.AddWithValue("@DateOfBirth", dateTimePicker1.Value); ```
19,179,635
i have a form on which controls are assigned ![enter image description here](https://i.stack.imgur.com/bxWr1.png) and this is the code when i clicked insert button ``` private void btnInsertRArtist_Click(object sender, EventArgs e) { SqlCommand comand = new SqlCommand("InsertRecordingArtists", conect); ...
2013/10/04
[ "https://Stackoverflow.com/questions/19179635", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2702357/" ]
Change your ``` comand.Parameters.AddWithValue("@DateOfBirth", dateTimePicker1); ``` to ``` comand.Parameters.AddWithValue("@DateOfBirth", dateTimePicker1.Text); ``` What you do is you can't add a `DateTimePicker` instance as a parameter. `AddWithValue` method takes string as a second parameter. Use [`Value`](ht...
What Dennis said is correct. Additionally you probably want to show an error message if it doesnt work. eg: ``` private void btnInsertRArtist_Click(object sender, EventArgs e) { SqlCommand comand = new SqlCommand("InsertRecordingArtists", conect); comand.CommandType = CommandType.StoredProcedure; ...
50,753,645
I am facing the following situation: I own a domain name, let's say example.com at name.com We have a website hosted at bluehost on a shared hosting with an IP1 We have an ERP (odoo) hosted at digitalocean on a droplet where Nginx is running and where IP2 is allocated. The erp is accesible via IP2:port\_number I am tr...
2018/06/08
[ "https://Stackoverflow.com/questions/50753645", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5594353/" ]
To keep it very short. `ngOnInit()` is used to execute any piece of code for only one time (for eg : data fetch on load). `ngOnChanges()` will execute on every `@Input()` property change. If you want to execute any component method, based on the `@Input()` value change, then you should write such logic inside `ngOnC...
ngOnChanges() is called whenever input bound properties of its component changes, it receives an object called SimpleChanges which contains changed and previous property. ngOnInit() is used to initialize things in a component,unlike ngOnChanges() it is called only once and after first ngOnChanges().
50,753,645
I am facing the following situation: I own a domain name, let's say example.com at name.com We have a website hosted at bluehost on a shared hosting with an IP1 We have an ERP (odoo) hosted at digitalocean on a droplet where Nginx is running and where IP2 is allocated. The erp is accesible via IP2:port\_number I am tr...
2018/06/08
[ "https://Stackoverflow.com/questions/50753645", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5594353/" ]
To keep it very short. `ngOnInit()` is used to execute any piece of code for only one time (for eg : data fetch on load). `ngOnChanges()` will execute on every `@Input()` property change. If you want to execute any component method, based on the `@Input()` value change, then you should write such logic inside `ngOnC...
ngOnChanges will be called first on the life cycle hook when there is a change to the component inputs through the parent. ngOnInit will be called only once on initializing the component after the first ngOnChanges called.
50,753,645
I am facing the following situation: I own a domain name, let's say example.com at name.com We have a website hosted at bluehost on a shared hosting with an IP1 We have an ERP (odoo) hosted at digitalocean on a droplet where Nginx is running and where IP2 is allocated. The erp is accesible via IP2:port\_number I am tr...
2018/06/08
[ "https://Stackoverflow.com/questions/50753645", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5594353/" ]
How a form need be setup **0. Static design** Html markup should hold how the design is structured and laid out. Any permanent classes are to be applied directly in markup. **1. Constructor** Setup dependencies, like services, providers, configuration etc. These enable the component to manage itself along with inter...
To keep it very short. `ngOnInit()` is used to execute any piece of code for only one time (for eg : data fetch on load). `ngOnChanges()` will execute on every `@Input()` property change. If you want to execute any component method, based on the `@Input()` value change, then you should write such logic inside `ngOnC...
50,753,645
I am facing the following situation: I own a domain name, let's say example.com at name.com We have a website hosted at bluehost on a shared hosting with an IP1 We have an ERP (odoo) hosted at digitalocean on a droplet where Nginx is running and where IP2 is allocated. The erp is accesible via IP2:port\_number I am tr...
2018/06/08
[ "https://Stackoverflow.com/questions/50753645", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5594353/" ]
To keep it very short. `ngOnInit()` is used to execute any piece of code for only one time (for eg : data fetch on load). `ngOnChanges()` will execute on every `@Input()` property change. If you want to execute any component method, based on the `@Input()` value change, then you should write such logic inside `ngOnC...
ngOnInit and ngOnChanges are functions belonging to a component life-cycle method groups and they are executed in a different moment of our component (that's why name life-cycle). Here is a list of all of them: [![enter image description here](https://i.stack.imgur.com/JwzQ4.png)](https://i.stack.imgur.com/JwzQ4.png)