qid int64 1 74.7M | question stringlengths 15 58.3k | date stringlengths 10 10 | metadata list | response_j stringlengths 4 30.2k | response_k stringlengths 11 36.5k |
|---|---|---|---|---|---|
46,010,817 | I have entities:
```
package datamodel.serviceone;
@Entity(name = "user")
public class Human{
```
and
```
package datamodel.servicetwo;
@Entity(name = "user")
public class Robot{
```
I have repository:
```
@Repository
public interface HumanRepository extends CrudRepository<Human, Long> {
Human findOneBySex(S... | 2017/09/02 | [
"https://Stackoverflow.com/questions/46010817",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5620472/"
] | You should use the `@Table` annotation. The problem is that you register two entities with the same name instead to bind them to same tables.
```
@Entity
@Table(name = "user")
public class Human
```
And then:
```
@Entity
@Table(name = "user")
public class Robot
``` | You are using same table for two different classes, it will get mixed up. How hibernate knows that user table is of human or robot.
Also both classes can have different properties.
Either create two different table or create a super class of `User` and extend `Human` and `Robot` classes from it. Put common attributes ... |
57,682,009 | If I'm implementing a for loop to shift elements to the right between two indices in an array it would take me O(n) to shift those elements, but instead what if I used library function like `std::rotate` that would be executed in one step, so does that means that it took constant time.
like this example
```
vector<... | 2019/08/27 | [
"https://Stackoverflow.com/questions/57682009",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7644243/"
] | `std::rotate` has linear complexity, so while it might be marginally faster or slower than your code, the two use approximately the same number of steps to do the job.
In this particular case, its likely that `std::rotate` actually uses more steps, because it's coded to handle rotation by an arbitrary number of places... | No, it does takes linear time.Actual time complexity is the difference between initial and final node .Check out
<https://en.cppreference.com/w/cpp/algorithm/rotate> |
47,643,487 | I have geoJson map regions rendered on a map with an initial opacity. I have a slider to change that opacity on the fly.
Here is the bit where I set the opacity on the fly (typescript), which I perform on the input change event within my custom leaflet control:
```
this.layers.forEach((r: L.GeoJSON<any>) => {
... | 2017/12/04 | [
"https://Stackoverflow.com/questions/47643487",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3295746/"
] | The [`resetStyle`](http://leafletjs.com/reference.html#geojson-resetstyle) method of a Leaflet GeoJSON Layer Group re-applies the [`style`](http://leafletjs.com/reference.html#geojson-style) that was applied at the time of creation of that group, or the default one if you did not provide style:
>
> Resets the given v... | Use [`L.Util.setOptions`](http://leafletjs.com/reference-1.2.0.html#util-setoptions)
so instead of
```
layer.setStyle({ fillOpacity: vm.mapOptions.heatmapOpacity });
```
use
```
L.Util.setOptions(layer, { style: { fillOpacity: vm.mapOptions.heatmapOpacity } });
``` |
20,254,488 | I'm in the process of learning Java and can't help but wonder how exactly Java passes function parameters and return values. I've done some search and found that Java only passes Objects by value. However, some people challenge this; they claim that when handling Complex Data Types (not Primitive like e.g. `int`) it on... | 2013/11/27 | [
"https://Stackoverflow.com/questions/20254488",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2037562/"
] | The key is to understand that Java passes **everything by value**. And this is also true for objects: *It passes **the pointers by values**.* So, it does not create a copy of the object, but of the reference.
The same goes for returning. So, yes, your thinking is right: you can modify the attributes (called class memb... | >
> I've done some search and found that Java only passes Objects by
> value.
>
>
>
There is your confusion. You cannot "pass objects" in Java, because objects are not values in Java. The only types in Java are primitive types and reference types (references are pointers to objects). So the only values you can ma... |
51,840,877 | I am looking for a way to determine with JavaScript / jQuery if the WooCommerce store notice is displayed. The HTML for the store notice looks like this...
```
<p class="woocommerce-store-notice demo_store" style="display: block;">
This is a store notice
</p>
```
I have tried to do this using the following...
`... | 2018/08/14 | [
"https://Stackoverflow.com/questions/51840877",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/779681/"
] | The element is removed when the store notice is disabled. The CSS `display` property is not available hence `undefined`. Try the below code
```
jQuery(document).ready(function(){
if ( jQuery('.woocommerce-store-notice').css('display') == undefined) {
console.log('Store Notice Hidden');
} else {
... | Check with
```
if(jQuery('.woocommerce-store-notice').is(':visible')){
}
else{
}
``` |
51,840,877 | I am looking for a way to determine with JavaScript / jQuery if the WooCommerce store notice is displayed. The HTML for the store notice looks like this...
```
<p class="woocommerce-store-notice demo_store" style="display: block;">
This is a store notice
</p>
```
I have tried to do this using the following...
`... | 2018/08/14 | [
"https://Stackoverflow.com/questions/51840877",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/779681/"
] | The element is removed when the store notice is disabled. The CSS `display` property is not available hence `undefined`. Try the below code
```
jQuery(document).ready(function(){
if ( jQuery('.woocommerce-store-notice').css('display') == undefined) {
console.log('Store Notice Hidden');
} else {
... | you can find what you are looking for here:
<http://api.jquery.com/visible-selector/>
Btw => [JQuery: if div is visible](https://stackoverflow.com/questions/40468981/jquery-if-div-is-visible) |
6,407,367 | Is it possible to use the Logging Application Block of the Enterprise Library (version 5.0) to write log entries to a custom table in SQL Server ?
(edit) changed to 'custom table' because we want to report on specific log-columns... | 2011/06/20 | [
"https://Stackoverflow.com/questions/6407367",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/72760/"
] | I'm assuming you mean that you want to write log entries from your .NET code to a SQL Server database in order to centralize your log store.
If that is the case, then you can definitely do that. See [Logging to a Database](http://msdn.microsoft.com/en-us/library/ff664543%28v=PandP.50%29.aspx) for more information. | The answer is yes :)
Same Link as Anders: <http://msdn.microsoft.com/en-us/library/ff664569(v=pandp.50).aspx>
SQL Server == Database |
2,208,219 | I have a model which have a function to calculate the difference between two fields
Example:
```
Class MyModel(models.Model):
fieldA = models.FloatField()
fieldB = models.FloatField()
def delta(self):
return self.fieldA - self.fieldB
```
Id like to use this model in a GenericView. I can use the ... | 2010/02/05 | [
"https://Stackoverflow.com/questions/2208219",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/138070/"
] | One way to do this is to create a Manager and defines a function with the raw SQL query. Create the model object attaching the new calculated field referencing to the model class with self.model
```
Class MyModel(models.Model):
fieldA = models.FloatField()
fieldB = models.FloatField()
objects = MyModelMan... | ```
Class MyModel(models.Model):
fieldA = models.FloatField()
fieldB = models.FloatField()
@property
def delta(self):
return self.fieldA - self.fieldB
```
Now, you can use delta as a attribute in admin panel or your DRF serializer or ... |
2,208,219 | I have a model which have a function to calculate the difference between two fields
Example:
```
Class MyModel(models.Model):
fieldA = models.FloatField()
fieldB = models.FloatField()
def delta(self):
return self.fieldA - self.fieldB
```
Id like to use this model in a GenericView. I can use the ... | 2010/02/05 | [
"https://Stackoverflow.com/questions/2208219",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/138070/"
] | For what you want just add a new method to the model and do the aggregation on the DB then just calculate the difference between the two sums. Like this:
```
class MyModel(models.Model):
fielda = ...
fieldb = ...
def delta(self):
return self.fielda-fieldb
def aggregate_delta(self):
retu... | Ok, first your code should have the selfs, since you want to calculate the delta of each line.
```
def delta(self):
return self.fieldA - self.fieldB
```
Regarding your question, it is not possible to aggregate from a django function. There are three ways of achieving what you want:
1. Do the aggregation in Pyth... |
2,208,219 | I have a model which have a function to calculate the difference between two fields
Example:
```
Class MyModel(models.Model):
fieldA = models.FloatField()
fieldB = models.FloatField()
def delta(self):
return self.fieldA - self.fieldB
```
Id like to use this model in a GenericView. I can use the ... | 2010/02/05 | [
"https://Stackoverflow.com/questions/2208219",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/138070/"
] | One way to do this is to create a Manager and defines a function with the raw SQL query. Create the model object attaching the new calculated field referencing to the model class with self.model
```
Class MyModel(models.Model):
fieldA = models.FloatField()
fieldB = models.FloatField()
objects = MyModelMan... | For what you want just add a new method to the model and do the aggregation on the DB then just calculate the difference between the two sums. Like this:
```
class MyModel(models.Model):
fielda = ...
fieldb = ...
def delta(self):
return self.fielda-fieldb
def aggregate_delta(self):
retu... |
2,208,219 | I have a model which have a function to calculate the difference between two fields
Example:
```
Class MyModel(models.Model):
fieldA = models.FloatField()
fieldB = models.FloatField()
def delta(self):
return self.fieldA - self.fieldB
```
Id like to use this model in a GenericView. I can use the ... | 2010/02/05 | [
"https://Stackoverflow.com/questions/2208219",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/138070/"
] | For what you want just add a new method to the model and do the aggregation on the DB then just calculate the difference between the two sums. Like this:
```
class MyModel(models.Model):
fielda = ...
fieldb = ...
def delta(self):
return self.fielda-fieldb
def aggregate_delta(self):
retu... | How could this work? Aggregation is done in the database, but your calculation is obviously in Python.
You'll have to do the sum in Python as well:
```
aggregated_delta = sum([m.delta() for m in MyModel.objects.all()])
``` |
2,208,219 | I have a model which have a function to calculate the difference between two fields
Example:
```
Class MyModel(models.Model):
fieldA = models.FloatField()
fieldB = models.FloatField()
def delta(self):
return self.fieldA - self.fieldB
```
Id like to use this model in a GenericView. I can use the ... | 2010/02/05 | [
"https://Stackoverflow.com/questions/2208219",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/138070/"
] | One way to do this is to create a Manager and defines a function with the raw SQL query. Create the model object attaching the new calculated field referencing to the model class with self.model
```
Class MyModel(models.Model):
fieldA = models.FloatField()
fieldB = models.FloatField()
objects = MyModelMan... | Ok, first your code should have the selfs, since you want to calculate the delta of each line.
```
def delta(self):
return self.fieldA - self.fieldB
```
Regarding your question, it is not possible to aggregate from a django function. There are three ways of achieving what you want:
1. Do the aggregation in Pyth... |
2,208,219 | I have a model which have a function to calculate the difference between two fields
Example:
```
Class MyModel(models.Model):
fieldA = models.FloatField()
fieldB = models.FloatField()
def delta(self):
return self.fieldA - self.fieldB
```
Id like to use this model in a GenericView. I can use the ... | 2010/02/05 | [
"https://Stackoverflow.com/questions/2208219",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/138070/"
] | ```
Class MyModel(models.Model):
fieldA = models.FloatField()
fieldB = models.FloatField()
@property
def delta(self):
return self.fieldA - self.fieldB
```
Now, you can use delta as a attribute in admin panel or your DRF serializer or ... | How could this work? Aggregation is done in the database, but your calculation is obviously in Python.
You'll have to do the sum in Python as well:
```
aggregated_delta = sum([m.delta() for m in MyModel.objects.all()])
``` |
2,208,219 | I have a model which have a function to calculate the difference between two fields
Example:
```
Class MyModel(models.Model):
fieldA = models.FloatField()
fieldB = models.FloatField()
def delta(self):
return self.fieldA - self.fieldB
```
Id like to use this model in a GenericView. I can use the ... | 2010/02/05 | [
"https://Stackoverflow.com/questions/2208219",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/138070/"
] | One way to do this is to create a Manager and defines a function with the raw SQL query. Create the model object attaching the new calculated field referencing to the model class with self.model
```
Class MyModel(models.Model):
fieldA = models.FloatField()
fieldB = models.FloatField()
objects = MyModelMan... | How could this work? Aggregation is done in the database, but your calculation is obviously in Python.
You'll have to do the sum in Python as well:
```
aggregated_delta = sum([m.delta() for m in MyModel.objects.all()])
``` |
2,208,219 | I have a model which have a function to calculate the difference between two fields
Example:
```
Class MyModel(models.Model):
fieldA = models.FloatField()
fieldB = models.FloatField()
def delta(self):
return self.fieldA - self.fieldB
```
Id like to use this model in a GenericView. I can use the ... | 2010/02/05 | [
"https://Stackoverflow.com/questions/2208219",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/138070/"
] | Did you try that?
```
Class MyModel(models.Model):
fieldA = models.FloatField()
fieldB = models.FloatField()
def __delta(self):
return self.fieldA - self.fieldB
delta = property(__delta)
``` | ```
Class MyModel(models.Model):
fieldA = models.FloatField()
fieldB = models.FloatField()
@property
def delta(self):
return self.fieldA - self.fieldB
```
Now, you can use delta as a attribute in admin panel or your DRF serializer or ... |
2,208,219 | I have a model which have a function to calculate the difference between two fields
Example:
```
Class MyModel(models.Model):
fieldA = models.FloatField()
fieldB = models.FloatField()
def delta(self):
return self.fieldA - self.fieldB
```
Id like to use this model in a GenericView. I can use the ... | 2010/02/05 | [
"https://Stackoverflow.com/questions/2208219",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/138070/"
] | Did you try that?
```
Class MyModel(models.Model):
fieldA = models.FloatField()
fieldB = models.FloatField()
def __delta(self):
return self.fieldA - self.fieldB
delta = property(__delta)
``` | Ok, first your code should have the selfs, since you want to calculate the delta of each line.
```
def delta(self):
return self.fieldA - self.fieldB
```
Regarding your question, it is not possible to aggregate from a django function. There are three ways of achieving what you want:
1. Do the aggregation in Pyth... |
2,208,219 | I have a model which have a function to calculate the difference between two fields
Example:
```
Class MyModel(models.Model):
fieldA = models.FloatField()
fieldB = models.FloatField()
def delta(self):
return self.fieldA - self.fieldB
```
Id like to use this model in a GenericView. I can use the ... | 2010/02/05 | [
"https://Stackoverflow.com/questions/2208219",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/138070/"
] | Did you try that?
```
Class MyModel(models.Model):
fieldA = models.FloatField()
fieldB = models.FloatField()
def __delta(self):
return self.fieldA - self.fieldB
delta = property(__delta)
``` | How could this work? Aggregation is done in the database, but your calculation is obviously in Python.
You'll have to do the sum in Python as well:
```
aggregated_delta = sum([m.delta() for m in MyModel.objects.all()])
``` |
33,002,386 | I am trying to run the simple word count program below in Eclipse and i am getting a error .I have checked my configurations in Run As and they are correct
```
Error: Main method not found in class wordcount.WordCount, please define the main method as:
public static void main(String[] args)
or a JavaFX application ... | 2015/10/07 | [
"https://Stackoverflow.com/questions/33002386",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4713216/"
] | What worked for me was to open the offending .png(s) in Photoshop, do "Save to Web" (under File) and overwriting the original file. | This issue because of build tools try change it from gradle
may be this help
```
compileSdkVersion 23
buildToolsVersion '23.0.0'
defaultConfig {
minSdkVersion 16
targetSdkVersion 23
}
```
**UPDATE ANSWER**
this happen with me cause I was include PSD file into my android studio |
13,842,745 | >
> **Possible Duplicate:**
>
> [How to develop or migrate apps for iPhone 5 screen resolution?](https://stackoverflow.com/questions/12395200/how-to-develop-or-migrate-apps-for-iphone-5-screen-resolution)
>
>
>
Although I am using iphone6 simulator, my simulator size is same as the iPhone 4, But I want to test... | 2012/12/12 | [
"https://Stackoverflow.com/questions/13842745",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1821383/"
] | You just need to go to hardware and select iPhone 4in Retina.
 | In the simulator, go to the menu "Hardware" > "Device" and select "iPhone (Retina 4-inch)" |
13,842,745 | >
> **Possible Duplicate:**
>
> [How to develop or migrate apps for iPhone 5 screen resolution?](https://stackoverflow.com/questions/12395200/how-to-develop-or-migrate-apps-for-iphone-5-screen-resolution)
>
>
>
Although I am using iphone6 simulator, my simulator size is same as the iPhone 4, But I want to test... | 2012/12/12 | [
"https://Stackoverflow.com/questions/13842745",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1821383/"
] | In the simulator, go to the menu "Hardware" > "Device" and select "iPhone (Retina 4-inch)" | In Xcode, *iPhone 6.0 Simulator* means an iPhone Simulator with iOS 6.0. Start the simulator, and go to the *Hardware* menu, choose *iPhone (Retina 4-inch)* to run in an iPhone 5 (with iOS 6.0) simulator. |
13,842,745 | >
> **Possible Duplicate:**
>
> [How to develop or migrate apps for iPhone 5 screen resolution?](https://stackoverflow.com/questions/12395200/how-to-develop-or-migrate-apps-for-iphone-5-screen-resolution)
>
>
>
Although I am using iphone6 simulator, my simulator size is same as the iPhone 4, But I want to test... | 2012/12/12 | [
"https://Stackoverflow.com/questions/13842745",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1821383/"
] | You just need to go to hardware and select iPhone 4in Retina.
 | In Xcode, *iPhone 6.0 Simulator* means an iPhone Simulator with iOS 6.0. Start the simulator, and go to the *Hardware* menu, choose *iPhone (Retina 4-inch)* to run in an iPhone 5 (with iOS 6.0) simulator. |
16,553 | Attempting to solve a practice problem, not sure if I'm heading in the right direction since my solution seems pretty messy. Given the following utility function,
$u(x,y)=min\{x^{1/2},2y\}$, find the Marshallian demands.
My answer:
Since Leontief is perfect complements, must be the case that $x^{1/2}=2y$, substituti... | 2017/04/29 | [
"https://economics.stackexchange.com/questions/16553",
"https://economics.stackexchange.com",
"https://economics.stackexchange.com/users/10957/"
] | Yes, Smith addresses these issues in [Book 1 Chapter 10 of *The Wealth of Nations*](http://www.econlib.org/library/Smith/smWN4.html). Firstly, he notes that where two jobs are in almost every respect equivalent, we should expect them to pay the same wage:
>
> "THE whole of the advantages and disadvantages of the diff... | I have thought about this issue as well. But through self-interest, don't you think that most people want the best for themselves and therefore, nobody would be willing to be a factory worker in this case?
If everybody strives for the best for themselves (i.e. all are trying to be CEO), the free market then puts upwar... |
56,700,827 | In `Node.js` I'm using `stream-chain` and `stream-json` to request streaming feeds from local and remote resources. Below works for local resources, but how to modify it, to allow also for external resources? Do I need to download the file first or?
```
const fs = require('fs');
const { chain } = r... | 2019/06/21 | [
"https://Stackoverflow.com/questions/56700827",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/488074/"
] | The question boils down to having a readable stream through network and processing it on run time.
I don't think this is going to work, and, finally you have to download the file only, and process as local file.
There are ways to get the file from network:
```
var remotePath = "https://....."
https.get(remotePath, r... | I think you need to download the file and process manually. You can use `request()` function to get online file. But i agree with `Suryapratap`. but you can also write to a file and read from same file and continue with your program. example
```
request("https://reqres.in/api/users",(err, res, body)=>{
if(... |
56,757,664 | I am looking at way to delegate contributor / owner permissions to resource groups lifecycle based on name pattern of the group. I am having trouble finding the proper approach.
In custom role definition, there does not seem to be an easy way to assign Actions to resource type based on name pattern, while in azure poli... | 2019/06/25 | [
"https://Stackoverflow.com/questions/56757664",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/223326/"
] | Pattern matching should accomplish the same goal with a fraction of the complexity and overhead. In my personal experience this is the best way to implement a visitor pattern in F#.
```
type Visitor = A of int | B of int
match a with
| A x -> 1 * x
| B x -> 2 * x
```
then for some possible C#
```
private static ... | If you really need to use OO patterns for C# interop, I believe the best way to decouple the types is to use generics:
```
module VisitorPattern =
type IVisitor<'T> =
abstract Visit : 'T -> unit
type IVisitable<'T> =
abstract InvokeVisit : IVisitor<'T> -> unit
module Visitors =
open Vis... |
4,055,941 | I have a SVN project at work that looks like this:
**Repository**
```
project
|-- docs
|-- scripts
`-- app
|-- trunk
|-- branches
| `-- development
`-- tags
|-- Release_1.0
|-- ...
`-- Release_5.3
```
I want my working folder like th... | 2010/10/29 | [
"https://Stackoverflow.com/questions/4055941",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/404863/"
] | From the error it looks like each of the folders under `dir_root` was checkout separately. Thus `dir_root` itself does not correspond to `project` folder in SVN.
You could start by checking out `project` with `--depth immediates` into `dir_root`. This will create a folder structure similar to the one in SVN in your `d... | Creating a dir with svn:externals with the structure you have mentioned will solve your problem. |
16,992,893 | I'm quite new to Stack Overflow and am still learning programming. I would like to put two tables side-by-side with equal spacing and prevent the tables from touching the sides of the page. I wrote this code, but am not getting the right result:
```
<table style="float:right; background-color: white;font-family: cursi... | 2013/06/07 | [
"https://Stackoverflow.com/questions/16992893",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2462467/"
] | Welcome!
1. Move your styles into a .css file first of all.
2. I put together a little demo, [check it out](http://jsbin.com/epiqiz/1/edit) - don't mind the table:nth-child(2n) selectors, those could also be class names. | You should use CSS3 for this task. Do NOT use frames (they, in essence, been deprecated). You should do a search for this. I found a good start on THIS site:
[Div side by side](https://stackoverflow.com/questions/6449521/div-side-by-side)
Good luck. |
16,992,893 | I'm quite new to Stack Overflow and am still learning programming. I would like to put two tables side-by-side with equal spacing and prevent the tables from touching the sides of the page. I wrote this code, but am not getting the right result:
```
<table style="float:right; background-color: white;font-family: cursi... | 2013/06/07 | [
"https://Stackoverflow.com/questions/16992893",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2462467/"
] | Welcome!
1. Move your styles into a .css file first of all.
2. I put together a little demo, [check it out](http://jsbin.com/epiqiz/1/edit) - don't mind the table:nth-child(2n) selectors, those could also be class names. | Set the two tables inside a container div with some `padding: 0 XXpx;` where XX is the amount of spacing that you want. For the tables to float properly, the width of this div must be at least 842px (the size of both floated tables plus the border of the first one). |
72,666,212 | I am new to angular.
I have list of people. Each div has people name and send request button. when send request button is clicked, the button becomes invisible and 'tick' button becomes visible.
I can access this feature in angularjs using 'this'.
```html
<div class="item">
<div class="imgNameDiv">
<... | 2022/06/18 | [
"https://Stackoverflow.com/questions/72666212",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11129951/"
] | In general, I recommend against trying to use `&&` and `||` to replace `if ... then ... else` blocks. `if` statements have clear and straightforward semantics, but combinations of `&&` and `||` often interact in unexpected and hard-to-understand ways.
Take `[[ $? -ne 0 ]] && echo "Add User failed" && exit 1`. The prob... | If I make some common-sense guesses about what you're trying to do, I arrive at:
```
([[ $? -ne 0 ]] && echo "Add User failed") || echo "User added successfully"
``` |
72,666,212 | I am new to angular.
I have list of people. Each div has people name and send request button. when send request button is clicked, the button becomes invisible and 'tick' button becomes visible.
I can access this feature in angularjs using 'this'.
```html
<div class="item">
<div class="imgNameDiv">
<... | 2022/06/18 | [
"https://Stackoverflow.com/questions/72666212",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11129951/"
] | In general, I recommend against trying to use `&&` and `||` to replace `if ... then ... else` blocks. `if` statements have clear and straightforward semantics, but combinations of `&&` and `||` often interact in unexpected and hard-to-understand ways.
Take `[[ $? -ne 0 ]] && echo "Add User failed" && exit 1`. The prob... | It is common in Bash programs to use a "die" function to print an error message and exit the program. See [BashFAQ/101 - Common utility functions (warn, die)](https://mywiki.wooledge.org/BashFAQ/101). (There's also [In bash, is there an equivalent of die "error msg"](https://stackoverflow.com/q/7868818/4154375), but al... |
53,194,676 | I want to use `qSort()` as follows.
I have a compare function called
```
bool CStreamSetup::compareNames(const QString &s1, const QString &s2)
{
QString temp1 = s1.section("Stream", 1);
temp1 = temp1.section('_', 0, 0);
QString temp2 = s2.section("Stream", 1);
temp2 = temp2.section('_', 0, 0);
... | 2018/11/07 | [
"https://Stackoverflow.com/questions/53194676",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6838856/"
] | You could keep an object in your state instead of a boolean, that has a key indicating if the object with that particular key as index is hovered or not.
**Example**
```js
class App extends React.Component {
state = {
arr: [{ text: "foo" }, { text: "bar" }],
isHovered: {}
};
handleMouseEnter = ind... | Create a property isHovered on item of an array dynamically and onMouseHover pass the item which you get in .map, now toggle the isHovered property. Should work now. |
63,414,490 | I'm converting my project to Typescript.
This has always worked for me in JS.
```
/* ##################### */
/* #### REDUX STORE #### */
/* ##################### */
const store = createStore(rootReducer, {
// INITIAL STATE GOES HERE
},window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__());
... | 2020/08/14 | [
"https://Stackoverflow.com/questions/63414490",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10128619/"
] | I think the problem resides here:
>
> mail.models.User.MultipleObjectsReturned: get() returned more than one User -- it returned 2!
>
>
>
It expects one resource, but gets two. I would look at the controller that calls this method.
Update
------
In Django the get() method expects one resource, but in this case ... | I think you can add `{ return false; }` at the end of the code snippet.
This prevents the default submission of the form which involves either reloading the current page or redirecting to a new one. |
663,559 | I'm trying to use this tool
<https://swingexplorer.dev.java.net/>
to find some information out about an applet's swing structure. Unfortunately, I didn't develop the applet. I've pulled the jars for the applet from the cache, but there are several hundred .class files in the jars, and I don't know which one has the m... | 2009/03/19 | [
"https://Stackoverflow.com/questions/663559",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34410/"
] | The lifecycle of an [Applet](http://docs.oracle.com/javase/6/docs/api/java/applet/Applet.html) (or [JApplet](http://docs.oracle.com/javase/6/docs/api/javax/swing/JApplet.html)) is more complicated than *start and run until the program is finished* so there is no single `main` method. It will be managed by the browser (... | The entry class will either be in the applet tag, or JNLP for new plugin JRE 6u10+ applets. You should be able to see which one it is from the jar alone by grepping for referecnes to the Applet or JApplet classes or, say, the init()V method. |
663,559 | I'm trying to use this tool
<https://swingexplorer.dev.java.net/>
to find some information out about an applet's swing structure. Unfortunately, I didn't develop the applet. I've pulled the jars for the applet from the cache, but there are several hundred .class files in the jars, and I don't know which one has the m... | 2009/03/19 | [
"https://Stackoverflow.com/questions/663559",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34410/"
] | The entry class will either be in the applet tag, or JNLP for new plugin JRE 6u10+ applets. You should be able to see which one it is from the jar alone by grepping for referecnes to the Applet or JApplet classes or, say, the init()V method. | I was trying to use the wrong tool for the task. |
663,559 | I'm trying to use this tool
<https://swingexplorer.dev.java.net/>
to find some information out about an applet's swing structure. Unfortunately, I didn't develop the applet. I've pulled the jars for the applet from the cache, but there are several hundred .class files in the jars, and I don't know which one has the m... | 2009/03/19 | [
"https://Stackoverflow.com/questions/663559",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34410/"
] | The lifecycle of an [Applet](http://docs.oracle.com/javase/6/docs/api/java/applet/Applet.html) (or [JApplet](http://docs.oracle.com/javase/6/docs/api/javax/swing/JApplet.html)) is more complicated than *start and run until the program is finished* so there is no single `main` method. It will be managed by the browser (... | I was trying to use the wrong tool for the task. |
280 | The Workplace is naturally attractive to soft questions, and soft questions, more often than not, attract a lot of answers. That's good, but after a point answers start becoming horribly repetitive, adding very little, if anything, to the discussion. It's a problem we've identified before, on various Meta discussions:
... | 2012/05/30 | [
"https://workplace.meta.stackexchange.com/questions/280",
"https://workplace.meta.stackexchange.com",
"https://workplace.meta.stackexchange.com/users/48/"
] | To be blunt, our current tools for dealing with bad answers are terrible.
We have downvotes but no one uses them, and one upvote erases 5 downvotes in rep. We have post notices (citation needed, ect) but they're mod only and we can't *practically* apply a "citation needed" post notice every time a totally unsupported... | To pick one example, it seems harsh to me that the person who wrote the top answer for [How can I overcome "years of experience" requirements when applying to positions?](https://workplace.stackexchange.com/questions/1478/how-can-i-overcome-years-of-experience-requirements-when-applying-to-positions) (which seems to be... |
280 | The Workplace is naturally attractive to soft questions, and soft questions, more often than not, attract a lot of answers. That's good, but after a point answers start becoming horribly repetitive, adding very little, if anything, to the discussion. It's a problem we've identified before, on various Meta discussions:
... | 2012/05/30 | [
"https://workplace.meta.stackexchange.com/questions/280",
"https://workplace.meta.stackexchange.com",
"https://workplace.meta.stackexchange.com/users/48/"
] | After [the discussion here](https://meta.stackexchange.com/questions/164080/why-can-only-moderators-protect-questions-less-than-1-day-old) brought this back to mind, I've dropped the threshold to 15.
10 seems *dangerously* low to me, in the range where it starts to be ripe for abuse, and unnecessarily stressful to mo... | To be blunt, our current tools for dealing with bad answers are terrible.
We have downvotes but no one uses them, and one upvote erases 5 downvotes in rep. We have post notices (citation needed, ect) but they're mod only and we can't *practically* apply a "citation needed" post notice every time a totally unsupported... |
280 | The Workplace is naturally attractive to soft questions, and soft questions, more often than not, attract a lot of answers. That's good, but after a point answers start becoming horribly repetitive, adding very little, if anything, to the discussion. It's a problem we've identified before, on various Meta discussions:
... | 2012/05/30 | [
"https://workplace.meta.stackexchange.com/questions/280",
"https://workplace.meta.stackexchange.com",
"https://workplace.meta.stackexchange.com/users/48/"
] | After [the discussion here](https://meta.stackexchange.com/questions/164080/why-can-only-moderators-protect-questions-less-than-1-day-old) brought this back to mind, I've dropped the threshold to 15.
10 seems *dangerously* low to me, in the range where it starts to be ripe for abuse, and unnecessarily stressful to mo... | To pick one example, it seems harsh to me that the person who wrote the top answer for [How can I overcome "years of experience" requirements when applying to positions?](https://workplace.stackexchange.com/questions/1478/how-can-i-overcome-years-of-experience-requirements-when-applying-to-positions) (which seems to be... |
3,593,722 | I made a push to a newly forked git repo on **Github** but after committing i noticed that my username was incorrect. The username I pushed was "Brock Woolf" but it should have been `brockwoolf` which is my username on github.
I already changed the default locally like this:
```
git config --global user.name "brockwo... | 2010/08/29 | [
"https://Stackoverflow.com/questions/3593722",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40002/"
] | The already pushed change, if people have pulled it, is something you'll have to live with. If no one's pulled it (i.e. you realize your mistake right after pushing), you can amend your commit:
```
git commit --amend
```
Make sure you don't add any new changes to the commit - don't use `-a`, don't use `git add` firs... | Sweet I figured it out:
```
git commit -a --amend
git pull
git push
```
Feel free to answer, if you have a better way I'll mark yours correct. |
3,593,722 | I made a push to a newly forked git repo on **Github** but after committing i noticed that my username was incorrect. The username I pushed was "Brock Woolf" but it should have been `brockwoolf` which is my username on github.
I already changed the default locally like this:
```
git config --global user.name "brockwo... | 2010/08/29 | [
"https://Stackoverflow.com/questions/3593722",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40002/"
] | As noted [here](https://stackoverflow.com/a/3042512/1411004), you can do
```
git commit --amend --author="Author Name <email@address.com>"
git push -f
``` | Sweet I figured it out:
```
git commit -a --amend
git pull
git push
```
Feel free to answer, if you have a better way I'll mark yours correct. |
3,593,722 | I made a push to a newly forked git repo on **Github** but after committing i noticed that my username was incorrect. The username I pushed was "Brock Woolf" but it should have been `brockwoolf` which is my username on github.
I already changed the default locally like this:
```
git config --global user.name "brockwo... | 2010/08/29 | [
"https://Stackoverflow.com/questions/3593722",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40002/"
] | The already pushed change, if people have pulled it, is something you'll have to live with. If no one's pulled it (i.e. you realize your mistake right after pushing), you can amend your commit:
```
git commit --amend
```
Make sure you don't add any new changes to the commit - don't use `-a`, don't use `git add` firs... | As noted [here](https://stackoverflow.com/a/3042512/1411004), you can do
```
git commit --amend --author="Author Name <email@address.com>"
git push -f
``` |
14,393,205 | I need a regex which can validate a **user input** like this:
```
Jr. //Valid
Jr //Valid
Junior //Valid
Jr.. // Invalid (1 or more periods)
.Jr // Invalid
```
Rules:
Alphanumeric characters and only 1 period at the end is allowed.
So Strings like test and test. should be valid as well.
Thanks! | 2013/01/18 | [
"https://Stackoverflow.com/questions/14393205",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1483119/"
] | Try this regex. It matches one or more alphanumeric characters followed by an optional `.`.
```
^[A-Za-z0-9]+\.?$
```
If you want to match sequence containing any character except `.` followed by an optional `.`, use
```
^[^.]+\.?$
``` | ```
/\b(Jr\.?|Junior|\Sr.?|Senior)\b/
``` |
14,393,205 | I need a regex which can validate a **user input** like this:
```
Jr. //Valid
Jr //Valid
Junior //Valid
Jr.. // Invalid (1 or more periods)
.Jr // Invalid
```
Rules:
Alphanumeric characters and only 1 period at the end is allowed.
So Strings like test and test. should be valid as well.
Thanks! | 2013/01/18 | [
"https://Stackoverflow.com/questions/14393205",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1483119/"
] | Try this regex. It matches one or more alphanumeric characters followed by an optional `.`.
```
^[A-Za-z0-9]+\.?$
```
If you want to match sequence containing any character except `.` followed by an optional `.`, use
```
^[^.]+\.?$
``` | You can try this:
`^(Jr\.?|Junior)$` |
25,580 | If I have a creature with 4/4 double strike, does it kill each blocking creature with toughness 4 or less due to first strike? | 2015/08/12 | [
"https://boardgames.stackexchange.com/questions/25580",
"https://boardgames.stackexchange.com",
"https://boardgames.stackexchange.com/users/13076/"
] | Creatures always deal damage equal to their power. Creatures with double strike do this twice.
Specifically, a creature with double strike deals damage equal to its power once during the first strike damage step, and once during the regular combat damage step. Creatures with first strike deal damage just once during t... | Your 4/4 creature will deal 4 damage, and then it will deal 4 damage again.
If you attack with a 4/4 creature that has double strike, and it gets blocked by two regular 4/4 creatures, the following will happen:
1. First Combat Damage Step
1. Your attacker deals a total of 4 damage to the first blocker.
2. The oppos... |
18,088,883 | I'm working on a JavaScript project in which I need to display an array of numbers. This numbers can be integers or fractions. I need to display the fraction in the classic way, I mean, the top number, below a line and below the other number, as shown in this example:
<http://jsfiddle.net/xW7d8/>
The thing is that th... | 2013/08/06 | [
"https://Stackoverflow.com/questions/18088883",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1450069/"
] | Try this with the string containing the tags. It should begin with a tag, though:
```
$("#num1").html(stringArray);
```
But since your fiddle rewrites the div with the fraction class you probably just want to generate the whole html of the fractions yourself. `<span class="top">1</span><span class="bottom">2</span>`... | Sounds to me like you want to use JQuery's html() function instead of text()
```
$("#num1").html(stringArray);
```
Does this help? |
19,313,255 | I need to examine millions of strings for abbreviations and replace them with the full version. Due to the data, only abbreviations terminated by a comma should be replaced. Strings can contain multiple abbreviations.
I have a lookup table that contains Abbreviation->Fullversion pairs, it contains about 600 pairs.
My... | 2013/10/11 | [
"https://Stackoverflow.com/questions/19313255",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2181915/"
] | It would already be a bit faster if you skip `contains()` part :) | I think I'd do this with a HashMap. The key would be the abbreviation and the value would be the full term. Then just search through a string for a comma and see if the text that precedes the comma is in the dictionary. You could probably map all the replacements in a single string in one pass and then make all the rep... |
19,313,255 | I need to examine millions of strings for abbreviations and replace them with the full version. Due to the data, only abbreviations terminated by a comma should be replaced. Strings can contain multiple abbreviations.
I have a lookup table that contains Abbreviation->Fullversion pairs, it contains about 600 pairs.
My... | 2013/10/11 | [
"https://Stackoverflow.com/questions/19313255",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2181915/"
] | What could really improve performance would be to use a better data structure than a simple array for storing your ShortForms. All of the shortForms could be stored sorted alphabetically by abbreviation. You could therefore reduce the lookup time from O(N) to something looking more like a binary search.
I haven't used... | I think I'd do this with a HashMap. The key would be the abbreviation and the value would be the full term. Then just search through a string for a comma and see if the text that precedes the comma is in the dictionary. You could probably map all the replacements in a single string in one pass and then make all the rep... |
41,034,365 | I used to load the video on `UITableViewCell` by using avplayer. I can load the video on `UITableViewCell` but I can't pause/play the video. I cant do any basic functionality like increase/decrease the volume. please any one help me to solve this issues.
here is my code:
```
func tableView(_ tableView: UITableView, ce... | 2016/12/08 | [
"https://Stackoverflow.com/questions/41034365",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6612275/"
] | Try this approach:
**1)** Declare a variable of `AVPlayer` in your `cell` class.
**2)** Inside `cellWillAppear` , instantiate this variable like
```
cell.avplayer = AVPlayer(url: videoURL! as URL)
```
**3)** Inside `cellWillDisapper` , make `avplayer nil`
```
cell.avplayer = nil
```
**4)** To increase / decrea... | maybe you should reuse the AVPlayerLayer , or the "https" cause it |
41,034,365 | I used to load the video on `UITableViewCell` by using avplayer. I can load the video on `UITableViewCell` but I can't pause/play the video. I cant do any basic functionality like increase/decrease the volume. please any one help me to solve this issues.
here is my code:
```
func tableView(_ tableView: UITableView, ce... | 2016/12/08 | [
"https://Stackoverflow.com/questions/41034365",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6612275/"
] | try this
func tableView(\_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
{
```
let cell: FeedCell = tableView.dequeueReusableCell(withIdentifier: "VedioCell", for: indexPath) as! FeedCell
let player = playerArray[indexPath.row]
let playerLayer = AVPlayerLayer(... | maybe you should reuse the AVPlayerLayer , or the "https" cause it |
41,034,365 | I used to load the video on `UITableViewCell` by using avplayer. I can load the video on `UITableViewCell` but I can't pause/play the video. I cant do any basic functionality like increase/decrease the volume. please any one help me to solve this issues.
here is my code:
```
func tableView(_ tableView: UITableView, ce... | 2016/12/08 | [
"https://Stackoverflow.com/questions/41034365",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6612275/"
] | try this
func tableView(\_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
{
```
let cell: FeedCell = tableView.dequeueReusableCell(withIdentifier: "VedioCell", for: indexPath) as! FeedCell
let player = playerArray[indexPath.row]
let playerLayer = AVPlayerLayer(... | Try this approach:
**1)** Declare a variable of `AVPlayer` in your `cell` class.
**2)** Inside `cellWillAppear` , instantiate this variable like
```
cell.avplayer = AVPlayer(url: videoURL! as URL)
```
**3)** Inside `cellWillDisapper` , make `avplayer nil`
```
cell.avplayer = nil
```
**4)** To increase / decrea... |
124,180 | I am trying to automatically identify identical vertices within a polyline and remove them without converting the vertices to points first. I have converted the vertices to XY points and identified a significant number of identical vertices, greater than 4000, that will need to be removed. I believe I can use itertools... | 2014/12/02 | [
"https://gis.stackexchange.com/questions/124180",
"https://gis.stackexchange.com",
"https://gis.stackexchange.com/users/40333/"
] | There are several ways of doing this. If you know ArcObjects and a bit of VBA you could knock a simple update script together calling the [ITopologicalOperator.Simplify()](http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/index.html#/Simplify_Method/002m000003w0000000/) method. But you mentioned python so... | The [Find Identical (Data Management)](http://resources.arcgis.com/en/help/main/10.2/index.html#//001700000054000000) tool will create a table listing identical features, but not delete them. This is useful if you want to just look over the duplicates.
The [Delete Identical (Data Management)](http://resources.arcgis.c... |
124,180 | I am trying to automatically identify identical vertices within a polyline and remove them without converting the vertices to points first. I have converted the vertices to XY points and identified a significant number of identical vertices, greater than 4000, that will need to be removed. I believe I can use itertools... | 2014/12/02 | [
"https://gis.stackexchange.com/questions/124180",
"https://gis.stackexchange.com",
"https://gis.stackexchange.com/users/40333/"
] | there is something inside of QGIS that may be able to help you out. inside the experimental plugins there is a [generalizer](https://plugins.qgis.org/plugins/generalizer/) plugin. I have used it before to accomplish what you are looking to do. have a look at this [post](https://gis.stackexchange.com/questions/37554/rem... | The [Find Identical (Data Management)](http://resources.arcgis.com/en/help/main/10.2/index.html#//001700000054000000) tool will create a table listing identical features, but not delete them. This is useful if you want to just look over the duplicates.
The [Delete Identical (Data Management)](http://resources.arcgis.c... |
124,180 | I am trying to automatically identify identical vertices within a polyline and remove them without converting the vertices to points first. I have converted the vertices to XY points and identified a significant number of identical vertices, greater than 4000, that will need to be removed. I believe I can use itertools... | 2014/12/02 | [
"https://gis.stackexchange.com/questions/124180",
"https://gis.stackexchange.com",
"https://gis.stackexchange.com/users/40333/"
] | The following code is what I have used per Hornbydd's reccomendation. I have not tested this extensively but it seems to work.
```py
import arcpy
import numpy
from arcpy import da
# Read the parameter values:
# 1: input river shapefile
# 2: output point shapefile with no overlapping points
# 3: output line shapef... | The [Find Identical (Data Management)](http://resources.arcgis.com/en/help/main/10.2/index.html#//001700000054000000) tool will create a table listing identical features, but not delete them. This is useful if you want to just look over the duplicates.
The [Delete Identical (Data Management)](http://resources.arcgis.c... |
124,180 | I am trying to automatically identify identical vertices within a polyline and remove them without converting the vertices to points first. I have converted the vertices to XY points and identified a significant number of identical vertices, greater than 4000, that will need to be removed. I believe I can use itertools... | 2014/12/02 | [
"https://gis.stackexchange.com/questions/124180",
"https://gis.stackexchange.com",
"https://gis.stackexchange.com/users/40333/"
] | There are several ways of doing this. If you know ArcObjects and a bit of VBA you could knock a simple update script together calling the [ITopologicalOperator.Simplify()](http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/index.html#/Simplify_Method/002m000003w0000000/) method. But you mentioned python so... | there is something inside of QGIS that may be able to help you out. inside the experimental plugins there is a [generalizer](https://plugins.qgis.org/plugins/generalizer/) plugin. I have used it before to accomplish what you are looking to do. have a look at this [post](https://gis.stackexchange.com/questions/37554/rem... |
124,180 | I am trying to automatically identify identical vertices within a polyline and remove them without converting the vertices to points first. I have converted the vertices to XY points and identified a significant number of identical vertices, greater than 4000, that will need to be removed. I believe I can use itertools... | 2014/12/02 | [
"https://gis.stackexchange.com/questions/124180",
"https://gis.stackexchange.com",
"https://gis.stackexchange.com/users/40333/"
] | There are several ways of doing this. If you know ArcObjects and a bit of VBA you could knock a simple update script together calling the [ITopologicalOperator.Simplify()](http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/index.html#/Simplify_Method/002m000003w0000000/) method. But you mentioned python so... | The following code is what I have used per Hornbydd's reccomendation. I have not tested this extensively but it seems to work.
```py
import arcpy
import numpy
from arcpy import da
# Read the parameter values:
# 1: input river shapefile
# 2: output point shapefile with no overlapping points
# 3: output line shapef... |
25,836,613 | I have a String in a class that is separate from another class and in this string i want to get an integer from an object of the other class, this object is in a class of its own.
Class with string below
```
TextView2.setText(//I want the objects integer value displayed here);
```
Class with object below
```
testC... | 2014/09/14 | [
"https://Stackoverflow.com/questions/25836613",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3786633/"
] | `findViewById()` will traverse only the given view and its children. It will not find sibling views. Your textview is a sibling to the custom view, not a child view.
In an activity, the root view where `findViewById()` traversal starts is the activity window (`Activity.findViewById()`). In a view, it is the view itsel... | Understanding helpful explanation above I would like to give an easy way to find a view by its ID from `CustomViews`:
```
(Activity)getContext()).findViewById(R.id.youViewToBeFound);
```
inside your `CustomView` class.
This code must be run AFTER constructor code e.g. inside `onAttachedToWindow()` |
8,555,175 | According to strict aliasing rules:
```
struct B { virtual ~B() {} };
struct D : public B { };
D d;
char *c = reinterpret_cast<char*>(&d);
```
A `char*` to any object of different type is valid. But now the question is, will it point to the same address of &d? what is the guarantee made by C++ Standard that it will... | 2011/12/18 | [
"https://Stackoverflow.com/questions/8555175",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1086635/"
] | Section 5.2.10, point 7 of the 2003 C++ Standard says:
>
> A pointer to an object can be explicitly converted to a pointer to an
> object of different type. Except that converting an rvalue of type
> “pointer to T1” to the type “pointer to T2” (where T1 and T2 are
> object types and where the alignment requirement... | The intent is clear (and not something that needs to be debated):
**`reinterpret_cast` never changes the value of an address**, unless the target type cannot represent all address values (like a small integer type, on a pointer type with intrinsic alignment: f.ex. a pointer that can only represent even addresses, or p... |
8,555,175 | According to strict aliasing rules:
```
struct B { virtual ~B() {} };
struct D : public B { };
D d;
char *c = reinterpret_cast<char*>(&d);
```
A `char*` to any object of different type is valid. But now the question is, will it point to the same address of &d? what is the guarantee made by C++ Standard that it will... | 2011/12/18 | [
"https://Stackoverflow.com/questions/8555175",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1086635/"
] | `c` and `&d` do indeed have the same value, and if you reinterpret-cast `c` back to a `D*` you get a valid pointer that you may dereference. Furthermore, you can treat `c` as (pointer to the first element of) an opaque array `char[sizeof(D)]` -- this is indeed the main purpose of casting pointers to char pointers: To a... | Section 5.2.10, point 7 of the 2003 C++ Standard says:
>
> A pointer to an object can be explicitly converted to a pointer to an
> object of different type. Except that converting an rvalue of type
> “pointer to T1” to the type “pointer to T2” (where T1 and T2 are
> object types and where the alignment requirement... |
8,555,175 | According to strict aliasing rules:
```
struct B { virtual ~B() {} };
struct D : public B { };
D d;
char *c = reinterpret_cast<char*>(&d);
```
A `char*` to any object of different type is valid. But now the question is, will it point to the same address of &d? what is the guarantee made by C++ Standard that it will... | 2011/12/18 | [
"https://Stackoverflow.com/questions/8555175",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1086635/"
] | `c` and `&d` do indeed have the same value, and if you reinterpret-cast `c` back to a `D*` you get a valid pointer that you may dereference. Furthermore, you can treat `c` as (pointer to the first element of) an opaque array `char[sizeof(D)]` -- this is indeed the main purpose of casting pointers to char pointers: To a... | The intent is clear (and not something that needs to be debated):
**`reinterpret_cast` never changes the value of an address**, unless the target type cannot represent all address values (like a small integer type, on a pointer type with intrinsic alignment: f.ex. a pointer that can only represent even addresses, or p... |
58,015,664 | I have
```
>> list = ["a","b","c"]
```
and I need to get the index of the elements and create a new list that follows
```
>> list_2 = [[1,"a"], [2,"b"], [3,c]]
```
to create the new list I used
```
lista = Enum.flat_map(list, fn x -> [index,x] end)
```
but I can't find a function like to get the "index" value | 2019/09/19 | [
"https://Stackoverflow.com/questions/58015664",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12091566/"
] | ```
list = ["a","b","c"]
list_2 = Enum.with_index(list)
```
gives
```
[{"a", 0}, {"b", 1}, {"c", 2}]
``` | I know the below answer is not related to asked question, but I'm sure it will help some in the feature.
In my case, I have to add an index to an array of lists/map.
So I did the below:
```
formatted_list = [%{"map 1": 1}, %{"map 2": 2}]
list_with_index = formatted_list
|> Enum.with_index(1)
|> Enum.map(fn {e, i} -> ... |
58,015,664 | I have
```
>> list = ["a","b","c"]
```
and I need to get the index of the elements and create a new list that follows
```
>> list_2 = [[1,"a"], [2,"b"], [3,c]]
```
to create the new list I used
```
lista = Enum.flat_map(list, fn x -> [index,x] end)
```
but I can't find a function like to get the "index" value | 2019/09/19 | [
"https://Stackoverflow.com/questions/58015664",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12091566/"
] | [`Enum.zip/2`](https://hexdocs.pm/elixir/master/Enum.html?#zip/2) is your friend here.
```rb
list = ~w[a b c]
#⇒ ["a", "b", "c"]
list_2 = Enum.zip(1..3, list)
#⇒ [{1, "a"}, {2, "b"}, {3, "c"}]
```
or, if the size is unknown upfront, you might
```rb
Enum.zip(Stream.iterate(1, & &1 + 1), list)
#⇒ [{1, "a"}, {2, "b"}... | I know the below answer is not related to asked question, but I'm sure it will help some in the feature.
In my case, I have to add an index to an array of lists/map.
So I did the below:
```
formatted_list = [%{"map 1": 1}, %{"map 2": 2}]
list_with_index = formatted_list
|> Enum.with_index(1)
|> Enum.map(fn {e, i} -> ... |
3,138,688 | In TFS2010/TFSPowerTools2010/Process Explorer I am creating a custom process template. I define a new work item type (WIT) called "Enhancement" copied from the CMMI "Change Request" WIT.
Then I want to rename the friendly field name of the work item type "System.Title" (called "Title") to "Summary".
When I upload my... | 2010/06/29 | [
"https://Stackoverflow.com/questions/3138688",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/72760/"
] | What you can do is create a new field and make it required. Call it **Summary**, etc. Change the `Title` label and textbox from the stock values and point it to your new field. Do not remove the `System.Title` field from the field list.
In the work flow, use the **Summary** value to populate the `System.Title` field, ... | You aren't able to rename a system field like **System.Title**. It's used by other work item types across the team project collection and the server instance. It also has to be filled in by the default rules. You can rename the "label" that gets shown to the end user by going to the layout tab of the work item type edi... |
3,138,688 | In TFS2010/TFSPowerTools2010/Process Explorer I am creating a custom process template. I define a new work item type (WIT) called "Enhancement" copied from the CMMI "Change Request" WIT.
Then I want to rename the friendly field name of the work item type "System.Title" (called "Title") to "Summary".
When I upload my... | 2010/06/29 | [
"https://Stackoverflow.com/questions/3138688",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/72760/"
] | What you can do is create a new field and make it required. Call it **Summary**, etc. Change the `Title` label and textbox from the stock values and point it to your new field. Do not remove the `System.Title` field from the field list.
In the work flow, use the **Summary** value to populate the `System.Title` field, ... | In Visual Studio I was looking at a WinForm and saving the form I got this error:
>
> Microsoft Visual Studio Save failed.
>
>
> TF20012: Field 'Title' cannot be empty.
>
>
> OK
>
>
>
Since its a **TF** error I closed all the Work Items (even unsaved ones...) and then saving the Winform worked.
I am not sure... |
7,945,888 | I have a server written in C# and need to talk to it from Java 1.6. I need to connect to the server, maintain the connection, and send messages in both directions. The messages are an int (length of the message) and then an XML file.
What is the best way to do this? I know Java well but I've never done TCP from Java (... | 2011/10/30 | [
"https://Stackoverflow.com/questions/7945888",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/509627/"
] | Since you're only exchanging integers, you might want to use the classes Socket and DataOutputStream (for sending) and DataInputStream (for receiving).
I highly recommend to make the use of threads. | For starters, check out [this tiny demo](http://systembash.com/content/a-simple-java-tcp-server-and-tcp-client/).
From there, the helpers provided by [Apache Commons Net](http://commons.apache.org/net/) may clean up some of the lower-level work. |
7,945,888 | I have a server written in C# and need to talk to it from Java 1.6. I need to connect to the server, maintain the connection, and send messages in both directions. The messages are an int (length of the message) and then an XML file.
What is the best way to do this? I know Java well but I've never done TCP from Java (... | 2011/10/30 | [
"https://Stackoverflow.com/questions/7945888",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/509627/"
] | So you want to build a Java client using Socket API. It's pretty simple to do.
```
try {
Socket socket = new Socket( host, port );
BufferedReader in = new BufferedReader( new InputStreamReader( socket.getInputStream() ) );
PrintWriter out = new PrintWriter( new OutputStreamWriter( socket.getOutputStream() ) )... | For starters, check out [this tiny demo](http://systembash.com/content/a-simple-java-tcp-server-and-tcp-client/).
From there, the helpers provided by [Apache Commons Net](http://commons.apache.org/net/) may clean up some of the lower-level work. |
7,945,888 | I have a server written in C# and need to talk to it from Java 1.6. I need to connect to the server, maintain the connection, and send messages in both directions. The messages are an int (length of the message) and then an XML file.
What is the best way to do this? I know Java well but I've never done TCP from Java (... | 2011/10/30 | [
"https://Stackoverflow.com/questions/7945888",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/509627/"
] | So you want to build a Java client using Socket API. It's pretty simple to do.
```
try {
Socket socket = new Socket( host, port );
BufferedReader in = new BufferedReader( new InputStreamReader( socket.getInputStream() ) );
PrintWriter out = new PrintWriter( new OutputStreamWriter( socket.getOutputStream() ) )... | Since you're only exchanging integers, you might want to use the classes Socket and DataOutputStream (for sending) and DataInputStream (for receiving).
I highly recommend to make the use of threads. |
284,550 | Dears,
We received a 50 Hz 5.5KW 220V Motor, How to change this to operate in 60HZ. | 2017/02/05 | [
"https://electronics.stackexchange.com/questions/284550",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/138149/"
] | The motor will operate 20% faster with 60 Hz. The driven equipment may run properly at a faster speed and it may not. If the motor is driving a fan or a centrifugal pump, it will require 44% more torque and 73% more power. That would not work at all. If the driven equipment is something like a conveyer, it will require... | Well, excellent answer given by Charles. The motor will run faster, it'll exceed the its rated speed. While it is not a problem for low torque applications assuming the motor structure is designed to withstand higher speeds, but for high torque applications, it'll really need more current to draw. Only way to feed that... |
44,859,238 | If the part in bold of this string are the seconds. 00:00:00:**00**.000
How could I add 10 seconds to all this string formats ?
```
00:00:00:00.000
00:00.000
00.000
```
The result should be:
```
00:00:00:10.000
00:10.000
10.000
``` | 2017/07/01 | [
"https://Stackoverflow.com/questions/44859238",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1092437/"
] | Using [`re.sub`](https://docs.python.org/3/library/re.html#re.sub) with replacement function:
```
>>> import re
>>> strings = [
... '00:00:00:00.000',
... '00:00.000',
... '00.000',
... ]
>>> for s in strings:
... re.sub(r'\d+(?=\.\d+$)', lambda match: str(int(match.group()) + 10), s) ... | You have two options that come to my mind:
1. Find or write your own converter of string to timestamp format, then increase it by 10s and convert back.
2. Write your own function that takes string, checks in which format it is and adds 10s shifting it to minutes if necessary. |
51,526,790 | I'm working on a job scheduling app for a REST API and I've created a Tasks, Nodes, URL, Adom, BaseOptions, and Jobs tables in Django. The BaseOptions have a foreign key for src\_adom and dst\_adom and the Jobs have foreign keys for the Task, src\_node, dst\_node, url and baseOptions. I didn't use a ModelForm but a gen... | 2018/07/25 | [
"https://Stackoverflow.com/questions/51526790",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/909698/"
] | When Redux gets the new data, it triggers props change through connect down to all connected components. There are some possibilities for how the component will behave according to the store changes:
1. When the connection to the store does not affect parents of the component, it will launch regular component lifecycl... | React uses [Reconciliation](https://reactjs.org/docs/reconciliation.html) to establish when a component should unmount then remount. React does diff checking to determine when to update a component and all its children. It will not remount any components when nothing has changed at the parent level, and therefore compo... |
60,216,186 | We are running a spark-job on the EMR cluster with the Cluster configuration as given below.
```
Resources:
Node Type:CORE - 2 INSTANCES OF
r4.8xlarge
32 vCore, 244 GiB memory, EBS only storage
EBS Storage:32 GiB
Node Type: MASTER
1 Instance of r4.4xlarge
16 vCore, 122 GiB memory, EBS only storage
EBS Storage:32 GiB
... | 2020/02/13 | [
"https://Stackoverflow.com/questions/60216186",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12632870/"
] | Not sure to understand your question.
Why couldn't you use `aes_string()` and define a function like below ?
```r
make.histogram <- function(variable) {
p <- ggplot(my.data, aes_string(x = variable, fill = "type")) + (...) + xlab(variable)
print(p)
}
``` | Since ggplot is part of the *tidyverse*, I think *tidyeval* will come in handy:
```
make.histogram <- function(var = "foo", bindwith = 0.01) {
varName <- as.name(var)
enquo_varName <- enquo(varName)
ggplot(my.data, aes(x = !!enquo_varName, fill = type)) +
...
labs(x = var)
}
``... |
60,216,186 | We are running a spark-job on the EMR cluster with the Cluster configuration as given below.
```
Resources:
Node Type:CORE - 2 INSTANCES OF
r4.8xlarge
32 vCore, 244 GiB memory, EBS only storage
EBS Storage:32 GiB
Node Type: MASTER
1 Instance of r4.4xlarge
16 vCore, 122 GiB memory, EBS only storage
EBS Storage:32 GiB
... | 2020/02/13 | [
"https://Stackoverflow.com/questions/60216186",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12632870/"
] | After reading the material that @andrew.punnett linked in his comment, it was very easy to code the desired function:
```
make.histogram <- function(column.name, binwidth = 0.02) {
base.aes <- eval(substitute(aes(x = column.name, fill = type)))
x.label <- deparse(substitute(column.name))
ggplot(my.data, ... | Since ggplot is part of the *tidyverse*, I think *tidyeval* will come in handy:
```
make.histogram <- function(var = "foo", bindwith = 0.01) {
varName <- as.name(var)
enquo_varName <- enquo(varName)
ggplot(my.data, aes(x = !!enquo_varName, fill = type)) +
...
labs(x = var)
}
``... |
20,042,716 | I'm novice to the excel macros. My requirement is like:
For given matrix which having single column with multiple rows I need to change this rows into column in next sheet(says sheet2).
```
Col1
xyz
pqr
abc
```
This need to be changed rows in sheet2 as follows:
```
xyz pqr abc
```
This is what I have tried... | 2013/11/18 | [
"https://Stackoverflow.com/questions/20042716",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3003807/"
] | Something like this:
```
NSString *date = @"11/17/2013 12:00:00 AM";
NSString *m = [date substringWithRange:NSMakeRange(0, 2)];
NSString *d = [date substringWithRange:NSMakeRange(3, 2)];
NSString *result = [NSString stringWithFormat:@"%@/%@/2013 12:00:00 AM",d,m];
```
I haven't tested it | You can do it:
```
NSMutableArray *array = [[yourString componentsSeparatedByString:@"/"] mutableCopy];
id temp = [array objectAtIndex:1];
[array replaceObjectAtIndex:1 withObject:[array objectAtIndex:0]];
[array replaceObjectAtIndex:0 withObject:temp];
NSString * finalString = [array componentsJoinedByString:@"/"];
... |
20,042,716 | I'm novice to the excel macros. My requirement is like:
For given matrix which having single column with multiple rows I need to change this rows into column in next sheet(says sheet2).
```
Col1
xyz
pqr
abc
```
This need to be changed rows in sheet2 as follows:
```
xyz pqr abc
```
This is what I have tried... | 2013/11/18 | [
"https://Stackoverflow.com/questions/20042716",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3003807/"
] | Try It:
```
NSMutableArray *dateArray = [[@"11/17/2013 12:00:00 AM" componentsSeparatedByString:@"/"] mutableCopy];
[dateArray exchangeObjectAtIndex:1 withObjectAtIndex:0];
NSString *dateString = [dateArray componentsJoinedByString:@"/"];
NSLog(@"%@", dateString);
``` | Something like this:
```
NSString *date = @"11/17/2013 12:00:00 AM";
NSString *m = [date substringWithRange:NSMakeRange(0, 2)];
NSString *d = [date substringWithRange:NSMakeRange(3, 2)];
NSString *result = [NSString stringWithFormat:@"%@/%@/2013 12:00:00 AM",d,m];
```
I haven't tested it |
20,042,716 | I'm novice to the excel macros. My requirement is like:
For given matrix which having single column with multiple rows I need to change this rows into column in next sheet(says sheet2).
```
Col1
xyz
pqr
abc
```
This need to be changed rows in sheet2 as follows:
```
xyz pqr abc
```
This is what I have tried... | 2013/11/18 | [
"https://Stackoverflow.com/questions/20042716",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3003807/"
] | Try It:
```
NSMutableArray *dateArray = [[@"11/17/2013 12:00:00 AM" componentsSeparatedByString:@"/"] mutableCopy];
[dateArray exchangeObjectAtIndex:1 withObjectAtIndex:0];
NSString *dateString = [dateArray componentsJoinedByString:@"/"];
NSLog(@"%@", dateString);
``` | You can do it:
```
NSMutableArray *array = [[yourString componentsSeparatedByString:@"/"] mutableCopy];
id temp = [array objectAtIndex:1];
[array replaceObjectAtIndex:1 withObject:[array objectAtIndex:0]];
[array replaceObjectAtIndex:0 withObject:temp];
NSString * finalString = [array componentsJoinedByString:@"/"];
... |
18,153,309 | ok i have the following:
```
<div class="row">
<div class="test">02/12/2013</div>
<div class="test">03/12/2013</div>
<div class="test">04/12/2013</div>
<div class="test">05/12/2013</div>
<div class="class1">06/12/2013</div>
<div class="test"><07/12/2013/div>
<div class="test">08/12/2013</d... | 2013/08/09 | [
"https://Stackoverflow.com/questions/18153309",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1754467/"
] | You mean something like this?
```
$(function(){
var $class1 = $('.class1');
var $class2 = $('.class2');
var $afterClass1 = $class1.nextAll('.test');
var $beforeClass2 = $class2.prevAll('.test');
var count = $afterClass1.length + $beforeClass2.length;
$('.count').html(count);
});
```
<ht... | Maybe something like this?
```
$divs = $('.row div');
var count = $divs.index($('.class2')) - $divs.index($('.class1')) - 1;
``` |
3,158,056 | I am using Visual studio 2008 in Windows 7. After an ajax call, I am building an image markup dynamically and setting it to a div like this.
```
var imageLocation="<%= Url.Action("Show", "Images", new { Id = Model.LoginUser.UserId })%>";
var markup = '<img class="profile-Image" src="' + imageLocation + '"/>';
$('.di... | 2010/07/01 | [
"https://Stackoverflow.com/questions/3158056",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/227829/"
] | I find the suggestion of **MSalters** to use `IOCTL_STORAGE_CHECK_VERIFY` very good. There are a small trick in the usage of `IOCTL_STORAGE_CHECK_VERIFY`. Before the usage of IOCTL code in the function `DeviceIoControl` one need to open the corresponding device with respect of `CreateFile` function:
```
HANDLE hDevice... | The reason for this behavior is historical, and dates back to floppy drives and MS-DOS. The `A:` drive would still be the `A:` drive even if there was no floppy in it.
It is sometimes possible to check whether a drive with removable media is empty. Card readers and CD drives usually support this, floppy drives don't.... |
26,762,058 | *I need to evaluate postfix expressions using a linked list stack. I think i need some help with the algorithm. I write* `13+` *as input but i get `100` as output.*
PostfixCalculator Class:
```
public class PostfixCalculator{
String expression;
MyStack stack = new MyStack<Double>();
public PostfixCalcula... | 2014/11/05 | [
"https://Stackoverflow.com/questions/26762058",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4208485/"
] | If the format is the given one, then I don't see that much of an issue:
```
var startIndex= inputString.IndexOf("[@ID=");
var endIndex = inputString.LastIndexOf("]");
if (startIndex < 0 || endIndex < startIndex)
throw new ArgumentException("Format is not valid.");
startIndex += "[@ID=".Length;
var potentia... | Try regular expressions
<http://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex(v=vs.110).aspx>
```
public int CheckValidID(string idString)
{
Regex rg = new Regex(@"\d*",RegexOptions.IgnoreCase);
string val = rg.Match(idString).Value;
int ValidID = Convert.ToInt32(val);
retu... |
33,924,053 | So I'm doing this website for a class project and for some reason if I make the browser window as small as possible on my screen, the second button in the "About section of my page gets cut in half, regardless of whether or not it has an overflow set.
I've attached an image of the button and a snippet of my css and h... | 2015/11/25 | [
"https://Stackoverflow.com/questions/33924053",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5421253/"
] | It's because of white space wrapping. include `white-space: nowrap;` in your `.about a` style. | While you can use something like `white-space: nowrap;` to hack in a fix for this, the problem lies in that your `a` tags are `display: inline` elements. You want them to behave like block-level elements in this situation but still sit inline, so what you're looking for is `.about a { display: inline-block; }`:
```css... |
33,924,053 | So I'm doing this website for a class project and for some reason if I make the browser window as small as possible on my screen, the second button in the "About section of my page gets cut in half, regardless of whether or not it has an overflow set.
I've attached an image of the button and a snippet of my css and h... | 2015/11/25 | [
"https://Stackoverflow.com/questions/33924053",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5421253/"
] | It's because of white space wrapping. include `white-space: nowrap;` in your `.about a` style. | Calling *display:inline-block* on the A tags would be the easiest fix, and work on IE8+ and current versions of other browsers.
To better control how they will respond in smaller widths (and on mobile), I'd set the A tags to *display:block;* and set widths and float them. |
33,924,053 | So I'm doing this website for a class project and for some reason if I make the browser window as small as possible on my screen, the second button in the "About section of my page gets cut in half, regardless of whether or not it has an overflow set.
I've attached an image of the button and a snippet of my css and h... | 2015/11/25 | [
"https://Stackoverflow.com/questions/33924053",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5421253/"
] | While you can use something like `white-space: nowrap;` to hack in a fix for this, the problem lies in that your `a` tags are `display: inline` elements. You want them to behave like block-level elements in this situation but still sit inline, so what you're looking for is `.about a { display: inline-block; }`:
```css... | Calling *display:inline-block* on the A tags would be the easiest fix, and work on IE8+ and current versions of other browsers.
To better control how they will respond in smaller widths (and on mobile), I'd set the A tags to *display:block;* and set widths and float them. |
370,425 | **UPDATE: 2020-07-12** I tried installing on Windows 10 64-bit and it failed to install WordPress with the same database error as on Windows 7. That tells me that ***either there is a bug in WAMPServer 3.2.0 or there is a bug in WordPress 5.4.2.*** because the issue occurs on both operating systems.
---
ISSUE
-----
... | 2020/07/05 | [
"https://wordpress.stackexchange.com/questions/370425",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/49697/"
] | Not sure what you would need this for but this is how you take the data of the variable $result from the operation function to your shortcode:
```
operation();
function operation(){
$result=5+1;
return $result;
}
function my_function(){
$result = operation();
return (string)$result;
}
add_shortcode( 'my-shortcode', ... | Do you mean something like this?
```
function some_function( $a ) {
return $a * 2;
}
function my_shortcode( $atts ) {
$params = shortcode_atts( array(
'value' => 0
), $atts );
return (string)some_function( $params['value'] );
}
add_shortcode( 'my-shortcode', 'my_shortcode' );
```
When you use... |
574,995 | I have an Excel spreadsheet which is being used to specify filesystem build information for our Unix team.
This worksheet would have different information depending on the system to be built. For example, a production system would have many filesystems, whereas a development system only one or two.
So based on user i... | 2009/02/22 | [
"https://Stackoverflow.com/questions/574995",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29286/"
] | There's a few ways depending on the complexity of the sheet:
* If you only have a few worksheets, and users would just select "Production" or "Test", you could set up the conditional logic in the formulas. For example: =if(A1="Test",TestSheet!A1 + TestSheet!A2, ProdSheet!A1 + ProdSheet!A2)
* You could utilize the same... | if you can use VBA code as LuckyLindy suggests, you can do pretty much anything. What I used to do is record macros for various operations, for example adding or renaming sheets and take the generated code and adapt it to do exactly what was required.
An example of simple macro code:
```
Sub Macro1()
'
' Macro1 Macro... |
574,995 | I have an Excel spreadsheet which is being used to specify filesystem build information for our Unix team.
This worksheet would have different information depending on the system to be built. For example, a production system would have many filesystems, whereas a development system only one or two.
So based on user i... | 2009/02/22 | [
"https://Stackoverflow.com/questions/574995",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29286/"
] | There's a few ways depending on the complexity of the sheet:
* If you only have a few worksheets, and users would just select "Production" or "Test", you could set up the conditional logic in the formulas. For example: =if(A1="Test",TestSheet!A1 + TestSheet!A2, ProdSheet!A1 + ProdSheet!A2)
* You could utilize the same... | Another way would be to use the INDIRECT formula.
Say you have in cell A1 the name of the sheet you want to look up input from, then the following will look up the value of cell B7 from that sheet:
```
=INDIRECT($A$1,"!B7")
``` |
574,995 | I have an Excel spreadsheet which is being used to specify filesystem build information for our Unix team.
This worksheet would have different information depending on the system to be built. For example, a production system would have many filesystems, whereas a development system only one or two.
So based on user i... | 2009/02/22 | [
"https://Stackoverflow.com/questions/574995",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29286/"
] | if you can use VBA code as LuckyLindy suggests, you can do pretty much anything. What I used to do is record macros for various operations, for example adding or renaming sheets and take the generated code and adapt it to do exactly what was required.
An example of simple macro code:
```
Sub Macro1()
'
' Macro1 Macro... | Another way would be to use the INDIRECT formula.
Say you have in cell A1 the name of the sheet you want to look up input from, then the following will look up the value of cell B7 from that sheet:
```
=INDIRECT($A$1,"!B7")
``` |
2,072,991 | I need to change the values of a PK/FK (add 10000) on 2 tables. How do I tell the two tables involved that they should not care about referential integrity during the update, but to care after. I don't want to have to drop and recreate the relationships if I don’t have to. | 2010/01/15 | [
"https://Stackoverflow.com/questions/2072991",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/172861/"
] | Your FK should have a "ON UPDATE CASCADE" option.
```
ALTER TABLE child CHANGE myfkconst FOREIGN KEY id REFERENCES parent (id) ON UPDATE CASCADE;
```
(or something like that. not 100% sure about the syntax)
And then you can just do
```
UPDATE parent SET id = id + 10000 WHERE id = something
```
and the child tabl... | Sorry, you have to. No option. |
2,072,991 | I need to change the values of a PK/FK (add 10000) on 2 tables. How do I tell the two tables involved that they should not care about referential integrity during the update, but to care after. I don't want to have to drop and recreate the relationships if I don’t have to. | 2010/01/15 | [
"https://Stackoverflow.com/questions/2072991",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/172861/"
] | You may want to disable all the constraints in the database by executing the following command:
```
EXEC sp_msforeachtable "ALTER TABLE ? NOCHECK CONSTRAINT all";
```
Then switching them back on with:
```
EXEC sp_msforeachtable @command1="print '?'",
@command2="ALTER TABLE ? WITH CHECK CHEC... | Sorry, you have to. No option. |
2,072,991 | I need to change the values of a PK/FK (add 10000) on 2 tables. How do I tell the two tables involved that they should not care about referential integrity during the update, but to care after. I don't want to have to drop and recreate the relationships if I don’t have to. | 2010/01/15 | [
"https://Stackoverflow.com/questions/2072991",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/172861/"
] | [This link](http://www.mssqlcity.com/Articles/General/using_constraints.htm) describes how to temporarily disable a contraint. I have not tested it.
```
-- disable constraint
ALTER TABLE table_name NOCHECK CONSTRAINT constraint_name
-- enable constraint
ALTER TABLE table_name CHECK CONSTRAINT constraint_name
``` | Sorry, you have to. No option. |
2,072,991 | I need to change the values of a PK/FK (add 10000) on 2 tables. How do I tell the two tables involved that they should not care about referential integrity during the update, but to care after. I don't want to have to drop and recreate the relationships if I don’t have to. | 2010/01/15 | [
"https://Stackoverflow.com/questions/2072991",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/172861/"
] | Your FK should have a "ON UPDATE CASCADE" option.
```
ALTER TABLE child CHANGE myfkconst FOREIGN KEY id REFERENCES parent (id) ON UPDATE CASCADE;
```
(or something like that. not 100% sure about the syntax)
And then you can just do
```
UPDATE parent SET id = id + 10000 WHERE id = something
```
and the child tabl... | You may want to disable all the constraints in the database by executing the following command:
```
EXEC sp_msforeachtable "ALTER TABLE ? NOCHECK CONSTRAINT all";
```
Then switching them back on with:
```
EXEC sp_msforeachtable @command1="print '?'",
@command2="ALTER TABLE ? WITH CHECK CHEC... |
2,072,991 | I need to change the values of a PK/FK (add 10000) on 2 tables. How do I tell the two tables involved that they should not care about referential integrity during the update, but to care after. I don't want to have to drop and recreate the relationships if I don’t have to. | 2010/01/15 | [
"https://Stackoverflow.com/questions/2072991",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/172861/"
] | Your FK should have a "ON UPDATE CASCADE" option.
```
ALTER TABLE child CHANGE myfkconst FOREIGN KEY id REFERENCES parent (id) ON UPDATE CASCADE;
```
(or something like that. not 100% sure about the syntax)
And then you can just do
```
UPDATE parent SET id = id + 10000 WHERE id = something
```
and the child tabl... | [This link](http://www.mssqlcity.com/Articles/General/using_constraints.htm) describes how to temporarily disable a contraint. I have not tested it.
```
-- disable constraint
ALTER TABLE table_name NOCHECK CONSTRAINT constraint_name
-- enable constraint
ALTER TABLE table_name CHECK CONSTRAINT constraint_name
``` |
21,653,331 | IDE: Visual C++ 2010
Coding an app that performs a simple dictionary attack. It opens a file and searches for a particular 'string' (a password) in that file. If found it alerts the user 'Pass Found!' else 'Good! Secure password'
In case this password dictionary file is not found (d8.txt), it should display an error... | 2014/02/08 | [
"https://Stackoverflow.com/questions/21653331",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1913137/"
] | fopen\_s doesn't return null pointer on fail, but it sets the file pointer (fp) to null. The return value would be either 0 (on success) and an error number (on fail). So you should go for:
```
int errno=0;
if((errno=fopen_s(&fp, "d8.txt", "r")) != 0) {
// Here you can check errno to give more detailed err... | The correct way:
```
if((fopen_s(&fp, "d8.txt", "r")) == 0)
```
fopen\_s returns `errno_t` which is `typedef int errno_t`.
`0 file opened non zero file not opened`
valter |
6,930 | How to make a sentence with an adjective which refers to different nouns? Do I have to put it twice?
For instance
>
> Его приветствовали с большим ликованием и радостью.
>
> Его приветствовали с большим ликованием и большой радостью.
>
> Его приветствовали с большим ликованием и с большой радостью.
>
>
> Она... | 2014/07/10 | [
"https://russian.stackexchange.com/questions/6930",
"https://russian.stackexchange.com",
"https://russian.stackexchange.com/users/-1/"
] | Grammatical norms require that adjective was put in plural form.
>
> Его приветствовали с большими ликованием и радостью.
>
>
>
if adj. is in singular form, it is dependent on closest noun in same grammatical case.
however, it is impossible to say from
>
> Она принесла охлаждённые сосиски и молоко.
>
>
>
i... | Technically, most of your sentences can be used in spoken speech, with the exception of
```
Нам нужно масло и нужна так же вода
```
That's invalid, although you could say
```
Нам нужно масло и нужна вода, or
Нам нужно масло и так же нужна вода
```
From the rest of your sentences, you would usually only say the fi... |
51,922,812 | I am trying to create a new variable that is based on customer\_id and dates. The table is a log of all customer contact, so there will be duplicate customer IDs. What I want to do it create a new variable that has a sequential count by using dates of contact within x days for each customer. All first contact from a cu... | 2018/08/20 | [
"https://Stackoverflow.com/questions/51922812",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6603900/"
] | ***Setup***
```
df = pd.DataFrame({'city name': ['Toronto', 'San Jose', 'Houston', 'Dallas']})
N = ['Toronto']
S = ['Houston', 'Dallas']
W = ['San Jose']
```
Using `np.select`:
```
c1 = df['city name'].isin(N)
c2 = df['city name'].isin(S)
c3 = df['city name'].isin(W)
df.assign(region=np.select([c1, c2, c3], ['Nort... | Since you do not have too many outcomes, you can combine all three conditions:
```
df["Region"] = pd.np.where(df["City name"].isin(N), "North",
pd.np.where(df["City name"].isin(S), "South",
pd.np.where(df["City name"].isin(W), "West", np.nan)))
``` |
51,922,812 | I am trying to create a new variable that is based on customer\_id and dates. The table is a log of all customer contact, so there will be duplicate customer IDs. What I want to do it create a new variable that has a sequential count by using dates of contact within x days for each customer. All first contact from a cu... | 2018/08/20 | [
"https://Stackoverflow.com/questions/51922812",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6603900/"
] | Since you do not have too many outcomes, you can combine all three conditions:
```
df["Region"] = pd.np.where(df["City name"].isin(N), "North",
pd.np.where(df["City name"].isin(S), "South",
pd.np.where(df["City name"].isin(W), "West", np.nan)))
``` | How about a `map` based solution?
```
mp = {k: lbl
for lst, lbl in [(N, 'North'), (S, 'South'), (E, 'East'), (W, 'West')]
for k in lst}
df['region'] = df['city name'].map(mp)
city name region
0 Toronto North
1 San Jose West
2 Houston South
3 Dallas South
```
Map-based replacement is fast... |
51,922,812 | I am trying to create a new variable that is based on customer\_id and dates. The table is a log of all customer contact, so there will be duplicate customer IDs. What I want to do it create a new variable that has a sequential count by using dates of contact within x days for each customer. All first contact from a cu... | 2018/08/20 | [
"https://Stackoverflow.com/questions/51922812",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6603900/"
] | ***Setup***
```
df = pd.DataFrame({'city name': ['Toronto', 'San Jose', 'Houston', 'Dallas']})
N = ['Toronto']
S = ['Houston', 'Dallas']
W = ['San Jose']
```
Using `np.select`:
```
c1 = df['city name'].isin(N)
c2 = df['city name'].isin(S)
c3 = df['city name'].isin(W)
df.assign(region=np.select([c1, c2, c3], ['Nort... | Using the data from user3483203
```
meltdf=pd.DataFrame({'North':N,'South':S,'West':W}).melt()
df.merge(meltdf,left_on='city',right_on='value',how='left')
Out[244]:
city variable value
0 City A North City A
1 City B South City B
2 City C West City C
```
If the list is not all same length
cha... |
51,922,812 | I am trying to create a new variable that is based on customer\_id and dates. The table is a log of all customer contact, so there will be duplicate customer IDs. What I want to do it create a new variable that has a sequential count by using dates of contact within x days for each customer. All first contact from a cu... | 2018/08/20 | [
"https://Stackoverflow.com/questions/51922812",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6603900/"
] | ***Setup***
```
df = pd.DataFrame({'city name': ['Toronto', 'San Jose', 'Houston', 'Dallas']})
N = ['Toronto']
S = ['Houston', 'Dallas']
W = ['San Jose']
```
Using `np.select`:
```
c1 = df['city name'].isin(N)
c2 = df['city name'].isin(S)
c3 = df['city name'].isin(W)
df.assign(region=np.select([c1, c2, c3], ['Nort... | How about a `map` based solution?
```
mp = {k: lbl
for lst, lbl in [(N, 'North'), (S, 'South'), (E, 'East'), (W, 'West')]
for k in lst}
df['region'] = df['city name'].map(mp)
city name region
0 Toronto North
1 San Jose West
2 Houston South
3 Dallas South
```
Map-based replacement is fast... |
51,922,812 | I am trying to create a new variable that is based on customer\_id and dates. The table is a log of all customer contact, so there will be duplicate customer IDs. What I want to do it create a new variable that has a sequential count by using dates of contact within x days for each customer. All first contact from a cu... | 2018/08/20 | [
"https://Stackoverflow.com/questions/51922812",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6603900/"
] | Using the data from user3483203
```
meltdf=pd.DataFrame({'North':N,'South':S,'West':W}).melt()
df.merge(meltdf,left_on='city',right_on='value',how='left')
Out[244]:
city variable value
0 City A North City A
1 City B South City B
2 City C West City C
```
If the list is not all same length
cha... | How about a `map` based solution?
```
mp = {k: lbl
for lst, lbl in [(N, 'North'), (S, 'South'), (E, 'East'), (W, 'West')]
for k in lst}
df['region'] = df['city name'].map(mp)
city name region
0 Toronto North
1 San Jose West
2 Houston South
3 Dallas South
```
Map-based replacement is fast... |
30,321,861 | Can I invoke Perl script from Unix shell? For example I have bash script in form like:
```
#!/bin/sh
echo This is bash
i=12
echo $i
perl <<__HERE__
print "This is perl\n";
my \$i = $i;
print ++\$i . "\n";
echo This is bash again
echo $i
```
Above is just an example.
Is it possible to pass variables from bash to ... | 2015/05/19 | [
"https://Stackoverflow.com/questions/30321861",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4738153/"
] | The problem is the dollar signs need escaped. It makes for an ugly, error prone Perl script. Use environmental variables.
```
#!/bin/bash
export i=12
readarray results < <(perl <<-'__HERE__'
my $i = $ENV{'i'};
print "$i\n";
$i += 1;
print "$i\n";
__HERE__
)
for r in "${results[... | This is a way to call a Perl script in Shell script. Make sure Perl script is executable and the first line is `#!/usr/bin/perl`.
```
#!/bin/sh
/path/to/perlscript/scriptName.pl arg1 arg2
```
`arg1 arg2 ..` are the arguments if you need to pass any.
You can set the PATH and call the script like this:
```
#!/bin/s... |
16,770,156 | Overriding ErrorPage.cshtml allows you to create custom error page for exceptons thrown from controllers, is there a way to handle exceptions thrown from filters? For example I would like to have custom page for anti forgery exceptions. | 2013/05/27 | [
"https://Stackoverflow.com/questions/16770156",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/930252/"
] | **Exception filters** are available to handle unhandled exceptions thrown during the execution of the ASP.NET MVC pipeline.
Filtering in ASP.NET MVC <http://msdn.microsoft.com/en-us/library/gg416513(v=vs.98).aspx> | Checkout [ELMAH](https://elmah.github.io/) for system wide error handling.
For the custom page on forgery you could always try and manipulate the Request from within the action filter.
For custom handling of an error message or exception type look at: [ASP.NET MVC Custom Error Handling Application\_Error Global.asax?... |
16,770,156 | Overriding ErrorPage.cshtml allows you to create custom error page for exceptons thrown from controllers, is there a way to handle exceptions thrown from filters? For example I would like to have custom page for anti forgery exceptions. | 2013/05/27 | [
"https://Stackoverflow.com/questions/16770156",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/930252/"
] | You can utilize exception filters. Just create your own `FilterProvider` and have it implement `IExceptionFilter`. Put all custom logic inside `OnException(filterContext)` method.
Take a look at eg. current implementation of `Orchard.Security.SecurityFilter` to have an idea. | Checkout [ELMAH](https://elmah.github.io/) for system wide error handling.
For the custom page on forgery you could always try and manipulate the Request from within the action filter.
For custom handling of an error message or exception type look at: [ASP.NET MVC Custom Error Handling Application\_Error Global.asax?... |
16,770,156 | Overriding ErrorPage.cshtml allows you to create custom error page for exceptons thrown from controllers, is there a way to handle exceptions thrown from filters? For example I would like to have custom page for anti forgery exceptions. | 2013/05/27 | [
"https://Stackoverflow.com/questions/16770156",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/930252/"
] | You can utilize exception filters. Just create your own `FilterProvider` and have it implement `IExceptionFilter`. Put all custom logic inside `OnException(filterContext)` method.
Take a look at eg. current implementation of `Orchard.Security.SecurityFilter` to have an idea. | **Exception filters** are available to handle unhandled exceptions thrown during the execution of the ASP.NET MVC pipeline.
Filtering in ASP.NET MVC <http://msdn.microsoft.com/en-us/library/gg416513(v=vs.98).aspx> |
13,034,131 | I wrote this C# code snippet here. The idea is to generate a random .NET Color in RGB, while keeping alpha at 255 (i.e. full)
My question is does this function have the potential to hit every colour in RGB space? I thought I was but now I'm second guessing myself. Alternatively is there a better way to do this?
Thank... | 2012/10/23 | [
"https://Stackoverflow.com/questions/13034131",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/721792/"
] | Maths contains many of the error. Please put OR into shift hexes NOT MULTIPLE!
Colour use is of much fun and ease in the C# :)
Constant is not needful. ALPHA 255 is of the implicit - simple:
```
private static readonly Random rand = new Random();
private Color GetRandomColour()
{
return Color.FromArgb(rand.Nex... | No. The (exclusive!) upper bound should be 0x1000000, not 0xFF \* 0xFF \* 0xFF.
0xFF \* 0xFF \* 0xFF is only 0xFD02FF, so you're missing that colour and all higher colours. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.