qid int64 1 74.7M | question stringlengths 15 58.3k | date stringlengths 10 10 | metadata list | response_j stringlengths 4 30.2k | response_k stringlengths 11 36.5k |
|---|---|---|---|---|---|
3,283,460 | I want to parse some emails from a user 's inbox but when I do:
```
typ, msg_data = imap_conn.fetch(uid, '(RFC822)')
```
It marks the email as SEEN or read. This is not the desired functionality. Do you know how can I keep the email at its previous stare either SEEN or NOT SEEN? | 2010/07/19 | [
"https://Stackoverflow.com/questions/3283460",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1438479/"
] | You might also set `read_only` to true when selecting the folder:
```
imap_conn.select('Inbox', readonly=True)
``` | You may use imap\_tools package:
<https://pypi.org/project/imap-tools/>
```
from imap_tools import MailBox, Q
# get list of email subjects from INBOX folder
with MailBox('imap.mail.com').login('test@mail.com', 'password') as mailbox:
# mark_seen=False - not mark emails as seen on fetch
subjects = [msg.subjec... |
3,311,399 | How would you check for the object type when looping std::list?
```
class A
{
int x; int y;
public:
A() {x = 1; y = 2;}
};
class B
{
double x; double y;
public:
B() {x = 1; y = 2;}
};
class C
{
float x; float y;
public:
C() {x = 1; y = 2;}
};
int main()
{
A a; B b; C c;
list <boost::... | 2010/07/22 | [
"https://Stackoverflow.com/questions/3311399",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/187543/"
] | About the only time I can think of using Assembly language for optimizing code is when you need something very specific, like you need a GPIO on a microcontroller to toggle between high and low ***exactly*** every 9 clock cycles. that's too short a time to manage with an interrupt, and higher level language compilers d... | Read [the Graphics Programming Black Book by Michael Abrash](http://www.gamedev.net/reference/articles/article1698.asp) |
3,311,399 | How would you check for the object type when looping std::list?
```
class A
{
int x; int y;
public:
A() {x = 1; y = 2;}
};
class B
{
double x; double y;
public:
B() {x = 1; y = 2;}
};
class C
{
float x; float y;
public:
C() {x = 1; y = 2;}
};
int main()
{
A a; B b; C c;
list <boost::... | 2010/07/22 | [
"https://Stackoverflow.com/questions/3311399",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/187543/"
] | These days, you have to be very good at assembly to beat the compiler.
I can do it any day of the week, but only by viewing the compiler's output first.
And then, if it gains more than a couple of percentage points I'd be surprised.
These days, I only program in assembly when I'm doing something the compiler *can't*... | When writing assembly, or even just straight raw bytes the assembler outputs, you can write programs that use computer hardware specific features or makes something otherwise very carefully specified.
There might be really high benefits if your program does the optimized part far more often than it does anything else.... |
3,311,399 | How would you check for the object type when looping std::list?
```
class A
{
int x; int y;
public:
A() {x = 1; y = 2;}
};
class B
{
double x; double y;
public:
B() {x = 1; y = 2;}
};
class C
{
float x; float y;
public:
C() {x = 1; y = 2;}
};
int main()
{
A a; B b; C c;
list <boost::... | 2010/07/22 | [
"https://Stackoverflow.com/questions/3311399",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/187543/"
] | Typically you wouldn't program in assembly. You would program in C, and then look at the generated assembly to see what optimzations (or not) the C compiler made automatically. Adjusting your C code (to allow for better vectorization for example) will allow the compiler to re-arrange code better, which will give you op... | Compilers do a good job of generating assembler.
However, there's a *bad* reason why hand-written assembler is faster. Since it's harder to write, you write less of it.
It would be nice if programmers could discipline themselves to get the same job done in minimal code, regardless of language. |
3,311,399 | How would you check for the object type when looping std::list?
```
class A
{
int x; int y;
public:
A() {x = 1; y = 2;}
};
class B
{
double x; double y;
public:
B() {x = 1; y = 2;}
};
class C
{
float x; float y;
public:
C() {x = 1; y = 2;}
};
int main()
{
A a; B b; C c;
list <boost::... | 2010/07/22 | [
"https://Stackoverflow.com/questions/3311399",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/187543/"
] | The most likely way programming in assembly can improve your code is by improving *you*: teaching you more about what is happening at a low level and getting the discipline of optimization can help you make good decisions in higher-level languages.
As far as actually helping one program: as others have noted it's rare... | Compilers do a good job of generating assembler.
However, there's a *bad* reason why hand-written assembler is faster. Since it's harder to write, you write less of it.
It would be nice if programmers could discipline themselves to get the same job done in minimal code, regardless of language. |
3,311,399 | How would you check for the object type when looping std::list?
```
class A
{
int x; int y;
public:
A() {x = 1; y = 2;}
};
class B
{
double x; double y;
public:
B() {x = 1; y = 2;}
};
class C
{
float x; float y;
public:
C() {x = 1; y = 2;}
};
int main()
{
A a; B b; C c;
list <boost::... | 2010/07/22 | [
"https://Stackoverflow.com/questions/3311399",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/187543/"
] | In principle, you can write highly-optimized code in assembly because the compiler is limited to specific, general-purpose optimizations that should apply to many programs, while you can be creative and use your knowledge of this particular program.
To take a simple example, back when I was new to this business compil... | So, you think you are smarter than `gcc` optimizing compiler?
If not, then fughed aboud it (learning assembly for the sake of getting better at optimization). That would be akin to learning `Scheme` language for the sake of getting better at recursion :) |
3,311,399 | How would you check for the object type when looping std::list?
```
class A
{
int x; int y;
public:
A() {x = 1; y = 2;}
};
class B
{
double x; double y;
public:
B() {x = 1; y = 2;}
};
class C
{
float x; float y;
public:
C() {x = 1; y = 2;}
};
int main()
{
A a; B b; C c;
list <boost::... | 2010/07/22 | [
"https://Stackoverflow.com/questions/3311399",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/187543/"
] | Programming in assembly won't, in and of itself, optimize your code. The main thing about assembly is that it allows you to have very low-level access and to choose exactly what instructions the processor executes.
Since you won't have some compiler generating the assembly for you, you can perform code optimizations w... | Read [the Graphics Programming Black Book by Michael Abrash](http://www.gamedev.net/reference/articles/article1698.asp) |
3,311,399 | How would you check for the object type when looping std::list?
```
class A
{
int x; int y;
public:
A() {x = 1; y = 2;}
};
class B
{
double x; double y;
public:
B() {x = 1; y = 2;}
};
class C
{
float x; float y;
public:
C() {x = 1; y = 2;}
};
int main()
{
A a; B b; C c;
list <boost::... | 2010/07/22 | [
"https://Stackoverflow.com/questions/3311399",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/187543/"
] | About the only time I can think of using Assembly language for optimizing code is when you need something very specific, like you need a GPIO on a microcontroller to toggle between high and low ***exactly*** every 9 clock cycles. that's too short a time to manage with an interrupt, and higher level language compilers d... | Compilers do a good job of generating assembler.
However, there's a *bad* reason why hand-written assembler is faster. Since it's harder to write, you write less of it.
It would be nice if programmers could discipline themselves to get the same job done in minimal code, regardless of language. |
3,311,399 | How would you check for the object type when looping std::list?
```
class A
{
int x; int y;
public:
A() {x = 1; y = 2;}
};
class B
{
double x; double y;
public:
B() {x = 1; y = 2;}
};
class C
{
float x; float y;
public:
C() {x = 1; y = 2;}
};
int main()
{
A a; B b; C c;
list <boost::... | 2010/07/22 | [
"https://Stackoverflow.com/questions/3311399",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/187543/"
] | These days, you have to be very good at assembly to beat the compiler.
I can do it any day of the week, but only by viewing the compiler's output first.
And then, if it gains more than a couple of percentage points I'd be surprised.
These days, I only program in assembly when I'm doing something the compiler *can't*... | About the only time I can think of using Assembly language for optimizing code is when you need something very specific, like you need a GPIO on a microcontroller to toggle between high and low ***exactly*** every 9 clock cycles. that's too short a time to manage with an interrupt, and higher level language compilers d... |
3,311,399 | How would you check for the object type when looping std::list?
```
class A
{
int x; int y;
public:
A() {x = 1; y = 2;}
};
class B
{
double x; double y;
public:
B() {x = 1; y = 2;}
};
class C
{
float x; float y;
public:
C() {x = 1; y = 2;}
};
int main()
{
A a; B b; C c;
list <boost::... | 2010/07/22 | [
"https://Stackoverflow.com/questions/3311399",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/187543/"
] | The most likely way programming in assembly can improve your code is by improving *you*: teaching you more about what is happening at a low level and getting the discipline of optimization can help you make good decisions in higher-level languages.
As far as actually helping one program: as others have noted it's rare... | About the only time I can think of using Assembly language for optimizing code is when you need something very specific, like you need a GPIO on a microcontroller to toggle between high and low ***exactly*** every 9 clock cycles. that's too short a time to manage with an interrupt, and higher level language compilers d... |
3,311,399 | How would you check for the object type when looping std::list?
```
class A
{
int x; int y;
public:
A() {x = 1; y = 2;}
};
class B
{
double x; double y;
public:
B() {x = 1; y = 2;}
};
class C
{
float x; float y;
public:
C() {x = 1; y = 2;}
};
int main()
{
A a; B b; C c;
list <boost::... | 2010/07/22 | [
"https://Stackoverflow.com/questions/3311399",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/187543/"
] | These days, you have to be very good at assembly to beat the compiler.
I can do it any day of the week, but only by viewing the compiler's output first.
And then, if it gains more than a couple of percentage points I'd be surprised.
These days, I only program in assembly when I'm doing something the compiler *can't*... | Typically you wouldn't program in assembly. You would program in C, and then look at the generated assembly to see what optimzations (or not) the C compiler made automatically. Adjusting your C code (to allow for better vectorization for example) will allow the compiler to re-arrange code better, which will give you op... |
26,467,445 | ```
$xml = '<?xml version="1.0" encoding="UTF-8"?>
<stw:ThumbnailResponse xmlns:stw="http://www.shrinktheweb.com/doc/stwresponse.xsd">
<stw:Response>
<stw:ThumbnailResult>
<stw:Thumbnail Exists="true">http://imagelink.com</stw:Thumbnail>
<stw:Thumbnail Verified="false">deliv... | 2014/10/20 | [
"https://Stackoverflow.com/questions/26467445",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/267304/"
] | Using simple xml you could use `->children()` method on this one:
```
$xml = simplexml_load_string($xml_string);
$stw = $xml->children('stw', 'http://www.shrinktheweb.com/doc/stwresponse.xsd');
echo '<pre>';
foreach($stw as $e) {
print_r($e);
// do what you have to do here
}
``` | This code actually runs just fine for me ---
Typically, that sort of error means you may've made a typo on your `$dom` object - double check it and try again.
Also, it is notable that you'll want to change the `item(0)` to `item(1)` when you're setting your `$status` variable.
```
$result = $dom->getElementsB... |
26,467,445 | ```
$xml = '<?xml version="1.0" encoding="UTF-8"?>
<stw:ThumbnailResponse xmlns:stw="http://www.shrinktheweb.com/doc/stwresponse.xsd">
<stw:Response>
<stw:ThumbnailResult>
<stw:Thumbnail Exists="true">http://imagelink.com</stw:Thumbnail>
<stw:Thumbnail Verified="false">deliv... | 2014/10/20 | [
"https://Stackoverflow.com/questions/26467445",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/267304/"
] | You need to specify a namespace and the method DOMDocument::getElementsByTagName can't handle it. In the [manual](http://php.net/manual/en/domdocument.getelementsbytagname.php):
>
> The local name (**without namespace**) of the tag to match on.
>
>
>
You can use [DOMDocument::getElementsByTagNameNS](http://php.n... | This code actually runs just fine for me ---
Typically, that sort of error means you may've made a typo on your `$dom` object - double check it and try again.
Also, it is notable that you'll want to change the `item(0)` to `item(1)` when you're setting your `$status` variable.
```
$result = $dom->getElementsB... |
35,535,374 | I'm trying to show custom layout as an item in options menu.
And this is what I have done so far
```
<item
android:id="@+id/action_profile"
android:orderInCategory="100"
android:title="Profile"
android:actionLayout="@layout/layout_menu_profile"
app:showAsAction="never" />
```
I tried
```
ap... | 2016/02/21 | [
"https://Stackoverflow.com/questions/35535374",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1000864/"
] | use `app:actionLayout` instead of `android:actionLayout`.
```
<item
...
app:actionLayout="@layout/layout_menu_profile"
app:showAsAction="always" />
``` | Try this code
```
<item
android:id="@+id/action_profile"
android:orderInCategory="100"
android:title="Profile"
android:actionLayout="@layout/layout_menu_profile"
app:showAsAction="always" />
```
Just set the **showAsAction** elements to **always** |
35,535,374 | I'm trying to show custom layout as an item in options menu.
And this is what I have done so far
```
<item
android:id="@+id/action_profile"
android:orderInCategory="100"
android:title="Profile"
android:actionLayout="@layout/layout_menu_profile"
app:showAsAction="never" />
```
I tried
```
ap... | 2016/02/21 | [
"https://Stackoverflow.com/questions/35535374",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1000864/"
] | use `app:actionLayout` instead of `android:actionLayout`.
```
<item
...
app:actionLayout="@layout/layout_menu_profile"
app:showAsAction="always" />
``` | Use "app:" instead of "android:"
```
app:actionLayout="@layout/layout_menu_profile"
``` |
33,125,802 | I have xml with a repeating node structure within single node. How do I parse all the values by level?
```
<Totallevel>3</Totallevel>
<A>
<B>text</B>
<level>1</level>
<A>
<B>text</B>
<level>2</level>
<A>
<B>text</B>
<level>3</level>
</A>
</A>
</A>
``` | 2015/10/14 | [
"https://Stackoverflow.com/questions/33125802",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1929007/"
] | The pattern is that **utility services** are prefixed with AWS, while **standalone services** are prefixed by "Amazon".
Services prefixed with AWS *typically use other services*, for example:
* **AWS Elastic Beanstalk**, **AWS OpsWorks** and **AWS CloudFormation** launch other services
* **AWS Lambda** is triggered b... | *I originally answered on [AWS products and services naming nomenclature starting with 'Amazon' vs 'AWS'](https://stackoverflow.com/a/65221189/1381529). I consider this answer needs to be mentioned here as well*.
Context: [Web Service](https://en.wikipedia.org/wiki/Web_service), initially designed as a replacement for... |
22,900,119 | I have a set of base steps in SpecFlow that do simple things like enter text and validate fields. I want so that these base steps can be used by non technical testers in creating higher level steps made out of these base steps. They should not need to know how to code or how to implement step definitions or how to use ... | 2014/04/06 | [
"https://Stackoverflow.com/questions/22900119",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1709356/"
] | If `tab` is uninitialized then you cannot access it by index as you are in
`tab[0][column].push_back(colour);`. | Check also if you use C++1X :
```
vector<vector<Colour>> tab;
```
The no espace syntax ">>" doesn't work otherwise. |
22,900,119 | I have a set of base steps in SpecFlow that do simple things like enter text and validate fields. I want so that these base steps can be used by non technical testers in creating higher level steps made out of these base steps. They should not need to know how to code or how to implement step definitions or how to use ... | 2014/04/06 | [
"https://Stackoverflow.com/questions/22900119",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1709356/"
] | Your member variable is a vector of `vector<Colour>`. If you want to add a `Colour` to a particular `vector<Colour>` at a particular index, then you need to first identify if that vector at that index is present. If so then you can add the `Colour`. If not you are assigning to an address that is not present.
You need ... | Check also if you use C++1X :
```
vector<vector<Colour>> tab;
```
The no espace syntax ">>" doesn't work otherwise. |
57,868,096 | I'm running a node project + reactjs on it. the process.env works inside the server.js but undefined in other js file.
I tried to build the project using webpack and then run the nodejs project like
here are the steps I did.
yarn build
CALLBACK\_URL=<https://localhost:9999/> BASE\_URL=<https://localhost:9443/> no... | 2019/09/10 | [
"https://Stackoverflow.com/questions/57868096",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3073958/"
] | Server.js is in the back end and is in scope of your "process" object.
React runs in the client browser engine. You need to get the environment variables From the "process" object available in your back-end's webpack build context into the webpack React Built files!
>
> See
>
>
> * [dotenv-webpack plugin](https://w... | in webpack.config you can add these lines in plugins section:
```
new webpack.DefinePlugin({
'process.env.CALLBACK_URL': 'https://localhost:9999/',
'process.env.BASE_URL': 'https://localhost:9443/'
})
``` |
23,553 | I am writing a semi-fantasy novel, which is set in medieval India and today's New York. I have never been to New York, and will not be there, for far period. How can I do research to embed the cultural and political references of New York into my novel | 2016/06/25 | [
"https://writers.stackexchange.com/questions/23553",
"https://writers.stackexchange.com",
"https://writers.stackexchange.com/users/19480/"
] | Google Maps and Street View is your friend. Take a virtual walk, learn the area, click on local stores, read reviews for these stores, check bus & metro schedules, find out about the parks, etc.
If you're interested in more in-depth elements, you'll need to provide more details about the particular elements. But basic... | Google Maps is fine for *geography*, but your question mentions "cultural and political references." If you cannot travel there, you have to find some way to be exposed to and/or interact with the people there.
Cities have their own personalities. They have neighborhoods, cliques, sections, classes, ethnicities. With... |
42,183,485 | I feel like an idiot for asking such a basic question but here goes... I'm trying out AWS Lambda in C# for the first time and according to the docs:
>
> Anything written to standard out or standard error - using
> Console.Write or a similar method - will be logged in CloudWatch Logs.
>
>
>
OK well upon execution... | 2017/02/12 | [
"https://Stackoverflow.com/questions/42183485",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7552065/"
] | As an alternative to `Console.Write` or `Console.WriteLine`, you can use the `Log` method on the static `Amazon.Lambda.Core.LambdaLogger` class.
```
private void DoSomething() {
LambdaLogger.Log("Log message");
}
```
Some more info can be found here: <http://docs.aws.amazon.com/lambda/latest/dg/dotnet-logging.ht... | Well turns out in the project.json file under the dependencies node, the wizard's serverless template made a reference to Microsoft.NETCore.App without specifying a "type" of "platform". I spotted other samples online where the type line was present and once I added it, everything started working!
```
"Microsoft.N... |
29,414,814 | I have developed an rest service using spring-boot and Spring-boot-starter hateoas. And I am facing an issue with customizing ObjectMapper. The code goes below for the same:
Application.java
```
@Configuration
@Import(BillServiceConfig.class)
@EnableAutoConfiguration
@EnableEurekaClient
@ComponentScan({"com.bill"})
@... | 2015/04/02 | [
"https://Stackoverflow.com/questions/29414814",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1957631/"
] | I'm using spring-boot 1.5 RC1. If you remove the @EnableHypermediaSupport annotation spring-boot should configure spring-hateoas with ISO 8601 dates for you so long as you have java time module on the classpath.
```
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-js... | Root of this problem - default ObjectMapper from Spring MVC is used instead of one configured by author.
This happens because of @EnableWebMvc.
Quote from [Spring Boot guide](https://spring.io/guides/gs/spring-boot/)
>
> Normally you would add @EnableWebMvc for a Spring MVC app, but Spring
> Boot adds it automatica... |
90,840 | >
> **Possible Duplicate:**
>
> [How the heck is http://to./ a valid domain name?](https://serverfault.com/questions/90737/how-the-heck-is-http-to-a-valid-domain-name)
>
>
>
<http://to./> must be the shortest domain name I have ever seen. How can did they register a domain without an extension? | 2009/12/03 | [
"https://serverfault.com/questions/90840",
"https://serverfault.com",
"https://serverfault.com/users/-1/"
] | They didn't, they have a top level domain (.to) - <http://www.to/> is them (when entering <http://to./your> browser automatically inserted the www. part and the trailing . prevented your browser from adding .com | Perhaps you are mistaken?
`$ whois to.`
`No whois server is known for this kind of object.` |
90,840 | >
> **Possible Duplicate:**
>
> [How the heck is http://to./ a valid domain name?](https://serverfault.com/questions/90737/how-the-heck-is-http-to-a-valid-domain-name)
>
>
>
<http://to./> must be the shortest domain name I have ever seen. How can did they register a domain without an extension? | 2009/12/03 | [
"https://serverfault.com/questions/90840",
"https://serverfault.com",
"https://serverfault.com/users/-1/"
] | <http://www.iana.org/domains/root/db/to.html> | Perhaps you are mistaken?
`$ whois to.`
`No whois server is known for this kind of object.` |
51,897 | I'm trying to translate an English sentence into Japanese , but i got some problems and confuse which should i use between が or は . So please tell me which is the correct one .
1. ジョンさんは休日にいつも東京にいる。
2. ジョンさんが休日にいつも東京にいる。
Also
1. 彼は傷口にそっと触れる。
2. 彼が傷口にそっと触れる。 | 2017/07/31 | [
"https://japanese.stackexchange.com/questions/51897",
"https://japanese.stackexchange.com",
"https://japanese.stackexchange.com/users/25205/"
] | I think one way to see the difference would be...
1. ジョンさん**は**休日にいつも東京にいる。
*lit.* As for John / Speaking of John, he is usually in Tokyo on holidays. (and someone else among the people we're talking about may also be in Tokyo.)
2. ジョンさん**が**休日にいつも東京にいる。
(Of all the people we are talking about) It is John (not ... | That should be #1,
>
> ジョンさんは休日にいつも東京にいる。
>
>
>
unless you have more special context. **は** is for **general ideas** like when you say *the store at the corner opens at 8 every morning.*
**が** is good for telling a ***happening***, or this is basically to be used in a ***modifying clauses.***
>
> ジョンさんが休日に... |
136,678 | I have a collection that contains linked assets.
I would like to override their materials and give them a unique material.
Is it possible to assign a material to a whole collection, and how ?
Thanks ! | 2019/04/09 | [
"https://blender.stackexchange.com/questions/136678",
"https://blender.stackexchange.com",
"https://blender.stackexchange.com/users/14306/"
] | If your model consists of only one object you can link the mesh/object data rather than the whole object, then create a new object in the scene and set the mesh/object data to the linked one.
You can then add any material you want (as only the mesh is linked) and any changes done to the original mesh will still be made... | The only way to do this is to change the materials in the original file(s).
The whole purpose of linking is to have one source in eventually multiple projects. Change the source and all the projects get updated, that have links to that source.
In your case, the collection should be the source and other projects shou... |
136,678 | I have a collection that contains linked assets.
I would like to override their materials and give them a unique material.
Is it possible to assign a material to a whole collection, and how ?
Thanks ! | 2019/04/09 | [
"https://blender.stackexchange.com/questions/136678",
"https://blender.stackexchange.com",
"https://blender.stackexchange.com/users/14306/"
] | You can override the materials from linked sources that are part of the same collection, just the same way you can override not linked ones.
In the scene context section you can find the options for override, you can select a single material and that will be used for all objects.
[.
The whole purpose of linking is to have one source in eventually multiple projects. Change the source and all the projects get updated, that have links to that source.
In your case, the collection should be the source and other projects shou... |
136,678 | I have a collection that contains linked assets.
I would like to override their materials and give them a unique material.
Is it possible to assign a material to a whole collection, and how ?
Thanks ! | 2019/04/09 | [
"https://blender.stackexchange.com/questions/136678",
"https://blender.stackexchange.com",
"https://blender.stackexchange.com/users/14306/"
] | What i found is:
Mark the whole Collection, press `CTRL`+`L`, select *Material* and select the material you want.
That will Link the selected material to the whole selection.
[source](https://chiaroscorner.wordpress.com/2019/08/19/how-to-assign-one-material-to-multiple-objects-in-blender-2-8/) | The only way to do this is to change the materials in the original file(s).
The whole purpose of linking is to have one source in eventually multiple projects. Change the source and all the projects get updated, that have links to that source.
In your case, the collection should be the source and other projects shou... |
136,678 | I have a collection that contains linked assets.
I would like to override their materials and give them a unique material.
Is it possible to assign a material to a whole collection, and how ?
Thanks ! | 2019/04/09 | [
"https://blender.stackexchange.com/questions/136678",
"https://blender.stackexchange.com",
"https://blender.stackexchange.com/users/14306/"
] | You can override the materials from linked sources that are part of the same collection, just the same way you can override not linked ones.
In the scene context section you can find the options for override, you can select a single material and that will be used for all objects.
[ and any changes done to the original mesh will still be made... |
136,678 | I have a collection that contains linked assets.
I would like to override their materials and give them a unique material.
Is it possible to assign a material to a whole collection, and how ?
Thanks ! | 2019/04/09 | [
"https://blender.stackexchange.com/questions/136678",
"https://blender.stackexchange.com",
"https://blender.stackexchange.com/users/14306/"
] | If your model consists of only one object you can link the mesh/object data rather than the whole object, then create a new object in the scene and set the mesh/object data to the linked one.
You can then add any material you want (as only the mesh is linked) and any changes done to the original mesh will still be made... | What i found is:
Mark the whole Collection, press `CTRL`+`L`, select *Material* and select the material you want.
That will Link the selected material to the whole selection.
[source](https://chiaroscorner.wordpress.com/2019/08/19/how-to-assign-one-material-to-multiple-objects-in-blender-2-8/) |
136,678 | I have a collection that contains linked assets.
I would like to override their materials and give them a unique material.
Is it possible to assign a material to a whole collection, and how ?
Thanks ! | 2019/04/09 | [
"https://blender.stackexchange.com/questions/136678",
"https://blender.stackexchange.com",
"https://blender.stackexchange.com/users/14306/"
] | You can override the materials from linked sources that are part of the same collection, just the same way you can override not linked ones.
In the scene context section you can find the options for override, you can select a single material and that will be used for all objects.
[ |
2,295,495 | I have an AllocatedStock table holding a case number (knows as a TPND) and a quantity. I need to select a list of product stock but present this with the product number (known as TPNB) rather than the case number. I also have a ProductLookup table which holds all TPNBs and TPNDs.
**AllocatedStock**
AllocatedStockI... | 2010/02/19 | [
"https://Stackoverflow.com/questions/2295495",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41169/"
] | `SELECT DISTINCT` should do it:
```
select TPNB, sum(AllocatedQty) as 'QTY'
from (SELECT DISTINCT TPND, TPNB FROM integration.ProductLookup) as PL
inner join dbo.AllocatedStock as AStock
on PL.TPND = AStock.TPND
group by TPNB
``` | ```
select distinct tpnb, qty
from (
select TPNB, sum(AllocatedQty) as 'QTY'
from integration.ProductLookup as PL
inner join dbo.AllocatedStock as AStock
on PL.TPND = AStock.TPND
group by ProductLookupID ) a
``` |
2,295,495 | I have an AllocatedStock table holding a case number (knows as a TPND) and a quantity. I need to select a list of product stock but present this with the product number (known as TPNB) rather than the case number. I also have a ProductLookup table which holds all TPNBs and TPNDs.
**AllocatedStock**
AllocatedStockI... | 2010/02/19 | [
"https://Stackoverflow.com/questions/2295495",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41169/"
] | `SELECT DISTINCT` should do it:
```
select TPNB, sum(AllocatedQty) as 'QTY'
from (SELECT DISTINCT TPND, TPNB FROM integration.ProductLookup) as PL
inner join dbo.AllocatedStock as AStock
on PL.TPND = AStock.TPND
group by TPNB
``` | ```
select TPNB, sum(AllocatedQty) as 'QTY'
from
(
SELECT TPND, TPNB
FROM ProductLookup
GROUP BY TPND, TPNB
) as PL
inner join dbo.AllocatedStock as AStock
on PL.TPND = AStock.TPND
group by TPNB
``` |
2,295,495 | I have an AllocatedStock table holding a case number (knows as a TPND) and a quantity. I need to select a list of product stock but present this with the product number (known as TPNB) rather than the case number. I also have a ProductLookup table which holds all TPNBs and TPNDs.
**AllocatedStock**
AllocatedStockI... | 2010/02/19 | [
"https://Stackoverflow.com/questions/2295495",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41169/"
] | Give this a whirl. I am using a derived query to 'clean' your productlookup table.
```
select TPNB, sum(AllocatedQty) as 'QTY'
from (select distinct TPND, TPNB from integration.ProductLookup) as PL
inner join dbo.AllocatedStock as AStock
on PL.TPND = AStock.TPND
group by TPNB
``` | `SELECT DISTINCT` should do it:
```
select TPNB, sum(AllocatedQty) as 'QTY'
from (SELECT DISTINCT TPND, TPNB FROM integration.ProductLookup) as PL
inner join dbo.AllocatedStock as AStock
on PL.TPND = AStock.TPND
group by TPNB
``` |
2,295,495 | I have an AllocatedStock table holding a case number (knows as a TPND) and a quantity. I need to select a list of product stock but present this with the product number (known as TPNB) rather than the case number. I also have a ProductLookup table which holds all TPNBs and TPNDs.
**AllocatedStock**
AllocatedStockI... | 2010/02/19 | [
"https://Stackoverflow.com/questions/2295495",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41169/"
] | Give this a whirl. I am using a derived query to 'clean' your productlookup table.
```
select TPNB, sum(AllocatedQty) as 'QTY'
from (select distinct TPND, TPNB from integration.ProductLookup) as PL
inner join dbo.AllocatedStock as AStock
on PL.TPND = AStock.TPND
group by TPNB
``` | ```
select distinct tpnb, qty
from (
select TPNB, sum(AllocatedQty) as 'QTY'
from integration.ProductLookup as PL
inner join dbo.AllocatedStock as AStock
on PL.TPND = AStock.TPND
group by ProductLookupID ) a
``` |
2,295,495 | I have an AllocatedStock table holding a case number (knows as a TPND) and a quantity. I need to select a list of product stock but present this with the product number (known as TPNB) rather than the case number. I also have a ProductLookup table which holds all TPNBs and TPNDs.
**AllocatedStock**
AllocatedStockI... | 2010/02/19 | [
"https://Stackoverflow.com/questions/2295495",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41169/"
] | Give this a whirl. I am using a derived query to 'clean' your productlookup table.
```
select TPNB, sum(AllocatedQty) as 'QTY'
from (select distinct TPND, TPNB from integration.ProductLookup) as PL
inner join dbo.AllocatedStock as AStock
on PL.TPND = AStock.TPND
group by TPNB
``` | ```
select TPNB, sum(AllocatedQty) as 'QTY'
from
(
SELECT TPND, TPNB
FROM ProductLookup
GROUP BY TPND, TPNB
) as PL
inner join dbo.AllocatedStock as AStock
on PL.TPND = AStock.TPND
group by TPNB
``` |
154,679 | I am trying to make a php script on a webserver write into a folder /data on a fileserver.
Apache 2.2, PhP 5.x. It's just a test configuration but I'd like to understand the thing somehow as I am not very experienced regarding permissions when it comes to webservers.
I am sharing the folder /data on the fileserver by... | 2014/09/09 | [
"https://unix.stackexchange.com/questions/154679",
"https://unix.stackexchange.com",
"https://unix.stackexchange.com/users/83599/"
] | The problem is that the optional parameter assignments are recognized *before* parameter expansion occurs, so the line
```
$X
```
is recognized as a command with no preceding assignments. The first word of the result of expanding it is assumed to be the command name, so the shell tries to run `Y=10`.
As is usually ... | The way to get a command to be parsed again after parameter expansion occurs is
```none
X="Y=10 echo foo"
eval "$X"
```
I'm assuming that you have a realistic reason for wanting to do this. |
154,679 | I am trying to make a php script on a webserver write into a folder /data on a fileserver.
Apache 2.2, PhP 5.x. It's just a test configuration but I'd like to understand the thing somehow as I am not very experienced regarding permissions when it comes to webservers.
I am sharing the folder /data on the fileserver by... | 2014/09/09 | [
"https://unix.stackexchange.com/questions/154679",
"https://unix.stackexchange.com",
"https://unix.stackexchange.com/users/83599/"
] | The problem is that the optional parameter assignments are recognized *before* parameter expansion occurs, so the line
```
$X
```
is recognized as a command with no preceding assignments. The first word of the result of expanding it is assumed to be the command name, so the shell tries to run `Y=10`.
As is usually ... | *It turned out that what I describe below is just an artifact of the minimal example, which leaves out the part where `Y` is used.*
There is a variable assignment before the command in the line:
```
Y=10 echo foo
```
The assignment will set the variable `Y` to `10` during the execution of `echo foo`. Because `echo ... |
154,679 | I am trying to make a php script on a webserver write into a folder /data on a fileserver.
Apache 2.2, PhP 5.x. It's just a test configuration but I'd like to understand the thing somehow as I am not very experienced regarding permissions when it comes to webservers.
I am sharing the folder /data on the fileserver by... | 2014/09/09 | [
"https://unix.stackexchange.com/questions/154679",
"https://unix.stackexchange.com",
"https://unix.stackexchange.com/users/83599/"
] | The problem is that the optional parameter assignments are recognized *before* parameter expansion occurs, so the line
```
$X
```
is recognized as a command with no preceding assignments. The first word of the result of expanding it is assumed to be the command name, so the shell tries to run `Y=10`.
As is usually ... | If you must do this, use `env`:
```
$ X='env Y=10 echo foo'
foo
```
...and to demonstrate `$Y`...
```
$ X='env Y=10 env'
$ $X | grep \^Y
Y=10
```
...but a function is better. |
154,679 | I am trying to make a php script on a webserver write into a folder /data on a fileserver.
Apache 2.2, PhP 5.x. It's just a test configuration but I'd like to understand the thing somehow as I am not very experienced regarding permissions when it comes to webservers.
I am sharing the folder /data on the fileserver by... | 2014/09/09 | [
"https://unix.stackexchange.com/questions/154679",
"https://unix.stackexchange.com",
"https://unix.stackexchange.com/users/83599/"
] | *It turned out that what I describe below is just an artifact of the minimal example, which leaves out the part where `Y` is used.*
There is a variable assignment before the command in the line:
```
Y=10 echo foo
```
The assignment will set the variable `Y` to `10` during the execution of `echo foo`. Because `echo ... | The way to get a command to be parsed again after parameter expansion occurs is
```none
X="Y=10 echo foo"
eval "$X"
```
I'm assuming that you have a realistic reason for wanting to do this. |
154,679 | I am trying to make a php script on a webserver write into a folder /data on a fileserver.
Apache 2.2, PhP 5.x. It's just a test configuration but I'd like to understand the thing somehow as I am not very experienced regarding permissions when it comes to webservers.
I am sharing the folder /data on the fileserver by... | 2014/09/09 | [
"https://unix.stackexchange.com/questions/154679",
"https://unix.stackexchange.com",
"https://unix.stackexchange.com/users/83599/"
] | If you must do this, use `env`:
```
$ X='env Y=10 echo foo'
foo
```
...and to demonstrate `$Y`...
```
$ X='env Y=10 env'
$ $X | grep \^Y
Y=10
```
...but a function is better. | The way to get a command to be parsed again after parameter expansion occurs is
```none
X="Y=10 echo foo"
eval "$X"
```
I'm assuming that you have a realistic reason for wanting to do this. |
481,267 | I have imported a .EPF Eclipse preferences file [from here](http://eclipsecolorthemes.org/?view=theme&id=8125) via `File > Import > General > Preferences`. The preferences file changes the colorization for the TeXlipse editor.
How do I remove/reverse the changes that this .EPF import has made? | 2012/09/29 | [
"https://superuser.com/questions/481267",
"https://superuser.com",
"https://superuser.com/users/144591/"
] | You can reverse these theme color changes in one of two ways:
**GUI Method**
* *Short Instructions*: Navigate to `Window -> Preferences`. In the popup that is displayed, expand the menu for the language you're interested in (in this example, it will be Java). Navigate to `Java -> Editor -> Syntax Coloring`. Click the... | I didn't manage to directly reverse the effects of the import but to change the colorization I downloaded the [Eclipse Colorer plugin](http://colorer.sourceforge.net/eclipsecolorer/index.html) which worked a treat. |
2,149,636 | The question I have is from a past exam paper:
Identity if it is an integral domain, whether it admits a finite basis over a coefficient ring, or whether it is isomorphic to another ring.
The first one is
$$R = \mathbb{Z}[x]/(6x^2 -1, 2x-4)$$
My first angle of attack is to find if we can simplify the ideal $I=(6x^2-... | 2017/02/18 | [
"https://math.stackexchange.com/questions/2149636",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/311475/"
] | Here's an intuitive overview:
What is a matrix? A matrix is a *representation* of a linear transformation between two vector spaces. The way we get this representation is by considering the linear transformation of *basis vectors*. If we know the linear transformation of all the basis vectors, we know the transformati... | Note that from theorem we know that two distinct eigenvectors must correspond to two linearly independent vectors. NOT THE OTHER WAY AROUND. That is, two vectors can be linearly independent having the same eigenvalue.
So, suppose the multiplicity of an eigenvalue is 2. Then, this either means that there are two line... |
2,149,636 | The question I have is from a past exam paper:
Identity if it is an integral domain, whether it admits a finite basis over a coefficient ring, or whether it is isomorphic to another ring.
The first one is
$$R = \mathbb{Z}[x]/(6x^2 -1, 2x-4)$$
My first angle of attack is to find if we can simplify the ideal $I=(6x^2-... | 2017/02/18 | [
"https://math.stackexchange.com/questions/2149636",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/311475/"
] | Here's an intuitive overview:
What is a matrix? A matrix is a *representation* of a linear transformation between two vector spaces. The way we get this representation is by considering the linear transformation of *basis vectors*. If we know the linear transformation of all the basis vectors, we know the transformati... | I can't provide any additional intuition for this, but hopefully, some clarity will help you feel more deeply why this is true. This answer is a concrete companion to the intuitive answer by @user156213.
Essentially, this proof boils down to the construction of a particular basis such that the matrix of the linear tra... |
2,149,636 | The question I have is from a past exam paper:
Identity if it is an integral domain, whether it admits a finite basis over a coefficient ring, or whether it is isomorphic to another ring.
The first one is
$$R = \mathbb{Z}[x]/(6x^2 -1, 2x-4)$$
My first angle of attack is to find if we can simplify the ideal $I=(6x^2-... | 2017/02/18 | [
"https://math.stackexchange.com/questions/2149636",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/311475/"
] | Note that from theorem we know that two distinct eigenvectors must correspond to two linearly independent vectors. NOT THE OTHER WAY AROUND. That is, two vectors can be linearly independent having the same eigenvalue.
So, suppose the multiplicity of an eigenvalue is 2. Then, this either means that there are two line... | I can't provide any additional intuition for this, but hopefully, some clarity will help you feel more deeply why this is true. This answer is a concrete companion to the intuitive answer by @user156213.
Essentially, this proof boils down to the construction of a particular basis such that the matrix of the linear tra... |
50,314,709 | I managed to scrape some data from a dynamic website and my output is in json format with only value, How do I modify this code to get both key and value json format and write into a file using python
```
import requests
import json
URL='http://tfda.go.tz/portal/en/trader_module/trader_module/getRegisteredDrugs_produ... | 2018/05/13 | [
"https://Stackoverflow.com/questions/50314709",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5897603/"
] | Try this to get the exact output you have mentioned in your post:
```
import requests
import json
URL='http://tfda.go.tz/portal/en/trader_module/trader_module/getRegisteredDrugs_products'
payload = "draw=1&columns%5B0%5D%5Bdata%5D=no&columns%5B0%5D%5Bname%5D=&columns%5B0%5D%5Bsearchable%5D=True&columns%5B0%5D%5Border... | You first create a dictionary and then convert it to JSON .for example :
```
name ='ali'
family='shahabi'
output={'name' :name ,'family': family}
json.dumps(output)
```
print :
```
'{"name": "ali", "family": "shahabi"}'
```
I suggest convert :
```
output = (dataserial,certno,brndname,clssification, common_name,d... |
23,692,656 | Haskell appears to be extremely picky about whitespace in my main function.
The following compiles nicely
```
module Main where
import System.Environment
main :: IO()
main = do args <- getArgs
putStrLn ("Hello, " ++ args !! 0)
```
But the following two programs give me a parse error
```
module Main wher... | 2014/05/16 | [
"https://Stackoverflow.com/questions/23692656",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1020076/"
] | To add to [Mephy’s answer](https://stackoverflow.com/a/23692683), while Haskell, written in usual Haskell style, *does* care about indentation (called ‘layout’ in the specification), you can write your code in a style such that indentation is ignored:
```
module Main where {
import System.Environment;
main ::... | Haskell does indeed cares about indentation, just like Python. When using the `do` construct, you must have all your actions in the same column. Note you also need to use spaces, not tabs, as '\t' will usually get ignored. |
255,957 | Someone who has been worn down by a harsh working-life? | 2015/06/30 | [
"https://english.stackexchange.com/questions/255957",
"https://english.stackexchange.com",
"https://english.stackexchange.com/users/127228/"
] | Such a person would become ***[careworn](http://dictionary.reference.com/browse/careworn)***.
>
> adjective
>
>
> 1. showing signs of care or worry; fatigued by trouble or anxiety; haggard:
>
>
> "a careworn old woman."
>
>
>
Reference
<http://dictionary.reference.com/browse/careworn> | **workhorse** (*noun*):
* a person or machine that dependably performs hard work over a long period of time [ODO](http://www.oxforddictionaries.com/definition/english/workhorse)
* someone who does a lot of hard or boring work [Macmillan](http://www.macmillandictionary.com/dictionary/british/workhorse) |
255,957 | Someone who has been worn down by a harsh working-life? | 2015/06/30 | [
"https://english.stackexchange.com/questions/255957",
"https://english.stackexchange.com",
"https://english.stackexchange.com/users/127228/"
] | I think ***[toiler](http://www.vocabulary.com/dictionary/toiler)*** may suggest the idea of a hard worker:
>
> * Toilers are people who work long and hard. Any employer would be grateful to have toilers as employees.
> * If you know that to toil is to work hard, then the meaning of toiler won't be a surprise. A toil... | >
> slogger
>
>
> someone who works diligently for long hours. (TFD)
>
>
> |
255,957 | Someone who has been worn down by a harsh working-life? | 2015/06/30 | [
"https://english.stackexchange.com/questions/255957",
"https://english.stackexchange.com",
"https://english.stackexchange.com/users/127228/"
] | Such a person would become ***[careworn](http://dictionary.reference.com/browse/careworn)***.
>
> adjective
>
>
> 1. showing signs of care or worry; fatigued by trouble or anxiety; haggard:
>
>
> "a careworn old woman."
>
>
>
Reference
<http://dictionary.reference.com/browse/careworn> | Well, yes, exactly:
[***downtrodden***](http://www.vocabulary.com/dictionary/downtrodden)
>
> abused or oppressed by people in power
>
>
>
... but you'd be using it in a more literal and less figurative sense. Worn down by work with little reward. |
255,957 | Someone who has been worn down by a harsh working-life? | 2015/06/30 | [
"https://english.stackexchange.com/questions/255957",
"https://english.stackexchange.com",
"https://english.stackexchange.com/users/127228/"
] | Such a person would become ***[careworn](http://dictionary.reference.com/browse/careworn)***.
>
> adjective
>
>
> 1. showing signs of care or worry; fatigued by trouble or anxiety; haggard:
>
>
> "a careworn old woman."
>
>
>
Reference
<http://dictionary.reference.com/browse/careworn> | I think ***[toiler](http://www.vocabulary.com/dictionary/toiler)*** may suggest the idea of a hard worker:
>
> * Toilers are people who work long and hard. Any employer would be grateful to have toilers as employees.
> * If you know that to toil is to work hard, then the meaning of toiler won't be a surprise. A toil... |
255,957 | Someone who has been worn down by a harsh working-life? | 2015/06/30 | [
"https://english.stackexchange.com/questions/255957",
"https://english.stackexchange.com",
"https://english.stackexchange.com/users/127228/"
] | I think **haggard** fits the bill here.
HAGGARD
having a gaunt, wasted, or exhausted appearance, as from prolonged suffering, exertion, or anxiety; worn | >
> slogger
>
>
> someone who works diligently for long hours. (TFD)
>
>
> |
255,957 | Someone who has been worn down by a harsh working-life? | 2015/06/30 | [
"https://english.stackexchange.com/questions/255957",
"https://english.stackexchange.com",
"https://english.stackexchange.com/users/127228/"
] | I think **haggard** fits the bill here.
HAGGARD
having a gaunt, wasted, or exhausted appearance, as from prolonged suffering, exertion, or anxiety; worn | Such a person would become ***[careworn](http://dictionary.reference.com/browse/careworn)***.
>
> adjective
>
>
> 1. showing signs of care or worry; fatigued by trouble or anxiety; haggard:
>
>
> "a careworn old woman."
>
>
>
Reference
<http://dictionary.reference.com/browse/careworn> |
255,957 | Someone who has been worn down by a harsh working-life? | 2015/06/30 | [
"https://english.stackexchange.com/questions/255957",
"https://english.stackexchange.com",
"https://english.stackexchange.com/users/127228/"
] | I think **haggard** fits the bill here.
HAGGARD
having a gaunt, wasted, or exhausted appearance, as from prolonged suffering, exertion, or anxiety; worn | **workhorse** (*noun*):
* a person or machine that dependably performs hard work over a long period of time [ODO](http://www.oxforddictionaries.com/definition/english/workhorse)
* someone who does a lot of hard or boring work [Macmillan](http://www.macmillandictionary.com/dictionary/british/workhorse) |
255,957 | Someone who has been worn down by a harsh working-life? | 2015/06/30 | [
"https://english.stackexchange.com/questions/255957",
"https://english.stackexchange.com",
"https://english.stackexchange.com/users/127228/"
] | I think ***[toiler](http://www.vocabulary.com/dictionary/toiler)*** may suggest the idea of a hard worker:
>
> * Toilers are people who work long and hard. Any employer would be grateful to have toilers as employees.
> * If you know that to toil is to work hard, then the meaning of toiler won't be a surprise. A toil... | Well, yes, exactly:
[***downtrodden***](http://www.vocabulary.com/dictionary/downtrodden)
>
> abused or oppressed by people in power
>
>
>
... but you'd be using it in a more literal and less figurative sense. Worn down by work with little reward. |
255,957 | Someone who has been worn down by a harsh working-life? | 2015/06/30 | [
"https://english.stackexchange.com/questions/255957",
"https://english.stackexchange.com",
"https://english.stackexchange.com/users/127228/"
] | I think **haggard** fits the bill here.
HAGGARD
having a gaunt, wasted, or exhausted appearance, as from prolonged suffering, exertion, or anxiety; worn | I think ***[toiler](http://www.vocabulary.com/dictionary/toiler)*** may suggest the idea of a hard worker:
>
> * Toilers are people who work long and hard. Any employer would be grateful to have toilers as employees.
> * If you know that to toil is to work hard, then the meaning of toiler won't be a surprise. A toil... |
255,957 | Someone who has been worn down by a harsh working-life? | 2015/06/30 | [
"https://english.stackexchange.com/questions/255957",
"https://english.stackexchange.com",
"https://english.stackexchange.com/users/127228/"
] | I think **haggard** fits the bill here.
HAGGARD
having a gaunt, wasted, or exhausted appearance, as from prolonged suffering, exertion, or anxiety; worn | Well, yes, exactly:
[***downtrodden***](http://www.vocabulary.com/dictionary/downtrodden)
>
> abused or oppressed by people in power
>
>
>
... but you'd be using it in a more literal and less figurative sense. Worn down by work with little reward. |
26,890,888 | I'm using google tag manager:
```js
<script>
(function(w, d, s, l, i) {
w[l] = w[l] || [];
w[l].push({
'gtm.start': new Date().getTime(),
event: 'gtm.js'
});
var f = d.getElementsByTagName(s)[0],
j = d.createElement(s),
dl = l != 'dataLayer' ? '&l=' + l : '';
j.async... | 2014/11/12 | [
"https://Stackoverflow.com/questions/26890888",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4199129/"
] | You may want to make sure that your tags (especially custom tags) are not specifying the http protocol. You can make URLs work on both http and https by not using the protocol portion of the URL. For example:
```
//www.google.com/
``` | If your are using scully, this issue is discussed [here](https://github.com/scullyio/scully/issues/291).
Scully generates renders using http. So, the google tag manager script in your header will contain http request in all pages.
Solution 1
==========
As SanderElias pointed out in the [issue](https://github.com/scu... |
5,647,270 | I have a small issue with integrating uploadify with zendframework. I have found a lot of posts about this issue but none of them able to help me.
in uploadify script when I use this
```
'script': '/uploadtest.php',
```
It works perfectly alright.
but when I use this and call a action in controller like this.
... | 2011/04/13 | [
"https://Stackoverflow.com/questions/5647270",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/376702/"
] | I figure out the solution. It was stupid mistake. my controller was not accessible for every one and it was returning the login page as response. so I change the rights in my ACL and it works fine.
I recommend Charles Proxy (http://www.charlesproxy.com) for debugging which helped me a lot to read the response from swf... | I had problem with the same error
>
> cannot assemble. reversed route is not specified
>
>
>
The solution, like they wrote in zend manual
"Since regex patterns are not easily reversed, you will need to prepare a reverse URL if you wish to use a URL helper or even an assemble method of this class. This reversed p... |
13,655,916 | I am trying to use RestyGWT's JsonEncoderDecoder to encode/decode JSON objects. From their documentation I was able to do:
```
public interface PersonCodec extends JsonEncoderDecoder<PersonCodec>> {}
```
and use the encode/decode functions. However, when I do:
```
public interface PersonListCodec extends JsonEncode... | 2012/12/01 | [
"https://Stackoverflow.com/questions/13655916",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1186955/"
] | I was able to encode my list using the following piece of code:
```
JSONArray batch = new JSONArray();
int idx=0;
for (Pojo i : buffer) {
batch.set(idx++, CODEC.encode(i));
}
``` | I wrap my List in an Object since I am in control of the output.
```
@XmlRootElement
public class WrapperResult {
protected List<Person> result;
}
```
Then I can encode and decode lists with no problem. |
12,355,231 | I work on an authentication component for my application. I'm using the Apache Shiro API with salted password.
I create a new user with the salt like in this example :
```
ByteSource salt = randomNumberGenerator.nextBytes(32);
byte[] byteTabSalt = salt.getBytes();
String strSalt = byteArrayToHexString(byteTa... | 2012/09/10 | [
"https://Stackoverflow.com/questions/12355231",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1269325/"
] | SaltedAuthenticationInfo
------------------------
`SaltedAuthenticationInfo` is an interface. The Shiro API provides a number of default implementations for convenience. As much as possible try to use one of the default implementations; avoid creating your own.
I suggest `SimpleAuthenticationInfo` which implements ... | My error was to not create correctly the AuthenticationInfo which was compare the AuthenticationToken. So in the doGetAuthenticationInfo method of my own realm I do this :
```
Object principal = arg0.getPrincipal();
Object credentials = arg0.getCredentials();
String realmName = this.getName(); // to get the realm ... |
27,556,104 | In my program an array `fClasses` of fixed length [7] of objects is created, each object is a class `FClass` that contains 3 `Strings`, an `int`, and an `int[]`. These values are read from a .txt file and added to a specific index of the array based on the value of the `int`. There are less entries in the .txt file the... | 2014/12/18 | [
"https://Stackoverflow.com/questions/27556104",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4375799/"
] | You need your own `Comparator` implementation and check for nulls and return 0
```
Arrays.sort(fClasses, new Comparator<FClass>() {
@Override
public int compare(FClass o1, FClass o2) {
if (o1 == null && o2 == null) {
return 0;
}
if (o1 == null) {
return 1;
... | You have to create a `Comparator<FClass>`, rather than use a `Comparable<FClass>`.
```
public class FClassComparator implements Comparator<FClass>
{
public int compare(FClass left, FClass right) {
// Swap -1 and 1 here if you want nulls to move to the front.
if (left == null) return right == null ... |
27,556,104 | In my program an array `fClasses` of fixed length [7] of objects is created, each object is a class `FClass` that contains 3 `Strings`, an `int`, and an `int[]`. These values are read from a .txt file and added to a specific index of the array based on the value of the `int`. There are less entries in the .txt file the... | 2014/12/18 | [
"https://Stackoverflow.com/questions/27556104",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4375799/"
] | You need your own `Comparator` implementation and check for nulls and return 0
```
Arrays.sort(fClasses, new Comparator<FClass>() {
@Override
public int compare(FClass o1, FClass o2) {
if (o1 == null && o2 == null) {
return 0;
}
if (o1 == null) {
return 1;
... | Using Java 8, you can easily build the comparator you need:
```
Arrays.sort(fClasses, Comparator.nullsFirst(Comparator.naturalOrder()));
```
Use `nullsLast` instead if that's what you want, of course. |
27,556,104 | In my program an array `fClasses` of fixed length [7] of objects is created, each object is a class `FClass` that contains 3 `Strings`, an `int`, and an `int[]`. These values are read from a .txt file and added to a specific index of the array based on the value of the `int`. There are less entries in the .txt file the... | 2014/12/18 | [
"https://Stackoverflow.com/questions/27556104",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4375799/"
] | You need your own `Comparator` implementation and check for nulls and return 0
```
Arrays.sort(fClasses, new Comparator<FClass>() {
@Override
public int compare(FClass o1, FClass o2) {
if (o1 == null && o2 == null) {
return 0;
}
if (o1 == null) {
return 1;
... | With [Apache Commons Collections 4](https://commons.apache.org/proper/commons-collections/) you can use [ComparatorUtils](https://commons.apache.org/proper/commons-collections/apidocs/org/apache/commons/collections4/ComparatorUtils.html) to do that:
```
Collections.sort(arr, ComparatorUtils.nullLowComparator(Comparato... |
27,556,104 | In my program an array `fClasses` of fixed length [7] of objects is created, each object is a class `FClass` that contains 3 `Strings`, an `int`, and an `int[]`. These values are read from a .txt file and added to a specific index of the array based on the value of the `int`. There are less entries in the .txt file the... | 2014/12/18 | [
"https://Stackoverflow.com/questions/27556104",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4375799/"
] | You need your own `Comparator` implementation and check for nulls and return 0
```
Arrays.sort(fClasses, new Comparator<FClass>() {
@Override
public int compare(FClass o1, FClass o2) {
if (o1 == null && o2 == null) {
return 0;
}
if (o1 == null) {
return 1;
... | By importing the [org.apache.commons.collections.comparators](https://commons.apache.org/proper/commons-collections/javadocs/api-2.1.1/org/apache/commons/collections/comparators/NullComparator.html) package of the
[Apache 2.1.1 Release](https://commons.apache.org/proper/commons-collections/javadocs/api-2.1.1/overview-... |
27,556,104 | In my program an array `fClasses` of fixed length [7] of objects is created, each object is a class `FClass` that contains 3 `Strings`, an `int`, and an `int[]`. These values are read from a .txt file and added to a specific index of the array based on the value of the `int`. There are less entries in the .txt file the... | 2014/12/18 | [
"https://Stackoverflow.com/questions/27556104",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4375799/"
] | Using Java 8, you can easily build the comparator you need:
```
Arrays.sort(fClasses, Comparator.nullsFirst(Comparator.naturalOrder()));
```
Use `nullsLast` instead if that's what you want, of course. | You have to create a `Comparator<FClass>`, rather than use a `Comparable<FClass>`.
```
public class FClassComparator implements Comparator<FClass>
{
public int compare(FClass left, FClass right) {
// Swap -1 and 1 here if you want nulls to move to the front.
if (left == null) return right == null ... |
27,556,104 | In my program an array `fClasses` of fixed length [7] of objects is created, each object is a class `FClass` that contains 3 `Strings`, an `int`, and an `int[]`. These values are read from a .txt file and added to a specific index of the array based on the value of the `int`. There are less entries in the .txt file the... | 2014/12/18 | [
"https://Stackoverflow.com/questions/27556104",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4375799/"
] | You have to create a `Comparator<FClass>`, rather than use a `Comparable<FClass>`.
```
public class FClassComparator implements Comparator<FClass>
{
public int compare(FClass left, FClass right) {
// Swap -1 and 1 here if you want nulls to move to the front.
if (left == null) return right == null ... | With [Apache Commons Collections 4](https://commons.apache.org/proper/commons-collections/) you can use [ComparatorUtils](https://commons.apache.org/proper/commons-collections/apidocs/org/apache/commons/collections4/ComparatorUtils.html) to do that:
```
Collections.sort(arr, ComparatorUtils.nullLowComparator(Comparato... |
27,556,104 | In my program an array `fClasses` of fixed length [7] of objects is created, each object is a class `FClass` that contains 3 `Strings`, an `int`, and an `int[]`. These values are read from a .txt file and added to a specific index of the array based on the value of the `int`. There are less entries in the .txt file the... | 2014/12/18 | [
"https://Stackoverflow.com/questions/27556104",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4375799/"
] | You have to create a `Comparator<FClass>`, rather than use a `Comparable<FClass>`.
```
public class FClassComparator implements Comparator<FClass>
{
public int compare(FClass left, FClass right) {
// Swap -1 and 1 here if you want nulls to move to the front.
if (left == null) return right == null ... | By importing the [org.apache.commons.collections.comparators](https://commons.apache.org/proper/commons-collections/javadocs/api-2.1.1/org/apache/commons/collections/comparators/NullComparator.html) package of the
[Apache 2.1.1 Release](https://commons.apache.org/proper/commons-collections/javadocs/api-2.1.1/overview-... |
27,556,104 | In my program an array `fClasses` of fixed length [7] of objects is created, each object is a class `FClass` that contains 3 `Strings`, an `int`, and an `int[]`. These values are read from a .txt file and added to a specific index of the array based on the value of the `int`. There are less entries in the .txt file the... | 2014/12/18 | [
"https://Stackoverflow.com/questions/27556104",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4375799/"
] | Using Java 8, you can easily build the comparator you need:
```
Arrays.sort(fClasses, Comparator.nullsFirst(Comparator.naturalOrder()));
```
Use `nullsLast` instead if that's what you want, of course. | With [Apache Commons Collections 4](https://commons.apache.org/proper/commons-collections/) you can use [ComparatorUtils](https://commons.apache.org/proper/commons-collections/apidocs/org/apache/commons/collections4/ComparatorUtils.html) to do that:
```
Collections.sort(arr, ComparatorUtils.nullLowComparator(Comparato... |
27,556,104 | In my program an array `fClasses` of fixed length [7] of objects is created, each object is a class `FClass` that contains 3 `Strings`, an `int`, and an `int[]`. These values are read from a .txt file and added to a specific index of the array based on the value of the `int`. There are less entries in the .txt file the... | 2014/12/18 | [
"https://Stackoverflow.com/questions/27556104",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4375799/"
] | Using Java 8, you can easily build the comparator you need:
```
Arrays.sort(fClasses, Comparator.nullsFirst(Comparator.naturalOrder()));
```
Use `nullsLast` instead if that's what you want, of course. | By importing the [org.apache.commons.collections.comparators](https://commons.apache.org/proper/commons-collections/javadocs/api-2.1.1/org/apache/commons/collections/comparators/NullComparator.html) package of the
[Apache 2.1.1 Release](https://commons.apache.org/proper/commons-collections/javadocs/api-2.1.1/overview-... |
27,556,104 | In my program an array `fClasses` of fixed length [7] of objects is created, each object is a class `FClass` that contains 3 `Strings`, an `int`, and an `int[]`. These values are read from a .txt file and added to a specific index of the array based on the value of the `int`. There are less entries in the .txt file the... | 2014/12/18 | [
"https://Stackoverflow.com/questions/27556104",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4375799/"
] | With [Apache Commons Collections 4](https://commons.apache.org/proper/commons-collections/) you can use [ComparatorUtils](https://commons.apache.org/proper/commons-collections/apidocs/org/apache/commons/collections4/ComparatorUtils.html) to do that:
```
Collections.sort(arr, ComparatorUtils.nullLowComparator(Comparato... | By importing the [org.apache.commons.collections.comparators](https://commons.apache.org/proper/commons-collections/javadocs/api-2.1.1/org/apache/commons/collections/comparators/NullComparator.html) package of the
[Apache 2.1.1 Release](https://commons.apache.org/proper/commons-collections/javadocs/api-2.1.1/overview-... |
3,550,337 | Could someone give me some guidance on when I should use `WITH (NOLOCK)` as opposed to `SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED`
What are the pros/cons of each? Are there any unintended consequences you've run into using one as opposed to the other? | 2010/08/23 | [
"https://Stackoverflow.com/questions/3550337",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/195583/"
] | They are the same thing. If you use the `set transaction isolation level` statement, it will apply to all the tables in the connection, so if you only want a `nolock` on one or two tables use that; otherwise use the other.
Both will give you dirty reads. If you are okay with that, then use them. If you can't have dir... | As you have to use WITH (NOLOCK) for each table it might be annoying to write it in every FROM or JOIN clause. However it has a reason why it is called a "dirty" read. So you really should know when you do one, and not set it as default for the session scope. Why?
Forgetting a WITH (NOLOCK) might not affect your prog... |
3,550,337 | Could someone give me some guidance on when I should use `WITH (NOLOCK)` as opposed to `SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED`
What are the pros/cons of each? Are there any unintended consequences you've run into using one as opposed to the other? | 2010/08/23 | [
"https://Stackoverflow.com/questions/3550337",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/195583/"
] | They are the same thing. If you use the `set transaction isolation level` statement, it will apply to all the tables in the connection, so if you only want a `nolock` on one or two tables use that; otherwise use the other.
Both will give you dirty reads. If you are okay with that, then use them. If you can't have dir... | You cannot use Set Transaction Isolation Level Read Uncommitted in a View (you can only have one script in there in fact), so you would have to use (nolock) if dirty rows should be included. |
3,550,337 | Could someone give me some guidance on when I should use `WITH (NOLOCK)` as opposed to `SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED`
What are the pros/cons of each? Are there any unintended consequences you've run into using one as opposed to the other? | 2010/08/23 | [
"https://Stackoverflow.com/questions/3550337",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/195583/"
] | WITH (NOLOCK) is a hint on a table level. Setting the transaction isolation level to READ\_UNCOMMITTED with affect the connection. The difference is in terms of scope. See READUNCOMMITTED and NOLOCK in the SQL Server documentation here:
<http://technet.microsoft.com/en-us/library/ms187373.aspx>
For TRANSACTION ISOLAT... | You cannot use Set Transaction Isolation Level Read Uncommitted in a View (you can only have one script in there in fact), so you would have to use (nolock) if dirty rows should be included. |
3,550,337 | Could someone give me some guidance on when I should use `WITH (NOLOCK)` as opposed to `SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED`
What are the pros/cons of each? Are there any unintended consequences you've run into using one as opposed to the other? | 2010/08/23 | [
"https://Stackoverflow.com/questions/3550337",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/195583/"
] | They are the same thing. If you use the `set transaction isolation level` statement, it will apply to all the tables in the connection, so if you only want a `nolock` on one or two tables use that; otherwise use the other.
Both will give you dirty reads. If you are okay with that, then use them. If you can't have dir... | WITH (NOLOCK) is a hint on a table level. Setting the transaction isolation level to READ\_UNCOMMITTED with affect the connection. The difference is in terms of scope. See READUNCOMMITTED and NOLOCK in the SQL Server documentation here:
<http://technet.microsoft.com/en-us/library/ms187373.aspx>
For TRANSACTION ISOLAT... |
3,550,337 | Could someone give me some guidance on when I should use `WITH (NOLOCK)` as opposed to `SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED`
What are the pros/cons of each? Are there any unintended consequences you've run into using one as opposed to the other? | 2010/08/23 | [
"https://Stackoverflow.com/questions/3550337",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/195583/"
] | WITH (NOLOCK) is a hint on a table level. Setting the transaction isolation level to READ\_UNCOMMITTED with affect the connection. The difference is in terms of scope. See READUNCOMMITTED and NOLOCK in the SQL Server documentation here:
<http://technet.microsoft.com/en-us/library/ms187373.aspx>
For TRANSACTION ISOLAT... | * NOLOCK is local to the table (or views etc)
* READ UNCOMMITTED is per session/connection
As for guidelines... a random search from StackOverflow and the electric interweb...
* [Is the NOLOCK (Sql Server hint) bad practice?](https://stackoverflow.com/questions/1452996/is-the-nolock-sql-server-hint-bad-practice)
* [W... |
3,550,337 | Could someone give me some guidance on when I should use `WITH (NOLOCK)` as opposed to `SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED`
What are the pros/cons of each? Are there any unintended consequences you've run into using one as opposed to the other? | 2010/08/23 | [
"https://Stackoverflow.com/questions/3550337",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/195583/"
] | * NOLOCK is local to the table (or views etc)
* READ UNCOMMITTED is per session/connection
As for guidelines... a random search from StackOverflow and the electric interweb...
* [Is the NOLOCK (Sql Server hint) bad practice?](https://stackoverflow.com/questions/1452996/is-the-nolock-sql-server-hint-bad-practice)
* [W... | As you have to use WITH (NOLOCK) for each table it might be annoying to write it in every FROM or JOIN clause. However it has a reason why it is called a "dirty" read. So you really should know when you do one, and not set it as default for the session scope. Why?
Forgetting a WITH (NOLOCK) might not affect your prog... |
3,550,337 | Could someone give me some guidance on when I should use `WITH (NOLOCK)` as opposed to `SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED`
What are the pros/cons of each? Are there any unintended consequences you've run into using one as opposed to the other? | 2010/08/23 | [
"https://Stackoverflow.com/questions/3550337",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/195583/"
] | WITH (NOLOCK) is a hint on a table level. Setting the transaction isolation level to READ\_UNCOMMITTED with affect the connection. The difference is in terms of scope. See READUNCOMMITTED and NOLOCK in the SQL Server documentation here:
<http://technet.microsoft.com/en-us/library/ms187373.aspx>
For TRANSACTION ISOLAT... | As you have to use WITH (NOLOCK) for each table it might be annoying to write it in every FROM or JOIN clause. However it has a reason why it is called a "dirty" read. So you really should know when you do one, and not set it as default for the session scope. Why?
Forgetting a WITH (NOLOCK) might not affect your prog... |
3,550,337 | Could someone give me some guidance on when I should use `WITH (NOLOCK)` as opposed to `SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED`
What are the pros/cons of each? Are there any unintended consequences you've run into using one as opposed to the other? | 2010/08/23 | [
"https://Stackoverflow.com/questions/3550337",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/195583/"
] | To my knowledge the only difference is the scope of the effects as Strommy said. NOLOCK hint on a table and the READ UNCOMMITTED on the session.
As to problems that can occur, it's all about consistency. If you care then be aware that you could get what is called dirty reads which could influence other data being man... | As you have to use WITH (NOLOCK) for each table it might be annoying to write it in every FROM or JOIN clause. However it has a reason why it is called a "dirty" read. So you really should know when you do one, and not set it as default for the session scope. Why?
Forgetting a WITH (NOLOCK) might not affect your prog... |
3,550,337 | Could someone give me some guidance on when I should use `WITH (NOLOCK)` as opposed to `SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED`
What are the pros/cons of each? Are there any unintended consequences you've run into using one as opposed to the other? | 2010/08/23 | [
"https://Stackoverflow.com/questions/3550337",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/195583/"
] | WITH (NOLOCK) is a hint on a table level. Setting the transaction isolation level to READ\_UNCOMMITTED with affect the connection. The difference is in terms of scope. See READUNCOMMITTED and NOLOCK in the SQL Server documentation here:
<http://technet.microsoft.com/en-us/library/ms187373.aspx>
For TRANSACTION ISOLAT... | To my knowledge the only difference is the scope of the effects as Strommy said. NOLOCK hint on a table and the READ UNCOMMITTED on the session.
As to problems that can occur, it's all about consistency. If you care then be aware that you could get what is called dirty reads which could influence other data being man... |
3,550,337 | Could someone give me some guidance on when I should use `WITH (NOLOCK)` as opposed to `SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED`
What are the pros/cons of each? Are there any unintended consequences you've run into using one as opposed to the other? | 2010/08/23 | [
"https://Stackoverflow.com/questions/3550337",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/195583/"
] | They are the same thing. If you use the `set transaction isolation level` statement, it will apply to all the tables in the connection, so if you only want a `nolock` on one or two tables use that; otherwise use the other.
Both will give you dirty reads. If you are okay with that, then use them. If you can't have dir... | * NOLOCK is local to the table (or views etc)
* READ UNCOMMITTED is per session/connection
As for guidelines... a random search from StackOverflow and the electric interweb...
* [Is the NOLOCK (Sql Server hint) bad practice?](https://stackoverflow.com/questions/1452996/is-the-nolock-sql-server-hint-bad-practice)
* [W... |
20,594,281 | I have simple question from OCJP
Given:
```
1. public class TestSeven extends Thread {
2. private static int x;
3. public synchronized void doThings() {
4. int current = x;
5. current++;
6. x = current;
7. }
8. public void run() {
9. doThings();
10. }
11. }
```
Whi... | 2013/12/15 | [
"https://Stackoverflow.com/questions/20594281",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3104319/"
] | The problem is that `x` is a static variable, that is thus shared by all the threads. And since all the threads are not synchronized on a single object (every thread uses `this` as the lock), nothing prevents two threads to execute the `doThings()` method in parallel. Two threads might thus read the value of x in paral... | No, because it accesses the static field `x` non-atomically. You could also make it threadsafe by using an [java.util.concurrent.atomic.AtomicInteger](http://docs.oracle.com/javase/6/docs/api/java/util/concurrent/atomic/AtomicInteger.html#getAndIncrement%28%29) with `getAndIncrement()`.
But the original form isn't, co... |
20,594,281 | I have simple question from OCJP
Given:
```
1. public class TestSeven extends Thread {
2. private static int x;
3. public synchronized void doThings() {
4. int current = x;
5. current++;
6. x = current;
7. }
8. public void run() {
9. doThings();
10. }
11. }
```
Whi... | 2013/12/15 | [
"https://Stackoverflow.com/questions/20594281",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3104319/"
] | A `synchronized` associated to an object's instance's method does not care of static variables, that are class's variables.
Indeed, in your case, the mutated variable is a `static` one: `x`
In order to synchronize a static variable, both easiest ways in this snippet code would be to declare `doThings()` as static (so ... | No, because it accesses the static field `x` non-atomically. You could also make it threadsafe by using an [java.util.concurrent.atomic.AtomicInteger](http://docs.oracle.com/javase/6/docs/api/java/util/concurrent/atomic/AtomicInteger.html#getAndIncrement%28%29) with `getAndIncrement()`.
But the original form isn't, co... |
20,594,281 | I have simple question from OCJP
Given:
```
1. public class TestSeven extends Thread {
2. private static int x;
3. public synchronized void doThings() {
4. int current = x;
5. current++;
6. x = current;
7. }
8. public void run() {
9. doThings();
10. }
11. }
```
Whi... | 2013/12/15 | [
"https://Stackoverflow.com/questions/20594281",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3104319/"
] | No, That method `doThings()` is not thread safe, because, it was synchronized on `this` instance means different object will use **them** as the lock to access it. So no synchronization is there. If that method `doThings()` uses a shared lock to access the method, then, this method is perfectly synchronized. Or, making... | No, because it accesses the static field `x` non-atomically. You could also make it threadsafe by using an [java.util.concurrent.atomic.AtomicInteger](http://docs.oracle.com/javase/6/docs/api/java/util/concurrent/atomic/AtomicInteger.html#getAndIncrement%28%29) with `getAndIncrement()`.
But the original form isn't, co... |
20,594,281 | I have simple question from OCJP
Given:
```
1. public class TestSeven extends Thread {
2. private static int x;
3. public synchronized void doThings() {
4. int current = x;
5. current++;
6. x = current;
7. }
8. public void run() {
9. doThings();
10. }
11. }
```
Whi... | 2013/12/15 | [
"https://Stackoverflow.com/questions/20594281",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3104319/"
] | No, because it accesses the static field `x` non-atomically. You could also make it threadsafe by using an [java.util.concurrent.atomic.AtomicInteger](http://docs.oracle.com/javase/6/docs/api/java/util/concurrent/atomic/AtomicInteger.html#getAndIncrement%28%29) with `getAndIncrement()`.
But the original form isn't, co... | Though the answers are more on synchronized method of doThings(), which is correct, but in particular the static member x, “may be” cached with the values in respective Thread objects. The x will not be truely shared among all threads until it is volatile. |
20,594,281 | I have simple question from OCJP
Given:
```
1. public class TestSeven extends Thread {
2. private static int x;
3. public synchronized void doThings() {
4. int current = x;
5. current++;
6. x = current;
7. }
8. public void run() {
9. doThings();
10. }
11. }
```
Whi... | 2013/12/15 | [
"https://Stackoverflow.com/questions/20594281",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3104319/"
] | The problem is that `x` is a static variable, that is thus shared by all the threads. And since all the threads are not synchronized on a single object (every thread uses `this` as the lock), nothing prevents two threads to execute the `doThings()` method in parallel. Two threads might thus read the value of x in paral... | A `synchronized` associated to an object's instance's method does not care of static variables, that are class's variables.
Indeed, in your case, the mutated variable is a `static` one: `x`
In order to synchronize a static variable, both easiest ways in this snippet code would be to declare `doThings()` as static (so ... |
20,594,281 | I have simple question from OCJP
Given:
```
1. public class TestSeven extends Thread {
2. private static int x;
3. public synchronized void doThings() {
4. int current = x;
5. current++;
6. x = current;
7. }
8. public void run() {
9. doThings();
10. }
11. }
```
Whi... | 2013/12/15 | [
"https://Stackoverflow.com/questions/20594281",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3104319/"
] | The problem is that `x` is a static variable, that is thus shared by all the threads. And since all the threads are not synchronized on a single object (every thread uses `this` as the lock), nothing prevents two threads to execute the `doThings()` method in parallel. Two threads might thus read the value of x in paral... | No, That method `doThings()` is not thread safe, because, it was synchronized on `this` instance means different object will use **them** as the lock to access it. So no synchronization is there. If that method `doThings()` uses a shared lock to access the method, then, this method is perfectly synchronized. Or, making... |
20,594,281 | I have simple question from OCJP
Given:
```
1. public class TestSeven extends Thread {
2. private static int x;
3. public synchronized void doThings() {
4. int current = x;
5. current++;
6. x = current;
7. }
8. public void run() {
9. doThings();
10. }
11. }
```
Whi... | 2013/12/15 | [
"https://Stackoverflow.com/questions/20594281",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3104319/"
] | The problem is that `x` is a static variable, that is thus shared by all the threads. And since all the threads are not synchronized on a single object (every thread uses `this` as the lock), nothing prevents two threads to execute the `doThings()` method in parallel. Two threads might thus read the value of x in paral... | Though the answers are more on synchronized method of doThings(), which is correct, but in particular the static member x, “may be” cached with the values in respective Thread objects. The x will not be truely shared among all threads until it is volatile. |
20,594,281 | I have simple question from OCJP
Given:
```
1. public class TestSeven extends Thread {
2. private static int x;
3. public synchronized void doThings() {
4. int current = x;
5. current++;
6. x = current;
7. }
8. public void run() {
9. doThings();
10. }
11. }
```
Whi... | 2013/12/15 | [
"https://Stackoverflow.com/questions/20594281",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3104319/"
] | A `synchronized` associated to an object's instance's method does not care of static variables, that are class's variables.
Indeed, in your case, the mutated variable is a `static` one: `x`
In order to synchronize a static variable, both easiest ways in this snippet code would be to declare `doThings()` as static (so ... | Though the answers are more on synchronized method of doThings(), which is correct, but in particular the static member x, “may be” cached with the values in respective Thread objects. The x will not be truely shared among all threads until it is volatile. |
20,594,281 | I have simple question from OCJP
Given:
```
1. public class TestSeven extends Thread {
2. private static int x;
3. public synchronized void doThings() {
4. int current = x;
5. current++;
6. x = current;
7. }
8. public void run() {
9. doThings();
10. }
11. }
```
Whi... | 2013/12/15 | [
"https://Stackoverflow.com/questions/20594281",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3104319/"
] | No, That method `doThings()` is not thread safe, because, it was synchronized on `this` instance means different object will use **them** as the lock to access it. So no synchronization is there. If that method `doThings()` uses a shared lock to access the method, then, this method is perfectly synchronized. Or, making... | Though the answers are more on synchronized method of doThings(), which is correct, but in particular the static member x, “may be” cached with the values in respective Thread objects. The x will not be truely shared among all threads until it is volatile. |
1,382,553 | Given an integer $n$ between 1 and 1000000, how do you directly prove that $n$ has at most 19 prime factors (with multiplicity)?
I'm quite stuck on how to do this. I can understand the base case which is $n=2$. This obviously is correct, but I don't know how to continue with this proof from here on out.
Any help is ... | 2015/08/03 | [
"https://math.stackexchange.com/questions/1382553",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/249468/"
] | Assume that there exists an integer $n\le 1000000$ with $20$ prime factors. Then each of these prime factors is at least $2$, so $n$ is at least the product of twenty $2$s, that is, $2^{20}=1048576>1000000$; this contradicts our hypothesis and therefore there is no such integer. | $2$ is the smallest prime number. So the smallest possible number with 20 prime factors is $2\cdot 2\cdot 2\cdot 2\cdot 2......\cdot 2\cdot 2$ which is $2^{20}$ which is more than your number |
491,318 | I have a laptop with 2 harddrive bays. One bay holds a smaller WD Scorpio. This is the boot drive that holds the operating system (Windows 7), and it no longer large enough. The other bay holds a newer (3 months old) Hitachi hd500gb that I was using for storage and backup of programs. This drive is not bootable.
I wa... | 2012/10/22 | [
"https://superuser.com/questions/491318",
"https://superuser.com",
"https://superuser.com/users/167027/"
] | Perhaps your tab size is set to 2 spaces.
Click on menu "settings" then "Preferences...", then switch to tab "Language menu/Tab settings", check the value of "Tab size" on the right bottom | Make sure you don't have the 'Replace by space' checkbox set next to the 'Tab Settings' in the Preferences->Language Menu/Tab settings. |
54,539,478 | When I have an interface with only one field (`val`)
```
interface ValObj {
val: number
}
```
creating an object with another field yields an error.
```
const someObj: ValObj = {
val: 5,
someStr:"hello"
}
```
But this principle isn't consistent when we return a value from a function. Defining a function ... | 2019/02/05 | [
"https://Stackoverflow.com/questions/54539478",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7224430/"
] | The error you are seeing in the first example is a product of excess property checks. Excess propeties are checked only when an object literal is directly assigned to something of a given type.
In this case:
```
const func: () => ValObj =
() => ({
val: 5,
someStr: "sdf"
})
```
The way typing is done i... | You are not defining the return type of the inner method call. It's default to `any` change it to
```
const func: () => ValObj =
(): ValObj => ({
val: 5,
someStr: "sdf"
})
``` |
50,661,663 | I'm currently trying to figure out the way to produce equivalent assembly code from corresponding C source file.
I've been using the C language for several years, but have little experience with assembly language.
I was able to output the assembly code using the `-S` option in gcc. However, the resulting assembly cod... | 2018/06/02 | [
"https://Stackoverflow.com/questions/50661663",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9886444/"
] | `_exp` is the standard math library function [`double exp(double)`](http://en.cppreference.com/w/c/numeric/math/exp); apparently you're on a platform that prepends a leading underscore to C symbol names.
Given a `.s` that calls some library functions, build it the same way you would a `.c` file that calls library func... | It is not possible in general, there are exceptions sure, I could craft one so that means other folks can too, but it isnt an interesting program.
Normally your C program, your main() entry point is only a percentage of the code. There is a bootstrap that contains the actual entry point for the operating system to la... |
9,300,893 | I'm trying to make a dropdown suggestion box using jQuery. I have a function that looks like this:
```
function onChoiceSelected(index){
var item = $("#suggestionBox li").get(index);
alert("inner html: "+item.html());
currentSuggestionInput.val(item.html());
hideSuggestions();
}
```
For some reason, ... | 2012/02/15 | [
"https://Stackoverflow.com/questions/9300893",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/492848/"
] | The `get` method returns the DOM node at the index specified. Since you are then trying to call a jQuery method on that, it will fail.
The `eq` method should do what you want. It will have the same effect as your `get` call, but it will return a jQuery object rather than the DOM node itself. | You want to use [`eq()`](http://api.jquery.com/eq/), not [`get()`](http://api.jquery.com/get/).
```
var item = $("#suggestionBox li").eq(index);
```
* [`get()`](http://api.jquery.com/get/) is DOM node
* [`eq()`](http://api.jquery.com/eq/) is the jQuery object. |
9,300,893 | I'm trying to make a dropdown suggestion box using jQuery. I have a function that looks like this:
```
function onChoiceSelected(index){
var item = $("#suggestionBox li").get(index);
alert("inner html: "+item.html());
currentSuggestionInput.val(item.html());
hideSuggestions();
}
```
For some reason, ... | 2012/02/15 | [
"https://Stackoverflow.com/questions/9300893",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/492848/"
] | You want to use [`eq()`](http://api.jquery.com/eq/), not [`get()`](http://api.jquery.com/get/).
```
var item = $("#suggestionBox li").eq(index);
```
* [`get()`](http://api.jquery.com/get/) is DOM node
* [`eq()`](http://api.jquery.com/eq/) is the jQuery object. | You should be seeing errors in the console of firebug.
You can also use tools like console.log(index) in firebug, as well as run the javascript directly from the console screen.
What value are you getting for index? |
9,300,893 | I'm trying to make a dropdown suggestion box using jQuery. I have a function that looks like this:
```
function onChoiceSelected(index){
var item = $("#suggestionBox li").get(index);
alert("inner html: "+item.html());
currentSuggestionInput.val(item.html());
hideSuggestions();
}
```
For some reason, ... | 2012/02/15 | [
"https://Stackoverflow.com/questions/9300893",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/492848/"
] | You want to use [`eq()`](http://api.jquery.com/eq/), not [`get()`](http://api.jquery.com/get/).
```
var item = $("#suggestionBox li").eq(index);
```
* [`get()`](http://api.jquery.com/get/) is DOM node
* [`eq()`](http://api.jquery.com/eq/) is the jQuery object. | do it as
```
function onChoiceSelected(index){
var item = $($("#suggestionBox li").get(index));
alert("inner html: "+item.html());
currentSuggestionInput.val(item.html());
hideSuggestions();
}
``` |
9,300,893 | I'm trying to make a dropdown suggestion box using jQuery. I have a function that looks like this:
```
function onChoiceSelected(index){
var item = $("#suggestionBox li").get(index);
alert("inner html: "+item.html());
currentSuggestionInput.val(item.html());
hideSuggestions();
}
```
For some reason, ... | 2012/02/15 | [
"https://Stackoverflow.com/questions/9300893",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/492848/"
] | The `get` method returns the DOM node at the index specified. Since you are then trying to call a jQuery method on that, it will fail.
The `eq` method should do what you want. It will have the same effect as your `get` call, but it will return a jQuery object rather than the DOM node itself. | You should be seeing errors in the console of firebug.
You can also use tools like console.log(index) in firebug, as well as run the javascript directly from the console screen.
What value are you getting for index? |
9,300,893 | I'm trying to make a dropdown suggestion box using jQuery. I have a function that looks like this:
```
function onChoiceSelected(index){
var item = $("#suggestionBox li").get(index);
alert("inner html: "+item.html());
currentSuggestionInput.val(item.html());
hideSuggestions();
}
```
For some reason, ... | 2012/02/15 | [
"https://Stackoverflow.com/questions/9300893",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/492848/"
] | The `get` method returns the DOM node at the index specified. Since you are then trying to call a jQuery method on that, it will fail.
The `eq` method should do what you want. It will have the same effect as your `get` call, but it will return a jQuery object rather than the DOM node itself. | do it as
```
function onChoiceSelected(index){
var item = $($("#suggestionBox li").get(index));
alert("inner html: "+item.html());
currentSuggestionInput.val(item.html());
hideSuggestions();
}
``` |
9,300,893 | I'm trying to make a dropdown suggestion box using jQuery. I have a function that looks like this:
```
function onChoiceSelected(index){
var item = $("#suggestionBox li").get(index);
alert("inner html: "+item.html());
currentSuggestionInput.val(item.html());
hideSuggestions();
}
```
For some reason, ... | 2012/02/15 | [
"https://Stackoverflow.com/questions/9300893",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/492848/"
] | You should be seeing errors in the console of firebug.
You can also use tools like console.log(index) in firebug, as well as run the javascript directly from the console screen.
What value are you getting for index? | do it as
```
function onChoiceSelected(index){
var item = $($("#suggestionBox li").get(index));
alert("inner html: "+item.html());
currentSuggestionInput.val(item.html());
hideSuggestions();
}
``` |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.