qid
int64 1
74.6M
| question
stringlengths 45
24.2k
| date
stringlengths 10
10
| metadata
stringlengths 101
178
| response_j
stringlengths 32
23.2k
| response_k
stringlengths 21
13.2k
|
---|---|---|---|---|---|
95,202 | I have a Gateway laptop that originally came with Vista, and I upgraded to Vista Ultimate. I have always been able to change the brightness settings by using Func+Up or Func+Down but a few days ago it stopped working and is always at MAX bright!
Anybody knows why is that happening and how to fix it? It is very annoying not being able to dim the screen when in battery mode, since it can make quite a difference in battery life.
Thanks! | 2010/01/13 | ['https://superuser.com/questions/95202', 'https://superuser.com', 'https://superuser.com/users/15180/'] | The screen brightness can be changed in the power options section of Control Panel (or by clicking the little battery icon in the system tray, though i'm unsure if that's new to Win 7 or works in vista).
As for the Fn keys stopping working, it's likely that there will be an app you can install from the Gateway website for your machine that will re-enable them. I've had this issue before too (though not on a Gateway), and had to reinstall the program from my manufacturers website to get proper Fn key functionality back. | Ensure you have the latest video driver, downloaded from the website of the card's manufacturer.
If you have installed "Dox Optimised Forceware", then uninstall it first. |
20,402,662 | Can anyone explain to me why I can write 'ECHO Y|' in the Powershell command line but not if I implement it in a script?
These variables are taken from a .csv file. When I used the command line I did not use the variables.
```
ECHO Y|cacls $_."Serverdisc" /G ADMINISTRATORS:F
cacls $_."Serverdisc" /G $_."Username":C /T /E
cacls $_."Serverdisc" /G SYSTEM:F /T /E
``` | 2013/12/05 | ['https://Stackoverflow.com/questions/20402662', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2564636/'] | I am guessing you are trying to pass "Y(es)" to any possible prompts?
CMD shell and PowerShell are two different shells. What you are trying to do is use the CMD shell syntax for Powershell and therefore running into trouble
$\_ is used when you are iterating through an array coming from pipeline, so there must be something other than what you have shared here. I will give you an example.
Assume I have 2 files in c:\temp\:
```
c:\temp\a.txt
c:\temp\b.txt
```
and I want to grant them permissions and not to be prompted.
```
"c:\temp\a.txt","c:\temp\b.txt" | foreach-object {
ECHO Y|cacls $_ /G ADMINISTRATORS:F
echo Y|cacls $_ /G SYSTEM:F /T /E
}
```
This is equivalent to the following
```
ECHO Y|cacls c:\temp\a.txt /G ADMINISTRATORS:F
echo Y|cacls c:\temp\a.txt /G SYSTEM:F /T /E
ECHO Y|cacls c:\temp\b.txt /G ADMINISTRATORS:F
echo Y|cacls c:\temp\b.txt /G SYSTEM:F /T /E
```
$\_ is being replaced withing foreach-object by what is coming down from pipeline, which is pretty much imitating CMD shell command that would work. | It's probably because the pipeline function of powershell is different from the cmd prompt
If you use `cmd /c echo Y| cacls ....`
it will work. |
20,402,662 | Can anyone explain to me why I can write 'ECHO Y|' in the Powershell command line but not if I implement it in a script?
These variables are taken from a .csv file. When I used the command line I did not use the variables.
```
ECHO Y|cacls $_."Serverdisc" /G ADMINISTRATORS:F
cacls $_."Serverdisc" /G $_."Username":C /T /E
cacls $_."Serverdisc" /G SYSTEM:F /T /E
``` | 2013/12/05 | ['https://Stackoverflow.com/questions/20402662', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2564636/'] | I will add to Adil H.'s comments and say that using cacls is depreciated. You should instead be using **icacls**. icacls has a parameter /Q (Quiet) which will suppress all the confirmation messages for you, and you will not have to use `ECHO Y|` in your code.
(assuming you have the rest of your script in order(see Adil H.'s post)) Your script block would change to this:
```
icacls $_."Serverdisc" /Q /Grant ADMINISTRATORS:F
icacls $_."Serverdisc" /Q /Grant $_."Username":C /T
icacls $_."Serverdisc" /Q /Grant SYSTEM:F /T
``` | It's probably because the pipeline function of powershell is different from the cmd prompt
If you use `cmd /c echo Y| cacls ....`
it will work. |
50,815,061 | I am building REST API which stores name, salary and expenses of people. How can I POST data of multiple people at the same time, like an array?
This is my serializers.py file
```
from rest_framework import serializers
from .models import Bucketlist
class BucketlistSerializer(serializers.ModelSerializer):
class Meta:
model = Bucketlist
fields = ('id','name', 'date_created', 'salary','Expenditure')
read_only_fields = ('date_created',)
```
This is my views.py file
![screenshot of views.py](https://i.stack.imgur.com/T4yAw.png) | 2018/06/12 | ['https://Stackoverflow.com/questions/50815061', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/9929677/'] | As you are on your tabbed page already you can literally just do the following
```
public partial class MyTabbedPage : TabbedPage
{
public MyTabbedPage()
{
InitializeComponent();
CurrentPageChanged += CurrentPageHasChanged;
}
private void CurrentPageHasChanged(object sender, EventArgs e) => Title = CurrentPage.Title;
}
```
if you want to use the sender you can do the following
```
public partial class MyTabbedPage : TabbedPage
{
public MyTabbedPage()
{
InitializeComponent();
CurrentPageChanged += CurrentPageHasChanged;
}
private void CurrentPageHasChanged(object sender, EventArgs e)
{
var tabbedPage = (TabbedPage) sender;
Title = tabbedPage.CurrentPage.Title;
}
}
```
Or if you can elaborate on what you are trying to do exactly I can give a better answer as I do not know what it is that you are trying to do exactly | I don't think you can achieve what you want to do, at least not like this. The event behaves the way it does and as described: it is fired whenever the current page changes, also for children.
That being said, I think you should focus on implementing the functionality you want with the tools we have. I can't really deduce from your code what you are trying to do, but it looks like you want to change the title? When a tab is changed? Why not just make some kind of condition to only do it for certain pages? For example when the page is contained in the `Children` collection? |
23,284,601 | I have an input form-
```
<input type="hidden" name="unsubscribe_email" value="<?=$email;?>" />
```
The variable `$email` is a decrypted one, & it holds the value `psb@***.com` (when echoed in the same page).
I'm retrieving the value in my action page like- `$_POST['unsubscribe_email']`.
Instead of getting `***@***.com`, the variable is getting appended.
This is what I get
`psb@***.com�����������������`
I'm clueless as to why this is happening.
Here's the actual code-
HTML-
```
<form method="POST" name="some_name" action="my_page.php">
<input type="hidden" name="unsubscribe_email" value="<?=$email;?>" />
<input type="submit" value="Unsubscribe" />
</form>
```
PHP-
```
$email = $_POST['unsubscribe_email'];
echo $email; //gives me this- psb@*.com�����������������
```
EDIT: The decrypt method that I'm using is appending "\u000" to the original string.
Any leads on how to deal with "\u000"?
Thanks in advance, folks! | 2014/04/25 | ['https://Stackoverflow.com/questions/23284601', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3523750/'] | Assign your context variable before using, like this
```
context = getApplicationContext();
``` | Its because your context is null. Instead of context, you could use your activity like `NextActivity.this` |
39,618,765 | I need to write a test `PartitionMapperTest` for my Java class `PartitionMapper`. This class has private fields with `@Inject` annotations but it has only a no-param constructor.
For the test, I want to create a `partitionMapper` before any test and inject values into its private fields. Then, tester tests the mapper's method `mapPartitions` and assert values. However, I don't know how to inject these values into `partitionMapper`.
PartitionMapper.java
```
@Named
public class PartitionMapper implements javax.batch.api.partition.PartitionMapper {
@Inject
private JobContext jobContext;
@Inject
@BatchProperty
private String fetchSize;
@Inject
@BatchProperty
private String rowsPerPartition;
// other batch properties ...
@PersistenceUnit(unitName = "h2")
private EntityManagerFactory emf;
@Override
public PartitionPlan mapPartitions() throws Exception {
// ...
}
}
```
PartitionMapperTest.java
```
public class PartitionMapperTest {
private PartitionMapper partitionMapper;
@Before
public void setUp() {
// Prepare JobContext, batch properties to inject ...
// Instantiation
partitionMapper = new PartitionMapper();
// TODO How to inject these objects into partitionMapper?
}
@Test
public void testMapPartitions() throws Exception {
PartitionPlan partitionPlan = partitionMapper.mapPartitions();
for (Properties p : partitionPlan.getPartitionProperties()) {
// Assertions here ...
}
}
// ...
}
```
I actually did implement a real `PartitionMapperTest` based on Mockito and PowerMock, which can be seen on my [GitHub](https://github.com/mincong-h/gsoc-hsearch/blob/217d560424171e83864dfe55f6d08d955baeb763/core/src/test/java/org/hibernate/search/jsr352/PartitionMapperTest.java). The problem is there're so many assumptions that it leads to very poor code for user-understanding. I'm looking for another solution for refactoring it. | 2016/09/21 | ['https://Stackoverflow.com/questions/39618765', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4381330/'] | Is there any reason to only have a no args constructor?
I would recommand you to use constructor injection instead of field injection. That would solve you problem.
For example instead of:
```
public class Foo {
@Inject
private Bar bar;
}
```
do this:
```
public class Foo {
private Bar bar;
public Foo(@Inject Bar bar) {
this.bar = bar;
}
}
```
If you define your injection points this way you have a clean API and your class can be used in non-cdi environments (like unit-tests).
There are many resources about "constructor injection VS field injection"... Also on stackoverflow, e.g. <https://stackoverflow.com/a/19382081/4864870>. | Use protected fields instead of private to be able to mock fields in unit test:
```
@Named
public class PartitionMapper implements javax.batch.api.partition.PartitionMapper {
@Inject
JobContext jobContext;
@Inject
@BatchProperty
String fetchSize;
@Inject
@BatchProperty
String rowsPerPartition;
// other batch properties ...
@PersistenceUnit(unitName = "h2")
EntityManagerFactory emf;
@Override
public PartitionPlan mapPartitions() throws Exception {
// ...
}
}
``` |
73,225,372 | What's the logic behind `if n < i*i: return True`?
```
def isPrime(n, i = 2):
# Base cases
if (n <= 2):
return True if(n == 2) else False
if (n % i == 0):
return False
if (n < i*i):
return True
# Check for the next divisor
return isPrime(n, i + 1)
``` | 2022/08/03 | ['https://Stackoverflow.com/questions/73225372', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/19583160/'] | For each factor `f`, there is a complement `n/f`. If the factor is less than `sqrt(n)`, the complement is bigger, and vice versa. So, if we checked all factors up to and including `sqrt(n)`, and found none, it is sufficient to say that there are no other factors. | At each iteration, we establish that `n` is not divisible by an integer less than or equal to `i`. If `n` were not a prime, then by definition `n = x * y` where `x` and `y` are positive integers. Both `x` and `y` must be greater than `i` as mentioned earlier. It follows that `n = x * y` must be greater than `i * i` for it to possibly be a prime. |
32,922 | I've noticed on my team the developers are very busy toward the beginning of the sprint with the QA people having little to do, while the opposite is true toward the end of the sprint.
This seems inefficient... is there any way to smooth it out? | 2021/07/29 | ['https://pm.stackexchange.com/questions/32922', 'https://pm.stackexchange.com', 'https://pm.stackexchange.com/users/597/'] | It sounds like you are doing something very common in teams - a 2-week waterfall project. Things likely move from some requirements conversations before the sprint or in the early days of it to coding, then QA at the end. There are a few things you can do to change this up which will also have the impact of smoothing out workload:
1. Smaller pieces of work. Break things down into small features that can be designed, coded, and tested in 2 - 3 days. Lessons learned many decades ago from Lean: small batches lead to better flow.
2. Test-first development. Using techniques like TDD and BDD (as examples) can bring a lot of the testing early in the process instead of later. (this doesn't completely eliminate exploratory testing btw). This also really helps with...
3. Invest in test automation. Unit tests, integration tests, automated acceptance tests. This is all part of the build it process. Also, this requires both the coders and testers to work together. The testers are good at knowing what to test and the developers can help automate them and build the application to be more easily testable. This also gives you a large suite of regression tests that make it easier and safer to do #1. | I'm using a lot of Scrum terms here, but other agile methods are not that different.
Let me make one thing clear first: test cases are not things developers or QA people make up as they go. Test cases are defined alongside the requirements. They need to be there when the implementation starts. Maybe not as automated tests, but at least as a description what should happen when on a piece of paper or in the ticket or as a reference to some electronic document.
Writing those testcases is a lot of work and can be done by QA people whenever they have nothing to do. However, that still leaves QA with one type of work at the start of the sprint and another type at the end of the sprint and the work at the start of a sprint is not even calculated into any kind of velocity because it's not measured as getting a ticket to "done".
The best way I have seen so far is to actually *not* have dedicated QA in the team. It doesn't make sense and wastes a lot of time. Maybe have a single one that can assist all others to become better at testing but can develop little features on their own if no assistance is neccessary.
Normal testing is done by the developers (preferably not the same developer that actually implemented the feature). They make sure a story works. They go by the test cases that are already listed with the story.
The team delivers *potentially releasable* software increments each sprint. The chance that you *actually* want to release that increment are slim. "Agile" lives from the ability to change things until the product owner is truly happy with them. Constantly realeasing a trickle of changes that might later be unchanged or changed in a different way is costly to everybody involved. You cannot run a marketing campaign every sprint. You cannot have ads for every little thing you finish. You cannot have 10 words translated (well, you can, but it might cost just as much as waiting until you have 100). And yes, you cannot have every feature thouroughly QA'd if it doesn't make it into a production release in the end. That's waste.
So your QA team needs to do their job not on every increment, but only on those increments that are to be released. The same as the marketing department, sales, whoever is involved in releasing a new version.
I know a team is supposed to be able to finish a product on their own, but that only goes for the actual implementation. There are no marketers, ad salesmen or translators on your team either. So don't make QA a part of the team. It's neither fun nor a good use of money to QA a feature over and over and over every time the product owner changes it.
Please note that I am talking about QA here. QA is making sure a product is working as it should be. I'm not talking about simple testing. Testing should be done by the developers, how else would they be able to say "I'm done". |
32,922 | I've noticed on my team the developers are very busy toward the beginning of the sprint with the QA people having little to do, while the opposite is true toward the end of the sprint.
This seems inefficient... is there any way to smooth it out? | 2021/07/29 | ['https://pm.stackexchange.com/questions/32922', 'https://pm.stackexchange.com', 'https://pm.stackexchange.com/users/597/'] | Switch to Kanban so that you can balance the flow of work without the cold-start at the beginning of every sprint.
Once you start optimizing for delivery, look at how developers can help with the QA to finish the work instead of starting new items.
Over time, this might reveal team imbalance and drive some staffing decisions and/or tooling improvements. | I'm using a lot of Scrum terms here, but other agile methods are not that different.
Let me make one thing clear first: test cases are not things developers or QA people make up as they go. Test cases are defined alongside the requirements. They need to be there when the implementation starts. Maybe not as automated tests, but at least as a description what should happen when on a piece of paper or in the ticket or as a reference to some electronic document.
Writing those testcases is a lot of work and can be done by QA people whenever they have nothing to do. However, that still leaves QA with one type of work at the start of the sprint and another type at the end of the sprint and the work at the start of a sprint is not even calculated into any kind of velocity because it's not measured as getting a ticket to "done".
The best way I have seen so far is to actually *not* have dedicated QA in the team. It doesn't make sense and wastes a lot of time. Maybe have a single one that can assist all others to become better at testing but can develop little features on their own if no assistance is neccessary.
Normal testing is done by the developers (preferably not the same developer that actually implemented the feature). They make sure a story works. They go by the test cases that are already listed with the story.
The team delivers *potentially releasable* software increments each sprint. The chance that you *actually* want to release that increment are slim. "Agile" lives from the ability to change things until the product owner is truly happy with them. Constantly realeasing a trickle of changes that might later be unchanged or changed in a different way is costly to everybody involved. You cannot run a marketing campaign every sprint. You cannot have ads for every little thing you finish. You cannot have 10 words translated (well, you can, but it might cost just as much as waiting until you have 100). And yes, you cannot have every feature thouroughly QA'd if it doesn't make it into a production release in the end. That's waste.
So your QA team needs to do their job not on every increment, but only on those increments that are to be released. The same as the marketing department, sales, whoever is involved in releasing a new version.
I know a team is supposed to be able to finish a product on their own, but that only goes for the actual implementation. There are no marketers, ad salesmen or translators on your team either. So don't make QA a part of the team. It's neither fun nor a good use of money to QA a feature over and over and over every time the product owner changes it.
Please note that I am talking about QA here. QA is making sure a product is working as it should be. I'm not talking about simple testing. Testing should be done by the developers, how else would they be able to say "I'm done". |
32,922 | I've noticed on my team the developers are very busy toward the beginning of the sprint with the QA people having little to do, while the opposite is true toward the end of the sprint.
This seems inefficient... is there any way to smooth it out? | 2021/07/29 | ['https://pm.stackexchange.com/questions/32922', 'https://pm.stackexchange.com', 'https://pm.stackexchange.com/users/597/'] | One key is cross-training to reduce the skill gap between QA and SW engineers. That is, train developers to do some low-level testing, and testers some low-level development work. In fact, a big-data presentation I saw all the way back in 2014 at Agile World showed the best-performing teams did not have separate disciplines.
This echoes some of the other answers, but the process that has worked well for my teams includes these generic tasks for each development user story:
1. Write the test case, if one doesn't exist (QA, or dev in easier
cases).
2. Develop (Dev) || Automate new test case, or conduct break/UX testing of existing code (QA).
3. Unit test (Dev).
4. "Second set of eyes" testing (QA, or different Dev from step 3's).
5. Acceptance test (Customer or Product Owner).
Good luck--Jim | I'm using a lot of Scrum terms here, but other agile methods are not that different.
Let me make one thing clear first: test cases are not things developers or QA people make up as they go. Test cases are defined alongside the requirements. They need to be there when the implementation starts. Maybe not as automated tests, but at least as a description what should happen when on a piece of paper or in the ticket or as a reference to some electronic document.
Writing those testcases is a lot of work and can be done by QA people whenever they have nothing to do. However, that still leaves QA with one type of work at the start of the sprint and another type at the end of the sprint and the work at the start of a sprint is not even calculated into any kind of velocity because it's not measured as getting a ticket to "done".
The best way I have seen so far is to actually *not* have dedicated QA in the team. It doesn't make sense and wastes a lot of time. Maybe have a single one that can assist all others to become better at testing but can develop little features on their own if no assistance is neccessary.
Normal testing is done by the developers (preferably not the same developer that actually implemented the feature). They make sure a story works. They go by the test cases that are already listed with the story.
The team delivers *potentially releasable* software increments each sprint. The chance that you *actually* want to release that increment are slim. "Agile" lives from the ability to change things until the product owner is truly happy with them. Constantly realeasing a trickle of changes that might later be unchanged or changed in a different way is costly to everybody involved. You cannot run a marketing campaign every sprint. You cannot have ads for every little thing you finish. You cannot have 10 words translated (well, you can, but it might cost just as much as waiting until you have 100). And yes, you cannot have every feature thouroughly QA'd if it doesn't make it into a production release in the end. That's waste.
So your QA team needs to do their job not on every increment, but only on those increments that are to be released. The same as the marketing department, sales, whoever is involved in releasing a new version.
I know a team is supposed to be able to finish a product on their own, but that only goes for the actual implementation. There are no marketers, ad salesmen or translators on your team either. So don't make QA a part of the team. It's neither fun nor a good use of money to QA a feature over and over and over every time the product owner changes it.
Please note that I am talking about QA here. QA is making sure a product is working as it should be. I'm not talking about simple testing. Testing should be done by the developers, how else would they be able to say "I'm done". |
32,922 | I've noticed on my team the developers are very busy toward the beginning of the sprint with the QA people having little to do, while the opposite is true toward the end of the sprint.
This seems inefficient... is there any way to smooth it out? | 2021/07/29 | ['https://pm.stackexchange.com/questions/32922', 'https://pm.stackexchange.com', 'https://pm.stackexchange.com/users/597/'] | It sounds like you are doing something very common in teams - a 2-week waterfall project. Things likely move from some requirements conversations before the sprint or in the early days of it to coding, then QA at the end. There are a few things you can do to change this up which will also have the impact of smoothing out workload:
1. Smaller pieces of work. Break things down into small features that can be designed, coded, and tested in 2 - 3 days. Lessons learned many decades ago from Lean: small batches lead to better flow.
2. Test-first development. Using techniques like TDD and BDD (as examples) can bring a lot of the testing early in the process instead of later. (this doesn't completely eliminate exploratory testing btw). This also really helps with...
3. Invest in test automation. Unit tests, integration tests, automated acceptance tests. This is all part of the build it process. Also, this requires both the coders and testers to work together. The testers are good at knowing what to test and the developers can help automate them and build the application to be more easily testable. This also gives you a large suite of regression tests that make it easier and safer to do #1. | Switch to Kanban so that you can balance the flow of work without the cold-start at the beginning of every sprint.
Once you start optimizing for delivery, look at how developers can help with the QA to finish the work instead of starting new items.
Over time, this might reveal team imbalance and drive some staffing decisions and/or tooling improvements. |
32,922 | I've noticed on my team the developers are very busy toward the beginning of the sprint with the QA people having little to do, while the opposite is true toward the end of the sprint.
This seems inefficient... is there any way to smooth it out? | 2021/07/29 | ['https://pm.stackexchange.com/questions/32922', 'https://pm.stackexchange.com', 'https://pm.stackexchange.com/users/597/'] | It sounds like you are doing something very common in teams - a 2-week waterfall project. Things likely move from some requirements conversations before the sprint or in the early days of it to coding, then QA at the end. There are a few things you can do to change this up which will also have the impact of smoothing out workload:
1. Smaller pieces of work. Break things down into small features that can be designed, coded, and tested in 2 - 3 days. Lessons learned many decades ago from Lean: small batches lead to better flow.
2. Test-first development. Using techniques like TDD and BDD (as examples) can bring a lot of the testing early in the process instead of later. (this doesn't completely eliminate exploratory testing btw). This also really helps with...
3. Invest in test automation. Unit tests, integration tests, automated acceptance tests. This is all part of the build it process. Also, this requires both the coders and testers to work together. The testers are good at knowing what to test and the developers can help automate them and build the application to be more easily testable. This also gives you a large suite of regression tests that make it easier and safer to do #1. | One key is cross-training to reduce the skill gap between QA and SW engineers. That is, train developers to do some low-level testing, and testers some low-level development work. In fact, a big-data presentation I saw all the way back in 2014 at Agile World showed the best-performing teams did not have separate disciplines.
This echoes some of the other answers, but the process that has worked well for my teams includes these generic tasks for each development user story:
1. Write the test case, if one doesn't exist (QA, or dev in easier
cases).
2. Develop (Dev) || Automate new test case, or conduct break/UX testing of existing code (QA).
3. Unit test (Dev).
4. "Second set of eyes" testing (QA, or different Dev from step 3's).
5. Acceptance test (Customer or Product Owner).
Good luck--Jim |
41,196 | I am having problem understanding why **negative frequencies are showing up to the right of positive frequencies** in discrete complex FFT.
I am not sure how to apply aliasing concept to explain such phenomenon even after reading about modulo-2pi angular frequency concept at [MIT OCW signal processing course](https://ocw.mit.edu/courses/mechanical-engineering/2-161-signal-processing-continuous-and-discrete-fall-2008/lecture-notes/lecture_10.pdf).
Anyone ?
[![enter image description here](https://i.stack.imgur.com/QfcWd.png)](https://i.stack.imgur.com/QfcWd.png) | 2017/05/24 | ['https://dsp.stackexchange.com/questions/41196', 'https://dsp.stackexchange.com', 'https://dsp.stackexchange.com/users/22522/'] | The Fourier transform $X(e^{j\Omega})$ of a sequence $x[n]$ is by definition periodic of period $2\pi$ in $\Omega$. The $N$-point discrete Fourier transform (DFT) of $x[n]$ is simply defined as a sampled version of the Fourier transform $X(e^{j\Omega})$, that is
$$X[k] = X(e^{j\frac{2k\pi}{N}}).$$
The periodicity of $2\pi$ in $\Omega$ for the Fourier transform becomes a periodicity of $N$ in $k$ for the DFT
$$X[k+N] = X[k].$$
The negative frequencies showing up to the right of the positive frequencies is simply a consequence of this periodicity. Or if you prefer, you get $X[k]$ for $k \in [0, N-1]$ instead of $k \in [-\frac{N-1}{2}, \frac{N-1}{2}]$. If you want the vector to contain first negative frequencies, then the DC and finally the positive frequencies instead, you can for example use MATLAB `fftshift`.
Those negative frequencies are not shown for the "real" DFT because if $x[n]$ is real, then $X[k] = X^\*[-k]$ (conjugate symmetry). Hence, you only need $X[k]$ for $k \in [0, N/2]$. | I will try to give a more intuitive answer here. Have you ever seen [this effect](http://www.youtube.com/watch?v=jHS9JGkEOmA)? It is related to your question.
For simplicity, I will take easy numbers. The camera rate (fs) is, lets say, 1 frames per second: every second it takes a snapshot of the wheel. Now, assume that the wheel is spinning also at 1 turn per second (fw). Result? you see a static wheel, the car is going fast (the landscape is passing by...), but the wheels just seem not to spin at all, but you know they are moving. In this case, $fw = fs$, and you see how $2 \cdot \pi$ [rads] maps to $0 \cdot \pi$ [rads], you lose information in the sampling process.
Now, if $fw$ is 0.9 ([Hz]), the wheels seem to spin counterclockwise very slowly. But the question is, did it turn counterclockwise slowly or clockwise but much faster?. We have two options:
1. Assume they are always spinning clockwise (or counterclockwise), i.e. it spun at 0.9 Hz clockwise. So possible frequencies span [0, N) samples or [0, 1) Hz.
2. Assume that wheels reached that state through the shortest pat, i.e. it spun counterclockwise at 0.1 Hz. So possible frequencies span [-N/2,N/2) samples or [-0.5, 0.5) Hz.
In the signal domain, a wheel spinning clockwise would be sine and a counterclockwise spinning wheel would be a negative sine ($sin(- \omega \cdot t) = -sin(\omega \cdot t)$), and so on for cosine. Since negative sine is common we better go with the second approach.
In short, negative frequencies equal higher positive frequencies, in the digital domain you can not tell the difference. |
129,650 | Let's say I have many-to-many relationship (using the ActiveRecord attribute HasAndBelongsToMany) between Posts and Tags (domain object names changed to protect the innocent), and I wanted a method like
```
FindAllPostByTags(IList<Tag> tags)
```
that returns all Posts that have all (not just some of) the Tags in the parameter. Any way I could accomplish this either with NHibernate Expressions or HQL? I've searched through the HQL documentation and couldn't find anything that suited my needs. I hope I'm just missing something obvious! | 2008/09/24 | ['https://Stackoverflow.com/questions/129650', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/14064/'] | You could also just use an `IN` statement
```
DetachedCriteria query = DetachedCriteria.For<Post>();
query.CreateCriteria("Post").Add(Expression.In("TagName", string.Join(",",tags.ToArray()) );
```
I haven't compiled that so it could have errors | I don't have a system at hand with a Castle install right now, so I didn't test or compile this, but the code below should about do what you want.
```
Junction c = Expression.Conjunction();
foreach(Tag t in tags)
c = c.Add( Expression.Eq("Tag", t);
return sess.CreateCriteria(typeof(Post)).Add(c).List();
``` |
129,650 | Let's say I have many-to-many relationship (using the ActiveRecord attribute HasAndBelongsToMany) between Posts and Tags (domain object names changed to protect the innocent), and I wanted a method like
```
FindAllPostByTags(IList<Tag> tags)
```
that returns all Posts that have all (not just some of) the Tags in the parameter. Any way I could accomplish this either with NHibernate Expressions or HQL? I've searched through the HQL documentation and couldn't find anything that suited my needs. I hope I'm just missing something obvious! | 2008/09/24 | ['https://Stackoverflow.com/questions/129650', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/14064/'] | You could also just use an `IN` statement
```
DetachedCriteria query = DetachedCriteria.For<Post>();
query.CreateCriteria("Post").Add(Expression.In("TagName", string.Join(",",tags.ToArray()) );
```
I haven't compiled that so it could have errors | I just had the same problem and tried to read the HQL-documentation, however some of the features doesn't seem to be implemented in NHibernate (with-keyword for example)
I ended up with this sort of solution:
```
select p
FROM Post p
JOIN p.Tags tag1
JOIN p.Tags tag2
WHERE
tag1.Id = 1
tag2.Id = 2
```
Meaning, dynamically build the HQL using join for each tag, then make the selection in your WHERE clause. This worked for me. I tried doing the same thing with a DetachedCriteria but ran into trouble when trying to join the table multiple times. |
71,368,718 | I am trying to build an application where user can search for various items. now my question is how can I send efficiently user search request to the server ?
example , user will type something (say 15 characters). For every 1 character he is sending one request to the server (using axios). now he is typing so fast, within 3 seconds he has sent 15 request to the server.. due to 15 parallel requests, my app is showing the actual result lately (or sometime failing). please help me how can i solve it.. I am using react native with axios.
example:
```
async searchLocation(text) {
if (text.length > 3) {
this.setState({searching: true, searchResultWindow: true});
var getSearchResult = await searchPlace(text); /// Here I am making axios call to our server
this.setState({searching: false, searchResults: getSearchResult.message});
}
}
``` | 2022/03/06 | ['https://Stackoverflow.com/questions/71368718', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/911423/'] | You can use `setTimeout` to handle that case
```
let timer //the global variable to track the timer
async searchLocation(text) {
if (text.length > 3) {
//remove the API trigger within 3 seconds
clearTimeout(timer)
//assign new timer for the API call
timer = setTimeout(() => {
this.setState({searching: true, searchResultWindow: true});
var getSearchResult = await searchPlace(text); /// Here I am making axios call to our server
this.setState({searching: false, searchResults: getSearchResult.message});
}, 3000) //the API only triggers once users stop typing after 3 seconds
}
}
```
If you want to have deeper understanding, you can read this article
<https://www.freecodecamp.org/news/javascript-debounce-example/> | I think you can divide the issue into two steps
* At the first you must find a word that the user wants to type for search (**not result of search**)
in this step, you can just use a dictionary
* The second step is finding user search results after pressing **Enter key** or Click to the search button |
11,671,135 | Consider this list of POSIXct dates:
```
times <- list(as.POSIXct(c("2012-07-26 00:30", "2012-07-26 6:20",
"2012-07-26 10:40", "2012-07-26 15:50")),
as.POSIXct(c("2012-07-26 01:15", "2012-07-26 10:10",
"2012-07-26 15:15", "2012-07-26 18:50")),
as.POSIXct(c("2012-07-26 00:35", "2012-07-26 15:05",
"2012-07-26 19:36", "2012-07-26 22:32")),
as.POSIXct(c("2012-07-26 03:34", "2012-07-26 16:43",
"2012-07-26 21:44", "2012-07-26 23:45")))
```
If I do:
```
range(times[[1]])
```
I correctly get:
```
[1] "2012-07-26 00:30:00 CEST" "2012-07-26 15:50:00 CEST"
```
Now, if I do:
```
range(times[c(1,3)])
```
for whatever reason R decides to convert the POSIXct objects into timestamps and gives me
```
[1] 1343255400 1343334720
```
I then try to reconvert them to POSIXct by doing:
```
as.POSIXct(range(times[c(1,3)]), origin="1970-01-01 00:00")
```
And, strangely, I get the range with 1 hour of advance:
```
[1] "2012-07-25 23:30:00 CEST" "2012-07-26 21:32:00 CEST"
```
So I have to do:
```
as.POSIXct(range(times[c(1,3)]), origin="1970-01-01 01:00")
```
To get the correct range of:
```
[1] "2012-07-26 00:30:00 CEST" "2012-07-26 22:32:00 CEST"
```
Am I missing something or is there a bug somewhere? | 2012/07/26 | ['https://Stackoverflow.com/questions/11671135', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/176923/'] | `times[[1]]` is a vector, while `times[c(1,3)]` is a list. Convert the latter to a vector before calling `range` and all is well.
You don't want to use `unlist` though, since it will only return an atomic vector (`range` must be doing something like that internally), but you can use `do.call`:
```
range(do.call(c,times[c(1,3)]))
```
The differences you get from using `as.POSIXct` are likely due to timezone issues. | As Joshua said, the hour is because of timezones. Try, for example:
```
times <- list(as.POSIXct(c("2012-07-26 00:30", "2012-07-26 6:20",
"2012-07-26 10:40", "2012-07-26 15:50"), "GMT"),
as.POSIXct(c("2012-07-26 01:15", "2012-07-26 10:10",
"2012-07-26 15:15", "2012-07-26 18:50"), "GMT"),
as.POSIXct(c("2012-07-26 00:35", "2012-07-26 15:05",
"2012-07-26 19:36", "2012-07-26 22:32"), "GMT"),
as.POSIXct(c("2012-07-26 03:34", "2012-07-26 16:43",
"2012-07-26 21:44", "2012-07-26 23:45"), "GMT"))
as.POSIXct(range(times[c(1,3)]), origin="1970-01-01 00:00", "GMT")
``` |
1,064,367 | Title pretty much says it all. `lspci -v` finds a sound card, but neither `aplay -l` not `pacmd list-cards` don't. Problem first surfaced when updating ubuntu to 18.04, which was a hail-mary attempt to fix an another probably unrelated issue with my login screen. I'm not sure whether or not my sound was working before the ubuntu update either, since the login screen issue arose when I got my machine back from warranty repair.
Alsa self diagnose:
<https://pastebin.com/787EwmQC>
lspci -v:
<https://pastebin.com/K52mA74m>
aplay -l:
aplay: device\_list:270: no soundcards found...
pacmd list-cards:
0 card(s) available.
Things to note:
* My boot time lasts a bit longer than I remember it lasting, maybe some kernel module thing fails?
* My pulseaudio daemon doesn't start on boot. Maybe unrelated but I think you should know.
* I'm running the newest ubuntu (18.04).
Have tried:
* Reinstalling many things, some probably multiple times.
* Robooting with various changes
* Deleting the local pulseaudio config in `~/.config/pulse`
* reseting default.pa (might have picked the wrong one to reset to)
* Adding myself to audio group
**EDIT:** `inxi -a` sees the card and states that it's using the snd\_hda\_intel driver. | 2018/08/11 | ['https://askubuntu.com/questions/1064367', 'https://askubuntu.com', 'https://askubuntu.com/users/527308/'] | Typically, `dconf` schemas translate nicely into `gsettings` schemas by replacing slashes with dots and vice versa.
In your example, `org.mate.peripherals-mouse` is the closest matching for what I'd expect to be a static schema.
However, not all `gsettings` schemas translate nicely. There's something known as [relocatable schemas](https://blog.gtk.org/2017/05/01/first-steps-with-gsettings/):
>
> A relocatable schema is what you need when you need multiple instances of the same configuration, stored separately. A typical example for this is accounts: your application allows to create more than one, and each of them has the same kind of configuration information associated with it.
>
>
>
For such cases, schema also requires a particular path added to it. [For example](https://askubuntu.com/a/290160/295286),
```
gsettings set org.compiz.unityshell:/org/compiz/profiles/unity/plugins/unityshell/ dash-blur-experimental 1
```
Here's another example from one of Budgie desktop schemas:
```
$ dconf write /com/solus-project/budgie-panel/panels/{5f6251f2-9d09-11e8-be4b-d053493d53fd}/size 52
$ gsettings set com.solus-project.budgie-panel.panel:/com/solus-project/budgie-panel/panels/{5f6251f2-9d09-11e8-be4b-d053493d53fd}/ size 52
```
Typically paths for relocatable `gsettings` schemas are the same as for `dconf`, but [it's not guaranteed](https://stackoverflow.com/q/30687792/3701431) from what I understand. Manual way would be to run `dconf watch /` and use GUI buttons/sliders/preferences menus to figure out which schemas are controlled by those. | To further clarify the relation between GSettings and DConf:
First of all, they are part of the *same* system. To be more precise, GSettings *uses* DConf as its ***storage backend***.
And that's what DConf is: a **storage** system. That's why it only speaks in terms of *paths*: it stores keys and values in a given path. Those paths, keys and values are then stored in a binary *source*. Think of `dconf` as a ZIP archive: it contains "files" (keys) with values, structured in directories and subdirectories.
For dconf that data has no *semantics*. Yes, its values are strongly typed (String, Integer, List, Boolean and so on). But they have no *meaning*. It doesn't care (or even *know*) about *schemas*.
Now comes GSettings. It organizes data in a *logical* way, with *schemas* declaring all settings an application uses, their description and summary. A Schema is the "blueprint" of a collection of settings, and has a unique ID. So an application, say Gnome Terminal, installs the schema `org.gnome.Terminal.Legacy.Settings`. The schema is saying "my (legacy) settings have this *format*".
GSettings (actually GLib) takes care of *where* and *how* such settings will be saved, so you don't have to. It could theoretically use an SQLite or MySQL database. Or INI files. Or JSON. It uses DConf, and so by default it saves that schema at dconf's path `/org/gnome/terminal/legacy/settings/`.
So is there a 1:1 mapping between GSettings schemas and DConf paths? For *non-relocatable* schemas (more on that later), yes. But you cannot derive a path from a schema name: even if *most* schemas are stored in a path resembling the schema, such as Gnome Terminal example above, that is not always the case: `org.gnome.Vino`, for example, is stored at `/org/gnome/desktop/remote-access/`. To get the paths where schemas are stored, use:
```
gsettings list-schemas --print-paths
```
And to infer the schemas from the paths... don't. You can get away with *"replace `/` with `.`"* only for the most basic cases. It won't work for:
* Schemas with`Mixed.case.Names`, such as Gnome Terminal
* Schemas in non-standard paths, such as Vino
* Non-relocatable schemas
***Relocatable***? Yes, when the same Schema is used in *multiple instances*. For example, Gnome Terminal allows you to create several named *profiles*, which is a subset of the application's settings. Since all profiles have the same *format*, they all share the same "blueprint", the Gsettings schema `org.gnome.Terminal.Legacy.Profile`. The data for each profile is saved in a distinct dconf *path*, and so that schema is a **relocatable** one.
That's why for relocatable schemas the application (and you) must specify **both** the schema *and* path when using `gsettings`. If accessing `dconf` directly, as it doesn't know about schemas, you use just the path. But there isn't a 1:1 mapping, as relocatable schemas have a 1:N relation with paths.
---
To answer your question: none of the mouse-related schemas you listed is a relocatable schema (those would be listed with `gsettings list-relocatable-schemas`), so you *can* for this particular case get their DConf paths with
```
gsettings list-schemas --print-paths | grep -i mouse
```
As for "which one should I use"? Well, that depends on what setting you want to change. Several applications might have mouse-related settings. Gnome Desktop has one, Mate has another for its desktop (I presume) and a mouse-related plugin in its "settings daemon", whatever that is. What behavior in your system each setting controls is application-dependent, but that would be outside the scope of the question. |
46,061,388 | I am trying to change the background color and text color of a link inside a button that I created, but only the background color changes. The text remains it's default color and refuses to change regardless of !important tags.
Here is my code:
```css
button,
input,
select,
textarea {
font-size: 100%;
/* Corrects font size not being inherited in all browsers */
margin: 0;
/* Addresses margins set differently in IE6/7, F3/4, S5, Chrome */
vertical-align: baseline;
/* Improves appearance and consistency in all browsers */
padding: 15px;
}
button,
.button,
input[type="button"],
input[type="reset"],
input[type="submit"] {
font-size: 12px;
padding: 12px 30px;
margin-bottom: 10px;
width: 200px;
border: 1px solid #007af4;
color: #007af4;
text-transform: uppercase;
letter-spacing: 4px;
background-color: transparent;
-webkit-transition: all 0.3s;
transition: all 0.3s;
cursor: pointer;
/* Improves usability and consistency of cursor style between image-type 'input' and others */
-webkit-appearance: button;
/* Corrects inability to style clickable 'input' types in iOS */
}
.button {
-webkit-appearance: none;
}
input[type="submit"] {
margin-top: 5px;
}
button:hover,
.button:hover,
input[type="button"]:hover,
input[type="reset"]:hover,
input[type="submit"]:hover {
background-color: #007af4;
text-decoration: none;
color: #FFFFFF;
}
```
```html
<div class="button">
<a href="javascript:void(0)" onclick="javascript:jqcc.cometchat.chatWith(<?PHP echo bp_displayed_user_id(); ?>);">Chat with us<a>
</div>
```
I've already looked at these two threads:
[a:hover color is not working](https://stackoverflow.com/questions/16967118/ahover-color-is-not-working)
[a: hover, color is not changing](https://stackoverflow.com/questions/35241294/a-hover-color-is-not-changing)
Neither of the answers given on those threads helped with my problem (Unless I've overlooked something), so any help is greatly appreciated! | 2017/09/05 | ['https://Stackoverflow.com/questions/46061388', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/8565234/'] | Your CSS doesn't actually have any `a:hover` rules.
Why do you expect something to happen?
CSS will only do what you tell it to. | When you are changing a links colour on hover you need to make sure to apply it to the `a` tag directly. So in your case you want a style similar to the following:
```
a:hover {
color: white;
}
``` |
46,061,388 | I am trying to change the background color and text color of a link inside a button that I created, but only the background color changes. The text remains it's default color and refuses to change regardless of !important tags.
Here is my code:
```css
button,
input,
select,
textarea {
font-size: 100%;
/* Corrects font size not being inherited in all browsers */
margin: 0;
/* Addresses margins set differently in IE6/7, F3/4, S5, Chrome */
vertical-align: baseline;
/* Improves appearance and consistency in all browsers */
padding: 15px;
}
button,
.button,
input[type="button"],
input[type="reset"],
input[type="submit"] {
font-size: 12px;
padding: 12px 30px;
margin-bottom: 10px;
width: 200px;
border: 1px solid #007af4;
color: #007af4;
text-transform: uppercase;
letter-spacing: 4px;
background-color: transparent;
-webkit-transition: all 0.3s;
transition: all 0.3s;
cursor: pointer;
/* Improves usability and consistency of cursor style between image-type 'input' and others */
-webkit-appearance: button;
/* Corrects inability to style clickable 'input' types in iOS */
}
.button {
-webkit-appearance: none;
}
input[type="submit"] {
margin-top: 5px;
}
button:hover,
.button:hover,
input[type="button"]:hover,
input[type="reset"]:hover,
input[type="submit"]:hover {
background-color: #007af4;
text-decoration: none;
color: #FFFFFF;
}
```
```html
<div class="button">
<a href="javascript:void(0)" onclick="javascript:jqcc.cometchat.chatWith(<?PHP echo bp_displayed_user_id(); ?>);">Chat with us<a>
</div>
```
I've already looked at these two threads:
[a:hover color is not working](https://stackoverflow.com/questions/16967118/ahover-color-is-not-working)
[a: hover, color is not changing](https://stackoverflow.com/questions/35241294/a-hover-color-is-not-changing)
Neither of the answers given on those threads helped with my problem (Unless I've overlooked something), so any help is greatly appreciated! | 2017/09/05 | ['https://Stackoverflow.com/questions/46061388', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/8565234/'] | If you want to change the `<a>` text color when hovering over the enclosing `.button` you can do this:
```
.button:hover a {
color: #FFFFFF
}
```
This has the advantage of not needing to hover over the actual link -- when you hover over any part of the button, the link color will change and stay readable.
```css
button,
input,
select,
textarea {
font-size: 100%;
/* Corrects font size not being inherited in all browsers */
margin: 0;
/* Addresses margins set differently in IE6/7, F3/4, S5, Chrome */
vertical-align: baseline;
/* Improves appearance and consistency in all browsers */
padding: 15px;
}
button,
.button,
input[type="button"],
input[type="reset"],
input[type="submit"] {
font-size: 12px;
padding: 12px 30px;
margin-bottom: 10px;
width: 200px;
border: 1px solid #007af4;
color: #007af4;
text-transform: uppercase;
letter-spacing: 4px;
background-color: transparent;
-webkit-transition: all 0.3s;
transition: all 0.3s;
cursor: pointer;
/* Improves usability and consistency of cursor style between image-type 'input' and others */
-webkit-appearance: button;
/* Corrects inability to style clickable 'input' types in iOS */
}
.button:hover a {
color: #FFFFFF
}
.button {
-webkit-appearance: none;
}
input[type="submit"] {
margin-top: 5px;
}
button:hover,
.button:hover,
input[type="button"]:hover,
input[type="reset"]:hover,
input[type="submit"]:hover {
background-color: #007af4;
text-decoration: none;
color: #FFFFFF;
}
```
```html
<div class="button">
<a href="javascript:void(0)" onclick="javascript:jqcc.cometchat.chatWith(<?PHP echo bp_displayed_user_id(); ?>);">Chat with us<a>
</div>
``` | Your CSS doesn't actually have any `a:hover` rules.
Why do you expect something to happen?
CSS will only do what you tell it to. |
46,061,388 | I am trying to change the background color and text color of a link inside a button that I created, but only the background color changes. The text remains it's default color and refuses to change regardless of !important tags.
Here is my code:
```css
button,
input,
select,
textarea {
font-size: 100%;
/* Corrects font size not being inherited in all browsers */
margin: 0;
/* Addresses margins set differently in IE6/7, F3/4, S5, Chrome */
vertical-align: baseline;
/* Improves appearance and consistency in all browsers */
padding: 15px;
}
button,
.button,
input[type="button"],
input[type="reset"],
input[type="submit"] {
font-size: 12px;
padding: 12px 30px;
margin-bottom: 10px;
width: 200px;
border: 1px solid #007af4;
color: #007af4;
text-transform: uppercase;
letter-spacing: 4px;
background-color: transparent;
-webkit-transition: all 0.3s;
transition: all 0.3s;
cursor: pointer;
/* Improves usability and consistency of cursor style between image-type 'input' and others */
-webkit-appearance: button;
/* Corrects inability to style clickable 'input' types in iOS */
}
.button {
-webkit-appearance: none;
}
input[type="submit"] {
margin-top: 5px;
}
button:hover,
.button:hover,
input[type="button"]:hover,
input[type="reset"]:hover,
input[type="submit"]:hover {
background-color: #007af4;
text-decoration: none;
color: #FFFFFF;
}
```
```html
<div class="button">
<a href="javascript:void(0)" onclick="javascript:jqcc.cometchat.chatWith(<?PHP echo bp_displayed_user_id(); ?>);">Chat with us<a>
</div>
```
I've already looked at these two threads:
[a:hover color is not working](https://stackoverflow.com/questions/16967118/ahover-color-is-not-working)
[a: hover, color is not changing](https://stackoverflow.com/questions/35241294/a-hover-color-is-not-changing)
Neither of the answers given on those threads helped with my problem (Unless I've overlooked something), so any help is greatly appreciated! | 2017/09/05 | ['https://Stackoverflow.com/questions/46061388', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/8565234/'] | Your CSS doesn't actually have any `a:hover` rules.
Why do you expect something to happen?
CSS will only do what you tell it to. | A link already has an predefined style. You need to remove that style first to apply your style. Try this in your link
```
text-decoration: none
```
Try hover after that. |
46,061,388 | I am trying to change the background color and text color of a link inside a button that I created, but only the background color changes. The text remains it's default color and refuses to change regardless of !important tags.
Here is my code:
```css
button,
input,
select,
textarea {
font-size: 100%;
/* Corrects font size not being inherited in all browsers */
margin: 0;
/* Addresses margins set differently in IE6/7, F3/4, S5, Chrome */
vertical-align: baseline;
/* Improves appearance and consistency in all browsers */
padding: 15px;
}
button,
.button,
input[type="button"],
input[type="reset"],
input[type="submit"] {
font-size: 12px;
padding: 12px 30px;
margin-bottom: 10px;
width: 200px;
border: 1px solid #007af4;
color: #007af4;
text-transform: uppercase;
letter-spacing: 4px;
background-color: transparent;
-webkit-transition: all 0.3s;
transition: all 0.3s;
cursor: pointer;
/* Improves usability and consistency of cursor style between image-type 'input' and others */
-webkit-appearance: button;
/* Corrects inability to style clickable 'input' types in iOS */
}
.button {
-webkit-appearance: none;
}
input[type="submit"] {
margin-top: 5px;
}
button:hover,
.button:hover,
input[type="button"]:hover,
input[type="reset"]:hover,
input[type="submit"]:hover {
background-color: #007af4;
text-decoration: none;
color: #FFFFFF;
}
```
```html
<div class="button">
<a href="javascript:void(0)" onclick="javascript:jqcc.cometchat.chatWith(<?PHP echo bp_displayed_user_id(); ?>);">Chat with us<a>
</div>
```
I've already looked at these two threads:
[a:hover color is not working](https://stackoverflow.com/questions/16967118/ahover-color-is-not-working)
[a: hover, color is not changing](https://stackoverflow.com/questions/35241294/a-hover-color-is-not-changing)
Neither of the answers given on those threads helped with my problem (Unless I've overlooked something), so any help is greatly appreciated! | 2017/09/05 | ['https://Stackoverflow.com/questions/46061388', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/8565234/'] | If you want to change the `<a>` text color when hovering over the enclosing `.button` you can do this:
```
.button:hover a {
color: #FFFFFF
}
```
This has the advantage of not needing to hover over the actual link -- when you hover over any part of the button, the link color will change and stay readable.
```css
button,
input,
select,
textarea {
font-size: 100%;
/* Corrects font size not being inherited in all browsers */
margin: 0;
/* Addresses margins set differently in IE6/7, F3/4, S5, Chrome */
vertical-align: baseline;
/* Improves appearance and consistency in all browsers */
padding: 15px;
}
button,
.button,
input[type="button"],
input[type="reset"],
input[type="submit"] {
font-size: 12px;
padding: 12px 30px;
margin-bottom: 10px;
width: 200px;
border: 1px solid #007af4;
color: #007af4;
text-transform: uppercase;
letter-spacing: 4px;
background-color: transparent;
-webkit-transition: all 0.3s;
transition: all 0.3s;
cursor: pointer;
/* Improves usability and consistency of cursor style between image-type 'input' and others */
-webkit-appearance: button;
/* Corrects inability to style clickable 'input' types in iOS */
}
.button:hover a {
color: #FFFFFF
}
.button {
-webkit-appearance: none;
}
input[type="submit"] {
margin-top: 5px;
}
button:hover,
.button:hover,
input[type="button"]:hover,
input[type="reset"]:hover,
input[type="submit"]:hover {
background-color: #007af4;
text-decoration: none;
color: #FFFFFF;
}
```
```html
<div class="button">
<a href="javascript:void(0)" onclick="javascript:jqcc.cometchat.chatWith(<?PHP echo bp_displayed_user_id(); ?>);">Chat with us<a>
</div>
``` | When you are changing a links colour on hover you need to make sure to apply it to the `a` tag directly. So in your case you want a style similar to the following:
```
a:hover {
color: white;
}
``` |
46,061,388 | I am trying to change the background color and text color of a link inside a button that I created, but only the background color changes. The text remains it's default color and refuses to change regardless of !important tags.
Here is my code:
```css
button,
input,
select,
textarea {
font-size: 100%;
/* Corrects font size not being inherited in all browsers */
margin: 0;
/* Addresses margins set differently in IE6/7, F3/4, S5, Chrome */
vertical-align: baseline;
/* Improves appearance and consistency in all browsers */
padding: 15px;
}
button,
.button,
input[type="button"],
input[type="reset"],
input[type="submit"] {
font-size: 12px;
padding: 12px 30px;
margin-bottom: 10px;
width: 200px;
border: 1px solid #007af4;
color: #007af4;
text-transform: uppercase;
letter-spacing: 4px;
background-color: transparent;
-webkit-transition: all 0.3s;
transition: all 0.3s;
cursor: pointer;
/* Improves usability and consistency of cursor style between image-type 'input' and others */
-webkit-appearance: button;
/* Corrects inability to style clickable 'input' types in iOS */
}
.button {
-webkit-appearance: none;
}
input[type="submit"] {
margin-top: 5px;
}
button:hover,
.button:hover,
input[type="button"]:hover,
input[type="reset"]:hover,
input[type="submit"]:hover {
background-color: #007af4;
text-decoration: none;
color: #FFFFFF;
}
```
```html
<div class="button">
<a href="javascript:void(0)" onclick="javascript:jqcc.cometchat.chatWith(<?PHP echo bp_displayed_user_id(); ?>);">Chat with us<a>
</div>
```
I've already looked at these two threads:
[a:hover color is not working](https://stackoverflow.com/questions/16967118/ahover-color-is-not-working)
[a: hover, color is not changing](https://stackoverflow.com/questions/35241294/a-hover-color-is-not-changing)
Neither of the answers given on those threads helped with my problem (Unless I've overlooked something), so any help is greatly appreciated! | 2017/09/05 | ['https://Stackoverflow.com/questions/46061388', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/8565234/'] | When you are changing a links colour on hover you need to make sure to apply it to the `a` tag directly. So in your case you want a style similar to the following:
```
a:hover {
color: white;
}
``` | A link already has an predefined style. You need to remove that style first to apply your style. Try this in your link
```
text-decoration: none
```
Try hover after that. |
46,061,388 | I am trying to change the background color and text color of a link inside a button that I created, but only the background color changes. The text remains it's default color and refuses to change regardless of !important tags.
Here is my code:
```css
button,
input,
select,
textarea {
font-size: 100%;
/* Corrects font size not being inherited in all browsers */
margin: 0;
/* Addresses margins set differently in IE6/7, F3/4, S5, Chrome */
vertical-align: baseline;
/* Improves appearance and consistency in all browsers */
padding: 15px;
}
button,
.button,
input[type="button"],
input[type="reset"],
input[type="submit"] {
font-size: 12px;
padding: 12px 30px;
margin-bottom: 10px;
width: 200px;
border: 1px solid #007af4;
color: #007af4;
text-transform: uppercase;
letter-spacing: 4px;
background-color: transparent;
-webkit-transition: all 0.3s;
transition: all 0.3s;
cursor: pointer;
/* Improves usability and consistency of cursor style between image-type 'input' and others */
-webkit-appearance: button;
/* Corrects inability to style clickable 'input' types in iOS */
}
.button {
-webkit-appearance: none;
}
input[type="submit"] {
margin-top: 5px;
}
button:hover,
.button:hover,
input[type="button"]:hover,
input[type="reset"]:hover,
input[type="submit"]:hover {
background-color: #007af4;
text-decoration: none;
color: #FFFFFF;
}
```
```html
<div class="button">
<a href="javascript:void(0)" onclick="javascript:jqcc.cometchat.chatWith(<?PHP echo bp_displayed_user_id(); ?>);">Chat with us<a>
</div>
```
I've already looked at these two threads:
[a:hover color is not working](https://stackoverflow.com/questions/16967118/ahover-color-is-not-working)
[a: hover, color is not changing](https://stackoverflow.com/questions/35241294/a-hover-color-is-not-changing)
Neither of the answers given on those threads helped with my problem (Unless I've overlooked something), so any help is greatly appreciated! | 2017/09/05 | ['https://Stackoverflow.com/questions/46061388', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/8565234/'] | If you want to change the `<a>` text color when hovering over the enclosing `.button` you can do this:
```
.button:hover a {
color: #FFFFFF
}
```
This has the advantage of not needing to hover over the actual link -- when you hover over any part of the button, the link color will change and stay readable.
```css
button,
input,
select,
textarea {
font-size: 100%;
/* Corrects font size not being inherited in all browsers */
margin: 0;
/* Addresses margins set differently in IE6/7, F3/4, S5, Chrome */
vertical-align: baseline;
/* Improves appearance and consistency in all browsers */
padding: 15px;
}
button,
.button,
input[type="button"],
input[type="reset"],
input[type="submit"] {
font-size: 12px;
padding: 12px 30px;
margin-bottom: 10px;
width: 200px;
border: 1px solid #007af4;
color: #007af4;
text-transform: uppercase;
letter-spacing: 4px;
background-color: transparent;
-webkit-transition: all 0.3s;
transition: all 0.3s;
cursor: pointer;
/* Improves usability and consistency of cursor style between image-type 'input' and others */
-webkit-appearance: button;
/* Corrects inability to style clickable 'input' types in iOS */
}
.button:hover a {
color: #FFFFFF
}
.button {
-webkit-appearance: none;
}
input[type="submit"] {
margin-top: 5px;
}
button:hover,
.button:hover,
input[type="button"]:hover,
input[type="reset"]:hover,
input[type="submit"]:hover {
background-color: #007af4;
text-decoration: none;
color: #FFFFFF;
}
```
```html
<div class="button">
<a href="javascript:void(0)" onclick="javascript:jqcc.cometchat.chatWith(<?PHP echo bp_displayed_user_id(); ?>);">Chat with us<a>
</div>
``` | A link already has an predefined style. You need to remove that style first to apply your style. Try this in your link
```
text-decoration: none
```
Try hover after that. |
11,934,236 | Is there anything similar to [Celery](http://celeryproject.org) for Ruby? Is there anyone with any experience with [rcelery](https://github.com/leapfrogonline/rcelery)? Is it a good choice for production?
Update: I came across [resque](https://github.com/resque/resque), which looks like something I might be able to use for my task. Any further suggestions welcome! | 2012/08/13 | ['https://Stackoverflow.com/questions/11934236', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/-1/'] | There are a lot of options for queues in ruby.
Sidekiq -> <https://github.com/mperham/sidekiq>
Resque, you got the link
DelayedJob -> <http://blog.leetsoft.com/delayed_job/>
All of them are pretty much the same. So you just need to use the one you are more confortable working with the examples.
In my projects i ended up using `Sidekiq`, the reviews about it are pretty awesome. | Here is a good comparison of Resque and Sidekiq.
[Resque vs Sidekiq?](https://stackoverflow.com/questions/11580954/resque-vs-sidekiq)
Sidekiq uses threads so there is a much lower memory footprint then Resque or delayed job. the downside, and a huge one i think, is your workers MUST be thread safe, including whatever gems you use in them. vetting all the code that goes into workers for thread safety is a on-taking for sure, as is potentially debugging contention in lower level libs, seg faults, etc.. |
11,012,218 | I have the following mysql table. I have been trying to select all the rows which are related with the row that has `B` as value in the `code` column. The relation is based on the value of the column `trans_id`
```
id trans_id code amount side
1 1 A 200 left
2 1 B 200 right
3 2 J 100 right
4 2 C 100 right
5 2 B 200 left
6 3 A 630 right
7 3 K 630 left
```
My Expected Result:
```
id trans_id code amount side
1 1 A 200 left
3 2 J 100 right
4 2 C 100 right
```
Could you please tell me what should be the mysql query to achieve this?
Thanks :) | 2012/06/13 | ['https://Stackoverflow.com/questions/11012218', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1209690/'] | Your question is unclear, but as far as I understand, you could use a self join like this:
```
select a.id,
a.trans_id,
a.code,
a.amount,
a.side
from table as a
inner join table as b on (a.id=b.trans_id and b.code='B');
```
This will return the row with table.id=2:
```
id trans_id code amount side
2 1 B 200 right
``` | If I'm understanding your problem correctly then a subquery would get you what you need.
```
SELECT * FROM yourTable WHERE id IN (SELECT trans_id FROM yourTable WHERE code='B')
``` |
11,012,218 | I have the following mysql table. I have been trying to select all the rows which are related with the row that has `B` as value in the `code` column. The relation is based on the value of the column `trans_id`
```
id trans_id code amount side
1 1 A 200 left
2 1 B 200 right
3 2 J 100 right
4 2 C 100 right
5 2 B 200 left
6 3 A 630 right
7 3 K 630 left
```
My Expected Result:
```
id trans_id code amount side
1 1 A 200 left
3 2 J 100 right
4 2 C 100 right
```
Could you please tell me what should be the mysql query to achieve this?
Thanks :) | 2012/06/13 | ['https://Stackoverflow.com/questions/11012218', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1209690/'] | ```
select
t1.*
from
table_name t1
inner join table_name t2 on t1.trans_id = t2.trans_id
where
t2.code = 'B' and
t2.code <> t1.code
``` | If I'm understanding your problem correctly then a subquery would get you what you need.
```
SELECT * FROM yourTable WHERE id IN (SELECT trans_id FROM yourTable WHERE code='B')
``` |
11,012,218 | I have the following mysql table. I have been trying to select all the rows which are related with the row that has `B` as value in the `code` column. The relation is based on the value of the column `trans_id`
```
id trans_id code amount side
1 1 A 200 left
2 1 B 200 right
3 2 J 100 right
4 2 C 100 right
5 2 B 200 left
6 3 A 630 right
7 3 K 630 left
```
My Expected Result:
```
id trans_id code amount side
1 1 A 200 left
3 2 J 100 right
4 2 C 100 right
```
Could you please tell me what should be the mysql query to achieve this?
Thanks :) | 2012/06/13 | ['https://Stackoverflow.com/questions/11012218', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1209690/'] | The following query should return the results you want. This uses a select query to return results to the WHERE clause.
```
SELECT * FROM yourTable
WHERE trans_id IN (
SELECT trans_id FROM yourTable WHERE code='B'
)
AND code!='B'
``` | If I'm understanding your problem correctly then a subquery would get you what you need.
```
SELECT * FROM yourTable WHERE id IN (SELECT trans_id FROM yourTable WHERE code='B')
``` |
11,012,218 | I have the following mysql table. I have been trying to select all the rows which are related with the row that has `B` as value in the `code` column. The relation is based on the value of the column `trans_id`
```
id trans_id code amount side
1 1 A 200 left
2 1 B 200 right
3 2 J 100 right
4 2 C 100 right
5 2 B 200 left
6 3 A 630 right
7 3 K 630 left
```
My Expected Result:
```
id trans_id code amount side
1 1 A 200 left
3 2 J 100 right
4 2 C 100 right
```
Could you please tell me what should be the mysql query to achieve this?
Thanks :) | 2012/06/13 | ['https://Stackoverflow.com/questions/11012218', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1209690/'] | The following query should return the results you want. This uses a select query to return results to the WHERE clause.
```
SELECT * FROM yourTable
WHERE trans_id IN (
SELECT trans_id FROM yourTable WHERE code='B'
)
AND code!='B'
``` | Your question is unclear, but as far as I understand, you could use a self join like this:
```
select a.id,
a.trans_id,
a.code,
a.amount,
a.side
from table as a
inner join table as b on (a.id=b.trans_id and b.code='B');
```
This will return the row with table.id=2:
```
id trans_id code amount side
2 1 B 200 right
``` |
11,012,218 | I have the following mysql table. I have been trying to select all the rows which are related with the row that has `B` as value in the `code` column. The relation is based on the value of the column `trans_id`
```
id trans_id code amount side
1 1 A 200 left
2 1 B 200 right
3 2 J 100 right
4 2 C 100 right
5 2 B 200 left
6 3 A 630 right
7 3 K 630 left
```
My Expected Result:
```
id trans_id code amount side
1 1 A 200 left
3 2 J 100 right
4 2 C 100 right
```
Could you please tell me what should be the mysql query to achieve this?
Thanks :) | 2012/06/13 | ['https://Stackoverflow.com/questions/11012218', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1209690/'] | The following query should return the results you want. This uses a select query to return results to the WHERE clause.
```
SELECT * FROM yourTable
WHERE trans_id IN (
SELECT trans_id FROM yourTable WHERE code='B'
)
AND code!='B'
``` | ```
select
t1.*
from
table_name t1
inner join table_name t2 on t1.trans_id = t2.trans_id
where
t2.code = 'B' and
t2.code <> t1.code
``` |
9,544,602 | graph.h
```
struct Edge {
int from;
int to;
int elabel;
unsigned int id;
Edge(): from(0), to(0), elabel(0), id(0) {};
};
```
What is the difference between `vector<Edge>` and `vector<Edge*>`? I know `vector<Edge>` is an array storing `Edge` objects, but what is the `Edge*` object? | 2012/03/03 | ['https://Stackoverflow.com/questions/9544602', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/419284/'] | The `Edge*` type is a pointer-to-edge. So a `vector<Edge*>` is a vector that stores pointers-to-edges.
The vector itself doesn't store the objects, only pointers to those objects. This means in particular that the pointed-to objects don't get automatically deleted when the pointer's lifetime ends. | `Edge*` is a pointer to an `Edge`. [Read up on Pointers in C++.](http://www.cplusplus.com/doc/tutorial/pointers/) |
2,289,288 | Say I'm cloning a repository that I always clone to `C:\working_copies\<customer-name>\<customer-project>\` and that the project has variables in it's `build.properties` that get filled in with `<customer-name> <customer-project>` (by me) everytime I clone the repo.
Is there a way that I can fill in these values in the file automatically by placing some special value in the file (in ant it's something like `${base-dir}` or something like that) that would fill in these build.property values for me? | 2010/02/18 | ['https://Stackoverflow.com/questions/2289288', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/18149/'] | From (hazy) memory, that was the tag used by SCCS back in the "good old days". Given that (to my knowledge), BitKeeper uses SCCS underneath, it could be BitKeeper. | It is usually something that is added automatically by the version control system. |
2,289,288 | Say I'm cloning a repository that I always clone to `C:\working_copies\<customer-name>\<customer-project>\` and that the project has variables in it's `build.properties` that get filled in with `<customer-name> <customer-project>` (by me) everytime I clone the repo.
Is there a way that I can fill in these values in the file automatically by placing some special value in the file (in ant it's something like `${base-dir}` or something like that) that would fill in these build.property values for me? | 2010/02/18 | ['https://Stackoverflow.com/questions/2289288', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/18149/'] | `@(#)` is the character string used by the Unix `what` command to filter strings from binaries to list the components that were used to build that binary. For instance `what java` on AIX yields:
```
java:
23 1.4 src/bos/usr/ccs/lib/libpthreads/init.c, libpth, bos520 8/19/99 12:20:14
61 1.14 src/bos/usr/ccs/lib/libc/__threads_init.c, libcthrd, bos520 7/11/00 12:04:14
src/tools/sov/java.c, tool, asdev, 20081128 1.83.1.36
src/misc/sov/copyrght.c, core, asdev, 20081128 1.8
```
while `strings java | grep '@(#)' yields:
```
@(#)23 1.4 src/bos/usr/ccs/lib/libpthreads/init.c, libpth, bos520 8/19/99 12:20:14
@(#)61 1.14 src/bos/usr/ccs/lib/libc/__threads_init.c, libcthrd, bos520 7/11/00 12:04:14
@(#)src/tools/sov/java.c, tool, asdev, 20081128 1.83.1.36
@(#)src/misc/sov/copyrght.c, core, asdev, 20081128 1.8
```
`@(#)` was chosen as marker because it would not occur elsewhere, source code controls systems typically add a line containing this marker and the description of the file version on synchronisation, expanding keywords with values reflecting the file contents.
For instance, the comment you list would be the result of expanding the SCCS keywords `%Z% %M% %R%.%L% %E%` where the `%Z%` translates into `@(#)`. | It is usually something that is added automatically by the version control system. |
2,289,288 | Say I'm cloning a repository that I always clone to `C:\working_copies\<customer-name>\<customer-project>\` and that the project has variables in it's `build.properties` that get filled in with `<customer-name> <customer-project>` (by me) everytime I clone the repo.
Is there a way that I can fill in these values in the file automatically by placing some special value in the file (in ant it's something like `${base-dir}` or something like that) that would fill in these build.property values for me? | 2010/02/18 | ['https://Stackoverflow.com/questions/2289288', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/18149/'] | From (hazy) memory, that was the tag used by SCCS back in the "good old days". Given that (to my knowledge), BitKeeper uses SCCS underneath, it could be BitKeeper. | That construct has no special meaning in Java. It is just some text in a comment.
It looks like something that's inserted by a version control system. |
2,289,288 | Say I'm cloning a repository that I always clone to `C:\working_copies\<customer-name>\<customer-project>\` and that the project has variables in it's `build.properties` that get filled in with `<customer-name> <customer-project>` (by me) everytime I clone the repo.
Is there a way that I can fill in these values in the file automatically by placing some special value in the file (in ant it's something like `${base-dir}` or something like that) that would fill in these build.property values for me? | 2010/02/18 | ['https://Stackoverflow.com/questions/2289288', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/18149/'] | `@(#)` is the character string used by the Unix `what` command to filter strings from binaries to list the components that were used to build that binary. For instance `what java` on AIX yields:
```
java:
23 1.4 src/bos/usr/ccs/lib/libpthreads/init.c, libpth, bos520 8/19/99 12:20:14
61 1.14 src/bos/usr/ccs/lib/libc/__threads_init.c, libcthrd, bos520 7/11/00 12:04:14
src/tools/sov/java.c, tool, asdev, 20081128 1.83.1.36
src/misc/sov/copyrght.c, core, asdev, 20081128 1.8
```
while `strings java | grep '@(#)' yields:
```
@(#)23 1.4 src/bos/usr/ccs/lib/libpthreads/init.c, libpth, bos520 8/19/99 12:20:14
@(#)61 1.14 src/bos/usr/ccs/lib/libc/__threads_init.c, libcthrd, bos520 7/11/00 12:04:14
@(#)src/tools/sov/java.c, tool, asdev, 20081128 1.83.1.36
@(#)src/misc/sov/copyrght.c, core, asdev, 20081128 1.8
```
`@(#)` was chosen as marker because it would not occur elsewhere, source code controls systems typically add a line containing this marker and the description of the file version on synchronisation, expanding keywords with values reflecting the file contents.
For instance, the comment you list would be the result of expanding the SCCS keywords `%Z% %M% %R%.%L% %E%` where the `%Z%` translates into `@(#)`. | That construct has no special meaning in Java. It is just some text in a comment.
It looks like something that's inserted by a version control system. |
2,289,288 | Say I'm cloning a repository that I always clone to `C:\working_copies\<customer-name>\<customer-project>\` and that the project has variables in it's `build.properties` that get filled in with `<customer-name> <customer-project>` (by me) everytime I clone the repo.
Is there a way that I can fill in these values in the file automatically by placing some special value in the file (in ant it's something like `${base-dir}` or something like that) that would fill in these build.property values for me? | 2010/02/18 | ['https://Stackoverflow.com/questions/2289288', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/18149/'] | `@(#)` is the character string used by the Unix `what` command to filter strings from binaries to list the components that were used to build that binary. For instance `what java` on AIX yields:
```
java:
23 1.4 src/bos/usr/ccs/lib/libpthreads/init.c, libpth, bos520 8/19/99 12:20:14
61 1.14 src/bos/usr/ccs/lib/libc/__threads_init.c, libcthrd, bos520 7/11/00 12:04:14
src/tools/sov/java.c, tool, asdev, 20081128 1.83.1.36
src/misc/sov/copyrght.c, core, asdev, 20081128 1.8
```
while `strings java | grep '@(#)' yields:
```
@(#)23 1.4 src/bos/usr/ccs/lib/libpthreads/init.c, libpth, bos520 8/19/99 12:20:14
@(#)61 1.14 src/bos/usr/ccs/lib/libc/__threads_init.c, libcthrd, bos520 7/11/00 12:04:14
@(#)src/tools/sov/java.c, tool, asdev, 20081128 1.83.1.36
@(#)src/misc/sov/copyrght.c, core, asdev, 20081128 1.8
```
`@(#)` was chosen as marker because it would not occur elsewhere, source code controls systems typically add a line containing this marker and the description of the file version on synchronisation, expanding keywords with values reflecting the file contents.
For instance, the comment you list would be the result of expanding the SCCS keywords `%Z% %M% %R%.%L% %E%` where the `%Z%` translates into `@(#)`. | From (hazy) memory, that was the tag used by SCCS back in the "good old days". Given that (to my knowledge), BitKeeper uses SCCS underneath, it could be BitKeeper. |
52,322,097 | Say I was observing a variable
`m.someObject.observeField("content", "onContentChanged")`
after a certain period of time I no longer need `m.someObject`.
Do I need to cleanup and call
`m.someObject.unobserveField("content")`
or can I just leave it? | 2018/09/13 | ['https://Stackoverflow.com/questions/52322097', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/5673746/'] | Yes, try to follow this as a good practice, just like when dealing with files after `open()` should eventually call `close()` (even as, generally speaking going out of scope takes care of closing connections, it's a good practice to explicitly take care of it).
Now, beware that `node.unobserveField("X")` is a "nuclear" option in that it drops *any and all* observers on node.X that were placed with `node.observeField("X", ...)`, regardless from what component or thread they came. So if having more than one observer per field, you may end up regretting and eventually avoiding unobserveField() use altogether. Mind you, when the `node` is destroyed, these observers will be taken care of (i.e. not a memory leak).
Now, there is also a newer API that's better in many cases - the "...Scoped()" versions of these methods. In that version, the `node.unobserveFieldScoped("X")` is more selective - it only removes the observer(s) on node.X that were placed by the *current component*; observers set by other components remain active.
For me it's easier to distinguish between these two approaches by thinking of *where* is the observer link stored. In the non-scoped versions, all links are stored with the observed object - and so the destructor takes care of cleaning the links. In the scoped versions, links are stored with each observING component - so Unobserve acts locally only on these. And so i believe there is a caveat - if observED object is destroyed, it will leave (temporarily) some hanging *scoped* links in observING objects. Conversely, if non-scoped ObserveField() was used, destruction of observING object will leave uncleaned link in the observED object (that will get cleaned when it gets droped). | Yeah, you should. Roku doesn't have the worlds greatest garbage collection and we've noticed considerable performance improvements from being careful about that. |
11,661 | or is there something else that is opposite or similar to it...
From all the teachings i have received the rule I'd say is Islamic is do what's the best. Basically people change so labelling someone as sinner may make us overlook his/her good parts and overlook their change if it occurs.
Please provide hadiths/Quran if possible | 2014/03/06 | ['https://islam.stackexchange.com/questions/11661', 'https://islam.stackexchange.com', 'https://islam.stackexchange.com/users/2948/'] | “Hate the sin, not the sinner” is only partly correct in Islam. Only a sinner with sins wholly occupying his heart making his heart dark lacking any light spot survived in it is one we should hate and even curse against them, though, if we can identify them correctly. About any other sinner no we cannot hate himself, but we must hate the sin, and the majority of the sinners belong to this latter group. The former group are those who would be left in the hell eternally, the rest will be survived from the hell and let enter the heaven after centuries and maybe millenniums or more of being tortured in the hell.
Those with completely dark hearts will never find the opportunity to repent in Dunya (world), they are Taqut (طاغوت: or leaders inviting to the Fire: أَئِمَّةً يَدْعُونَ إِلَى النَّارِ, Al-Qasas,41) against which Allah has ordered us to be Kafir about them. The others we should always have hope that they may repent, and we should help them so by enjoying them to what is right and banning them from what s wrong.
>
> اللَّـهُ وَلِيُّ الَّذِينَ آمَنُوا يُخْرِجُهُم مِّنَ الظُّلُمَاتِ
> إِلَى النُّورِ ۖ وَالَّذِينَ كَفَرُوا أَوْلِيَاؤُهُمُ الطَّاغُوتُ
> يُخْرِجُونَهُم مِّنَ النُّورِ إِلَى الظُّلُمَاتِ ۗ أُولَـٰئِكَ
> أَصْحَابُ النَّارِ ۖ هُمْ فِيهَا خَالِدُونَ
>
>
> Allah is the ally of those who believe. He brings them out from
> darknesses into the light. And those who disbelieve - their allies are
> Taghut. They take them out of the light into darknesses. Those are the
> companions of the Fire; they will abide eternally therein.
> [Al-Baqareh, 257]
>
>
>
Godspeed | It depends on the type of sin.
Quran says there has already been for you an excellent pattern in Abraham. So this means that we should follow this pattern. He many times invited his people to monotheism by kindness. But they still insisted on Shirk and did not leave their idols and tried to kill prophet Ibrahim a.s.
A Muslims should disassociate and have animosity and hatred about Mushrik people (those who worship other than Allah like idol, Satan...). But hating is some different. We can disassociate one but still love him for guidance.
>
> There has already been for you an excellent pattern in Abraham and
> those with him, when they said to their people, "Indeed, we are
> disassociated from you and from whatever you worship other than Allah.
> We have denied you, and there has appeared between us and you
> animosity and hatred forever until you believe in Allah alone" except
> for the saying of Abraham to his father, "I will surely ask
> forgiveness for you, but I have not [power to do] for you anything
> against Allah. Our Lord, upon You we have relied, and to You we have
> returned, and to You is the destination. <http://tanzil.net/#60:4>
>
>
>
Prophet Muhammad SAWW did so also. he invited people many times and many of them accepted but some still did not accept and tried to kill prophet and made wars like Badr, Uhod and other wars and tried to kill Muslims. so then prophet made around 100 wars against them (although himself did not participate in all of them directly).
But it is important to distinguish between clear Shirk and Hidden Shirk. This applies only to clear Shirk. Because many of believers have hidden shirk:
>
> And most of them believe not in Allah except while they associate
> others with Him. <http://tanzil.net/#12:106>
>
>
>
But a Muslim who believes in Allah but still is sinner is different.
>
> There has certainly come to you a Messenger from among yourselves.
> Grievous to him is what you suffer; [he is] concerned over you and to
> the believers is kind and merciful. <http://tanzil.net/#9:128>
>
>
>
We should love and guide Muslims who are going astray and are sinner. |
23,010,340 | How do you use **name** with a function that I'd like to pass a keyword argument through?
For example, I have the following function:
```
def func(keyword1='A'):
print keyword1
```
I can do this:
```
func.__name__
>> 'func'
```
But, I'd like to do this:
```
func(keyword1='B').__name__
>>> 'func'
```
The reason I'd like to do this is because I have another method that takes in this function as an argument and it needs to pull the name of the function and run that function with different keywords.
So, what I'm really trying to do is get this function to work:
```
def Function_Name_And_Result(x):
print x.__name__ + x()
Function_Name_And_Result(func(keyword1='B'))
>> funcB
``` | 2014/04/11 | ['https://Stackoverflow.com/questions/23010340', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2850808/'] | Python's functions are objects too, so you can pass them along just like any other object. What you're doing (which can't obviously work) is passing the result of calling the function. What you want is to pass the function and the function's argument:
```
def print_function_name_and_result(func, *args, **kw):
print "%s : %s" % (func.__name__, func(*args, **kw))
print_function_name_and_result(func, keyword1='B')
>> func : B
``` | If you have a method that takes a function, **then pass in the function**, not the return value.
You are instead calling the function. The `.__name__` attribute lookup is applied to the return value of that call. If you are passing the *return value* of a function call to your method, you are **not** passing the function object itself.
If you need to pass in a function that needs to be called with certain arguments *by the method*, you can pass in those extra arguments instead, and have the method use those arguments for you:
```
def Function_Name_And_Result(x, *args, **kw):
print x.__name__, x(*args, **kw)
```
Now you can still pass in your function object *itself*:
```
Function_Name_And_Result(func, keyword1='B')
```
Demo:
```
>>> def Function_Name_And_Result(x, *args, **kw):
... print x.__name__, x(*args, **kw)
...
>>> def func(keyword1='A'):
... print keyword1
...
>>> Function_Name_And_Result(func, keyword1='B')
func B
None
``` |
44,871 | I have a big share (~5TB) that is getting full.
Now I want to make a script that deletes data from 2 specified folders. But this need to be the oldest files/folders and it need to stop when ~50GB has been removed, so it won't delete all folders.
**Edit:** This need to work with Samba shares for my Synology DS-409. The script need to run on the Synology in /etc/crontab.
Somewhere else they gave me this code:
```
#!/opt/bin/bash
dir=/data/video
min_dirs=3
full=60
logfile=/var/tmp/removed.log
df=`df | grep data | awk '{print $5}' | sed s/%//g`
if [ $df -gt $full ]; then
[[ $(find "$dir" -type d | wc -l) -ge $min_dirs ]] &&
IFS= read -r -d $'\0' line < <(find "$dir" -printf '%T@ %p\0' 2>/dev/null | sort -z -n)
file="${line#* }"
ls -lLd "$file"
#rm -rf "$file"
date=`date`
if [ -f "$file" ]; then
echo "$date $file could not be removed!" >> $logfile
else
echo "$date $file removed" >> $logfile
fi
fi
``` | 2012/08/06 | ['https://unix.stackexchange.com/questions/44871', 'https://unix.stackexchange.com', 'https://unix.stackexchange.com/users/21697/'] | This should work:
```
DIRS="a/ b/"
MAXDELBYTES="53687091200" # 50GB
DELBYTES="0"
find $DIRS -type f -printf "%T@ %s %p\n" | sort -r -n | while read time bytes filename
do
rm -fv "$filename"
DELBYTES=$((DELBYTES + bytes))
if [ $DELBYTES -ge $MAXDELBYTES ]; then break; fi
done
``` | scai, autodelete.txt is a file i created in windows and uploaded to a linux share :)
Now i have made this code in nano because of windows linux code problems.
But now it gives a bunch of error's
```
root ~/.config # sh autodelete
find: unrecognized: -printf
BusyBox v1.20.2 (2012-08-09 05:49:15 CEST) multi-call binary.
Usage: find [PATH]... [OPTIONS] [ACTIONS]
Search for files and perform actions on them.
First failed action stops processing of current file.
Defaults: PATH is current directory, action is '-print'
-follow Follow symlinks
Actions:
! ACT Invert ACT's success/failure
ACT1 [-a] ACT2 If ACT1 fails, stop, else do ACT2
ACT1 -o ACT2 If ACT1 succeeds, stop, else do ACT2
Note: -a has higher priority than -o
-name PATTERN Match file name (w/o directory name) to PATTERN
-iname PATTERN Case insensitive -name
-path PATTERN Match path to PATTERN
-ipath PATTERN Case insensitive -path
-type X File type is X (one of: f,d,l,b,c,...)
-links N Number of links is greater than (+N), less than (-N),
or exactly N
If none of the following actions is specified, -print is assumed
-print Print file name
-exec CMD ARG ; Run CMD with all instances of {} replaced by
file name. Fails if CMD exits with nonzero
autodelete: line 11: bytes: not found
``` |
282,604 | I have two tables. Each holds some attributes for a business entity and the date range for which those attributes were valid. I want to combine these tables into one, matching rows on the common business key and splitting the time ranges.
The real-world example is two source temporal tables feeding a type-2 dimension table in the data warehouse.
The entity can be present in neither, one or both of the source systems at any point in time. Once an entity is recorded in a source system the intervals are well-behaved - no gaps, duplicates or other monkey business. Membership in the sources can end at different dates.
The business rules state we only want to return intervals where the entity is present in both sources simultaneously.
What query will give this result?
This illustrates the situation:
```
Month J F M A M J J
Source A: <--><----------><----------><---->
Source B: <----><----><----------------><-->
Result: <----><----><----><---->
```
Sample Data
-----------
For simplicity I've used closed date intervals; likely any solution could be extended to half-open intervals with a little typing.
```
drop table if exists dbo.SourceA;
drop table if exists dbo.SourceB;
go
create table dbo.SourceA
(
BusinessKey int,
StartDate date,
EndDate date,
Attribute char(9)
);
create table dbo.SourceB
(
BusinessKey int,
StartDate date,
EndDate date,
Attribute char(9)
);
GO
insert dbo.SourceA(BusinessKey, StartDate, EndDate, Attribute)
values
(1, '19990101', '19990113', 'black'),
(1, '19990114', '19990313', 'red'),
(1, '19990314', '19990513', 'blue'),
(1, '19990514', '19990613', 'green'),
(2, '20110714', '20110913', 'pink'),
(2, '20110914', '20111113', 'white'),
(2, '20111114', '20111213', 'gray');
insert dbo.SourceB(BusinessKey, StartDate, EndDate, Attribute)
values
(1, '19990214', '19990313', 'left'),
(1, '19990314', '19990413', 'right'),
(1, '19990414', '19990713', 'centre'),
(1, '19990714', '19990730', 'back'),
(2, '20110814', '20110913', 'top'),
(2, '20110914', '20111013', 'middle'),
(2, '20111014', '20120113', 'bottom');
```
Desired output
--------------
```
BusinessKey StartDate EndDate a_Colour b_Placement
----------- ---------- ---------- --------- -----------
1 1999-02-14 1999-03-13 red left
1 1999-03-14 1999-04-13 blue right
1 1999-04-14 1999-05-13 blue centre
1 1999-05-14 1999-06-13 green centre
2 2011-08-14 2011-09-13 pink top
2 2011-09-14 2011-10-13 white middle
2 2011-10-14 2011-11-13 white bottom
2 2011-11-14 2011-12-13 gray bottom
``` | 2021/01/05 | ['https://dba.stackexchange.com/questions/282604', 'https://dba.stackexchange.com', 'https://dba.stackexchange.com/users/36809/'] | I may have misunderstood your question, but the results seem to be according to your question:
```
select a.businesskey
-- greatest(a.startdate, b.startdate)
, case when a.startdate > b.startdate
then a.startdate
else b.startdate
end as startdate
-- least(a.enddate, b.enddate)
, case when a.enddate < b.enddate
then a.enddate
else b.enddate
end as enddate
, a.attribute as a_color
, b.attribute as b_placement
from dbo.SourceA a
join dbo.SourceB b
on a.businesskey = b.businesskey
and (a.startdate between b.startdate and b.enddate
or b.startdate between a.startdate and a.enddate)
order by 1,2
```
Since intervals need to overlap most of the work can be done with a join with that as the predicate. Then it's just a matter of choosing the intersection of the intervals.
LEAST and GREATEST seem to be missing as functions, so I used a case expression instead.
[Fiddle](https://dbfiddle.uk/?rdbms=sqlserver_2019&fiddle=5cf15423456c3e879560cb0df46948c5) | This solution deconstructs the source intervals to just their starting dates. By combining these two list a set of output interval start dates are obtained. From these the corresponding output end dates are calculated by a window function. As the final output interval must end when either of the two input intervals end there is special processing to determine this value.
```
;with Dates as
(
select BusinessKey, StartDate
from dbo.SourceA
union
select BusinessKey, StartDate
from dbo.SourceB
union
select x.BusinessKey, DATEADD(DAY, 1, MIN(x.EndDate))
from
(
select BusinessKey, EndDate = MAX(EndDate)
from dbo.SourceA
group by BusinessKey
union all
select BusinessKey, EndDate = MAX(EndDate)
from dbo.SourceB
group by BusinessKey
) as x
group by x.BusinessKey
),
Intervals as
(
select
dt.BusinessKey,
dt.StartDate,
EndDate = lead (DATEADD(DAY, -1, dt.StartDate), 1)
over (partition by dt.BusinessKey order by dt.StartDate)
from Dates as dt
)
select
i.BusinessKey,
i.StartDate,
i.EndDate,
a_Colour = a.Attribute,
b_Placement = b.Attribute
from Intervals as i
inner join dbo.SourceA as a
on i.BusinessKey = a.BusinessKey
and i.StartDate between a.StartDate and a.EndDate
inner join dbo.SourceB as b
on i.BusinessKey = b.BusinessKey
and i.StartDate between b.StartDate and b.EndDate
where i.EndDate is not NULL
order by
i.BusinessKey,
i.StartDate;
```
The "Dates" CTE uses UNION rather than UNION ALL to eliminate duplicates. If both sources change on the same date we want only one corresponding output row.
As we want to close output when either source closes the third query in "Dates" adds the earliest end date i.e. the MIN of the MAX of EndDates. As it is an EndDate masquerading as a StartDate it must have another day added to it. It's purpose is to allow the window function to calculate the end of the preceding interval. It will be eliminated in the final predicate.
Using inner joins for the final query eliminates those source intervals for which there is no corresponding value in the other source. |
282,604 | I have two tables. Each holds some attributes for a business entity and the date range for which those attributes were valid. I want to combine these tables into one, matching rows on the common business key and splitting the time ranges.
The real-world example is two source temporal tables feeding a type-2 dimension table in the data warehouse.
The entity can be present in neither, one or both of the source systems at any point in time. Once an entity is recorded in a source system the intervals are well-behaved - no gaps, duplicates or other monkey business. Membership in the sources can end at different dates.
The business rules state we only want to return intervals where the entity is present in both sources simultaneously.
What query will give this result?
This illustrates the situation:
```
Month J F M A M J J
Source A: <--><----------><----------><---->
Source B: <----><----><----------------><-->
Result: <----><----><----><---->
```
Sample Data
-----------
For simplicity I've used closed date intervals; likely any solution could be extended to half-open intervals with a little typing.
```
drop table if exists dbo.SourceA;
drop table if exists dbo.SourceB;
go
create table dbo.SourceA
(
BusinessKey int,
StartDate date,
EndDate date,
Attribute char(9)
);
create table dbo.SourceB
(
BusinessKey int,
StartDate date,
EndDate date,
Attribute char(9)
);
GO
insert dbo.SourceA(BusinessKey, StartDate, EndDate, Attribute)
values
(1, '19990101', '19990113', 'black'),
(1, '19990114', '19990313', 'red'),
(1, '19990314', '19990513', 'blue'),
(1, '19990514', '19990613', 'green'),
(2, '20110714', '20110913', 'pink'),
(2, '20110914', '20111113', 'white'),
(2, '20111114', '20111213', 'gray');
insert dbo.SourceB(BusinessKey, StartDate, EndDate, Attribute)
values
(1, '19990214', '19990313', 'left'),
(1, '19990314', '19990413', 'right'),
(1, '19990414', '19990713', 'centre'),
(1, '19990714', '19990730', 'back'),
(2, '20110814', '20110913', 'top'),
(2, '20110914', '20111013', 'middle'),
(2, '20111014', '20120113', 'bottom');
```
Desired output
--------------
```
BusinessKey StartDate EndDate a_Colour b_Placement
----------- ---------- ---------- --------- -----------
1 1999-02-14 1999-03-13 red left
1 1999-03-14 1999-04-13 blue right
1 1999-04-14 1999-05-13 blue centre
1 1999-05-14 1999-06-13 green centre
2 2011-08-14 2011-09-13 pink top
2 2011-09-14 2011-10-13 white middle
2 2011-10-14 2011-11-13 white bottom
2 2011-11-14 2011-12-13 gray bottom
``` | 2021/01/05 | ['https://dba.stackexchange.com/questions/282604', 'https://dba.stackexchange.com', 'https://dba.stackexchange.com/users/36809/'] | I may have misunderstood your question, but the results seem to be according to your question:
```
select a.businesskey
-- greatest(a.startdate, b.startdate)
, case when a.startdate > b.startdate
then a.startdate
else b.startdate
end as startdate
-- least(a.enddate, b.enddate)
, case when a.enddate < b.enddate
then a.enddate
else b.enddate
end as enddate
, a.attribute as a_color
, b.attribute as b_placement
from dbo.SourceA a
join dbo.SourceB b
on a.businesskey = b.businesskey
and (a.startdate between b.startdate and b.enddate
or b.startdate between a.startdate and a.enddate)
order by 1,2
```
Since intervals need to overlap most of the work can be done with a join with that as the predicate. Then it's just a matter of choosing the intersection of the intervals.
LEAST and GREATEST seem to be missing as functions, so I used a case expression instead.
[Fiddle](https://dbfiddle.uk/?rdbms=sqlserver_2019&fiddle=5cf15423456c3e879560cb0df46948c5) | There are a lot of interesting solutions to this problem (stated in different terms) [here](https://sqlperformance.com/2022/03/t-sql-queries/supply-demand-solutions-3) and its preceding pages. There it is presented as matching supply and demand in an auction. The units supplied/demanded is directly analogous to the days in an interval from this question so the solution translates. I've left it in the terms used in the linked site, though.
Sample data.
```
DROP TABLE IF EXISTS dbo.Auctions;
CREATE TABLE dbo.Auctions
(
ID INT NOT NULL IDENTITY(1, 1)
CONSTRAINT pk_Auctions PRIMARY KEY CLUSTERED,
Code CHAR(1) NOT NULL
CONSTRAINT ck_Auctions_Code CHECK (Code = 'D' OR Code = 'S'),
Quantity DECIMAL(19, 6) NOT NULL
CONSTRAINT ck_Auctions_Quantity CHECK (Quantity > 0)
);
SET NOCOUNT ON;
DELETE FROM dbo.Auctions;
SET IDENTITY_INSERT dbo.Auctions ON;
INSERT INTO dbo.Auctions(ID, Code, Quantity) VALUES
(1, 'D', 5.0),
(2, 'D', 3.0),
(3, 'D', 8.0),
(5, 'D', 2.0),
(6, 'D', 8.0),
(7, 'D', 4.0),
(8, 'D', 2.0),
(1000, 'S', 8.0),
(2000, 'S', 6.0),
(3000, 'S', 2.0),
(4000, 'S', 2.0),
(5000, 'S', 4.0),
(6000, 'S', 3.0),
(7000, 'S', 2.0);
```
The solutions expounded reduce the elapsed time for his 400k row sample data from a naive 11 seconds to 0.4s. The fastest is by Paul White (of this parish), shown here.
```
DROP TABLE IF EXISTS #MyPairings;
CREATE TABLE #MyPairings
(
DemandID integer NOT NULL,
SupplyID integer NOT NULL,
TradeQuantity decimal(19, 6) NOT NULL
);
GO
INSERT #MyPairings
WITH (TABLOCK)
(
DemandID,
SupplyID,
TradeQuantity
)
SELECT
Q3.DemandID,
Q3.SupplyID,
Q3.TradeQuantity
FROM
(
SELECT
Q2.DemandID,
Q2.SupplyID,
TradeQuantity =
-- Interval overlap
CASE
WHEN Q2.Code = 'S' THEN
CASE
WHEN Q2.CumDemand >= Q2.IntEnd THEN Q2.IntLength
WHEN Q2.CumDemand > Q2.IntStart THEN Q2.CumDemand - Q2.IntStart
ELSE 0.0
END
WHEN Q2.Code = 'D' THEN
CASE
WHEN Q2.CumSupply >= Q2.IntEnd THEN Q2.IntLength
WHEN Q2.CumSupply > Q2.IntStart THEN Q2.CumSupply - Q2.IntStart
ELSE 0.0
END
END
FROM
(
SELECT
Q1.Code,
Q1.IntStart,
Q1.IntEnd,
Q1.IntLength,
DemandID = MAX(IIF(Q1.Code = 'D', Q1.ID, 0)) OVER (
ORDER BY Q1.IntStart, Q1.ID
ROWS UNBOUNDED PRECEDING),
SupplyID = MAX(IIF(Q1.Code = 'S', Q1.ID, 0)) OVER (
ORDER BY Q1.IntStart, Q1.ID
ROWS UNBOUNDED PRECEDING),
CumSupply = SUM(IIF(Q1.Code = 'S', Q1.IntLength, 0)) OVER (
ORDER BY Q1.IntStart, Q1.ID
ROWS UNBOUNDED PRECEDING),
CumDemand = SUM(IIF(Q1.Code = 'D', Q1.IntLength, 0)) OVER (
ORDER BY Q1.IntStart, Q1.ID
ROWS UNBOUNDED PRECEDING)
FROM
(
-- Demand intervals
SELECT
A.ID,
A.Code,
IntStart = SUM(A.Quantity) OVER (
ORDER BY A.ID
ROWS UNBOUNDED PRECEDING) - A.Quantity,
IntEnd = SUM(A.Quantity) OVER (
ORDER BY A.ID
ROWS UNBOUNDED PRECEDING),
IntLength = A.Quantity
FROM dbo.Auctions AS A
WHERE
A.Code = 'D'
UNION ALL
-- Supply intervals
SELECT
A.ID,
A.Code,
IntStart = SUM(A.Quantity) OVER (
ORDER BY A.ID
ROWS UNBOUNDED PRECEDING) - A.Quantity,
IntEnd = SUM(A.Quantity) OVER (
ORDER BY A.ID
ROWS UNBOUNDED PRECEDING),
IntLength = A.Quantity
FROM dbo.Auctions AS A
WHERE
A.Code = 'S'
) AS Q1
) AS Q2
) AS Q3
WHERE
Q3.TradeQuantity > 0;
``` |
34,015,595 | For some unfathomable reason Google decided to add Splash Screens (Launch Screen) to their design guidelines, I know that,
**1. Splash screen is better than staring at an empty screen.**
................ [ Inflating the main layout and showing a UI without any dynamic data should be very fast. If that's not the case in your app you should fix it by making it fast to load instead of adding a splash screen that will then guarantee that your app is always launching slow.]
**2. Splash screen is better than not having any information if the app is launching other than the launcher button getting pressed.**
**3.app's data takes a long time to load. A splash screen is better than a loading indicator. This especially with slow internet speeds.**
**All these problems , But splash Screen Is not only Single solution I think, It also have some Cons Like:**
1. If you show your app's UI to the user first and then load the data into it you allow user to orient to the UI and they're immediately ready to go when the data comes in.
2. Users don't always want to interact with the data on the app's landing screen. Let the user get on with their task without forcing them to load the first screen's data. This is very important especially on a slow internet connection. Let user interact with your app while the data is loading. In many cases they might not care about the data you're loading by default.
\*\*\*\*\*\*\*\*\*\* Friends,**I am using \*\*UBER App** & even only I want to see my **"Promo code"** To share with friend I need to Open app & Its take lots of time to open and for that much time I stuck on Splash screen & If there is no internet connection then app Stuck on startup I can't even read my **"Promo Code"**
So, My question is that , **can we avoid splash screen there is another alternative?** **Its really needed & useful?** **Why cant we think about any other innovative Concept?** | 2015/12/01 | ['https://Stackoverflow.com/questions/34015595', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/5021501/'] | Sanket, splash screens also allow for the app itself to load. some apps like facebook are not actually apps but the normal website for mobile phones... made into its own special browser for only that website. thus, the app itself must load even its menus, which have icons and all on them. splash screens definitely would be great for those apps, though, other apps such as a non-website app..IE, something that loads locally then connects to the internet to update and cache data would totally be usable without a splash screen. you could straight up display or open the app to a menu and show a loading wheel on the menu options that aren't fully loaded yet. instead of a splash screen, you could also show terms and conditions of your app so users can go ahead and agree to them if they are required (such as apps that require use of an online service.) | Just display a dialog about you app updates or If ur app contains login functionality just use login using dialog.I think it may be an best alternative for splash. |
24,226,385 | How can I get the next word after pregmatch with PHP.
For example, If I have a string like this:
```
"This is a string, keyword next, some more text. keyword next-word."
```
I want to use a `preg_match` to get the next word after “keyword”, including if the word is hyphenated.
So in the case above, I want to return “next” and ”next-word”
I’ve tried :
```
$string = "This is a string, keyword next, some more text. keyword next-word.";
$keywords = preg_split("/(?<=\keyword\s)(\w+)/", $string);
print_r($keywords);
```
Which just returns everything and doesn’t seem to work at all.
Any help is much appreciated. | 2014/06/15 | ['https://Stackoverflow.com/questions/24226385', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3143218/'] | Using your example this should work using [`preg_match_all`](http://www.php.net/manual/en/function.preg-match-all.php):
```
// Set the test string.
$string = "This is a string, keyword next, some more text. keyword next-word. keyword another_word. Okay, keyword do-rae-mi-fa_so_la.";
// Set the regex.
$regex = '/(?<=\bkeyword\s)(?:[\w-]+)/is';
// Run the regex with preg_match_all.
preg_match_all($regex, $string, $matches);
// Dump the resulst for testing.
echo '<pre>';
print_r($matches);
echo '</pre>';
```
And the results I get are:
```
Array
(
[0] => Array
(
[0] => next
[1] => next-word
[2] => another_word
[3] => do-rae-mi-fa_so_la
)
)
``` | Positive look behind is what you are looking for:
```
(?<=\bkeyword\s)([a-zA-Z-]+)
```
Should work perfect with `preg_match`. Use `g` modifier to catch all matches.
[Demo](http://regex101.com/r/nB9rU1)
Reference Question: [How to match the first word after an expression with regex?](https://stackoverflow.com/questions/546220/how-to-match-the-first-word-after-an-expression-with-regex) |
24,226,385 | How can I get the next word after pregmatch with PHP.
For example, If I have a string like this:
```
"This is a string, keyword next, some more text. keyword next-word."
```
I want to use a `preg_match` to get the next word after “keyword”, including if the word is hyphenated.
So in the case above, I want to return “next” and ”next-word”
I’ve tried :
```
$string = "This is a string, keyword next, some more text. keyword next-word.";
$keywords = preg_split("/(?<=\keyword\s)(\w+)/", $string);
print_r($keywords);
```
Which just returns everything and doesn’t seem to work at all.
Any help is much appreciated. | 2014/06/15 | ['https://Stackoverflow.com/questions/24226385', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3143218/'] | Using your example this should work using [`preg_match_all`](http://www.php.net/manual/en/function.preg-match-all.php):
```
// Set the test string.
$string = "This is a string, keyword next, some more text. keyword next-word. keyword another_word. Okay, keyword do-rae-mi-fa_so_la.";
// Set the regex.
$regex = '/(?<=\bkeyword\s)(?:[\w-]+)/is';
// Run the regex with preg_match_all.
preg_match_all($regex, $string, $matches);
// Dump the resulst for testing.
echo '<pre>';
print_r($matches);
echo '</pre>';
```
And the results I get are:
```
Array
(
[0] => Array
(
[0] => next
[1] => next-word
[2] => another_word
[3] => do-rae-mi-fa_so_la
)
)
``` | While regex is powerful, it's also for most of us hard to debug and memorize.
On this particular case, **Get next word after ... match with PHP**, which is a very common string operation.
Simply, by exploding the string in an array, and searching the index. This is useful because we can specify how much words forward or backward.
This match the first occurrence + `1 word`:
```
<?php
$string = explode(" ","This is a string, keyword next, some more text. keyword next-word.");
echo $string[array_search("keyword",$string) + 1];
/* OUTPUT next, *
```
[Run it online](https://3v4l.org/4bnXr)
By reversing the array, we can catch the last occurrence - `1 word`:
```
<?php
$string = array_reverse(explode(" ","This is a string, keyword next, some more text. keyword next-word."));
echo $string[array_search("keyword",$string) - 1];
/* OUTPUT next-word. */
```
[Run it online](https://3v4l.org/4o4FJ)
This is good for performances if we are making multiples searches, but of course the length of the **string must be kept short** (whole string in memory). |
34,329 | I just got this mountain bike almost 3 weeks ago. I took it for a long ride(120km back and forth). We encountered heavy rain during our ride, we were riding on a highway back then, there's flood water flowing everywhere as you would imagine but not enough to submerge the bottom bracket.
Everything is perfect until the next day. I took the bike for a spin, I felt something inside bottom bracket snapping. I immediately inspected the crank to see if its loose but its not. I then moved on investigating on the pedal, as it may give this feel as well but its not.
I really think this has something to do with the bottom bracket. I then took it back to the bike shop I purchased is from to be checked. What I was thinking is flood water went in and affected the performance of the bottom bracket, I'm thinking of asking them to repack my bottom bracket however. The shop mechanic won't do it, he told me that its too soon for a bottom bracket repack. The snap that I feel inside the bottom bracket is not extreme, as a matter of fact you wont feel it if you don't pay attention to it.
Its just irritating for me specially if I'm not experiencing anything like that before the long ride. If you shake the crank its rock solid. What should I do? I'm using **Trinx XC3 treker**, not top of the line but high quality. | 2015/09/11 | ['https://bicycles.stackexchange.com/questions/34329', 'https://bicycles.stackexchange.com', 'https://bicycles.stackexchange.com/users/22534/'] | If you just bought it, the shop mechanic should remedy the problem no matter what specific part is to blame. If not, threaten to return the entire bike and take your business elsewhere. It should be as simple as that. | Heck, for piece of mind, I'd make the following deal with the shop. Offer to pay for a clean and repack, but if they find anything inside (like metal debris, etc) that came from the original manufacturing process then the bike manufacturer gets to own that.
My thought is.. what if a piece of extraneous metal, left in the frame during a sloppy manufacturing experience has fallen into your bearings? (loose burr on inside of seat post that has now fallen, loose weld bead, welding rod stub, etc...) What if a ball bearing has broken in half, or a race has become bent? Heck are the correct number of ball bearings in there? Many of those things would fall under warranty.
Remember how the warranty works. The bike shop does a repair, and if its a valid warranty claim, the manufacturer re-imburses the local bike shop the repair costs. If the bike shop does a repair and its not considered to be under warranty, then the bike shop has to eat that loss. So work with them..
Either you pay the local bike shop, or the manufacturer pays your local bike shop. The bike shop incurs no loss and you get piece of mind, zen and harmony (in that order.) Everybody leaves happy.
As an alternative, you can certainly purchase the tools to do this job by yourself. |
1,803,274 | I have recently started learning more about complex numbers and stumbled upon this problem:
Plot the numbers $z$ in the complex plane that fulfil $|z-2i| ≤ 1$ and $\text{Im} (z) ≥ 2$
I know that $\text{Im}(z) ≥ 2$ means that all imaginary numbers who are positioned somewhere on the horizontal line $\text{Im} = 2$ or above the line can be plotted. However I’m not quite sure what $ |z-2i| ≤ 1 $ means. I understand that if I only had $|z| ≤ 1$ that would mean I can plot all numbers inside a circle with the radius $1$ including the ones on the circles circumference. But I don’t really understand what the term $-2i$ does to the circle. I compared it to other similar questions and came to the conclusion that the centre should be at $2i$ instead of $0$. My problem is that I don’t quite understand why the circle gets a centre at $2i$ and not at $-2i$. Thankful for any help and explanation. | 2016/05/28 | ['https://math.stackexchange.com/questions/1803274', 'https://math.stackexchange.com', 'https://math.stackexchange.com/users/333942/'] | Let's write z=x+iy and then the inequality $ |z-2i|\leq1$ becomes $ |x+(y-2)i|\leq1 $ so we get $x^2+(y-2)^2 \leq 1$. Can you see it now? | Hint let $z=x+iy$ so equation on squaring becomes $x^2+(y-2)^2\leq 1$. Now do you understand why is it $+2i$ |
51,192,832 | I need to create a login dialog like this
[![enter image description here](https://i.stack.imgur.com/3MJEH.png)](https://i.stack.imgur.com/3MJEH.png) [![enter image description here](https://i.stack.imgur.com/Qrkwx.png)](https://i.stack.imgur.com/Qrkwx.png)
image files: `eyeOn.png`, `eyeOff.png`
Requirements:
* password is shown only when we CLICK AND HOLD the eyeOn icon (even when we click and hold and drag the mouse to area outside of the dialog, the password is still shown), when we release the mouse, password is covered again.
* while password is shown, the eye icon is eyeOn. While password is covered, the eye icon is eyeOff.
I have just built the layout.
```
QGridLayout *mainlogin = new QGridLayout();
QLabel *usernameLabel = new QLabel;
usernameLabel->setWordWrap(true);
usernameLabel->setText("Username");
mainlogin->addWidget(usernameLabel, 0, 0);
QComboBox *usernameLineEdit = new QComboBox;
usernameLineEdit->setEditable(true);
usernameLabel->setBuddy(usernameLineEdit);
mainlogin->addWidget(usernameLineEdit, 0, 1);
QLabel *capslockShow = new QLabel;
capslockShow->setWordWrap(true);
capslockShow->setText(" ");
mainlogin->addWidget(capslockShow, 1, 1);
QLabel *passwordLabel = new QLabel;
passwordLabel->setWordWrap(true);
passwordLabel->setText("Password");
mainlogin->addWidget(passwordLabel, 2, 0);
QLineEdit *passwordLineEdit = new QLineEdit;
passwordLineEdit->setEchoMode(QLineEdit::Password);
QAction *myAction = passwordLineEdit->addAction(QIcon(":/eyeOff.png"), QLineEdit::TrailingPosition);
passwordLabel->setBuddy(passwordLineEdit);
mainlogin->addWidget(passwordLineEdit, 2, 1);
```
What should I do next? Pls help me with code snippet. | 2018/07/05 | ['https://Stackoverflow.com/questions/51192832', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4196709/'] | The solution is to add a `QAction` to the `QLineEdit`, this will create a `QToolButton` that we can obtain from the `associatedWidgets()` (it will be the second widget since the first one is the one associated with `clearButton`). Already having the `QToolButton` you must use the `pressed` and `released` signal.
**passwordlineedit.h**
```
#ifndef PASSWORDLINEEDIT_H
#define PASSWORDLINEEDIT_H
#include <QAction>
#include <QLineEdit>
#include <QToolButton>
class PasswordLineEdit: public QLineEdit
{
public:
PasswordLineEdit(QWidget *parent=nullptr);
private slots:
void onPressed();
void onReleased();
protected:
void enterEvent(QEvent *event);
void leaveEvent(QEvent *event);
void focusInEvent(QFocusEvent *event);
void focusOutEvent(QFocusEvent *event);
private:
QToolButton *button;
};
#endif // PASSWORDLINEEDIT_H
```
**passwordlineedit.cpp**
```
#include "passwordlineedit.h"
PasswordLineEdit::PasswordLineEdit(QWidget *parent):
QLineEdit(parent)
{
setEchoMode(QLineEdit::Password);
QAction *action = addAction(QIcon(":/eyeOff"), QLineEdit::TrailingPosition);
button = qobject_cast<QToolButton *>(action->associatedWidgets().last());
button->hide();
button->setCursor(QCursor(Qt::PointingHandCursor));
connect(button, &QToolButton::pressed, this, &PasswordLineEdit::onPressed);
connect(button, &QToolButton::released, this, &PasswordLineEdit::onReleased);
}
void PasswordLineEdit::onPressed(){
QToolButton *button = qobject_cast<QToolButton *>(sender());
button->setIcon(QIcon(":/eyeOn"));
setEchoMode(QLineEdit::Normal);
}
void PasswordLineEdit::onReleased(){
QToolButton *button = qobject_cast<QToolButton *>(sender());
button->setIcon(QIcon(":/eyeOff"));
setEchoMode(QLineEdit::Password);
}
void PasswordLineEdit::enterEvent(QEvent *event){
button->show();
QLineEdit::enterEvent(event);
}
void PasswordLineEdit::leaveEvent(QEvent *event){
button->hide();
QLineEdit::leaveEvent(event);
}
void PasswordLineEdit::focusInEvent(QFocusEvent *event){
button->show();
QLineEdit::focusInEvent(event);
}
void PasswordLineEdit::focusOutEvent(QFocusEvent *event){
button->hide();
QLineEdit::focusOutEvent(event);
}
```
The complete example can be downloaded from the following [link](https://github.com/eyllanesc/stackoverflow/tree/master/questions/51192832). | Rather than trying to make use of the `QAction` returned by `QLineEdit::addAction` you could probably use a [`QWidgetAction`](http://doc.qt.io/qt-5/qwidgetaction.html) for this when combined with a suitable event filter...
```
class eye_spy: public QWidgetAction {
using super = QWidgetAction;
public:
explicit eye_spy (QLineEdit *control, QWidget *parent = nullptr)
: super(parent)
, m_control(control)
, m_on(":/eyeOn")
, m_off(":/eyeOff")
, m_pixmap_size(50, 50)
{
m_label.setScaledContents(true);
m_control->setEchoMode(QLineEdit::Password);
m_label.setPixmap(m_off.pixmap(m_pixmap_size));
m_label.installEventFilter(this);
setDefaultWidget(&m_label);
}
protected:
virtual bool eventFilter (QObject *obj, QEvent *event) override
{
if (event->type() == QEvent::MouseButtonPress) {
m_control->setEchoMode(QLineEdit::Normal);
m_label.setPixmap(m_on.pixmap(m_pixmap_size));
} else if (event->type() == QEvent::MouseButtonRelease) {
m_control->setEchoMode(QLineEdit::Password);
m_label.setPixmap(m_off.pixmap(m_pixmap_size));
}
return(super::eventFilter(obj, event));
}
private:
QLineEdit *m_control;
QLabel m_label;
QIcon m_on;
QIcon m_off;
QSize m_pixmap_size;
};
```
Now, rather than...
```
QAction *myAction = passwordLineEdit->addAction(QIcon(":/eyeOff.png"), QLineEdit::TrailingPosition);
```
Use...
```
eye_spy eye_spy(passwordLineEdit);
passwordLineEdit->addAction(&eye_spy, QLineEdit::TrailingPosition);
```
Seems to provide the desired behaviour. |
284,228 | In my modern SharePoint, I have a simple webpart and there's scenerio where to allow user to choose colour from custom properties pane configuration.
it can be colour picker
[![enter image description here](https://i.stack.imgur.com/lSoht.png)](https://i.stack.imgur.com/lSoht.png)
or as simple as dropdown options with the background colour.
[![enter image description here](https://i.stack.imgur.com/xHT4y.png)](https://i.stack.imgur.com/xHT4y.png)
How to achieve this in client-webpart? | 2020/08/28 | ['https://sharepoint.stackexchange.com/questions/284228', 'https://sharepoint.stackexchange.com', 'https://sharepoint.stackexchange.com/users/92501/'] | If you are implementing SPFx you can use PnP controls color picker in prperty pane to allow user select the color value. It's easier to implement than creating custom one.
[PnP Color Picker](https://pnp.github.io/sp-dev-fx-property-controls/controls/PropertyFieldColorPicker/)
[![color picker](https://i.stack.imgur.com/h25sN.png)](https://i.stack.imgur.com/h25sN.png) | [![enter image description here](https://i.stack.imgur.com/3v9s8.gif)](https://i.stack.imgur.com/3v9s8.gif)
Main code:
```
import * as React from 'react';
import * as ReactDom from 'react-dom';
import { Version } from '@microsoft/sp-core-library';
import {
IPropertyPaneConfiguration,
PropertyPaneTextField,
PropertyPaneDropdown
} from '@microsoft/sp-property-pane';
import { BaseClientSideWebPart } from '@microsoft/sp-webpart-base';
import * as strings from 'ReactSpfxWebPartStrings';
import ReactSpfx from './components/ReactSpfx';
import { IReactSpfxProps } from './components/IReactSpfxProps';
export interface IReactSpfxWebPartProps {
description: string;
bgcolor:Array<any>;
selectedColor:string;
}
export default class ReactSpfxWebPart extends BaseClientSideWebPart<IReactSpfxWebPartProps> {
public render(): void {
const element: React.ReactElement<IReactSpfxProps> = React.createElement(
ReactSpfx,
{
description: this.properties.description,
bgcolor:this.properties.bgcolor,
selectedColor:this.properties.selectedColor
}
);
console.log(this.properties.bgcolor)
ReactDom.render(element, this.domElement);
}
protected onDispose(): void {
ReactDom.unmountComponentAtNode(this.domElement);
}
protected get dataVersion(): Version {
return Version.parse('1.0');
}
protected onPropertyPaneFieldChanged(propertyPath: string, oldValue: any, newValue: any): void {
if (propertyPath === 'BGcolor' && newValue) {
this.properties.selectedColor=newValue;
// push new list value
super.onPropertyPaneFieldChanged(propertyPath, oldValue, newValue);
// refresh the item selector control by repainting the property pane
this.context.propertyPane.refresh();
// re-render the web part as clearing the loading indicator removes the web part body
this.render();
}
else {
super.onPropertyPaneFieldChanged(propertyPath, oldValue, oldValue);
}
}
protected getPropertyPaneConfiguration(): IPropertyPaneConfiguration {
return {
pages: [
{
header: {
description: strings.PropertyPaneDescription,
},
groups: [
{
groupName: strings.BasicGroupName,
groupFields: [
PropertyPaneTextField('description', {
label: strings.DescriptionFieldLabel,
}),
PropertyPaneDropdown('BGcolor', {
label:'BGcolor',
selectedKey:"red",
options: this.properties.bgcolor
})
]
}
]
}
]
};
}
}
```
You could get the full project here:<https://github.com/Amos-IT/SharePoint-FrameWork-Demos/tree/master/ReactSPFX> |
46,810 | I'm buying a train ticket on the long-distance Amtrak Empire Builder train that runs Chicago-Milwaukee-...-St. Paul-...
I'm traveling from Milwaukee to St. Paul. All the saver tickets are sold out. Value tickets are sold out for Milwaukee-St. Paul, but not for Chicago-St. Paul. This means it cheaper to buy a ticket from Chicago and just get on the train at it's second stop in Milwaukee.
I found this similar question [Can you get on an Amtrak train at a later station?](https://travel.stackexchange.com/questions/35960/can-you-get-on-an-amtrak-train-at-a-later-station/35979#35979), which notes I need to change my ticket after purchase. It doesn't address the possibility of a fare increase, is there a possibility that Amtrak would charge me extra and make me change my Chicago-Milwaukee-Minneapolis value ticket into a Milwaukee-St Paul flexible ticket? | 2015/04/27 | ['https://travel.stackexchange.com/questions/46810', 'https://travel.stackexchange.com', 'https://travel.stackexchange.com/users/20576/'] | I asked a similar question to an Amtrak agent a few days ago. Here's what he told me:
Officially, your ticket gets treated as a "no-show" and is "subject to automatic cancellation" if you haven't boarded the train within two hours of the originally-scheduled departure time at your ticketed station.
He said that if you're traveling without checked baggage & printed your own ticket, it's "very unlikely" anyone would give you any problems as long as you were on board within that two hour window of time.
If the train is running late, or you have checked baggage, things get more complicated & uncertain. Apparently, staff have a tiny bit of discretion to relax an official policy, and almost unlimited discretion to rigidly ENFORCE an official policy. So, if your train is scheduled to depart from Chicago at noon, and Milwaukee at 1:45, but gets delayed and doesn't arrive in Milwaukee until 2:05, you COULD be denied boarding if someone wanted to be mean, but it's unlikely to happen unless you give them an excuse to SAY "no". If you're on board the train, have a valid ticket, and it's within 2 hours of the train's actual departure from Chicago, it's almost *inconceivable* that they'd make you get off the train at the next station & leave you stranded. But if you showed up at the station in Milwaukee 4 minutes before departure with checked baggage & needed to have them print your ticket, they COULD refuse, and management would back them up (possibly giving you a retroactive credit for future travel if you got lucky, but nevertheless leaving you in a world of hurt at that particular moment).
Another issue: if you DO need to check baggage, they probably WON'T tag it for the earlier station on the return trip. They won't do anything to prevent YOU from getting off the train before your official stop, but any checked baggage will probably be going to your official ticketed destination whether you like it or not. That's not to say you might not get lucky... but if they refused to pull your bags in Milwaukee, or refused to tag them at check-in FOR Milwaukee, they'd be entirely within their discretion, and you'd be out of luck. | Amtrak terms and conditions state that if you fail to board your train as booked your entire reservation is subject to cancellation
It's one of the first things detailed on the conditions of carriage page here.
<http://www.amtrak.com/servlet/ContentServer?c=Page&pagename=am%2FLayout&cid=1241337896121>
If discovered that you boarded at the wrong station the conductor at the very least might ask you to pay the difference in fare, and possibly be forced purchase a whole new ticket.
You ask about changing your ticket.
All saver fares are non refundable, so you can't change the booking, however if cancelled in advance they will issue you an e voucher for the value of the fare. Value fares also have conditions about cancellation and refunds
<http://www.amtrak.com/servlet/Satellite?SnippetName=IBLegacy&pagename=am/AM_Snippet_C/SnippetWrapper&ibsref=seeTCdetails>
You would then need to purchace a whole new ticket, and if the saver or value fares have already sold out then you will be forced to buy a full fare ticket |
55,715,000 | I'm creating an application, which interacts with OpenGL via *QOpenGL\** classes. The graphics is shown through a *QOpenGLWidget*, which is placed in a UI-form.
Now, there is a library for CAD purposes ([Open CASCADE](https://www.opencascade.com)), an OpenGL interface of which requires a handle to the render window. The question is: can I somehow say the library to render everything to the mentioned widget?
In other words, is there a way to interpret the widget as a native, probably, platform-specific (HWND here) window, so that the library renders its own stuff exactly there?
Thanks | 2019/04/16 | ['https://Stackoverflow.com/questions/55715000', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4886665/'] | **QOpenGLWidget** is not the same thing as **QGLWidget**.
The classical approach for embedding OCCT 3D viewer, which you can find in Qt IESample coming with OCCT, creates QWidget with unique window handle flag, takes this window handle and ask OCCT to take care about OpenGL context creation for this window. This is most straightforward, robust and portable way with one limitation - Qt will not be able drawing semitransparent widgets on top of this QWidget. This is not a limitation of OCCT, but rather limitation of Qt Widgets design.
**QOpenGLWidget** was intended to solve this limitation by allowing to mix custom OpenGL rendering and normal widgets. The integration of external OpenGL graphics engine, however, became more complicated and fragile. It is not very helpful stealing winId() from QOpenGLWidget, as rendering content is expected to be drawn not into window itself, but rather into OpenGL framebufer object (FBO), created by QOpenGLWidget - see **QOpenGLWidget::defaultFramebufferObject()** property.
External renderer is expected to render into this FBO for proper composition of Qt widgets. Luckily, OCCT is flexible enough to allow such integration. Unluckily, such integration requires some knowledge of OpenGL, as well as its usage by Qt and OCCT.
For that, you need to ask OCCT wrapping OpenGL context already created by Qt (for that **V3d\_View::SetWindow()** provides an optional argument of type *Aspect\_RenderingContext*, which corresponds to **HGLRC** on Windows and can be fetched using **wglGetCurrentContext()** within rendering thread) as well as FBO created by QOpenGLWidget (for that, OCCT provides **OpenGl\_FrameBuffer::InitWrapper()** and **OpenGl\_Context::SetDefaultFrameBuffer()** methods, as well as **OpenGl\_Caps::buffersNoSwap** flag to leave window buffer swapping management to Qt).
OCCT doesn't come yet with a sample using **QOpenGLWidget**, but you can find also **qt/AndroidQt** sample implementing similar thing for embedding OCCT 3D Viewer into **QtQuick** application. | After some investigation, I found that method *QOpenGLWidget::winId()* returns the correct handle. It's been found out only now, because the rendered scene disappeared immediately, leaving a black picture instead. However, when the viewport is resized, the scene returns back (and disappears again, though). Looks like Open CASCADE has problems with Qt 5 OpenGL implementation, since QGLWidget didn't have such problems, as far as I know. |
31,581,537 | here the df(i updated by real data ):
```
>TIMESTAMP OLTPSOURCE RNR RQDRECORD
>20150425232836 0PU_IS_PS_44 REQU_51NHAJUV06IMMP16BVE572JM2 17020
>20150128165726 ZFI_DS41 REQU_50P1AABLYXE86KYE3O6EY390M 6925
>20150701144253 ZZZJB_TEXT REQU_52DV5FB812JCDXDVIV9P35DGM 2
>20150107201358 0EQUIPMENT_ATTR REQU_50EVHXSDOITYUQLP4L8UXOBT6 14205
>20150623215202 0CO_OM_CCA_1 REQU_528XSXYWTK6FSJXDQY2ROQQ4Q 0
>20150715144139 0HRPOSITION_TEXT REQU_52I9KQ1LN4ZWTNIP0N1R68NDY 25381
>20150625175157 0HR_PA_0 REQU_528ZS1RFN0N3Y3AEB48UDCUKQ 100020
>20150309153828 0HR_PA_0 REQU_51385K5F3AGGFVCGHU997QF9M 0
>20150626185531 0FI_AA_001 REQU_52BO3RJCOG4JGHEIIZMJP9V4A 0
>20150307222336 0FUNCT_LOC_ATTR REQU_513JJ6I6ER5ZVW5CAJMVSKAJQ 13889
>20150630163419 0WBS_ELEMT_ATTR REQU_52CUPVUFCY2DDOG6SPQ1XOYQ2 0
>20150424162226 6DB_V_DGP_EXPORTDATA REQU_51N1F5ZC8G3LW68E4TFXRGH9I 0
>20150617143720 ZRZMS_TEXT REQU_5268R1YE6G1U7HUK971LX1FPM 6
>20150405162213 0HR_PA_0 REQU_51FFR7T4YQ2F766PFY0W9WUDM 0
>20150202165933 ZFI_DS41 REQU_50QPTCF0VPGLBYM9MGFXMWHGM 6925
>20150102162140 0HR_PA_0 REQU_50CNUT7I9OXH2WSNLC4WTUZ7U 0
>20150417184916 0FI_AA_004 REQU_51KFWWT6PPTI5X44D3MWD7CYU 0
>20150416220451 0FUNCT_LOC_ATTR REQU_51JP3BDCD6TUOBL2GK9ZE35UU 13889
>20150205150633 ZHR_DS09 REQU_50RFRYRADMA9QXB1PW4PRF5XM 6667
>20150419230724 0PU_IS_PS_44 REQU_51LC5XX6VWEERAVHEFJ9K5A6I 22528
>and the relationships between columns is
>OLTPSOURCE--RNR:1>n
>RNR--RQDRECORD:1>N
```
>
> and my requirement is:
>
>
>
1. sum the RQDRECORD by RNR;
2. get the max sum result of every OLTPSOURCE;
3. Finally, I would draw a graph showing the results of all
sumed largest OLTPSOURCE by time
Thanks everyone, I further explain my problem:
1. if OLTPSOURCE:RNR:RQDRECORD= 1:1:1
>
> just sum RQDRECORD,RETURN OLTPSOURCE AND SUM RESULT
>
>
>
2. if OLTPSOURCE:RNR:RQDRECORD= 1:1:N
>
> just sum RQDRECORD,RETURN OLTPSOURCE AND SUM RESULT
>
>
>
3. if OLTPSOURCE:RNR:RQDRECORD= 1:N:(N OR 1)
>
> sum RQDRECORD by RNR GROUP first,THEN Find the max result of one OLTPSOURCE,return all the OLTPSOURCE with the max RQDRECORD .
>
>
>
So for the above sample data, I eventually want the result as follows
```
>TIMESTAMP OLTPSOURCE RNR RQDRECORD
>20150623215202 0CO_OM_CCA_1 REQU_528XSXYWTK6FSJXDQY2ROQQ4Q 0
>20150107201358 0EQUIPMENT_ATTR REQU_50EVHXSDOITYUQLP4L8UXOBT6 14205
>20150626185531 0FI_AA_001 REQU_52BO3RJCOG4JGHEIIZMJP9V4A 0
>20150417184916 0FI_AA_004 REQU_51KFWWT6PPTI5X44D3MWD7CYU 0
>20150416220451 0FUNCT_LOC_ATTR REQU_51JP3BDCD6TUOBL2GK9ZE35UU 13889
>20150625175157 0HR_PA_0 REQU_528ZS1RFN0N3Y3AEB48UDCUKQ 100020
>20150715144139 0HRPOSITION_TEXT REQU_52I9KQ1LN4ZWTNIP0N1R68NDY 25381
>20150419230724 0PU_IS_PS_44 REQU_51LC5XX6VWEERAVHEFJ9K5A6I 22528
>20150630163419 0WBS_ELEMT_ATTR REQU_52CUPVUFCY2DDOG6SPQ1XOYQ2 0
>20150424162226 6DB_V_DGP_EXPORTDATA REQU_51N1F5ZC8G3LW68E4TFXRGH9I 0
>20150202165933 ZFI_DS41 REQU_50QPTCF0VPGLBYM9MGFXMWHGM 6925
>20150205150633 ZHR_DS09 REQU_50RFRYRADMA9QXB1PW4PRF5XM 6667
>20150617143720 ZRZMS_TEXT REQU_5268R1YE6G1U7HUK971LX1FPM 6
>20150701144253 ZZZJB_TEXT REQU_52DV5FB812JCDXDVIV9P35DGM 2
```
Referring to EdChum's approach, I made some adjustments, the results were as follows, because the amount of data is too big, I did "'RQDRECORD> 100000'" is set, in fact I would like to sort and then take the top 100, but not success
>
> [1]: <http://i.imgur.com/FgfZaDY.jpg> "result"
>
>
> | 2015/07/23 | ['https://Stackoverflow.com/questions/31581537', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/5146939/'] | Peter, we've just implemented the same thing.
Users have the software pre-installed on their device and we host update APK's on the companies servers.
From the app they can then check for updates where we have a WCF service which extracts the APK file (essentially a .zip) and returns the manifest details. From there we have the version of the APK and can compare it against the local version.
If the user decides to upgrade they can download the APK and you can automatically launch it. At which point the user will be told the application is going to be updated. There are no file locks etc, the app will just close and restart using the new version.
Note: Downgrading is not "automatic". The user would have to first uninstall the app. For upgrades, however, it's a simple case of downloading and launching the APK version (the user will be told they need to allow installations from unknown sources if this is not checked). | You have a couple of options, depending upon your target system.
1. Use the link you posted. This will provide the user with a traditional install dialog, whereby the user can choose to install or not. You should avoid doing that automatically, as APKs can be large and you might irritate the user if they don't want updates.
2. You can install updates magically, but you will require the firmware signing key (or possibly root, but I haven't tested that). That will not ask for consent from the user. You will need to add additional code using reflection to access the installation methods of Android. If you go this way, you should build an opt-out/in mechanism. |
31,581,537 | here the df(i updated by real data ):
```
>TIMESTAMP OLTPSOURCE RNR RQDRECORD
>20150425232836 0PU_IS_PS_44 REQU_51NHAJUV06IMMP16BVE572JM2 17020
>20150128165726 ZFI_DS41 REQU_50P1AABLYXE86KYE3O6EY390M 6925
>20150701144253 ZZZJB_TEXT REQU_52DV5FB812JCDXDVIV9P35DGM 2
>20150107201358 0EQUIPMENT_ATTR REQU_50EVHXSDOITYUQLP4L8UXOBT6 14205
>20150623215202 0CO_OM_CCA_1 REQU_528XSXYWTK6FSJXDQY2ROQQ4Q 0
>20150715144139 0HRPOSITION_TEXT REQU_52I9KQ1LN4ZWTNIP0N1R68NDY 25381
>20150625175157 0HR_PA_0 REQU_528ZS1RFN0N3Y3AEB48UDCUKQ 100020
>20150309153828 0HR_PA_0 REQU_51385K5F3AGGFVCGHU997QF9M 0
>20150626185531 0FI_AA_001 REQU_52BO3RJCOG4JGHEIIZMJP9V4A 0
>20150307222336 0FUNCT_LOC_ATTR REQU_513JJ6I6ER5ZVW5CAJMVSKAJQ 13889
>20150630163419 0WBS_ELEMT_ATTR REQU_52CUPVUFCY2DDOG6SPQ1XOYQ2 0
>20150424162226 6DB_V_DGP_EXPORTDATA REQU_51N1F5ZC8G3LW68E4TFXRGH9I 0
>20150617143720 ZRZMS_TEXT REQU_5268R1YE6G1U7HUK971LX1FPM 6
>20150405162213 0HR_PA_0 REQU_51FFR7T4YQ2F766PFY0W9WUDM 0
>20150202165933 ZFI_DS41 REQU_50QPTCF0VPGLBYM9MGFXMWHGM 6925
>20150102162140 0HR_PA_0 REQU_50CNUT7I9OXH2WSNLC4WTUZ7U 0
>20150417184916 0FI_AA_004 REQU_51KFWWT6PPTI5X44D3MWD7CYU 0
>20150416220451 0FUNCT_LOC_ATTR REQU_51JP3BDCD6TUOBL2GK9ZE35UU 13889
>20150205150633 ZHR_DS09 REQU_50RFRYRADMA9QXB1PW4PRF5XM 6667
>20150419230724 0PU_IS_PS_44 REQU_51LC5XX6VWEERAVHEFJ9K5A6I 22528
>and the relationships between columns is
>OLTPSOURCE--RNR:1>n
>RNR--RQDRECORD:1>N
```
>
> and my requirement is:
>
>
>
1. sum the RQDRECORD by RNR;
2. get the max sum result of every OLTPSOURCE;
3. Finally, I would draw a graph showing the results of all
sumed largest OLTPSOURCE by time
Thanks everyone, I further explain my problem:
1. if OLTPSOURCE:RNR:RQDRECORD= 1:1:1
>
> just sum RQDRECORD,RETURN OLTPSOURCE AND SUM RESULT
>
>
>
2. if OLTPSOURCE:RNR:RQDRECORD= 1:1:N
>
> just sum RQDRECORD,RETURN OLTPSOURCE AND SUM RESULT
>
>
>
3. if OLTPSOURCE:RNR:RQDRECORD= 1:N:(N OR 1)
>
> sum RQDRECORD by RNR GROUP first,THEN Find the max result of one OLTPSOURCE,return all the OLTPSOURCE with the max RQDRECORD .
>
>
>
So for the above sample data, I eventually want the result as follows
```
>TIMESTAMP OLTPSOURCE RNR RQDRECORD
>20150623215202 0CO_OM_CCA_1 REQU_528XSXYWTK6FSJXDQY2ROQQ4Q 0
>20150107201358 0EQUIPMENT_ATTR REQU_50EVHXSDOITYUQLP4L8UXOBT6 14205
>20150626185531 0FI_AA_001 REQU_52BO3RJCOG4JGHEIIZMJP9V4A 0
>20150417184916 0FI_AA_004 REQU_51KFWWT6PPTI5X44D3MWD7CYU 0
>20150416220451 0FUNCT_LOC_ATTR REQU_51JP3BDCD6TUOBL2GK9ZE35UU 13889
>20150625175157 0HR_PA_0 REQU_528ZS1RFN0N3Y3AEB48UDCUKQ 100020
>20150715144139 0HRPOSITION_TEXT REQU_52I9KQ1LN4ZWTNIP0N1R68NDY 25381
>20150419230724 0PU_IS_PS_44 REQU_51LC5XX6VWEERAVHEFJ9K5A6I 22528
>20150630163419 0WBS_ELEMT_ATTR REQU_52CUPVUFCY2DDOG6SPQ1XOYQ2 0
>20150424162226 6DB_V_DGP_EXPORTDATA REQU_51N1F5ZC8G3LW68E4TFXRGH9I 0
>20150202165933 ZFI_DS41 REQU_50QPTCF0VPGLBYM9MGFXMWHGM 6925
>20150205150633 ZHR_DS09 REQU_50RFRYRADMA9QXB1PW4PRF5XM 6667
>20150617143720 ZRZMS_TEXT REQU_5268R1YE6G1U7HUK971LX1FPM 6
>20150701144253 ZZZJB_TEXT REQU_52DV5FB812JCDXDVIV9P35DGM 2
```
Referring to EdChum's approach, I made some adjustments, the results were as follows, because the amount of data is too big, I did "'RQDRECORD> 100000'" is set, in fact I would like to sort and then take the top 100, but not success
>
> [1]: <http://i.imgur.com/FgfZaDY.jpg> "result"
>
>
> | 2015/07/23 | ['https://Stackoverflow.com/questions/31581537', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/5146939/'] | Peter, we've just implemented the same thing.
Users have the software pre-installed on their device and we host update APK's on the companies servers.
From the app they can then check for updates where we have a WCF service which extracts the APK file (essentially a .zip) and returns the manifest details. From there we have the version of the APK and can compare it against the local version.
If the user decides to upgrade they can download the APK and you can automatically launch it. At which point the user will be told the application is going to be updated. There are no file locks etc, the app will just close and restart using the new version.
Note: Downgrading is not "automatic". The user would have to first uninstall the app. For upgrades, however, it's a simple case of downloading and launching the APK version (the user will be told they need to allow installations from unknown sources if this is not checked). | If your app is open-source, [F-Droid](https://f-droid.org/) would solve the problem for you.
>
> F-Droid is an installable catalogue of FOSS (Free and Open Source
> Software) applications for the Android platform. The client makes it
> easy to browse, install, and keep track of updates on your device.
>
>
>
Mainly, it updates your app when necessary. (Or just have a look at its [source code](https://gitlab.com/fdroid/fdroidclient) for inspiration on how to do it). |
31,581,537 | here the df(i updated by real data ):
```
>TIMESTAMP OLTPSOURCE RNR RQDRECORD
>20150425232836 0PU_IS_PS_44 REQU_51NHAJUV06IMMP16BVE572JM2 17020
>20150128165726 ZFI_DS41 REQU_50P1AABLYXE86KYE3O6EY390M 6925
>20150701144253 ZZZJB_TEXT REQU_52DV5FB812JCDXDVIV9P35DGM 2
>20150107201358 0EQUIPMENT_ATTR REQU_50EVHXSDOITYUQLP4L8UXOBT6 14205
>20150623215202 0CO_OM_CCA_1 REQU_528XSXYWTK6FSJXDQY2ROQQ4Q 0
>20150715144139 0HRPOSITION_TEXT REQU_52I9KQ1LN4ZWTNIP0N1R68NDY 25381
>20150625175157 0HR_PA_0 REQU_528ZS1RFN0N3Y3AEB48UDCUKQ 100020
>20150309153828 0HR_PA_0 REQU_51385K5F3AGGFVCGHU997QF9M 0
>20150626185531 0FI_AA_001 REQU_52BO3RJCOG4JGHEIIZMJP9V4A 0
>20150307222336 0FUNCT_LOC_ATTR REQU_513JJ6I6ER5ZVW5CAJMVSKAJQ 13889
>20150630163419 0WBS_ELEMT_ATTR REQU_52CUPVUFCY2DDOG6SPQ1XOYQ2 0
>20150424162226 6DB_V_DGP_EXPORTDATA REQU_51N1F5ZC8G3LW68E4TFXRGH9I 0
>20150617143720 ZRZMS_TEXT REQU_5268R1YE6G1U7HUK971LX1FPM 6
>20150405162213 0HR_PA_0 REQU_51FFR7T4YQ2F766PFY0W9WUDM 0
>20150202165933 ZFI_DS41 REQU_50QPTCF0VPGLBYM9MGFXMWHGM 6925
>20150102162140 0HR_PA_0 REQU_50CNUT7I9OXH2WSNLC4WTUZ7U 0
>20150417184916 0FI_AA_004 REQU_51KFWWT6PPTI5X44D3MWD7CYU 0
>20150416220451 0FUNCT_LOC_ATTR REQU_51JP3BDCD6TUOBL2GK9ZE35UU 13889
>20150205150633 ZHR_DS09 REQU_50RFRYRADMA9QXB1PW4PRF5XM 6667
>20150419230724 0PU_IS_PS_44 REQU_51LC5XX6VWEERAVHEFJ9K5A6I 22528
>and the relationships between columns is
>OLTPSOURCE--RNR:1>n
>RNR--RQDRECORD:1>N
```
>
> and my requirement is:
>
>
>
1. sum the RQDRECORD by RNR;
2. get the max sum result of every OLTPSOURCE;
3. Finally, I would draw a graph showing the results of all
sumed largest OLTPSOURCE by time
Thanks everyone, I further explain my problem:
1. if OLTPSOURCE:RNR:RQDRECORD= 1:1:1
>
> just sum RQDRECORD,RETURN OLTPSOURCE AND SUM RESULT
>
>
>
2. if OLTPSOURCE:RNR:RQDRECORD= 1:1:N
>
> just sum RQDRECORD,RETURN OLTPSOURCE AND SUM RESULT
>
>
>
3. if OLTPSOURCE:RNR:RQDRECORD= 1:N:(N OR 1)
>
> sum RQDRECORD by RNR GROUP first,THEN Find the max result of one OLTPSOURCE,return all the OLTPSOURCE with the max RQDRECORD .
>
>
>
So for the above sample data, I eventually want the result as follows
```
>TIMESTAMP OLTPSOURCE RNR RQDRECORD
>20150623215202 0CO_OM_CCA_1 REQU_528XSXYWTK6FSJXDQY2ROQQ4Q 0
>20150107201358 0EQUIPMENT_ATTR REQU_50EVHXSDOITYUQLP4L8UXOBT6 14205
>20150626185531 0FI_AA_001 REQU_52BO3RJCOG4JGHEIIZMJP9V4A 0
>20150417184916 0FI_AA_004 REQU_51KFWWT6PPTI5X44D3MWD7CYU 0
>20150416220451 0FUNCT_LOC_ATTR REQU_51JP3BDCD6TUOBL2GK9ZE35UU 13889
>20150625175157 0HR_PA_0 REQU_528ZS1RFN0N3Y3AEB48UDCUKQ 100020
>20150715144139 0HRPOSITION_TEXT REQU_52I9KQ1LN4ZWTNIP0N1R68NDY 25381
>20150419230724 0PU_IS_PS_44 REQU_51LC5XX6VWEERAVHEFJ9K5A6I 22528
>20150630163419 0WBS_ELEMT_ATTR REQU_52CUPVUFCY2DDOG6SPQ1XOYQ2 0
>20150424162226 6DB_V_DGP_EXPORTDATA REQU_51N1F5ZC8G3LW68E4TFXRGH9I 0
>20150202165933 ZFI_DS41 REQU_50QPTCF0VPGLBYM9MGFXMWHGM 6925
>20150205150633 ZHR_DS09 REQU_50RFRYRADMA9QXB1PW4PRF5XM 6667
>20150617143720 ZRZMS_TEXT REQU_5268R1YE6G1U7HUK971LX1FPM 6
>20150701144253 ZZZJB_TEXT REQU_52DV5FB812JCDXDVIV9P35DGM 2
```
Referring to EdChum's approach, I made some adjustments, the results were as follows, because the amount of data is too big, I did "'RQDRECORD> 100000'" is set, in fact I would like to sort and then take the top 100, but not success
>
> [1]: <http://i.imgur.com/FgfZaDY.jpg> "result"
>
>
> | 2015/07/23 | ['https://Stackoverflow.com/questions/31581537', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/5146939/'] | Peter, we've just implemented the same thing.
Users have the software pre-installed on their device and we host update APK's on the companies servers.
From the app they can then check for updates where we have a WCF service which extracts the APK file (essentially a .zip) and returns the manifest details. From there we have the version of the APK and can compare it against the local version.
If the user decides to upgrade they can download the APK and you can automatically launch it. At which point the user will be told the application is going to be updated. There are no file locks etc, the app will just close and restart using the new version.
Note: Downgrading is not "automatic". The user would have to first uninstall the app. For upgrades, however, it's a simple case of downloading and launching the APK version (the user will be told they need to allow installations from unknown sources if this is not checked). | Yes but as far as I remember only if you had Root privileges in order to have access to the INSTALL\_PACKAGES permission. |
9,590,702 | I have a ListBox which I put some files, if the file is not AVI I automatically converts it but I want when the files converting message will write on a label that the files are now converted to another format, i know i need use Dispatcher in order to update the UI thread but i use now Winform instead of WPF, and i need help with this.
BTW i cannot use Task because i am using .Net 3.5
```
private void btnAdd_Click(object sender, EventArgs e)
{
System.IO.Stream myStream;
OpenFileDialog thisDialog = new OpenFileDialog();
thisDialog.InitialDirectory = "c:\\";
thisDialog.Filter = "All files (*.*)|*.*";
thisDialog.FilterIndex = 1;
thisDialog.RestoreDirectory = false;
thisDialog.Multiselect = true; // Allow the user to select multiple files
thisDialog.Title = "Please Select Source File";
thisDialog.FileName = lastPath;
List<string> list = new List<string>();
if (thisDialog.ShowDialog() == DialogResult.OK)
{
foreach (String file in thisDialog.FileNames)
{
try
{
if ((myStream = thisDialog.OpenFile()) != null)
{
using (myStream)
{
listBoxFiles.Items.Add(file);
lastPath = file;
}
}
}
catch (Exception ex)
{
MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message);
}
}
for (int i = 0; i < listBoxFiles.Items.Count; i++)
{
string path = (string)listBoxFiles.Items[i];
FileInfo fileInfo = new FileInfo(path);
if (fileInfo.Extension != ".AVI")
{
listToRemove.Add(path);
}
}
(new System.Threading.Thread(sendFilesToConvertToPcap)).Start();
foreach (string file in listToRemove) //remove all non .AVI files from listbox
{
listBoxFiles.Items.Remove(file);
}
}
}
```
this function need to change the Label:
```
public void sendFilesToConvertToPcap()
{
if (listToRemove.Count == 0) // nothing to do
{
return;
}
lblStatus2.Content = "Convert file to .AVI...";
foreach (String file in listToRemove)
{
FileInfo fileInfo = new FileInfo(file);
myClass = new (class who convert the files)(fileInfo);
String newFileName = myClass.mNewFileName;
listBoxFiles.Items.Add(myClass._newFileName);
}
lblStatus2.Content = "Finished...";
}
``` | 2012/03/06 | ['https://Stackoverflow.com/questions/9590702', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/979033/'] | From your question, it seems that you'd like to convert several files. You may want to consider using the [BackgroundWorker](http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker.aspx) class and overwrite the DoWork and ProgressChanged events as described in [this article](http://msdn.microsoft.com/en-us/library/cc221403%28v=vs.95%29.aspx). You can update the label and other controls in the ProgressChanged event. | This is a very common requirement for long-running processes. If you don't explicitly call methods on a separate thread, they will automatically run on the main (see: UI) thread and cause your UI to hand (as I suspect you already know).
<http://www.dotnetperls.com/backgroundworker>
Here is an old, but excellent link with an example on how to use the background worker to handle the threadpool for you.
This way, you can just create a worker to manage running your conversion process on a separate thread, and I believe there is even an example for creating a process bar. |
9,590,702 | I have a ListBox which I put some files, if the file is not AVI I automatically converts it but I want when the files converting message will write on a label that the files are now converted to another format, i know i need use Dispatcher in order to update the UI thread but i use now Winform instead of WPF, and i need help with this.
BTW i cannot use Task because i am using .Net 3.5
```
private void btnAdd_Click(object sender, EventArgs e)
{
System.IO.Stream myStream;
OpenFileDialog thisDialog = new OpenFileDialog();
thisDialog.InitialDirectory = "c:\\";
thisDialog.Filter = "All files (*.*)|*.*";
thisDialog.FilterIndex = 1;
thisDialog.RestoreDirectory = false;
thisDialog.Multiselect = true; // Allow the user to select multiple files
thisDialog.Title = "Please Select Source File";
thisDialog.FileName = lastPath;
List<string> list = new List<string>();
if (thisDialog.ShowDialog() == DialogResult.OK)
{
foreach (String file in thisDialog.FileNames)
{
try
{
if ((myStream = thisDialog.OpenFile()) != null)
{
using (myStream)
{
listBoxFiles.Items.Add(file);
lastPath = file;
}
}
}
catch (Exception ex)
{
MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message);
}
}
for (int i = 0; i < listBoxFiles.Items.Count; i++)
{
string path = (string)listBoxFiles.Items[i];
FileInfo fileInfo = new FileInfo(path);
if (fileInfo.Extension != ".AVI")
{
listToRemove.Add(path);
}
}
(new System.Threading.Thread(sendFilesToConvertToPcap)).Start();
foreach (string file in listToRemove) //remove all non .AVI files from listbox
{
listBoxFiles.Items.Remove(file);
}
}
}
```
this function need to change the Label:
```
public void sendFilesToConvertToPcap()
{
if (listToRemove.Count == 0) // nothing to do
{
return;
}
lblStatus2.Content = "Convert file to .AVI...";
foreach (String file in listToRemove)
{
FileInfo fileInfo = new FileInfo(file);
myClass = new (class who convert the files)(fileInfo);
String newFileName = myClass.mNewFileName;
listBoxFiles.Items.Add(myClass._newFileName);
}
lblStatus2.Content = "Finished...";
}
``` | 2012/03/06 | ['https://Stackoverflow.com/questions/9590702', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/979033/'] | From your question, it seems that you'd like to convert several files. You may want to consider using the [BackgroundWorker](http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker.aspx) class and overwrite the DoWork and ProgressChanged events as described in [this article](http://msdn.microsoft.com/en-us/library/cc221403%28v=vs.95%29.aspx). You can update the label and other controls in the ProgressChanged event. | ```
public void sendFilesToConvertToPcap()
{
.....
....
this.Invoke((MethodInvoker)delegate {
lblStatus2.Text = "Convert file to .AVI..."; });
....
}
``` |
9,590,702 | I have a ListBox which I put some files, if the file is not AVI I automatically converts it but I want when the files converting message will write on a label that the files are now converted to another format, i know i need use Dispatcher in order to update the UI thread but i use now Winform instead of WPF, and i need help with this.
BTW i cannot use Task because i am using .Net 3.5
```
private void btnAdd_Click(object sender, EventArgs e)
{
System.IO.Stream myStream;
OpenFileDialog thisDialog = new OpenFileDialog();
thisDialog.InitialDirectory = "c:\\";
thisDialog.Filter = "All files (*.*)|*.*";
thisDialog.FilterIndex = 1;
thisDialog.RestoreDirectory = false;
thisDialog.Multiselect = true; // Allow the user to select multiple files
thisDialog.Title = "Please Select Source File";
thisDialog.FileName = lastPath;
List<string> list = new List<string>();
if (thisDialog.ShowDialog() == DialogResult.OK)
{
foreach (String file in thisDialog.FileNames)
{
try
{
if ((myStream = thisDialog.OpenFile()) != null)
{
using (myStream)
{
listBoxFiles.Items.Add(file);
lastPath = file;
}
}
}
catch (Exception ex)
{
MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message);
}
}
for (int i = 0; i < listBoxFiles.Items.Count; i++)
{
string path = (string)listBoxFiles.Items[i];
FileInfo fileInfo = new FileInfo(path);
if (fileInfo.Extension != ".AVI")
{
listToRemove.Add(path);
}
}
(new System.Threading.Thread(sendFilesToConvertToPcap)).Start();
foreach (string file in listToRemove) //remove all non .AVI files from listbox
{
listBoxFiles.Items.Remove(file);
}
}
}
```
this function need to change the Label:
```
public void sendFilesToConvertToPcap()
{
if (listToRemove.Count == 0) // nothing to do
{
return;
}
lblStatus2.Content = "Convert file to .AVI...";
foreach (String file in listToRemove)
{
FileInfo fileInfo = new FileInfo(file);
myClass = new (class who convert the files)(fileInfo);
String newFileName = myClass.mNewFileName;
listBoxFiles.Items.Add(myClass._newFileName);
}
lblStatus2.Content = "Finished...";
}
``` | 2012/03/06 | ['https://Stackoverflow.com/questions/9590702', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/979033/'] | ```
public void sendFilesToConvertToPcap()
{
.....
....
this.Invoke((MethodInvoker)delegate {
lblStatus2.Text = "Convert file to .AVI..."; });
....
}
``` | This is a very common requirement for long-running processes. If you don't explicitly call methods on a separate thread, they will automatically run on the main (see: UI) thread and cause your UI to hand (as I suspect you already know).
<http://www.dotnetperls.com/backgroundworker>
Here is an old, but excellent link with an example on how to use the background worker to handle the threadpool for you.
This way, you can just create a worker to manage running your conversion process on a separate thread, and I believe there is even an example for creating a process bar. |
419,654 | I'm not sure what I'm doing wrong on my questions in [Go](https://en.wikipedia.org/wiki/Go_%28programming_language%29) as I always get downvotes.
Do you think something can be improved in these questions? Can I do something else to avoid being banned?
*[Deleting endpoint in Go is not working as expected](https://stackoverflow.com/questions/73249646/delete-endpoint-in-golang-not-working-as-expected/)*
*[Improving GET request using the default Go HTTP client](https://stackoverflow.com/questions/73232160/improving-get-request-with-net-http-packet-in-go)*
I always try to search the site first, research documentation, but for these two questions I'm banned... | 2022/08/05 | ['https://meta.stackoverflow.com/questions/419654', 'https://meta.stackoverflow.com', 'https://meta.stackoverflow.com/users/15083173/'] | I closed both questions.
[Delete endpoint in golang not working as expected](https://stackoverflow.com/questions/73249646/delete-endpoint-in-golang-not-working-as-expected/73250074#73250074)
This question seems to have just been a typo. It doesn't look useful to others unless you explain what the mistake in the URL was. Even then, the question would probably be misleading and not very useful, hence the downvotes.
[Improving get request with net/http packet](https://stackoverflow.com/questions/73232160/improving-get-request-with-net-http-packet-in-go)
This question needs to be narrowed down. What improvement are you looking for? If the code works and you are only looking for code review, then it should have been asked on <https://codereview.stackexchange.com/> | Your titles are not very informative - since SO primarily intends to be useful for other people with the same issue, a title like 'Delete endpoint in golang not working as expected' is really not very helpful, since nobody else knows what 'as expected' is meant to be. For some users, that would be grounds for a downvote as it renders the question 'not useful'.
Try and focus on titles which concisely but specifically explain your problem. |
24,371,011 | I have a Rails4 app with the following models:
```
1. Systems (has many devices, has many parameters through devices)
2. Devices (belongs to a system, has many parameters)
3. Parameters (belongs to a Device)
4. Events (polymorphic - Systems, Devices and Parameters can have events)
```
When an event is created, a boolean field (on the event) is assigned a value. False indicated a failure.
I have a scope on my events, to only show failing events:
```
scope :failing, -> { where(okay: false).order('created_at desc') }
```
I can retrieve events as follows:
```
System.events.failing
Device.events.failing
Parameter.events.failing
```
I am trying to return a list of Systems where either:
```
1. the most recent event for the system has failed
2. the most recent event for any of it's devices has failed
3. the most recent event for any parameters of it's devices have failed
```
I have written this (horrible) SQL query which when executed in the console, returns the systems as an array:
```
"SELECT * FROM Systems WHERE Systems.id IN (SELECT Devices.system_id FROM Devices WHERE Devices.id IN (SELECT Parameters.device_id FROM Parameters JOIN EVENTS ON Parameters.id=Events.eventable_id WHERE Events.okay ='f')) OR Systems.id IN (SELECT Devices.system_id FROM Devices JOIN Events ON Devices.id=Events.eventable_id WHERE Events.okay='f')")
```
I need to either define a scope on the System model or a class method to return a list of 'failing' systems. Can you help? | 2014/06/23 | ['https://Stackoverflow.com/questions/24371011', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2778833/'] | Basically your Javascript could be shortened to:
```
$(".question").click(function(argument) {
$(this).parent().find(".answer").removeClass("hideinit").addClass("display");
});
```
In order to make this work the only other thing you need to do is to make `question` a class rather than as an id. That looks like:
```
<p class="answer hideinit">the answer</p>
```
**[See the fiddle here](http://jsfiddle.net/6S9r3/2/)**
---
**Edit: Add Hide / Show**
To get this to hide and show as expected you'll want to update the code to check the current class before hiding and showing. That looks like:
```
$(".question").click(function(argument) {
var el = $(this).parent().find(".answer");
if (el.hasClass("display")) {
el.removeClass("display").addClass("hideinit");
} else {
el.removeClass("hideinit").addClass("display");
}
});
```
**[See the fiddle here](http://jsfiddle.net/6S9r3/3/)** | Well, for one thing, in your JSFiddle you were not including the jQuery library. I've adjusted your code, I think this is what you were going for:
```
$(".question").click(function() {
$(this).siblings().toggle();
});
```
Here's an [updated JSFiddle](http://jsfiddle.net/8UVAf/5/).
=========================================================== |
24,371,011 | I have a Rails4 app with the following models:
```
1. Systems (has many devices, has many parameters through devices)
2. Devices (belongs to a system, has many parameters)
3. Parameters (belongs to a Device)
4. Events (polymorphic - Systems, Devices and Parameters can have events)
```
When an event is created, a boolean field (on the event) is assigned a value. False indicated a failure.
I have a scope on my events, to only show failing events:
```
scope :failing, -> { where(okay: false).order('created_at desc') }
```
I can retrieve events as follows:
```
System.events.failing
Device.events.failing
Parameter.events.failing
```
I am trying to return a list of Systems where either:
```
1. the most recent event for the system has failed
2. the most recent event for any of it's devices has failed
3. the most recent event for any parameters of it's devices have failed
```
I have written this (horrible) SQL query which when executed in the console, returns the systems as an array:
```
"SELECT * FROM Systems WHERE Systems.id IN (SELECT Devices.system_id FROM Devices WHERE Devices.id IN (SELECT Parameters.device_id FROM Parameters JOIN EVENTS ON Parameters.id=Events.eventable_id WHERE Events.okay ='f')) OR Systems.id IN (SELECT Devices.system_id FROM Devices JOIN Events ON Devices.id=Events.eventable_id WHERE Events.okay='f')")
```
I need to either define a scope on the System model or a class method to return a list of 'failing' systems. Can you help? | 2014/06/23 | ['https://Stackoverflow.com/questions/24371011', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2778833/'] | Basically your Javascript could be shortened to:
```
$(".question").click(function(argument) {
$(this).parent().find(".answer").removeClass("hideinit").addClass("display");
});
```
In order to make this work the only other thing you need to do is to make `question` a class rather than as an id. That looks like:
```
<p class="answer hideinit">the answer</p>
```
**[See the fiddle here](http://jsfiddle.net/6S9r3/2/)**
---
**Edit: Add Hide / Show**
To get this to hide and show as expected you'll want to update the code to check the current class before hiding and showing. That looks like:
```
$(".question").click(function(argument) {
var el = $(this).parent().find(".answer");
if (el.hasClass("display")) {
el.removeClass("display").addClass("hideinit");
} else {
el.removeClass("hideinit").addClass("display");
}
});
```
**[See the fiddle here](http://jsfiddle.net/6S9r3/3/)** | Please watch your includes in your JSFiddle as the version you linked was not including the jQuery library. You should also clean up your multiple `id` references (as this is invalid HTML and will cause some issues down the road).
Those issues aside, you can use jQuery's [`.next()`](http://api.jquery.com/next/) method to help you with this particular problem:
```
$(".question").click(function (argument) {
$(this).next(".hideinit").removeClass("hideinit").addClass("display");
});
```
[JSFiddle](http://jsfiddle.net/8UVAf/4/) |
24,371,011 | I have a Rails4 app with the following models:
```
1. Systems (has many devices, has many parameters through devices)
2. Devices (belongs to a system, has many parameters)
3. Parameters (belongs to a Device)
4. Events (polymorphic - Systems, Devices and Parameters can have events)
```
When an event is created, a boolean field (on the event) is assigned a value. False indicated a failure.
I have a scope on my events, to only show failing events:
```
scope :failing, -> { where(okay: false).order('created_at desc') }
```
I can retrieve events as follows:
```
System.events.failing
Device.events.failing
Parameter.events.failing
```
I am trying to return a list of Systems where either:
```
1. the most recent event for the system has failed
2. the most recent event for any of it's devices has failed
3. the most recent event for any parameters of it's devices have failed
```
I have written this (horrible) SQL query which when executed in the console, returns the systems as an array:
```
"SELECT * FROM Systems WHERE Systems.id IN (SELECT Devices.system_id FROM Devices WHERE Devices.id IN (SELECT Parameters.device_id FROM Parameters JOIN EVENTS ON Parameters.id=Events.eventable_id WHERE Events.okay ='f')) OR Systems.id IN (SELECT Devices.system_id FROM Devices JOIN Events ON Devices.id=Events.eventable_id WHERE Events.okay='f')")
```
I need to either define a scope on the System model or a class method to return a list of 'failing' systems. Can you help? | 2014/06/23 | ['https://Stackoverflow.com/questions/24371011', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2778833/'] | Basically your Javascript could be shortened to:
```
$(".question").click(function(argument) {
$(this).parent().find(".answer").removeClass("hideinit").addClass("display");
});
```
In order to make this work the only other thing you need to do is to make `question` a class rather than as an id. That looks like:
```
<p class="answer hideinit">the answer</p>
```
**[See the fiddle here](http://jsfiddle.net/6S9r3/2/)**
---
**Edit: Add Hide / Show**
To get this to hide and show as expected you'll want to update the code to check the current class before hiding and showing. That looks like:
```
$(".question").click(function(argument) {
var el = $(this).parent().find(".answer");
if (el.hasClass("display")) {
el.removeClass("display").addClass("hideinit");
} else {
el.removeClass("hideinit").addClass("display");
}
});
```
**[See the fiddle here](http://jsfiddle.net/6S9r3/3/)** | ```
$(".question").on('click',function() {
$(this).next().toggle();
});
``` |
40,584,664 | I am new to TYPO3 and have a big problem. I deleted the page with the id 1 (startpage, I know its stupid) and now I woudl like to know if it is possible to restore the page somehow. | 2016/11/14 | ['https://Stackoverflow.com/questions/40584664', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3649851/'] | Install extension Recycler, it ships with TYPO3 by default. You can then restore pages and content you deleted using the backend UI it has.
<https://docs.typo3.org/typo3cms/extensions/recycler/Introduction/Index.html> | You can use the recycler that is found under the web module and click on a page in the page tree at a higher level than the deleted page. You can also set the depth to infinitive if not certain where the page used to be in the page tree. Then put a tick beside the page you want to restore and click undelete. Note that PID is 'Parent ID' (not Page ID), and UID is the ID of the deleted page.If you click on the little + you will get additional information, e.g. the original path to the deleted page. If part of the path is highlighted in red, then that indicates another deleted branch or page. Remember to leave the Recycler module with 'Depth' NOT set to 'Infinite' (leave it at 'This page' or '1-4 levels') otherwise the recycler will hang if you use it on a larger part of your page t ree. Hope this will help you. |
29,516,573 | This is something that has bugged me for many many years and have never asked.
Why is it that when writing SQL against a schema in a databases, whether it be Oracle, Postgres, MySQL or MSSQL I have to specify the database name and the table name? e.g.
SELECT id FROM mydb.mytable;
and other times as
SELECT id FROM mytable;
Is this some sort of configuration thing of the database I really would like to know why.
I am currently using the Postgres PGAdmin SQL Editor. I am selecting in the drop down the DB schema to utilize. When connecting to DB A I wont have to specify the DB in the query but when connecting to DB B I do have to specify the DB in the query. This is inconsistent and does not make any sense to me. | 2015/04/08 | ['https://Stackoverflow.com/questions/29516573', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/588492/'] | The main problem is that you have declared `position1` as a `VARCHAR(100)` instead of as an `INTEGER`. This leads to the unhelpful error here as there is no substring version that takes a varchar parameter (and in this context conversion from varchar to integer is not supported).
A working (or at least: compiling) version of your function is:
```sql
CREATE OR ALTER FUNCTION TRANSLATE_func
(text varchar(10000),
toReplace varchar(10000),
replacePattern varchar(10000))
RETURNS VARCHAR(100)
AS
declare variable resultat varchar(100);
declare variable cut varchar(100);
declare variable i integer;
declare variable position1 integer;
declare variable letter varchar(100);
declare variable lenght integer;
BEGIN
i = 1;
resultat ='';
lenght = char_length(text);
while(i <= lenght) do
begin
cut = substring(text from i for 1);
position1 = position(cut, toReplace);
if (position1 > 0) then
begin
letter = substring(replacePattern from position1 for 1);
resultat = resultat||''||letter;
end
else
begin
resultat = resultat ||''|| cut;
end
i = i+1;
end
return resultat;
END
``` | For Firebird 3
```sql
SET TERM ^ ;
create function translator (
inp varchar(10000),
pat varchar(1000),
rep varchar(1000))
returns varchar(10000)
as
declare variable tex varchar(10000);
declare variable inp_idx integer = 1;
declare variable cha char(1);
declare variable pos integer;
begin
tex = '';
while (inp_idx <= char_length(inp)) do
begin
cha = substring(inp from inp_idx for 1);
pos = position(cha, pat);
if (pos > 0) then
cha = substring(rep from pos for 1);
tex = tex || cha;
inp_idx = inp_idx + 1;
end
return tex;
end^
SET TERM ; ^
```
Test
```sql
select translator('džiná lasaí ireo dana kýrne číraž', 'ážíýč', 'AZIYC')
from rdb$database;
```
Result
```
dZinA lasaI ireo dana kYrne CIraZ
``` |
8,414,930 | I have...
```
Func<string> del2 = new Func<string>(MyMethod);
```
and I really want to do..
```
Func<> del2 = new Func<>(MyMethod);
```
so the return type of the callback method is void. Is this possible using the generic type func? | 2011/12/07 | ['https://Stackoverflow.com/questions/8414930', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/223863/'] | Yes a function returning void (no value) is a `Action`
```
public Test()
{
// first approach
Action firstApproach = delegate
{
// do your stuff
};
firstApproach();
//second approach
Action secondApproach = MyMethod;
secondApproach();
}
void MyMethod()
{
// do your stuff
}
```
**hope this helps** | Use [Action delegate type](http://msdn.microsoft.com/en-us/library/system.action.aspx). |
8,414,930 | I have...
```
Func<string> del2 = new Func<string>(MyMethod);
```
and I really want to do..
```
Func<> del2 = new Func<>(MyMethod);
```
so the return type of the callback method is void. Is this possible using the generic type func? | 2011/12/07 | ['https://Stackoverflow.com/questions/8414930', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/223863/'] | The `Func` family of delegates is for methods that take zero or more parameters and return a value. For methods that take zero or more parameters an don't return a value use one of the `Action` delegates. If the method has no parameters, use [the non-generic version of `Action`](http://msdn.microsoft.com/en-us/library/system.action.aspx):
```
Action del = MyMethod;
``` | Use [Action delegate type](http://msdn.microsoft.com/en-us/library/system.action.aspx). |
8,414,930 | I have...
```
Func<string> del2 = new Func<string>(MyMethod);
```
and I really want to do..
```
Func<> del2 = new Func<>(MyMethod);
```
so the return type of the callback method is void. Is this possible using the generic type func? | 2011/12/07 | ['https://Stackoverflow.com/questions/8414930', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/223863/'] | Yes a function returning void (no value) is a `Action`
```
public Test()
{
// first approach
Action firstApproach = delegate
{
// do your stuff
};
firstApproach();
//second approach
Action secondApproach = MyMethod;
secondApproach();
}
void MyMethod()
{
// do your stuff
}
```
**hope this helps** | In cases where you're 'forced' to use `Func<T>`, e.g. in an internal generic API which you want to reuse, you can just define it as `new Func<object>(() => { SomeStuff(); return null; });`. |
8,414,930 | I have...
```
Func<string> del2 = new Func<string>(MyMethod);
```
and I really want to do..
```
Func<> del2 = new Func<>(MyMethod);
```
so the return type of the callback method is void. Is this possible using the generic type func? | 2011/12/07 | ['https://Stackoverflow.com/questions/8414930', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/223863/'] | The `Func` family of delegates is for methods that take zero or more parameters and return a value. For methods that take zero or more parameters an don't return a value use one of the `Action` delegates. If the method has no parameters, use [the non-generic version of `Action`](http://msdn.microsoft.com/en-us/library/system.action.aspx):
```
Action del = MyMethod;
``` | Yes a function returning void (no value) is a `Action`
```
public Test()
{
// first approach
Action firstApproach = delegate
{
// do your stuff
};
firstApproach();
//second approach
Action secondApproach = MyMethod;
secondApproach();
}
void MyMethod()
{
// do your stuff
}
```
**hope this helps** |
8,414,930 | I have...
```
Func<string> del2 = new Func<string>(MyMethod);
```
and I really want to do..
```
Func<> del2 = new Func<>(MyMethod);
```
so the return type of the callback method is void. Is this possible using the generic type func? | 2011/12/07 | ['https://Stackoverflow.com/questions/8414930', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/223863/'] | Yes a function returning void (no value) is a `Action`
```
public Test()
{
// first approach
Action firstApproach = delegate
{
// do your stuff
};
firstApproach();
//second approach
Action secondApproach = MyMethod;
secondApproach();
}
void MyMethod()
{
// do your stuff
}
```
**hope this helps** | Here is a code example using Lambda expressions instead of Action/Func delegates.
```
delegate void TestDelegate();
static void Main(string[] args)
{
TestDelegate testDelegate = () => { /*your code*/; };
testDelegate();
}
``` |
8,414,930 | I have...
```
Func<string> del2 = new Func<string>(MyMethod);
```
and I really want to do..
```
Func<> del2 = new Func<>(MyMethod);
```
so the return type of the callback method is void. Is this possible using the generic type func? | 2011/12/07 | ['https://Stackoverflow.com/questions/8414930', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/223863/'] | The `Func` family of delegates is for methods that take zero or more parameters and return a value. For methods that take zero or more parameters an don't return a value use one of the `Action` delegates. If the method has no parameters, use [the non-generic version of `Action`](http://msdn.microsoft.com/en-us/library/system.action.aspx):
```
Action del = MyMethod;
``` | In cases where you're 'forced' to use `Func<T>`, e.g. in an internal generic API which you want to reuse, you can just define it as `new Func<object>(() => { SomeStuff(); return null; });`. |
8,414,930 | I have...
```
Func<string> del2 = new Func<string>(MyMethod);
```
and I really want to do..
```
Func<> del2 = new Func<>(MyMethod);
```
so the return type of the callback method is void. Is this possible using the generic type func? | 2011/12/07 | ['https://Stackoverflow.com/questions/8414930', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/223863/'] | The `Func` family of delegates is for methods that take zero or more parameters and return a value. For methods that take zero or more parameters an don't return a value use one of the `Action` delegates. If the method has no parameters, use [the non-generic version of `Action`](http://msdn.microsoft.com/en-us/library/system.action.aspx):
```
Action del = MyMethod;
``` | Here is a code example using Lambda expressions instead of Action/Func delegates.
```
delegate void TestDelegate();
static void Main(string[] args)
{
TestDelegate testDelegate = () => { /*your code*/; };
testDelegate();
}
``` |
9,247,730 | My question concerns writing JAXB plugins, in particular JAXB codemodel.
What is the role of `ClassOutline` (and it's [companions](http://www.docjar.com/docs/api/com/sun/tools/internal/xjc/outline/package-index.html)) and `JClass` (and [companions](http://codemodel.java.net/nonav/apidocs/com/sun/codemodel/package-summary.html)) and `CClass` (and [companions](http://www.docjar.com/docs/api/com/sun/tools/internal/xjc/model/package-index.html))? When looking at the list of classes in corresponding packages it is not clear what is chicken and what is egg.
My interpretation is that `CClass` (`CPropertyInfo`, `CEnumConstant`, ...) are created by XJC at first draft parsing of XSD. Then some magic happens and this model is transformed into `JClass` (`JFieldVar`, `JEnumConstant`, ...) and during this transformation customizations are applied. Afterwards plugins are invoked. `ClassOutline` is used as a bridge between these two models. Altogether looks very complicated.
With these parallel models I believe that the same information can be derived in several ways. For example, class field type:
* `JClass#fields()` → `JFieldVar#type` → `JType`
* `CClassInfo#getProperties()` → `CPropertyInfo#baseType` → `JType`
I am looking for verbose explanation of the lifecycle of above mentioned models. Thanks. | 2012/02/12 | ['https://Stackoverflow.com/questions/9247730', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/267197/'] | Oh, oh, someone is interested in XJC internals. I might be of some help since I've probably developed more JAXB plugins than anyone else (see [JAXB2 Basics](https://github.com/highsource/jaxb2-basics) for instance)
Ok, let's start. In XJC the schema compiler does approximately following
* Parses the schema
* Creates the model of the schema (CClass, CPropertyInfo etc.)
* Creates the outline (ClassOutline, FieldOutline etc.)
* Renders the code model (JClass, JDefinedClass, JMethod etc.)
* Writes the physical code (ex.Java files on the disk)
Let's start with the last two.
Java files don't need explanation, I hope.
Code model is also a relativesly easy thing. It is an API which can be used to construct Java code programmatically. You could just use string concatination instead, but it's much more error-prone. With CodeModel you're almost guaranteed to get at least grammatically correct Java code. So I hope this part is also clear. (By the way, I like CodeModel very much. I recently wrote [JavaScript Code Model](https://github.com/highsource/javascript-codemodel) based on ideas from the CodeModel.)
Let's now look at the "model" and the "outline".
Model is the result of parsing the incoming schema. It models the constructs of the incoming schema, mainly in terms of "classes" which corresponds to complex types and "properties" which corresponds to elements, attributes and values (ex. when you have a complex type with simple content).
The model should be understand as a logical modelling construct close to XML and schema. As such, it just describes types and properties that they have. It's surely much more complex that how I'm describing it, there's all sorts of exceptions and caveats - starting from wilcard types (xsd:any), substitution groups, enums, built-in types and so on.
Quite interestingly, a sibling of `Model` is `RuntimeTypeInfoSetImpl` which is used by JAXB in the runtime. So it's also a type of model - which is however not parsed from the XML Schema but rather from JAXB annotations in classes. The concept is the same. Both Model and `RuntimeTypeInfoSetImpl` implement the `TypeInfoSet` interface which is a super-construct. Check interfaces like `ClassInfo` and `PropertyInfo` - they have implementation both for compile-time (`CClassInfo` and `CPropertyInfo` in XJC) and run-time (`RuntimeClassInfoImpl` etc. for JAXB RI).
Ok, so when XJC parsed and analysed the schema, you've got the `Model`. This `Model` can't produce the code yet. There are, indeed, different strategies of producing the code. You can generate just annotated classes or you can generate interface/implementing class pair like in JAXB 1. The whole code generation thing isn't actually the task of the model. Moreover, there is a number of aspects that are relevant to the physical nature of the Java code, but aren't really relevant for the model. For instance, you have to group classes into packages. This is driven by the packing system of Java, not by the properties of the model itself.
And this is where outlines come into play. You can see outlines as step between the schema model and the code model. You can view outlines as factories for code model elements responsible for organization of the code and generation of `JDefinedClass`es from `CClassInfo`s.
So you're right, it is indeed very complicated. I am not a Sun/Oracle employee, I did not design it (I know the person who did it, though and respect him very much).
I can guess a couple of reasons for certain design decisions, for instance:
* Use the same interfaces for compile-time and run-time models
* Allow different strategies of code generation
* Allow plugins to manipulate the created model
I agree that this design is very complicated, but it has its reasons. One proof for that is that it was actually possible to build a mapping generator for XML-to-JavaScript mappings - basically on the same models. I just had to replace the code generation leaving schema analysis intact. (See [Jsonix](https://github.com/highsource/jsonix) for that.)
Ok, hopefully I shed some light on why things in XJC are how they are. Good luck with these APIs, they're not straghtforward. Feel free to check existing open-source code, there's a lot of examples available.
ps. Really always wanted to write this. :) | (This is to answer your further questions.)
Yes, it is possible to check customizations. [Here is](https://svn.java.net/svn/jaxb2-commons~svn/basics/trunk/tools/src/main/java/org/jvnet/jaxb2_commons/util/CustomizationUtils.java) a class I am using to access customizations.
The trick is that reference properties don't have own customizations, customizations are placed in the referenced element properties.
```
public static CCustomizations getCustomizations(
final CPropertyInfo propertyInfo) {
final CCustomizations main = new CCustomizations(
propertyInfo.getCustomizations());
final Collection<CCustomizations> elementCustomizations = propertyInfo
.accept(new CPropertyVisitor<Collection<CCustomizations>>() {
public Collection<CCustomizations> onAttribute(
CAttributePropertyInfo info) {
return Collections.emptyList();
}
public Collection<CCustomizations> onElement(
CElementPropertyInfo arg0) {
return Collections.emptyList();
}
public Collection<CCustomizations> onReference(
CReferencePropertyInfo info) {
final List<CCustomizations> elementCustomizations = new ArrayList<CCustomizations>(
info.getElements().size());
for (CElement element : info.getElements()) {
if (!(element instanceof CElementInfo && ((CElementInfo) element)
.hasClass())) {
elementCustomizations.add(element
.getCustomizations());
}
}
return elementCustomizations;
}
public Collection<CCustomizations> onValue(
CValuePropertyInfo arg0) {
return Collections.emptyList();
};
});
CCustomizations customizations = main;
for (CCustomizations e : elementCustomizations) {
main.addAll(e);
}
return customizations;
}
```
I'd say users@jaxb.java.net is a good place for such discussions. |
5,861,428 | In lots of Linux programs, like curl, wget, and anything with a progress meter, they have the bottom line constantly update, every certain amount of time. How do I do that in a bash script? All I can do now is just echo a new line, and that's not what I want because it builds up. I did come across something that mentioned "tput cup 0 0", but I tried it and it's kind of quirky. What's the best way? | 2011/05/02 | ['https://Stackoverflow.com/questions/5861428', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/689317/'] | Small variation on linuts' code sample to move the cursor not to the beginning, but the end of the current line.
```
{
for pc in {1..100}; do
#echo -ne "$pc%\033[0K\r"
echo -ne "\r\033[0K${pc}%"
sleep 1
done
echo
}
``` | man terminfo(5) and look at the "cap-nam" column.
```
clr_eol=$(tput el)
while true
do
printf "${clr_eol}your message here\r"
sleep 60
done
``` |
5,861,428 | In lots of Linux programs, like curl, wget, and anything with a progress meter, they have the bottom line constantly update, every certain amount of time. How do I do that in a bash script? All I can do now is just echo a new line, and that's not what I want because it builds up. I did come across something that mentioned "tput cup 0 0", but I tried it and it's kind of quirky. What's the best way? | 2011/05/02 | ['https://Stackoverflow.com/questions/5861428', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/689317/'] | You can also use `tput cuu1;tput el` (or `printf '\e[A\e[K'`) to move the cursor up one line and erase the line:
```
for i in {1..100};do echo $i;sleep 1;tput cuu1;tput el;done
``` | `printf '\r'`, usually. There's no reason for cursor addressing in this case. |
5,861,428 | In lots of Linux programs, like curl, wget, and anything with a progress meter, they have the bottom line constantly update, every certain amount of time. How do I do that in a bash script? All I can do now is just echo a new line, and that's not what I want because it builds up. I did come across something that mentioned "tput cup 0 0", but I tried it and it's kind of quirky. What's the best way? | 2011/05/02 | ['https://Stackoverflow.com/questions/5861428', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/689317/'] | Small variation on linuts' code sample to move the cursor not to the beginning, but the end of the current line.
```
{
for pc in {1..100}; do
#echo -ne "$pc%\033[0K\r"
echo -ne "\r\033[0K${pc}%"
sleep 1
done
echo
}
``` | `printf '\r'`, usually. There's no reason for cursor addressing in this case. |
5,861,428 | In lots of Linux programs, like curl, wget, and anything with a progress meter, they have the bottom line constantly update, every certain amount of time. How do I do that in a bash script? All I can do now is just echo a new line, and that's not what I want because it builds up. I did come across something that mentioned "tput cup 0 0", but I tried it and it's kind of quirky. What's the best way? | 2011/05/02 | ['https://Stackoverflow.com/questions/5861428', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/689317/'] | ```
{
for pc in $(seq 1 100); do
echo -ne "$pc%\033[0K\r"
usleep 100000
done
echo
}
```
The "\033[0K" will delete to the end of the line - in case your progress line gets shorter at some point, although this may not be necessary for your purposes.
The "\r" will move the cursor to the beginning of the current line
The -n on echo will prevent the cursor advancing to the next line | man terminfo(5) and look at the "cap-nam" column.
```
clr_eol=$(tput el)
while true
do
printf "${clr_eol}your message here\r"
sleep 60
done
``` |
5,861,428 | In lots of Linux programs, like curl, wget, and anything with a progress meter, they have the bottom line constantly update, every certain amount of time. How do I do that in a bash script? All I can do now is just echo a new line, and that's not what I want because it builds up. I did come across something that mentioned "tput cup 0 0", but I tried it and it's kind of quirky. What's the best way? | 2011/05/02 | ['https://Stackoverflow.com/questions/5861428', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/689317/'] | To actually erase *previous* lines, not just the current line, you can use the following bash functions:
```
# Clears the entire current line regardless of terminal size.
# See the magic by running:
# { sleep 1; clear_this_line ; }&
clear_this_line(){
printf '\r'
cols="$(tput cols)"
for i in $(seq "$cols"); do
printf ' '
done
printf '\r'
}
# Erases the amount of lines specified.
# Usage: erase_lines [AMOUNT]
# See the magic by running:
# { sleep 1; erase_lines 2; }&
erase_lines(){
# Default line count to 1.
test -z "$1" && lines="1" || lines="$1"
# This is what we use to move the cursor to previous lines.
UP='\033[1A'
# Exit if erase count is zero.
[ "$lines" = 0 ] && return
# Erase.
if [ "$lines" = 1 ]; then
clear_this_line
else
lines=$((lines-1))
clear_this_line
for i in $(seq "$lines"); do
printf "$UP"
clear_this_line
done
fi
}
```
Now, simply call `erase_lines 5` for example to clear the last 5 lines in the terminal. | man terminfo(5) and look at the "cap-nam" column.
```
clr_eol=$(tput el)
while true
do
printf "${clr_eol}your message here\r"
sleep 60
done
``` |
5,861,428 | In lots of Linux programs, like curl, wget, and anything with a progress meter, they have the bottom line constantly update, every certain amount of time. How do I do that in a bash script? All I can do now is just echo a new line, and that's not what I want because it builds up. I did come across something that mentioned "tput cup 0 0", but I tried it and it's kind of quirky. What's the best way? | 2011/05/02 | ['https://Stackoverflow.com/questions/5861428', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/689317/'] | ```
{
for pc in $(seq 1 100); do
echo -ne "$pc%\033[0K\r"
usleep 100000
done
echo
}
```
The "\033[0K" will delete to the end of the line - in case your progress line gets shorter at some point, although this may not be necessary for your purposes.
The "\r" will move the cursor to the beginning of the current line
The -n on echo will prevent the cursor advancing to the next line | `printf '\r'`, usually. There's no reason for cursor addressing in this case. |
5,861,428 | In lots of Linux programs, like curl, wget, and anything with a progress meter, they have the bottom line constantly update, every certain amount of time. How do I do that in a bash script? All I can do now is just echo a new line, and that's not what I want because it builds up. I did come across something that mentioned "tput cup 0 0", but I tried it and it's kind of quirky. What's the best way? | 2011/05/02 | ['https://Stackoverflow.com/questions/5861428', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/689317/'] | ```
{
for pc in $(seq 1 100); do
echo -ne "$pc%\033[0K\r"
usleep 100000
done
echo
}
```
The "\033[0K" will delete to the end of the line - in case your progress line gets shorter at some point, although this may not be necessary for your purposes.
The "\r" will move the cursor to the beginning of the current line
The -n on echo will prevent the cursor advancing to the next line | To actually erase *previous* lines, not just the current line, you can use the following bash functions:
```
# Clears the entire current line regardless of terminal size.
# See the magic by running:
# { sleep 1; clear_this_line ; }&
clear_this_line(){
printf '\r'
cols="$(tput cols)"
for i in $(seq "$cols"); do
printf ' '
done
printf '\r'
}
# Erases the amount of lines specified.
# Usage: erase_lines [AMOUNT]
# See the magic by running:
# { sleep 1; erase_lines 2; }&
erase_lines(){
# Default line count to 1.
test -z "$1" && lines="1" || lines="$1"
# This is what we use to move the cursor to previous lines.
UP='\033[1A'
# Exit if erase count is zero.
[ "$lines" = 0 ] && return
# Erase.
if [ "$lines" = 1 ]; then
clear_this_line
else
lines=$((lines-1))
clear_this_line
for i in $(seq "$lines"); do
printf "$UP"
clear_this_line
done
fi
}
```
Now, simply call `erase_lines 5` for example to clear the last 5 lines in the terminal. |
5,861,428 | In lots of Linux programs, like curl, wget, and anything with a progress meter, they have the bottom line constantly update, every certain amount of time. How do I do that in a bash script? All I can do now is just echo a new line, and that's not what I want because it builds up. I did come across something that mentioned "tput cup 0 0", but I tried it and it's kind of quirky. What's the best way? | 2011/05/02 | ['https://Stackoverflow.com/questions/5861428', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/689317/'] | You can also use `tput cuu1;tput el` (or `printf '\e[A\e[K'`) to move the cursor up one line and erase the line:
```
for i in {1..100};do echo $i;sleep 1;tput cuu1;tput el;done
``` | To actually erase *previous* lines, not just the current line, you can use the following bash functions:
```
# Clears the entire current line regardless of terminal size.
# See the magic by running:
# { sleep 1; clear_this_line ; }&
clear_this_line(){
printf '\r'
cols="$(tput cols)"
for i in $(seq "$cols"); do
printf ' '
done
printf '\r'
}
# Erases the amount of lines specified.
# Usage: erase_lines [AMOUNT]
# See the magic by running:
# { sleep 1; erase_lines 2; }&
erase_lines(){
# Default line count to 1.
test -z "$1" && lines="1" || lines="$1"
# This is what we use to move the cursor to previous lines.
UP='\033[1A'
# Exit if erase count is zero.
[ "$lines" = 0 ] && return
# Erase.
if [ "$lines" = 1 ]; then
clear_this_line
else
lines=$((lines-1))
clear_this_line
for i in $(seq "$lines"); do
printf "$UP"
clear_this_line
done
fi
}
```
Now, simply call `erase_lines 5` for example to clear the last 5 lines in the terminal. |
5,861,428 | In lots of Linux programs, like curl, wget, and anything with a progress meter, they have the bottom line constantly update, every certain amount of time. How do I do that in a bash script? All I can do now is just echo a new line, and that's not what I want because it builds up. I did come across something that mentioned "tput cup 0 0", but I tried it and it's kind of quirky. What's the best way? | 2011/05/02 | ['https://Stackoverflow.com/questions/5861428', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/689317/'] | ```
{
for pc in $(seq 1 100); do
echo -ne "$pc%\033[0K\r"
usleep 100000
done
echo
}
```
The "\033[0K" will delete to the end of the line - in case your progress line gets shorter at some point, although this may not be necessary for your purposes.
The "\r" will move the cursor to the beginning of the current line
The -n on echo will prevent the cursor advancing to the next line | Small variation on linuts' code sample to move the cursor not to the beginning, but the end of the current line.
```
{
for pc in {1..100}; do
#echo -ne "$pc%\033[0K\r"
echo -ne "\r\033[0K${pc}%"
sleep 1
done
echo
}
``` |
5,861,428 | In lots of Linux programs, like curl, wget, and anything with a progress meter, they have the bottom line constantly update, every certain amount of time. How do I do that in a bash script? All I can do now is just echo a new line, and that's not what I want because it builds up. I did come across something that mentioned "tput cup 0 0", but I tried it and it's kind of quirky. What's the best way? | 2011/05/02 | ['https://Stackoverflow.com/questions/5861428', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/689317/'] | ```
{
for pc in $(seq 1 100); do
echo -ne "$pc%\033[0K\r"
usleep 100000
done
echo
}
```
The "\033[0K" will delete to the end of the line - in case your progress line gets shorter at some point, although this may not be necessary for your purposes.
The "\r" will move the cursor to the beginning of the current line
The -n on echo will prevent the cursor advancing to the next line | You can also use `tput cuu1;tput el` (or `printf '\e[A\e[K'`) to move the cursor up one line and erase the line:
```
for i in {1..100};do echo $i;sleep 1;tput cuu1;tput el;done
``` |
17,572,348 | According to <http://guides.rubyonrails.org/routing.html>:
```
HTTP Verb Path Action Used for
GET /photos index display a list of all photos
GET /photos/new new return an HTML form for creating a new photo
POST /photos create create a new photo
GET /photos/:id show display a specific photo
GET /photos/:id/edit edit return an HTML form for editing a photo
PATCH/PUT /photos/:id update update a specific photo
DELETE /photos/:id destroy delete a specific photo
```
How does rails know when a PATCH/PUT REST is received. I understand the get/post but PATCH/PUT I cannot figure it out. Is something being done internally, like in the input. | 2013/07/10 | ['https://Stackoverflow.com/questions/17572348', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2542493/'] | Rails figures out which method to call based on whether the form submitted is a form for a new record that has not yet been saved or for a record that already exists in the database. | Read about "resource routing" in the document you referenced at the top of your post.
Also, run `rake routes` to see how rails is currently configured to route. |
17,572,348 | According to <http://guides.rubyonrails.org/routing.html>:
```
HTTP Verb Path Action Used for
GET /photos index display a list of all photos
GET /photos/new new return an HTML form for creating a new photo
POST /photos create create a new photo
GET /photos/:id show display a specific photo
GET /photos/:id/edit edit return an HTML form for editing a photo
PATCH/PUT /photos/:id update update a specific photo
DELETE /photos/:id destroy delete a specific photo
```
How does rails know when a PATCH/PUT REST is received. I understand the get/post but PATCH/PUT I cannot figure it out. Is something being done internally, like in the input. | 2013/07/10 | ['https://Stackoverflow.com/questions/17572348', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2542493/'] | Read about "resource routing" in the document you referenced at the top of your post.
Also, run `rake routes` to see how rails is currently configured to route. | In The Terminal Type:
```
$rake routes
```
and hit enter
Prefix Verb URI Pattern Controller#Action
root GET / welcome#index |
17,572,348 | According to <http://guides.rubyonrails.org/routing.html>:
```
HTTP Verb Path Action Used for
GET /photos index display a list of all photos
GET /photos/new new return an HTML form for creating a new photo
POST /photos create create a new photo
GET /photos/:id show display a specific photo
GET /photos/:id/edit edit return an HTML form for editing a photo
PATCH/PUT /photos/:id update update a specific photo
DELETE /photos/:id destroy delete a specific photo
```
How does rails know when a PATCH/PUT REST is received. I understand the get/post but PATCH/PUT I cannot figure it out. Is something being done internally, like in the input. | 2013/07/10 | ['https://Stackoverflow.com/questions/17572348', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2542493/'] | Rails figures out which method to call based on whether the form submitted is a form for a new record that has not yet been saved or for a record that already exists in the database. | In The Terminal Type:
```
$rake routes
```
and hit enter
Prefix Verb URI Pattern Controller#Action
root GET / welcome#index |
425,937 | I leanred, if all partial derivatives exist and all are continuous, then it is differentiable. Am I wrong?
I tried same way for this problem, I think it is differentiable because
all the derivative exist and are continuous.
However, it is not differentiable at 0.
Why is it the case?
![The problem](https://i.stack.imgur.com/UWjHD.jpg)
![Another problem](https://i.stack.imgur.com/ozRR1.jpg)
// then I think... the functions of tho problems all have discontinuous partial derivative at (0,0)... right?
then, why is it differentiable or not?.. | 2013/06/21 | ['https://math.stackexchange.com/questions/425937', 'https://math.stackexchange.com', 'https://math.stackexchange.com/users/78027/'] | The partial derivatives evaluate to both to $0$. Thus, **if** the function is differentiable, it must be the case the differential is identically zero.
You're looking at $$\lim\_{(x,y)\to (0,0)}\left|\frac{f(x,y)-\nabla f(x,y)\cdot (x-y) }{\lVert (x,y)\rVert}\right|$$
This is $$\lim\_{(x,y)\to (0,0)}\left|\frac{xy}{x^2+y^2}\right|$$
What happens if you take the limit along $y=x$? Is it $0$, as it should be?
**ADD** The partial derivatives are $$\eqalign{
& \frac{{\partial f}}{{\partial x}} = \frac{{{y^2}}}{{{x^2} + {y^2}}}\frac{y}{{\sqrt {{x^2} + {y^2}} }} \cr
& \frac{{\partial f}}{{\partial y}} = \frac{{{x^2}}}{{{x^2} + {y^2}}}\frac{x}{{\sqrt {{x^2} + {y^2}} }} \cr} $$
Are you **sure** they are continuous at the origin? | For the first one.
if $y = ax$,
$\dfrac{xy}{\sqrt{x^2+y^2}}
=\dfrac{ax^2}{\sqrt{x^2+a^2x^2}}
=\dfrac{a}{\sqrt{1+a^2}}
$,
so the function is not even continuous
at $(0, 0)$.
(This is, of course, not original.) |
4,261,219 | I've been tinkering around trying to make an AI player for the popular card game, Dominion (http://www.boardgamegeek.com/boardgame/36218/dominion).
If you are not familiar with the game, it is basically a very streamlined cousin of Magic: The Gathering, where there is a large-ish library of cards with different rules on them. Over the course of a game, players buy these cards and incorporate them into their deck.
I am interested in this game from a machine learning perspective - I want to pit bots against each other, have them play millions of games, and try to datamine insights that will make them play better.
I am unsure how to separate the rules of the game (the verbatim instructions printed on each card) from the core AI decision-making logic.
The obvious path that I have started down is creating a class for each Card, and putting both rules and AI stuff in the same place. This is sort of gross - but it seems like the path of least resistance. But maybe it is best for each card to support some sort of interface and then have AI components code against these?
Is there a "Correct" OOP design for this? Or several reasonable possibilities? | 2010/11/23 | ['https://Stackoverflow.com/questions/4261219', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/409020/'] | I would lean toward encapsulating the behaviour of a card as its own class, allowing easily for cards that have multiple behaviours (i.e. choices). It would also allow you to write parameterizable behaviours and mix and match them with cards.
So cards would contain things like the cost of the card, when it can be played, its name, etc. It would also contain a list of behaviours that the card can do.
The behaviours are seen by the AI actors as part of the cards. Just another property the cards have that can be weighed along with the cost.
The AI actor that is actually *using* the card's behaviour needs to be able to interpret the behaviours, so the behaviour class might need to contain some hints for the AI to understand it, but no actual AI logic itself should be contained there. If AIs need specific behaviours for specific cards, write that kind of thing into the AI actor, not the card behaviour.
If an AI actor needs to know that, for example, this behaviour has an expected victory point payoff of .2 points/round, that might be a part of the behaviour that acts as a hint to the AI when choosing what cards to buy/play.
But really I don't know how you're approaching your AI actor design so maybe this doesn't make sense. But I think that thinking of behaviour as a property of cards rather than a fundamental part of the cards themselves might help.
It gives you the advantage of encapsulating the AI actors' default actions (things the actors can do without needing cards) as behaviours as well, so you can weigh those actions against card actions without any special-case code. | I'm not familiar with all the variations of cards in Dominion, but the idea of writing a class for each one seems burdensome. Ideally, you would want to create a general card class that encapsulated all the variations of instructions on the card, and then load the particular values for a given card into that general class.
I can imagine a class that contains sets of powers and restrictions could be a good general representation. Something like:
* Required in play resources for play
* State where play is prohibited
* Damage types/value
* Health/mana changes
* Effects on other cards (perhaps a dictionary of card ids and effects)
* etc... |
4,261,219 | I've been tinkering around trying to make an AI player for the popular card game, Dominion (http://www.boardgamegeek.com/boardgame/36218/dominion).
If you are not familiar with the game, it is basically a very streamlined cousin of Magic: The Gathering, where there is a large-ish library of cards with different rules on them. Over the course of a game, players buy these cards and incorporate them into their deck.
I am interested in this game from a machine learning perspective - I want to pit bots against each other, have them play millions of games, and try to datamine insights that will make them play better.
I am unsure how to separate the rules of the game (the verbatim instructions printed on each card) from the core AI decision-making logic.
The obvious path that I have started down is creating a class for each Card, and putting both rules and AI stuff in the same place. This is sort of gross - but it seems like the path of least resistance. But maybe it is best for each card to support some sort of interface and then have AI components code against these?
Is there a "Correct" OOP design for this? Or several reasonable possibilities? | 2010/11/23 | ['https://Stackoverflow.com/questions/4261219', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/409020/'] | there are several "correct" OOP designs for this, depending on *how you want to model the game process and the game-playing-agent's AI*
personally, i would take the minimum number of cards for a valid *round* in the game and implement those as instances of a Card class, and implement the players as instances of an Agent class, and implement a few simple playing strategies as instances of a Strategy (pattern) class, and then *see what happens*
run through some tests, have a totally random player as a foil, look at short-term gain/loss max/min operators, try mutating the agent's strategies using a genetic algorithm, download an XCS classifier and see if it is useful to derive strategies...
...the notion of a correct model depends strongly on how it will be used. Once you understand how you need to use the elements of the game and model/manipulate the player strategies/tactics, then you'll know what the 'correct' structure is for your solution | I'm not familiar with all the variations of cards in Dominion, but the idea of writing a class for each one seems burdensome. Ideally, you would want to create a general card class that encapsulated all the variations of instructions on the card, and then load the particular values for a given card into that general class.
I can imagine a class that contains sets of powers and restrictions could be a good general representation. Something like:
* Required in play resources for play
* State where play is prohibited
* Damage types/value
* Health/mana changes
* Effects on other cards (perhaps a dictionary of card ids and effects)
* etc... |
4,261,219 | I've been tinkering around trying to make an AI player for the popular card game, Dominion (http://www.boardgamegeek.com/boardgame/36218/dominion).
If you are not familiar with the game, it is basically a very streamlined cousin of Magic: The Gathering, where there is a large-ish library of cards with different rules on them. Over the course of a game, players buy these cards and incorporate them into their deck.
I am interested in this game from a machine learning perspective - I want to pit bots against each other, have them play millions of games, and try to datamine insights that will make them play better.
I am unsure how to separate the rules of the game (the verbatim instructions printed on each card) from the core AI decision-making logic.
The obvious path that I have started down is creating a class for each Card, and putting both rules and AI stuff in the same place. This is sort of gross - but it seems like the path of least resistance. But maybe it is best for each card to support some sort of interface and then have AI components code against these?
Is there a "Correct" OOP design for this? Or several reasonable possibilities? | 2010/11/23 | ['https://Stackoverflow.com/questions/4261219', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/409020/'] | I would lean toward encapsulating the behaviour of a card as its own class, allowing easily for cards that have multiple behaviours (i.e. choices). It would also allow you to write parameterizable behaviours and mix and match them with cards.
So cards would contain things like the cost of the card, when it can be played, its name, etc. It would also contain a list of behaviours that the card can do.
The behaviours are seen by the AI actors as part of the cards. Just another property the cards have that can be weighed along with the cost.
The AI actor that is actually *using* the card's behaviour needs to be able to interpret the behaviours, so the behaviour class might need to contain some hints for the AI to understand it, but no actual AI logic itself should be contained there. If AIs need specific behaviours for specific cards, write that kind of thing into the AI actor, not the card behaviour.
If an AI actor needs to know that, for example, this behaviour has an expected victory point payoff of .2 points/round, that might be a part of the behaviour that acts as a hint to the AI when choosing what cards to buy/play.
But really I don't know how you're approaching your AI actor design so maybe this doesn't make sense. But I think that thinking of behaviour as a property of cards rather than a fundamental part of the cards themselves might help.
It gives you the advantage of encapsulating the AI actors' default actions (things the actors can do without needing cards) as behaviours as well, so you can weigh those actions against card actions without any special-case code. | I've been thinking about the logic for a non-AI version of Dominion, and it's still a mess to figure out.
You almost have to have a class for each card deck and an interface for each card type, keeping in mind that cards may have multiple types (such as Great Hall which is both Action and Victory).
At present, all Attack cards are also Actions, so you may want to make the Attack interface subclass action. For most cards, the Action would just call the Attack method. However, there are a few cards where this would need to be different, such as for Minion where you have a choice whether or not to attack.
Reaction cards are also Actions, but will also need special handling, as they can be revealed during an opponent's turn in response to an Attack card. As of Prosperity, they can also be revealed in response to things other than attacks... Watchtower can be revealed any time you would gain a card.
Duration cards (which I missed in my list of 7 card types earlier) are Actions that stay in play for an extra turn... and also count for the Peddler's buy cost in Prosperity.
Edit: Whoops, I didn't address the AI issue at all here... probably because my own development had been aimed more at a multiplayer network version. |
4,261,219 | I've been tinkering around trying to make an AI player for the popular card game, Dominion (http://www.boardgamegeek.com/boardgame/36218/dominion).
If you are not familiar with the game, it is basically a very streamlined cousin of Magic: The Gathering, where there is a large-ish library of cards with different rules on them. Over the course of a game, players buy these cards and incorporate them into their deck.
I am interested in this game from a machine learning perspective - I want to pit bots against each other, have them play millions of games, and try to datamine insights that will make them play better.
I am unsure how to separate the rules of the game (the verbatim instructions printed on each card) from the core AI decision-making logic.
The obvious path that I have started down is creating a class for each Card, and putting both rules and AI stuff in the same place. This is sort of gross - but it seems like the path of least resistance. But maybe it is best for each card to support some sort of interface and then have AI components code against these?
Is there a "Correct" OOP design for this? Or several reasonable possibilities? | 2010/11/23 | ['https://Stackoverflow.com/questions/4261219', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/409020/'] | there are several "correct" OOP designs for this, depending on *how you want to model the game process and the game-playing-agent's AI*
personally, i would take the minimum number of cards for a valid *round* in the game and implement those as instances of a Card class, and implement the players as instances of an Agent class, and implement a few simple playing strategies as instances of a Strategy (pattern) class, and then *see what happens*
run through some tests, have a totally random player as a foil, look at short-term gain/loss max/min operators, try mutating the agent's strategies using a genetic algorithm, download an XCS classifier and see if it is useful to derive strategies...
...the notion of a correct model depends strongly on how it will be used. Once you understand how you need to use the elements of the game and model/manipulate the player strategies/tactics, then you'll know what the 'correct' structure is for your solution | I've been thinking about the logic for a non-AI version of Dominion, and it's still a mess to figure out.
You almost have to have a class for each card deck and an interface for each card type, keeping in mind that cards may have multiple types (such as Great Hall which is both Action and Victory).
At present, all Attack cards are also Actions, so you may want to make the Attack interface subclass action. For most cards, the Action would just call the Attack method. However, there are a few cards where this would need to be different, such as for Minion where you have a choice whether or not to attack.
Reaction cards are also Actions, but will also need special handling, as they can be revealed during an opponent's turn in response to an Attack card. As of Prosperity, they can also be revealed in response to things other than attacks... Watchtower can be revealed any time you would gain a card.
Duration cards (which I missed in my list of 7 card types earlier) are Actions that stay in play for an extra turn... and also count for the Peddler's buy cost in Prosperity.
Edit: Whoops, I didn't address the AI issue at all here... probably because my own development had been aimed more at a multiplayer network version. |
4,261,219 | I've been tinkering around trying to make an AI player for the popular card game, Dominion (http://www.boardgamegeek.com/boardgame/36218/dominion).
If you are not familiar with the game, it is basically a very streamlined cousin of Magic: The Gathering, where there is a large-ish library of cards with different rules on them. Over the course of a game, players buy these cards and incorporate them into their deck.
I am interested in this game from a machine learning perspective - I want to pit bots against each other, have them play millions of games, and try to datamine insights that will make them play better.
I am unsure how to separate the rules of the game (the verbatim instructions printed on each card) from the core AI decision-making logic.
The obvious path that I have started down is creating a class for each Card, and putting both rules and AI stuff in the same place. This is sort of gross - but it seems like the path of least resistance. But maybe it is best for each card to support some sort of interface and then have AI components code against these?
Is there a "Correct" OOP design for this? Or several reasonable possibilities? | 2010/11/23 | ['https://Stackoverflow.com/questions/4261219', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/409020/'] | I would lean toward encapsulating the behaviour of a card as its own class, allowing easily for cards that have multiple behaviours (i.e. choices). It would also allow you to write parameterizable behaviours and mix and match them with cards.
So cards would contain things like the cost of the card, when it can be played, its name, etc. It would also contain a list of behaviours that the card can do.
The behaviours are seen by the AI actors as part of the cards. Just another property the cards have that can be weighed along with the cost.
The AI actor that is actually *using* the card's behaviour needs to be able to interpret the behaviours, so the behaviour class might need to contain some hints for the AI to understand it, but no actual AI logic itself should be contained there. If AIs need specific behaviours for specific cards, write that kind of thing into the AI actor, not the card behaviour.
If an AI actor needs to know that, for example, this behaviour has an expected victory point payoff of .2 points/round, that might be a part of the behaviour that acts as a hint to the AI when choosing what cards to buy/play.
But really I don't know how you're approaching your AI actor design so maybe this doesn't make sense. But I think that thinking of behaviour as a property of cards rather than a fundamental part of the cards themselves might help.
It gives you the advantage of encapsulating the AI actors' default actions (things the actors can do without needing cards) as behaviours as well, so you can weigh those actions against card actions without any special-case code. | there are several "correct" OOP designs for this, depending on *how you want to model the game process and the game-playing-agent's AI*
personally, i would take the minimum number of cards for a valid *round* in the game and implement those as instances of a Card class, and implement the players as instances of an Agent class, and implement a few simple playing strategies as instances of a Strategy (pattern) class, and then *see what happens*
run through some tests, have a totally random player as a foil, look at short-term gain/loss max/min operators, try mutating the agent's strategies using a genetic algorithm, download an XCS classifier and see if it is useful to derive strategies...
...the notion of a correct model depends strongly on how it will be used. Once you understand how you need to use the elements of the game and model/manipulate the player strategies/tactics, then you'll know what the 'correct' structure is for your solution |
12,726,149 | I downloaded and configured eclipse cdt along with MinGW and able to compile c programs.
My question, how to start executing the program in command prompt when Run option clicked from eclipse. Currently it always executes the program in eclipse console.
Reason to have command prompt for executing c programs is to accept user inputs.
I would also like to know is there a way to accept user inputs when c program running in eclipse console.
Thanks in advance,
-Manju | 2012/10/04 | ['https://Stackoverflow.com/questions/12726149', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/612465/'] | Yes.
```
select
substring(data, 1, PATINDEX('%[0-9]%',data)-1) as ename,
substring(data, PATINDEX('%[0-9]%',data), len(data)) as sal
from
table
``` | ```
SELECT SUBSTRING(@ourName, 1, CHARINDEX(' ', @ourName)) AS [First],
SUBSTRING(@ourName, CHARINDEX(' ', @ourName) + 2, LEN(@ourName)) AS[Last]
``` |
26,371,381 | Let's say I have two Tables, called Person, and Couple, where each Couple record stores a pair of Person id's (also assume that each person is bound to *at most* another different person).
I am planning to support a lot of queries where I will ask for Person records that are not married yet. Do you guys think it's worthwhile to add a 'partnerId' field to Person? (It would be set to null if that person is not married yet)
I am hesitant to do this because the partnerId field is something that is computable - just go through the Couple table to find out. The performance cost for creating new couple will also increase because I have to do this extra book keeping.
I hope that it doesn't sound like I am asking two different questions here, but I felt that this is relevant. Is it a good/common idea to include extra fields that are redundant (computable/inferable by joining with other tables), but will make your query a lot easier to write and faster?
Thanks! | 2014/10/14 | ['https://Stackoverflow.com/questions/26371381', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4143394/'] | A better option is to keep the data normalized, and utilize a view (indexed, if supported by your rdbms). This gets you the convenience of dealing with all the relevant fields in one place, without denormalizing your data.
Note: Even if a database doesn't support indexed views, you'll likely still be better off with a view as the indexes on the underlying tables can be utilized. | Is there always a zero to one relationship between Person and Couples? i.e. a person can have zero or one partner? If so then your `Couple` table is actually redundant, and your new field is a better approach.
The only reason to split `Couple` off to another table is if one Person can have many partners.
When someone gets a partner you either write one record to the `Couple` table or update one record in the `Person` table. I argue that your `Couple` table is redundant here. You haven't indicated that there is any extra info on the `Couple` record besides the link, and it appears that there is only ever zero or one Couple record for every `Person` record. |
26,371,381 | Let's say I have two Tables, called Person, and Couple, where each Couple record stores a pair of Person id's (also assume that each person is bound to *at most* another different person).
I am planning to support a lot of queries where I will ask for Person records that are not married yet. Do you guys think it's worthwhile to add a 'partnerId' field to Person? (It would be set to null if that person is not married yet)
I am hesitant to do this because the partnerId field is something that is computable - just go through the Couple table to find out. The performance cost for creating new couple will also increase because I have to do this extra book keeping.
I hope that it doesn't sound like I am asking two different questions here, but I felt that this is relevant. Is it a good/common idea to include extra fields that are redundant (computable/inferable by joining with other tables), but will make your query a lot easier to write and faster?
Thanks! | 2014/10/14 | ['https://Stackoverflow.com/questions/26371381', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4143394/'] | A better option is to keep the data normalized, and utilize a view (indexed, if supported by your rdbms). This gets you the convenience of dealing with all the relevant fields in one place, without denormalizing your data.
Note: Even if a database doesn't support indexed views, you'll likely still be better off with a view as the indexes on the underlying tables can be utilized. | How about one table?
```
-- This is psuedo-code, the syntax is not correct, but it should
-- be clear what it's doing
CREATE TABLE Person
(
PersonId int not null
primary key
,PartnerId int null
foreign key references Person (PersonId)
)
```
With this,
* Everyone on the system has a row and a PersonId
* If you have a partner, they are listed in the PartnerId column
Unnormalized data is always bad. Denormalized data, now, that can be beneficial under very specific circumstances. The best advice I ever heard on this subject it to first fully normalize your data, assess performance/goals/objectives, and then carefully denormalize only if it's demonstrably worth the extra overhead. |
26,371,381 | Let's say I have two Tables, called Person, and Couple, where each Couple record stores a pair of Person id's (also assume that each person is bound to *at most* another different person).
I am planning to support a lot of queries where I will ask for Person records that are not married yet. Do you guys think it's worthwhile to add a 'partnerId' field to Person? (It would be set to null if that person is not married yet)
I am hesitant to do this because the partnerId field is something that is computable - just go through the Couple table to find out. The performance cost for creating new couple will also increase because I have to do this extra book keeping.
I hope that it doesn't sound like I am asking two different questions here, but I felt that this is relevant. Is it a good/common idea to include extra fields that are redundant (computable/inferable by joining with other tables), but will make your query a lot easier to write and faster?
Thanks! | 2014/10/14 | ['https://Stackoverflow.com/questions/26371381', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4143394/'] | A better option is to keep the data normalized, and utilize a view (indexed, if supported by your rdbms). This gets you the convenience of dealing with all the relevant fields in one place, without denormalizing your data.
Note: Even if a database doesn't support indexed views, you'll likely still be better off with a view as the indexes on the underlying tables can be utilized. | I agree with Nick. Also consider the need for history of the couples. You could use row versioning in the same table, but this doesn't work very well for application databases, works best in a in a DW scenario. A history table in theory would duplicate all the data in the table, not just the relationship. A secondary table would give you this flexibility to add additional information about the relationship including StartDate and EndDate. |
26,371,381 | Let's say I have two Tables, called Person, and Couple, where each Couple record stores a pair of Person id's (also assume that each person is bound to *at most* another different person).
I am planning to support a lot of queries where I will ask for Person records that are not married yet. Do you guys think it's worthwhile to add a 'partnerId' field to Person? (It would be set to null if that person is not married yet)
I am hesitant to do this because the partnerId field is something that is computable - just go through the Couple table to find out. The performance cost for creating new couple will also increase because I have to do this extra book keeping.
I hope that it doesn't sound like I am asking two different questions here, but I felt that this is relevant. Is it a good/common idea to include extra fields that are redundant (computable/inferable by joining with other tables), but will make your query a lot easier to write and faster?
Thanks! | 2014/10/14 | ['https://Stackoverflow.com/questions/26371381', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4143394/'] | Is there always a zero to one relationship between Person and Couples? i.e. a person can have zero or one partner? If so then your `Couple` table is actually redundant, and your new field is a better approach.
The only reason to split `Couple` off to another table is if one Person can have many partners.
When someone gets a partner you either write one record to the `Couple` table or update one record in the `Person` table. I argue that your `Couple` table is redundant here. You haven't indicated that there is any extra info on the `Couple` record besides the link, and it appears that there is only ever zero or one Couple record for every `Person` record. | How about one table?
```
-- This is psuedo-code, the syntax is not correct, but it should
-- be clear what it's doing
CREATE TABLE Person
(
PersonId int not null
primary key
,PartnerId int null
foreign key references Person (PersonId)
)
```
With this,
* Everyone on the system has a row and a PersonId
* If you have a partner, they are listed in the PartnerId column
Unnormalized data is always bad. Denormalized data, now, that can be beneficial under very specific circumstances. The best advice I ever heard on this subject it to first fully normalize your data, assess performance/goals/objectives, and then carefully denormalize only if it's demonstrably worth the extra overhead. |
26,371,381 | Let's say I have two Tables, called Person, and Couple, where each Couple record stores a pair of Person id's (also assume that each person is bound to *at most* another different person).
I am planning to support a lot of queries where I will ask for Person records that are not married yet. Do you guys think it's worthwhile to add a 'partnerId' field to Person? (It would be set to null if that person is not married yet)
I am hesitant to do this because the partnerId field is something that is computable - just go through the Couple table to find out. The performance cost for creating new couple will also increase because I have to do this extra book keeping.
I hope that it doesn't sound like I am asking two different questions here, but I felt that this is relevant. Is it a good/common idea to include extra fields that are redundant (computable/inferable by joining with other tables), but will make your query a lot easier to write and faster?
Thanks! | 2014/10/14 | ['https://Stackoverflow.com/questions/26371381', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4143394/'] | Is there always a zero to one relationship between Person and Couples? i.e. a person can have zero or one partner? If so then your `Couple` table is actually redundant, and your new field is a better approach.
The only reason to split `Couple` off to another table is if one Person can have many partners.
When someone gets a partner you either write one record to the `Couple` table or update one record in the `Person` table. I argue that your `Couple` table is redundant here. You haven't indicated that there is any extra info on the `Couple` record besides the link, and it appears that there is only ever zero or one Couple record for every `Person` record. | I agree with Nick. Also consider the need for history of the couples. You could use row versioning in the same table, but this doesn't work very well for application databases, works best in a in a DW scenario. A history table in theory would duplicate all the data in the table, not just the relationship. A secondary table would give you this flexibility to add additional information about the relationship including StartDate and EndDate. |
70,342,429 | I trying to change the color of the chevron indicator that appears on the section headers in a List view likest one shown here:
[![enter image description here](https://i.stack.imgur.com/paNRA.png)](https://i.stack.imgur.com/paNRA.png)
I tried to do that by setting the tint color on the list view:
```
List {
...
}
.tint(.red)
...
```
That is not working.
How can I change the color of that indicator? | 2021/12/14 | ['https://Stackoverflow.com/questions/70342429', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/728246/'] | You haven't provided much code but some change with `accentColor` instead of `tint` | The chevron can't react on any color changing modifiers.
You have to disable standard chevron and use own, custom, (behaviour of the List is the same), like below
```js
HStack {
Text(text)
NavigationLink(destination: Text("D")) { EmptyView() } // disabled !
Image(systemName: "chevron.right") // << custom !!
.foregroundColor(Color.red) // any color !!!
}
``` |
18,274,428 | I'm tried to deploy a new version of my app to heroku. The deployment fails because heroku says, that the gem pg is not in my GEMFILE ... I have this postgres gem in my GEMFILE. I also looked for some answers, but no one worked ... As anyone an idea?
I use Ruby 2.0.0p247, Rails 3.2.14 refinery-cms 2.1.0
Here is my Gemfile:
```
source 'https://rubygems.org'
ruby '2.0.0'
gem 'rails'
gem 'newrelic_rpm'
group :production do
gem 'pg'
gem 'fog'
end
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails'
gem 'coffee-rails'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', :platforms => :ruby
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby'
# To use Jbuilder templates for JSON
gem 'jbuilder'
# Use unicorn as the app server
gem 'unicorn'
# Deploy with Capistrano
gem 'capistrano'
# To use debugger
gem 'debugger'
# The Heroku gem allows you to interface with Heroku's API
gem 'heroku'
# Fog allows you to use S3 assets (added for Heroku)
gem 'fog'
# Postgres support (added for Heroku)
#gem 'pg'
#Connecting to Amazon S3
gem 'aws-s3'
#gem 'taps'
# Refinery CMS
#gem 'refinerycms', '~> 2.0.0', :git => 'git://github.com/refinery/refinerycms.git', :branch => '2-0-stable'
gem 'refinerycms'
# Specify additional Refinery CMS Extensions here (all optional):
gem 'refinerycms-i18n'
# gem 'refinerycms-blog', '~> 2.0.0'
# gem 'refinerycms-inquiries', '~> 2.0.0'
# gem 'refinerycms-search', '~> 2.0.0'
gem 'refinerycms-page-images'
gem 'refinerycms-announcements', :path => 'vendor/extensions'
gem 'refinerycms-publications', :path => 'vendor/extensions'
gem 'refinerycms-workers', :path => 'vendor/extensions'
```
And here the error message:
```
-----> Writing config/database.yml to read from DATABASE_URL
-----> Preparing app for Rails asset pipeline
Running: rake assets:precompile
rake aborted!
Please install the postgresql adapter: `gem install activerecord-postgresql-adapter` (pg is not part of the bundle. Add it to Gemfile.)
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/bundler-1.3.2/lib/bundler/rubygems_integration.rb:214:in `block in replace_gem'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.14/lib/active_record/connection_adapters/postgresql_adapter.rb:7:in `<top (required)>'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.14/lib/active_support/dependencies.rb:251:in `require'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.14/lib/active_support/dependencies.rb:251:in `block in require'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.14/lib/active_support/dependencies.rb:236:in `load_dependency'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.14/lib/active_support/dependencies.rb:251:in `require'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.14/lib/active_record/connection_adapters/abstract/connection_specification.rb:50:in `resolve_hash_connection'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.14/lib/active_record/connection_adapters/abstract/connection_specification.rb:41:in `resolve_string_connection'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.14/lib/active_record/connection_adapters/abstract/connection_specification.rb:27:in `spec'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.14/lib/active_record/connection_adapters/abstract/connection_specification.rb:130:in `establish_connection'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.14/lib/active_record/railtie.rb:88:in `block (2 levels) in <class:Railtie>'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.14/lib/active_support/lazy_load_hooks.rb:36:in `instance_eval'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.14/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.14/lib/active_support/lazy_load_hooks.rb:26:in `block in on_load'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.14/lib/active_support/lazy_load_hooks.rb:25:in `each'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.14/lib/active_support/lazy_load_hooks.rb:25:in `on_load'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.14/lib/active_record/railtie.rb:80:in `block in <class:Railtie>'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/railties-3.2.14/lib/rails/initializable.rb:30:in `instance_exec'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/railties-3.2.14/lib/rails/initializable.rb:30:in `run'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/railties-3.2.14/lib/rails/initializable.rb:55:in `block in run_initializers'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/railties-3.2.14/lib/rails/initializable.rb:54:in `each'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/railties-3.2.14/lib/rails/initializable.rb:54:in `run_initializers'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/railties-3.2.14/lib/rails/application.rb:136:in `initialize!'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/railties-3.2.14/lib/rails/railtie/configurable.rb:30:in `method_missing'
/tmp/build_37zyls4tcoz59/config/environment.rb:5:in `<top (required)>'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.14/lib/active_support/dependencies.rb:251:in `require'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.14/lib/active_support/dependencies.rb:251:in `block in require'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.14/lib/active_support/dependencies.rb:236:in `load_dependency'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.14/lib/active_support/dependencies.rb:251:in `require'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/railties-3.2.14/lib/rails/application.rb:103:in `require_environment!'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/railties-3.2.14/lib/rails/application.rb:305:in `block (2 levels) in initialize_tasks'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.14/lib/sprockets/assets.rake:93:in `block (2 levels) in <top (required)>'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.14/lib/sprockets/assets.rake:60:in `block (3 levels) in <top (required)>'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.14/lib/sprockets/assets.rake:23:in `invoke_or_reboot_rake_task'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.14/lib/sprockets/assets.rake:29:in `block (2 levels) in <top (required)>'
Tasks: TOP => environment
(See full trace by running task with --trace)
Precompiling assets failed, enabling runtime asset compilation
Injecting rails31_enable_runtime_asset_compilation
Please see this article for troubleshooting help:
http://devcenter.heroku.com/articles/rails31_heroku_cedar#troubleshooting
``` | 2013/08/16 | ['https://Stackoverflow.com/questions/18274428', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1458773/'] | according to the gemfile:
```
# Postgres support (added for Heroku)
#gem 'pg'
```
pg is commented-out. uncomment it to install it
```
gem 'pg'
```
In my gemfile for instance, I work in windows, and heroku doesn't. So I have
```
gem "pg", '~> 0.15.1', :group => :production
group :development, :test do
gem 'pg', "~> 0.15.1", :platform => [:mswin, :mingw]
```
since you must have some db installed, preferbly pg since it is heroku
also, as Gavin in the comments said - make sure you are in production, since it seems that heroku doesn't think o.. | The problem is that you have the pg gem in the production group. Therefore when assets are precompiled on Heroku (which uses the global group + assets group) then the PG gem cannot indeed be found because it's in the production group.
I would suggest having the pg gem in the global group and available to allow asset groups. |
18,274,428 | I'm tried to deploy a new version of my app to heroku. The deployment fails because heroku says, that the gem pg is not in my GEMFILE ... I have this postgres gem in my GEMFILE. I also looked for some answers, but no one worked ... As anyone an idea?
I use Ruby 2.0.0p247, Rails 3.2.14 refinery-cms 2.1.0
Here is my Gemfile:
```
source 'https://rubygems.org'
ruby '2.0.0'
gem 'rails'
gem 'newrelic_rpm'
group :production do
gem 'pg'
gem 'fog'
end
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails'
gem 'coffee-rails'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', :platforms => :ruby
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby'
# To use Jbuilder templates for JSON
gem 'jbuilder'
# Use unicorn as the app server
gem 'unicorn'
# Deploy with Capistrano
gem 'capistrano'
# To use debugger
gem 'debugger'
# The Heroku gem allows you to interface with Heroku's API
gem 'heroku'
# Fog allows you to use S3 assets (added for Heroku)
gem 'fog'
# Postgres support (added for Heroku)
#gem 'pg'
#Connecting to Amazon S3
gem 'aws-s3'
#gem 'taps'
# Refinery CMS
#gem 'refinerycms', '~> 2.0.0', :git => 'git://github.com/refinery/refinerycms.git', :branch => '2-0-stable'
gem 'refinerycms'
# Specify additional Refinery CMS Extensions here (all optional):
gem 'refinerycms-i18n'
# gem 'refinerycms-blog', '~> 2.0.0'
# gem 'refinerycms-inquiries', '~> 2.0.0'
# gem 'refinerycms-search', '~> 2.0.0'
gem 'refinerycms-page-images'
gem 'refinerycms-announcements', :path => 'vendor/extensions'
gem 'refinerycms-publications', :path => 'vendor/extensions'
gem 'refinerycms-workers', :path => 'vendor/extensions'
```
And here the error message:
```
-----> Writing config/database.yml to read from DATABASE_URL
-----> Preparing app for Rails asset pipeline
Running: rake assets:precompile
rake aborted!
Please install the postgresql adapter: `gem install activerecord-postgresql-adapter` (pg is not part of the bundle. Add it to Gemfile.)
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/bundler-1.3.2/lib/bundler/rubygems_integration.rb:214:in `block in replace_gem'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.14/lib/active_record/connection_adapters/postgresql_adapter.rb:7:in `<top (required)>'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.14/lib/active_support/dependencies.rb:251:in `require'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.14/lib/active_support/dependencies.rb:251:in `block in require'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.14/lib/active_support/dependencies.rb:236:in `load_dependency'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.14/lib/active_support/dependencies.rb:251:in `require'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.14/lib/active_record/connection_adapters/abstract/connection_specification.rb:50:in `resolve_hash_connection'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.14/lib/active_record/connection_adapters/abstract/connection_specification.rb:41:in `resolve_string_connection'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.14/lib/active_record/connection_adapters/abstract/connection_specification.rb:27:in `spec'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.14/lib/active_record/connection_adapters/abstract/connection_specification.rb:130:in `establish_connection'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.14/lib/active_record/railtie.rb:88:in `block (2 levels) in <class:Railtie>'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.14/lib/active_support/lazy_load_hooks.rb:36:in `instance_eval'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.14/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.14/lib/active_support/lazy_load_hooks.rb:26:in `block in on_load'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.14/lib/active_support/lazy_load_hooks.rb:25:in `each'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.14/lib/active_support/lazy_load_hooks.rb:25:in `on_load'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.14/lib/active_record/railtie.rb:80:in `block in <class:Railtie>'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/railties-3.2.14/lib/rails/initializable.rb:30:in `instance_exec'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/railties-3.2.14/lib/rails/initializable.rb:30:in `run'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/railties-3.2.14/lib/rails/initializable.rb:55:in `block in run_initializers'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/railties-3.2.14/lib/rails/initializable.rb:54:in `each'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/railties-3.2.14/lib/rails/initializable.rb:54:in `run_initializers'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/railties-3.2.14/lib/rails/application.rb:136:in `initialize!'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/railties-3.2.14/lib/rails/railtie/configurable.rb:30:in `method_missing'
/tmp/build_37zyls4tcoz59/config/environment.rb:5:in `<top (required)>'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.14/lib/active_support/dependencies.rb:251:in `require'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.14/lib/active_support/dependencies.rb:251:in `block in require'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.14/lib/active_support/dependencies.rb:236:in `load_dependency'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.14/lib/active_support/dependencies.rb:251:in `require'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/railties-3.2.14/lib/rails/application.rb:103:in `require_environment!'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/railties-3.2.14/lib/rails/application.rb:305:in `block (2 levels) in initialize_tasks'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.14/lib/sprockets/assets.rake:93:in `block (2 levels) in <top (required)>'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.14/lib/sprockets/assets.rake:60:in `block (3 levels) in <top (required)>'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.14/lib/sprockets/assets.rake:23:in `invoke_or_reboot_rake_task'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.14/lib/sprockets/assets.rake:29:in `block (2 levels) in <top (required)>'
Tasks: TOP => environment
(See full trace by running task with --trace)
Precompiling assets failed, enabling runtime asset compilation
Injecting rails31_enable_runtime_asset_compilation
Please see this article for troubleshooting help:
http://devcenter.heroku.com/articles/rails31_heroku_cedar#troubleshooting
``` | 2013/08/16 | ['https://Stackoverflow.com/questions/18274428', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1458773/'] | according to the gemfile:
```
# Postgres support (added for Heroku)
#gem 'pg'
```
pg is commented-out. uncomment it to install it
```
gem 'pg'
```
In my gemfile for instance, I work in windows, and heroku doesn't. So I have
```
gem "pg", '~> 0.15.1', :group => :production
group :development, :test do
gem 'pg', "~> 0.15.1", :platform => [:mswin, :mingw]
```
since you must have some db installed, preferbly pg since it is heroku
also, as Gavin in the comments said - make sure you are in production, since it seems that heroku doesn't think o.. | Oh no ... the solution was to delete my git repo and create a new one. I don't know why, but my repo got messed up (I added new files and so on ..) and so it didn't commit all data. After the tip of chucknelson I tried to lock a certain rails version and saw that heroku didn't get this. |
18,274,428 | I'm tried to deploy a new version of my app to heroku. The deployment fails because heroku says, that the gem pg is not in my GEMFILE ... I have this postgres gem in my GEMFILE. I also looked for some answers, but no one worked ... As anyone an idea?
I use Ruby 2.0.0p247, Rails 3.2.14 refinery-cms 2.1.0
Here is my Gemfile:
```
source 'https://rubygems.org'
ruby '2.0.0'
gem 'rails'
gem 'newrelic_rpm'
group :production do
gem 'pg'
gem 'fog'
end
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails'
gem 'coffee-rails'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', :platforms => :ruby
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby'
# To use Jbuilder templates for JSON
gem 'jbuilder'
# Use unicorn as the app server
gem 'unicorn'
# Deploy with Capistrano
gem 'capistrano'
# To use debugger
gem 'debugger'
# The Heroku gem allows you to interface with Heroku's API
gem 'heroku'
# Fog allows you to use S3 assets (added for Heroku)
gem 'fog'
# Postgres support (added for Heroku)
#gem 'pg'
#Connecting to Amazon S3
gem 'aws-s3'
#gem 'taps'
# Refinery CMS
#gem 'refinerycms', '~> 2.0.0', :git => 'git://github.com/refinery/refinerycms.git', :branch => '2-0-stable'
gem 'refinerycms'
# Specify additional Refinery CMS Extensions here (all optional):
gem 'refinerycms-i18n'
# gem 'refinerycms-blog', '~> 2.0.0'
# gem 'refinerycms-inquiries', '~> 2.0.0'
# gem 'refinerycms-search', '~> 2.0.0'
gem 'refinerycms-page-images'
gem 'refinerycms-announcements', :path => 'vendor/extensions'
gem 'refinerycms-publications', :path => 'vendor/extensions'
gem 'refinerycms-workers', :path => 'vendor/extensions'
```
And here the error message:
```
-----> Writing config/database.yml to read from DATABASE_URL
-----> Preparing app for Rails asset pipeline
Running: rake assets:precompile
rake aborted!
Please install the postgresql adapter: `gem install activerecord-postgresql-adapter` (pg is not part of the bundle. Add it to Gemfile.)
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/bundler-1.3.2/lib/bundler/rubygems_integration.rb:214:in `block in replace_gem'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.14/lib/active_record/connection_adapters/postgresql_adapter.rb:7:in `<top (required)>'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.14/lib/active_support/dependencies.rb:251:in `require'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.14/lib/active_support/dependencies.rb:251:in `block in require'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.14/lib/active_support/dependencies.rb:236:in `load_dependency'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.14/lib/active_support/dependencies.rb:251:in `require'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.14/lib/active_record/connection_adapters/abstract/connection_specification.rb:50:in `resolve_hash_connection'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.14/lib/active_record/connection_adapters/abstract/connection_specification.rb:41:in `resolve_string_connection'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.14/lib/active_record/connection_adapters/abstract/connection_specification.rb:27:in `spec'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.14/lib/active_record/connection_adapters/abstract/connection_specification.rb:130:in `establish_connection'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.14/lib/active_record/railtie.rb:88:in `block (2 levels) in <class:Railtie>'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.14/lib/active_support/lazy_load_hooks.rb:36:in `instance_eval'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.14/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.14/lib/active_support/lazy_load_hooks.rb:26:in `block in on_load'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.14/lib/active_support/lazy_load_hooks.rb:25:in `each'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.14/lib/active_support/lazy_load_hooks.rb:25:in `on_load'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.14/lib/active_record/railtie.rb:80:in `block in <class:Railtie>'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/railties-3.2.14/lib/rails/initializable.rb:30:in `instance_exec'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/railties-3.2.14/lib/rails/initializable.rb:30:in `run'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/railties-3.2.14/lib/rails/initializable.rb:55:in `block in run_initializers'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/railties-3.2.14/lib/rails/initializable.rb:54:in `each'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/railties-3.2.14/lib/rails/initializable.rb:54:in `run_initializers'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/railties-3.2.14/lib/rails/application.rb:136:in `initialize!'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/railties-3.2.14/lib/rails/railtie/configurable.rb:30:in `method_missing'
/tmp/build_37zyls4tcoz59/config/environment.rb:5:in `<top (required)>'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.14/lib/active_support/dependencies.rb:251:in `require'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.14/lib/active_support/dependencies.rb:251:in `block in require'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.14/lib/active_support/dependencies.rb:236:in `load_dependency'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.14/lib/active_support/dependencies.rb:251:in `require'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/railties-3.2.14/lib/rails/application.rb:103:in `require_environment!'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/railties-3.2.14/lib/rails/application.rb:305:in `block (2 levels) in initialize_tasks'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.14/lib/sprockets/assets.rake:93:in `block (2 levels) in <top (required)>'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.14/lib/sprockets/assets.rake:60:in `block (3 levels) in <top (required)>'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.14/lib/sprockets/assets.rake:23:in `invoke_or_reboot_rake_task'
/tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.14/lib/sprockets/assets.rake:29:in `block (2 levels) in <top (required)>'
Tasks: TOP => environment
(See full trace by running task with --trace)
Precompiling assets failed, enabling runtime asset compilation
Injecting rails31_enable_runtime_asset_compilation
Please see this article for troubleshooting help:
http://devcenter.heroku.com/articles/rails31_heroku_cedar#troubleshooting
``` | 2013/08/16 | ['https://Stackoverflow.com/questions/18274428', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1458773/'] | The problem is that you have the pg gem in the production group. Therefore when assets are precompiled on Heroku (which uses the global group + assets group) then the PG gem cannot indeed be found because it's in the production group.
I would suggest having the pg gem in the global group and available to allow asset groups. | Oh no ... the solution was to delete my git repo and create a new one. I don't know why, but my repo got messed up (I added new files and so on ..) and so it didn't commit all data. After the tip of chucknelson I tried to lock a certain rails version and saw that heroku didn't get this. |