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 |
|---|---|---|---|---|---|
168,350 | I'm setting up a site for internal use and it will be served over HTTPS with a self-signed server certificate.
To increase security, I want to also secure the site with client certificates.
Is there any reason to use a separate certificate authority to sign the client certificates instead of just using the server priv... | 2017/08/28 | [
"https://security.stackexchange.com/questions/168350",
"https://security.stackexchange.com",
"https://security.stackexchange.com/users/157901/"
] | When you talk about security, all this self-signed SSL stuff has nothing common with security. In order to implement proper SSL configuration for internal network, you have to:
* Create your own CA server (depending on a platform, different products may be used. For example, in Windows you can use Active Directory Cer... | Crypt32 gave information about "how". Here's a reason to do this the "right way" --
The "right way" is likely less costly than running your own CA, distributing keys, etc. "Let's encrypt" is free. A wildcard from a "cheap" SSL provider is only about $100/year and can provide a cert for all sites in a domain. Either s... |
1,578,885 | Let $\mathscr A$ be a unital C\*-algebra and let $a,b\in \mathscr A$ such that $0\leq a \leq b$ and $a$ is invertible. How to show that $b$ is invertible?
($0\leq a \leq b$ means that $a,b$ is positive and that $b-a$ is positive. Moreover, a positive element is a hermitian element with a spectrum which is a subset of... | 2015/12/16 | [
"https://math.stackexchange.com/questions/1578885",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/82448/"
] | Let $x=-\cos(\theta)$ so that
$$\mu(1-x^2)^2-x=0$$
This polynomial indeed has a single root in the range $[0,1]$ for all positive $\mu$.
We can rewrite the above equation as
$$\mu=\frac x{(1-x^2)^2}.$$
For small $x$, $x\approx\mu$.
For $x$ close to $1$, let $1-\epsilon$, we have
$$\mu=\frac{1-\epsilon}{(1-(1-\ep... | You can avoid ugly analytical formulas but you'll need to use a numerical method to solve for the roots of a polynomial.
Rewrite your equation as
$$\mu\sin^4\theta-\sqrt{1-\sin^2\theta}=0$$
(because $\pi/2<\theta<\pi$), from which you get
$$\mu^2\sin^8\theta+\sin^2\theta - 1=0$$
With $x=\sin\theta$ this is equival... |
57,343 | How to determine the order of nucleophilicity for given chemical species?
Like I came across this question, to rearrange $\ce{RCOO-, OR-, OH-, H2O}$ (alkyl acetate, alkoxide, hydroxide, and water) in decreasing order of nucleophilicity and it ranked $\ce{OR-}$ first.
Shouldn't it be $\ce{OH-}$ since $\ce{OR-}$ would ... | 2016/08/12 | [
"https://chemistry.stackexchange.com/questions/57343",
"https://chemistry.stackexchange.com",
"https://chemistry.stackexchange.com/users/30466/"
] | In this case you can look at the pKa values of their conjugate acids. Higher pKa of conjugate acid means a weaker acid hence a stronger base. The pKa of water is 15.7, while most alcohols have pKa of 16-18.
I guess this question is asking for a general trend. Although alkoxide could be sterically hindered, for which ... | OR¯ is NOT RO¯ !!!
Clearly, R¯ is an unknown species and nothing else can be said about it.
OR¯ would be an unusual structure, given oxygen's electronegativity compared to carbon's. In the case of RO¯, the R "group" would have to be very large and bulky to dramatically sterically affect (hide) the O¯ from other molecul... |
57,343 | How to determine the order of nucleophilicity for given chemical species?
Like I came across this question, to rearrange $\ce{RCOO-, OR-, OH-, H2O}$ (alkyl acetate, alkoxide, hydroxide, and water) in decreasing order of nucleophilicity and it ranked $\ce{OR-}$ first.
Shouldn't it be $\ce{OH-}$ since $\ce{OR-}$ would ... | 2016/08/12 | [
"https://chemistry.stackexchange.com/questions/57343",
"https://chemistry.stackexchange.com",
"https://chemistry.stackexchange.com/users/30466/"
] | Within a group of nucleophiles with the same atom, the nucleophilicity decrease with **decreasing basicity of nucleophile**.
Decreasing basicity means the decreasing affinity of electron pair for a proton. The decreasing order of nucleophilicity is shown in the figure.
[ in decreasing order of nucleophilicity and it ranked $\ce{OR-}$ first.
Shouldn't it be $\ce{OH-}$ since $\ce{OR-}$ would ... | 2016/08/12 | [
"https://chemistry.stackexchange.com/questions/57343",
"https://chemistry.stackexchange.com",
"https://chemistry.stackexchange.com/users/30466/"
] | In addition to looking at pKa's, you must also consider the stabilizing effects of the surrounding groups. RO- has an alkyl group attached, allowing a greater amount of polarizability. This means Oxygen's loan pairs will be more readily available to react (ie they will not be held in as close and as tight) in RO- than ... | OR¯ is NOT RO¯ !!!
Clearly, R¯ is an unknown species and nothing else can be said about it.
OR¯ would be an unusual structure, given oxygen's electronegativity compared to carbon's. In the case of RO¯, the R "group" would have to be very large and bulky to dramatically sterically affect (hide) the O¯ from other molecul... |
57,343 | How to determine the order of nucleophilicity for given chemical species?
Like I came across this question, to rearrange $\ce{RCOO-, OR-, OH-, H2O}$ (alkyl acetate, alkoxide, hydroxide, and water) in decreasing order of nucleophilicity and it ranked $\ce{OR-}$ first.
Shouldn't it be $\ce{OH-}$ since $\ce{OR-}$ would ... | 2016/08/12 | [
"https://chemistry.stackexchange.com/questions/57343",
"https://chemistry.stackexchange.com",
"https://chemistry.stackexchange.com/users/30466/"
] | Within a group of nucleophiles with the same atom, the nucleophilicity decrease with **decreasing basicity of nucleophile**.
Decreasing basicity means the decreasing affinity of electron pair for a proton. The decreasing order of nucleophilicity is shown in the figure.
[ the O¯ from other molecul... |
57,343 | How to determine the order of nucleophilicity for given chemical species?
Like I came across this question, to rearrange $\ce{RCOO-, OR-, OH-, H2O}$ (alkyl acetate, alkoxide, hydroxide, and water) in decreasing order of nucleophilicity and it ranked $\ce{OR-}$ first.
Shouldn't it be $\ce{OH-}$ since $\ce{OR-}$ would ... | 2016/08/12 | [
"https://chemistry.stackexchange.com/questions/57343",
"https://chemistry.stackexchange.com",
"https://chemistry.stackexchange.com/users/30466/"
] | Within a group of nucleophiles with the same atom, the nucleophilicity decrease with **decreasing basicity of nucleophile**.
Decreasing basicity means the decreasing affinity of electron pair for a proton. The decreasing order of nucleophilicity is shown in the figure.
[ in RO- than ... |
34,496,574 | No mather what I write in the input fields I only get NaN even from the page load I get NaN
Any idea why? I need quantity to \* by price and give a result, here is the code. I will display the code now
```
<form action="?F=save-sale" method="post" name="venta">
<table class="table-global">
<tr>
<td... | 2015/12/28 | [
"https://Stackoverflow.com/questions/34496574",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5618056/"
] | Just have this condition `if (aaventa.value && aacantidad.value)` before calculating the product. It makes sure that the values are not *empty*. Everything else is fine.
```js
var aaventa = document.getElementsByName('venta')[0];
var aaventatotal = document.getElementsByName('ventatotal')[0];
var aacantidad = docume... | ```
<input id="venta">
<input id="cantidad">
<input id="ventatotal">
```
Using jQuery
```
$('#venta').change(function(){ updateInput() ;});
$('#cantidad').change(function(){ updateInput() ;});
$('#ventatotal').change(function(){ updateInput() ;});
``` |
52,141,775 | I have a Typscript app and API. I wrote the below test per numerous Google searches and some examples found here on SO and other places. I see no issue in the test code. Googling `TypeError: chai.request is not a function`, so far is getting me now where. Do you see my error below?
Thank you, thank you, thank you for... | 2018/09/02 | [
"https://Stackoverflow.com/questions/52141775",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2556640/"
] | I can reproduce the problem if I enable the `esModuleInterop` compiler option. When this option is enabled, `import * as chai from 'chai';` only imports the members that the `chai` module has at the time it is imported. Indeed, I believe it's considered dodgy to add exports to an ES module at runtime. Try `import chai ... | You are mixing `import` and `require` syntax, it's a bad idea!
Use only `import` syntax :
```
import * as chai from 'chai';
import * as chai-http from 'chai-http';
chai.use(chai-http);
```
**Edit**
Unfortunately, it seems that the es6 module syntax is not supported in chai-http. You can see the issue [here](https... |
52,141,775 | I have a Typscript app and API. I wrote the below test per numerous Google searches and some examples found here on SO and other places. I see no issue in the test code. Googling `TypeError: chai.request is not a function`, so far is getting me now where. Do you see my error below?
Thank you, thank you, thank you for... | 2018/09/02 | [
"https://Stackoverflow.com/questions/52141775",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2556640/"
] | I solved this by the following approach (Express.js with TypeScript)
```
import chai from 'chai';
import chaiHttp from 'chai-http';
chai.use(chaiHttp);
```
Hope it helps.
*Remember to install* **@types/chai** *and other type definition packages for the block above to work* | install from github
```
"devDependencies": {
"chai-http": "git+https://github.com/chaijs/chai-http.git",
},
``` |
52,141,775 | I have a Typscript app and API. I wrote the below test per numerous Google searches and some examples found here on SO and other places. I see no issue in the test code. Googling `TypeError: chai.request is not a function`, so far is getting me now where. Do you see my error below?
Thank you, thank you, thank you for... | 2018/09/02 | [
"https://Stackoverflow.com/questions/52141775",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2556640/"
] | I can reproduce the problem if I enable the `esModuleInterop` compiler option. When this option is enabled, `import * as chai from 'chai';` only imports the members that the `chai` module has at the time it is imported. Indeed, I believe it's considered dodgy to add exports to an ES module at runtime. Try `import chai ... | install from github
```
"devDependencies": {
"chai-http": "git+https://github.com/chaijs/chai-http.git",
},
``` |
52,141,775 | I have a Typscript app and API. I wrote the below test per numerous Google searches and some examples found here on SO and other places. I see no issue in the test code. Googling `TypeError: chai.request is not a function`, so far is getting me now where. Do you see my error below?
Thank you, thank you, thank you for... | 2018/09/02 | [
"https://Stackoverflow.com/questions/52141775",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2556640/"
] | You are mixing `import` and `require` syntax, it's a bad idea!
Use only `import` syntax :
```
import * as chai from 'chai';
import * as chai-http from 'chai-http';
chai.use(chai-http);
```
**Edit**
Unfortunately, it seems that the es6 module syntax is not supported in chai-http. You can see the issue [here](https... | I can reproduce the issue on my own machine. This is how I solve it.
```
import * as chai from 'chai';
import chaiHttp = require('chai-http');
chai.use(chaiHttp);
```
I also need to install **@types/chai-http** so the compiler knows.
```
npm install @types/chai-http --save-dev
```
Hope it helps |
52,141,775 | I have a Typscript app and API. I wrote the below test per numerous Google searches and some examples found here on SO and other places. I see no issue in the test code. Googling `TypeError: chai.request is not a function`, so far is getting me now where. Do you see my error below?
Thank you, thank you, thank you for... | 2018/09/02 | [
"https://Stackoverflow.com/questions/52141775",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2556640/"
] | Thank you very much for the replies! Ultimately I had to change where/how `chai.request` was being imported and rewrite the test a good bit. Based on the code in the test you might think 1 or more of the first 5 lines are not necessary, but they *all* are. Assuming the rest api is started up on 3000, the following code... | install from github
```
"devDependencies": {
"chai-http": "git+https://github.com/chaijs/chai-http.git",
},
``` |
52,141,775 | I have a Typscript app and API. I wrote the below test per numerous Google searches and some examples found here on SO and other places. I see no issue in the test code. Googling `TypeError: chai.request is not a function`, so far is getting me now where. Do you see my error below?
Thank you, thank you, thank you for... | 2018/09/02 | [
"https://Stackoverflow.com/questions/52141775",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2556640/"
] | I solved this by the following approach (Express.js with TypeScript)
```
import chai from 'chai';
import chaiHttp from 'chai-http';
chai.use(chaiHttp);
```
Hope it helps.
*Remember to install* **@types/chai** *and other type definition packages for the block above to work* | Use :
```
const chai =require('chai');
const chaiHttp = require('chai-http');
chai.use(chaiHttp);
```
Then use
```
describe('Chat', () => {
it('should return all data',async()=>{
chai.request("https://google.com")
.get('/')
.end((err, res) => {
expect(res).to.have.st... |
52,141,775 | I have a Typscript app and API. I wrote the below test per numerous Google searches and some examples found here on SO and other places. I see no issue in the test code. Googling `TypeError: chai.request is not a function`, so far is getting me now where. Do you see my error below?
Thank you, thank you, thank you for... | 2018/09/02 | [
"https://Stackoverflow.com/questions/52141775",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2556640/"
] | Use :
```
const chai =require('chai');
const chaiHttp = require('chai-http');
chai.use(chaiHttp);
```
Then use
```
describe('Chat', () => {
it('should return all data',async()=>{
chai.request("https://google.com")
.get('/')
.end((err, res) => {
expect(res).to.have.st... | I can reproduce the issue on my own machine. This is how I solve it.
```
import * as chai from 'chai';
import chaiHttp = require('chai-http');
chai.use(chaiHttp);
```
I also need to install **@types/chai-http** so the compiler knows.
```
npm install @types/chai-http --save-dev
```
Hope it helps |
52,141,775 | I have a Typscript app and API. I wrote the below test per numerous Google searches and some examples found here on SO and other places. I see no issue in the test code. Googling `TypeError: chai.request is not a function`, so far is getting me now where. Do you see my error below?
Thank you, thank you, thank you for... | 2018/09/02 | [
"https://Stackoverflow.com/questions/52141775",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2556640/"
] | I solved this by the following approach (Express.js with TypeScript)
```
import chai from 'chai';
import chaiHttp from 'chai-http';
chai.use(chaiHttp);
```
Hope it helps.
*Remember to install* **@types/chai** *and other type definition packages for the block above to work* | You are mixing `import` and `require` syntax, it's a bad idea!
Use only `import` syntax :
```
import * as chai from 'chai';
import * as chai-http from 'chai-http';
chai.use(chai-http);
```
**Edit**
Unfortunately, it seems that the es6 module syntax is not supported in chai-http. You can see the issue [here](https... |
52,141,775 | I have a Typscript app and API. I wrote the below test per numerous Google searches and some examples found here on SO and other places. I see no issue in the test code. Googling `TypeError: chai.request is not a function`, so far is getting me now where. Do you see my error below?
Thank you, thank you, thank you for... | 2018/09/02 | [
"https://Stackoverflow.com/questions/52141775",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2556640/"
] | You are mixing `import` and `require` syntax, it's a bad idea!
Use only `import` syntax :
```
import * as chai from 'chai';
import * as chai-http from 'chai-http';
chai.use(chai-http);
```
**Edit**
Unfortunately, it seems that the es6 module syntax is not supported in chai-http. You can see the issue [here](https... | Use :
```
const chai =require('chai');
const chaiHttp = require('chai-http');
chai.use(chaiHttp);
```
Then use
```
describe('Chat', () => {
it('should return all data',async()=>{
chai.request("https://google.com")
.get('/')
.end((err, res) => {
expect(res).to.have.st... |
52,141,775 | I have a Typscript app and API. I wrote the below test per numerous Google searches and some examples found here on SO and other places. I see no issue in the test code. Googling `TypeError: chai.request is not a function`, so far is getting me now where. Do you see my error below?
Thank you, thank you, thank you for... | 2018/09/02 | [
"https://Stackoverflow.com/questions/52141775",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2556640/"
] | I can reproduce the problem if I enable the `esModuleInterop` compiler option. When this option is enabled, `import * as chai from 'chai';` only imports the members that the `chai` module has at the time it is imported. Indeed, I believe it's considered dodgy to add exports to an ES module at runtime. Try `import chai ... | I can reproduce the issue on my own machine. This is how I solve it.
```
import * as chai from 'chai';
import chaiHttp = require('chai-http');
chai.use(chaiHttp);
```
I also need to install **@types/chai-http** so the compiler knows.
```
npm install @types/chai-http --save-dev
```
Hope it helps |
5,235,998 | I wrote a small farad converter to learn GUI programming. It works great, looks fine-ish. The only problem is I can't seem to figure out how to control this strange highlighting that comes up on my `ttk.Combobox` selections. I did use a `ttk.Style()`, but it only changed the colors of the `ttk.Combobox` background, ent... | 2011/03/08 | [
"https://Stackoverflow.com/questions/5235998",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/623985/"
] | You can use the Combobox's [`selection_clear()`](http://effbot.org/tkinterbook/entry.htm#Tkinter.Entry.selection_clear-method) method to clear the selection whenever you want.
e.g
```
inUnitsValue.selection_clear()
``` | Just refresh the selected value of the Combobox.
This will help for removing the highlight.
```
import tkinter.ttk
import tkinter
items = ["test1","test2","test3","test4"]
class TkCombobox(tkinter.ttk.Combobox):
def __init__(self, *arg, **kwarg):
super(TkCombobox, self).__init__(*arg, **kwarg)
self._s... |
5,235,998 | I wrote a small farad converter to learn GUI programming. It works great, looks fine-ish. The only problem is I can't seem to figure out how to control this strange highlighting that comes up on my `ttk.Combobox` selections. I did use a `ttk.Style()`, but it only changed the colors of the `ttk.Combobox` background, ent... | 2011/03/08 | [
"https://Stackoverflow.com/questions/5235998",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/623985/"
] | Could it be that with a readonly combobox the problem is not the selection but the relatively strong focus-indicator?
With this workarround you lose the ability to control your program by keyboard. To do it right you would have to change the style of the focus-highlighting.
```
from tkinter import *
from ttk import ... | Just refresh the selected value of the Combobox.
This will help for removing the highlight.
```
import tkinter.ttk
import tkinter
items = ["test1","test2","test3","test4"]
class TkCombobox(tkinter.ttk.Combobox):
def __init__(self, *arg, **kwarg):
super(TkCombobox, self).__init__(*arg, **kwarg)
self._s... |
4,433,626 | We have a growing mailing list which we want to send our newsletter to. At the moment we are sending around 1200 per day, but this will increase quite a bit. I've written a PHP script which runs every half hour to send email from a queue. The problem is that it is very slow (for example to send 106 emails took a total ... | 2010/12/13 | [
"https://Stackoverflow.com/questions/4433626",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/541095/"
] | There doesn't appear to be a method, but I am not surprised. Slugify removes characters from the string and unslugify would not know where to put it back in.
For example, if you look at the URL for this question, it is
```
stackoverflow.com/questions/4433620/play-framework-how-do-i-lookup-an-item-from-a-slugify-url
... | Actually you can: you need to store the slugified string into your db.
In your *model*:
```
//import ... ;
import play.templates.JavaExtensions;
@Entity
public class Product extends Model{
public String name;
public String slug;
@PrePersist
@PreUpdate
void pre_update(){
this.slug = Java... |
84,130 | Is there any way to see all publicly shared Google Drive items/documents from a specific Google user? | 2015/09/05 | [
"https://webapps.stackexchange.com/questions/84130",
"https://webapps.stackexchange.com",
"https://webapps.stackexchange.com/users/95229/"
] | I wrote a Google Apps Script macro that you can attach to a new spreadsheet (or an old one, if it would make any sense) that accomplishes this task. To attach a script to a spreadsheet, go into that spreadsheet (or create a new one), click "Tools"->"Script editor...", copy and paste the code into the editor, click "Res... | If you are admin you can use the Drige API with a service account impersonating that user. |
411,968 | I am working with VLC from C# by creating a process that opens the command line.
Is there any way of knowing when a movie ended in from the command line or something ? | 2012/04/13 | [
"https://superuser.com/questions/411968",
"https://superuser.com",
"https://superuser.com/users/128126/"
] | I have googled for solution finally - its not a thing that comes visible with a simple search though. Seems not many people interested.
I am writing from a PC where I do not have Outlook installed, but hope I remember that well.
1. You need to enable Developer "ribbon" in Outlook
2. You need to create new form (usi... | Follow this guideline:
<https://www.datanumen.com/blogs/2-methods-change-default-duration-appointment-meeting-outlook/>
and use the following macro instead:
```
Private WithEvents objInspectors As Outlook.Inspectors
Private WithEvents objAppointment As Outlook.AppointmentItem
Private Sub Application_Startup()
... |
411,968 | I am working with VLC from C# by creating a process that opens the command line.
Is there any way of knowing when a movie ended in from the command line or something ? | 2012/04/13 | [
"https://superuser.com/questions/411968",
"https://superuser.com",
"https://superuser.com/users/128126/"
] | I have googled for solution finally - its not a thing that comes visible with a simple search though. Seems not many people interested.
I am writing from a PC where I do not have Outlook installed, but hope I remember that well.
1. You need to enable Developer "ribbon" in Outlook
2. You need to create new form (usi... | It appears that Outlook has this feature in later versions: <https://chrismenardtraining.com/post/outlook-buffer-time> |
411,968 | I am working with VLC from C# by creating a process that opens the command line.
Is there any way of knowing when a movie ended in from the command line or something ? | 2012/04/13 | [
"https://superuser.com/questions/411968",
"https://superuser.com",
"https://superuser.com/users/128126/"
] | It appears that Outlook has this feature in later versions: <https://chrismenardtraining.com/post/outlook-buffer-time> | Follow this guideline:
<https://www.datanumen.com/blogs/2-methods-change-default-duration-appointment-meeting-outlook/>
and use the following macro instead:
```
Private WithEvents objInspectors As Outlook.Inspectors
Private WithEvents objAppointment As Outlook.AppointmentItem
Private Sub Application_Startup()
... |
42,606,533 | I was given an assignment to find the sum of the squares of the first n odd numbers whereby n is given by the user.
The assignment was;
```
The script only takes one input, so do not
# include any input command below. The print commands below are already given.
# Do not alter the print commands. Do not add any other ... | 2017/03/05 | [
"https://Stackoverflow.com/questions/42606533",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7660992/"
] | ```
r = range(1, n + 1,2)
print r
result = 0
for k in r:
result = result + k ** 2
print result
```
if you pass n=5 then it will print 35 because the range is 1,3,5 and during iteration it skip the step 2,4..you are considering like 1,3,5,7,9=165 but actual result will be 35 so instea... | `n**n` is n to the nth power. So with `n=5`, your range is all the odd numbers between 1 and 3125. It should be odd numbers between 1 and 10.
```
r = range(1, n ** n, 2)
# ^ replace n**n by ...
```
You want to sum squares, so you should compute squares :
```
result = result + k
# ^ ... |
42,606,533 | I was given an assignment to find the sum of the squares of the first n odd numbers whereby n is given by the user.
The assignment was;
```
The script only takes one input, so do not
# include any input command below. The print commands below are already given.
# Do not alter the print commands. Do not add any other ... | 2017/03/05 | [
"https://Stackoverflow.com/questions/42606533",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7660992/"
] | We want to do iterate through odd numbers so if we want to do n odd numbers we need to go up to 2\*n. For example, 5 odd numbers would be 1,3,5,7,9 and 2\*5=10, but we only want every other number so we have the command `r = range(1, n * 2, 2)`
We then start with zero and add to it, hence `result = 0`
Now we iterate ... | `n**n` is n to the nth power. So with `n=5`, your range is all the odd numbers between 1 and 3125. It should be odd numbers between 1 and 10.
```
r = range(1, n ** n, 2)
# ^ replace n**n by ...
```
You want to sum squares, so you should compute squares :
```
result = result + k
# ^ ... |
42,606,533 | I was given an assignment to find the sum of the squares of the first n odd numbers whereby n is given by the user.
The assignment was;
```
The script only takes one input, so do not
# include any input command below. The print commands below are already given.
# Do not alter the print commands. Do not add any other ... | 2017/03/05 | [
"https://Stackoverflow.com/questions/42606533",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7660992/"
] | We want to do iterate through odd numbers so if we want to do n odd numbers we need to go up to 2\*n. For example, 5 odd numbers would be 1,3,5,7,9 and 2\*5=10, but we only want every other number so we have the command `r = range(1, n * 2, 2)`
We then start with zero and add to it, hence `result = 0`
Now we iterate ... | ```
r = range(1, n + 1,2)
print r
result = 0
for k in r:
result = result + k ** 2
print result
```
if you pass n=5 then it will print 35 because the range is 1,3,5 and during iteration it skip the step 2,4..you are considering like 1,3,5,7,9=165 but actual result will be 35 so instea... |
62,454,336 | Env: Python 3.6, O/S: Windows 10
I have the following code that will search for filenames that contain a string either at the start (`.startswith`) of a filename or the end of a filename (`.endswith`), including sub directories and is case sensitive, i.e. `searchText = 'guess'` as opposed to `searchText = 'Guess'`.
I... | 2020/06/18 | [
"https://Stackoverflow.com/questions/62454336",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1709475/"
] | A simple `glob`-based approach:
```
#!/usr/bin/env python3
import os
import glob
# set text to search for
searchText = 'Guess'
# the root (top of tree hierarchy) to search, remember to change \ to / for Windows
TOP = 'C:/works'
found = 0
for filename in glob.iglob(os.path.join(TOP, '**', f'*{searchText}*'), rec... | Instead you can locally store all the .py files in your directory with their absolute path, use a simple regex to see if the absolute path has "Guess" or "guess" (depends on your use). Try this code and let us know
```
import pathlib
import os
import re
required=[]
for filepath in pathlib.Path('C:\\your\\directory... |
631,694 | [](https://i.stack.imgur.com/UBFqR.png)
The supply voltage is 15 V and RL is 100 kΩ. Find the voltage across each diode and RL.
Is = 0.1 μA, η = 2, and VT = 25 mV.
How can I calculate the net current through RL? I have three unknowns: the net current... | 2022/08/18 | [
"https://electronics.stackexchange.com/questions/631694",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/293958/"
] | You'd use the Shockley equation,
$$ I(V\_D)=I\_S \left( e^\frac{V\_D}{\eta V\_T} - 1 \right), $$
to figure it out.
You're given \$I\_S\$, \$V\_T\$ and \$\eta\$.
We can invert this equation: given \$I\$, solve for \$V\_D\$. This will be more useful, since the current \$I\$ is the same for both diodes:
$$
V\_D(I) = \l... | Assuming the circuit is properly drawn and it is assembled with good parts you will not get any current flow through the circuit except for a small leakage current through the D2. D2 will have the supply dropping across it - the Vf of the first diode. There should be no voltage drop across RL other then what is caused ... |
631,694 | [](https://i.stack.imgur.com/UBFqR.png)
The supply voltage is 15 V and RL is 100 kΩ. Find the voltage across each diode and RL.
Is = 0.1 μA, η = 2, and VT = 25 mV.
How can I calculate the net current through RL? I have three unknowns: the net current... | 2022/08/18 | [
"https://electronics.stackexchange.com/questions/631694",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/293958/"
] | Assuming the circuit is properly drawn and it is assembled with good parts you will not get any current flow through the circuit except for a small leakage current through the D2. D2 will have the supply dropping across it - the Vf of the first diode. There should be no voltage drop across RL other then what is caused ... | You simply solve a system with 3 uknowns.
$$
I = I\_{S}\cdot\left(e^{\frac{V\_{D1}}{\eta V\_{T}}}-1\right),\
I = I\_{S}\cdot\left(e^{\frac{V\_{D2}}{\eta V\_{T}}}-1\right),\
I = \frac{V\_{s}-V\_{D1}-V\_{D2}}{R\_{L}}
$$
Be careful of the sign of the voltages \$V\_{D1}\$ and \$V\_{D2}\$
Hint: one is <0 the other is >... |
631,694 | [](https://i.stack.imgur.com/UBFqR.png)
The supply voltage is 15 V and RL is 100 kΩ. Find the voltage across each diode and RL.
Is = 0.1 μA, η = 2, and VT = 25 mV.
How can I calculate the net current through RL? I have three unknowns: the net current... | 2022/08/18 | [
"https://electronics.stackexchange.com/questions/631694",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/293958/"
] | You'd use the Shockley equation,
$$ I(V\_D)=I\_S \left( e^\frac{V\_D}{\eta V\_T} - 1 \right), $$
to figure it out.
You're given \$I\_S\$, \$V\_T\$ and \$\eta\$.
We can invert this equation: given \$I\$, solve for \$V\_D\$. This will be more useful, since the current \$I\$ is the same for both diodes:
$$
V\_D(I) = \l... | You simply solve a system with 3 uknowns.
$$
I = I\_{S}\cdot\left(e^{\frac{V\_{D1}}{\eta V\_{T}}}-1\right),\
I = I\_{S}\cdot\left(e^{\frac{V\_{D2}}{\eta V\_{T}}}-1\right),\
I = \frac{V\_{s}-V\_{D1}-V\_{D2}}{R\_{L}}
$$
Be careful of the sign of the voltages \$V\_{D1}\$ and \$V\_{D2}\$
Hint: one is <0 the other is >... |
631,694 | [](https://i.stack.imgur.com/UBFqR.png)
The supply voltage is 15 V and RL is 100 kΩ. Find the voltage across each diode and RL.
Is = 0.1 μA, η = 2, and VT = 25 mV.
How can I calculate the net current through RL? I have three unknowns: the net current... | 2022/08/18 | [
"https://electronics.stackexchange.com/questions/631694",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/293958/"
] | You'd use the Shockley equation,
$$ I(V\_D)=I\_S \left( e^\frac{V\_D}{\eta V\_T} - 1 \right), $$
to figure it out.
You're given \$I\_S\$, \$V\_T\$ and \$\eta\$.
We can invert this equation: given \$I\$, solve for \$V\_D\$. This will be more useful, since the current \$I\$ is the same for both diodes:
$$
V\_D(I) = \l... | The voltage across the forward-biased diode is going to be less than 0.7V (the forward voltage with substantial current). If you look at the Shockley diode equation, the current with a large negative voltage (relative to \$\eta\$ Vt) will be essentially -Is. So you can then calculate the forward voltage of the forward ... |
631,694 | [](https://i.stack.imgur.com/UBFqR.png)
The supply voltage is 15 V and RL is 100 kΩ. Find the voltage across each diode and RL.
Is = 0.1 μA, η = 2, and VT = 25 mV.
How can I calculate the net current through RL? I have three unknowns: the net current... | 2022/08/18 | [
"https://electronics.stackexchange.com/questions/631694",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/293958/"
] | The voltage across the forward-biased diode is going to be less than 0.7V (the forward voltage with substantial current). If you look at the Shockley diode equation, the current with a large negative voltage (relative to \$\eta\$ Vt) will be essentially -Is. So you can then calculate the forward voltage of the forward ... | You simply solve a system with 3 uknowns.
$$
I = I\_{S}\cdot\left(e^{\frac{V\_{D1}}{\eta V\_{T}}}-1\right),\
I = I\_{S}\cdot\left(e^{\frac{V\_{D2}}{\eta V\_{T}}}-1\right),\
I = \frac{V\_{s}-V\_{D1}-V\_{D2}}{R\_{L}}
$$
Be careful of the sign of the voltages \$V\_{D1}\$ and \$V\_{D2}\$
Hint: one is <0 the other is >... |
635,440 | I am using debian 10 and I want to create a user with no home directory. the user should only have access to the directories that his or her group owns. that is the user has only to his or her group directories.
This is my command information:
`useradd -g mygroup-G mygroup1,mygroup2 -s /bin/bash -M username`
However ... | 2021/02/19 | [
"https://unix.stackexchange.com/questions/635440",
"https://unix.stackexchange.com",
"https://unix.stackexchange.com/users/457004/"
] | 1. There are tools to manipulate filesystems as you ask. One such is the [mtools](https://www.gnu.org/software/mtools/) package, which does FAT filesystems. Another is [e2tools](https://e2tools.github.io), which does EXT2 and EXT3 filesystems. Both of these are available in debian linux, and probably many others.
2. Th... | I use and recommend [`guestfish`](https://libguestfs.org/guestfish.1.html), which is a part of [libguestfs, library for accessing and modifying VM disk images](https://libguestfs.org/).
I've found OpenStack's documentation includes a useful description of tools that do not require privileges: [Modify images — Virtual ... |
4,490,691 | I want to achieve this:
```
public System.Web.Mvc.ActionResult ExposureGrid(Guid? id, decimal stdDev)
{
//return null;
try
{
var str = "<table border=1>";
str += "<tr><th>Date</th><th>Expected Credit Exposure</th><th>Max Credit Exposure</th></... | 2010/12/20 | [
"https://Stackoverflow.com/questions/4490691",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/534101/"
] | change:
```
dataType: "jsonData",
```
to
```
dataType: "json",
```
hopefully, issue should be resolved. | Why you don't load it directly from html ?
Instead of rendering a Json (content-type: application/json), you return it as a partial html element (content-type: text/html) and from JQuery you load it with dataType: "html".
Doing so, you even wouldn't have to change your success method ! |
1,966,030 | I'm writing a simple Twitter example that reads the Twitter Search RSS feed via:
```
http://search.twitter.com/search.rss
```
This works well except that the Description in this contains HTML such as Bold Tags and Link Tags, I have looked at the Atom feed via:
```
http://search.twitter.com/search.atom
```
It also... | 2009/12/27 | [
"https://Stackoverflow.com/questions/1966030",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/61529/"
] | There is a hack:
```
private void setDimButtons(boolean dimButtons) {
Window window = getWindow();
LayoutParams layoutParams = window.getAttributes();
float val = dimButtons ? 0 : -1;
try {
Field buttonBrightness = layoutParams.getClass().getField(
"buttonBrightness");
b... | AFAIK, there is no API to control the backlight of the buttons -- sorry! |
1,966,030 | I'm writing a simple Twitter example that reads the Twitter Search RSS feed via:
```
http://search.twitter.com/search.rss
```
This works well except that the Description in this contains HTML such as Bold Tags and Link Tags, I have looked at the Atom feed via:
```
http://search.twitter.com/search.atom
```
It also... | 2009/12/27 | [
"https://Stackoverflow.com/questions/1966030",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/61529/"
] | There is a hack:
```
private void setDimButtons(boolean dimButtons) {
Window window = getWindow();
LayoutParams layoutParams = window.getAttributes();
float val = dimButtons ? 0 : -1;
try {
Field buttonBrightness = layoutParams.getClass().getField(
"buttonBrightness");
b... | I see that this is an old question that was mostly answered in a comment link, but to make it clear to anyone else who comes across this question, here's my own answer.
It's built-in since API 8. ([doc](http://developer.android.com/reference/android/view/WindowManager.LayoutParams.html#buttonBrightness))
```
float an... |
51,857,207 | I want to change this:
```
input <- c("Théodore Agrippa d'AUBIGNÉ", "Vital d'AUDIGUIER DE LA MENOR")
```
into this :
```
output <- c("Théodore Agrippa d'Aubigné", "Vital d'Audiguier De La Menor")
```
The only words that should be modified are those that are all upper case.
**Edit:**
An edge case, where first l... | 2018/08/15 | [
"https://Stackoverflow.com/questions/51857207",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2270475/"
] | Form two groups with boundaries on both sides as in
```
\b([A-Z])(\w+)\b
```
and use `tolower` on the second group (leaving the first untouched).
See [**a demo on regex101.com**](https://regex101.com/r/gdaEQR/1/) (and mind the modifiers, especially `u`).
---
*As a side note: you still have a couple of questions... | You could also use the [snakecase pkg](https://github.com/Tazinho/snakecase) and specifically set `sep_in = " "` to not delete non-alphanumerics like `'` (default is `sep_in = "[^[:alnum:]]"`):
```r
library(snakecase)
input <- c("Théodore Agrippa d'AUBIGNÉ", "Vital d'AUDIGUIER DE LA MENOR")
output <- c("Théodore Agri... |
51,857,207 | I want to change this:
```
input <- c("Théodore Agrippa d'AUBIGNÉ", "Vital d'AUDIGUIER DE LA MENOR")
```
into this :
```
output <- c("Théodore Agrippa d'Aubigné", "Vital d'Audiguier De La Menor")
```
The only words that should be modified are those that are all upper case.
**Edit:**
An edge case, where first l... | 2018/08/15 | [
"https://Stackoverflow.com/questions/51857207",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2270475/"
] | A general answer that detects all upper case characters and works whatever the encoding, would be :
```
input <- c("Théodore Agrippa d'AUBIGNÉ", "Vital d'AUDIGUIER DE LA MENOR", "Philippe Fabre d'ÉGLANTINE")
gsub("(*UCP)\\b(\\p{Lu})(\\p{Lu}+)\\b", "\\1\\L\\2", input, perl = TRUE)
# [1] "Théodore Agrippa d'Aubigné" ... | You could also use the [snakecase pkg](https://github.com/Tazinho/snakecase) and specifically set `sep_in = " "` to not delete non-alphanumerics like `'` (default is `sep_in = "[^[:alnum:]]"`):
```r
library(snakecase)
input <- c("Théodore Agrippa d'AUBIGNÉ", "Vital d'AUDIGUIER DE LA MENOR")
output <- c("Théodore Agri... |
51,857,207 | I want to change this:
```
input <- c("Théodore Agrippa d'AUBIGNÉ", "Vital d'AUDIGUIER DE LA MENOR")
```
into this :
```
output <- c("Théodore Agrippa d'Aubigné", "Vital d'Audiguier De La Menor")
```
The only words that should be modified are those that are all upper case.
**Edit:**
An edge case, where first l... | 2018/08/15 | [
"https://Stackoverflow.com/questions/51857207",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2270475/"
] | Here is an alternative solution:
```
gsub("(?<=\\p{L})(\\p{L}+)", "\\L\\1", input, perl = TRUE)
```
I'm not trying to compete with the other existing answers, I just solved (or tried) for the challenge and share it here because it might be useful for someone and/or I get constructive feedback on how it could be impr... | You could also use the [snakecase pkg](https://github.com/Tazinho/snakecase) and specifically set `sep_in = " "` to not delete non-alphanumerics like `'` (default is `sep_in = "[^[:alnum:]]"`):
```r
library(snakecase)
input <- c("Théodore Agrippa d'AUBIGNÉ", "Vital d'AUDIGUIER DE LA MENOR")
output <- c("Théodore Agri... |
603,007 | I have had the misfortune to need to clone a dual-booting Windows XP/7 box to replace its hard drive with a smaller one. I had great trouble getting it to boot and would like to understand what's going on and if I could be doing anything better.
Background: the machine has a 750Gb drive with 3 partitions on it:
* Win... | 2013/06/02 | [
"https://superuser.com/questions/603007",
"https://superuser.com",
"https://superuser.com/users/101178/"
] | After cloning partitions containing Windows operating systems, it is necessary to fix up the boot configuration data if the cloned partitions are not in exactly the same position on the cloned disc as they are on the original.
The Windows boot mechanism, since Windows Vista, stores its configuration as "Boot Configur... | According to [this unofficial documentation on BCD internals](http://diddy.boot-land.net/bcdedit/files/bcd.htm), partitions in the BCD store are actually identified by the disk signature and the partition offset. You copied the disk signature (MBR bytes 440–443), but most likely changed partition offsets when putting p... |
4,312,386 | I know it's similar to [this](https://math.stackexchange.com/questions/265809/sup-gyy-in-y-leq-inf-fxx-in-x)
and I proved this inequality, but I'm stuck at finding examples that this inequality is strict.
thanks.
Edit: range is bounded. | 2021/11/21 | [
"https://math.stackexchange.com/questions/4312386",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/470876/"
] | The inequality can be strict if both $X$ and $Y$ have at least two elements. For an example pick arbitrary elements $x\_1 \in X$ and $y\_1 \in Y$ and define
$$
f(x, y) = \begin{cases}
0 & \text{ if } x=x\_1 \text{ and } y = y\_1 \\
1 & \text{ if } x=x\_1 \text{ and } y \ne y\_1 \\
1 & \text{ if } x\ne x\_1 \text{ a... | Any nonzero linear function should demonstrate this. For example:
Set $X=\mathbb{R}$ and $Y=\mathbb{R}$ and $f(x,y)=x+y$. Then, for any fixed $y^\*\in Y$, we have $\inf\_{x\in X}f(x,y)=\inf\_{x\in\mathbb{R}}(x+y^\*)\to-\infty$, so $$\sup\_{y\in Y}\big(\inf\_{x\in X}f(x,y))\big)=\sup\_{y\in Y}\{-\infty\}=-\infty.$$
Sim... |
31,607,465 | I'm new here and registered because I couldn't find my answer in the existing treads.
I'm trying to make a one-page website, and I want the 'landing page' to have a full background. I had the background on the whole page, but when I started placing text in the div, it broke. I used the following css (sass):
```
.int... | 2015/07/24 | [
"https://Stackoverflow.com/questions/31607465",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5151678/"
] | Your problem is with [margin collapsing](https://developer.mozilla.org/en-US/docs/Web/CSS/margin_collapsing):
**Parent and first/last child**
If there is no border, padding, inline content, or clearance to separate the margin-top of a block with the margin-top of its first child block, or no border, padding, inline... | You have not disabled the margin of the body. Add this to your CSS
```
body{
margin:0px;
}
```
edit: The answer Pete posted seems to be the complete solution, sorry was too slow! |
31,607,465 | I'm new here and registered because I couldn't find my answer in the existing treads.
I'm trying to make a one-page website, and I want the 'landing page' to have a full background. I had the background on the whole page, but when I started placing text in the div, it broke. I used the following css (sass):
```
.int... | 2015/07/24 | [
"https://Stackoverflow.com/questions/31607465",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5151678/"
] | Your problem is with [margin collapsing](https://developer.mozilla.org/en-US/docs/Web/CSS/margin_collapsing):
**Parent and first/last child**
If there is no border, padding, inline content, or clearance to separate the margin-top of a block with the margin-top of its first child block, or no border, padding, inline... | This was already said above in a side conversation, but it worked for me and I want people to find it easily.
```
-- overflow-x:hidden; on both html, body in the css.
``` |
31,607,465 | I'm new here and registered because I couldn't find my answer in the existing treads.
I'm trying to make a one-page website, and I want the 'landing page' to have a full background. I had the background on the whole page, but when I started placing text in the div, it broke. I used the following css (sass):
```
.int... | 2015/07/24 | [
"https://Stackoverflow.com/questions/31607465",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5151678/"
] | You have not disabled the margin of the body. Add this to your CSS
```
body{
margin:0px;
}
```
edit: The answer Pete posted seems to be the complete solution, sorry was too slow! | This was already said above in a side conversation, but it worked for me and I want people to find it easily.
```
-- overflow-x:hidden; on both html, body in the css.
``` |
8,187,082 | Suppose I have a class with a constructor (or other function) that takes a variable number of arguments and then sets them as class attributes conditionally.
I could set them manually, but it seems that variable parameters are common enough in python that there should be a common idiom for doing this. But I'm not sure... | 2011/11/18 | [
"https://Stackoverflow.com/questions/8187082",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12982/"
] | You can use the [`setattr()`](https://docs.python.org/3/library/functions.html#setattr) method:
```
class Foo:
def setAllWithKwArgs(self, **kwargs):
for key, value in kwargs.items():
setattr(self, key, value)
```
There is an analogous [`getattr()`](https://docs.python.org/3/library/functions.html#getattr... | The following solutions `vars(self).update(kwargs)` or `self.__dict__.update(**kwargs)` are not robust, because the user can enter any dictionary with no error messages. If I need to check that the user insert the following signature ('a1', 'a2', 'a3', 'a4', 'a5') the solution does not work. Moreover, the user should b... |
8,187,082 | Suppose I have a class with a constructor (or other function) that takes a variable number of arguments and then sets them as class attributes conditionally.
I could set them manually, but it seems that variable parameters are common enough in python that there should be a common idiom for doing this. But I'm not sure... | 2011/11/18 | [
"https://Stackoverflow.com/questions/8187082",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12982/"
] | This is what I usually do:
```
class Foo():
def __init__(self, **kwrgs):
allowed_args = ('a', 'b', 'c')
default_values = {'a':None, 'b':None}
self.__dict__.update(default_values)
if set(kwrgs.keys()).issubset(allowed_args):
self.__dict__.update(kwrgs)
else:
... | I landed on this page with a subtly different question, but here's the answer I needed:
Try `namedtuple` class ([see this answer](https://stackoverflow.com/a/34573457/93910)), or the `@dataclass` decorator ([this question](https://stackoverflow.com/questions/47955263/what-are-data-classes-and-how-are-they-different-fr... |
8,187,082 | Suppose I have a class with a constructor (or other function) that takes a variable number of arguments and then sets them as class attributes conditionally.
I could set them manually, but it seems that variable parameters are common enough in python that there should be a common idiom for doing this. But I'm not sure... | 2011/11/18 | [
"https://Stackoverflow.com/questions/8187082",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12982/"
] | this one is the easiest via [larsks](https://stackoverflow.com/users/147356/larsks)
```
class Foo:
def setAllWithKwArgs(self, **kwargs):
for key, value in kwargs.items():
setattr(self, key, value)
```
my example:
```
class Foo:
def __init__(self, **kwargs):
for key, value in kwar... | Their might be a better solution but what comes to mind for me is:
```
class Test:
def __init__(self, *args, **kwargs):
self.args=dict(**kwargs)
def getkwargs(self):
print(self.args)
t=Test(a=1, b=2, c="cats")
t.getkwargs()
python Test.py
{'a': 1, 'c': 'cats', 'b': 2}
``` |
8,187,082 | Suppose I have a class with a constructor (or other function) that takes a variable number of arguments and then sets them as class attributes conditionally.
I could set them manually, but it seems that variable parameters are common enough in python that there should be a common idiom for doing this. But I'm not sure... | 2011/11/18 | [
"https://Stackoverflow.com/questions/8187082",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12982/"
] | You could update the `__dict__` attribute (which represents the instance attributes in the form of a dictionary) with the keyword arguments:
```
class Bar(object):
def __init__(self, **kwargs):
self.__dict__.update(kwargs)
```
then you can:
```
>>> bar = Bar(a=1, b=2)
>>> bar.a
1
```
and with somethin... | Yet another variant based on the excellent answers by [mmj](https://stackoverflow.com/a/32019483/7382307) and [fqxp](https://stackoverflow.com/a/8187408/7382307). What if we want to
1. Avoid hardcoding a list of allowed attributes
2. *Directly* and explicitly set default values for each attributes in the constructor
3... |
8,187,082 | Suppose I have a class with a constructor (or other function) that takes a variable number of arguments and then sets them as class attributes conditionally.
I could set them manually, but it seems that variable parameters are common enough in python that there should be a common idiom for doing this. But I'm not sure... | 2011/11/18 | [
"https://Stackoverflow.com/questions/8187082",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12982/"
] | Both the `setattr()` and `__dict__.update()` methods bypass property `@setter` functions. The only way I have found to get this to work is by using `exec()`.
`exec` is considered a security risk, but we're not using it with any old user input, so I can't see why it would be. If you disagree I'd really like to learn wh... | I suspect it might be better in most instances to use named args (for better self documenting code) so it might look something like this:
```
class Foo:
def setAll(a=None, b=None, c=None):
for key, value in (a, b, c):
if (value != None):
settattr(self, key, value)
``` |
8,187,082 | Suppose I have a class with a constructor (or other function) that takes a variable number of arguments and then sets them as class attributes conditionally.
I could set them manually, but it seems that variable parameters are common enough in python that there should be a common idiom for doing this. But I'm not sure... | 2011/11/18 | [
"https://Stackoverflow.com/questions/8187082",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12982/"
] | The following solutions `vars(self).update(kwargs)` or `self.__dict__.update(**kwargs)` are not robust, because the user can enter any dictionary with no error messages. If I need to check that the user insert the following signature ('a1', 'a2', 'a3', 'a4', 'a5') the solution does not work. Moreover, the user should b... | I suspect it might be better in most instances to use named args (for better self documenting code) so it might look something like this:
```
class Foo:
def setAll(a=None, b=None, c=None):
for key, value in (a, b, c):
if (value != None):
settattr(self, key, value)
``` |
8,187,082 | Suppose I have a class with a constructor (or other function) that takes a variable number of arguments and then sets them as class attributes conditionally.
I could set them manually, but it seems that variable parameters are common enough in python that there should be a common idiom for doing this. But I'm not sure... | 2011/11/18 | [
"https://Stackoverflow.com/questions/8187082",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12982/"
] | Most answers here do not cover a good way to initialize all allowed attributes to just one default value.
So, to add to the answers given by [@fqxp](https://stackoverflow.com/a/8187408/3357935) and [@mmj](https://stackoverflow.com/a/32019483/3357935):
```
class Myclass:
def __init__(self, **kwargs):
# all... | The following solutions `vars(self).update(kwargs)` or `self.__dict__.update(**kwargs)` are not robust, because the user can enter any dictionary with no error messages. If I need to check that the user insert the following signature ('a1', 'a2', 'a3', 'a4', 'a5') the solution does not work. Moreover, the user should b... |
8,187,082 | Suppose I have a class with a constructor (or other function) that takes a variable number of arguments and then sets them as class attributes conditionally.
I could set them manually, but it seems that variable parameters are common enough in python that there should be a common idiom for doing this. But I'm not sure... | 2011/11/18 | [
"https://Stackoverflow.com/questions/8187082",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12982/"
] | Their might be a better solution but what comes to mind for me is:
```
class Test:
def __init__(self, *args, **kwargs):
self.args=dict(**kwargs)
def getkwargs(self):
print(self.args)
t=Test(a=1, b=2, c="cats")
t.getkwargs()
python Test.py
{'a': 1, 'c': 'cats', 'b': 2}
``` | I landed on this page with a subtly different question, but here's the answer I needed:
Try `namedtuple` class ([see this answer](https://stackoverflow.com/a/34573457/93910)), or the `@dataclass` decorator ([this question](https://stackoverflow.com/questions/47955263/what-are-data-classes-and-how-are-they-different-fr... |
8,187,082 | Suppose I have a class with a constructor (or other function) that takes a variable number of arguments and then sets them as class attributes conditionally.
I could set them manually, but it seems that variable parameters are common enough in python that there should be a common idiom for doing this. But I'm not sure... | 2011/11/18 | [
"https://Stackoverflow.com/questions/8187082",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12982/"
] | You can use the [`setattr()`](https://docs.python.org/3/library/functions.html#setattr) method:
```
class Foo:
def setAllWithKwArgs(self, **kwargs):
for key, value in kwargs.items():
setattr(self, key, value)
```
There is an analogous [`getattr()`](https://docs.python.org/3/library/functions.html#getattr... | Most answers here do not cover a good way to initialize all allowed attributes to just one default value.
So, to add to the answers given by [@fqxp](https://stackoverflow.com/a/8187408/3357935) and [@mmj](https://stackoverflow.com/a/32019483/3357935):
```
class Myclass:
def __init__(self, **kwargs):
# all... |
8,187,082 | Suppose I have a class with a constructor (or other function) that takes a variable number of arguments and then sets them as class attributes conditionally.
I could set them manually, but it seems that variable parameters are common enough in python that there should be a common idiom for doing this. But I'm not sure... | 2011/11/18 | [
"https://Stackoverflow.com/questions/8187082",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12982/"
] | Most answers here do not cover a good way to initialize all allowed attributes to just one default value.
So, to add to the answers given by [@fqxp](https://stackoverflow.com/a/8187408/3357935) and [@mmj](https://stackoverflow.com/a/32019483/3357935):
```
class Myclass:
def __init__(self, **kwargs):
# all... | I landed on this page with a subtly different question, but here's the answer I needed:
Try `namedtuple` class ([see this answer](https://stackoverflow.com/a/34573457/93910)), or the `@dataclass` decorator ([this question](https://stackoverflow.com/questions/47955263/what-are-data-classes-and-how-are-they-different-fr... |
148,065 | I seem to see the phrase "shake his booty" being used to say something is good and attractive. But does it mean "shake his butt"? And if they are the same, why does "shake his butt" seem a somewhat distasteful action, but "shake his booty" all of a sudden becomes somewhat glamorous? | 2014/01/26 | [
"https://english.stackexchange.com/questions/148065",
"https://english.stackexchange.com",
"https://english.stackexchange.com/users/1204/"
] | "Neither is glamorous! "Booty" is [American slang for buttocks](http://www.urbandictionary.com/define.php?term=booty) but almost universally refers to that of a woman. "Butt" is also slang for "buttocks" but does not imply gender. Moreover, "booty" has overt sexual overtones (and is, in fact, slang for having sex in so... | "Booty" is a word for a person's rear end from the [African American Vernacular English](http://en.wikipedia.org/wiki/African_American_Vernacular_English) dialect. I believe it probably first entered wider usage through disco music, particularly in the phrase ["Shake your booty"](http://en.wikipedia.org/wiki/%28Shake,_... |
45,541,902 | Say we have 3 kafka partitions for one topic, and I want my events to be windowed by the hour, using event time.
Will the kafka consumer stop reading from a partition when it is outside of the current window? Or does it open a new window? If it is opening new windows then wouldn't it be theoretically possible to have... | 2017/08/07 | [
"https://Stackoverflow.com/questions/45541902",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3305586/"
] | So first of all events from Kafka are read constantly and the further windowing operations have no impact on that. There are more things to consider when talking about running out-of-memory.
* usually you do not store every event for a window, but just some aggregate for the event
* whenever window is closed the corre... | **You could try to use this type of style**
```
public void runStartFromLatestOffsets() throws Exception {
// 50 records written to each of 3 partitions before launching a latest-starting consuming job
final int parallelism = 3;
final int recordsInEachPartition = 50;
// each partition ... |
63,084 | The background of my question relies on the following points.
* Quine-Duhem thesis: it is difficult to test a theory with an experiment,
because the test would rely on other theories.
* The discussion of the previous point is difficult because we do not
have a "theory of everything", so it is not clear if the chain
of... | 2019/04/24 | [
"https://philosophy.stackexchange.com/questions/63084",
"https://philosophy.stackexchange.com",
"https://philosophy.stackexchange.com/users/39393/"
] | In addition to Nietzsche:
---
[Rousseau](https://en.wikipedia.org/wiki/Jean-Jacques_Rousseau) wrote both the music and libretto for an opera - [Le Devin du Village](https://en.wikipedia.org/wiki/Le_devin_du_village).
[Rousseau - Le Devin du Village on YouTube](https://www.youtube.com/watch?v=Ld7XDELDnto)
---
[Ador... | Gabriel Marcel according to Brendan Sweetman composed music:
>
> He also developed a keen interest in classical music and composed a number of pieces.
>
>
>
However, I could not find a list of these compositions.
---
Thanks to @sand1 from comments: "La Biblitheque Nationale Francaise list has a section for him ... |
5,094 | Which of the following sentences is better to use?
>
> 1. Where it is concluded that the report is incorrect it will be returned.
> 2. If the report is incorrect then it will be returned.
>
>
>
Or do they mean the same thing?
These sentences will be used for a description of activities. | 2010/11/16 | [
"https://english.stackexchange.com/questions/5094",
"https://english.stackexchange.com",
"https://english.stackexchange.com/users/201/"
] | In your examples, the sentence starting with *if* is easier to understand. But it always depends on the context of what's being written as well as target audience. I find *where* is used more often in formal writings, but not always. | **If**.
If you use *where*, the sentence is harder to parse. You run the risk of confusing your audience, who might think that you're talking about a location. |
5,094 | Which of the following sentences is better to use?
>
> 1. Where it is concluded that the report is incorrect it will be returned.
> 2. If the report is incorrect then it will be returned.
>
>
>
Or do they mean the same thing?
These sentences will be used for a description of activities. | 2010/11/16 | [
"https://english.stackexchange.com/questions/5094",
"https://english.stackexchange.com",
"https://english.stackexchange.com/users/201/"
] | In your examples, the sentence starting with *if* is easier to understand. But it always depends on the context of what's being written as well as target audience. I find *where* is used more often in formal writings, but not always. | "Where" is making a more general statement. In particular the statement with "if" would be appropriate whether we were talking about a particular report right now, or about any report which might happen to be produced; "where" would be appropriate only in the latter case.
Apart from that, I agree with vehomzzz and jos... |
38,552,131 | Question
========
I want to separate my prod settings from my local settings. I found this library [django-split-settings](https://github.com/sobolevn/django-split-settings), which worked nicely.
However somewhere in my code I have something like this:
```
if settings.DEBUG:
# do debug stuff
else:
# do prod st... | 2016/07/24 | [
"https://Stackoverflow.com/questions/38552131",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/766570/"
] | This is an old question, here is the answer:
* with older versions of scapy, it simply was not possible
* with newer scapy versions (2.4.0+), simply sniff using the monitor argument
`sniff([args], monitor=True)`
It shows all packets ! | I think you're looking for something like this: [How can I put mac os x en1 interface into monitor mode to use with python3 scapy?](https://stackoverflow.com/questions/31459949/how-can-i-put-mac-os-x-en1-interface-into-monitor-mode-to-use-with-python3-scapy)
It is possible, shouldn't be a problem to switch between pyt... |
38,552,131 | Question
========
I want to separate my prod settings from my local settings. I found this library [django-split-settings](https://github.com/sobolevn/django-split-settings), which worked nicely.
However somewhere in my code I have something like this:
```
if settings.DEBUG:
# do debug stuff
else:
# do prod st... | 2016/07/24 | [
"https://Stackoverflow.com/questions/38552131",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/766570/"
] | This is an old question, here is the answer:
* with older versions of scapy, it simply was not possible
* with newer scapy versions (2.4.0+), simply sniff using the monitor argument
`sniff([args], monitor=True)`
It shows all packets ! | I know this is a old question but I had the same problem. I'm unsure as to why en0 appears to be deactivated after running `airportd en0 sniff 1` or `airport sniff`.
To keep the device active while monitoring you can instead use `tcpdump`.
**Example:**
```
$ sudo tcpdump -nnvs0 -I -i en0 -w output.pcap
$ ifconfig
... |
14,321,101 | I'm using Flash Builder 4.7. When starting a new Actionscript Project, the first popup box where you define the project name etc doesn't show any SDK's. So under "This project will use" there is just an empty area...
And in the created project I also can't link to a Flex SDK in the Actionscript Build Path.
When start... | 2013/01/14 | [
"https://Stackoverflow.com/questions/14321101",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/278949/"
] | Problem found and solved thanks to this blog post:
<http://www.badu.ro/?p=238>
Apparantly when moving from Flex Builder 4.6 to 4.7 you have to use new workspaces. If you reuse the existing ones from version 4.6 you run into problems like I was having...
Thanks for all your help,
Frank | I suspect you are seeing errors because your class has no package definition.
```
package com.something.something
{
// imports
import flash.display.Sprite
// class definition
public class Something extends Sprite{
}
}
```
But, you didn't show us the actual errors in your screenshot. IF that is not the erro... |
158,224 | I am using the below code
```
Web rootWeb = clientContext.Site.RootWeb;
rootWeb.Fields.AddFieldAsXml("<Field DisplayName='Session Name' Name='SessionName' ID='"+new GUID()+"' Group='SharePoint Saturday 2014 Columns' Type='Text' />", false, AddFieldOptions.AddFieldInternalNameHint);
clientContext.Execut... | 2015/09/29 | [
"https://sharepoint.stackexchange.com/questions/158224",
"https://sharepoint.stackexchange.com",
"https://sharepoint.stackexchange.com/users/41560/"
] | I removed the ID parameter in the column creation and it worked fine
```
Web rootWeb = clientContext.Site.RootWeb;
rootWeb.Fields.AddFieldAsXml("<Field DisplayName='Session Name' Name='SessionName' Group='SharePoint Saturday 2014 Columns' Type='Text' />", false, AddFieldOptions.AddFieldInternalNameHint);
... | I have faced this issue before. The error says that there already exists a column named `SessionName`. Replace `SessionName` with `SessionNameTest` and try. Mostly this will solve your issue. |
158,224 | I am using the below code
```
Web rootWeb = clientContext.Site.RootWeb;
rootWeb.Fields.AddFieldAsXml("<Field DisplayName='Session Name' Name='SessionName' ID='"+new GUID()+"' Group='SharePoint Saturday 2014 Columns' Type='Text' />", false, AddFieldOptions.AddFieldInternalNameHint);
clientContext.Execut... | 2015/09/29 | [
"https://sharepoint.stackexchange.com/questions/158224",
"https://sharepoint.stackexchange.com",
"https://sharepoint.stackexchange.com/users/41560/"
] | I have faced this issue before. The error says that there already exists a column named `SessionName`. Replace `SessionName` with `SessionNameTest` and try. Mostly this will solve your issue. | But to be useful i guess you need to set name through a variable like
```
string columnName;
string groupName;
rootWeb.Fields.AddFieldAsXml("<Field DisplayName='"+columnName+"' Name='" + columnName + "' Group='" + groupName + "' Type='Text' />", false, AddFieldOptions.AddFieldInternalNameHint);
```
Then you can add... |
158,224 | I am using the below code
```
Web rootWeb = clientContext.Site.RootWeb;
rootWeb.Fields.AddFieldAsXml("<Field DisplayName='Session Name' Name='SessionName' ID='"+new GUID()+"' Group='SharePoint Saturday 2014 Columns' Type='Text' />", false, AddFieldOptions.AddFieldInternalNameHint);
clientContext.Execut... | 2015/09/29 | [
"https://sharepoint.stackexchange.com/questions/158224",
"https://sharepoint.stackexchange.com",
"https://sharepoint.stackexchange.com/users/41560/"
] | I removed the ID parameter in the column creation and it worked fine
```
Web rootWeb = clientContext.Site.RootWeb;
rootWeb.Fields.AddFieldAsXml("<Field DisplayName='Session Name' Name='SessionName' Group='SharePoint Saturday 2014 Columns' Type='Text' />", false, AddFieldOptions.AddFieldInternalNameHint);
... | But to be useful i guess you need to set name through a variable like
```
string columnName;
string groupName;
rootWeb.Fields.AddFieldAsXml("<Field DisplayName='"+columnName+"' Name='" + columnName + "' Group='" + groupName + "' Type='Text' />", false, AddFieldOptions.AddFieldInternalNameHint);
```
Then you can add... |
18,466,107 | I've created some utilities that help me at generating HTML and I reference them in my views as `@div( "class" -> "well" ){ Hello Well. }`. Until now those classes were subclassing `NodeSeq` because they [aren't escaped](https://github.com/playframework/playframework/blob/702d48bf4d9d24b58f247546b0cd0cb893659dc0/framew... | 2013/08/27 | [
"https://Stackoverflow.com/questions/18466107",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1493269/"
] | If the PID is stored in a variable called `x`, then the last digit can be found as `x % 10`. | Use `mod 10` to get the value, for example:
```
int a = 123;
printf("%d\n", a % 10)
```
Output:
```
3
```
Of course you will need the pid instead of a. |
18,466,107 | I've created some utilities that help me at generating HTML and I reference them in my views as `@div( "class" -> "well" ){ Hello Well. }`. Until now those classes were subclassing `NodeSeq` because they [aren't escaped](https://github.com/playframework/playframework/blob/702d48bf4d9d24b58f247546b0cd0cb893659dc0/framew... | 2013/08/27 | [
"https://Stackoverflow.com/questions/18466107",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1493269/"
] | If the PID is stored in a variable called `x`, then the last digit can be found as `x % 10`. | Use [modulo](http://en.wikipedia.org/wiki/Modulo_operation)
`int lastDigit = pid % 10;`
Be careful though, if that last digit is a 0, you'll get problems! |
18,466,107 | I've created some utilities that help me at generating HTML and I reference them in my views as `@div( "class" -> "well" ){ Hello Well. }`. Until now those classes were subclassing `NodeSeq` because they [aren't escaped](https://github.com/playframework/playframework/blob/702d48bf4d9d24b58f247546b0cd0cb893659dc0/framew... | 2013/08/27 | [
"https://Stackoverflow.com/questions/18466107",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1493269/"
] | If the PID is stored in a variable called `x`, then the last digit can be found as `x % 10`. | PID is usually of type pid\_t an integer type, from "sys/types.h". As it should be a *signed* type recommend
unsigned LastDigit = ((unsigned) pid) % 10;
This will insure your mod does not report negative results, as in -57%10 --> -7.
`sleep(t)` takes an `unsigned` parameter. Should your variable `pid`, take on a neg... |
18,466,107 | I've created some utilities that help me at generating HTML and I reference them in my views as `@div( "class" -> "well" ){ Hello Well. }`. Until now those classes were subclassing `NodeSeq` because they [aren't escaped](https://github.com/playframework/playframework/blob/702d48bf4d9d24b58f247546b0cd0cb893659dc0/framew... | 2013/08/27 | [
"https://Stackoverflow.com/questions/18466107",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1493269/"
] | Use [modulo](http://en.wikipedia.org/wiki/Modulo_operation)
`int lastDigit = pid % 10;`
Be careful though, if that last digit is a 0, you'll get problems! | Use `mod 10` to get the value, for example:
```
int a = 123;
printf("%d\n", a % 10)
```
Output:
```
3
```
Of course you will need the pid instead of a. |
18,466,107 | I've created some utilities that help me at generating HTML and I reference them in my views as `@div( "class" -> "well" ){ Hello Well. }`. Until now those classes were subclassing `NodeSeq` because they [aren't escaped](https://github.com/playframework/playframework/blob/702d48bf4d9d24b58f247546b0cd0cb893659dc0/framew... | 2013/08/27 | [
"https://Stackoverflow.com/questions/18466107",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1493269/"
] | Use [modulo](http://en.wikipedia.org/wiki/Modulo_operation)
`int lastDigit = pid % 10;`
Be careful though, if that last digit is a 0, you'll get problems! | PID is usually of type pid\_t an integer type, from "sys/types.h". As it should be a *signed* type recommend
unsigned LastDigit = ((unsigned) pid) % 10;
This will insure your mod does not report negative results, as in -57%10 --> -7.
`sleep(t)` takes an `unsigned` parameter. Should your variable `pid`, take on a neg... |
34,415,375 | I have an entity with `@OneToOne` mapped subentity:
```
@Entity @Table
public class BaseEntity {
@Id
private String key;
@OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
private InnerEntity inner;
}
@Entity @Table
public class InnerEntity {
private String data;
}
```
It was worki... | 2015/12/22 | [
"https://Stackoverflow.com/questions/34415375",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/610215/"
] | If you want `inner` field to be loaded on demand and your relation is `@OnToOne`you can try this
`@OneToOne(fetch = FetchType.LAZY, optional = false)` | When using HQL hibernate doesn't consider the annotations, so you should tell it how to work.
In your case you should right the HQL like this:
SELECT e FROM BaseEntity as e left join fetch e.inner |
57,412,417 | i have a array `banks`
and I need to return one object with all the parameters described below
```
const banks = [{kod: 723,name: "bank",},{kod: 929,name: "bank2"}]
```
i tried to do it with
```
const lookup = banks.map(item => {
return ({[item.kod]: item.name })
})
```
but it returns the result `[ {723: "ban... | 2019/08/08 | [
"https://Stackoverflow.com/questions/57412417",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10473328/"
] | You can use [`.reduce()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce) with the [spread syntax](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax) like so:
```js
const banks = [{kod: 723,name: "bank",},{kod: 929,name: "bank2"}];
... | You can use `reduce` instead
```js
const banks = [{kod: 723,name: "bank",},{kod: 929,name: "bank2"}]
const lookup = banks.reduce((op,item) => {
op[item.kod] = item.name
return op
},{})
console.log(lookup)
``` |
57,412,417 | i have a array `banks`
and I need to return one object with all the parameters described below
```
const banks = [{kod: 723,name: "bank",},{kod: 929,name: "bank2"}]
```
i tried to do it with
```
const lookup = banks.map(item => {
return ({[item.kod]: item.name })
})
```
but it returns the result `[ {723: "ban... | 2019/08/08 | [
"https://Stackoverflow.com/questions/57412417",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10473328/"
] | You can use [`.reduce()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce) with the [spread syntax](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax) like so:
```js
const banks = [{kod: 723,name: "bank",},{kod: 929,name: "bank2"}];
... | You could take the result and assign all parts to a new object.
```js
const
banks = [{ kod: 723, name: "bank" }, { kod: 929, name: "bank2" }],
lookup = Object.assign({}, ...banks.map(({ kod, name }) => ({ [kod]: name })));
console.log(lookup);
``` |
4,055,939 | I am having a problem with the asp:Menu control.
A menu control 2 levels deep does not play well with internet explorer on https.
I continually get an annoying popup.
I think in order to fix this I need to override a function in an automatically included script file.
change this
```
function PopOut_Show(panelI... | 2010/10/29 | [
"https://Stackoverflow.com/questions/4055939",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/102526/"
] | If you declare the overload later that should be the function that executes
```
function alerttest(){
alert("1");
}
function alerttest(){
alert("2");
}
alerttest();
```
Here is another answer:
[Overriding a JavaScript function while referencing the original](https://stackoverflow.com/questions/296667/overriding-a... | ```
childFrame.src = (data.iframeUrl ? data.iframeUrl : "about:blank");
```
Is identical to:
```
if(data.iframeUrl){
childFrame.src = data.iframeUrl;
}
else{
childFrame.src = 'about:blank';
}
```
Why do you need to override the function? |
18,500,368 | I'm learning JavaScript from w3schools and it talks about how "If you execute document.write after the document has finished loading, the entire HTML page will be overwritten" and I've seen from examples that this does in fact happen, but "I don't understand what is really going on and the website kind seems to skip ov... | 2013/08/29 | [
"https://Stackoverflow.com/questions/18500368",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2727356/"
] | If you're familiar with programming in general then you'll be aware of `stream`s, which represent something you can read from, or write to, in continuous fashion and (usually) lack random-access.
Imagine that the `document` object contains hidden inside it a stream that represents the raw text response from the webser... | What happens depends on what browser you are using. Until recently your code would replace the page with the text in all browsers, but lately the implementation has changed in some browsers to simply ignore the `document.write` call instead of implicitly calling `document.open` first if it hasn't been called already.
... |
72,998,115 | My text in the button is not centered.
I feel that this happens all the time.
The text always seems to be a bit under the center.
I tried to open the code with Chrome and Edge. They look the same.
Here's a photo of the button
```css
.button-container {
display: flex;
position: absolute;
top: 10px;
right: 10px;... | 2022/07/15 | [
"https://Stackoverflow.com/questions/72998115",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19480643/"
] | Removing everything but the following provided the desire result of centering:
```
.button-container {
text-align: center;
vertical-align: middle;
}
```
Padding, in the comment above, is appropriate as well. Take your padding and simply apply it to the `.button-container` CSS script. It will move the button down... | use for button class
```
.button {
text-align: center;
}
``` |
72,998,115 | My text in the button is not centered.
I feel that this happens all the time.
The text always seems to be a bit under the center.
I tried to open the code with Chrome and Edge. They look the same.
Here's a photo of the button
```css
.button-container {
display: flex;
position: absolute;
top: 10px;
right: 10px;... | 2022/07/15 | [
"https://Stackoverflow.com/questions/72998115",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19480643/"
] | You are trying to position an element using hard coded padding values. My advice would be not to do that.
Remove the padding and change your x -> X. Then add these to your class
```
.button {height: 15px; aspect-ratio: 1/1;}
```
Whatever you set the height to the width will follow. With your border radius you can t... | use for button class
```
.button {
text-align: center;
}
``` |
72,998,115 | My text in the button is not centered.
I feel that this happens all the time.
The text always seems to be a bit under the center.
I tried to open the code with Chrome and Edge. They look the same.
Here's a photo of the button
```css
.button-container {
display: flex;
position: absolute;
top: 10px;
right: 10px;... | 2022/07/15 | [
"https://Stackoverflow.com/questions/72998115",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19480643/"
] | There are two big issues in your code:
* First, you want your button to have the same `height` and `width`.
Either set those two properties separately or use the `aspect-ratio` property as suggested by [`@fluffybacon`](https://stackoverflow.com/a/72998212/3723993).
* Then, you are using a character that it's not a pe... | use for button class
```
.button {
text-align: center;
}
``` |
72,998,115 | My text in the button is not centered.
I feel that this happens all the time.
The text always seems to be a bit under the center.
I tried to open the code with Chrome and Edge. They look the same.
Here's a photo of the button
```css
.button-container {
display: flex;
position: absolute;
top: 10px;
right: 10px;... | 2022/07/15 | [
"https://Stackoverflow.com/questions/72998115",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19480643/"
] | Removing everything but the following provided the desire result of centering:
```
.button-container {
text-align: center;
vertical-align: middle;
}
```
Padding, in the comment above, is appropriate as well. Take your padding and simply apply it to the `.button-container` CSS script. It will move the button down... | add below codes to class .button-container:
```
align-items: center;
justify-content: center;
``` |
72,998,115 | My text in the button is not centered.
I feel that this happens all the time.
The text always seems to be a bit under the center.
I tried to open the code with Chrome and Edge. They look the same.
Here's a photo of the button
```css
.button-container {
display: flex;
position: absolute;
top: 10px;
right: 10px;... | 2022/07/15 | [
"https://Stackoverflow.com/questions/72998115",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19480643/"
] | You are trying to position an element using hard coded padding values. My advice would be not to do that.
Remove the padding and change your x -> X. Then add these to your class
```
.button {height: 15px; aspect-ratio: 1/1;}
```
Whatever you set the height to the width will follow. With your border radius you can t... | add below codes to class .button-container:
```
align-items: center;
justify-content: center;
``` |
72,998,115 | My text in the button is not centered.
I feel that this happens all the time.
The text always seems to be a bit under the center.
I tried to open the code with Chrome and Edge. They look the same.
Here's a photo of the button
```css
.button-container {
display: flex;
position: absolute;
top: 10px;
right: 10px;... | 2022/07/15 | [
"https://Stackoverflow.com/questions/72998115",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19480643/"
] | There are two big issues in your code:
* First, you want your button to have the same `height` and `width`.
Either set those two properties separately or use the `aspect-ratio` property as suggested by [`@fluffybacon`](https://stackoverflow.com/a/72998212/3723993).
* Then, you are using a character that it's not a pe... | add below codes to class .button-container:
```
align-items: center;
justify-content: center;
``` |
72,998,115 | My text in the button is not centered.
I feel that this happens all the time.
The text always seems to be a bit under the center.
I tried to open the code with Chrome and Edge. They look the same.
Here's a photo of the button
```css
.button-container {
display: flex;
position: absolute;
top: 10px;
right: 10px;... | 2022/07/15 | [
"https://Stackoverflow.com/questions/72998115",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19480643/"
] | You are trying to position an element using hard coded padding values. My advice would be not to do that.
Remove the padding and change your x -> X. Then add these to your class
```
.button {height: 15px; aspect-ratio: 1/1;}
```
Whatever you set the height to the width will follow. With your border radius you can t... | Removing everything but the following provided the desire result of centering:
```
.button-container {
text-align: center;
vertical-align: middle;
}
```
Padding, in the comment above, is appropriate as well. Take your padding and simply apply it to the `.button-container` CSS script. It will move the button down... |
72,998,115 | My text in the button is not centered.
I feel that this happens all the time.
The text always seems to be a bit under the center.
I tried to open the code with Chrome and Edge. They look the same.
Here's a photo of the button
```css
.button-container {
display: flex;
position: absolute;
top: 10px;
right: 10px;... | 2022/07/15 | [
"https://Stackoverflow.com/questions/72998115",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19480643/"
] | You are trying to position an element using hard coded padding values. My advice would be not to do that.
Remove the padding and change your x -> X. Then add these to your class
```
.button {height: 15px; aspect-ratio: 1/1;}
```
Whatever you set the height to the width will follow. With your border radius you can t... | There are two big issues in your code:
* First, you want your button to have the same `height` and `width`.
Either set those two properties separately or use the `aspect-ratio` property as suggested by [`@fluffybacon`](https://stackoverflow.com/a/72998212/3723993).
* Then, you are using a character that it's not a pe... |
1,685 | This question may be interpreted as "too localized", but it is not.
I'm interested in what you find to be the best sites for this type of operation, regardless of where they are located. For instance, I want to learn about how do these sites do the following:
* How do they work with geographic information?
* What sea... | 2010/07/07 | [
"https://webapps.stackexchange.com/questions/1685",
"https://webapps.stackexchange.com",
"https://webapps.stackexchange.com/users/567/"
] | The ones I've had most sucess with is:
* [Rightmove](http://www.rightmove.co.uk/) | When I was looking for my house, I found [Trulia](http://www.trulia.com/) to be very helpful in terms of the search and notification options it has.
Geographic Info: Search by city and zip code. You can also have it show everything within the visible Google Maps area. For cities and such, you can also select specific ... |
1,685 | This question may be interpreted as "too localized", but it is not.
I'm interested in what you find to be the best sites for this type of operation, regardless of where they are located. For instance, I want to learn about how do these sites do the following:
* How do they work with geographic information?
* What sea... | 2010/07/07 | [
"https://webapps.stackexchange.com/questions/1685",
"https://webapps.stackexchange.com",
"https://webapps.stackexchange.com/users/567/"
] | The ones I've had most sucess with is:
* [Rightmove](http://www.rightmove.co.uk/) | I like [Nestoria.co.uk](http://www.nestoria.co.uk) for its combination of list and map search.
Moving around the map refreshes the search listings around the centered location. |
1,685 | This question may be interpreted as "too localized", but it is not.
I'm interested in what you find to be the best sites for this type of operation, regardless of where they are located. For instance, I want to learn about how do these sites do the following:
* How do they work with geographic information?
* What sea... | 2010/07/07 | [
"https://webapps.stackexchange.com/questions/1685",
"https://webapps.stackexchange.com",
"https://webapps.stackexchange.com/users/567/"
] | The ones I've had most sucess with is:
* [Rightmove](http://www.rightmove.co.uk/) | [RateMyStudentRental.com](http://www.ratemystudentrental.com/) has housing for colleges and universities. It focuses on ratings and reviews, rather than just listing properties (and it's still pretty new), so it doesn't have a ton of housing listed yet.
You can do a personalized search here: www.ratemystudentrental.co... |
1,685 | This question may be interpreted as "too localized", but it is not.
I'm interested in what you find to be the best sites for this type of operation, regardless of where they are located. For instance, I want to learn about how do these sites do the following:
* How do they work with geographic information?
* What sea... | 2010/07/07 | [
"https://webapps.stackexchange.com/questions/1685",
"https://webapps.stackexchange.com",
"https://webapps.stackexchange.com/users/567/"
] | The ones I've had most sucess with is:
* [Rightmove](http://www.rightmove.co.uk/) | My favorite, that I just found yesterday in fact, is:
[PadMapper](http://www.padmapper.com/)
It automagically pulls in Craigslist, ForRent, Apartments.com & "Others". You can filter by price, size, bathrooms, bedrooms, whether they allow animals or not, pictures & more.
It's based on Google Maps. Very handy. :) |
1,685 | This question may be interpreted as "too localized", but it is not.
I'm interested in what you find to be the best sites for this type of operation, regardless of where they are located. For instance, I want to learn about how do these sites do the following:
* How do they work with geographic information?
* What sea... | 2010/07/07 | [
"https://webapps.stackexchange.com/questions/1685",
"https://webapps.stackexchange.com",
"https://webapps.stackexchange.com/users/567/"
] | The ones I've had most sucess with is:
* [Rightmove](http://www.rightmove.co.uk/) | Gotta go with [PadMapper.com](http://www.padmapper.com/). It aggregates lots of sources, offers lots of filters, lets you hide/favorite listings, lets you subscribe to updates to your search via email, and even has an iPhone app. And it's all map based, as the name suggests :-) |
1,685 | This question may be interpreted as "too localized", but it is not.
I'm interested in what you find to be the best sites for this type of operation, regardless of where they are located. For instance, I want to learn about how do these sites do the following:
* How do they work with geographic information?
* What sea... | 2010/07/07 | [
"https://webapps.stackexchange.com/questions/1685",
"https://webapps.stackexchange.com",
"https://webapps.stackexchange.com/users/567/"
] | The ones I've had most sucess with is:
* [Rightmove](http://www.rightmove.co.uk/) | Here in Aus I've always used the traditional [domain.com.au](http://domain.com.au) and [realestate.com.au](http://realestate.com.au). They're not super good, but they're always adding more features. They've got everything that [rchern](https://webapps.stackexchange.com/questions/1685/web-applications-to-look-for-rental... |
1,685 | This question may be interpreted as "too localized", but it is not.
I'm interested in what you find to be the best sites for this type of operation, regardless of where they are located. For instance, I want to learn about how do these sites do the following:
* How do they work with geographic information?
* What sea... | 2010/07/07 | [
"https://webapps.stackexchange.com/questions/1685",
"https://webapps.stackexchange.com",
"https://webapps.stackexchange.com/users/567/"
] | The ones I've had most sucess with is:
* [Rightmove](http://www.rightmove.co.uk/) | The best site that I have found is [Freerentalsite.com](http://www.freerentalsite.com/). As far as search you can type in anything that you want. Address, landmark, a park, school whatever and it gives you the results with a radius of that search. They call it "borderless search".
Once you have the location, you can r... |
10,051,395 | ```
public class Main {
public static void main(String[] args){
Class2 class2Object = new Class2();
//class2Object
//num1
class2Object.setNumber(class2Object.number1, 1) ;
class2Object.getNumber(class2Object.number1);
}
}
public class Class2 {
public int numb... | 2012/04/07 | [
"https://Stackoverflow.com/questions/10051395",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1050548/"
] | Your setter doesn't do anything:
```
public void setNumber(int x, int value){
x = value; // This just overwrites the value of x!
}
```
A setter should have only one parameter. You need to assign the received value to the member field:
```
// The field should be private.
private int number;
public void setNum... | Since you should assign like this:
```
private int number1;
public void setNumber(int value){
this.number1 = value;
}
``` |
10,051,395 | ```
public class Main {
public static void main(String[] args){
Class2 class2Object = new Class2();
//class2Object
//num1
class2Object.setNumber(class2Object.number1, 1) ;
class2Object.getNumber(class2Object.number1);
}
}
public class Class2 {
public int numb... | 2012/04/07 | [
"https://Stackoverflow.com/questions/10051395",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1050548/"
] | Your setter doesn't do anything:
```
public void setNumber(int x, int value){
x = value; // This just overwrites the value of x!
}
```
A setter should have only one parameter. You need to assign the received value to the member field:
```
// The field should be private.
private int number;
public void setNum... | In Java, primitive types (like int) are passed by value, not by reference.
So saying:
```
Class2 class2Object = new Class2();
class2Object.setNumber(class2Object.number1, 1) ;
```
passes `class2object.number1` by value, not by reference. So the parameter x in `setNumber` is a whole new int and is not pointing to th... |
10,051,395 | ```
public class Main {
public static void main(String[] args){
Class2 class2Object = new Class2();
//class2Object
//num1
class2Object.setNumber(class2Object.number1, 1) ;
class2Object.getNumber(class2Object.number1);
}
}
public class Class2 {
public int numb... | 2012/04/07 | [
"https://Stackoverflow.com/questions/10051395",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1050548/"
] | In Java, primitive types (like int) are passed by value, not by reference.
So saying:
```
Class2 class2Object = new Class2();
class2Object.setNumber(class2Object.number1, 1) ;
```
passes `class2object.number1` by value, not by reference. So the parameter x in `setNumber` is a whole new int and is not pointing to th... | Since you should assign like this:
```
private int number1;
public void setNumber(int value){
this.number1 = value;
}
``` |
68,656,785 | If my code is:
```
context('The Test', () => {
let testStr = 'Test A'
it(`This test is ${testStr}`, () => {
expect(testStr).to.eq('Test A')
})
testStr = 'Test B'
it(`This test is ${testStr}`, () => {
expect(testStr).to.eq('Test B')
})
testStr = 'Test C'
it(`This test is ${testStr}`, () => {
... | 2021/08/04 | [
"https://Stackoverflow.com/questions/68656785",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16595273/"
] | `it()`'s callbacks will be executed only after parent's one (`context` in your case).
You can play with it in debugger and see it live:
[](https://i.stack.imgur.com/AFUOV.gif)
So mocha will assign the final 'Test C' value and call the first `it()` cal... | I don't have enough proof but i believe that it must be because `it()` must be asynchronous like the following code
```
let a= 10;
setTimeout(function(){ console.log(a); }, 1000);
a = 11;
setTimeout(function(){ console.log(a); }, 1000);
```
by the time setTimeout are executed the value of a becomes 11.
[Found this ... |
27,420,848 | My understanding of Oblique font styling in CSS3 is that it's the same as the normal font, with an angle applied.
Italics on the other hand, is a separate set of glyphs, that while slanted also feature unique characters, like an extra curly z, or a pronounced y, whatever.
Now, I've been running font-style: oblique, a... | 2014/12/11 | [
"https://Stackoverflow.com/questions/27420848",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4345631/"
] | Oblique and Italic are two different styles. They don't look the same; the fact that they *seem* to look the same is caused by the program that displays the font (i.e. the browser); it shows the variant that is present, so if you specify `oblique`, it uses italic if oblique isn't available, and vice versa.
Now it's po... | It is my opinion...
When you pick one family font, it has many forms (normal, bold, italic, ...).
Usually, if you want to display a font cursive, you should use the italic style instead oblique style, that's because it's the default form which come from in the family font that you chose.
If you use oblique style, ... |
39,328,291 | I'm building a CMS where Administrators must be able to define an arbitrary number fields of different types (text, checkboxes, etc). Users then can fill those fields and generate posts.
How can this be done in Rails? I guess that the persistence of these "virtual" attributes will be done in a serialised attribute in ... | 2016/09/05 | [
"https://Stackoverflow.com/questions/39328291",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/182172/"
] | What you describe is called [Entity-Attribute-Value model](https://en.wikipedia.org/wiki/Entity%E2%80%93attribute%E2%80%93value_model). MattW. provided 2 possible solutions, but you can also use one of these gems that implement this data pattern instead of handling this yourself:
* [eav\_hashes](https://github.com/ios... | As soon as it's user defined, it is never a column (field), it's always a row (entity) in the database – users don't get to define your data structure.
Here are two ideas. (1) is the more idiomatic "Rails Way". (2) is somewhat less complicated, but may tie you to your specific DBMS.
(1) Using four models: `Posts` (n:... |
66,998,989 | I am working on a Rest API in TypeScript.
The part I'm working on receives as a parameter a Type object containing a body attribute as being of type "Unknown".
I have to check that the body attribute that I received in my object as a parameter is strictly compliant with my Type / Interface, here in the exemple : "acc... | 2021/04/08 | [
"https://Stackoverflow.com/questions/66998989",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15345150/"
] | You seem to want:
Your query can be radically simplified:
* The outer join is really an inner join due to the `WHERE` clause.
* The boolean conditions are much more complicated than necessary ( "(A OR B) AND A" is really just "A").
* No subquery is necessary.
* The `JOIN` conditions can be expanded.
So:
```
SELECT ... | Try something like this
```
SELECT
import_data.id,
import_data.phone,
import_data.business_name,
import_data.address,
api_request_record.lc_compliant,
api_request_record.dnc_compliant
FROM
import_data
LEFT JOIN api_request_record on api_request_record.data_record_id = import_data.id AND... |
459,801 | I'd like to ask for the community's opinion regarding the correct usage of a comma for a quoted question.
In a situation such as this, which of the two following sentences would be correct? The placement of the comma is the only difference, and I can't seem to pinpoint which one is correct.
>
> A popular answer to t... | 2018/08/12 | [
"https://english.stackexchange.com/questions/459801",
"https://english.stackexchange.com",
"https://english.stackexchange.com/users/312127/"
] | Berserk is an odd option here. **Violent** would provide better meaning. (i)Brusque implies a lack of manners. That's a very *hoity-toity* way of putting it. Pacific is just flat out wrong, it means 'peaceful'. No one stops for picnics in the park in the middle of a revolution. (ii) "more peaceful" implies a calming do... | If it helps, let's rewrite the sentence replacing some possibly difficult words with simpler ones in the context:
First, I'll give definitions of the words I'll be replacing:
>
> temperate
> adjective
>
> 2.
> a. Moderate in degree or quality; restrained.
> b. Exercising moderation and self-restraint. ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.