qid int64 1 74.7M | question stringlengths 0 58.3k | date stringlengths 10 10 | metadata list | response_j stringlengths 2 48.3k | response_k stringlengths 2 40.5k |
|---|---|---|---|---|---|
186,307 | I currently use a 13" Mid 2011 MacBook Air, and the thing I dislike most about it is that it can get very hot. I'm particularly physically sensitive to the heat for some reason, and at its hottest it makes me uncomfortable even to just sit at a desk with my hands on it.
Anyway, I'm in the market for a new laptop, and ... | 2015/05/08 | [
"https://apple.stackexchange.com/questions/186307",
"https://apple.stackexchange.com",
"https://apple.stackexchange.com/users/87124/"
] | This question seems a bit reversed. All Apple products are designed to let the CPU hit 90°C before the CPU is throttled. So all of them, when given an unlimited workload hit the same design temperature.
What does change is the workload required to saturate the CPU of a MacBook is lower than what will saturate a MacBo... | It is a truism that the more applications you run, plus the intensity of those applications' operations, will cause a certain amount of heat dissipation in the given device.
So assuming that the applications you need will be used regardless, you need to consider the hardware components within each device, since this d... |
186,307 | I currently use a 13" Mid 2011 MacBook Air, and the thing I dislike most about it is that it can get very hot. I'm particularly physically sensitive to the heat for some reason, and at its hottest it makes me uncomfortable even to just sit at a desk with my hands on it.
Anyway, I'm in the market for a new laptop, and ... | 2015/05/08 | [
"https://apple.stackexchange.com/questions/186307",
"https://apple.stackexchange.com",
"https://apple.stackexchange.com/users/87124/"
] | This question seems a bit reversed. All Apple products are designed to let the CPU hit 90°C before the CPU is throttled. So all of them, when given an unlimited workload hit the same design temperature.
What does change is the workload required to saturate the CPU of a MacBook is lower than what will saturate a MacBo... | It all depends on your usage (the load).
For normal uses (the CPU newer runs at 100% for long times) the MacBook Air would be the colder solution.
The MacBook Pro is the more power hungry machine (retina display) and could run hotter.
One way to see this is in the Battery life. MacBook Air can go up to 10 hours on a... |
58,017,490 | I am trying to create a launcher for a flash game. I am new in electron and in programming so I was reading the electron documentation but my flash isn't working.
```
const electron = require('electron')
const { app, BrowserWindow } = require('electron')
const path = require('path');
let pluginName
switch (process.pl... | 2019/09/19 | [
"https://Stackoverflow.com/questions/58017490",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11286758/"
] | Use an older electron version (4.2.6). Newer electron versions (newer than 4.2.6) will not load flash content.
Edit: In Linux, latest electron from 4.2.x series will work with flash player. In windows, latest version works normally
*Added on behalf of question asker.* | Flash appears to be working at least to some extent with Electron 9.0. I've got a test app with Electron 9 (Chromium 83) loading the plugin on my Mac, and also see here: [Can I bundle Pepper Flash in an Electron.js app to run Flash in 2021+?](https://stackoverflow.com/questions/62766547/can-i-bundle-pepper-flash-in-an-... |
4,355,243 | I'm making a website. On it, I want to have a link to my twitter account, http://twitter.com/[username].
On iOS devices, I've coded it so that it goes to twitter://[username], the iOS URL scheme for the official Twitter app. However, if the user does not have this app installed, safari just errors, saying that the 'UR... | 2010/12/04 | [
"https://Stackoverflow.com/questions/4355243",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/252817/"
] | You can not access anything external to your application, so you will not be able to see if another application has been installed.
One option would be to load your profile in a web view and then at least they can get to your profile. | For anyone who stumbles upon this page and still wants further clarification, you can use an if/else statement.
```
if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"twitter:@user"]])
{
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"twitter:@user"]];
}
else
{
webVie... |
46,095,787 | ```
using namespace std;
template <typename T>
void add(linked<T> &list1,ifstream& myFile){
string a;
while(!myFile.eof()){
myFile >> a;
T car1;
car1.setName(a);
T& car2 = car1;
list1.addtolist(car2);
}
}
int main(){
linked<car> list1;
ifstream myFile;
myFile.open("car.txt... | 2017/09/07 | [
"https://Stackoverflow.com/questions/46095787",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8285107/"
] | Provide overloads:
```
std::istream& operator >> (std::istream& is, Car& car)
{
std::string s;
is >> s;
car.setName(s);
return is;
}
std::istream& operator >> (std::istream& is, Bus& bus)
{
std::string s;
std::string s2;
is >> s >> s2;
bus.setName(s);
bus.setProperty(s2);
retur... | Create a template initialize function
```
template<typename T>
T CreateFromFileStream(ifstream& myFile);
template<>
car CreateFromFileStream(ifstream& myFile)
{
std::string a;
myFile >> a;
car myCar;
myCar.setName(a);
return myCar;
}
template<>
bus CreateFromFileStream(ifstream& myFile)
{
...
}
template... |
17,105,898 | I am developing MVC application.
I am trying to build the project by model first technique.
I have created the three class.
1. Company - Base/Parent class.
2. Customer - Child class inherited from Company class.
3. Party class - Child class inherited from Company class.
now while generating the DB , it creates three... | 2013/06/14 | [
"https://Stackoverflow.com/questions/17105898",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1650894/"
] | I think you need an `INNER JOIN` rather than a `LEFT JOIN` query
```
SELECT *, `users`.`id` as user_id
FROM (`users`)
INNER JOIN `user_profile`
ON `user_profile`.`user_id` = `users`.`id`
INNER JOIN `user_image_profile`
ON `user_image_profile`.`user_id` = `users`.`id`
ORDER BY `users`.`created` desc LIMIT 12
`... | Add in query
```
GROUP BY `users`.`id`
``` |
320,465 | What specifications do I need to look for in a class D vehicle amplifier so that I can run it for 8 hours using an 18V 5Ah rechargeable tool battery.
I need to operate the amplifier at full power for 8 hours.
What power rating could I hope to support? | 2017/07/25 | [
"https://electronics.stackexchange.com/questions/320465",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/158035/"
] | Ah / A = Time in hours, so choose a power amp, find out its current draw in amps and plug in the numbers...
You can also do Ah / hours = amps which gives 5 (Ah) / 8 (hours) = 0.625 amps to run your power amplifier, a small one then.
Note I ignored the voltage difference and also that you probably won't get the full s... | 18v \* 5ah = 90 Wh (this is the energy you got)
90 Wh / 8h = 11.25W (this is the max power you can draw for 8 hours)
You need an efficient amplifier, so it will be class D.
Suppose 90% efficiency. I'd go with a 10W class D amp, allowing a bit of headroom. |
64,752,741 | it doesn't count the second number entered by the user. I tried other things but still can get to it.
```
Scanner in = new Scanner(System.in);
int count = 0;
int num = in.nextInt();
int num2 = in.nextInt();
if (num > 0){
count++;
}
else if (num2 > 0){
count++;
}
Sy... | 2020/11/09 | [
"https://Stackoverflow.com/questions/64752741",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14574428/"
] | ```
if (num > 0){
count++;
}
else if (num2 > 0){
count++;
}
```
is about equivalent to (perhaps, it will make it clearer for you)
```
if (num > 0){
count++;
}
else {
// this block is entered only if "num <= 0"!
if (num2 > 0){
count++;
}
}
```
So, if your first test passes, the secon... | to check and count each number separately you need to define condition for each variable:
```
if (num > 0) {
count++;
}
if (num2 > 0) {
count++;
}
```
and you can abbreviate it much better like:
```
count += num > 0 ? 1 : 0;
count += num2 > 0 ? 1 : 0;
``` |
16,672,603 | I have the following code:
(Meeting beeing the exchange appointment)
```
For Each Recipient As String In emailAdresses
For i As Integer = 0 To Meeting.RequiredAttendees.Count - 1
If (Meeting.RequiredAttendees(i).Address).ToUpper() = Recipient.ToUpper() Then
Meeting.RequiredAttendees.RemoveAt(... | 2013/05/21 | [
"https://Stackoverflow.com/questions/16672603",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1801412/"
] | Doing:
```
Meeting.Update(ConflictResolutionMode.NeverOverwrite, SendInvitationsOrCancellationsMode.SendOnlyToChanged)
```
Instead of:
```
Meeting.Update(ConflictResolutionMode.AutoResolve, SendInvitationsOrCancellationsMode.SendOnlyToChanged)
```
Solved my problem, I do not know why and what it was having troubl... | Using `ConflictResolutionMode.AutoResolve` instead of `ConflictResolutionMode.NeverOverwrite` did not work for me. After some research, I found out that this is the normal behaviour.
The [`SendInvitationsOrCancellationsMode`](https://msdn.microsoft.com/en-us/library/microsoft.exchange.webservices.data.sendinvitations... |
28,924,227 | How can I use Bokeh's Area to plot between two y-values to represent an error? (e.g. like fill\_between in matplotlib) | 2015/03/08 | [
"https://Stackoverflow.com/questions/28924227",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2424587/"
] | The variable `add` stars out with the value 5 and `*mem` starts out with `1`.
The `lock xadd %0, (%1)` assembly template gets compiled by gcc to:
```
lock xadd %eax, (%edx)
```
GCC has to use `eax` because your constraints indicate that `%0` should use `%eax`. Your constraint also ties `%eax` to the variable `add`.... | In x86, **XADD** is the [Exchange and Add](http://x86.renejeschke.de/html/file_module_x86_id_327.html) instruction. So the register holding the `add` parameter became `1` after the `lock xadd` instruction. `add` is then returned by `atomic_add()` thus you see `1` printed instead of `5`.
For `atomic_add()` you probably... |
70,434,658 | I want to generate a group id, based on combinations of two variables (country and party). This is my data:
```
df <- data.frame(country = c("BE", "BE", "BE", "NL", "NL", "NL"),
year = c(2010, 2010, 2010, 2010, 2010, 2010),
party = c(NA, NA, NA, "A", "B", "B"))
```
Which gives:
``... | 2021/12/21 | [
"https://Stackoverflow.com/questions/70434658",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13339640/"
] | Helped by [this example](http://docs.locust.io/en/stable/testing-other-systems.html) in the official docs and Cyberwiz's answer, I created this bare-bones solution for my specific problem.
```python
import time
import boto3
from locust import User, task, constant, events
class BotoClient:
def __init__(self):
... | The changes needed to adapt the code to version 1+ of Locust are very small.
Quoting the documentation changelog:
```
Locust class renamed to User
We’ve renamed the Locust and HttpLocust classes to User and HttpUser. The locust attribute on TaskSet instances has been renamed to user.
``` |
5,032,124 | I am trying to follow this [blog](http://dalelane.co.uk/blog/?p=1599) for building push services for iPhone. The blog uses Android as the working platform,but it can be migrated to iPhone too, provided I get an MQTT client in objective C..which I cant find anywhere. The closest I got to this is :
1. I got a C implemen... | 2011/02/17 | [
"https://Stackoverflow.com/questions/5032124",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/430720/"
] | The HTTP option would not help you in this case as you're not trying to talk to a JMS app via MQ (well - you haven't said that is your goal). Your best bet would be to compile something like libmosquitto or one of the other MQTT clients (see list at <http://mqtt.org>) for the iPhone. There's now a good example <https:/... | I'm not familiar with Objective C at all, but it seems as though you can compile any C code as Objective C. Would this get round your problem?
If you're using gcc, you can force it to compile as Objective C using "-x objective-c". |
5,032,124 | I am trying to follow this [blog](http://dalelane.co.uk/blog/?p=1599) for building push services for iPhone. The blog uses Android as the working platform,but it can be migrated to iPhone too, provided I get an MQTT client in objective C..which I cant find anywhere. The closest I got to this is :
1. I got a C implemen... | 2011/02/17 | [
"https://Stackoverflow.com/questions/5032124",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/430720/"
] | I'm not familiar with Objective C at all, but it seems as though you can compile any C code as Objective C. Would this get round your problem?
If you're using gcc, you can force it to compile as Objective C using "-x objective-c". | I am currently using [MQTTKit](https://github.com/mobile-web-messaging/MQTTKit) in my projects. It's fairly easy and straightforward to use. |
5,032,124 | I am trying to follow this [blog](http://dalelane.co.uk/blog/?p=1599) for building push services for iPhone. The blog uses Android as the working platform,but it can be migrated to iPhone too, provided I get an MQTT client in objective C..which I cant find anywhere. The closest I got to this is :
1. I got a C implemen... | 2011/02/17 | [
"https://Stackoverflow.com/questions/5032124",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/430720/"
] | I'm not familiar with Objective C at all, but it seems as though you can compile any C code as Objective C. Would this get round your problem?
If you're using gcc, you can force it to compile as Objective C using "-x objective-c". | For swift you can use the following library : <https://github.com/ltg-uic/ios-mqtt-base> |
5,032,124 | I am trying to follow this [blog](http://dalelane.co.uk/blog/?p=1599) for building push services for iPhone. The blog uses Android as the working platform,but it can be migrated to iPhone too, provided I get an MQTT client in objective C..which I cant find anywhere. The closest I got to this is :
1. I got a C implemen... | 2011/02/17 | [
"https://Stackoverflow.com/questions/5032124",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/430720/"
] | The HTTP option would not help you in this case as you're not trying to talk to a JMS app via MQ (well - you haven't said that is your goal). Your best bet would be to compile something like libmosquitto or one of the other MQTT clients (see list at <http://mqtt.org>) for the iPhone. There's now a good example <https:/... | I am currently using [MQTTKit](https://github.com/mobile-web-messaging/MQTTKit) in my projects. It's fairly easy and straightforward to use. |
5,032,124 | I am trying to follow this [blog](http://dalelane.co.uk/blog/?p=1599) for building push services for iPhone. The blog uses Android as the working platform,but it can be migrated to iPhone too, provided I get an MQTT client in objective C..which I cant find anywhere. The closest I got to this is :
1. I got a C implemen... | 2011/02/17 | [
"https://Stackoverflow.com/questions/5032124",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/430720/"
] | The HTTP option would not help you in this case as you're not trying to talk to a JMS app via MQ (well - you haven't said that is your goal). Your best bet would be to compile something like libmosquitto or one of the other MQTT clients (see list at <http://mqtt.org>) for the iPhone. There's now a good example <https:/... | For swift you can use the following library : <https://github.com/ltg-uic/ios-mqtt-base> |
5,032,124 | I am trying to follow this [blog](http://dalelane.co.uk/blog/?p=1599) for building push services for iPhone. The blog uses Android as the working platform,but it can be migrated to iPhone too, provided I get an MQTT client in objective C..which I cant find anywhere. The closest I got to this is :
1. I got a C implemen... | 2011/02/17 | [
"https://Stackoverflow.com/questions/5032124",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/430720/"
] | I am currently using [MQTTKit](https://github.com/mobile-web-messaging/MQTTKit) in my projects. It's fairly easy and straightforward to use. | For swift you can use the following library : <https://github.com/ltg-uic/ios-mqtt-base> |
32,511,027 | I am setting up a site with silex and I am sure this is a n00b question. I have my htaccess set up (per the silex recommendation) to redirect to my home page if a url does not exist.
```
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteBase /home
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ ... | 2015/09/10 | [
"https://Stackoverflow.com/questions/32511027",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5322689/"
] | The route is
```
$app->get('/mysite/api/v1/users/{userid}', function (Silex\Application $app, $userid) use ($users) {
}
```
The RewriteBase must be the path to the site root, relative to document root. | I ran your code in my Silex app and it seems to work fine.
I think you may be using multiple front controllers (multiple index.php files). This may be possible to accomplish but it goes against the usual [MVC single entry point](https://stackoverflow.com/a/5596774/1814739) concept. Let me know if I'm wrong about the m... |
4,480,208 | Consider the following code, or any variations upon it:
`string = "www.google.com/test/test.html`
or
`string = "www.stackoverflow.com/test/test.html`
---
How would i make it so i strip out the first part of the URL `www.google.com` JUST to `/test/test.html? This would have to be universal, so if they were to enter AN... | 2010/12/18 | [
"https://Stackoverflow.com/questions/4480208",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/451711/"
] | <http://ruby-doc.org/core/classes/URI/Generic.html#M004891> | I just going through ruby. I can get it as an array for you. Here is my thinking...
string=www.google.com/test/test.html
Interested part is /test/test.html
not interested part is www.google.com
.com looks as a separator here to me. Therefore,
**string=string.split{'.com') #step 1**
This gives an array of size 2.
... |
39,059,757 | I followed come tutorials about building my apk file.
I can generate the debug apk file, but not the release one.
But, when I try to generate a signed apk, i get the following error message:
>
> Error:(53, 19) No resource found that matches the given name (at
> 'menu' with value '@menu/activity\_main\_drawer').
>
... | 2016/08/21 | [
"https://Stackoverflow.com/questions/39059757",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2093013/"
] | Switch from Android view to Project view. Navigate to
>
> app --> src --> debug --> res --> menu
>
>
>
. Move your activity\_main\_drawer.xml file from this location to
>
> app --> src --> main --> res --> menu
>
>
>
.
In your current setup you have your resource files setup for debug build and not commo... | ```
release {
lintOptions {
checkReleaseBuilds false
disable 'MissingTranslation'
}
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
``` |
35,926,023 | I am using angular2-seed, which I love. I am trying to add the `moment.js` library, but I would like to use it's d.ts file. I tried to run `typings install...` but that didn't seem to work. I noticed a folder `\tools\manual_typings\project`. Do I just add d.ts file there? Should I also run typinds install? | 2016/03/10 | [
"https://Stackoverflow.com/questions/35926023",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2904713/"
] | Firstly:
```
npm install tsd -g
```
Then:
```
tsd install moment
``` | Use:
```
typings install moment --ambient
``` |
35,926,023 | I am using angular2-seed, which I love. I am trying to add the `moment.js` library, but I would like to use it's d.ts file. I tried to run `typings install...` but that didn't seem to work. I noticed a folder `\tools\manual_typings\project`. Do I just add d.ts file there? Should I also run typinds install? | 2016/03/10 | [
"https://Stackoverflow.com/questions/35926023",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2904713/"
] | Firstly:
```
npm install tsd -g
```
Then:
```
tsd install moment
``` | I followed the example in [angular2-seed-example-mashup](https://github.com/AngularShowcase/angular2-seed-example-mashup) and, with some minor changes, made it work.
Add this to typings.json
```
"dependencies": {
"moment": "github:typed-typings/npm-moment#a4075cd50e63efbedd850f654594f293ab81a385",
```
Then go ... |
35,367,760 | Using Telerik DataAccess, i have a Numeric(1,0) Field on my Database called chkSomething which was historically used to determine the state of a checkbox (you know, the tristate one)
```
0 - Unchecked
1 - Checked
2 - Neither Checked nor Unchecked
```
But the Kendo Checkbox is only a 2-State checkbox. So i thought i ... | 2016/02/12 | [
"https://Stackoverflow.com/questions/35367760",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5724010/"
] | Just override the `buildScale` method to mess around with the scale object once its created.
---
**Preview**
[](https://i.stack.imgur.com/bILl2.png)
---
**Script**
```
Chart.types.HorizontalBar.extend({
name: "HorizontalBarAlt",
initialize: ... | You can set it inside options object.
```
var options =
{
scales:
{
yAxes: [
{
barPercentage: 0.3
}]
}
}
``` |
50,935,730 | So it appears with the advent of ASP.NET Core 2.1, Kestrel now automatically creates an HTTPS endpoint along side the HTTP one, and default project templates are setup to redirect from HTTP to HTTPS (which is easy enough to undo).
However my question is... how can I disable HTTPS entirely for my project. I've read thr... | 2018/06/19 | [
"https://Stackoverflow.com/questions/50935730",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3022291/"
] | The `dotnet` CLI now has a template for this.
```
dotnet new webapi --no-https
``` | @joanlofe answer is excellent one, but there is also "stupid" way how one can reintroduce HTTPS on 5001 port. If you call `Clear` on your config sources (for proper layering of config sources for example) it means that one implicit source is gone -- "launchSettings.json" template. So if you rely on this file instead of... |
50,935,730 | So it appears with the advent of ASP.NET Core 2.1, Kestrel now automatically creates an HTTPS endpoint along side the HTTP one, and default project templates are setup to redirect from HTTP to HTTPS (which is easy enough to undo).
However my question is... how can I disable HTTPS entirely for my project. I've read thr... | 2018/06/19 | [
"https://Stackoverflow.com/questions/50935730",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3022291/"
] | One more way for disabling https epecially is handy when docker is used.
Set enviroment variable in Dockerfile with only one HTTP url in value.
```
#https + http
ENV ASPNETCORE_URLS=http://+:5001;http://+:5000
```
```
#http only
ENV ASPNETCORE_URLS=http://+:5000
``` | @joanlofe answer is excellent one, but there is also "stupid" way how one can reintroduce HTTPS on 5001 port. If you call `Clear` on your config sources (for proper layering of config sources for example) it means that one implicit source is gone -- "launchSettings.json" template. So if you rely on this file instead of... |
50,935,730 | So it appears with the advent of ASP.NET Core 2.1, Kestrel now automatically creates an HTTPS endpoint along side the HTTP one, and default project templates are setup to redirect from HTTP to HTTPS (which is easy enough to undo).
However my question is... how can I disable HTTPS entirely for my project. I've read thr... | 2018/06/19 | [
"https://Stackoverflow.com/questions/50935730",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3022291/"
] | With ASPNET CORE 2.2, I simply set the web server URL to http not https and it picks it up on its own. I run it as a self hosted process.
1. Go to your project properties.
2. Click on the Debug tab.
3. Under Web Server Settings, set the URL to <http://xxx>
4. Try again :) | For Development & not in production:
[](https://i.stack.imgur.com/Uk5Vo.png)
in project properties disable Enable SSL |
50,935,730 | So it appears with the advent of ASP.NET Core 2.1, Kestrel now automatically creates an HTTPS endpoint along side the HTTP one, and default project templates are setup to redirect from HTTP to HTTPS (which is easy enough to undo).
However my question is... how can I disable HTTPS entirely for my project. I've read thr... | 2018/06/19 | [
"https://Stackoverflow.com/questions/50935730",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3022291/"
] | In the Startup.cs, remove the middleware
```
app.UseHttpsRedirection();
``` | **Turning off https** lies in these 3 changes...
**Properties/launchSettings.json**
* set *sslPort* to 0
* remove the https url from the *applicationUrl*

**Startup.cs**
* Remove or comment-out *app.UseHttpsRedirection()*
.
However my question is... how can I disable HTTPS entirely for my project. I've read thr... | 2018/06/19 | [
"https://Stackoverflow.com/questions/50935730",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3022291/"
] | In the Program.cs, Add UseUrls as following:
```
WebHost.CreateDefaultBuilder(args)
.UseUrls("http://localhost:5000")
.UseStartup<Startup>();
```
And In The Startup.cs remove/comment the following:
```
app.UseHttpsRedirection();
``` | With ASPNET CORE 2.2, I simply set the web server URL to http not https and it picks it up on its own. I run it as a self hosted process.
1. Go to your project properties.
2. Click on the Debug tab.
3. Under Web Server Settings, set the URL to <http://xxx>
4. Try again :) |
50,935,730 | So it appears with the advent of ASP.NET Core 2.1, Kestrel now automatically creates an HTTPS endpoint along side the HTTP one, and default project templates are setup to redirect from HTTP to HTTPS (which is easy enough to undo).
However my question is... how can I disable HTTPS entirely for my project. I've read thr... | 2018/06/19 | [
"https://Stackoverflow.com/questions/50935730",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3022291/"
] | The `dotnet` CLI now has a template for this.
```
dotnet new webapi --no-https
``` | One more way for disabling https epecially is handy when docker is used.
Set enviroment variable in Dockerfile with only one HTTP url in value.
```
#https + http
ENV ASPNETCORE_URLS=http://+:5001;http://+:5000
```
```
#http only
ENV ASPNETCORE_URLS=http://+:5000
``` |
50,935,730 | So it appears with the advent of ASP.NET Core 2.1, Kestrel now automatically creates an HTTPS endpoint along side the HTTP one, and default project templates are setup to redirect from HTTP to HTTPS (which is easy enough to undo).
However my question is... how can I disable HTTPS entirely for my project. I've read thr... | 2018/06/19 | [
"https://Stackoverflow.com/questions/50935730",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3022291/"
] | Turns out the proper way to achieve what I wanted to do, was to specifically configure Kestrel with .UseKestrel() and simply specify a single address, like this:
```
WebHost.CreateDefaultBuilder(args)
.UseKestrel(options => {
if (context.Configuration[WebHostDefaults.EnvironmentKey] == Environments.Develop... | @joanlofe answer is excellent one, but there is also "stupid" way how one can reintroduce HTTPS on 5001 port. If you call `Clear` on your config sources (for proper layering of config sources for example) it means that one implicit source is gone -- "launchSettings.json" template. So if you rely on this file instead of... |
50,935,730 | So it appears with the advent of ASP.NET Core 2.1, Kestrel now automatically creates an HTTPS endpoint along side the HTTP one, and default project templates are setup to redirect from HTTP to HTTPS (which is easy enough to undo).
However my question is... how can I disable HTTPS entirely for my project. I've read thr... | 2018/06/19 | [
"https://Stackoverflow.com/questions/50935730",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3022291/"
] | Turns out the proper way to achieve what I wanted to do, was to specifically configure Kestrel with .UseKestrel() and simply specify a single address, like this:
```
WebHost.CreateDefaultBuilder(args)
.UseKestrel(options => {
if (context.Configuration[WebHostDefaults.EnvironmentKey] == Environments.Develop... | One more way for disabling https epecially is handy when docker is used.
Set enviroment variable in Dockerfile with only one HTTP url in value.
```
#https + http
ENV ASPNETCORE_URLS=http://+:5001;http://+:5000
```
```
#http only
ENV ASPNETCORE_URLS=http://+:5000
``` |
50,935,730 | So it appears with the advent of ASP.NET Core 2.1, Kestrel now automatically creates an HTTPS endpoint along side the HTTP one, and default project templates are setup to redirect from HTTP to HTTPS (which is easy enough to undo).
However my question is... how can I disable HTTPS entirely for my project. I've read thr... | 2018/06/19 | [
"https://Stackoverflow.com/questions/50935730",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3022291/"
] | In the Startup.cs, remove the middleware
```
app.UseHttpsRedirection();
``` | If you are using Visual Studio 2017, then you can do the following:
1. Go to your project properties. (Right-click > Properties)
2. Click on the Debug tab.
3. Under Web Server Settings, deselect Enable SSL.
4. Save, build, and try again.
This will update the iisExpress settings in the launchSettings.json file. |
50,935,730 | So it appears with the advent of ASP.NET Core 2.1, Kestrel now automatically creates an HTTPS endpoint along side the HTTP one, and default project templates are setup to redirect from HTTP to HTTPS (which is easy enough to undo).
However my question is... how can I disable HTTPS entirely for my project. I've read thr... | 2018/06/19 | [
"https://Stackoverflow.com/questions/50935730",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3022291/"
] | If you are using Visual Studio 2017, then you can do the following:
1. Go to your project properties. (Right-click > Properties)
2. Click on the Debug tab.
3. Under Web Server Settings, deselect Enable SSL.
4. Save, build, and try again.
This will update the iisExpress settings in the launchSettings.json file. | One more way for disabling https epecially is handy when docker is used.
Set enviroment variable in Dockerfile with only one HTTP url in value.
```
#https + http
ENV ASPNETCORE_URLS=http://+:5001;http://+:5000
```
```
#http only
ENV ASPNETCORE_URLS=http://+:5000
``` |
30,375,949 | Assume you imported a package, say unittest2
if you were using Windows IDLE, if you press:
unittest2.
a small help window will pop up and show the list of functions you can use, similarly how can I get this small pop up on linux ?
Am accessing a linux box from putty | 2015/05/21 | [
"https://Stackoverflow.com/questions/30375949",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1056464/"
] | After a couple of weeks I got back to the problem and found the solution. The problem was - of course - in configuration and had nothing in common with the particular version of Wildfly. Mode specifically:
There were three nodes in the domain and three servers in each node. All nodes were launched with the following p... | There is no need for any unnecessary effort or uneasiness about static proxy configuration. Each WildFly distribution comes with xsd sheets that describe xml subsystem configuration. For instance, with WildFly 9x, it's:
```
WILDFLY_DIRECTORY/docs/schema/jboss-as-mod-cluster_2_0.xsd
```
It says:
```
<xs:attribute na... |
30,375,949 | Assume you imported a package, say unittest2
if you were using Windows IDLE, if you press:
unittest2.
a small help window will pop up and show the list of functions you can use, similarly how can I get this small pop up on linux ?
Am accessing a linux box from putty | 2015/05/21 | [
"https://Stackoverflow.com/questions/30375949",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1056464/"
] | After a couple of weeks I got back to the problem and found the solution. The problem was - of course - in configuration and had nothing in common with the particular version of Wildfly. Mode specifically:
There were three nodes in the domain and three servers in each node. All nodes were launched with the following p... | I ran into the Node Removed issue to.
I managed to solve it by using the following as instance-id
```
<subsystem xmlns="urn:jboss:domain:undertow:2.0" instance-id="${jboss.server.name}">
```
I hope this will help someone else to ;) |
74,959 | I signed a contract with my employer stating that for any and all reasons I am not working at that company before 2 years, I have to pay back x amount of dollars for the cost of training. Now this wasn't a small sum of money, but I got fired for reasons unknown (lack of "performance"). Is this common practice (and/or l... | 2016/08/27 | [
"https://workplace.stackexchange.com/questions/74959",
"https://workplace.stackexchange.com",
"https://workplace.stackexchange.com/users/56787/"
] | This site cannot speak to whether or not this is a legal practice.
I do know of at least one time this has happened in Ohio -- a person was let go, changed jobs, and the person's original employer wanted the person (or new employer) to pay for the training.
Asking employees to pay for training when they voluntarily l... | A regular search, <https://www.google.com/?ion=1&espv=2#q=recoup+training+costs+employee+after+firing+them+ohio> might help you a little bit.
It appears that the answer is - it depends.
Most of the info is directed at employees who leave voluntarily.
Did you know that a fired employee can sue for wrongful termi... |
74,959 | I signed a contract with my employer stating that for any and all reasons I am not working at that company before 2 years, I have to pay back x amount of dollars for the cost of training. Now this wasn't a small sum of money, but I got fired for reasons unknown (lack of "performance"). Is this common practice (and/or l... | 2016/08/27 | [
"https://workplace.stackexchange.com/questions/74959",
"https://workplace.stackexchange.com",
"https://workplace.stackexchange.com/users/56787/"
] | This site cannot speak to whether or not this is a legal practice.
I do know of at least one time this has happened in Ohio -- a person was let go, changed jobs, and the person's original employer wanted the person (or new employer) to pay for the training.
Asking employees to pay for training when they voluntarily l... | You'd need to ask a lawyer about the legality. I have seen a lot of strange things in contracts and normally it's best to abide by them.
However once I leave a job I ignore anything the employer threatens me with. The last couple had sour grapes since many of their clients followed me out. Legal action is a costly exe... |
74,959 | I signed a contract with my employer stating that for any and all reasons I am not working at that company before 2 years, I have to pay back x amount of dollars for the cost of training. Now this wasn't a small sum of money, but I got fired for reasons unknown (lack of "performance"). Is this common practice (and/or l... | 2016/08/27 | [
"https://workplace.stackexchange.com/questions/74959",
"https://workplace.stackexchange.com",
"https://workplace.stackexchange.com/users/56787/"
] | You'd need to ask a lawyer about the legality. I have seen a lot of strange things in contracts and normally it's best to abide by them.
However once I leave a job I ignore anything the employer threatens me with. The last couple had sour grapes since many of their clients followed me out. Legal action is a costly exe... | A regular search, <https://www.google.com/?ion=1&espv=2#q=recoup+training+costs+employee+after+firing+them+ohio> might help you a little bit.
It appears that the answer is - it depends.
Most of the info is directed at employees who leave voluntarily.
Did you know that a fired employee can sue for wrongful termi... |
62,053,083 | I have the following program:
```
#include <vector>
struct Comp1
{
float x;
std::vector<int> vec;
};
int main()
{
std::vector<char> data;
data.resize(sizeof(Comp1));
Comp1* ptr1 = new (&data[0]) Comp1({.3f,{3,4,2,1}});
data.resize(sizeof(Comp1)*2);
Comp1* ptr2 = new (&data[sizeof(Comp... | 2020/05/27 | [
"https://Stackoverflow.com/questions/62053083",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1862823/"
] | In your code you do
```
data.resize(sizeof(Comp1)*2);
```
which is a modification event of the storage the vector uses. When that happens, all pointers, iterators, and references into the vector are invalidated. That means
```
ptr1->~Comp1();
```
is accessing an invalid object and you have undefined behavior. Thi... | (Too long for a comment.)
If you want the backing store buffer of the in-place constructed objects not to move around, you can use a vector of vector of bytes. If you want consecutive memory though (say, for cache locality), this won't work.
```
#include <vector>
using std::vector;
struct Comp1 {
float x;
v... |
7,776 | If you are supposed to do UX design estimate, and you need to measure it based on "Simple, Medium and Complex", how do you classify the Simple, Medium and Complex screen design?
What are all the factors that you will consider to define a screen complexity, like number of screen elements, form elements, data structures... | 2011/05/31 | [
"https://ux.stackexchange.com/questions/7776",
"https://ux.stackexchange.com",
"https://ux.stackexchange.com/users/5716/"
] | It would be the most important to take into account how much the applications or site offers in terms of functionality. Most great UX can be made to look simple or effortless, when in fact these solutions are often the ones that are the hardest to arrive at. Find out from the client exactly what the interface has to do... | **Ask questions** until you know enough that you can qualify the project as taking "a long time", "not that long" and "not long at all". It's not as simple as looking at the number of elements on a screen.
Here are some questions I tend to ask clients when they approach us:
* **Who is the target audience?** - so we k... |
7,776 | If you are supposed to do UX design estimate, and you need to measure it based on "Simple, Medium and Complex", how do you classify the Simple, Medium and Complex screen design?
What are all the factors that you will consider to define a screen complexity, like number of screen elements, form elements, data structures... | 2011/05/31 | [
"https://ux.stackexchange.com/questions/7776",
"https://ux.stackexchange.com",
"https://ux.stackexchange.com/users/5716/"
] | It would be the most important to take into account how much the applications or site offers in terms of functionality. Most great UX can be made to look simple or effortless, when in fact these solutions are often the ones that are the hardest to arrive at. Find out from the client exactly what the interface has to do... | You are right, that is hard to pin down.
We could create a formula to calculate the complexity of a UX design.
First, lets list all the factors:
1. (F) Functionality, each function in the design multiplies the work
2. (P) Platforms, reworking the UX for a new screensize or platform also multiplies the work
3. (N) T... |
33,168,544 | I'm starting now with C++, so I imagine this is gonna be a very easy-newbie question.
Well, why the "cin >> x" line inside while doesn't stop the loop to get the user input (if the user inputs a character, in place of a number)?
```
#include <iostream>
using std::cin;
using std::cout;
using std::endl;
int main()
{
... | 2015/10/16 | [
"https://Stackoverflow.com/questions/33168544",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3116664/"
] | Well, your program should be corrected slightly
```
#include <iostream>
using std::cin;
using std::cout;
using std::endl;
int main()
{
int x = 0;
cout << "Please, enter x: ";
cin >> x;
while (!cin)
{
cin.clear();
cin.ignore(10000, '\n');
cout << "Please, it must be a number... | if user input a character than it will take the ascii value of character so it will not stop.
To stop the loop enter 0. |
73,412,881 | Given a dataframe, how do I calculate the probability of consecutive events using python pandas?
For example,
| Time | A | B | C |
| --- | --- | --- | --- |
| 1 | 1 | 1 | 1 |
| 2 | -1 | -1 | -1 |
| 3 | 1 | 1 | 1 |
| 4 | -1 | -1 | -1 |
| 5 | 1 | 1 | 1 |
| 6 | -1 | -1 | -1 |
| 7 | 1 | 1 | 1 |
| 8 | -1 | 1 | 1 |
| 9 | 1... | 2022/08/19 | [
"https://Stackoverflow.com/questions/73412881",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19799730/"
] | If you read the documentation a bit further, you'll see that constraint arguments on the `Container` itself will override this behavior:
>
> Containers with no children try to be as big as possible unless the incoming constraints are unbounded, in which case they try to be as small as possible. Containers with childr... | Although red container has infinite size, You put it in a scaffold's body which has specific size. so your red container get specific size then your grin container with no child get size as much as its parents. |
73,412,881 | Given a dataframe, how do I calculate the probability of consecutive events using python pandas?
For example,
| Time | A | B | C |
| --- | --- | --- | --- |
| 1 | 1 | 1 | 1 |
| 2 | -1 | -1 | -1 |
| 3 | 1 | 1 | 1 |
| 4 | -1 | -1 | -1 |
| 5 | 1 | 1 | 1 |
| 6 | -1 | -1 | -1 |
| 7 | 1 | 1 | 1 |
| 8 | -1 | 1 | 1 |
| 9 | 1... | 2022/08/19 | [
"https://Stackoverflow.com/questions/73412881",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19799730/"
] | If you read the documentation a bit further, you'll see that constraint arguments on the `Container` itself will override this behavior:
>
> Containers with no children try to be as big as possible unless the incoming constraints are unbounded, in which case they try to be as small as possible. Containers with childr... | The red `container` actually will has size as small as posibble depends its child.
the green container has no child, then as the documentation said it will try to be as big as possible unless the incoming constraints are unbounded,
if you change the child , like Text widget, or Column, or other widget, it will not ge... |
73,412,881 | Given a dataframe, how do I calculate the probability of consecutive events using python pandas?
For example,
| Time | A | B | C |
| --- | --- | --- | --- |
| 1 | 1 | 1 | 1 |
| 2 | -1 | -1 | -1 |
| 3 | 1 | 1 | 1 |
| 4 | -1 | -1 | -1 |
| 5 | 1 | 1 | 1 |
| 6 | -1 | -1 | -1 |
| 7 | 1 | 1 | 1 |
| 8 | -1 | 1 | 1 |
| 9 | 1... | 2022/08/19 | [
"https://Stackoverflow.com/questions/73412881",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19799730/"
] | Although red container has infinite size, You put it in a scaffold's body which has specific size. so your red container get specific size then your grin container with no child get size as much as its parents. | The red `container` actually will has size as small as posibble depends its child.
the green container has no child, then as the documentation said it will try to be as big as possible unless the incoming constraints are unbounded,
if you change the child , like Text widget, or Column, or other widget, it will not ge... |
67,696,508 | This was working fine till yesterday with keras 2.2.4, i did train a model too so today i had to restart the runtime and i had to downgrade keras to 2.2.4 and when I import keras I get an error.
my tensorflow ver-2.5.0
```
pip install keras==2.2.4
```
*
```
import keras
```
The error I get
```
Using TensorFlow... | 2021/05/25 | [
"https://Stackoverflow.com/questions/67696508",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10346410/"
] | Perhaps something like this
```
Declare @YourTable table (Name varchar(50),Balance money)
Insert Into @YourTable values
('A',15000)
,('B',25360)
,('C',1255555)
,('D',945)
Select *
,Formated =coalesce(
left(nullIf( convert(int,Balance) / 1000000000 ,0),3)+'B'
... | You can use arithmetic and string operations:
```
select concat( floor(balance / 1000), 'K')
```
You could make this conditional as well:
```
select (case when balance < 1000 then cast(balance as varchar(255))
when balance < 1000000 then concat( floor(balance / 1000), 'K')
else concat( flo... |
7,705,752 | As I was developing something, I wondered what might be the better/faster approach to create a bunch of objects while iterating over something.
Lets say we have this wrapper-class:
```
public class Photo{
private String url;
private String creator;
public Photo(String url, String creator){
this.u... | 2011/10/09 | [
"https://Stackoverflow.com/questions/7705752",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/717341/"
] | The two first methods are similar. Introduce variables if you feel it's more readable and maintainable. The last one makes the `Photo` class mutable whereas it was immutable in the first two methods (not in the strictest meaning used in concurrency, though).
You should always favor immutability when possible, mainly ... | The difference in speed is negligible between the solutions you've provided for the code you're looking at here. Readability is actually more important than one might think. Is it more important to you that your end-users experience a 1% speed increase? Or that you will be able to maintain this code in future versions?... |
784,599 | I've got a Ubuntu 16.04 box on an Intel NUC for HTPC purposes (running Kodi). Most of the time it's outputting audio to the TV via HDMI (one day will be via a receiver) however occasionally I'd like to output audio to my Bluetooth headphones to avoid bothering others. The box does not have a GUI installed on it and I'd... | 2016/06/08 | [
"https://askubuntu.com/questions/784599",
"https://askubuntu.com",
"https://askubuntu.com/users/488044/"
] | In order to fix this, you can either reinstall `sudo`, or download a default `/etc/sudoers` and edit it. Both ways require these steps: First, restart your computer. When the Grub screen displays, instead of choosing `Ubuntu xxx`, choose `Advanced options for Ubuntu xxx`. Under `Advanced Options`, choose `Recovery mode... | You obviously can access the internet on another machine because you posted this question. You can create an Ubuntu live CD, boot into it, and fix `sudo` with the following steps. Mount the partitions of your installation to recreate the filesystem at `/mnt` (`sudo mount /dev/<whatever> /mnt`, `mkdir -p /mnt/home && su... |
5,306 | Quando descrevendo características físicas em perfis biográficos vez ou outra tenho certa dificuldade em nomear cores pouco específicas.
Por exemplo: **Laranja**. Quase todo mundo sabe qual é a cor da laranja, mas usado num contexto de descrição, pode talvez ficar confuso, afinal temos a laranja... laranja, madurinha ... | 2018/05/08 | [
"https://portuguese.stackexchange.com/questions/5306",
"https://portuguese.stackexchange.com",
"https://portuguese.stackexchange.com/users/1139/"
] | Se se trata de literatura, então o que pode funcionar em cada caso específico depende bastante do contexto e das escolhas artísticas do autor.
Numa ficção científica, por exemplo, se poderia talvez até mencionar um código numérico para a cor, como os dos links:
- "Pele: laranja, #ff7f00".
Outra opção é se estender... | As maçãs possuem diversas colorações, normalmente vermelhas. Dizer vermelho maçã provocaria dúvida. Agora, verde maçã já traz à mente aquele verde vivo único.
```
Olhos: verde maçã.
```
Perfeito e não traz redundância.
A descrição de características pode ser mais sutil, como "pele alaranjada", ... ao invés de "... |
22,071,804 | I have a set of K element and i need to create a combination of N ordered element.
For examle if K=1 and i have {X1, emptyset} and n = 2 then i have an ordered pair i need to make this:
**Example1:**
```
({},{})
({X1},{}), ({},{X1})
({X1},{X1})
```
Note that I need to get the element in this order: firs... | 2014/02/27 | [
"https://Stackoverflow.com/questions/22071804",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2898525/"
] | If you define `B` as a `cell` array makes more sense:
```
B = {'a' 'b' 'c' 'd' 'e'}
```
then assign empties like so:
```
>> B(A==0) = {''}
B =
'a' '' 'c' '' 'e'
``` | Use logical indexing
```
C = B( A == 1 )
``` |
466,296 | I have a the following message when i try to install windows 7 through an bootable USB..
>
> setup was unable to create a new system partition or locate an
> existing system partition
>
>
>
I will explain the things I did to my lenovo y500 laptop.The laptop was initially working with 2 os .. ubuntu linux and win... | 2012/08/25 | [
"https://superuser.com/questions/466296",
"https://superuser.com",
"https://superuser.com/users/152377/"
] | Assuming that your first partition is Windows 7 and the second is Windows 8, you can do this just using tools coming with Windows 7:
1. Boot Windows 7
2. Open the disk management
3. Simply delete the Windows 8 partition
4. Resize the Windows 7 partition to use the now available free space
However, if you have some pa... | I highly recommend [Gnome Partition Editor](http://gparted.sourceforge.net/).
It can perform actions with partitions such as:
* create or delete
* resize or move
* check
* label
* set new UUID
* copy and paste
Manipulate file systems such as:
* btrfs
* ext2 / ext3 / ext4
* fat16 / fat32
* hfs / hfs+
* linux-swap
* ... |
466,296 | I have a the following message when i try to install windows 7 through an bootable USB..
>
> setup was unable to create a new system partition or locate an
> existing system partition
>
>
>
I will explain the things I did to my lenovo y500 laptop.The laptop was initially working with 2 os .. ubuntu linux and win... | 2012/08/25 | [
"https://superuser.com/questions/466296",
"https://superuser.com",
"https://superuser.com/users/152377/"
] | Assuming that your first partition is Windows 7 and the second is Windows 8, you can do this just using tools coming with Windows 7:
1. Boot Windows 7
2. Open the disk management
3. Simply delete the Windows 8 partition
4. Resize the Windows 7 partition to use the now available free space
However, if you have some pa... | Simply delete the Windows 8 partition, set the Windows 7 partition to active, and reboot.
Some great programs that can easily do this for you
[gParted live cd](http://gparted.sourceforge.net/livecd.php)
[Norton Ghost](http://us.norton.com/ghost/)
[Acronis Disk Director](http://www.acronis.com/homecomputing/produ... |
51,882,030 | Hi EC2 instance is created, but commands as part of userdata.sh are not gettingexecuted. When I manually connect to EC2 via putty, i found that nginx is not installed in EC2 instance. To verify if the script is getting executed or not I added echo message, but no output is display in command prompt when i run terraform... | 2018/08/16 | [
"https://Stackoverflow.com/questions/51882030",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10194117/"
] | I could see one issue with the code you have posted, the user\_data variable should be like
```
user_data = "${data.template_file.user_data.rendered}"
```
Moreover, as a suggestion i will recommend you to try creating a log file in your script to check what all steps have been executed. It will also benefit you to k... | Why so comlicated?
```
user_data = file("user_data.sh")
```
This file must exist near other `tf.files` of the project.
That will be enough |
30,701,560 | I've read a lot about this issue.. (also read this: [Tables with no Primary Key](https://stackoverflow.com/questions/5600/tables-with-no-primary-key))
it seems like there is no reason to use tables with no PK. so why does PostgreSQL allows it? can you give an example when it's good idea to not indicate PK? | 2015/06/08 | [
"https://Stackoverflow.com/questions/30701560",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3540876/"
] | A primary key is a special form of a unique constraint. A unique constraint is always backed up by an index. And the disadvantage of an index is that it takes time to update. Tables with an index have lower `update`, `delete` and `insert` performance.
So if you have a table that has a lot of modifications, and few que... | AFAIK, the primary key is primarily needed for the relationships between tables as a foreign key. If you have a table that is not linked to anything you don't need a primary key. In Excel spreadsheets there're no primary keys but a spreadsheet is not a relational database. |
30,701,560 | I've read a lot about this issue.. (also read this: [Tables with no Primary Key](https://stackoverflow.com/questions/5600/tables-with-no-primary-key))
it seems like there is no reason to use tables with no PK. so why does PostgreSQL allows it? can you give an example when it's good idea to not indicate PK? | 2015/06/08 | [
"https://Stackoverflow.com/questions/30701560",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3540876/"
] | I think the answer to your question lies in trying to understand what are the drawbacks of having a Primary-Key (PK) in the first place.
One obvious 'drawback' (depending on how you see it) in maintaining a PK is that it has its own overhead during an `INSERT`. So, in order to increase `INSERT` performance (assuming f... | AFAIK, the primary key is primarily needed for the relationships between tables as a foreign key. If you have a table that is not linked to anything you don't need a primary key. In Excel spreadsheets there're no primary keys but a spreadsheet is not a relational database. |
30,701,560 | I've read a lot about this issue.. (also read this: [Tables with no Primary Key](https://stackoverflow.com/questions/5600/tables-with-no-primary-key))
it seems like there is no reason to use tables with no PK. so why does PostgreSQL allows it? can you give an example when it's good idea to not indicate PK? | 2015/06/08 | [
"https://Stackoverflow.com/questions/30701560",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3540876/"
] | I think the answer to your question lies in trying to understand what are the drawbacks of having a Primary-Key (PK) in the first place.
One obvious 'drawback' (depending on how you see it) in maintaining a PK is that it has its own overhead during an `INSERT`. So, in order to increase `INSERT` performance (assuming f... | A primary key is a special form of a unique constraint. A unique constraint is always backed up by an index. And the disadvantage of an index is that it takes time to update. Tables with an index have lower `update`, `delete` and `insert` performance.
So if you have a table that has a lot of modifications, and few que... |
2,954 | Suppose I have these two sets of data:
```
data1 = {{0, 0}, {5, 0}, {10, .1}, {15, .3}, {20, .7}, {25, 1}, {30, 1}};
data2 = {{0, 0}, {5, 0}, {10, 0}, {15, 0}, {20, 0}, {25, .1}, {30, .3}};
```
and I fit them with a cumulative Gaussian function:
```
cumulativeGauss[x_, μ_, Σ_] :=
CDF[NormalDistribution[μ, Σ], ... | 2012/03/14 | [
"https://mathematica.stackexchange.com/questions/2954",
"https://mathematica.stackexchange.com",
"https://mathematica.stackexchange.com/users/685/"
] | I'm assuming you want to use the same `PlotRange` for cell (2,2) as for the other cells.
You can change the order: show `Plot` before `ListPlot`. Note that `Plot` will now set the `PlotRange`; as I understand it, the first function called by `Show` controls the graphics settings (if there should be a conflict).
```
S... | The issue is that
```
Plot[cumulativeGauss[x, fit2[[1]], fit2[[2]]], {x, 0, 30}]
```
>
> 
>
>
>
is clipping where it goes off the top of the vertical plot range.
Forcing that plot to `PlotRange -> {{0, 30}, {0, 1}}` like the others will solve ... |
26,787,761 | Here is the code that i am using to connect to `MysSQL` database using java.....
**I am getting a runtime error...**
```
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class Java2MySql
{
public static void main(String[] args)
{
String url = "jdbc:m... | 2014/11/06 | [
"https://Stackoverflow.com/questions/26787761",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3751615/"
] | The MySQL connector library Jar file needs to be in your classpath.
See : <http://dev.mysql.com/downloads/connector/j/>
Information how to set the classpath can be found in this posting [Setting multiple jars in java classpath](https://stackoverflow.com/questions/219585/setting-multiple-jars-in-java-classpath)
In yo... | Place your MySQL connector jar in the lib folder, which you can find under,
WebContent -> WEB-INF folder. It should work. |
70,578,327 | I have a spreadsheet with multiple columns. When any column gets updated, I need it to update the timestamp on column 5 which is our timestamp column:
<https://docs.google.com/spreadsheets/d/1zOKwPL0LMtWpcbhji6XDi-8Sx3-WfxRXnboZ_Le0wZo/edit?usp=sharing>
but I can't for the life figure out why it won't work. | 2022/01/04 | [
"https://Stackoverflow.com/questions/70578327",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17831445/"
] | the simple mantra
>
> Variables hold data. Functions hold code. Don't put code inside [string] variables!
>
>
>
[source](http://mywiki.wooledge.org/BashFAQ/050) for more info / going further: [comprehensive answer on StackExchange](https://unix.stackexchange.com/a/444949/472564)
---
the advanced mantra regardin... | Your script attempts to store the output of the command to the PING variable, but not the command itself. There are two basic ways to test the result of a command, and it's either by checking its output or by checking its return code.
In the case of ping, you can simply check if it's successful by checking its return ... |
32,608,433 | I'm having some trouble configuring Buildship for Eclipse the way I want. I currently have > 50 projects always open in Eclipse, but I want to move to having only the projects I am actively working on in Eclipse, and the other projects would use a Maven repository to resolve their dependency.
Lets say ProjectA (which ... | 2015/09/16 | [
"https://Stackoverflow.com/questions/32608433",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2278844/"
] | 1. There's a new [composite build support](https://docs.gradle.org/current/userguide/composite_builds.html) feature added in Gradle 3.1. This feature is a game changer and makes it simple to work on more than one project at once.
2. You can use [dependency substitution rules](https://docs.gradle.org/current/userguide/c... | For the sake of completion, I ended up going with the dependency substitution as suggested by Lance Java. This approach has the following advantages:
* Does not require a third party software.
* Is IDE independent. We're not tinkering with the `.classpath` file directly, we let the Eclipse plugin (or any other IDE pl... |
45,334,761 | How can I use OR in a ternary operator? Here's what I'm trying to do:
`let surname = name == "John" || "Jack" ? "Johnson" : "Smith"` | 2017/07/26 | [
"https://Stackoverflow.com/questions/45334761",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4574147/"
] | Use brackets, and add `name ==` in your second comparison condition, As I put first in comment this is the appropriated code
```
let surname = (name == "John" || name == "Jack") ? "Johnson" : "Smith"
```
Hope this helps | Use brackets:
```
let surname = (name == "John" || name == "Jack") ? "Johnson" : "Smith"
```
These brackets are necessary because you want to evaluate first if `name` is either *John* or *Jack* before "passing" that result to the ternary operator.
Additionally, like in a all C-like languages, you have to mention `n... |
45,334,761 | How can I use OR in a ternary operator? Here's what I'm trying to do:
`let surname = name == "John" || "Jack" ? "Johnson" : "Smith"` | 2017/07/26 | [
"https://Stackoverflow.com/questions/45334761",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4574147/"
] | Use brackets:
```
let surname = (name == "John" || name == "Jack") ? "Johnson" : "Smith"
```
These brackets are necessary because you want to evaluate first if `name` is either *John* or *Jack* before "passing" that result to the ternary operator.
Additionally, like in a all C-like languages, you have to mention `n... | Please be aware of **Operator precedence**
You should use brackets to form valid condition.
```
let surname = (name == "John" || name == "Jack") ? "Johnson" : "Smith"
``` |
45,334,761 | How can I use OR in a ternary operator? Here's what I'm trying to do:
`let surname = name == "John" || "Jack" ? "Johnson" : "Smith"` | 2017/07/26 | [
"https://Stackoverflow.com/questions/45334761",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4574147/"
] | Use brackets:
```
let surname = (name == "John" || name == "Jack") ? "Johnson" : "Smith"
```
These brackets are necessary because you want to evaluate first if `name` is either *John* or *Jack* before "passing" that result to the ternary operator.
Additionally, like in a all C-like languages, you have to mention `n... | Except for brackets, you can also use array.contains for cases with a lot of names that could make the bracket code long and unreadable.
```
let name = "Three"
let nameList = ["One", "Two", "Three", "John", "Jack", "Vlatko"]
let surname = ["John", "Jack"].contains(name) ? "Johnson" : "Smith"
let surnameAlternate = nam... |
45,334,761 | How can I use OR in a ternary operator? Here's what I'm trying to do:
`let surname = name == "John" || "Jack" ? "Johnson" : "Smith"` | 2017/07/26 | [
"https://Stackoverflow.com/questions/45334761",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4574147/"
] | Use brackets, and add `name ==` in your second comparison condition, As I put first in comment this is the appropriated code
```
let surname = (name == "John" || name == "Jack") ? "Johnson" : "Smith"
```
Hope this helps | Please be aware of **Operator precedence**
You should use brackets to form valid condition.
```
let surname = (name == "John" || name == "Jack") ? "Johnson" : "Smith"
``` |
45,334,761 | How can I use OR in a ternary operator? Here's what I'm trying to do:
`let surname = name == "John" || "Jack" ? "Johnson" : "Smith"` | 2017/07/26 | [
"https://Stackoverflow.com/questions/45334761",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4574147/"
] | Use brackets, and add `name ==` in your second comparison condition, As I put first in comment this is the appropriated code
```
let surname = (name == "John" || name == "Jack") ? "Johnson" : "Smith"
```
Hope this helps | Alternatively
```
let surname = ["John", "Jack"].contains(name) ? "Johnson" : "Smith"
``` |
45,334,761 | How can I use OR in a ternary operator? Here's what I'm trying to do:
`let surname = name == "John" || "Jack" ? "Johnson" : "Smith"` | 2017/07/26 | [
"https://Stackoverflow.com/questions/45334761",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4574147/"
] | Use brackets, and add `name ==` in your second comparison condition, As I put first in comment this is the appropriated code
```
let surname = (name == "John" || name == "Jack") ? "Johnson" : "Smith"
```
Hope this helps | Except for brackets, you can also use array.contains for cases with a lot of names that could make the bracket code long and unreadable.
```
let name = "Three"
let nameList = ["One", "Two", "Three", "John", "Jack", "Vlatko"]
let surname = ["John", "Jack"].contains(name) ? "Johnson" : "Smith"
let surnameAlternate = nam... |
45,334,761 | How can I use OR in a ternary operator? Here's what I'm trying to do:
`let surname = name == "John" || "Jack" ? "Johnson" : "Smith"` | 2017/07/26 | [
"https://Stackoverflow.com/questions/45334761",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4574147/"
] | Alternatively
```
let surname = ["John", "Jack"].contains(name) ? "Johnson" : "Smith"
``` | Please be aware of **Operator precedence**
You should use brackets to form valid condition.
```
let surname = (name == "John" || name == "Jack") ? "Johnson" : "Smith"
``` |
45,334,761 | How can I use OR in a ternary operator? Here's what I'm trying to do:
`let surname = name == "John" || "Jack" ? "Johnson" : "Smith"` | 2017/07/26 | [
"https://Stackoverflow.com/questions/45334761",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4574147/"
] | Alternatively
```
let surname = ["John", "Jack"].contains(name) ? "Johnson" : "Smith"
``` | Except for brackets, you can also use array.contains for cases with a lot of names that could make the bracket code long and unreadable.
```
let name = "Three"
let nameList = ["One", "Two", "Three", "John", "Jack", "Vlatko"]
let surname = ["John", "Jack"].contains(name) ? "Johnson" : "Smith"
let surnameAlternate = nam... |
36,911 | I'm trying to describe the walls in a bar (in my story), and this is what I've come up with:
>
> 酒吧漆黑的墙面稀疏地装饰着粉红樱花图案。
>
>
>
Essentially, there's a bar and it's walls are painted black, except for a pink cherry-blossom motif which occurs infrequently.
Describing things in detail seems to be a major obstacle for m... | 2020/02/16 | [
"https://chinese.stackexchange.com/questions/36911",
"https://chinese.stackexchange.com",
"https://chinese.stackexchange.com/users/8099/"
] | >
> 酒吧漆黑的墙面稀疏地装饰着粉红樱花图案。
>
>
>
--> 酒吧漆黑的墙面[上],稀疏地[點綴]着粉红[色的]樱花图案。 --> **粉红色的樱花图案,稀疏地點綴着酒吧漆黑的墙面。** | 酒吧漆黑的墙面上稀稀拉拉地贴着几片粉色樱花图案。
(Don't go to the bar, you might get the 病毒!) |
36,911 | I'm trying to describe the walls in a bar (in my story), and this is what I've come up with:
>
> 酒吧漆黑的墙面稀疏地装饰着粉红樱花图案。
>
>
>
Essentially, there's a bar and it's walls are painted black, except for a pink cherry-blossom motif which occurs infrequently.
Describing things in detail seems to be a major obstacle for m... | 2020/02/16 | [
"https://chinese.stackexchange.com/questions/36911",
"https://chinese.stackexchange.com",
"https://chinese.stackexchange.com/users/8099/"
] | >
> 酒吧漆黑的墙面稀疏地装饰着粉红樱花图案。
>
>
>
--> 酒吧漆黑的墙面[上],稀疏地[點綴]着粉红[色的]樱花图案。 --> **粉红色的樱花图案,稀疏地點綴着酒吧漆黑的墙面。** | Your suggestion is already pretty good now!
There are other possible ways to express the same thing:
装饰在酒吧漆黑墙面上的,是稀疏的粉红樱花图案。
粉红的樱花图案,稀疏地装饰在酒吧漆黑的墙面上。 |
36,911 | I'm trying to describe the walls in a bar (in my story), and this is what I've come up with:
>
> 酒吧漆黑的墙面稀疏地装饰着粉红樱花图案。
>
>
>
Essentially, there's a bar and it's walls are painted black, except for a pink cherry-blossom motif which occurs infrequently.
Describing things in detail seems to be a major obstacle for m... | 2020/02/16 | [
"https://chinese.stackexchange.com/questions/36911",
"https://chinese.stackexchange.com",
"https://chinese.stackexchange.com/users/8099/"
] | Your suggestion is already pretty good now!
There are other possible ways to express the same thing:
装饰在酒吧漆黑墙面上的,是稀疏的粉红樱花图案。
粉红的樱花图案,稀疏地装饰在酒吧漆黑的墙面上。 | 酒吧漆黑的墙面上稀稀拉拉地贴着几片粉色樱花图案。
(Don't go to the bar, you might get the 病毒!) |
43,440,127 | I am having a bit of an issue with dismissing a modal view presented from a childviewController in a container view. I have a UINavigationController as the rootViewController (MainNavigationController), and present a modal from one of the childViewControllers from the selectedSegmentIndex 1 (secondViewController). The ... | 2017/04/16 | [
"https://Stackoverflow.com/questions/43440127",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3708224/"
] | I don't know where you are getting the `jsonHash` variable from but I think you are doing unecessary JSON-handling here. You are also inserting the wrong variable, you want to insert `objHash` which is a valid object to insert, now you are inserting `jsonHash` which is just a string. `JSON.stringify(objHash);` is not d... | `jsonHash` is still a string. May be you want to save `objHash` instead without `JSON.stringify` ? |
38,239,550 | I want to add data-value attribute in input element:
```
{{input type="text" data-value=ec.ec_id value=ec.ecl_subject placeholder=ec.ecl_en_subject name="ecl_subject" class="form-control" }}
```
But its not visible in browser:
```
<input id="ember874" class="ember-view ember-text-field form-control" placeholder=... | 2016/07/07 | [
"https://Stackoverflow.com/questions/38239550",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3305119/"
] | **ADDING DATA ATTRIBUTES**
By default, view helpers do not accept data attributes
i.e.
```
{{input type="text" data-value=ec.ec_id value=ec.ecl_subject name="ecl_subject" }}
```
Render as
```
<input id="ember257" class="ember-view ember-text-field" type="text" value="12">
```
>
> There are two ways to enable... | Ember Input helpers doesn't allow data-attributes. The list of allowed attributes can be found at <https://guides.emberjs.com/v2.6.0/templates/input-helpers/>
The solution for problem is that you use html tag itself, when you want to place data-attributes like below
```
<input type="text" data-value="{{ec.ec_id}}" va... |
47,722,527 | I have a file upload form in html with which I'm trying to upload a file(and file size to display) via ajax call. I'm using django. Whenever I try to do anything nothing happens. Here's the upload form:
```
<form class="uploadForm" method="post" enctype="multipart/form-data">
{% csrf_token %}
<input type="file" id... | 2017/12/08 | [
"https://Stackoverflow.com/questions/47722527",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5205011/"
] | Based on the documentation on [`FormData()`](https://developer.mozilla.org/en-US/docs/Web/API/FormData/FormData), the correct approach would be in the sense of:
```
var formData = new FormData();
formData.append('fileSize', sizeConverter($('#uploadFile')[0].files[0].size/1024));
formData.append('file', $('#uploadFile'... | I think you need to include `enctype: 'multipart/form-data'` in your ajax. And handle the `csrfmiddlewaretoken` with `.append(..)` method.
```
$('.uploadForm').on('submit', function(event){
event.preventDefault();
var fileSize = $('#uploadFile')[0].files[0].size/1024;
var fileName = $('#uploadFile')[0].files[0]... |
43,855,041 | I am making a table row clickable but once clicked I want to open a new tab. I tried using `data-target` but that didn't work.
```
<tr class="table-row" data-href="mypage.php" data-target="_blank"></tr>
<script type="text/javascript">
$(document).ready(function ($) {
$(".table-row").click(function () {
... | 2017/05/08 | [
"https://Stackoverflow.com/questions/43855041",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3892314/"
] | This should work. It will open new tab;
HTML
```
<table>
<tr class="table-row" data-href="mypage.php" data-target="_blank">
<td>something</td>
</tr>
</table>
```
JavaScript
```
$(document).ready(function ($) {
$(".table-row").click(function () {
window.open($(this).dat... | Have you tried:
```
<tr class="table-row"
onclick="window.open('http://website-name.com/mypage.php', '_blank');">
``` |
43,855,041 | I am making a table row clickable but once clicked I want to open a new tab. I tried using `data-target` but that didn't work.
```
<tr class="table-row" data-href="mypage.php" data-target="_blank"></tr>
<script type="text/javascript">
$(document).ready(function ($) {
$(".table-row").click(function () {
... | 2017/05/08 | [
"https://Stackoverflow.com/questions/43855041",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3892314/"
] | could be done like this:
**jQuery: [JSFiddle 1](https://jsfiddle.net/wxc80ybf/2/)**
```js
$('.table-row').each(function() {
var $th = $(this);
$th.on('click', function() {
window.open($th.attr('data-href'), $th.attr('data-target'));
});
});
```
---
**Pure JS: [JSFiddle 2](https://jsfiddle.net/wxc80ybf/3/... | Have you tried:
```
<tr class="table-row"
onclick="window.open('http://website-name.com/mypage.php', '_blank');">
``` |
43,855,041 | I am making a table row clickable but once clicked I want to open a new tab. I tried using `data-target` but that didn't work.
```
<tr class="table-row" data-href="mypage.php" data-target="_blank"></tr>
<script type="text/javascript">
$(document).ready(function ($) {
$(".table-row").click(function () {
... | 2017/05/08 | [
"https://Stackoverflow.com/questions/43855041",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3892314/"
] | This should work. It will open new tab;
HTML
```
<table>
<tr class="table-row" data-href="mypage.php" data-target="_blank">
<td>something</td>
</tr>
</table>
```
JavaScript
```
$(document).ready(function ($) {
$(".table-row").click(function () {
window.open($(this).dat... | In this case you need to use `windows.open` and you can use `_blank`
```
<tr class="table-row" data-href="mypage.php">
$(document).ready(function ($) {
$(".table-row").click(function () {
var url = $(this).data("href");
window.open(url,'_blank');
});
});
``` |
43,855,041 | I am making a table row clickable but once clicked I want to open a new tab. I tried using `data-target` but that didn't work.
```
<tr class="table-row" data-href="mypage.php" data-target="_blank"></tr>
<script type="text/javascript">
$(document).ready(function ($) {
$(".table-row").click(function () {
... | 2017/05/08 | [
"https://Stackoverflow.com/questions/43855041",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3892314/"
] | could be done like this:
**jQuery: [JSFiddle 1](https://jsfiddle.net/wxc80ybf/2/)**
```js
$('.table-row').each(function() {
var $th = $(this);
$th.on('click', function() {
window.open($th.attr('data-href'), $th.attr('data-target'));
});
});
```
---
**Pure JS: [JSFiddle 2](https://jsfiddle.net/wxc80ybf/3/... | In this case you need to use `windows.open` and you can use `_blank`
```
<tr class="table-row" data-href="mypage.php">
$(document).ready(function ($) {
$(".table-row").click(function () {
var url = $(this).data("href");
window.open(url,'_blank');
});
});
``` |
43,855,041 | I am making a table row clickable but once clicked I want to open a new tab. I tried using `data-target` but that didn't work.
```
<tr class="table-row" data-href="mypage.php" data-target="_blank"></tr>
<script type="text/javascript">
$(document).ready(function ($) {
$(".table-row").click(function () {
... | 2017/05/08 | [
"https://Stackoverflow.com/questions/43855041",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3892314/"
] | could be done like this:
**jQuery: [JSFiddle 1](https://jsfiddle.net/wxc80ybf/2/)**
```js
$('.table-row').each(function() {
var $th = $(this);
$th.on('click', function() {
window.open($th.attr('data-href'), $th.attr('data-target'));
});
});
```
---
**Pure JS: [JSFiddle 2](https://jsfiddle.net/wxc80ybf/3/... | This should work. It will open new tab;
HTML
```
<table>
<tr class="table-row" data-href="mypage.php" data-target="_blank">
<td>something</td>
</tr>
</table>
```
JavaScript
```
$(document).ready(function ($) {
$(".table-row").click(function () {
window.open($(this).dat... |
34,834,519 | My input file looks something like this:
```
{
"login": "dmaxfield",
"id": 7449977,
...
}
{
"login": "dmaxfield",
"id": 7449977,
...
}
```
I can get all the login names with this : `cat members | jq '.[].login'`
but I have not been able to crack the syntax to get both the login and id? | 2016/01/17 | [
"https://Stackoverflow.com/questions/34834519",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5790543/"
] | You can use `jq '.[] | .login, .id'` to obtain each login followed by its id. | This works for me:
```
> echo '{"a":1,"b":2,"c":3}{"a":1,"b":2,"c":3}' | jq '{a,b}'
{
"a": 1,
"b": 2
}
{
"a": 1,
"b": 2
}
``` |
34,834,519 | My input file looks something like this:
```
{
"login": "dmaxfield",
"id": 7449977,
...
}
{
"login": "dmaxfield",
"id": 7449977,
...
}
```
I can get all the login names with this : `cat members | jq '.[].login'`
but I have not been able to crack the syntax to get both the login and id? | 2016/01/17 | [
"https://Stackoverflow.com/questions/34834519",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5790543/"
] | You can use `jq '.[] | .login, .id'` to obtain each login followed by its id. | In order to select values which are indented to different levels (i.e. both first and second level), you might use the following:
```
echo '[{"a":{"aa":1,"ab":2},"b":3,"c":4},{"a":{"aa":5,"ab":6},"b":7,"c":8}]' \
| jq '.[]|[.a.aa,.a.ab,.b]'
[
1,
2,
3
]
[
5,
6,
7
]
``` |
34,834,519 | My input file looks something like this:
```
{
"login": "dmaxfield",
"id": 7449977,
...
}
{
"login": "dmaxfield",
"id": 7449977,
...
}
```
I can get all the login names with this : `cat members | jq '.[].login'`
but I have not been able to crack the syntax to get both the login and id? | 2016/01/17 | [
"https://Stackoverflow.com/questions/34834519",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5790543/"
] | You can use `jq '.[] | .login, .id'` to obtain each login followed by its id. | Just provide one more example here (jq-1.6):
Walk through an array and select a field of an object element and a field of object in that object
```
echo '[{"id":1, "private_info": {"name": "Ivy", "age": 18}}, {"id":2, "private_info": {"name": "Tommy", "aga": 18}}]' | jq ".[] | {id: .id, name: .private_info.name}" -
... |
34,834,519 | My input file looks something like this:
```
{
"login": "dmaxfield",
"id": 7449977,
...
}
{
"login": "dmaxfield",
"id": 7449977,
...
}
```
I can get all the login names with this : `cat members | jq '.[].login'`
but I have not been able to crack the syntax to get both the login and id? | 2016/01/17 | [
"https://Stackoverflow.com/questions/34834519",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5790543/"
] | This works for me:
```
> echo '{"a":1,"b":2,"c":3}{"a":1,"b":2,"c":3}' | jq '{a,b}'
{
"a": 1,
"b": 2
}
{
"a": 1,
"b": 2
}
``` | In order to select values which are indented to different levels (i.e. both first and second level), you might use the following:
```
echo '[{"a":{"aa":1,"ab":2},"b":3,"c":4},{"a":{"aa":5,"ab":6},"b":7,"c":8}]' \
| jq '.[]|[.a.aa,.a.ab,.b]'
[
1,
2,
3
]
[
5,
6,
7
]
``` |
34,834,519 | My input file looks something like this:
```
{
"login": "dmaxfield",
"id": 7449977,
...
}
{
"login": "dmaxfield",
"id": 7449977,
...
}
```
I can get all the login names with this : `cat members | jq '.[].login'`
but I have not been able to crack the syntax to get both the login and id? | 2016/01/17 | [
"https://Stackoverflow.com/questions/34834519",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5790543/"
] | This works for me:
```
> echo '{"a":1,"b":2,"c":3}{"a":1,"b":2,"c":3}' | jq '{a,b}'
{
"a": 1,
"b": 2
}
{
"a": 1,
"b": 2
}
``` | Just provide one more example here (jq-1.6):
Walk through an array and select a field of an object element and a field of object in that object
```
echo '[{"id":1, "private_info": {"name": "Ivy", "age": 18}}, {"id":2, "private_info": {"name": "Tommy", "aga": 18}}]' | jq ".[] | {id: .id, name: .private_info.name}" -
... |
34,834,519 | My input file looks something like this:
```
{
"login": "dmaxfield",
"id": 7449977,
...
}
{
"login": "dmaxfield",
"id": 7449977,
...
}
```
I can get all the login names with this : `cat members | jq '.[].login'`
but I have not been able to crack the syntax to get both the login and id? | 2016/01/17 | [
"https://Stackoverflow.com/questions/34834519",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5790543/"
] | Just provide one more example here (jq-1.6):
Walk through an array and select a field of an object element and a field of object in that object
```
echo '[{"id":1, "private_info": {"name": "Ivy", "age": 18}}, {"id":2, "private_info": {"name": "Tommy", "aga": 18}}]' | jq ".[] | {id: .id, name: .private_info.name}" -
... | In order to select values which are indented to different levels (i.e. both first and second level), you might use the following:
```
echo '[{"a":{"aa":1,"ab":2},"b":3,"c":4},{"a":{"aa":5,"ab":6},"b":7,"c":8}]' \
| jq '.[]|[.a.aa,.a.ab,.b]'
[
1,
2,
3
]
[
5,
6,
7
]
``` |
1,370,322 | If I navigate away from a page in the middle of an $.ajax() request it fires the error callback. I've tested in Safari and FF with both GET and POST requests.
One potential solution would be to abort all AJAX requests on page unload, but the error handler is called before unload, so this doesn't seem possible.
I want... | 2009/09/02 | [
"https://Stackoverflow.com/questions/1370322",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/83810/"
] | This is a tough one to handle correctly in all situations. Unfortunately in many popular browsers the `xhr.status` is the same (`0`) if the AJAX call is cancelled by navigation or by a server being down / unresponsive. So that technique rarely works.
Here's a set of highly "practical" hacks that I've accumulated that ... | *(I'd add this as a comment to the main answer but haven't built up enough points to do so yet!)*
I'm also seeing this in FF4 and Chrome (9.0.597.107). Probably elsewhere but that's bad enough for me to want to fix it!
One of the things that's odd about this situation is that returned XMLHttpRequest.status === 0
Whi... |
1,370,322 | If I navigate away from a page in the middle of an $.ajax() request it fires the error callback. I've tested in Safari and FF with both GET and POST requests.
One potential solution would be to abort all AJAX requests on page unload, but the error handler is called before unload, so this doesn't seem possible.
I want... | 2009/09/02 | [
"https://Stackoverflow.com/questions/1370322",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/83810/"
] | This is a tough one to handle correctly in all situations. Unfortunately in many popular browsers the `xhr.status` is the same (`0`) if the AJAX call is cancelled by navigation or by a server being down / unresponsive. So that technique rarely works.
Here's a set of highly "practical" hacks that I've accumulated that ... | Just wait a while before showing the error. If a request fails due to page unload, the timeout won't fire and the error won't be shown. My experiments have shown that 100ms is enough for desktop Safari and Firefox (desktop and Android) and 500ms is enough for iOS Safari. The durations are fuzzy, so you should increase ... |
1,370,322 | If I navigate away from a page in the middle of an $.ajax() request it fires the error callback. I've tested in Safari and FF with both GET and POST requests.
One potential solution would be to abort all AJAX requests on page unload, but the error handler is called before unload, so this doesn't seem possible.
I want... | 2009/09/02 | [
"https://Stackoverflow.com/questions/1370322",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/83810/"
] | In the error callback or [$.ajax](http://docs.jquery.com/Ajax/jQuery.ajax) you have three input arguments:
```
function (XMLHttpRequest, textStatus, errorThrown) {
this; // options for this ajax request
}
```
You can check directly the `xhr.status` to get the HTTP response code, for example:
```
$.ajax({
url: ... | *(I'd add this as a comment to the main answer but haven't built up enough points to do so yet!)*
I'm also seeing this in FF4 and Chrome (9.0.597.107). Probably elsewhere but that's bad enough for me to want to fix it!
One of the things that's odd about this situation is that returned XMLHttpRequest.status === 0
Whi... |
1,370,322 | If I navigate away from a page in the middle of an $.ajax() request it fires the error callback. I've tested in Safari and FF with both GET and POST requests.
One potential solution would be to abort all AJAX requests on page unload, but the error handler is called before unload, so this doesn't seem possible.
I want... | 2009/09/02 | [
"https://Stackoverflow.com/questions/1370322",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/83810/"
] | In the error callback or [$.ajax](http://docs.jquery.com/Ajax/jQuery.ajax) you have three input arguments:
```
function (XMLHttpRequest, textStatus, errorThrown) {
this; // options for this ajax request
}
```
You can check directly the `xhr.status` to get the HTTP response code, for example:
```
$.ajax({
url: ... | The error callback should get a reference to the XHR object, check the status code to see if it's a server error or not? |
1,370,322 | If I navigate away from a page in the middle of an $.ajax() request it fires the error callback. I've tested in Safari and FF with both GET and POST requests.
One potential solution would be to abort all AJAX requests on page unload, but the error handler is called before unload, so this doesn't seem possible.
I want... | 2009/09/02 | [
"https://Stackoverflow.com/questions/1370322",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/83810/"
] | *(I'd add this as a comment to the main answer but haven't built up enough points to do so yet!)*
I'm also seeing this in FF4 and Chrome (9.0.597.107). Probably elsewhere but that's bad enough for me to want to fix it!
One of the things that's odd about this situation is that returned XMLHttpRequest.status === 0
Whi... | If you make use of jQuery functions such as `$.get`, `$.post`, `$.ajax`... then you can use the parameter `text_status` to check what type of fail is:
```
request = $.get('test.html', function(data){
//whatever
}).fail(function(xhr, text_status, error_thrown) {
if(text_status!== 'abort'){
console.warn... |
1,370,322 | If I navigate away from a page in the middle of an $.ajax() request it fires the error callback. I've tested in Safari and FF with both GET and POST requests.
One potential solution would be to abort all AJAX requests on page unload, but the error handler is called before unload, so this doesn't seem possible.
I want... | 2009/09/02 | [
"https://Stackoverflow.com/questions/1370322",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/83810/"
] | In the error callback or [$.ajax](http://docs.jquery.com/Ajax/jQuery.ajax) you have three input arguments:
```
function (XMLHttpRequest, textStatus, errorThrown) {
this; // options for this ajax request
}
```
You can check directly the `xhr.status` to get the HTTP response code, for example:
```
$.ajax({
url: ... | Just wait a while before showing the error. If a request fails due to page unload, the timeout won't fire and the error won't be shown. My experiments have shown that 100ms is enough for desktop Safari and Firefox (desktop and Android) and 500ms is enough for iOS Safari. The durations are fuzzy, so you should increase ... |
1,370,322 | If I navigate away from a page in the middle of an $.ajax() request it fires the error callback. I've tested in Safari and FF with both GET and POST requests.
One potential solution would be to abort all AJAX requests on page unload, but the error handler is called before unload, so this doesn't seem possible.
I want... | 2009/09/02 | [
"https://Stackoverflow.com/questions/1370322",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/83810/"
] | *(I'd add this as a comment to the main answer but haven't built up enough points to do so yet!)*
I'm also seeing this in FF4 and Chrome (9.0.597.107). Probably elsewhere but that's bad enough for me to want to fix it!
One of the things that's odd about this situation is that returned XMLHttpRequest.status === 0
Whi... | Just wait a while before showing the error. If a request fails due to page unload, the timeout won't fire and the error won't be shown. My experiments have shown that 100ms is enough for desktop Safari and Firefox (desktop and Android) and 500ms is enough for iOS Safari. The durations are fuzzy, so you should increase ... |
1,370,322 | If I navigate away from a page in the middle of an $.ajax() request it fires the error callback. I've tested in Safari and FF with both GET and POST requests.
One potential solution would be to abort all AJAX requests on page unload, but the error handler is called before unload, so this doesn't seem possible.
I want... | 2009/09/02 | [
"https://Stackoverflow.com/questions/1370322",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/83810/"
] | This is a tough one to handle correctly in all situations. Unfortunately in many popular browsers the `xhr.status` is the same (`0`) if the AJAX call is cancelled by navigation or by a server being down / unresponsive. So that technique rarely works.
Here's a set of highly "practical" hacks that I've accumulated that ... | If you make use of jQuery functions such as `$.get`, `$.post`, `$.ajax`... then you can use the parameter `text_status` to check what type of fail is:
```
request = $.get('test.html', function(data){
//whatever
}).fail(function(xhr, text_status, error_thrown) {
if(text_status!== 'abort'){
console.warn... |
1,370,322 | If I navigate away from a page in the middle of an $.ajax() request it fires the error callback. I've tested in Safari and FF with both GET and POST requests.
One potential solution would be to abort all AJAX requests on page unload, but the error handler is called before unload, so this doesn't seem possible.
I want... | 2009/09/02 | [
"https://Stackoverflow.com/questions/1370322",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/83810/"
] | In the error callback or [$.ajax](http://docs.jquery.com/Ajax/jQuery.ajax) you have three input arguments:
```
function (XMLHttpRequest, textStatus, errorThrown) {
this; // options for this ajax request
}
```
You can check directly the `xhr.status` to get the HTTP response code, for example:
```
$.ajax({
url: ... | This is a tough one to handle correctly in all situations. Unfortunately in many popular browsers the `xhr.status` is the same (`0`) if the AJAX call is cancelled by navigation or by a server being down / unresponsive. So that technique rarely works.
Here's a set of highly "practical" hacks that I've accumulated that ... |
1,370,322 | If I navigate away from a page in the middle of an $.ajax() request it fires the error callback. I've tested in Safari and FF with both GET and POST requests.
One potential solution would be to abort all AJAX requests on page unload, but the error handler is called before unload, so this doesn't seem possible.
I want... | 2009/09/02 | [
"https://Stackoverflow.com/questions/1370322",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/83810/"
] | In the error callback or [$.ajax](http://docs.jquery.com/Ajax/jQuery.ajax) you have three input arguments:
```
function (XMLHttpRequest, textStatus, errorThrown) {
this; // options for this ajax request
}
```
You can check directly the `xhr.status` to get the HTTP response code, for example:
```
$.ajax({
url: ... | If you make use of jQuery functions such as `$.get`, `$.post`, `$.ajax`... then you can use the parameter `text_status` to check what type of fail is:
```
request = $.get('test.html', function(data){
//whatever
}).fail(function(xhr, text_status, error_thrown) {
if(text_status!== 'abort'){
console.warn... |
49,972,817 | I am getting "can only concatenate list (not "MultiValue") to list" highlighting map (float portion, while running below resampling, this code is very commonly used throughout image segmentation like lungs etc, I am thinking maybe this is issue with Python 3 and was working for earlier versions, any help is much apprec... | 2018/04/23 | [
"https://Stackoverflow.com/questions/49972817",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9618189/"
] | Change
```
spacing = map(float, ([scan[0].SliceThickness] + scan[0].PixelSpacing))
```
To
```
spacing = map(float, ([scan[0].SliceThickness] + list(scan[0].PixelSpacing)))
```
Basically scan[0].PixelSpacing is a MultiValue and need to be converted into list before concatenation to another list. | this is the fix :
```
def resample(image, scan, new_spacing=[1,1,1]):
spacing = np.array([float(scan[0].SliceThickness)] + [float(x) for x in scan[0].PixelSpacing], dtype=np.float32)
resize_factor = spacing / new_spacing
new_real_shape = image.shape * resize_factor
new_shape = np.round(new_real_shape)
... |
49,972,817 | I am getting "can only concatenate list (not "MultiValue") to list" highlighting map (float portion, while running below resampling, this code is very commonly used throughout image segmentation like lungs etc, I am thinking maybe this is issue with Python 3 and was working for earlier versions, any help is much apprec... | 2018/04/23 | [
"https://Stackoverflow.com/questions/49972817",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9618189/"
] | Change
```
spacing = map(float, ([scan[0].SliceThickness] + scan[0].PixelSpacing))
```
To
```
spacing = map(float, ([scan[0].SliceThickness] + list(scan[0].PixelSpacing)))
```
Basically scan[0].PixelSpacing is a MultiValue and need to be converted into list before concatenation to another list. | This is the solution:
```py
def resample(image, scan, new_spacing=[1,1,1]):
# Determine current pixel spacing
spacing = [scan[0].SliceThickness]
spacing.extend(scan[0].PixelSpacing)
spacing = np.array(spacing, dtype=np.float32)
resize_factor = spacing / new_spacing
new_real_shape = image.shape... |
39,460 | Нужна ли здесь запятая перед словом НЕТ? Умом понимаю, что кажется нет, но не смогла найти правило, которое здесь применяется.
Никаких дополнительных нормативно-правовых документов, устанавливающих требования к устройству оборудования НЕТ. | 2014/09/23 | [
"https://rus.stackexchange.com/questions/39460",
"https://rus.stackexchange.com",
"https://rus.stackexchange.com/users/4012/"
] | Конечно, нужна. В чистом виде причастный оборот после определяемого слова.
Заскок-с? ))) | Предложение надо переделать, так как оборот требует обязательного обособления:
(1) Нет никаких дополнительных нормативно-правовых документов, устанавливающих требования к устройству оборудования.
(2) Никаких дополнительных нормативно-правовых документов, устанавливающих требования к устройству оборудования, не сущест... |
16,355,998 | I need to make script that behaves differently per system. Today it is possible to run bash even on microsoft windows, mac, linux, hp-ux, solaris etc...
How can I determine which of these operating systems I am on? I don't need exact version, I just need to know if I am on windows, linux, solaris... | 2013/05/03 | [
"https://Stackoverflow.com/questions/16355998",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1514983/"
] | There is a standard shell command "uname" which returns the current platform as a string
To use this in a shell program a typical stanza might be
```
#!/bin/sh
if [ `uname` = "Linux" ] ;
then
echo "we are on the operating system of Linux"
fi
if [ `uname` = "FreeBSD" ] ;
then
echo "we are on the operating sy... | I would look at the output of
```
uname -a
```
and look for specific strings, which can help you identify the system.
Or more specific
```
uname -s
```
With Windows, do you mean something like cygwin? |
16,355,998 | I need to make script that behaves differently per system. Today it is possible to run bash even on microsoft windows, mac, linux, hp-ux, solaris etc...
How can I determine which of these operating systems I am on? I don't need exact version, I just need to know if I am on windows, linux, solaris... | 2013/05/03 | [
"https://Stackoverflow.com/questions/16355998",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1514983/"
] | There is a standard shell command "uname" which returns the current platform as a string
To use this in a shell program a typical stanza might be
```
#!/bin/sh
if [ `uname` = "Linux" ] ;
then
echo "we are on the operating system of Linux"
fi
if [ `uname` = "FreeBSD" ] ;
then
echo "we are on the operating sy... | bash has a global var called `$OSTYPE`. Type echo `$OSTYPE` to see:
```
echo "$OSTYPE"
// linux-gnu
```
From the [bash man page](http://linux.die.net/man/1/bash):
>
> OSTYPE Automatically set to a string that describes the operating system on which bash is executing. The default is system-dependent.
>
>
>
---
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.