qid
int64 1
74.7M
| question
stringlengths 0
70k
| date
stringlengths 10
10
| metadata
list | response
stringlengths 0
115k
|
---|---|---|---|---|
533,140 |
I am concerned with a QHO that is linearly perturbed in $x$, i.e.
$$ H = \hbar \omega \left(\hat{n} + \frac{1}{2}\right) + \lambda \underbrace{\left(\hat{b}+ \hat{b}^\dagger \right)}\_{\propto \hat{x}}.$$
For $\lambda = 0$, the ground state energy is of course $E\_0 = \frac{\hbar \omega}{2}$. For non-zero $\lambda$, we can absorb the $\lambda \hat{x}$ perturbation into the $\hat{x}^2$ term of the unperturbed Hamiltonian, leading to an energy shift $\propto -\lambda^2$; see e.g. [here](https://physics.bgu.ac.il/COURSES/QuantumMechCohen/ExercisesPool/EXERCISES/ex_6120_sol_Y11.pdf) for details.
In particular, this means that the ground state energy of the perturbed system is always lower than $\frac{\hbar \omega}{2}$.
Mathematically, sure; trivial, actually. But physically, this goes against my intuition—how does shifting an axis, or putting the potential on a slope, *always* decrease the ground state energy, regardless of which way I shift it (i.e. regardless of the sign of $\lambda$)?
---
Specifically, in the context of the Holstein model or a (basic) [Franck-Condon excitation](https://en.wikipedia.org/wiki/Franck%E2%80%93Condon_principle), this implies that exciting an electron makes vibrational states accessible with a lower energy than was accessible when the electron was not excited. It seems paradoxical that the vibrational ground state energy would *always*, for any parameters, be lower in the excited-electron manifold. Are other cases (where e.g. the lowest-energy vibrational state is actually associated with the lowest-energy electronic state) described by including higher-order perturbation terms?
|
2020/02/25
|
[
"https://physics.stackexchange.com/questions/533140",
"https://physics.stackexchange.com",
"https://physics.stackexchange.com/users/84454/"
] |
I think it's worth thinking about this classically:
Physically, the perturbation is a constant force pointing in one direction or the other. This is because if $V(x) = \alpha x$, then the force is given by
$$
F\_x=-\frac{d}{dx}V(x) = -\alpha.
$$
One of the effects of a constant force on a harmonic oscillator is to *shift* the equilibrium position in the direction of the force. This is *also* the direction of *decreasing* $V(x)$, and so one consequence of this shift is that the total energy at the minimum is also decreased.
Now, this decrease in minimum energy (corresponding to the ground-state energy being smaller than $\hbar\omega/2$) is *irrelevant*, because the spacing between harmonic oscillator levels doesn't change: it's still $\hbar\omega$. Therefore, we still need to add the same amount of energy to add a vibrational excitation.
|
10,899,566 |
Have just finished a couple of tutorials regarding populating a SQLite database with data and then using this data within your app.
However none of these tutorials show how to connect to a remote server in order to obtain data.
QUESTION:
How do you get data from a remote MySQL database into your app??
What options do you have?
|
2012/06/05
|
[
"https://Stackoverflow.com/questions/10899566",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/157991/"
] |
Remote access is not a good idea, you would have to allow everyone to access it since it's an app. The best way to go about this is to build a layer between your app and database. From the app you would access a server side script which does the database work and responds to your app.
|
37,322,633 |
I sometimes facing dependency hell in Java. It is common known problem: library A depends on library C in version 2.5 and library B depends on C too, but in version 2.6. Then I have to solve question: Are two versions of C library backward compatible? Can I use libraries A, B and C in one application classpath? Or should I create "shaded bundle" of A with old version of C?
If two versions of C library are incompatible and I use it, application can be started usually. But then after some hours or days can "no such method" exception occurs! I would like to detect this problem before application start, not in runtime.
**Question is**: Exist some tool that can list all used symbols in class and all provided symbols by class? Then I can create script that detect used but missing symbols...
|
2016/05/19
|
[
"https://Stackoverflow.com/questions/37322633",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1632737/"
] |
**Try this Query:**
```
select * from catalog_product_entity
where user_id not in (12,36,43)
and entity_id = 12345;
```
|
131,562 |
Perhaps I'm missing something, but is there a way to either
(a) ensure that pandoc places pagebreaks before level 1 and level 2 headers in markdown (`#`,`##`), or
(b) hide `\newpage` from other markdown tools?
Is it possible to edit the template that pandoc uses for the conversion in order to do (a)?
Any ideas gratefully received.
:-)
|
2013/09/04
|
[
"https://tex.stackexchange.com/questions/131562",
"https://tex.stackexchange.com",
"https://tex.stackexchange.com/users/36180/"
] |
`pandoc --chapters`, or `pandoc -V documentclass=memoir` or `pandoc -V documentclass=book` will tell pandoc to treat level 1 headers as chapters rather than sections. In both the book and memoir document classes, chapters are preceded by page breaks.
I'm not sure exactly what you need to set in your header to get page breaks before sections. Have you read the documentation for the memoir class? It includes a `\setbeforesectionskip{}` command that might a place to start.
|
3,779,909 |
Given a floating point system defined as: $F = \{x = (\frac{m}{\beta^t})\beta^e = m\beta^{e-t}\}$, where $m$ is an integer $m \in [1, \beta^t]$, $e$ is an arbitrary integer, and $\beta$ is an integer $\beta \geq 2$. Find an exact formula for the smallest integer $n$ that does not belong to $F$.
In a floating point system, $t$ is often $53$, so with that in mind $x = m\*\beta^{e-53}$
I read that the solution is $\beta^t + 1$, but I'm not sure how to prove there is no combination of $m, e$ such that $m\beta^{e-53} = \beta^{53}+1$.
|
2020/08/04
|
[
"https://math.stackexchange.com/questions/3779909",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/517455/"
] |
It is obvious that all integers $\le\beta^m$ can be represented, with $e=t$. Then if $e>t$, all the numbers that you get are multiples of $\beta$.
The first non-multiple of $\beta$ above $\beta^t$ is $\beta^t+1$.
|
19,134,192 |
I have the next div:
```
<div class="div-class" style="width:158px;text-overflow:ellipsis;overflow:hidden;white-space:nowrap;" title=<%=myDesc%>
```
How can I show the tooltip only when ellipsis is active?
I find this function
```
function isEllipsisActive(e) {
return (e.offsetWidth < e.scrollWidth);
}
```
But I didn't know how to use it knowing I use jsp and struts
|
2013/10/02
|
[
"https://Stackoverflow.com/questions/19134192",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1515379/"
] |
Try something like this:
[**Working DEMO**](http://jsfiddle.net/cgzW8/173/)
[**Working DEMO - with tooltip**](http://jsfiddle.net/cgzW8/514/)
```
$(function() {
$('div').each(function(i) {
if (isEllipsisActive(this))
//Enable tooltip
else
//Disable tooltip
});
});
function isEllipsisActive(e) {
return (e.offsetWidth < e.scrollWidth);
}
```
|
27,896 |
Please help me or give me the correct terms to find it out.
What I want is:
* Play chess against an engine or repeat an existing game
* For my current move, I want an analyser to analyse my move, and a visualiation (not only text) to show me (better) alternatives.
What I tried:
* I installed SCID, with Stockfish, and loaded some PNG games or, doing: 'serious game' and play against stockfish
* I can see some analysis text running at a window. However, that is sort of exhausting.
What I want: having an arrow that shows me what to move where; after I have done my move.
Either by: analysing my move, and showing a better alternative. Or, showing me what the player (whose game I just play) was doing
My questions: how is it called, what I want? Does this exist, especially a visualization?
It is not necessary to use SCID, however, I failed to install SCID vs PC and Lukas Chess.
|
2020/01/09
|
[
"https://chess.stackexchange.com/questions/27896",
"https://chess.stackexchange.com",
"https://chess.stackexchange.com/users/21135/"
] |
I suggest that you simply use a browser, and play online at chess.com, lichess.com, or chess24.com. While chess.com and chess24.com have paid versions too, all three have the ability to create an account, and play online, including against computers.
You also have the option to use online engines to analyze your games.
|
60,952 |
Should one always write a cover letter when applying for faculty positions, even when not explicitly asked for in the job post?
If it depends on the field and/or type of university, please specify. If it matters, I'm applying to Physics departments in universities which primarily emphasize research, which already require (at least) a CV, research statement, teaching statement, and letters of recommendation.
|
2016/01/02
|
[
"https://academia.stackexchange.com/questions/60952",
"https://academia.stackexchange.com",
"https://academia.stackexchange.com/users/12915/"
] |
The cover letter is one place in your application where you can explain why you're interested in this particular position including both professional reasons ("I'd really like to work with your library's archive of original manuscripts by P.D.Q. Bach") and personal reasons ("My in-laws happen to live in your small town and my spouse would like to move back.") Showing that you know something about the location, the the institution, and the particular position can be a helpful factor if you're on the borderline for an interview.
If there's really nothing special that you want to say then a generic two sentence cover letter won't greatly hurt your chances.
|
14,754,402 |
I'm new to jython and failing utterly at importing a java class within a jar.
What I am trying to do is write a wrapper shell script which calls a jython script. I can not allowed to edit the jython at all, so adding jars to sys.path within that jython script is not possible.
Error
y", line 17, in
from com.polarland.testModule.cache import CacheInterface
ImportError: No module named polarland
I've added the jar which contains the above package with name of TestModule.jar to PATH, ClASSPATH and JYTHONPATH with no avail. I'm worried this is due to the name of the jar but am not sure.
Any advice would be greatly appreciated!!
|
2013/02/07
|
[
"https://Stackoverflow.com/questions/14754402",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2051190/"
] |
In your shell script use:
```
export CLASSPATH=TestModule.jar:$CLASSPATH
jython ...
```
In my case setting `CLASSPATH` is enough. Remember to use full path name and remember to use good .jar name (`testmodule.jar` and `TestModul.jar` are different). Maybe you use wrong file rights. Try `file` command to check if you can read that file. Example for one of jars I use:
```
mn$ file junit-4.1.jar
junit-4.1.jar: Zip archive data, at least v2.0 to extract
```
|
2,008,970 |
I have a problem I am trying to resolve. We have a SQL Server 2005 running a commercial ERP system. The implication for this is that we cannot change the database structure and all of the character fields are CHAR or VARCHAR rather than Unicode types (NCHAR, NVARCHAR).
We also have multiple instances of the ERP software, based on country. Each country has it's own database on the same database server, which results in variations in the table names based on the instance of the ERP software that is running. For example, the US customer table is called US\_CUSTOMER and the UK one is GB\_CUSTOMER. We have created a separate database that essentially mirrors the ERP system tables with synonyms, and then views that handle all of our SQL transactions against these synonyms. This was done to use LINQ TO SQL. Thanks for reading this far :)
The issue we have is we are now implementing Simplified Chinese for the application. In the customer ERP system, they set the code page for the ERP system so that when the ERP system writes to the base tables, the data is written as multi-byte. My question is how can I get this multi-byte information translated back to Simplified chinese? I would like to be able to do this at the database level, since I have both a web application and SSRS reports that need to take advantage of it.
Any ideas or directions? I don't think I can change the codepage, since multiple countries are using the same database server (though different databases).
Thanks ahead of time
|
2010/01/05
|
[
"https://Stackoverflow.com/questions/2008970",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39797/"
] |
Are we saying that 2 varchar characters are being using to store 1 unicode character?
If so, try CAST to binary to nvarchar etc (or something similar)
Otherwise, look at COLLATE clauses to coerce data?
Edit:
A CLR function might be your only bet to use Remus' suggestion of MultiByteToWideChar
|
51,379,974 |
I'm trying to create a folder, handling the different errors (`FileExistsError` if the folder already exists and `OSError` if the folder's name contains illegal characters), but Python seems to always choose the first except block when catching an error no matter which one it is and the order they are.
Is there anything I didn't understand?
```
import os
from pathlib import Path
def generateSetup(name) :
dir_path = os.path.dirname(os.path.realpath(__file__))
if not Path(dir_path + '/setups').exists() : os.mkdir(dir_path + '/setups')
try : os.mkdir(dir_path + '/setups/' + name)
except FileExistsError : print('The file already exists')
except OSError : print('The name contains illegal characters')
stp_name = input('Enter your setup\'s name :')
generateSetup(stp_name)
```
|
2018/07/17
|
[
"https://Stackoverflow.com/questions/51379974",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8836622/"
] |
There is nothing wrong with your code. It works properly as intended, catches `FileExistsError` if the directory already exists or `OSError` if the directory name contains invalid symbols. So I assume the problem is in the way you are testing the code
```
>>> dloc='tmp/\/b'
>>> try:
... os.mkdir(dloc)
... except FileExistsError:
... print('The file already exists')
... except OSError:
... print('The name contains illegal characters')
...
The name contains illegal characters
```
|
52,448,702 |
I have Spring Boot OAuth2 server working, but now we need to distinguish between different clients from different departments and provide different functionality depending on the department. I figure I can separate it by the client id. This guide shows how to set up the OAuth2 server with a single client id, but how do I set it up with multiple client ids?
<https://spring.io/guides/tutorials/spring-boot-oauth2/#_social_login_authserver>
And then, when an API request is made, how do I find out which client id it is?
|
2018/09/21
|
[
"https://Stackoverflow.com/questions/52448702",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/148844/"
] |
You can create multiple entries in table **oauth\_client\_details** with different combination of client\_id and client\_secret. The client\_secret obviously will be encrypted.
Now to generate the refresh and access token, hit the url
`/oauth/token` with `Authorization : Basic base64-encoded`,
Where base64-encoded will be Base64 encryption of `client_id:client_secret`.
Remember, client\_secret here should be original plain password (without encryption).
The same thing can be achieved using Spring xml configuration (in older way) as
```
<oauth:client client-id="mobile_ios"
authorized-grant-types="password,refresh_token,implicit" secret="ios_s3cret"
authorities="ROLE_CLIENT"
refresh-token-validity="7776000"
access-token-validity="300" />
<oauth:client client-id="mobile_android"
authorized-grant-types="password,refresh_token,implicit" secret="android_s3cret"
authorities="ROLE_CLIENT"
refresh-token-validity="7776000"
access-token-validity="300" />
<oauth:client client-id="web_app"
authorized-grant-types="password,refresh_token,implicit" secret="web_s3cret"
authorities="ROLE_CLIENT"
refresh-token-validity="7776000"
access-token-validity="30000" />
</oauth:client-details-service>
```
|
5,866,771 |
i have a large horizontal scrollview with different views on it.
The scrolling works fine, but now i added buttons to go the previous of next page.
I assumed that this code would do the trick because i already used it a few times:
```
-(void)goBack{
CGPoint offset = [self.scrollview contentOffset];
NSLog(@"Offset : %@", NSStringFromCGPoint(offset));
[self.scrollview setContentOffset:huidigeOffset];
CGPoint offset2 = [self.scrollview contentOffset];
NSLog(@"Offset2 : %@", NSStringFromCGPoint(offset2));}
```
However this does not work, for the first en last NSLog i get this result:
```
2011-05-03 09:41:42.066 Elektrozine_V6[1668:207] Offset : {0, 0}
2011-05-03 09:41:42.066 Elektrozine_V6[1668:207] Offset2 : {0, 0}
```
In the viewDidLoad the offset is set to:
```
2011-05-03 09:41:38.497 Elektrozine_V6[1668:207] Offset : {600, 0}
```
This part is correct , i actually set it for this amount with this:
```
[scrollview setContentSize:CGSizeMake(2141, 0)];
scrollview.contentOffset = CGPointMake((int)600, 0);
huidigeOffset = [self.scrollview contentOffset];
```
Does anyone have a clue why it won't work in the method i have made?
I searched a lot of sites but nobody has a real answer to it
Kind regards !
Snowy
|
2011/05/03
|
[
"https://Stackoverflow.com/questions/5866771",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/729358/"
] |
The flexibility of sudo is widely under-estimated. This leads to very poor practices (like the `sudo su -` canon-ball surgery method).
**A much better method is to specificly allow the commands you intend to allow *without use of a password***:
```
phill = NOPASSWD: /bin/ls, /usr/bin/lprm
```
---
You can optionally do this for specific users from specific hosts running as specific admin users. You can even prevent users from passing shell escapes as parameters. You can make sudo prevent the launched program to execute further applications dynamically etc. etc. You will want to [read the man-page for sudoers (and be sure to read the procedures for editing this special file!)](https://help.ubuntu.com/community/Sudoers).
Here is a small taste of things, ([from here](http://www.go2linux.org/sudoers-how-to)):
```
User_Alias OPERATORS = joe, mike, jude
Runas_Alias OP = root, operator
Host_Alias OFNET = 10.1.2.0/255.255.255.0
Cmnd_Alias PRINTING = /usr/sbin/lpc, /usr/bin/lprm
OPERATORS ALL=ALL
#The users in the OPERATORS group can run any command from any terminal.
linus ALL=(OP) ALL
# The user linus can run any command from any terminal as any user in the OP group (root or operator).
user2 OFNET=(ALL) ALL
# user user2 may run any command from any machine in the OFNET network, as any user.
user3 ALL= PRINTING
# user user3 may run lpc and lprm from any machine.
go2linux ALL=(ALL) ALL
# user go2linux may run any command from any machine acting as any user. (like Ubuntu)
If you want not to be asked for a password use this form
go2linux ALL=(ALL) ALL NO PASSWD: ALL
```
|
3,322,102 |
I am taking a first course in functional analysis but I am unable to understand the difference between $\|x-y\|$ and $|x-y|$ ?
I have doubt that if $|x-y|$ is defined as the distance between x and y ,then why to we define $\|x-y\|$ and what do we literally mean by that?
I too have the same problem with $\|x\|$ and $|x|$?
|
2019/08/13
|
[
"https://math.stackexchange.com/questions/3322102",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/489735/"
] |
In this case, the notation $f^{-1}(7)$ *does not* mean the **number** obtained by applying the inverse of $f$ to 7; what it actually refers to is the **set**
$$f^{-1}(7) = \{x \in {\Bbb R}: f(x) = 7\}$$ (which would be, as suggested, better denoted by $f^{-1}(\{7\})$).
If $f$ is 1-1, then in particular there is one and only one element in $f^{-1}(\{7\})$, which is then given - perhaps a little confusingly - the name $f^{-1}(7)$.
|
45,741,236 |
Is there any authentication method (user and password) and UI for it avalible for Netflix's server registry library Eureka? I'm looking for something like Spring Boot Admin's login page.
|
2017/08/17
|
[
"https://Stackoverflow.com/questions/45741236",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3612430/"
] |
There is ui page which you can see just enter your **host:port** in browser. But it just shows info about registered clients, nothing you can do more. And for authentication you can use basic spring security. If you enable basic security with a user name and password, that ui asks you for it when you try to get to page. Additionally you should supply those username and password for registering clients too.
|
20,292,014 |
When I have a string, I can use the `Substring()` or `Split()` functions and store the result into a `string` or `string[]` respectively.
I want to treat below **string array** same way as with **string**.
+-----------------------------------------------+
| $ | $ | Name | $ | $ |NIC| $ | $ |Gender |
+-----------------------------------------------+
How it is possible?
|
2013/11/29
|
[
"https://Stackoverflow.com/questions/20292014",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3001536/"
] |
Here's an example of getting what's between NIC & Gender:
```
var betweenNicAndGender = stringArray.SkipWhile(s => !s.Equals("NIC"))
.Skip(1) // skip NIC
.TakeWhile(s => !s.Equal("Gender"));
```
|
121,248 |
We have the following SVN structure.
* Projects: Our work
* Clients: Projects for clients, needs to be different
* Shared: Shared libraries we created
* Docs: Documents explaining how software development flows within the company (has nothing to do with my question anyway)
Where should we put the external libraries? Let's say from opensource projects etc.

|
2011/11/23
|
[
"https://softwareengineering.stackexchange.com/questions/121248",
"https://softwareengineering.stackexchange.com",
"https://softwareengineering.stackexchange.com/users/35446/"
] |
Some people use [Maven](http://en.wikipedia.org/wiki/Apache_Maven) or similar solutions that automatically *download* libraries from various repositories as needed. It may be convenient, but then you're dependent on repositories maintained by some 3rd party. Getting some less popular libraries updated may be sluggish, and of course, most commercial libraries aren't available in public repositories.
We've simply put 3rd party libraries in our own repository under `/lib/libraryname/tags/1.2.3/` and, using `svn:externals`, get those libraries to where they are needed. It may be a bit clumsy, some manual work is required to update the libraries, but at least your software is totally under your own control.
In technical sense, shared libraries are shared libraries regardless of who created them (you or someone else), so in your structure I would put them in `/company/shared/3rdparty/etc.`
|
33,434,107 |
I am looking for a way to *skip tests* from one of the projects in a *multi-build project*. I don't want to use **gradle build -x** test because then it will skip test for all sub - projects.
Root
* Sub P1
+ build.gradle
* Sub P2
+ build.gradle
* Sub P3
+ build.gradle
* build.gradle
* settings.gradle
I want to skip tests only for "Sub P3"
Can i configure my project(Sub P3) build file to skip tests?
|
2015/10/30
|
[
"https://Stackoverflow.com/questions/33434107",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4923185/"
] |
Due to [official user guide](https://docs.gradle.org/current/userguide/more_about_tasks.html#N10E33), there are 3 ways to skip some task in gradle.
The first 2, are: using predicate and exception throwing. Predicates are resolved during the configuration phase and may not pass to your requirements. `StopExecutionExeption`throwing could be added to the `doFirst` of every test and be throwed according to some condition. Bit that seems to be not very clear, because you have to modify both root script to set the condition and subroject sripts test tasks.
And the 3rd one is - disabling the tasks. Every task, has a `enabled` property (default is true), which is preventing task execution, if it was set to false. Only thing you have to do is to set this property for test task in your subproject. This can be done in sub projects buil script root, as:
```
test.enabled = false
```
This will work, if you didn't specify custom test tasks, if you did, you can disable all test by task type, as:
```
project(':subProject').tasks.withType(Test){
enabled = false
}
```
Previews 2 configurations must be included to the build script of the subproject, but since you have a root project, you can configure subprojecst from it's build script, via `project()` providing subproject's name:
```
project(':subProject').tasks.withType(Test){
enabled = false
}
```
|
18,847,231 |
I have a `<dl>` and `<dd>` that I am trying to convert into a table cells but I am not able to get the widths to display corectly.
The outer `<dl>` is 100% and the `<dt>`'s are 20% and 80%. Why dont the `<dt>` together per row display at a 100% of the width of the outer `<dl>`
All I should see is red and blue and no yellow
Here is my fiddle - thanks for the help
<http://jsfiddle.net/35Gmm/2/>
|
2013/09/17
|
[
"https://Stackoverflow.com/questions/18847231",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1477816/"
] |
You need to switch the display to `table` on the definition list
```
dl{
display:table;
}
```
and probably want to convert one `dd` into an `dt`
```
<dl>
<dt>hot drink</dt>
<dd>cold drink</dd>
</dl>
dl > dt {
background:red;
width: 20%;
}
dl > dd {
background:blue;
width: 80%;
}
```
[working example](http://jsfiddle.net/35Gmm/30/)
But why would you want to use a definition list (a list of terms (`dt`), which you are then offering an explanation for (`dd`) ), if your data is semantically not appropriate for it? (Or was the fiddle just some random sample data?)
|
69,988,345 |
![image showing an input element with the text "[email protected]", and an "x" in a circle on the right](https://i.stack.imgur.com/Jiiig.png)
The application has a custom email input field, how can I check that it displays the drawable icons in android test (espresso)
xml:
```
<com.my.mobile.kit.input.InputGeneral
android:id="@+id/login_email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="10dp"
app:kitEndIconDrawable="@drawable/kit_ic_cleanitem_24"
app:kitEndIconMode="clear_text"
app:kitEndIconTint="@color/baseDeepGreyOne"
app:kitLabelText="@string/m_auth_login_email_hint"
app:kitLabelVisibilityMode="manual"
app:kitPlaceholderText="@string/m_auth_login_email_hint"
app:layout_constraintTop_toTopOf="parent" />
```
|
2021/11/16
|
[
"https://Stackoverflow.com/questions/69988345",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16537888/"
] |
Well, you don't need to use a `for` loop here.
You could instead utilize the `addAll` method to achieve what you want:
```java
void addCoordinatesToBack(List<Coordinate> coordinateList) {
coordinates.addAll(coordinateList);
}
void addCoordinatesToFront(List<Coordinate> coordinateList) {
coordinates.addAll(0, coordinateList);
}
```
`addAll` has two forms:
* `addAll(Collection c)` adds all elements of the specified `Collection` at the end of the list;
* `addAll(int position, Collection c)` adds all elements of the specified `Collection` at the given position. Use position `0` to add them at the beginning of the list.
Also note that I have used `List` instead of `ArrayList` with your parameters, as this makes it more flexible.
---
Note that this is not quite the same as *reversing* lists.
|
363,142 |
I write C programs in Vim; the font size in it is very small.
Is there any option to increase the font size in Vim?
|
2013/10/21
|
[
"https://askubuntu.com/questions/363142",
"https://askubuntu.com",
"https://askubuntu.com/users/205685/"
] |
This may not be an ideal solution but it works for me.
Just zoom in on your terminal with `Ctrl`+`Shift`+`+`.
Zoom out with `Ctrl`+`-`
|
63,291,425 |
The [Firebase Rules docs](https://firebase.google.com/docs/firestore/security/rules-conditions) suggest building conditions comparing the authenticated user's token (i.e., `request.auth`) with the target Firestore document(s). Something like:
```
match /posts/{postId} {
allow read, write: if (request.auth.uid != null) &&
(resource.data.tenantId == request.auth.token.tenantId);
}
```
However, `tenantId` doesn't appear to be available in [Firebase Rules](https://firebase.google.com/docs/reference/rules/rules.firestore.Request#auth) like other related auth fields (e.g., `uid`, `email`, `email_verified`, etc.).
One option appears to be to add `tenantId` separately as a [custom claim](https://firebase.google.com/docs/auth/admin/custom-claims) using the `firebase-admin` SDK. But that would create duplicate info on the user object:
```
{
uid: 'nzjNp3QIfSR6uWy',
emailVerified: true,
displayName: 'pickleR'
...
tenantId: 'wubalubadubdub',
customClaims: { tenantId: 'wubalubadubdub' },
}
```
An [alternative option](https://groups.google.com/forum/#!topic/firebase-talk/z_j9Z2HNjb4) appears to be to create a `tenants` collection in Firestore. However, that approach seems to introduce needless complexity and inflate the # of required Firestore queries.
**Are there alternatives for accessing the `tenantId` in Firestore Rules and/or alternative best practices for using Firestore with multi-tenancy?**
|
2020/08/06
|
[
"https://Stackoverflow.com/questions/63291425",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13995622/"
] |
The two options you describe are the idiomatic ones:
1. Pass the information into the rules as part of the ID token as a custom claim.
2. Look up the information in the database from the rules by the `request.auth.uid`.
Neither of these is always better than the other: custom claims are more convenient and readable, while using the database is usually faster. It's common to use the database lookup for more volatile information, and claims for information that is "once".
Since this is for a tenant ID, which is unlikely to change quickly, I'd probably go for a custom claim.
|
3,757 |
I have a 2006 Mercedes E-350 with an automatic rear sunshade; until a week ago the sunshade worked fine, but now it's stuck up and I can't get it to come down by any means.
The button to move the shade doesn't respond; I can hear a click in the back of the car but that's it; none of the other mechanical noises it makes when it comes down proper. I can't physically push it back down, even after loosening the arms a bit (I got it about 20% down before it stopped moving). Even after loosening the arm's position the button doesn't work, though on occasion I've heard *slightly* more mechanical noises after pressing the button.
I've tried several tricks Mercedes forums recommend; I had someone push down on the shade while I press the button; no luck, it doesn't move. I heard the problem might be caused by a blown fuse, but I don't know which fuse it would be or how to get to the front fuse-box, actually; I can't seem to access the driver's side primary one if it's in there. I can see the rear fuse box but can't seem to open it.
At this point I don't really care if the sun shade comes back up but I want it down; I'm content to not use it again if it's not going to work. At the same time I'd rather not *break* it, at least not more than it already is, because the mechanism allegedly costs something around $1500.
|
2012/06/12
|
[
"https://mechanics.stackexchange.com/questions/3757",
"https://mechanics.stackexchange.com",
"https://mechanics.stackexchange.com/users/1817/"
] |
Took her in to s Mercedes licensed mechanic, they took apart the assembly. Turns out the Up motor worked fine, but the Down motor was burt out.
It's *possible* a similar situation could be caused by something as simple as a blown fuse or a misalignment of the "scissor" bars that raise/lower the shade, but that wasn't the case here.
Since it was the dead motor and not something simple they'd have had to replace *the entire assembly* which costs $1700. They're expensive because no one bothers to replace them, most places won't have them in stock. Instead they (carefully) shoved the shade back into it's housing and took out the fuse so it couldn't be accidentally put up again. If this happens to you make sure you take the fuse for the sunshade out!
|
9,938,179 |
I have a problem with ASP.NET and japanese.
My ASP.Net Web, SQLserver DB is encoded as JAPAN SHIFT\_JIS,
but in japanese has about 45 special characters,
[enter link description here](http://www.tkmj.net/kanji-4.htm)
they are not the SHIFT-JIS,
```
* When inserted to DB "邰" is changed to "&#37040;"
```
* In my C# code:
```
string strHtmlDecode = Server.HtmlDecode("&#37040;");
this.txtName.Text = strHtmlDecode;
```
In the server side <.cs code file> when debuging return true character
```
"邰"
```
But the respond to client (HTML page) is not true. Because of page's encoding is shift-jis
=> solution for solve this problem?
=> Or how can I encode only "txtName" TextBox as utf-8 in a Shift-jis page?
|
2012/03/30
|
[
"https://Stackoverflow.com/questions/9938179",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1299527/"
] |
The jar and context factory mentioned would tend to indicate that the WMQ client was borrowed from a WebSphere Application Server install rather than using the stand-alone WMQ client installer. If that is the case you can likely fix this quite easily by installing the stand-alone client. You can obtain this free (with registration) as a SupportPac. These are by version so you have your choice of:
* V7.1 client is [SupportPacMQC71](http://ibm.co/SupptPacMQC71) (Preferred)
* V7.0 client is [SupportPacMQC7](http://ibm.co/SupptPacMQC7)
* V6.0 client is [SupportPacMQC6](http://ibm.co/SupptPacMQC6) (Out of support as of September 2012)
Note that installing the client from the IBM-supplied installer provides a number of additional features such as diagnostics for tracing, version display, initial verification test code, sample source code, etc. This is the method of install that IBM will support so even though you can get it to work by copying the jars from the WMQ server install, using IBM's media is recommended.
Note also that the packaging of the Java and JMS classes has changed between versions. It is important to know which version that you are using and refer to the corresponding docs for `CLASSPATH` and other config options. The v7.1 implementation has many functional improvements and is the only version that will take advantage of the features on a v7.1 QMgr. However it will connect to *any* version QMgr so if this is new development, try to use the v7.1 client now so that you don't end up needing to upgrade down the road.
The Infocenter links for each version of the client are:
* V7.1 Infocenter [Environment Varariables for JMS](http://publib.boulder.ibm.com/infocenter/wmqv7/v7r1/topic/com.ibm.mq.doc/jm10330_.htm) & [Installing classes for JMS](http://publib.boulder.ibm.com/infocenter/wmqv7/v7r1/topic/com.ibm.mq.doc/jm10300_.htm)
* V7.0 Infocenter [Clients](http://publib.boulder.ibm.com/infocenter/wmqv7/v7r0/topic/com.ibm.mq.csqzaf.doc/cs10120_.htm) and [Using Java](http://publib.boulder.ibm.com/infocenter/wmqv7/v7r0/topic/com.ibm.mq.csqzaw.doc/uj10120_.htm) manuals
* V7.0 Infocenter [Clients](http://publib.boulder.ibm.com/infocenter/wmqv6/v6r0/topic/com.ibm.mq.csqzaf.doc/cs10120_.htm) and [Using Java](http://publib.boulder.ibm.com/infocenter/wmqv6/v6r0/topic/com.ibm.mq.csqzaw.doc/uj10120_.htm) manuals
One of the utilities supplied with the IBM installer is the `setmqjmsenv` script (and `setmqjmsenv64` when installing the 64-bit client) in the `java/bin` directory. You can look here to determine the `CLASSPATH` and other environment variables needed for your version of WMQ Client Classes for Java.
|
51,746 |
I'm looking on eBay for replacement parts for my E90 320i 2006, but I can't find anything for it. In the results I always find replacement parts for the 325i, 328i, etc., but not for my 320i 2006. I would like to know if someone could guide me and tell me which other model I can buy parts for my vehicle.
Thanks
|
2018/02/13
|
[
"https://mechanics.stackexchange.com/questions/51746",
"https://mechanics.stackexchange.com",
"https://mechanics.stackexchange.com/users/35541/"
] |
Airbags protect the moving occupant against the sudden deceleration of the vehicle. Trucks usually hit objects that are lighter in mass. The truck's energy is transfered to the other vehicle, so the truck decelerates slowly.
Even if the truck hits a wall, the large mass and crumple zone means slower deceleration. The occupant can be protected by only lap/shoulder belts.
|
47,939,358 |
I am implementing azure for my web application and trying to get access token by following there openId connect tutorial
<https://learn.microsoft.com/en-us/azure/active-directory/develop/active-directory-protocols-oauth-code>
And when i am requesting to get the access token, i am always getting bad request 400
Request to get access token :
>
> POST /{tenant}/oauth2/token HTTP/1.1
>
>
> Host: <https://login.microsoftonline.com>
>
>
> Content-Type: application/x-www-form-urlencoded
>
>
> grant\_type=authorization\_code
>
>
> &client\_id=2d4d11a2-f814-46a7-890a-274a72a7309e
>
>
> &code=AwABAAAAvPM1KaPl.......
>
>
> &redirect\_uri=https%3A%2F%2Flocalhost%2Fmyapp%2F
>
>
> &resource=https%3A%2F%2Fservice.contoso.com%2F
>
>
> &client\_secret=p@ssw0rd
>
>
>
here is my code :
```
public static String post( String endpoint,
Map<String, String> params) {//YD
StringBuffer paramString = new StringBuffer("");
//if(!Utilities.checkInternetConnection(context)){
// return XMLHandler.getXMLForErrorCode(context, JSONHandler.ERROR_CODE_INTERNET_CONNECTION);
//}
Iterator<Entry<String, String>> iterator = params.entrySet().iterator();
StringBuffer tempBuffer = new StringBuffer("");
String paramval;
while (iterator.hasNext()) {
Entry<String, String> param = iterator.next();
if (param != null) {
if (paramString.length() > 0) {
paramString.append("&");
}
System.out.println( "post key : " + param.getKey());
String value;
try {
paramval = param.getValue();
if(paramval!=null)
value = URLEncoder.encode(paramval, "UTF-8");
else
value = "";
} catch (UnsupportedEncodingException e) {
value = "";
e.printStackTrace();
}
paramString.append(param.getKey()).append("=")
.append(value);
}
}
try {
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost(endpoint);
String data = "";
try {
// Add your data
// httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs))
//httppost.addHeader("Host", host);
httppost.addHeader("Content-Type",
"application/x-www-form-urlencoded");
if (!paramString.equals("")) {
if (tempBuffer.length() > 0) {
data = data + tempBuffer.toString();
}
data = data + paramString.toString();
if (data.endsWith("&")) {
data = data.substring(0, data.length() - 1);
}
httppost.setEntity(new ByteArrayEntity(data.getBytes()));
}
System.out.println( "post Stringbuffer : " + data);
// Execute HTTP Post Request
HttpResponse response = httpclient.execute(httppost);
int statuscode = response.getStatusLine().getStatusCode();
System.out.println("Response code : " + statuscode);
if (statuscode != 200) {
return null;
}
HttpEntity entity = response.getEntity();
InputStream in = null;
if (entity != null) {
in = entity.getContent();
}
if (in != null) {
StringBuilder builder = new StringBuilder();
String line;
try {
BufferedReader reader = new BufferedReader(
new InputStreamReader(in, "UTF-8"));
while ((line = reader.readLine()) != null) {
builder.append(line);
}
} finally {
in.close();
}
String response2 = builder.toString();
System.out.println("response :" + response2);
retrycount = 0;
return response2;
}
}
catch(UnknownHostException e){
e.printStackTrace();
return null;
}
catch (EOFException eof) {
if (retrycount < max_retry) {
eof.printStackTrace();
post( endpoint, params);
retrycount = 1;
}
} catch (Throwable th) {
throw new IOException("Error in posting :" + th.getMessage());
}
retrycount = 0;
return null;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
```
Please help me with this
Thanks in Advance
|
2017/12/22
|
[
"https://Stackoverflow.com/questions/47939358",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2357864/"
] |
You're getting *is not a function* Error since `tn` is just a string (selector) you can't call `removeClass()` method on it, you should wrap it by `$()` to be a jQuery object, Should be :
```
$(tn).addClass(tns);
//And
$(tn).removeClass(tns);
```
|
13,684,927 |
I want to show `MyProperty1` or `MyProperty2` based on **MyPropertySelected**. How to use a conditional statement `if` or `else` based on **MyPropertySelected**? Thanks.
```
// [Browsable(true)
// ????? conditional statement IF ELSE in here..
// IF (MyPropertySelected) MyProperty1 will be show ELSE MyProperty2 will be show.
public bool MyPropertySelected { get; set; }
// [Browsable(true) or [Browsable(false) depending on MyPropertySelected condition.
public int MyProperty1 { get; set; }
// [Browsable(true) or [Browsable(false) depending on MyPropertySelected condition.
public int MyProperty2 { get; set; }
```
|
2012/12/03
|
[
"https://Stackoverflow.com/questions/13684927",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1815264/"
] |
You're confusing apples with oranges.
*Attributes* are metadata and a property value acquires *its value* on run-time.
In other words: *attribute* is something that you'll access using **[reflection](http://msdn.microsoft.com/en-us/library/f7ykdhsy%28v=vs.110%29.aspx)** and those aren't tied to a particular object but to the type of the object (i.e. *the class*).
Another issue is that you want to add an attribute to a property based on a condition that can't work in compile-time.
Your `MyPropertySelected` won't get any value until its enclosing class gets instantiated *- that's creating an object, for example: `MyClass a = new MyClass()`-*, **meaning that adding or not adding the attribute would never be a compile-time choice**.
I want to be clear: **you can't do what you want purely using attributes!**
*You can't conditionally apply attributes based on run-time values*.
Finally, I suspect you want to make something `Browsable` based on a condition, like your own question says. You can't do that.
Ok ok, but what...?
-------------------
You can workaround your situation with a different software design.
### 1)
First, create an interface that will have any of the properties that would be browsable or not. But don't apply the attribute `[Browsable(bool)]` to the interface properties.
### 2)
Create two classes that implements the previously created interface.
In the first class, implement the interface properties and put a `[Browsable(true)]` attribute on them. In the second class, do the same, but this time put a `[Browsable(false)]` on them.
### 3)
Some code that creates the instance of the object will be the one that will also decide *which one will be instantiated*.
That is, externalizing `MyPropertySelected` outside of both classes and performing the whole condition switch in the caller.
```
public interface IBrowsableProperties
{
int Property1 { get;set; }
int Property2 { get;set; }
}
public class A : IBrowsableProperties
{
[Browsable(true)]
public int Property1 { get;set; }
[Browsable(true)]
public int Property1 { get;set; }
}
public class B : IBrowsableProperties
{
[Browsable(false)]
public int Property1 { get;set; }
[Browsable(false)]
public int Property1 { get;set; }
}
// Somewhere in some method...
bool propertySelected = true;
IBrowsableProperties instance = null;
if(propertySelected)
{
instance = new A();
}
else
{
instance = new B();
}
// ... do stuff with your instance of IBrowsableProperties!
```
UPDATE
======
*I've reviewed some of your question's comments and I've found you're working with `PropertyGrid` control.*
*Anyway, you can apply the concept in your case. `PropertyGrid` can be inherited. You can create both `PropertyGrid1` and `PropertyGrid2` derived classes that both implement the proposed interface!*
|
49,928,894 |
I wrote a short azure function to simply take data in from CosmosDB change feed Trigger.
However, looks like it returns some form of encoded data.
For example
```
{
"_id" : ObjectId("5ad8db107dfa95101430ab94"),
"id" : "task123",
"type" : "genera123l",
"information" : "some task"
}
```
If above document is created in my cosmos db,
```
public static void Run(IReadOnlyList<Document> documents, TraceWriter log)
{
if (documents != null && documents.Count > 0)
{
log.Info("Documents modified " + documents.Count);
log.Info("First document Id " + documents[0].Id);
}
}
```
above code will print
```
2018-04-19T19:28:23.899 [Info] Documents modified 1
2018-04-19T19:28:23.899 [Info] First document Id NWFkOGRiMTA3ZGZhOTUxMDE0MzBhYjk0
```
instead of
```
2018-04-19T19:28:23.899 [Info] Documents modified 1
2018-04-19T19:28:23.899 [Info] First document Id task123
```
which is the expected output.
Is there some sort of configuration that I'm missing here?
Looks like none of the documentations for CosmosDB or Azure Function App
addresses this issuse :(
Thanks
|
2018/04/19
|
[
"https://Stackoverflow.com/questions/49928894",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2662520/"
] |
I assume that you use the **Azure CosmosDB MongoDb** API for input bindings.
Please hava a try to use the **Azure CosmosDB SQL API**. Detail steps you could refer to this [guide](https://github.com/MicrosoftDocs/azure-docs/blob/master/articles/azure-functions/functions-create-cosmos-db-triggered-function.md#create-a-function-triggered-by-azure-cosmos-db). Then you could get the expected answer. For more information, please refer to this [link](https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-cosmosdb#input).
>
> **Don't** use Azure Cosmos DB input or output bindings if you're using **MongoDB API** on a Cosmos DB account. **Data corruption is possible.**
>
>
>
[](https://i.stack.imgur.com/68s8s.png)
|
4,456,292 |
I have to solve this non-linear DE
$y' -e^y -x^2 = 0 , y(0)=c$
using powerseries.
$y(x) = \sum\_{n=0}^\infty a\_{n}x^n $
$y'(x) = \sum\_{n=1}^\infty na\_{n}x^{n-1} $
so we get
$\sum\_{n=1}^\infty na\_{n}x^{n-1} -e^{\sum\_{n=0}^\infty a\_{n}x^n} -x^2 = 0 $
changing the sum indexes
$\sum\_{n=0}^\infty (n+1)a\_{n+1}x^{n} -e^{\sum\_{n=0}^\infty a\_{n}x^n} -x^2 = 0 $
I want to find the recurrence relation of the coefficients.
But i cannot merge/group them into the same sum, meaning, the sum of $y'(x) = \sum\_{n=1}^\infty na\_{n}x^{n-1} $ and the sum of $y(x) = \sum\_{n=0}^\infty a\_{n}x^n $ cause it is power of $e$ in order to get the equality of them with $0$.
|
2022/05/22
|
[
"https://math.stackexchange.com/questions/4456292",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/921823/"
] |
We first prove the following lemma.
**Lemma.** Let $\lambda>0$. Then
$$\sup\_{x>0}\left(\frac1{\sqrt{1+x}}+\frac1{\sqrt{1+\frac{\lambda}x}}\right)=\begin{cases}\frac2{\sqrt{1+\sqrt\lambda}}&\text{if }\lambda<4\\\sqrt{\frac{\lambda}{\lambda-1}}&\text{if }\lambda\geq 4.\end{cases}$$
*Proof.* Fixing $\lambda$ constant, let the left side be $f(x)$. The function $f$ is clearly continuous and infinitely differentiable, and so its global extrema are reached when $x\to 0$, $x\to\infty$, or when $f''(x)=0$. It is not hard to compute that
$$f''(x)=0\Longleftrightarrow \lambda^2(1+x)^3=x(\lambda+x)^3;$$
the polynomial on the right factors as $(x^2-\lambda)(x^2-(\lambda^2-3\lambda)x+\lambda)$. So, the extrema are when $x=\sqrt{\lambda}$, or when $x$ and $\lambda/x$ satisfy $x+\frac\lambda x=\lambda^2-3\lambda$. For $\lambda<4$, $x+\frac\lambda x$ is always larger than $\lambda^2-3\lambda$, so the only $x$ with $f''(x)=0$ is $x=\sqrt\lambda$, giving the desired bound. For $\lambda\geq 4$, such a real $x>0$ does exist, and satisfies, letting $y=\lambda/x$ so that $x+y=\lambda^2-3\lambda$,
\begin{align\*}
\left(\frac1{\sqrt{1+x}}\right)\left(\frac1{\sqrt{1+y}}\right)&=\frac{1}{\sqrt{1+(\lambda^2-3\lambda)+\lambda}}=\frac1{\lambda-1}\\
\left(\frac1{\sqrt{1+x}}\right)^2+\left(\frac1{\sqrt{1+y}}\right)^2&=\frac{2+x+y}{(1+x)(1+y)}=\frac{\lambda-2}{\lambda-1},
\end{align\*}
so
$$\frac1{\sqrt{1+x}}+\frac1{\sqrt{1+y}}=\sqrt{\frac{\lambda-2}{\lambda-1}+\frac2{\lambda-1}}=\frac{\lambda}{\lambda-1}.$$
For $\lambda\geq 4$, this is always at least the value $\frac2{\sqrt{1+\sqrt\lambda}}$ achieved at $x=\sqrt\lambda$, and so is the maximum of $f$. $\square$
---
Now, under the substitution $w=\frac{b^2}{a^2}$, $x=\frac{c^2}{b^2}$, $y=\frac{d^2}{c^2}$, $z=\frac{a^2}{d^2}$, the problem becomes to show
$$\frac1{\sqrt{1+w}}+\frac1{\sqrt{1+x}}+\frac1{\sqrt{1+y}}+\frac1{\sqrt{1+z}}\leq 3$$
for $w,x,y,z>0$ and $wxyz=1$. If $wx,yz\leq 4$, then the sum is at most
$$\frac2{\sqrt{1+t}}+\frac2{\sqrt{1+\frac1t}}\leq \frac4{\sqrt{2}}=2\sqrt2<3$$
for $t=\sqrt{wx}$, where we have used our lemma on $\lambda=t^2=wx$, $\lambda=1/t^2=yz$, and again on $\lambda=1$. Otherwise, assume without loss of generality that $wx\geq 4$, and let $s=\sqrt{wx}$. Then, by our lemma, the sum is at most
$$\sqrt{\frac{s^2}{s^2-1}}+\frac{2}{\sqrt{1+\frac1s}},$$
where $s\geq 2$. However, for $s\geq 2$,
\begin{align\*}
\sqrt{\frac{s^2}{s^2-1}}+\frac{2}{\sqrt{1+\frac1s}}
&=\frac{\sqrt s(\sqrt s+2\sqrt{s-1})}{\sqrt{s^2-1}}\\
&\leq \frac{\sqrt s\left(\sqrt s+2\left[\sqrt s-\frac1{2\sqrt s}\right]\right)}{\sqrt{s^2-1}}\\
&=\frac{3s-1}{\sqrt{s^2-1}},
\end{align\*}
which is at most $3$ whenever $s\geq 5/3$ since
$$(3s-1)^2=9s^2-6s+1\leq 9s^2-9\implies \frac{3s-1}{\sqrt{s^2-1}}\leq 3.$$
|
45,077,014 |
```
select
MITARBEITER.NAME,
MITARBEITER.GEHALT
from
MITARBEITER
where MITARBEITER.GEHALT = @minGehalt
DECLARE @minGehalt as INT
SET @minGehalt = (SELECT MIN(MITARBEITER.GEHALT) FROM MITARBEITER)
EXEC @minGehalt
```
@minGehalt is a number
My problem is it says its not declared
|
2017/07/13
|
[
"https://Stackoverflow.com/questions/45077014",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
Ok it's been a while but I got it working in another project without the `setTimeOut` function so I wanted to answer this question.
Since Redux pass the new updates through props, I used the `componentWillRecieveProps()` method instead of `componentDidUpdate()` , this allowes you a better control over the updated properties and works as expected with the `scrollIntoView()` function.
```
class PhotoContainer extends React.Component {
componentWillReceiveProps(newProps) {
if (
this.props.navigation.sectionSelected !==
newProps.navigation.sectionSelected &&
newProps.navigation.sectionSelected !== ""
) {
this.focusDiv(newProps.navigation.sectionSelected);
}
}
focusDiv(section){
var scrolling = this[section]; //section would be 'theDiv' in this example
scrolling.scrollIntoView({ block: "start", behavior: "smooth" });//corrected typo
}
render() {
const totalList = [];
for(let i = 0; i < 300; i += 1) {
totalList.push(
<div key={i}>{`hello ${i}`}</div>
);
}
return (
<div >
{totalList}
<div ref={(el) => this.theDiv = el}>
this is the div I am trying to scroll to
</div>
</div>
)
};
}
```
|
67,333,760 |
I have an array like this.
```
let arr = ['A1.1', 'A1.3', 'A1.2', 'A1.1 (2)', 'A1.3 (2)', 'A1.2 (2)', 'A1.1 (3)', 'A1.3 (3)', 'A1.2 (3)']
```
Current sorting makes it like this. I have tried sort() method.
```
let arr = ['A1.1', 'A1.1 (2)', 'A1.1 (3)', 'A1.2', 'A1.2 (2)', 'A1.2 (3)', 'A1.3', 'A1.3 (2)', 'A1.3 (3)']
```
I need the result to be like this.
```
let arr = ['A1.1', 'A1.2', 'A1.3', 'A1.1 (2)', 'A1.2 (2)', 'A1.3 (2)', 'A1.1 (3)', 'A1.2 (3)', 'A1.3 (3)']
```
|
2021/04/30
|
[
"https://Stackoverflow.com/questions/67333760",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11934748/"
] |
Because single `int` surrounded by `()` has type `int`.
```py
>>> t = (1)
>>> type(t)
<class 'int'>
```
You can use `,` to make it tuple. (if it has only one value.)
```py
>>> t = (1,)
>>> type(t)
<class 'tuple'>
```
|
19,279 |
I constantly have exams that require to shade bubbles on an optical answer sheet. Usually I will shade it with a 0.5 (2B) lead mechanical pencil. I think I shade quite hard sometimes(not sure if the pressure matters), then when I try to erase my choices on the bubble, I realise there are still some remains on it (about 50% of its previous darkness) on the bubble, and I do not know if the machine will still detect that previous bubble as filled and be unable to conclude my final option.
Is there a way to get a good way to do exams related to these? Like getting a good eraser from a certain brand or making sure my eraser can lead to a cleaner erasing job?
|
2018/10/02
|
[
"https://lifehacks.stackexchange.com/questions/19279",
"https://lifehacks.stackexchange.com",
"https://lifehacks.stackexchange.com/users/25643/"
] |
A technique that I use that may help. I use a two-step approach.
No problem with the questions I know. I answer them and move on.
I answer the questions with a small, light "x" mark in the answer bubble if I have any question about the answer being the correct one. It's dark enough for me to see it easily.
Near the end of the exam, I review the lightly-marked answers and darken them in after I'm sure of my response.
This GREATLY REDUCES the need to use much time and effort to change a questionable answer.
|
623,968 |
Here's my data:
```
id date
1 2009-01-01 10:15:23
2 2009-01-01 13:21:29
3 2009-01-02 01:03:13
4 2009-01-03 12:20:19
5 2009-01-03 13:01:06
```
What I'd like to do is group by each date and then list the id numbers below each date. Should I be getting the distinct date values and then cycling through them to get the entries that fall on the date? is this efficient?
so my output would look like:
```
2009-01-01
1
2
2009-01-02
3
2009-01-03
4
5
```
|
2009/03/08
|
[
"https://Stackoverflow.com/questions/623968",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
```
$query = "SELECT DATE(date) as mydate, id FROM your_data_table ORDER BY mydate, id";
$result = $pdo->query($query);
$oldDate = false;
while ( list($date, $id) = $result->fetch(PDO::FETCH_NUM) ) {
if ( $oldDate != $date ) {
echo "$date\n$id\n";
$oldDate = $date;
} else {
echo "$id\n";
}
}
```
Instead of doing it in several queries, you just fetch all the data at once. If you only need some dates then you just put a `WHERE` clause before the `ORDER BY`.
|
8,353,538 |
I have a form which contains a wysiwyg editor. The form data is sent to a page using a GET method in the form.
How would i decode(to keep the DIV and BR tags) in the variable and print it out on the page using Javascript?
Any help would be appreciated
|
2011/12/02
|
[
"https://Stackoverflow.com/questions/8353538",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/954325/"
] |
The equivalent of decode would be unescape(), you should be able to something like this:
```
(function(){
document.$_GET = [];
var urlHalves = String(document.location).split('?');
if(urlHalves[1]){
var urlVars = urlHalves[1].split('&');
for(var i=0; i<=(urlVars.length); i++){
if(urlVars[i]){
var urlVarPair = urlVars[i].split('=');
document.$_GET[urlVarPair[0]] = urlVarPair[1];
}
}
}
})();
document.write(unescape(document.$_GET['varname']));
```
|
161,294 |
I have two coordinates which represent the mouse position with respect to the center of the screen ([0, 0] meaning the center, y increases downwards).
So, [0, 0] is one corner of the triangle, and mousePos is another. Now, the position of the mouse should determine the direction of of a small sprite representing the player (in radians).
When the mousePos is, say, [0, -100], right above the player (remember, y increases downwards), then the players direction is 0. When it's [100, 0], right to the player, the direction should be PI/2.
How do I get this? I know how to do it in a very long way, which would be very inefficient for the computer. What is the standard way of computing the angle?
|
2012/06/21
|
[
"https://math.stackexchange.com/questions/161294",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/17356/"
] |
You want to use the [atan2](http://en.wikipedia.org/wiki/Atan2) function if you have it.
Since different languages treat it in different ways, you may need to experiment: `atan2(-y,x)` or `atan2(x,-y)` will probably give you what you want.
|
51,175 |
One of the things that affects the color of the sky is the wavelengths of light that the star emits, like the image in [this question](https://worldbuilding.stackexchange.com/questions/48867/sky-color-of-an-alien-world). Here is the image again:
[](https://i.stack.imgur.com/wA8GN.jpg)
If you are standing on a circumbinary planet with an earth-like atmosphere orbiting a binary star system containing one star from the left side of that image and one star from the right side, would the sky appear different colors depending on which star was currently visible? If not, what sort of atmospheric conditions would make it possible?
For the purposes of this question, I am counting different shades of the same hue as the same color, i.e. light blue and dark blue don't count as "different colors".
|
2016/08/10
|
[
"https://worldbuilding.stackexchange.com/questions/51175",
"https://worldbuilding.stackexchange.com",
"https://worldbuilding.stackexchange.com/users/2566/"
] |
Yes, because:
Here on Earth you see a wide range of colours in the sky depending on time of day, cloud cover, dust etc. as the atmosphere absorbs and scatters different frequencies of the generally yellow light from our Sun.
If your planet orbits a very blue star you won't expect to see the reds you get here at sunrise and sunset.
If it orbits a very red star, you will never see a blue sky as you just won't get light at those wavelengths.
**So:**
Assuming a similar atmosphere to our own, when your red star is in the sky you will have an overall red sky, with the blue star in the sky you will have a blue sky. With both you will have variation.
The interesting times will be at or around sunset and sunrise as the light from one appears or disappears and is attenuated through atmosphere.
|
7,432 |
In this headline:
>
> [Wie Franziskus die Machtachse der Kirche verschiebt](http://www.zeit.de/gesellschaft/zeitgeschehen/2013-07/franziskus-brasilien-lateinamerika)
>
>
>
there is this word, *Machtachse*, which I haven't been able to find anywhere (so I don't even know if it's really a word).
In the same headline there is also *verschiebt*, which, presumably, is the present of the verb *verschieben*, which means either *to move / to shift*, or *to change*, even *to postpone*.
Unfortunately, I cannot infer what this verb means in this context unless I have a translation for *Machtachse*.
|
2013/07/27
|
[
"https://german.stackexchange.com/questions/7432",
"https://german.stackexchange.com",
"https://german.stackexchange.com/users/3111/"
] |
*Macht* means power, and *Achse* means axis. Together, it means the *axis of power*. I didn't read the article, but the headline express how possible it is that the "axis of power" (or rather part of it) could be translated from the Vatican to Latin America.
Just as a hint, if you don't find a word in the dictionary, you can divide it in words which you know (or which you might find in the dictionary). Sometimes it is sufficient to identify just one of them.
|
12,869,251 |
I have a function literal
```
{case QualifiedType(preds, ty) =>
t.ty = ty ;
Some((emptyEqualityConstraintSet,preds)) }
```
Which results in an error message
```
missing parameter type for expanded function The argument types of an anonymous function
must be fully known. (SLS 8.5) Expected type was:
? => Option[(Typer.this.EqualityConstraintSet, Typer.this.TypeRelationSet)]
```
I looked in [SLS 8.5](https://www.scala-lang.org/files/archive/spec/2.11/08-pattern-matching.html#pattern-matching-anonymous-functions), but didn't find an explanation.
If I expand the function myself to
```
{(qt : QualifiedType) =>
qt match {case QualifiedType(preds, ty) =>
t.ty = ty ;
Some((emptyEqualityConstraintSet,preds)) }}
```
the error goes away.
(a) Why is this an error?
(b) What can I do to fix it?
I tried the obvious fix, which was to add `: QualifiedType` between the pattern and the =>, but this is a syntax error.
---
One thing I noticed is that the context makes a difference. If I use the function literal as an argument to a function declared as expecting a `QualifiedType => B`, there is no error. But if I use it as an argument to a function expecting an `A => B`, there is an error. I expect that what is going on here is that, as the pattern could conceivably be applied to an object whose type is a supertype of QualifiedType, the compiler is not willing to assign the obvious type without assurance that the function won't be applied to anything that isn't a QualifiedType. Really what I'd like is to be able to write `{QualifiedType( preds, ty) => ...}`
and have it mean the same thing as Haskell's `\QualifiedType(preds,ty) -> ...`.
|
2012/10/13
|
[
"https://Stackoverflow.com/questions/12869251",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/667690/"
] |
`{ case X(x) => ... }` is a partial function, but the compiler still doesn't know what your input type is, except that it's a supertype of `X`. Normally this isn't a problem because if you're writing an anonymous function, the type is known from the context. But here is how you can provide the type:
```
case class Foo(x: Int)
// via annotation
val f: Foo => Int = { case Foo(x) => x }
// use pattern matching
val f = (_: Foo) match { case Foo(x) => x }
// or more normally, write as a method
def f(a: Foo) = a match { case Foo(x) => x }
def f(a: Foo) = a.x
```
As you've probably noticed, using function literals / pattern matching here is pretty pointless. It seems in your case you just need a regular method:
```
def whatever(qt: QualifiedType) = {
t.ty = qt.ty
Some((emptyEqualityConstraintSet, qt.preds))
}
```
although you should refactor to remove that mutable state.
|
30,956,943 |
so in routing.yml I have the following routes defined in order to edit and delete specific settings:
**routing.yml:**
```
settings.editDefaults:
path: settings/{id}/defaults/edit/{widgetType}
defaults: { _controller: AppBundle:Settings:editDefaults }
methods: [POST, PUT]
settings.deleteDefaults:
path: settings/{id}/defaults/delete/{widgetType}
defaults: { _controller: AppBundle:Settings:deleteDefaults }
methods: [DELETE]
```
And in my controller I have the correct actions defined:
**SettingController.php:**
```
/**
* edit the default settings of a hotel/widget
*/
public function editDefaultsAction(Request $request)
{
//Edit logic
}
/**
* delete a default setting of a hotel/widget
*/
public function deleteDefaultsAction($hotelId, $widgetType)
{
//Delete logic
}
```
In the second action I only need the `id` and `widgetType` passed so I can query for and remove the selected record.
When I go to either of the routes I get the following:
**Edit Route Error:**
>
> No route found for "GET
> /settings/2b2acd55-0dd6-11e5-8107-621ae3320fd4/defaults/edit/default":
> Method Not Allowed (Allow: POST, PUT)
>
>
>
**Delete Route Error:**
>
> No route found for "GET
> /settings/2b2acd55-0dd6-11e5-8107-621ae3320fd4/defaults/delete/default":
> Method Not Allowed (Allow: DELETE)
>
>
>
But when I remove one and leave the other they work fine. I'm assuming it's the path definitions that are similar? Is it possible for me to keep the same paths and not get this error? What am I not understanding?
Thanks for your help, Anth
|
2015/06/20
|
[
"https://Stackoverflow.com/questions/30956943",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3966445/"
] |
You only allow POST, PUT and DELETE methods, but you are accessing those routes via GET method.
so define your routes like this:
```
settings.editDefaults:
path: settings/{id}/defaults/edit/{widgetType}
defaults: { _controller: AppBundle:Settings:editDefaults }
settings.deleteDefaults:
path: settings/{id}/defaults/delete/{widgetType}
defaults: { _controller: AppBundle:Settings:deleteDefaults }
```
Or leave the DELETE, PUT and POST methods in, if you really need those restrictions and add GET method.
When you are accessing a URL with your browser, you are usually sending a your request via GET method. You can read more about these:
[Here](http://www.tutorialspoint.com/http/http_methods.htm)
[And here](http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html)
|
35,328,272 |
My program is having issues with the printRecipeOfTheDay function. Say for example 0 is randomly selected by the program and gets assigned to the Monday variable I created, when I pass "recipe1" to the function "printRecipeOfTheDay" I get no output or a null value. Any idea on what I may have messed up?
```
if monday == 0 {
fmt.Println(0)
printRecipeOfTheDay(recipe1)
} else if monday == 1 {
fmt.Println(1)
```
The entire program is below:
```
package main
import (
"fmt"
"math/rand"
"time"
)
//Struct for Recipe below
type Recipe struct { //Struct for recipe information
name string
prepTime int
cookTime int
Ingredients []string //this is now a slice that will accept multiple elements
ID int
Yield int
}
//function to print Recipe
func printRecipe(recipe Recipe) {
fmt.Printf("Recipe Name : %s\n", recipe.name)
fmt.Printf("Prep Time : %d\n", recipe.prepTime)
fmt.Printf("Cook Time : %d\n", recipe.cookTime)
fmt.Printf("Ingredients : %s\n", recipe.Ingredients)
fmt.Printf("Recipe ID : %d\n", recipe.ID)
}
//Returns total time by addings cookTime and prepTime
func totalTime(recipe Recipe) {
fmt.Printf("The total time for this recipe is %d\n", recipe.cookTime+recipe.prepTime)
}
func main() {
var recipe1 Recipe //Declare recipe1 of Type Recipe
var recipe2 Recipe
var recipe3 Recipe
//choose random number for recipe
r := rand.New(rand.NewSource(time.Now().UnixNano()))
i := r.Perm(5)
fmt.Printf("%v\n", i)
fmt.Printf("%d\n", i[0])
//assign slices of int from Perm to variables assigned days of the week
var monday = i[0]
var tuesday = i[1]
var wednesday = i[2]
var thursday = i[3]
var friday = i[4]
//testing printing of variables assigned to days
fmt.Printf("This is for the day Monday %d\n", monday)
fmt.Printf("%d\n", tuesday)
fmt.Printf("%d\n", wednesday)
fmt.Printf("%d\n", thursday)
fmt.Printf("%d\n", friday)
//logic for Mondays Recipe
if monday == 0 {
fmt.Println(0)
printRecipeOfTheDay(recipe1)
} else if monday == 1 {
fmt.Println(1)
printRecipeOfTheDay(recipe2)
} else if monday == 2 {
fmt.Println(2)
printRecipeOfTheDay(recipe3)
} else if monday == 3 {
fmt.Println(3)
}
/* recipe1 specifications */
recipe1.name = "BBQ Pulled Chicken"
recipe1.prepTime = 25
recipe1.cookTime = 5
recipe1.Ingredients = append(
recipe1.Ingredients,
"1 8-ounce can reduced-sodium tomato sauce",
)
recipe1.Ingredients = append(
recipe1.Ingredients,
"1/2 medium onion (grated),",
)
recipe1.ID = 1
recipe1.Yield = 8
/* Recipe 2 specifications */
recipe2.name = "Steak Tacos with Pineapple"
recipe2.prepTime = 45
recipe2.cookTime = 45
recipe2.Ingredients = append(
recipe2.Ingredients,
"3 tablespoons soy sauce,",
)
recipe2.Ingredients = append(
recipe2.Ingredients,
"1 tablespoon finely grated garlic,",
)
recipe2.Ingredients = append(
recipe2.Ingredients,
"1 tablespoon finely grated peeled fresh ginger,",
)
recipe2.Ingredients = append(
recipe2.Ingredients,
"1 1/2 pounds skirt steak, cut into 5-inch lengths,",
)
recipe2.Ingredients = append(
recipe2.Ingredients,
"Salt",
)
recipe2.Ingredients = append(
recipe2.Ingredients,
"Pepper",
)
recipe2.ID = 2
recipe2.Yield = 4
recipe3.name = "Simple Lemon Herb Chicken"
recipe3.prepTime = 10
recipe3.cookTime = 15
recipe3.Ingredients = append(
recipe3.Ingredients,
"2 skinless boneless chicken breast halves,",
)
recipe3.Ingredients = append(
recipe3.Ingredients,
"1 Lemon,",
)
recipe3.Ingredients = append(
recipe3.Ingredients,
"Salt and Pepper to taste,",
)
recipe3.Ingredients = append(
recipe3.Ingredients,
"1 tablespoon olive oil,",
)
recipe3.Ingredients = append(
recipe3.Ingredients,
"2 sprigs fresh parsley (for garnish),",
)
recipe3.Ingredients = append(
recipe3.Ingredients,
"1 pinch dried oregano,",
)
recipe3.ID = 3
recipe3.Yield = 2
//call to printRecipe function below
printRecipe(recipe1)
totalTime(recipe1)
printRecipe(recipe2)
totalTime(recipe2)
printRecipe(recipe3)
totalTime(recipe3)
}
//function to print the winner for recipe of the day to use
//for either lunch or dinner
func printRecipeOfTheDay(recipe Recipe) {
fmt.Printf("The recipe of the day is : %s\n", recipe.name)
}
```
|
2016/02/10
|
[
"https://Stackoverflow.com/questions/35328272",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5896062/"
] |
You have your statements in the wrong order. At the point when you try to print the recipe you've declared it but you've done no initialization so it should be null.
```
package main
import (
"fmt"
"math/rand"
"time"
)
//Struct for Recipe below
type Recipe struct { //Struct for recipe information
name string
prepTime int
cookTime int
Ingredients []string //this is now a slice that will accept multiple elements
ID int
Yield int
}
//function to print Recipe
func printRecipe(recipe Recipe) {
fmt.Printf("Recipe Name : %s\n", recipe.name)
fmt.Printf("Prep Time : %d\n", recipe.prepTime)
fmt.Printf("Cook Time : %d\n", recipe.cookTime)
fmt.Printf("Ingredients : %s\n", recipe.Ingredients)
fmt.Printf("Recipe ID : %d\n", recipe.ID)
}
//Returns total time by addings cookTime and prepTime
func totalTime(recipe Recipe) {
fmt.Printf("The total time for this recipe is %d\n", recipe.cookTime+recipe.prepTime)
}
func main() {
var recipe1 Recipe //Declare recipe1 of Type Recipe
var recipe2 Recipe
var recipe3 Recipe
/* recipe1 specifications */
recipe1.name = "BBQ Pulled Chicken"
recipe1.prepTime = 25
recipe1.cookTime = 5
recipe1.Ingredients = append(
recipe1.Ingredients,
"1 8-ounce can reduced-sodium tomato sauce",
)
recipe1.Ingredients = append(
recipe1.Ingredients,
"1/2 medium onion (grated),",
)
recipe1.ID = 1
recipe1.Yield = 8
/* Recipe 2 specifications */
recipe2.name = "Steak Tacos with Pineapple"
recipe2.prepTime = 45
recipe2.cookTime = 45
recipe2.Ingredients = append(
recipe2.Ingredients,
"3 tablespoons soy sauce,",
)
recipe2.Ingredients = append(
recipe2.Ingredients,
"1 tablespoon finely grated garlic,",
)
recipe2.Ingredients = append(
recipe2.Ingredients,
"1 tablespoon finely grated peeled fresh ginger,",
)
recipe2.Ingredients = append(
recipe2.Ingredients,
"1 1/2 pounds skirt steak, cut into 5-inch lengths,",
)
recipe2.Ingredients = append(
recipe2.Ingredients,
"Salt",
)
recipe2.Ingredients = append(
recipe2.Ingredients,
"Pepper",
)
recipe2.ID = 2
recipe2.Yield = 4
recipe3.name = "Simple Lemon Herb Chicken"
recipe3.prepTime = 10
recipe3.cookTime = 15
recipe3.Ingredients = append(
recipe3.Ingredients,
"2 skinless boneless chicken breast halves,",
)
recipe3.Ingredients = append(
recipe3.Ingredients,
"1 Lemon,",
)
recipe3.Ingredients = append(
recipe3.Ingredients,
"Salt and Pepper to taste,",
)
recipe3.Ingredients = append(
recipe3.Ingredients,
"1 tablespoon olive oil,",
)
recipe3.Ingredients = append(
recipe3.Ingredients,
"2 sprigs fresh parsley (for garnish),",
)
recipe3.Ingredients = append(
recipe3.Ingredients,
"1 pinch dried oregano,",
)
recipe3.ID = 3
recipe3.Yield = 2
//choose random number for recipe
r := rand.New(rand.NewSource(time.Now().UnixNano()))
i := r.Perm(5)
fmt.Printf("%v\n", i)
fmt.Printf("%d\n", i[0])
//assign slices of int from Perm to variables assigned days of the week
var monday = i[0]
var tuesday = i[1]
var wednesday = i[2]
var thursday = i[3]
var friday = i[4]
//testing printing of variables assigned to days
fmt.Printf("This is for the day Monday %d\n", monday)
fmt.Printf("%d\n", tuesday)
fmt.Printf("%d\n", wednesday)
fmt.Printf("%d\n", thursday)
fmt.Printf("%d\n", friday)
//logic for Mondays Recipe
if monday == 0 {
fmt.Println(0)
printRecipeOfTheDay(recipe1)
} else if monday == 1 {
fmt.Println(1)
printRecipeOfTheDay(recipe2)
} else if monday == 2 {
fmt.Println(2)
printRecipeOfTheDay(recipe3)
} else if monday == 3 {
fmt.Println(3)
}
//call to printRecipe function below
printRecipe(recipe1)
totalTime(recipe1)
printRecipe(recipe2)
totalTime(recipe2)
printRecipe(recipe3)
totalTime(recipe3)
}
//function to print the winner for recipe of the day to use
//for either lunch or dinner
func printRecipeOfTheDay(recipe Recipe) {
fmt.Printf("The recipe of the day is : %s\n", recipe.name)
}
```
I just did a quick cut and paste there cause I'm rather busy at the moment. I may edit this later, it would just be for style and readability. I recommend making an `initRecipes` method and having it return a `[]Recipe` and using composite literal syntax to do your initialization instead of calling append over and over again.
|
4,993,802 |
i got a (hopefully) simple problem with a Code Template on Eclipse. I try to use a Code Template to surround a word with somehing. The Replacement is nearly successful, but i have a problem with handling the selected word.
My task is to select "save " on this example
```
<button type="submit">save</button>
```
and want to have
```
<button type="submit"><?= $this->_('save') ?></button>
```
The problem is, that i got this after replacement
```
<button type="submit">save<?= $this->_('save') ?></button>
```
Is there a possibility to remove the selected word after using a code template? I am thankful for every help i get. Smile
I forgot, the template looks like this:
```
<?= $$this->_('${word_selection}') ?>${cursor}
```
|
2011/02/14
|
[
"https://Stackoverflow.com/questions/4993802",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/616419/"
] |
Maybe this question is somewhat old, but I came across the same idea in Java for adding String constants by simply typing the desired name and then replace it with a template, like this for example:
type `VALUE` and get it replaced with `private static final String VALUE = "VALUE";`
I use eclipse 3.6 and got it working with the following template:
`private static final String ${word_selection} = "${word_selection}";`
Then I do the following steps:
1. type `VALUE`
2. select it by double-clicking and hit `CTRL`+`SPACE`
3. enter first few chars for the template name in the opened proposal pop-up and select the template (see image below)

4. hit `ENTER`
And the result is this:

Maybe this is helpful.
|
41,611,750 |
I have a piece of statement that I don't understand how to model it in a class diagram. It is about **Formula 1 races**. The piece is the following:
>
> We can only have one race per circuit in each season
>
>
>
So there is a relationship between **CIRCUIT**, **SEASON** and **RACE**.
---
I believe that it is a ternary association, but a mate told me that it could be an association between **CIRCUIT - SEASON** and then an association between ***that association*** and **RACE**:
[](https://i.stack.imgur.com/F0l9r.png)
Is that picture wrong? I mean, association should be between 2 classes as far as I know. Not between a class and an association...
Thank's you very much!!!!
**EDIT:**
The statement was wrong, I restated it and could be translated in: (imagine we have 3 circuits)
* Circuit A in Season 1 --> Race 1
* Circuit B in Season 1 --> Race 2
* Circuit C in Season 1 --> Race 3
* *Circuit A in Season 1 --> Race 4* (This should not be allowed, we can only have one race per circuit in each season)
* Circuit A in Season 2 --> Race 5 (This is correct)
We can only have 1 race per circuit in each season
|
2017/01/12
|
[
"https://Stackoverflow.com/questions/41611750",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5356700/"
] |
To make `Race` an association class as desired, make the horizontal connector dashed and remove the multiplicities. The above currently shows sort of a ternary connector (see discussion).
[](https://i.stack.imgur.com/wSEzJ.png)
This is equivalent to
[](https://i.stack.imgur.com/C4efr.png)
The multiplicity `0..1` tells that there is one or no race per season and circuit.
|
144,116 |
i recently got a new cord for my laptop because the cord i had before broke.im not sure how it got messed up, but one moment it charged my laptop and the next moment it didn't. i then got a new cord. the new cord worked perfectly fine until now, and it has only been a month. the cord wont work unless i am pressing it into the socket, which i am currently doing. the only thing i can find in common with the cords is that i leave them plugged in 24/7. my brother says that is the problem, but i do not think it is.any tips or hints? im going to use duct tape to keep the pressure on the cord till i can find a better solution(im also thinking it could be the hole i plug it into on the back of my computer, but im focusing on the other idea for now.if i wiggle the plug part in the socket of my computer it will stop charging unless im pressing it in or to the side) any help or ideas are appreciated. not sure if this will help but i use a gateway with windows vista. thanks
|
2010/05/22
|
[
"https://superuser.com/questions/144116",
"https://superuser.com",
"https://superuser.com/users/-1/"
] |
It is very possible this isn't a cord problem, usually when this happens, the socket is either:
1. Not solded on the circuit board properly,
2. The socket broke off from the main circuit board by applying sideward pressure on the plug while it was plugged in,
3. The circuit board has been torn/broken by the same cause as the one in remark 2,
4. Molten by use of an excessive charger. (This happens A LOT with Acer Laptops)
|
34,488,776 |
I'm new to C++ (although also a relative newbie to C) and I've written some code in which I read a file into a char Vector. I then need to consume chunks of this vector and pass the next chunk to an appropriate class for handling.
In C, I would have simply made a char array, and then moved a pointer along the chunks. Basically I could treat the pointer position as a "new" array for the sake of my processing classes and it's efficient since I don't need to copy the data at all.
for example:
```
char arr[100];
char *pa = &arr[0];
char *pa_half = &arr[50];
//pass pa somewhere and pa_half elsewhere for processing
```
I more or less want this behavior in C++. Do I need to initialize new Vectors each time? If so, does this mean I have to copy the data?
Much appreciated!
|
2015/12/28
|
[
"https://Stackoverflow.com/questions/34488776",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2152153/"
] |
You can do the same thing with `std::vector`:
```
std::vector<char> arr(100);
char *pa = &arr[0];
char *pa_half = &arr[50];
//pass pa somewhere and pa_half elsewhere for processing
```
Or if you use `iterator`:
```
std::vector<char> arr(100);
auto pa = arr.begin();
auto pa_half = pa + 50;
//pass pa somewhere and pa_half elsewhere for processing
```
Note that pointer or iterator will become invalid if [std::vector](http://en.cppreference.com/w/cpp/container/vector) get destroyed or reconstructed.
|
396,153 |
Let $x$ be an odd number, $y$ a positive integer, and $p$ an odd prime number such that $x^2+y^2=p$. Show that there exists an integer $a$ such that $\dfrac{a^2-x}{p}\in \mathbb{Z}.$
This problem is one that my friend asked me, and I've considered it for some time, but I can't prove it. Thank you everyone.
|
2013/05/19
|
[
"https://math.stackexchange.com/questions/396153",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/58742/"
] |
Google the Square wave function $\mathbf{sqw}(x)=(-1)^{\mathbf{floor}(x)}$ to find out it is a periodic function which is obviously piecewise and by using the L.T. rules we can see that $$\mathcal{L}\{\mathbf{sqw}(x)\}=\frac{1}{s}\tanh(s/2)=\frac{e^s-1}{s(e^s+1)}$$ So since $$\mathcal{L}\{1\}=\frac{1}{s}$$ I think you can do the rest.
|
47,546,610 |
I have a payroll database table that shows punch ins, and punch outs. Im trying to get the total amount of hours worked, but am having no luck.
The $time\_array is a regular array, made from the data pictured below.
```
$time_array = ['8:55', '11:31', '12:34', '6:19' ];
```
Im trying
```
$i = 0;
$total_time = 0;
foreach($time_array as $time){
if($i % 2 == 0){
$punch_in = strtotime($time);
}else{
$punch_out = strtotime($time);
$total_time = $punch_in - $punch_out;
}
$i++;
}
echo $total_time;
$total_time = 0;
$i = 0;
```
Ive attached a photo of the data im trying to use.
[](https://i.stack.imgur.com/4Zx4O.png)
Edit: Here is what worked
=========================
```
$time_array = ['8:55', '11:31', '12:34', '6:19' ];
$punch_in = [];
$punch_out = [];
$i = 0;
foreach($times as $time){
//echo $name . ":". $time . "<br>";
if($i%2==0){
$punch_in[] = strtotime($time);
}else{
$punch_out[] = strtotime($time);
}
$i++;
}
$totally = 0;
for ($i = 0; $i < count($punch_out); $i++){
//echo "Time in: ".$punch_in[$i] . b;
//echo "Time out: ".$punch_out[$i] . b;
$result = abs($punch_in[$i]) - abs($punch_out[$i]);
$totally += abs($result);
echo "<br>";
}
```
==========================================
Is there a name to this algorithm strategy?
|
2017/11/29
|
[
"https://Stackoverflow.com/questions/47546610",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4441614/"
] |
I can't really understand the error message as of now. There are two things that I can see which can make it go wrong here
1) To add a subcomponent to a parent component, add the subcomponent class to the subcomponents attribute of a @Module that the parent component installs. Then the subcomponent’s builder can be requested from within the parent
`@Module(subcomponents = XYZ.class)
class AppModule(val app: Application){`
2) Also, you are providing the same scope to subcomponent and component which is not allowed unless there is no ambiguity in resolution.
Please read the documentation here at
<https://google.github.io/dagger/subcomponents.html>
|
13,643,230 |
I am currently converting a legacy ASP.NET 1.1 application into a .NET 4 MVC 3 application.
I am looking at the password encryption and a routine was written in the old code to use the MD5CryptoServiceProvider.
```
private string EncryptText(string szText)
{
try
{
UTF8Encoding objEncoder = new UTF8Encoding();
MD5CryptoServiceProvider objMD5Hasher = new MD5CryptoServiceProvider();
Byte[] btHashedDataBytes = objMD5Hasher.ComputeHash(objEncoder.GetBytes(szText));
string szReturn = objEncoder.GetString(btHashedDataBytes);
objEncoder = null;
objMD5Hasher = null;
return szReturn;
}
catch
{
return "";
}
}
```
I have written a quick .NET 4 console application and copied this function so I can do a comparison against the current passwords in the database (to make sure the MD5 function still gives me the same output)
```
string encTxt = encryptor.EncryptText("fbloggsPass12345");
using (SqlConnection conn = new SqlConnection("Server=server;Database=db;User Id=sa;Password=1111;"))
{
conn.Open();
using (SqlCommand cmd = new SqlCommand())
{
cmd.Connection = conn;
cmd.CommandType = System.Data.CommandType.Text;
cmd.CommandText = "UPDATE SiteUsers SET Token = '" + encTxt + "' WHERE PKey = 10";
if (cmd.ExecuteNonQuery() > 0)
Console.WriteLine("Updated");
else
Console.WriteLine("Failed");
}
conn.Close();
}
Console.ReadLine();
```
However the password in the database is currently !?MGF+&> and the output I am getting is ���!?��MGF�+&��> which when I store in the database converts to ???!???MGF?+&??>
Which I can see is almost the same, but why am I getting the ? characters
|
2012/11/30
|
[
"https://Stackoverflow.com/questions/13643230",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1659709/"
] |
This is the first problem, at least:
```
string szReturn = objEncoder.GetString(btHashedDataBytes);
```
You're trying to use the hash as if it were UTF-8-encoded text. It's not - it's just arbitrary binary data.
If you need to convert arbitrary binary data to text, you should use something like Base64 (e.g. `Convert.ToBase64String`) or hex.
(Additionally, I would *strongly* advise you not to "handle" exceptions in the way you're doing so at the moment. Why would you want to hide problems like that? And why are you setting variables to `null` just before they go out of scope anyway?)
Oh, and *please* don't include values directly in your SQL like that - use parameterized SQL instead.
Finally, I would use a different hashing algorithm these days, particularly for passwords. Can you not use an off-the-shelf system for authentication, which is actually developed by security experts? Security is difficult: we'd all be better off leaving it to the relatively few people who know how to do it right :) See comments for more suggestions.
|
46,435,335 |
I have an problem as follows, burning my mind pretty hard.
Imagine the following table (the second\_id is unimportant and saying that i should use unique() is not working in my case)
```
create table adressen (
id int PRIMARY KEY AUTO_INCREMENT,
second_id int,
name char(64),
email char(64)
);
INSERT INTO adressen (second_id, name, email) VALUES ('1','max','[email protected]');
INSERT INTO adressen (second_id, name, email) VALUES ('1','peter','[email protected]');
INSERT INTO adressen (second_id, name, email) VALUES ('1','emma','[email protected]');
INSERT INTO adressen (second_id, name, email) VALUES ('2','max','[email protected]');
INSERT INTO adressen (second_id, name, email) VALUES ('2','peeter','[email protected]');
INSERT INTO adressen (second_id, name, email) VALUES ('2','emma','[email protected]');
INSERT INTO adressen (second_id, name, email) VALUES ('3','maax','[email protected]');
INSERT INTO adressen (second_id, name, email) VALUES ('3','elisa','[email protected]');
INSERT INTO adressen (second_id, name, email) VALUES ('3','eemmaa','[email protected]');
```
As you can see, there are multiple users with the same mail, but with different names.
Im trying to select all mails, where multiple names exist.
In this case it would be:
* `[email protected]` with the two different names (`emma`, `eemmaa`)
* `[email protected]` with the two different names (`max`, `maax`)
* `[email protected]` with the two different names (`peter`, `peeter`)
So the output shall be 1 row for each "set" of name and mail, like:
```
[email protected] , emma
[email protected] , eemmaa
[email protected], max
[email protected], maxx
petertest.com, peter
petertest.com, peeter
```
I don't want to get the rows where mail and name are the same. Also i dont want to get a row, if there is only one entry (in this case for karl) in my table
Thanks a lot for your help!
|
2017/09/26
|
[
"https://Stackoverflow.com/questions/46435335",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8496515/"
] |
Use a subquery that finds all the `mail` values with more than one different `name`, and join with the table itself.
```
SELECT DISTINCT a.mail, a.name
FROM tbl a
JOIN (
SELECT mail
FROM tbl
GROUP BY mail
HAVING COUNT(DISTINCT name) > 1
) b ON a.mail = b.mail
ORDER BY a.mail, a.name;
```
[DEMO](http://rextester.com/BCOP84426)
This is based on O. Jones's answer, but adds `COUNT(DISTINCT name)` so that rows that have the same name and email aren't counted as duplicates.
|
21,281,785 |
I am new to this concept of reflection and finding problem in retrieving property value from a string. E.g.
I have a class Employee with following properties :
```
public string Name {get;set;}
public int Age {get;set;}
public string EmployeeID {get;set;}
string s = "Name=ABCD;Age=25;EmployeeID=A12";
```
I want to retrieve the value of each property from this string and create a new object of Employee with those values retrieved from the string for each field.
Can anyone please suggest how it can be done using reflection ??
|
2014/01/22
|
[
"https://Stackoverflow.com/questions/21281785",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3223270/"
] |
You need something like this:
```
var sendData= true;
$('#file').fileupload({
dataType : 'json',
autoUpload : false,
add : function(e,data){
$("#myForm button").on("click",function(){
if(sendData){
data.formData = $("#myForm").serializeArray();
sendData = false;
}
data.submit();
});
},
done: function(e,data){
sendData = true;
}
})
```
here you can find more information about [formData](https://github.com/blueimp/jQuery-File-Upload/wiki/How-to-submit-additional-form-data)
|
48,020,790 |
I created a signed build of my application which is working fine in every device but fails to install in OnePlus One device with device error as `App not installed`. I tried to check the logcat and it resulted into `Installation error code: -7`. I looked for it on Google but found nothing helpful.
This happened when I changed the package name of my project.
|
2017/12/29
|
[
"https://Stackoverflow.com/questions/48020790",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3876954/"
] |
Replace your for by the code below:
```
for (int j =0; j<words.length; j++){
char whitespace = ' ';
System.out.print(words[j].toUpperCase());
if (j < (words.length - 1)) {
System.out.print(whitespace);
}
}
```
That way, you will add a whitespace except for the last word of your array
|
89,902 |
I work with QGIS, v. 2.0.1. I have a point layer in which I have structures that could be represented as lines or polygons, but at the moment they are represented as a group of points. I know I can create new layers with different geometry but if I do this, I don't have the attribute table of the original point layer attached to the new line/polygon layer. And if I copy the point layer, I have the attribute table but it's not the right geometry. Can I change the geometry afterwards?
I could do a table join, right? But I don't have a common attribute and the table join is not permanent is it?
I tried the "PointstoPaths" Plugin, but it's not what I'm looking for. I also found the "Points2One" Plugin which seems perfect for my problem, but somehow it doesn't work (a shapefile is created but I can't "see" anything in the map).
That's how the map looks: for lines:
[](https://i.stack.imgur.com/tsc4m.png)
and for polygons:
[](https://i.stack.imgur.com/ts4f5.png)
I have about 800 points and the attributes show name of the place, measurements, date and much more.
|
2014/03/17
|
[
"https://gis.stackexchange.com/questions/89902",
"https://gis.stackexchange.com",
"https://gis.stackexchange.com/users/26528/"
] |
Creating a buffer around points (or lines) will result in a polygon shapefile that preserves the attribute table.
If you want to connect your points to a line or polygon, you have to specify the sequence of the points in the line. Form your images, I have not understood how you want to do this.
If you want to join 2 points with different attributes, only one can be stored for the line.
|
43,376,001 |
I have a cordova application where i have a login page and an inner page for logged in users. Whenever the user session is gone it asks for a login information. How do i prevent ths cordova app to drop sessions uppon restart or restore the cookies and session information when restarting the mobile app? So the login screen doesn't show up everytime?
|
2017/04/12
|
[
"https://Stackoverflow.com/questions/43376001",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3724513/"
] |
You can either use local storage or secure storage for storing some kind of token or something for the app.
During the startup of the app, you can check for the token and act accordingly.
secure storage cordova plugin
<https://github.com/Crypho/cordova-plugin-secure-storage>
local storage cordova plugin
<https://cordova.apache.org/docs/en/latest/cordova/storage/storage.html>
Hope this helps. :)
|
63,801,951 |
I noticed today that a [Python script](https://stackoverflow.com/questions/62955679/multithreaded-keyboard-detector-for-linux-and-windows) running in my PyCharm 2020.2 IDE on Windows 10, when I click on the X to quit, the main window disappears but PyCharm still shows its icon for a running script. After explicitly terminating the script in PyCharm the following error message appears.
```
Process finished with exit code -1
```
When the script in my PyCarm IDE is executed on Linux (Ubuntu), PyCharm does not show an icon for a running script after clicking on the X to exit the main window.
Why is this so?
**Code**
```
import sys
from datetime import datetime
import pythoncom
import wmi
from PyQt5. QtCore import QObject, QRunnable, QThreadPool, pyqtSignal
from PyQt5.QtWidgets import QApplication, QMainWindow, QTableWidget, QTableWidgetItem, QHeaderView
class KeyboardDetectorSignals(QObject):
keyboard_changed = pyqtSignal(str)
class KeyboardDetector(QRunnable):
def __init__(self):
super().__init__()
self.signals = KeyboardDetectorSignals()
def run(self):
pythoncom.CoInitialize()
device_connected_wql = "SELECT * FROM __InstanceCreationEvent WITHIN 2 WHERE TargetInstance ISA \'Win32_Keyboard\'"
device_disconnected_wql = "SELECT * FROM __InstanceDeletionEvent WITHIN 2 WHERE TargetInstance ISA \'Win32_Keyboard\'"
c = wmi.WMI()
connected_watcher = c.watch_for(raw_wql=device_connected_wql)
disconnected_watcher = c.watch_for(raw_wql=device_disconnected_wql)
while True:
try:
connected = connected_watcher(timeout_ms=10)
except wmi.x_wmi_timed_out:
pass
else:
if connected:
self.signals.keyboard_changed.emit("Keyboard connected.")
try:
disconnected = disconnected_watcher(timeout_ms=10)
except wmi.x_wmi_timed_out:
pass
else:
if disconnected:
self.signals.keyboard_changed.emit("Keyboard disconnected.")
class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
self.setGeometry(100, 100, 500, 500)
self.setWindowTitle("Keyboard Logger")
self.log_table = QTableWidget()
self.log_table.setColumnCount(2)
self.log_table.setShowGrid(True)
self.log_table.setHorizontalHeaderLabels(["Time", "Event"])
self.log_table.horizontalHeader().setStretchLastSection(True)
self.log_table.horizontalHeader().setSectionResizeMode(QHeaderView.ResizeToContents)
self.setCentralWidget(self.log_table)
self.show()
self.threadpool = QThreadPool()
keyboard_detector = KeyboardDetector()
keyboard_detector.signals.keyboard_changed.connect(self.add_row)
self.threadpool.start(keyboard_detector)
def add_row(self, event: str):
now = datetime.now()
datetime_string = now.strftime("%Y-%m-%d %H:%M:%S")
row_count = self.log_table.rowCount()
self.log_table.insertRow(row_count)
self.log_table.setItem(row_count, 0, QTableWidgetItem(datetime_string))
self.log_table.setItem(row_count, 1, QTableWidgetItem(event))
def main():
app = QApplication(sys.argv)
window = MainWindow()
sys.exit(app.exec_())
if __name__ == '__main__':
main()
```
|
2020/09/08
|
[
"https://Stackoverflow.com/questions/63801951",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7481773/"
] |
Note that `Process finished with exit code -1` isn't an error it just means your program was terminated.
|
1,097,769 |
This shell script is used to extract a line of data from `$2` if it contains the pattern `$line`.
`$line` is constructed using the regular expression `[A-Z0-9.-]+@[A-Z0-9.-]+` (a simple email match), form the lines in file `$1`.
```
#! /bin/sh
clear
for line in `cat "$1" | grep -i -o -E "[A-Z0-9.-]+@[A-Z0-9.-]+"`
do
echo `cat "$2" | grep -m 1 "\b$line\b"`
done
```
**File `$1`** has short lines of data (< 100 chars) and contains approx. 50k lines (approx. 1-1.5 MB).
**File `$2`** has slightly longer lines of text (> 80 to < 200) and has 2M+ lines (approx. 200MB).
The desktops this is running on has plenty of RAM (6 Gig) and Xenon processors with 2-4 cores.
Are there any quick fixes to increase performance as currently it takes 1-2 hours to completely run (and output to another file).
*NB: I'm open to all suggestions but we're not in the position to complexity re-write the whole system etc. In addition the data come from a third party and is prone to random formatting.*
|
2009/07/08
|
[
"https://Stackoverflow.com/questions/1097769",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/89035/"
] |
Quick suggestions:
1. Avoid the [useless use of `cat`](http://partmaps.org/era/unix/award.html) and change `cat X | grep Y` to `grep Y X`.
2. You can process the `grep` output as it is produced by piping it rather than using backticks. Using backticks requires the first `grep` to complete before you can start the second `grep`.
Thus:
```
grep -i -o -E "[A-Z0-9.-]+@[A-Z0-9.-]+" "$1" | while read line; do
grep -m 1 "\b$line\b" "$2"
done
```
Next step:
1. Don't process `$2` repeatedly. It's huge. You can save up all your patterns and then execute a single grep over the file.
2. Replace loop with `sed`.
No more repeated `grep`:
```
grep -i -o -E "[A-Z0-9.-]+@[A-Z0-9.-]+" "$1" | sed -E 's/^|$/\\1/g' > patterns
grep -f patterns "$2"
```
Finally, using some `bash` fanciness (see `man bash` → Process Substitution) we can ditch the temporary file and do this in one long line:
```
grep -f <(grep -i -o -E "[A-Z0-9.-]+@[A-Z0-9.-]+" "$1" | sed -E 's/^|$/\\b/g') "$2"
```
---
That's great unless you have so many patterns `grep -f` runs out of memory and barfs. If that happens you'll need to run it in batches. Annoying, but doable:
```
grep -i -o -E "[A-Z0-9.-]+@[A-Z0-9.-]+" "$1" | sed -E 's/^|$/\\1/g' > patterns
while [ -s patterns ]; do
grep -f <(head -n 100 patterns) "$2"
sed -e '1,100d' -i patterns
done
```
That'll process 100 patterns at a time. The more it can do at once the fewer passes it'll have to make over your 2nd file.
|
32,846,035 |
Controller
==========
```
public function codingPuzzleProcess()
{
$word = Input::get('word');
$length = strlen($word);
return Redirect::to('/coding-puzzle')
->with('word', $word )
->with('length', $length )
->with('success','Your word was submit succesfully!');
}
```
---
View
====
I tried to access those data in my blade view like this
`{!!$word or '' !!} | {!!$length or '' !!}`
and I'm not sure why I got nothing printing. I'm sure that my
`$word = 'love' with length of 4`
Any hints / suggestion on this will be much appreciated !
|
2015/09/29
|
[
"https://Stackoverflow.com/questions/32846035",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4480164/"
] |
A *redirect* doesn't pass control to a view, it passes control to the client, which then issues another, separate request, to the application.
*This* request will then be handled by a controller which can send data to a view like I think you are trying to. However, when you redirect and pass data like this, the data will not just become magically available in the current scope. It will instead be magically available in the session flash data:
```
{!! $word = session('word') ? $word : '' !!}
```
[Manual](http://laravel.com/docs/5.1/responses#redirecting-with-flashed-session-data)
|
14,178,659 |
I'd like to warp a TextView with an arc shape. I know it's possible to warp images, but is it possible to warp TextViews? Is there a established pattern for doing so?
My other option is to warp the text in Photoshop, save it with a transparent background, and use an ImageView, but a client wants this done in about 10 places and I'd like to avoid the extra resources if I can.

|
2013/01/06
|
[
"https://Stackoverflow.com/questions/14178659",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/654870/"
] |
You need to use customView, override the onDraw(), create a path and use drawTextOnPath.
```
@Override onDraw(Canvas canvas){
Path mPath = new Path();
mPath.addCircle(x, y, 200, Path.Direction.CW);
canvas.drawTextOnPath(textToDraw, mPath, textX, textY, paint);
}
```
Please have a look [Draw text in circular view?](https://stackoverflow.com/questions/10150642/draw-text-in-circular-view)
[How to Show Circular Text using TextView in Android](https://stackoverflow.com/questions/13153201/how-to-show-circular-text-using-textview-in-android)
|
49,941 |
When I was looking through what chords I should use in the key of B minor, I realized that C sharp diminished is one of them. But C sharp diminished has a B flat in it, which isn't in the scale of B minor. Why is this?
|
2016/10/30
|
[
"https://music.stackexchange.com/questions/49941",
"https://music.stackexchange.com",
"https://music.stackexchange.com/users/-1/"
] |
When we say C♯ dim. is in the key of B minor, we mean the C♯ diminished *triad*, which is `C♯ E G`. B minor is `B C♯ D E F♯ G A B` (note that this is natural minor), and `C♯ E G` is within that collection.
But, for what it's worth, that fully-diminished seventh chord is also in the key of B minor, though instead of B♭ the chordal seventh is spelled as A♯ (note that here we're using the harmonic minor collection of `B C♯ D E F♯ G A♯ B`). When we realize this, we suddenly spot that the chord is actually an A♯ diminished seventh chord, because when we stack thirds it's A♯ on the bottom instead of C♯.
This is because fully-diminished seventh chords are symmetrical, so we can conceptualize them as having up to four different roots. By symmetrical, I mean that the chord is constructed of three consecutive minor thirds: `C♯ E`, `E G`, and `G B♭`. `B♭ C♯` is also a minor third, just spelled as an augmented second. This means that we can conceptualize this fully-diminished seventh chord as having any one of these four roots (and their enharmonic equivalents).
|
18,499,036 |
This is a new question feeding from another question that was just answered [here](https://stackoverflow.com/questions/18498131/how-to-highlight-an-entire-div-based-on-search).
I am working to highlight a `<div>` based on search text. We've accomplished that, thanks to Alex.
Now, I'm trying to apply the same concept to mapped coordinates on an image map.
There's a jsfiddle [here](http://jsfiddle.net/jlnewnam/y8GUc/3/).
**Here's the JS(jQuery 1.10.2)...**
```
function doSearch(text) {
$('#content div').removeClass('highlight');
$('#content div:contains(' + text + ')').addClass('highlight');
}
```
|
2013/08/28
|
[
"https://Stackoverflow.com/questions/18499036",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2464865/"
] |
Assign
```
$_SESSION['question'] = $que;
```
`print_r($_SESSION['question'][0]);` will give you first question.
|
435,914 |
So I was reading about Tesla Coil propulsion and Ion Thrusters.
The things I don't understand are the following:
1. As it is shown on the image, when an electron collides into a gas atom, it ionizes it. But how does this happen? In order to do this, an electron had to eject one of atom's electrons and also "escape" the force of the protons? Or even eject two of atom's electrons, while being "captured" by atom...
2. When I tried to understand Tesla Coil propulsion I found an article about Corona discharge. There's an explanation for Ionization with cosmic rays, but that's not the case in Ionization chambers. So can someone please tell me what is actually going on? I'd be very grateful for graphical interpretation!
[](https://i.stack.imgur.com/IGVfE.png)
|
2018/10/21
|
[
"https://physics.stackexchange.com/questions/435914",
"https://physics.stackexchange.com",
"https://physics.stackexchange.com/users/210340/"
] |
What causes interference pattern to vanish? Suppose we send a particle through two slits. Then you will see an interference pattern.
Now, suppose there is some asymmetry in the two slots, so that somewhere in the universe (not necessarily accessible to the experimenter) there is some information telling which of the two slits the particle went through. Then the interference pattern vanishes.
There might be incomplete information that only gives us a probabilistic guess as to which slit the particle went through. In this case, the interference pattern is dimmer, but it doesn't go away completely.
Finally, to make things even more complicated, there is a very clever experiment that shows that, after we make a measurement $M\_1$ that gives us some information (we keep the results of this measurement in quantum superposition) telling us that which slit the particles went through, we can make a second measurement $M\_2$ on this information we kept which destroys it. What happens here is if we just look at the results of $M\_1$, the interference pattern is gone. But, conditioned on the result of the measurement $M\_2$, the interference pattern reappears. This is called the [quantum eraser experiment](https://en.wikipedia.org/wiki/Quantum_eraser_experiment).
So does the wave function collapse after measurement $M\_1$? No, it can't because we can restore the interference pattern with measurement $M\_2$. But it's not the experimenter looking at the results of $M\_1$ that collapses the wave function, because we can just throw the results of measurement $M\_1$ away, rather than remeasuring the outcome with measurement $M\_2$. If we do this, the interference pattern is gone forever, without the experimenter ever learning anything about the measurement.
I would stop worrying about what makes the wave function collapse, and start worrying about what causes the interference pattern to go away. Nobody knows when the wave function collapses. And some of the people who believe in the many-worlds interpretation of QM claim that the wave function never collapses; what happens instead is that the experimenter gets entangled with the outcome of the measurement.
|
1,017,768 |
I am trying to execute a mysql query over ssh
it works fine unless i put a where=xxx clause
can anyone guide me?
here is an example of a working one
```
ssh mysql1.server.xxx "sudo mysql -u root --execute 'SELECT * from mysql.user;'"
```
here is an example of the non working one
```
ssh mysql1.server.xxx "sudo mysql -u root --execute 'SELECT * from mysql.user where User='username';'"
```
|
2020/05/19
|
[
"https://serverfault.com/questions/1017768",
"https://serverfault.com",
"https://serverfault.com/users/575484/"
] |
You have nested single quotes:
```
'SELECT ... User='username';'
^ ^ ^ ^ <-- here
```
You need to escape one set of quotes. Example:
```
ssh mysql1.example.com "mysql --execute \"SELECT * from mysql.user where User='username';\""
```
|
21,629,167 |
I am trying to write my own validation attribute but I am having trouble getting the value of a property from the inherited class. This is my code:
```
protected override ValidationResult IsValid(object value, ValidationContext context)
{
if (context.ObjectType.BaseType == typeof(AddressModel))
{
PropertyInfo property = context.ObjectType.BaseType.GetProperty(_propertyName);
// this is the line i'm having trouble with:
bool isRequired = (bool)property.GetValue(context.ObjectType.BaseType);
return base.IsValid(value, context);
}
return ValidationResult.Success;
}
```
I don't know what I'm meant to pass into the `GetValue` as it is expecting an object but everything I pass in gives me a **property type does not match target** exception
I'm having to go to the base type as I am trying to get the value of a property from an inherited class and `context.ObjectInstance` doesn't include the necessary properties
|
2014/02/07
|
[
"https://Stackoverflow.com/questions/21629167",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1790982/"
] |
You can simply cast your object as the `AddressModel` and use it like that.
```
protected override ValidationResult IsValid(object value, ValidationContext context)
{
var addressModel = context.ObjectInstance as AddressModel
if (addressModel != null)
{
// Access addressModel.PROPERTY here
return base.IsValid(value, context);
}
return ValidationResult.Success;
}
```
`context.ObjectInstance` is of `object` type instead of your model's type because the validation framework wasn't created to explicitly validate your model, but it is the right object instance. Once it's casted you can use it normally.
As a side note, the reason why you were getting an error with `property.GetValue(context.ObjectType.BaseType)` is because the `GetValue` method expects the instance of the object whose property you are calling.
|
12,277,841 |
Question:
We have a portal, where the doctype is compatible to xhtml 1.0.
Then, in the portal, we have a content iframe, where we embed different web-applications.
Some of those application were written by us, some are 3rd party.
Now in that iframe, we embed, amongst other things, Microsoft Reporting Service reports.
The problem is, Reporting Service Reports requires QuirksMode to render "correctly".
And the portal doesn't work in QuirksMode (which is fine, as far as I am concerned, since we only target 9, and possibly IE8). The portal also doesn't render fine in IE7, and we're going to abandon IE8 support as soon as possible.
However, IE9 seems to inherit the document mode from the parent page, so the reporting service reports gets rendered in IE9 standards mode instead of quirks mode.
So all the reports are displayed incorrectly (and i don't mean a little bit, it's really severe, completely incorrect, absolutely horrible)
The problem is, we can't change reporting service...
There's no way to make reporting service (any version) render non-quirksmode HTML.
~~As per [Will an iframe render in quirks mode?](https://stackoverflow.com/questions/3717932/will-an-iframe-render-in-quirks-mode)
i could add~~
```
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7">
<meta http-equiv="X-UA-Compatible" content="IE=8" />
```
~~To get the iframe to render in QuirksMode.~~ (edit: doesn't even work when I don't care about how the portal renders and put it in anyway)
Unfortunately, the portal is as said, not IE7 compatible, so this is not an option.
Also, the SSRS reports runs on another domain than the portal, so I can't use JavaScript/jQuery in any way.
Is there any way to make an iframe render in QuirksMode, without destroying the parent page layout ?
Or a (already existing) way to make reporting service render valid HTML (I certainly don't have the time to write a custom HTML rendering extension) ?
|
2012/09/05
|
[
"https://Stackoverflow.com/questions/12277841",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/155077/"
] |
Via [MSDN](http://msdn.microsoft.com/en-us/library/gg558056%28v=VS.85%29.aspx):
>
> Although the newer rendering engine is only used when Windows® Internet Explorer® detects that an HTML page has requested the highest level of support for standards, the same is not always true for child pages that might be loaded within frame and iframe elements. Because **only one rendering engine can be active at a time**, IE9 Mode also includes emulation for Quirks Mode.
>
>
>
Sorry, but what you want to do is impossible to achieve in IE9.
|
70,949,500 |
I have a table below.
[](https://i.stack.imgur.com/Iol7a.png)
The Check column has a formula: `=IF(AND(COUNTIF([Item],[@Item])=2,[Type]="123"),1,0)`.
What it does is if there are duplicates in the Item column, AND if the Type column is 123, it returns 1, else 0.
I want to extract values from the Price column. However sometimes data has duplicates, and I want to get a value with Type=123 (the Red rectangle).
I created the Check column to flag which row to select, and I tried to add it as a condition.
But I do not want to use Power Query for this, and use only formulas.
How do I solve this?
|
2022/02/02
|
[
"https://Stackoverflow.com/questions/70949500",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8666758/"
] |
It looks like you are using a message queue, so there must be a documented async way of doing this, but you may try something like the following:
```py
exit_path = None
while exit_path is None:
try:
exit_path = zmq._GET_DATA_()
except AttributeError:
exit_path = None
sleep(1)
```
This should check once every second to see if the data is available.
|
33,094,095 |
I am tring to insert data in a table.
trying like this but it`s not working.
```
$sql = $queryBuilder->insert(' HRMS_candidateEducation', [
'HRMS_candidateEducationCandidateID' => $candidateID,
'HRMS_candidateEducationDegree' => $data['Degree'.$i],
'HRMS_candidateEducationUniversity' => $data['University'.$i],
'HRMS_candidateEducationCollege' => $data['College'.$i],
'HRMS_candidateEducationYear' => $data['Specilization'.$i],
'HRMS_candidateEducationSpecilization' => $data['Specilization'.$i],
], $params);
```
What is incorrect?
using
```
use yii\db\QueryBuilder;
use app\models\CandidateEducation;
```
|
2015/10/13
|
[
"https://Stackoverflow.com/questions/33094095",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3349666/"
] |
This function seem only create the SQL statement [see doc](http://www.yiiframework.com/doc-2.0/yii-db-command.html#insert%28%29-detail)
>
> insert() Creates an INSERT command
>
>
>
for executing the command i think you shoul try this way
```
Yii::$app->db->createCommand()->
insert(' HRMS_candidateEducation', [
'HRMS_candidateEducationCandidateID' => $candidateID,
'HRMS_candidateEducationDegree' => $data['Degree'.$i],
'HRMS_candidateEducationUniversity' => $data['University'.$i],
'HRMS_candidateEducationCollege' => $data['College'.$i],
'HRMS_candidateEducationYear' => $data['Specilization'.$i],
'HRMS_candidateEducationSpecilization' => $data['Specilization'.$i],
], $params)->
execute();
```
|
41,787,521 |
I am using cshtml as view
this is my input:
```
@Html.TextArea("DESCRIPTION", null, new { @class = "field-longtext", @cols = 100, @rows = 5, maxlength = 255 })
@Html.TextBox("DOC_TYPE", null, new { @class = "field-longtext", maxlength = 10 })
@Html.TextBox("DOC_FILE", null, new { @class = "field-longtext", @type = "file" })
```
and using ajax post
```
function UploadFile() {
var url = '@Url.Action("CreateUploadFile")';
var data = {};
var result = false;
$('#@ViewBag.FormName').find('input, textarea').each(function () {
data[$(this).attr('name')] = $(this).val();
});
data.PROBLEM_CALL_ID = @Model.Model.PROBLEM_CALL_ID;
$.ajax({
type: 'POST',
url: url,
data: data,
async: false,
success: function (data) {
if (data.result) {
var selectedRow = SubFormService.tableList['#@ViewBag.TableName'].selectedRow;
result = true;
} else {
alert(data.errorMsg);
result = false;
}
}
});
return result;
}
```
My Controller:
```
[HttpPost]
public ActionResult CreateUploadFile(Models.Shared.DocumentModel vm)
{
var id = -1;
var result = string.Empty;
var json = new BasicJsonResult();
var file = vm.DOC_FILE;
LogUtility.Debug(file.ContentLength.ToString());
if (file != null && file.ContentLength > 0)
{
var fileName = Path.GetFileName(file.FileName);
LogUtility.Debug(fileName);
LogUtility.Debug(Server.MapPath("~/Images/"));
var path = Path.Combine(Server.MapPath("~/Images/"), fileName);
file.SaveAs(path);
}
return Json(json, JsonRequestBehavior.AllowGet);
}
```
the code `var file = vm.DOC_FILE;` warns me (Object reference not set to an instance of an object.), but I can get another control value (`vm.DESCRIPTION, vm.DOC_TYPE`).
Please help.
Also, I want to download file when that file is uploaded.
|
2017/01/22
|
[
"https://Stackoverflow.com/questions/41787521",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7073415/"
] |
With the introduction of XHR2 it is now possible to upload files using AJAX. You could use [`FormData`](https://developer.mozilla.org/en-US/docs/Web/API/FormData) to achieve this. Assuming that your input elements are inside a `<form>` you may try this (also include in this form a hidden input for the `PROBLEM_CALL_ID` field so that it gets sent to the server):
```
function UploadFile() {
var url = '@Url.Action("CreateUploadFile")';
var formData = new FormData($('form')[0]);
var result = false;
$.ajax({
type: 'POST',
url: url,
data: formData,
async: false,
success: function (data) {
...
}
});
return result;
}
```
So just make sure that you have wrapped your input elements inside a form tag (preferably with an id so that you can more specifically select it):
```
<form id="myForm">
@Html.TextArea("DESCRIPTION", null, new { @class = "field-longtext", @cols = 100, @rows = 5, maxlength = 255 })
@Html.TextBox("DOC_TYPE", null, new { @class = "field-longtext", maxlength = 10 })
@Html.TextBox("DOC_FILE", null, new { @class = "field-longtext", @type = "file" })
@Html.HiddenFor(x => x.PROBLEM_CALL_ID)
</form>
```
and then select the form like this:
```
var formData = new FormData($('#myForm')[0]);
```
Also please, please, please don't do that:
```
async: false
```
By doing this you are defeating the whole purpose of an asynchronous call to the server. If you set this flag the browser will freeze during the file upload which is an absolutely horrible user experience. If you do this, then you'd better use a normal HTML form submit to upload the file - you are loosing all the benefits of AJAX and there's no point to be making an AJAX request with this flag set to true.
|
4,123,308 |
In the models.py of django/django/contrib/auth the username is length is changed to 64 fields instead of 30 and the username in database has varchar(64).But it doesnt allow to login with a long username like [email protected]
how can this be fixed
```
class User(models.Model):
"""
Users within the Django authentication system are represented by this model.
Username and password are required. Other fields are optional.
"""
username = models.CharField(_('username'), max_length=64, unique=True, help_text=_("Required. 64 characters or fewer. Letters, numbers and @/./+/-/_ characters"))
```
|
2010/11/08
|
[
"https://Stackoverflow.com/questions/4123308",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/221149/"
] |
I would recommend that you not monkey patch Django, but instead create your own authentication backend. You can then validate against a user's email like in this example: <http://djangosnippets.org/snippets/1845/>
|
12,919,125 |
I've got a big element, that includes SVG embed element (external file). I'd like to change its fill colour on a:hover. How would you approach it? It really drives me crazy :)
What I thought should work is:
```
$("a#title").hover(function() {
$("svg#logo").attr('fill','#f0f');
});
```
|
2012/10/16
|
[
"https://Stackoverflow.com/questions/12919125",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1233971/"
] |
Your compiler just tried to compile the file named `foo.cc`. Upon hitting line number `line`, the compiler finds:
```
#include "bar"
```
or
```
#include <bar>
```
The compiler then tries to find that file. For this, it uses a set of directories to look into, but within this set, there is no file `bar`. For an explanation of the difference between the versions of the include statement look [here](https://stackoverflow.com/questions/21593/what-is-the-difference-between-include-filename-and-include-filename).
How to tell the compiler where to find it
-----------------------------------------
`g++` has an option `-I`. It lets you add include search paths to the command line. Imagine that your file `bar` is in a folder named `frobnicate`, relative to `foo.cc` (assume you are compiling from the directory where `foo.cc` is located):
```
g++ -Ifrobnicate foo.cc
```
You can add more include-paths; each you give is relative to the current directory. Microsoft's compiler has a correlating option `/I` that works in the same way, or in Visual Studio, the folders can be set in the Property Pages of the Project, under Configuration Properties->C/C++->General->Additional Include Directories.
Now imagine you have multiple version of `bar` in different folders, given:
---
```
// A/bar
#include<string>
std::string which() { return "A/bar"; }
```
---
```
// B/bar
#include<string>
std::string which() { return "B/bar"; }
```
---
```
// C/bar
#include<string>
std::string which() { return "C/bar"; }
```
---
```
// foo.cc
#include "bar"
#include <iostream>
int main () {
std::cout << which() << std::endl;
}
```
---
The priority with `#include "bar"` is leftmost:
```
$ g++ -IA -IB -IC foo.cc
$ ./a.out
A/bar
```
As you see, when the compiler started looking through `A/`, `B/` and `C/`, it stopped at the first or leftmost hit.
This is true of both forms, `include <>` and `incude ""`.
Difference between `#include <bar>` and `#include "bar"`
--------------------------------------------------------
Usually, the `#include <xxx>` makes it look into system folders first, the `#include "xxx"` makes it look into the current or custom folders first.
E.g.:
Imagine you have the following files in your project folder:
```
list
main.cc
```
with `main.cc`:
```
#include "list"
....
```
For this, your compiler will `#include` the file `list` in your project folder, because it currently compiles `main.cc` and there is that file `list` in the current folder.
But with `main.cc`:
```
#include <list>
....
```
and then `g++ main.cc`, your compiler will look into the system folders first, and because `<list>` is a standard header, it will `#include` the file named `list` that comes with your C++ platform as part of the standard library.
This is all a bit simplified, but should give you the basic idea.
Details on `<>`/`""`-priorities and `-I`
----------------------------------------
According to the [gcc-documentation](http://gcc.gnu.org/onlinedocs/cpp/Search-Path.html), the priority for `include <>` is, on a "normal Unix system", as follows:
```
/usr/local/include
libdir/gcc/target/version/include
/usr/target/include
/usr/include
```
>
> For C++ programs, it will also look in /usr/include/c++/version, first. In the above, target is the canonical name of the system GCC was configured to compile code for; [...].
>
>
>
The documentation also states:
>
> You can add to this list with the -Idir command line option. All the directories named by -I are searched, in left-to-right order, **before the default directories**. The only exception is when dir is already searched by default. In this case, the option is ignored and the search order for system directories remains unchanged.
>
>
>
To continue our `#include<list> / #include"list"` example (same code):
```
g++ -I. main.cc
```
and
```
#include<list>
int main () { std::list<int> l; }
```
and indeed, the `-I.` prioritizes the folder `.` over the system includes and we get a compiler error.
|
11,697,928 |
In tutrorials for Connecting to MySQL with PHP you see something similar to the below.
```
$pdo = new PDO('mysql:host=localhost;dbname=mydb', 'myuser','mypassword');
```
I have a connection working this way on my localhost but for putting it live what do you do about the password? Do you just leave it as plain text like that in your php file? Or is there a more secure way to handle this?
|
2012/07/28
|
[
"https://Stackoverflow.com/questions/11697928",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/737114/"
] |
Nobody can see your connection string if they look at the source, it can only be seen by looking at your raw code. I would also have it inside a separate file, and include the file on your page. This also helps if you need to change the password, as you won't have to edit every page that uses a connection - you'll only need to edit the one file.
Alternatively, you can have a connection string in an include file and place it outside of document root. This stops people getting to this file using a browser or if they attack your FTP. This will ***help*** security of your plain-text passwords, but is still accessible if somebody gets/has access to your local directories. To do this, you may need to configure a PHP configuration variable, `open_basedir`, which allows your script to talk to a file outside of root. This all depends on if you have access to a folder behind root of course, *and* if you can change that configuration variable.
Other than that, there's not much that can be done.
**Include File Example:**
Create a file called `conn.php` and store your connection in there.
```
$dbConn = mysql_connect($host, $user, $pass);
mysql_select_db("dbName", $dbConn);
```
On the page that needs the connection, include the conn.php file like so:
```
<?php
include("conn.php");
if (!dbConn) {
die('Sorry, our database did not load. Please try again later.');
exit();
}
$result = mysql_query("...");
?>
```
|
286,270 |
What is the best way to password protect quicktime streaming videos using php/.htaccess. They are being streamed using rtsp, but I can use other formats if necessary.
I know how to do authentication with php, but I'm not sure how to setup authentication so that will protect the streaming files urls so that a user can't just copy the url and share it.
Or am I overthinking this and I can just use a normal authentication scheme and place the files in a protected directory?
|
2008/11/13
|
[
"https://Stackoverflow.com/questions/286270",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
Both nginx and lighttpd web servers have X-Send-File headers you can return from PHP. So you can do your checks in PHP and then conditionally server out the file.
```
if (check_user_can_access()){
header('X-sendfile: /path/to/file');
} else {
header('HTTP/1.1 403 Fail!');
}
```
Lighttpd also has a neat module called [mod\_secure\_download](http://redmine.lighttpd.net/wiki/lighttpd/Docs#mod_secure_download) that allows you to programatically generate a URL that will only be valid for a short time period.
Nginx, and possibly lighttpd, allow you to cap the download speed, so you're not sending out streaming data faster than it can be consumed.
Either way, you want to use your web server for serving files. Serving them through PHP is possible, but slow.
|
40,109,295 |
I've used this exact code on a different div element and it works perfectly. When I went to add the same code to another div element with a different id it registers the element has been clicked but it doesn't add or remove any of the classes.
```
$('#quoteClick').click(function(){
$('#cbox-1').addClass('displayCboxBackground');
$('#cbox-2').removeClass('displayCboxBackground');
$('#cbox-3').removeClass('displayCboxBackground');
$('#dbox-1').addClass('displayBlock');
$('#dbox-2').removeClass('displayBlock');
$('#dbox-3').removeClass('displayBlock');
console.log("clicked");
});
```
The html structure is as follows:
```
<div id="cbox-1">
<div id="dbox-1">
content...
</div>
</div>
<div id="cbox-2">
<div id="dbox-2">
content...
</div>
</div>
<div id="cbox-3">
<div id="dbox-3">
<div id="quoteClick">
a quote
</div>
</div>
</div>
```
JSFiddle: <https://jsfiddle.net/m81c23cx/1/>
In the fiddle you can see the content will changes when each header is clicked. When the "quoteClick" element is clicked I want it to change to the second headers content exactly how it does when the second header is clicked.
I can see in Chrome's console that when I click the div element that it highlights all the classes but it doesn't change any of them. I have the jQuery inside a `document.ready()` function so it should be waiting for the DOM to load and it works perfectly when I just write the lines into the console.
|
2016/10/18
|
[
"https://Stackoverflow.com/questions/40109295",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6175966/"
] |
I'm surprised that nobody actually questioned your use of ids (instead of suggesting that you should double-check for dupes). The reason why this code is hard to debug is because it's too complicated. As a result, you'll have a hard time fixing issues similar to this in the future too.
Drop it, do it better.
I didn't even go through your fiddle. Instead, I'm going to propose that you change your approach altogether.
Update your HTML and use classes instead of ids. Something similar to this:
```
<div class="cbox">
<div class="dbox">
content...
</div>
</div>
<div class="cbox">
<div class="dbox">
content...
</div>
</div>
<div class="cbox">
<div class="dbox">
<div id="quoteAdvert">
a quote
</div>
</div>
</div>
```
Update your JavaScript and use `this` to get the context of the current box:
```
$('.cbox').click( function cboxClicked () {
// Remove the previous class from all .cbox & .dbox elements; we don't care which
$('.cbox').removeClass('displayCboxBackground')
$('.dbox').removeClass('displayBlock')
// Add a new class to the clicked .cbox & it's child .dbox
$(this).addClass('displayCboxBackground')
$(this).children('.dbox').addClass('displayBlock')
})
```
The beauty of this? You can have 1000 boxes, it'll still work. No need to add any extra lines of code.
Here's a [fiddle](https://jsfiddle.net/dx6rsvsL/1/) showing it in action.
|
8,591,004 |
What is the difference between an IPA file and an .xcarchive?
Which one do I have to create to upload an app using Xcode's Application Loader?
|
2011/12/21
|
[
"https://Stackoverflow.com/questions/8591004",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/977121/"
] |
*Difference between IPA and .xcarchive:*
IPA is a zipped up Payload folder which has YourApp.app bundle. .app contains all your application resources like images, plist files, compressed nibs and the executable, CodeSigning resources,etc.
xcarchive contains your app and dsym files. .DSYM is required to desymbolicate your crash logs. Right click on saved .xcarchive and select show package contents to see what it contains.
|
48,793,389 |
I am trying to compress an uploaded image using imagefromjpeg but I get this error:
```
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 24000 bytes)
```
The image is only 13215317 bytes big - why do I keep getting this error? I can not ramp up the memory for the server myself - so is there a way to compress without loading the entire image at once?
```
$image = imagecreatefromjpeg('../../uploads/DSC_0230.jpg');
imagejpeg($image, '../../uploads/DSC_0230.jpg.new', 0.8);
imagedestroy($image);
```
|
2018/02/14
|
[
"https://Stackoverflow.com/questions/48793389",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6228450/"
] |
It is certainly possible, but your code has inter-related dependencies. Setting the `url` property looks up `self.subdomain`, which calls the `subdomain` property which in turn looks up the value of `self.__subdomain` - which doesn't exist yet.
You should at least set `self.subdomain` first. However, you should reconsider having getters and setters for `subdomain` at all; just set the an attribute directly. Either way, you should avoid the double-underscore prefix, since this does name mangling and leads to behaviour you may not expect; if you must set a hidden attribute, use a single underscore prefix.
|
6,440,940 |
I had some problem formulating the question in the title, but i hope you get me with a bit of example code.
Basically:
In a objectoriented project i want to access an object that is defined in the "parent" object.
consider this snippet:
```
class Bar
{
public $var;
public function Bar()
{
$this->var = 'value';
}
}
class Bogus
{
public function Bogus()
{
//Here i want to access the methods and vars of obj1 in the "parent" object
}
}
class Foo
{
public $obj1,$obj2;
function Foo()
{
$this->obj1 = new Bar();
$this->obj2 = new Bogus();
}
}
```
as you can see the "child" object are not really childs in the sense that they extend the "parent" class but only objects instanciated inside an object.
is there any "oh damn thats cool" kinda way to do this or do i have to pass the objects to eachother
like:
```
$this->obj2 = new Bogus($this->obj1);
```
or make use of global object, instanciating objects outside the class:
```
global $bar,$bogus;
class Foo
{
public $obj1,$obj2;
function Foo()
{
global $bar,$bogus;
$this->obj1 = $bar = new Bar();
$this->obj2 = $bogus = new Bogus();
}
}
```
I hope you can understand what im getting at ;)
|
2011/06/22
|
[
"https://Stackoverflow.com/questions/6440940",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/715239/"
] |
I think you might want to use a [Singleton Pattern](http://en.wikipedia.org/wiki/Singleton_pattern) ([Creating the Singleton design pattern in PHP5](https://stackoverflow.com/questions/203336/creating-the-singleton-design-pattern-in-php5)).
Although you also might want to do a little more research on [design patterns](http://en.wikipedia.org/wiki/Design_pattern_%28computer_science%29) in general, specifically you might want to take a look at [Is there a use-case for singletons with database access in PHP?](https://stackoverflow.com/questions/4595964/who-needs-singletons/4596323#4596323)
|
5,819,946 |
I had a lot of testcases running on the class MyClass, using it's default constructor: MyClass().
Now the requirements of MyClass changed and the user can provide a HashMap to indicate some pairs . Now a MyClass needs to have at least one pair and throws exceptions if one of those is null.
I was hoping to create another default constructor to avoid having to rewrite all the test methods something like:
```
public MyClass() {
HashMap<KeyClass, ValueClass> hashMap = HashMap<KeyClass, ValueClass>();
hashMap.put(KeyClass.someValue, new ValueClass());
this(hashMap);
}
```
Now this doesn't work, because i have to call the other constructor first, so i thought of writing some method
```
private static HashMap<KeyClass, ValueClass> getDefaultHashmap();
```
and using it to call the other constructor like this:
```
public MyClass() {
this(MyClass.getDefaultHashmap());
}
```
But this seemed to me as not really good style, so i was hoping you could tell me what the right way to do something like this is!
|
2011/04/28
|
[
"https://Stackoverflow.com/questions/5819946",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/253387/"
] |
You could inline the HashMap creation:
```
public MyClass() {
this(new HashMap<KeyClass, ValueClass>() {{
put(KeyClass.someValue, new ValueClass());
}});
}
```
But you'd have to ignore the serial-id warning to keep it "pretty".
|
50,646,387 |
I'm testing the compatibility of two products (A) and (B) within a TestAutomation project. The test verifies that product (B), which is actually the product under test, can be installed eventhough (A) is already installed --> to do so, the installer of (B) looks up if the [UpgradeCode](https://msdn.microsoft.com/en-us/library/windows/desktop/aa372375(v=vs.85).aspx) of (A) is present.
**NOTE: I already know the UpgradeCode of (A). What I'm trying to do is to write it into the table that will be looked-up upon installing (B), WITHOUT actually installing the MSI of (A)** - this is kind of like a "mock" in integration-testing.
The test is running on a VM where (A) is not already installed by default. My goal would be to write a script which would allow me to skip the "real" installation of (A).
QUESTIONS:
1. I'm not sure of where it looks the UpgradeCode up. It is **NOT** looking it up in the registries (I aready tried that hack). I have found the UpgradeCode within the Win32\_Property table... is that the right place to look into?
2. My guess is that I have to emulate the API-call, with which the original MSI from (A) sets its UpgradeCode... any idea of how that works? Possibly with a Powershell script. I have seen online people modifying the WMI properties tables can with calls to [gwmi](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.management/get-wmiobject?view=powershell-5.1) (then using put) or [swmi](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.management/set-wmiinstance?view=powershell-5.1), but all my attempts so far failed.
NOTES:
* I do not really know my way around with the Windows Installer nor with PowerShell... this is not at all what I usually do. An answer in Layman terms would be much appreciated.
* I know that there are other ways around this (e.g. a dedicated VM or performing a "real" installation of (A)), but I'd like to know how to achieve this programmatically.
* Why I need to do that? It's an automated test that only concerns the installer of (B). I do not want the success of my test to be depending from (A)'s successfull download or installation.
|
2018/06/01
|
[
"https://Stackoverflow.com/questions/50646387",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1469932/"
] |
The easiest way to do a test without installing the actual A would be to produce a small MSI with the same UpgradeCode and ProductCode and install it. I can't see why you want to "fake" it when you can just do the real thing.
If you want to prevent the install of B when A is already installed you could add A's UpgradeCode to B with OnlyDetect=yes, that will set a property that can be used to prevent B from being installed. It's not clear what the context is for not installing B, whether you have external launchers, a bootstrapper, or which tool is being used to generate the MSI (because some tools will give you help if you want to skip B if A is installed with their built-in detection features).
|
18,343,801 |
**BUG: I used cell-arrays in the underlying functions, bad!**
I cannot understand why restarting Matlab result sometimes into more verbose error messages that help me to actually solve problems. Now I am trying to find a command that makes Matlab showing as much information as possible. For example the below index-exceed-dimension error is totally useless with my recursive algorithm -- this is the specific algorithm where Matlab have once revealed the specific line but now for some reason only telling the vacuously the name of the algorithm
```
Index exceeds matrix dimensions.
Error in Dij (line 65)
Dij_=Dij(ii,jj,[II,k],[r,q_(k)]);
```
where you can see that I am running the algorithm Dij failing on the line running the algorithm Dij again.
**How can I get more information about the error? Or how can I get inside any point in the recursive algorithm? -Linebreak and trying to get inside that point just fires the error.**
|
2013/08/20
|
[
"https://Stackoverflow.com/questions/18343801",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/164148/"
] |
try the below function
```
function register_my_menus() {
register_nav_menus(
array(
'Slider' => __( 'Under Slider Navigation' ),
)
);
}
add_action( 'init', 'register_my_menus' );
<?php wp_nav_menu( array( 'theme_location' => 'Slider' ) ); ?>
```
`register_nav_menus` must be in array
|
38,318,252 |
Suppose I have the following struct
```
struct Being{
int canFly;
int (*printFlying)();
}
```
And I want to do something like the following:
```
int main(){
struct Being * flyingThing = new_flyingThing();
struct Being * thingThatCantFly = new_Thing();
flyingThing->printFlying(); /* "I'm flying!" */
thingThatCantFly->printFlying(); /* "I can't fly!" */
}
```
It looks like I would need the `printFlying`function to be able to access the `canFly` variable in the struct, but I don't know how to do this, or if this is possible.
Is there any way to get my code to do what I want? Thanks!!
---
I explained in the comments why this question is not a duplicate of the linked one.
|
2016/07/12
|
[
"https://Stackoverflow.com/questions/38318252",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6366047/"
] |
C isn't an object-oriented language, so there's no automatic way for a function member to know which structure was used to call it.
Since each structure has its own function pointer, you can get the result you want by having them refer to different functions, which print the appropriate message, instead of getting it from the `can_fly` member.
```
int print_flying_thing() {
printf("I'm flying!\n");
}
struct Being *new_flyingThing() {
struct Being *thing = malloc(sizeof(struct Being));
thing->can_fly = 1;
thing->printFlying = print_flying_thing;
return thing;
}
int print_nonflying_thing() {
printf("I can't fly!\n");
}
struct Being *new_Thing() {
struct Being *thing = malloc(sizeof(struct Being));
thing->can_fly = 0;
thing->printFlying = print_nonflying_thing;
return thing;
}
```
|
311,366 |
As I understand it, when you define a column on a table you define its precision. This precision takes 1 byte and is stored at the column level. If you use a precision of 5 or more, then a DateTime2 column will take 8 bytes per row. (The precision is not stored at the row level.)
But when you convert that same DateTime2 as a VarBinary, it will take 9 bytes. That is because it needs the precision byte that is stored at the column level.
I am curious how this relates to when a DateTime2 is stored in memory. Say I have 1,000,000 DateTime2s in memory (each with a precision of 5 or more). Will that take up 8,000,000 bytes of memory, or 9,000,000 bytes of memory?
**Basically, I would like to know if a default precision DateTime2 will cause more pressure on Page Life Expectancy than a normal DateTime?**
|
2022/04/26
|
[
"https://dba.stackexchange.com/questions/311366",
"https://dba.stackexchange.com",
"https://dba.stackexchange.com/users/6383/"
] |
A default precision DATETIME2 will not cause more pressure on PLE compared to DATETIME. The buffer pool consists of 8-KB pages. The page count is what matters as opposed to the internal storage workings of each page. It isn't really correct to say that 1 million column values will take 8 million or 9 million bytes. Quoting from the [documentation](https://learn.microsoft.com/en-us/sql/database-engine/configure-windows/buffer-pool-extension?view=sql-server-ver15#concepts):
>
> Buffer
>
>
> In SQL Server, A buffer is an 8-KB page in memory, the same
> size as a data or index page. Thus, the buffer cache is divided into
> 8-KB pages. A page remains in the buffer cache until the buffer
> manager needs the buffer area to read in more data. Data is written
> back to disk only if it is modified. These in-memory modified pages
> are known as dirty pages. A page is clean when it is equivalent to its
> database image on disk. Data in the buffer cache can be modified
> multiple times before being written back to disk.
>
>
> Buffer pool
>
>
> Also called buffer cache. The buffer pool is a global
> resource shared by all databases for their cached data pages. The
> maximum and minimum size of the buffer pool cache is determined during
> startup or when the instance of SQL server is dynamically reconfigured
> by using sp\_configure. This size determines the maximum number of
> pages that can be cached in the buffer pool at any time in the running
> instance.
>
>
>
|
57,117,855 |
conda update brakes everything.
conda env-solving took hours and forever
probably due to a conda optimization:
<https://www.anaconda.com/why-we-removed-the-free-channel-in-conda-4-7/>
but that breaks many systems (like mine):
<https://github.com/conda/conda/issues/8844>
got errors like
```
Collecting package metadata (current_repodata.json): - WARNING conda.models.version:get_matcher(531): Using .* with relational operator is superfluous and deprecated and will be removed in a future version of conda. Your spec was 1.*, but conda is ignoring the .* and treating it as 1
done
Solving environment: failed with current_repodata.json, will retry with next repodata source.
Initial quick solve with frozen env failed. Unfreezing env and trying again.
Solving environment: failed with current_repodata.json, will retry with next repodata source.
Collecting package metadata (repodata.json): done
```
so I downgraded to conda=4.6
but got
```
Collecting package metadata: / WARNING conda.core.index:push_record(193): Skipping conda-forge/label/broken/linux-64::ipywidgets-5.2.3-py36_0 due to InvalidSpec: ==1.*
WARNING conda.core.index:push_record(193): Skipping conda-forge/label/broken/linux-64::ipywidgets-5.2.3-py27_0 due to InvalidSpec: ==1.*
WARNING conda.core.index:push_record(193): Skipping conda-forge/label/broken/linux-64::ipywidgets-5.2.3-py35_0 due to InvalidSpec: ==1.*
done
Solving environment: failed
InvalidVersionSpec: Invalid version '==1.*': invalid operator with '.*'
```
and
```
conda install conda=4.7
Collecting package metadata: failed
CondaUpgradeError: This environment has previously been operated on by a conda version that's newer
than the conda currently being used. A newer version of conda is required.
target environment location: /home/aeug/conda
current conda version: 4.6.0
minimum conda version: 4.7
```
Is there anything to fix the system / envs again?
All I can see is to reinstall with an good old conda 4.6.11 `https://repo.anaconda.com/miniconda/`
---
```
conda install conda=4.6
conda config --set pip_interop_enabled True
```
and I could rebuild the env with some errors but it took ~6 hours.
|
2019/07/19
|
[
"https://Stackoverflow.com/questions/57117855",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7084278/"
] |
This solution helped my system, set a conda config parameter [conda docs](https://docs.conda.io/projects/conda/en/latest/user-guide/troubleshooting.html?highlight=allow_conda_downgrades)
```
conda config --set allow_conda_downgrades true
conda install conda=4.6.11
```
It works all right again.
|
191,750 |
I need to migrate some old MS Access data to a SQL Server Database. Which tool is easier for a newbie to work with: SQL Server Import/Export or Migration assistant for access(SSMA)
|
2017/11/26
|
[
"https://dba.stackexchange.com/questions/191750",
"https://dba.stackexchange.com",
"https://dba.stackexchange.com/users/131530/"
] |
I would use the SQL Server import wizard, but make sure to use staging tables to import the data from Access, so you can perform data cleansing before inserting on the definitive tables.
A staging table is a temporary table used to load the data "as is" in the destination system (SQL Server in your case) so you can make sure the datatypes, collation, any custom format is according to your needs. This is made to avoid key/constraint violations, errors due to incompatible datypes, etc...
So for this example, you can import your access tables and ask the wizard to create the new tables during the import, after your are ok with your data, you can insert them in your definitive tables.
|
14,341,752 |
My table Looks like this:
```
Date DataPoint Type Value
2000 HVAC Phase1 220
2000 HVAC Phase2 221
2000 SERVER Phase1 222
2000 SERVER Phase2 223
2001 HVAC Phase1 220
2001 HVAC Phase2 221
2001 SERVER Phase1 222
2001 SERVER Phase2 223
2002 HVAC Phase1 220
2002 HVAC Phase2 221
2002 SERVER Phase1 222
2002 SERVER Phase2 223
...
...
2013 HVAC Phase1 220
2013 HVAC Phase2 221
2013 SERVER Phase1 222
2013 SERVER Phase2 223
```
I want to get last date, data points,sum of Type values.
Expected result
```
Date DataPoint Value
2013 HVAC 441
2013 SERVER 445
```
How can I do this? Hint, starting point, code example?
Thanks...
|
2013/01/15
|
[
"https://Stackoverflow.com/questions/14341752",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1324756/"
] |
USE [`TOP... WITH TIES`](http://msdn.microsoft.com/en-us/library/ms189463.aspx) to simplify:
```
SELECT TOP 1 WITH TIES Date, DataPoint, SUM(Value) AS Value
FROM YourTable
GROUP BY Date, DataPoint
ORDER BY Date DESC
```
**[SQL Fiddle](http://sqlfiddle.com/#!3/fa600/1)**
|
10,911,362 |
Is there a way to check whether a file was correctly written, I mean if there is an EOF at the end?
I'm asking that because I have a program that takes some file, merge them in a very big file and then use it to get statistics from it.
The point is that the second part never ends because it doesn't recognize the end of file.
The relevant parts of the code are the following:
(please do not ask for the whole code as I cannot post for important reasons)
```
FileWriter file=null;
PrintWriter pw = null;
String pathToRead=null;
InputStreamReader isr = null;
BufferedReader br = null ;
FileInputStream fis = null ;
TestJFileChooser d=new TestJFileChooser();
int c=1;
String line=null;
....
//here i select the files
selectedFile=new File(pathToRead);
//here I get one buffer reader for each file got with listFiles()
for(File file_sel:app){
if (file_sel.getName().startsWith("gtou")){
System.out.println(file_sel.getName());
fis = null;
try {
fis = new FileInputStream(file_sel);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
isr=new InputStreamReader(fis);
br=new BufferedReader(isr);
map.put(i, br);
num_file++;
i++;
}
}
//then I select the output file and open a print writer for it
fileToWrite=new File(pathToRead);
try {
file = new FileWriter(fileToWrite);
pw= new PrintWriter(file);
} catch (IOException e1) {
e1.printStackTrace();
}
//merging part
....
line=br.readLine();
while(line!=null){
System.out.println("line is:"+line);
....
line=br.readLine();
}
//end of merging ....
pw.flush();
pw.close();
try {
if (file!=null) file.close();
fis.close();
isr.close();
br.close();
for(int fi=0;fi<num_file;fi++){
br2=map.get(fi);
br2.close();
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
so.kill();
Runtime r=Runtime.getRuntime();
r.gc();
//this is a popup that comes out
GlitchSquad gli=new GlitchSquad("Completed");
```
the problem is that as output I get:
```
line is: null ;
line is: null ;
line is: null ;
```
etc
And never get to "completed" popup =(
I cannot understand what is exactly that null because the control line!=null doesn't work.
I also tried to use that null as a string ..but nothing..
I thought that was a problem in how I close the streams but now the code seems correct to me ..but still no way to stop it..
Suggestion?
Thanks in advance!
p.s. it is a summarized version in order to focus on the streams.. variables are correctly declared and the same is for imports etc
edit: code updated
|
2012/06/06
|
[
"https://Stackoverflow.com/questions/10911362",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1083700/"
] |
In the customadapter's getview method, do
```
//use the actual id of your checkbox of course
Checkbox checkbox = (CheckBox)findViewById(R.id.checkbox);
checkbox.setFocusable(false);
checkbox.setFocusableInTouchMode(false);
```
now the checkbox is clickable as is the listitem.
|
40,462,633 |
So i have written :
```
create or replace package body schema_name.package_name
```
and as soon as i press compile, application removes schema name replacing it with white spaces like this :
```
create or replace package body package_name
```
Does anyone know how to get rid of this annoying behavior?
|
2016/11/07
|
[
"https://Stackoverflow.com/questions/40462633",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4849861/"
] |
It isn't SQL Developer doing that. If you create the package through SQL\*Plus and then query `dba_source` (or the all/user variants) you'll see the name has been removed, along with the `create or replace` text:
```
SQL> create or replace package my_schema.package_name as
2 end;
3 /
Package created.
SQL> select text from sys.dba_source
2 where type = 'PACKAGE' and owner = 'MY_SCHEMA' and name = 'PACKAGE_NAME'
3 order by line;
TEXT
--------------------------------------------------------------------------------
package package_name as
end;
2 rows selected.
```
The owner isn't part of the package source, it's stored separately in the data dictionary (`dba_objects.owner` etc.). The parser is removing the owner because it doesn't belong there, as part of the object that actually exists in the database. As pure, external source code it does (or may do anyway) and the version you have in source control can keep that if it's appropriate; but as part of the object defined in that schema it wouldn't mean anything.
You might also notice that if you try to create an object in another schema from the object viewer it tells you the module has been renamed and tries to reopen the object viewer.
It is interesting, though, that the owner name is substituted for spaces (including two for the double-quotes, if the schema name is quoted) rather than just being completely removed. And also interesting that SQL Developer's object viewer always puts the `create or replace` in - but also notice that it always includes the `or replace`, even if you originally didn't have that in your code. If it didn't then you wouldn't be able to recompile it, of course.
The `dbms_metadata.get_ddl` package re-adds the schema name by default, and quotes the identifiers; but also loses the extra whitespace in the process:
```
SQL> select dbms_metadata.get_ddl('PACKAGE', 'PACKAGE_NAME', 'MY_SCHEMA') from dual;
DBMS_METADATA.GET_DDL('PACKAGE','PACKAGE_NAME','MY_SCHEMA')
--------------------------------------------------------------------------------
CREATE OR REPLACE PACKAGE "MY_SCHEMA"."PACKAGE_NAME" as
end;
1 row selected.
```
There doesn't seem to be any way for SQL Developer's object view to show or re-add the schema name though.
|
42,263,562 |
Here is my JQL :
```
project = XXX AND issuetype = Bug AND status in (Open, 'In Progress', Reopened) and summary ~ '\\\\[A\\\\]'
```
JIRA return no result even I have tickets that contain the text "[A]" in the summary. It only doesn't work for "[A]", if i try with other letters, it works.
For example, the jql below works :
```
project = XXX AND issuetype = Bug AND status in (Open, 'In Progress', Reopened) and summary ~ '\\\\[B\\\\]'
```
|
2017/02/16
|
[
"https://Stackoverflow.com/questions/42263562",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2234931/"
] |
you need to return
```
Observable.just(arAllMedia)
```
|
55,386,202 |
I came across an article awhile back titled [Inspecting Docker Images without pulling them](https://ops.tips/blog/inspecting-docker-image-without-pull/) that gets into the nitty-gritty of the specific API calls needed to essentially do a `docker inspect` with REST calls. However, I'm wondering if perhaps something has changed with the Docker registry API since that article was written.
The article breaks down that you need to make three REST calls, in order, to get information about a container. In the case of the public Docker registry, they are as follows:
1. A GET request to auth.docker.io to get a token
```
curl "https://auth.docker.io/token?scope=repository:<image>:pull&service=registry.docker.io"
```
In this case `image` could be something like `nginx` or `docker` - basically whatever image you're looking up. This REST call returns a token to use in subsequent requests.
2. A GET request to retrieve the manifest listings
```
curl -H "Accept: application/vnd.docker.distribution.manifest.v2+json"
-H "Authorization: Bearer <token-from-step-1>"
"https://registry-1.docker.io/v2/<image>/manifests/<tag>"
```
Here `image` is the same as in Step 1, and `tag` could be something like `latest`. This call returns some JSON; the key is that we need to extract the value at `.config.digest`. This is the digest string that we use in the final request.
3. Finally a GET request to retrieve the container config, using the digest we received in step 2
```
curl -H "Accept: application/vnd.docker.distribution.manifest.v2+json"
-H "Authorization: Bearer <token-from-step-1>"
"https://registry-1.docker.io/v2/<image>/blobs/<digest-from-step-2>"
```
This returns some JSON, and the field I care about is `.config`
I was able to test this successfully on a private Docker registry, although there I had to do something different for auth. However I have the opposite problem when I try to follow along with the guide (which I've outlined in these steps above) for the public Docker registry: Step 1 gives me a token, but that token is worthless. Whenever I try to use it, in Steps 2 or 3, I get this back:
```
{"errors":[{"code":"UNAUTHORIZED","message":"authentication required","detail":[{"Type":"repository","Class":"","Name":"docker","Action":"pull"}]}]}
```
Any ideas on how to get this working?
|
2019/03/27
|
[
"https://Stackoverflow.com/questions/55386202",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5454/"
] |
Using the following steps you can retrieve the configuration of any public container-image.
1. Get the respective token for the image. Note that you **must specify the full name of the image** (official images use the `library` repository). Thereby, the [NGINX image](https://hub.docker.com/_/nginx) should be referred to as: `library/nginx`.
```
curl \
--silent \
"https://auth.docker.io/token?scope=repository:library/nginx:pull&service=registry.docker.io" \
| jq -r '.token'
```
>
> *Token shortened for brevity:* eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXV...
>
>
>
2. Retrieve the image digest from the manifest. For this request, you also need to specify a valid tag (this example uses the `latest` tag).
```
curl \
--silent \
--header "Accept: application/vnd.docker.distribution.manifest.v2+json" \
--header "Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXV..." \
"https://registry-1.docker.io/v2/library/nginx/manifests/latest" \
| jq -r '.config.digest'
```
>
> sha256:2bcb04bdb83f7c5dc30f0edaca1609a716bda1c7d2244d4f5fbbdfef33da366c
>
>
>
3. Finally, get the container configuration by using the following request. Within the URL, the digest from step two must be specified.
```
curl \
--silent \
--location \
--header "Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXV..." \
"https://registry-1.docker.io/v2/library/nginx/blobs/sha256:2bcb04bdb83f7c5dc30f0edaca1609a716bda1c7d2244d4f5fbbdfef33da366c" \
| jq -r '.container_config'
```
>
> *Output shortened for brevity:*
>
>
>
> ```
> {
> "Hostname": "6c02a05b3d09",
> "Env": [
> "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
> "NGINX_VERSION=1.15.10-1~stretch",
> "NJS_VERSION=1.15.10.0.3.0-1~stretch"
> ],
> "Labels": {
> "maintainer": "NGINX Docker Maintainers <[email protected]>"
> },
> "StopSignal": "SIGTERM"
> }
>
> ```
>
>
|
80,323 |
I have always been interested in putting up a website where people upload NDAs. They would be properly redacted if applicable and reviewed.
I have worked in software for a long time, in many positions, and the variety of NDA silliness is out of this world. I have always wanted to get these in the public domain, ideally associated with the parent company, to provide a forum for discussion on NDA abuse.
The succinct question is "Can this be done legally?".
I see an NDA as a pseudo-public document, something you need to read in detail before you acknowledge and opt-in to limit rights (discussion of topic/tech).
Mainly interested in USA.
|
2022/05/18
|
[
"https://law.stackexchange.com/questions/80323",
"https://law.stackexchange.com",
"https://law.stackexchange.com/users/44882/"
] |
The question reads:
>
> I see an NDA as a pseudo-public document, something you need to read in detail before you acknowledge and opt-in to limit rights (discussion of topic/tech).
>
>
>
Unfortunately for this view, the law normally sees an NDA as a private contract, except when it is alleged that it violates public policy. If an NDA explicitly or implicitly includes itself in the list of things not to be disclosed, then posting it would be a violation of the contract. In such a case the party posting the agreement would be subject to whatever consequence the agreement specifies for violation, unless that person had a valid defense. The operator of a web site where the document might be posted would not normally ne a party to the agreement, and so would not be liable for hosting it, unless some other limitation applies, beyond the NDA itself.
An NDA can indeed be a significant limitation on the signer's freedom to discuss certain topics, and a person would be wise to consider it in detail, and perhaps consult a lawyer, before signing one. But that does not mean that the person should post or distribute it publicly, nor that the person is automatically entitled to consult NDAs that others have signed. There are sufficient sample NDA forms available that a person can compare an offered NDA with other possibilities, and get an idea if an offered NDA goes beyond the usual terms.
|
43,643,795 |
According to [this link](https://developer.mozilla.org/en-US/docs/Tools/Responsive_Design_Mode), it should. But my Responsive Design Mode seems to be from before version 52, even though Firefox says it's version "53.0 (64-bit)"
|
2017/04/26
|
[
"https://Stackoverflow.com/questions/43643795",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7469817/"
] |
I had this problem and although the other answers were somewhat helpful, they didn't really solve this for me. After doing additional research, this is what I found what I had to do:
1. Open about:config in your address bar.
2. In the search bar, type browser.tabs.remote.autostart
3. Double-click on this to change the value to true. If it was already set to true, no need to make any changes.
4. Right-click anywhere on the list and from the drop-down menu, choose new -> boolean
5. Name this 'browser.tabs.remote.force-enable'
6. Set its value to true.
7. In the search bar, type accessibility.force\_disabled
8. If it is present and the value is 0, set it to 1.
9. Restart the browser
The device bar should now be present. Like so:
[](https://i.stack.imgur.com/ee0Mx.png)
Credit goes to this [page](http://techdows.com/2016/08/firefox-48-e10s-enabled-or-disabled-if-disabled-enable.html)
|
2,042,378 |
I'm currently taking a course in concurrent software design, and we're focusing a lot on modeling. I see the value in this, but I am not sure if the tool we are using is horrible, good, or somewhere in between, because I can't find any other examples. We're currently using LTS Analyzer, with some more information [here](http://www.doc.ic.ac.uk/~jnm/book/).
So my question is, for anyone who has done concurrent system design, do you model you application before implementing, and if so what tools do you use to do so? Thanks.
|
2010/01/11
|
[
"https://Stackoverflow.com/questions/2042378",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/68467/"
] |
Since tasklets are not queued but scheduled, i.e. several hardware interrupts posting the same tasklet might result in a single tasklet function invocation, you would be able to save *up to 90%* of the processing in extreme cases.
On the other hand there's already a high-priority soft IRQ for net-rx.
|
22,991,567 |
I am trying to get the Adj Close prices from Yahoo Finance into a DataFrame. I have all the stocks I want but I am not able to sort on date.
```
stocks = ['ORCL', 'TSLA', 'IBM','YELP', 'MSFT']
ls_key = 'Adj Close'
start = datetime(2014,1,1)
end = datetime(2014,3,28)
f = web.DataReader(stocks, 'yahoo',start,end)
cleanData = f.ix[ls_key]
dataFrame = pd.DataFrame(cleanData)
print dataFrame[:5]
```
I get the following result, which is almost perfect.
```
IBM MSFT ORCL TSLA YELP
Date
2014-01-02 184.52 36.88 37.61 150.10 67.92
2014-01-03 185.62 36.64 37.51 149.56 67.66
2014-01-06 184.99 35.86 37.36 147.00 71.72
2014-01-07 188.68 36.14 37.74 149.36 72.66
2014-01-08 186.95 35.49 37.61 151.28 78.42
```
However, the Date is not an Item. so when I run:
```
print dataFrame['Date']
```
I get the error:
```
KeyError: u'no item named Date'
```
Hope anyone can help me adding the Date.
|
2014/04/10
|
[
"https://Stackoverflow.com/questions/22991567",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1948338/"
] |
```
import pandas_datareader.data as web
import datetime
start = datetime.datetime(2013, 1, 1)
end = datetime.datetime(2016, 1, 27)
df = web.DataReader("GOOGL", 'yahoo', start, end)
dates =[]
for x in range(len(df)):
newdate = str(df.index[x])
newdate = newdate[0:10]
dates.append(newdate)
df['dates'] = dates
print df.head()
print df.tail()
```
|
16,826,510 |
G'day,
I'm having issues with PUT requests made via Chrome Postman to a controller, the PUT data is not present, POST data works fine.
I had performed a composer update prior to ensure that the latest version of vendor products where available and even removed bootstrap/compiled.php.
Is anybody else having similar issues?
The update function with both section\_id and data being empty in the response:
```
public function update($id)
{
$section_id = Input::get('section_id');
$data = Input::all();
return Response::json(array('id' => $id, 'section_id' => $section_id, 'data' => $data));
}
```
I've debugged the code all the way to ParameterBag.php and $this->request's parameter list is empty, I'm not sure what's supposed to contain any values but all through the code the input values are empty. Not sure what to do now, short of using post instead of put.
|
2013/05/30
|
[
"https://Stackoverflow.com/questions/16826510",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/683352/"
] |
PUT parameters don't work "out of the box" because PHP itself has some security restrictions around them. See: <http://www.php.net/manual/en/features.file-upload.put-method.php>
Laravel does implement a common workaround for this, though.
In Postman (or your form, or curl, or whatever client you're using), simply add a URL parameter name: "\_method" value: PUT
Example 1:
?\_method=PUT
Example 2:
<input type="hidden" name="\_method" value="PUT" />
Laravel uses the symfony Http Foundation which checks for the \_method variable and if it's present it routes based on its value, instead of the actual HTTP method used.
|
35,663,139 |
The Form:
```
<form class="col-md-4 col-sm-12 col-xs-12 pull-right banner-contact-form" onSubmit="return support_send();" id="contact_form" name="contact_form">
<div class="col-xs-12 text-center">
<h3>Application Form</h3>
</div>
<div class="form-group col-sm-4">
<select class="form-control input-md" id="title" name="title" required>
<option value="" selected hidden>Title</option>
<option value="1">Mr</option>
<option value="2">Mrs</option>
<option value="3">Miss</option>
<option value="4">Ms</option>
</select>
</div>
<div class="form-group col-sm-8">
<input type="text" class="form-control input-md" id="contact_name" placeholder="Your Full Name" name="contact_name" required>
</div>
<div class="form-group col-sm-12">
<input type="text" class="form-control input-md" id="post_code" placeholder="Postcode" name="post_code" required>
</div>
<div class="form-group col-sm-12">
<select class="form-control input-md" id="product" name="product" required>
<option value="" selected hidden>Main product interested in</option>
<option value="1">Washing Machines</option>
<option value="2">Washer Dryers</option>
<option value="3">Tumble Dryers</option>
<option value="4">Dishwashers</option>
</select>
</div>
<div class="form-group col-sm-12">
<input type="tel" class="form-control input-md" id="contact_telephone_number" placeholder="Contact Telephone Number" name="contact_telephone_number" required>
</div>
<div class="form-group col-sm-12">
<input type="email" class="form-control input-md" id="email" placeholder="Email Address" name="email">
</div>
<div class="col-xs-12">
<button type="submit" class="btn btn-default col-xs-12 btn btn-success"><span class="banner-contact-form-submit">Apply today</span><br><small>no obligation | fast response</small></button>
</div>
<div class="col-xs-12">
<p id="message_result" class="text-center"></p>
<p class="text-center"><span class="banner-contact-form-apr">68.9% APR</span> representative <br /> (64.9% APR existing customers)</p>
</div>
</form>
```
Ajax Handler:
```
function support_send(){
$.ajax( {
type: "POST",
url: "includes/contact_handler.php",
data: $('#contact_form').serialize(),
dataType: 'text',
success: function( response ) {
alert("It worked");
},
error: function(response) {
alert(response);
}
});
event.preventDefault()
};
```
Php Handler:
```
<?php
$name = addslashes($_POST['title'];)
$name = addslashes($_POST['contact_name'];)
$email = addslashes($_POST['email'];)
$telephone = addslashes($_POST['contact_telephone_number'];)
$post_code = addslashes($_POST['post_code'];)
$product = addslashes($_POST['product'];)
$from = 'From: Contact Us Form';
$to = '[email protected]';
$subject = 'New Contact Enquiry';
$body = "From: $name\n E-Mail: $email\n product:\n $product";
if (!empty($_POST)) {
if (mail ($to, $subject, $body, $from)) {
echo '<p>Your message has been sent!</p>';
} else {
echo '<p>Something went wrong, go back and try again!</p>';
}
}
?>
```
I am trying to submit a contact form via ajax which will then be emailed to the client, my issue here is that it keeps returning an error response of [object Object].
I believe the issue is that some of the fields in the form being submitted are objects but I cant figure out how to fix this issue.
Any help would be much appreciated.
Thanks.
|
2016/02/26
|
[
"https://Stackoverflow.com/questions/35663139",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5988405/"
] |
First of all, your function is only being run 10 times. You need to store the values you're generating, rather than printing them to the screen. You can do this by storing it in a list.
To get a list of 100 random variables, you could do `[random.uniform(num1, num2) for i in range(100)]`.
Then, you need to find the average of this. To get a total sum, you can do `sum(list)`. To get the number of values, do `len(list)`. If we combine this all together, we get:
```
import random
num1 = int(input("Input First number: "))
num2 = int(input("Input Second number: "))
random_numbers = [random.uniform(num1, num2) for i in range(100)]
print(sum(random_numbers)/len(random_numbers))
```
Output is:
```
>>> import random
>>> num1 = int(input("Input First number: "))
Input First number: 10
>>> num2 = int(input("Input Second number: "))
Input Second number: 20
>>> random_numbers = [random.uniform(num1, num2) for i in range(10)]
>>> random_numbers
[13.083389212287019, 12.551686149990369, 13.881302022239865, 12.5156539109837, 12.340949073439575, 13.693758114264867, 13.972147752101735, 14.111313446849902, 11.693700678679372, 18.136716333128035]
>>> print(sum(random_numbers)/len(random_numbers))
13.5980616694
```
|
59,586,577 |
I am trying to get and export an SSM parameter as an environment variable to an EC2 using the `UserData` section of Cloudformation.
The script is trying to append for e.g `export WHATS_HER_NAME=Sherlyn` to the `/etc/profile` file. But all i see in the `/etc/profile` is `export WHATS_HER_NAME=`. The value is not present. I use amazon linux 2 ami.
here is my cloudformation template.
```
{
"AWSTemplateFormatVersion": "2010-09-09",
"Resources": {
"Ec2Instance": {
"Type": "AWS::EC2::Instance",
"Properties": {
"IamInstanceProfile": {
"Ref": "Ec2instanceProfileTest"
},
"UserData": {
"Fn::Base64": {
"Fn::Join": [
"\n",
[
"#!/bin/bash -xe",
"yum update -y aws-cfn-bootstrap",
{
"Fn::Sub": "/opt/aws/bin/cfn-init -v --stack ${AWS::StackName} --resource Ec2Instance --configsets default --region ${AWS::Region}"
},
{
"Fn::Sub": "/opt/aws/bin/cfn-signal -e $? --stack ${AWS::StackName} --resource EC2Instance --region ${AWS::Region}"
},
{
"Fn::Sub": "echo \"export WHATS_HER_NAME=$(aws ssm get-parameter --name WhatsHerName --region ${AWS::Region} --query 'Parameter.Value')\" >> /etc/profile"
}
]
]
}
}
}
},
"GetSSMParameterPolicy": {
"Type": "AWS::IAM::Policy",
"Properties": {
"PolicyName": "GetSsmProperty",
"PolicyDocument": {
"Statement": [
{
"Effect": "Allow",
"Resource": "arn:aws:ssm:ap-southeast-2:012345678901:parameter/WhatsHerName",
"Action": [
"ssm:GetParameters",
"ssm:GetParameter"
]
},
{
"Effect": "Allow",
"Resource": "*",
"Action": [
"ssm:DescribeParameters"
]
}
]
},
"Roles": [
{
"Ref": "InstanceRole"
}
]
}
},
"InstanceRole": {
"Type": "AWS::IAM::Role",
"Properties": {
"AssumeRolePolicyDocument": {
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": [
"ec2.amazonaws.com"
]
},
"Action": [
"sts:AssumeRole"
]
}
]
},
"Path": "/"
}
},
"BasicParameter": {
"Type": "AWS::SSM::Parameter",
"Properties": {
"Name": "WhatsHerName",
"Type": "String",
"Value": "Sherlyn"
}
}
}
}
```
any help would be highly appreciated.
|
2020/01/03
|
[
"https://Stackoverflow.com/questions/59586577",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1448679/"
] |
I am not a fan of using JSON for CloudFormation templates so I cannot offer the solution in JSON, but here it is in YAML.
```
UserData:
Fn::Base64: !Sub
- |
#!/bin/bash -xe
yum update -y aws-cfn-bootstrap
/opt/aws/bin/cfn-init -v --stack ${AWS::StackName} --resource Ec2Instance --configsets default --region ${AWS::Region}
/opt/aws/bin/cfn-signal -e $? --stack ${AWS::StackName} --resource EC2Instance --region ${AWS::Region}
echo export WHATS_HER_NAME=${WhatsHerNameParameter} >> /etc/profile
- WhatsHerNameParameter: {{resolve:ssm:WhatsHerName:1}}
```
You can read more about [using AWS Systems Manager Parameter Store Secure String parameters in AWS CloudFormation templates](https://aws.amazon.com/blogs/mt/using-aws-systems-manager-parameter-store-secure-string-parameters-in-aws-cloudformation-templates/)
The snippet above is substituting *${AWS::StackName}* and *${AWS::Region}* and when it gets to *${WhatsHerNameParameter}* it checks for the SSM parameter and substitutes that into the UserData.
This mean that the UserData is complete before it gets to the EC2 instance.
|
18,806,175 |
Can anyone provide me the shader that are similar to the Fixed function Pipeline?
*I need the Fragment shader default the most, because I found a similar vertex shader online. But if you have a pair that should be fine!*
I want to use fixed pipeline, but have the flexability of shaders, so I need similar shaders so I'll be able to mimic the functionality of the fixed pipeline.
**Thank you very much!**
*I'm new here so if you need more information tell me:D*
This is what I would like to replicate: (texture unit 0)
* functionality of glTranslatef
* functionality of glColor4f
* functionality of glTexCoord2f
* functionality of glVertex2f
* functionality of glOrtho (I know it does some magic stuff behind the scenes with the shader)
Thats it. That is all the functionality I would like to replicate form the fixed function pipeline. Can anyone show me an example of how to replicate those things with shaders?
|
2013/09/14
|
[
"https://Stackoverflow.com/questions/18806175",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2780020/"
] |
You have a couple of issues here that will make implementing this using shaders more difficult.
First and foremost, in addition to using fixed-function features you are also using immediate mode. Before you can make the transition to shaders, you should switch to vertex arrays. You could write a class that takes immediate mode-like commands that would come between `glBegin (...)` and `glEnd (...)` and pushes them into a vertex array if you absolutely need to structure your software this way.
As for `glTranslatef (...)` and `glOrtho (...)` these are nothing particularly special. They create translation matrices and orthographic projection matrices and multiply the "current" matrix by this. It is unclear what language you are using, but one possible replacement for these functions could come from using a library like [`glm`](http://glm.g-truc.net/0.9.4/index.html) (C++).
The biggest obstacle will be getting rid of the "current" state mentality that comes with thinking in terms of the fixed-function pipeline. With shaders you have full control over just about every state, and you don't have to use functions that multiply the "current" matrix or set the "current" color. You can simply pass the exact matrix or color value that you need to your shader. This is an altogether better way of approaching these problems, and is why I honestly think you should ditch the fixed-function approach altogether instead of trying to emulate it.
This is why your desire to "use the fixed-function pipeline but have the flexibility of shaders" fundamentally makes very little sense.
Having said all that, in OpenGL compatibility mode, there are reserved words in GLSL that refer to many of the fixed-function constructs. These include things like `gl_MultiTexCoord<N>`, `gl_ModelViewProjectionMatrix`, etc. They can be used as a transitional aid, but really should not be relied upon in the long run.
|
69,265,150 |
I've just upgraded to Delphi 11 Alexandria from Delphi 10.4.2. I use RDP a lot so I noticed flicker when a TPaintBox is invalidated. The weird thing is that it doesn't flicker if the form with the TPaintBox is the first one created. Also it doesn't flicker if run on local machine. Only in RDP. If I compile same project in Delphi 10.4.2 it doesn't flicker in RDP.
Can anyone figure this one out? Is it "simply" a bug in Delphi 11?
Edit: Demoproject <http://procurisupdate.se/downloads/Temp/PaintBoxFlicker.zip>
Simple project with two forms. One has an TImage so it is quite large.
If run as is, when you click the picture and move the mouse it flickers. If you change so that Form23 is created first (or even if it is created before Application.run) it doesn't flicker. Note it onlyt flickers in RDP.
Edit2: After some looking I find the following in TApplication.Run:
```
procedure TApplication.Run;
begin
FRunning := True;
try
{$IF NOT DEFINED(CLR)}
AddExitProc(DoneApplication);
{$ENDIF}
RemoteSessionCheck; // This has been added since Delphi 10.4.2
if FMainForm <> nil then
...
```
If I comment out RemoteSessionCheck; and recompile (you have to add Your Source\vcl dir to Library path) it works with no flicker.
|
2021/09/21
|
[
"https://Stackoverflow.com/questions/69265150",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12491946/"
] |
You cannot have an `INTERVAL` literal of a variable amount; however, you can have a fixed `INTERVAL` literal and then multiply it by a bind variable:
```sql
SELECT TO_CHAR(
SYSDATE + :hourvalue * INTERVAL '1' HOUR,
'hh12:mi AM'
) AS TIME
FROM DUAL
```
If you want a negative amount then just specify a negative `:hourvalue` rather than using a separate `:operator` bind variable.
|
261,439 |
So, I'm writing a story. I have a part where I describe a family who has had a lot of misfortunes; the mother got killed, the father got sick, etc. I want to follow it up with a statement when another tragedy happens and I want a sentence it like this:
"The already [insert word] here family once again receives a visit from misfortune as..."
I think "unfortunate" just wouldn't cut it.
|
2015/07/22
|
[
"https://english.stackexchange.com/questions/261439",
"https://english.stackexchange.com",
"https://english.stackexchange.com/users/130079/"
] |
**Torment(ed)**
>
> noun |ˈtɔːmɛnt| [ mass noun ] severe physical or mental suffering:
> their deaths have left both families in torment.
>
>
>
(OED, via the Apple Dictionary App)
|
30,465,618 |
I'm using spring security 4.0.1 inside a spring boot 1.2.3 web application ( and also with spring-session 1.0.1, but this is irrelevant for the case ).
I do have a private area, and an all access area ( "/about", "/","/contact",... more than 20 pages ) for which every user can access. ( it's like a web-shop )
Whenever a **logged-in** user session expires,Spring detects an invalid session and redirects the user to the **'.invalidSessionUrl("/session/error/invalid")'**
However, i only want to be redirected if the target link in inside the private area, nor the public one.
How can i avoid that ?
Thanks.
This is my (java) config : ( **updated** after seen post )
```
http
.authorizeRequests()
.anyRequest()
.permitAll()
.antMatchers("/privado/**")
.authenticated()
.and()
.formLogin()
.loginPage("/login")
.failureUrl("/login?error")
.defaultSuccessUrl("/")
.successHandler(new SessionSuccessHandler())
.and()
.logout()
.logoutSuccessUrl("/")
.deleteCookies("JSESSIONID", "SESSION")
.and()
.sessionManagement()
.invalidSessionUrl("/session/error/invalid")
.sessionFixation()
.changeSessionId()
.maximumSessions(1)
.expiredUrl("/session/error/expired")
.and()
.and()
.csrf()
.ignoringAntMatchers("/jolokia/**", "/v1.0/**");
```
How can i achieve that ?
Thanks a lot.
|
2015/05/26
|
[
"https://Stackoverflow.com/questions/30465618",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/269830/"
] |
@RobWinch - This seem like a pretty common use case and the solution you propose does not seem to work from the test I ran and also comments. Similar issue was raised I believe in [http://forum.spring.io/forum/spring-projects/security/94772-redirect-to-invalid-session-url-only-when-user-accesses-secured-resource](http://web.archive.org/web/20170517083636/http://forum.spring.io/forum/spring-projects/security/94772-redirect-to-invalid-session-url-only-when-user-accesses-secured-resource) and it appears it was never resolved. My thinking is to have multiple http settings (using xml config)
```
<http pattern="/aboutUs**" security="none" />
<http pattern="/contact**" security="none" />
etc
```
This does not seem ideal when having quite a number unsecured pages and also adding a new unsecured page requires a configuration update. It will be nice if we can have an "ideal" solution for this use case. With Spring security 4.1 release, it appears there is still no clear way to do this.
|
14,614,809 |
I have a ListView with a GridView (multiple columns) layout. Some column have converters which uses the current locale to prettify numbers, turn unix timestamps into datetime strings, or just translate an enum to a localized description of it.
The locale can be changed during runtime, so I need a way to rerun these converters as that happens. Note that the value itself of the binding has not changed, but the output of the converter may be different with a different locale.
What is the best way to do so? I don't want to iterate the whole collection of every affected list and call OnPropertyChanged. Is there a way to either force the ListView to refresh every binding, or just the bindings of some columns?
|
2013/01/30
|
[
"https://Stackoverflow.com/questions/14614809",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1121561/"
] |
I found the answer:
```
ICollectionView view = CollectionViewSource.GetDefaultView(MyListView.ItemsSource);
view.Refresh();
```
|
4,648,351 |
Let $a , b$ and $c$ are real numbers with $a < b$. Can there be a smooth diffeomorphism between the semi-open interval $[a , b)$ and the unbounded closed interval $[c , +\infty)$? I know smooth diffeomorphism between the open interval $(a , b)$ and the unbounded open interval $(c , +\infty)$. Can this be extended? Any help please. Thanks in advance.
|
2023/02/28
|
[
"https://math.stackexchange.com/questions/4648351",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/711027/"
] |
Take
$$h : (-\infty,b) \to (c-1,\infty), h(x) = c - 1 + \frac{b-a}{b-x} . $$
This is a smooth map with smooth inverse
$$g : (c-1,\infty) \to (-\infty,b), g(y) = b - \frac{b-a}{y - c +1} . $$
We have
$$h([a,b) ) = [c,\infty)$$
which proves that there is a smooth diffeomorphism between $[a,b)$ and $ [c,∞)$.
|
21,131,081 |
In a for loop should I use only `i++` or `i--` operators ? OR can I also use `i+10`, `i+20`,`i-20` ? I used `i+10` in the increment place in the For loop , it is not getting executed.but when I use `i++` , it is getting executed.so please help me solve this ! I tried `for(i=0;i<=100;i+20`) is it wrong ?
|
2014/01/15
|
[
"https://Stackoverflow.com/questions/21131081",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3197016/"
] |
In C and C++ at least, the statement:
```c
i + 20
```
is an *expression statement* - the expression is evaluated (or may not be if the optimiser figures out the result does not affect the observable behaviour of the program, which is likely) but otherwise ignored. In fact, the statement:
```c
42
```
is *also* valid but equally useless.
---
What you *should* be doing is one of:
```c
i += 20
i = i + 20
```
That will work better in your loop because it actually *modifies* the loop control variable.
|
2,827,198 |
Consider a sequence in $\mathbb{R}^K$: Let the $j$-th term in the sequence be denoted by $x\_j = ((x\_1)\_j, (x\_2)\_j, \ldots, (x\_K)\_j)$. I've been given that for all $k = 1, 2, \ldots, K$, the sequence $(x\_k)\_n \to 0$ as $n \to \infty$ and I'm trying to prove that
$$\big(\max\_k x\_k\big)\_n \to 0$$
Let $\epsilon > 0$ be given. For any $k \in \{1,\ldots,K\}$, let $N\_k \in \mathbb{N}$ such that $(x\_k)\_n < \epsilon$ for all $n > N\_k$. If $N = \max\_k N\_k$, then for all $k \in \{1,\ldots,K\}$, $(x\_k)\_n < \epsilon$ for all $n > N$, which in turn implies $\big(\max\_k x\_k\big)\_n < \epsilon$ for all $n > N$.
Seems like a simple result to prove yet I'm not entirely sure. Does this need any corrections? Thanks
|
2018/06/21
|
[
"https://math.stackexchange.com/questions/2827198",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/458802/"
] |
\begin{align}
&(x-y)^2\ge0\\
\implies&x^2-2xy+y^2\ge0\\
\implies&-2xy\ge-1
\end{align}
Do you know how to continue?
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.