INSTRUCTION
stringlengths 25
999
| RESPONSE
stringlengths 0
999
| SOURCE
stringlengths 16
38
| METADATA
dict |
---|---|---|---|
Prove or give a counter-example for the inequality
Prove or give a counter-example for the following:
$\frac{2}{\gamma}[\sqrt{(1+\gamma (n-1))(1+\gamma (s -1))}-(1+\gamma (s -1))] \leq n-s$
where $n,s$ natural numbers with $n \geq 2$, $0<s<n-1$ and $\gamma$ a real in (0,1).
|
If $f(\gamma)$ is your left side, $$ \frac{df}{d\gamma} = {\frac {-2-\gamma\,s+2\,\gamma-\gamma\,n+2\,\sqrt { \left( 1+\gamma\,n -\gamma \right) \left( 1+\gamma\,s-\gamma \right) }}{{\gamma}^{2} \sqrt { \left( 1+\gamma\,n-\gamma \right) \left( 1+\gamma\,s-\gamma \right) }}}$$ The limit of this as $\gamma \to 0+$ is $-(n-s)^2/4$, which is negative. If we set the numerator equal $0$, subtract the square root term from both sides, square and simplify we find $\gamma^2 (n-s)^2 = 0$. So $f'(\gamma) < 0$ on $(0,\infty)$, and in particular $f(\gamma) < \lim_{\gamma \to 0+} f(\gamma) = n-s$.
|
stackexchange-math
|
{
"answer_score": 1,
"question_score": -1,
"tags": "elementary number theory, inequality"
}
|
How to programmatically change one RecyclerView item style?
I've got this `RecyclerView`, it's showing a list of persons with their names, phones and birthday.
I want to change the color of the item if the person's birthday is today, but I want to know if I should do the verification and change on my `RecyclerView's` adapter inside the `OnBindViewHolder` method, or if I should do it inside my activity calling my `LinearLayoutManager` or calling the item using the `RecyclerView.getChildAt()` method.
Should I go whit the first option, using the `onBindViewHolder`?
|
**YES** . Should you choose to make changes in the `onBindViewHolder()`. We'll take a sample:
@Override
public void onBindViewHolder(FeedsViewHolder feedViewHolder, int i)
{
if(d1.feeds.get(i).getFeedContentType().equals("b-day")) // <-- Pointing to the List that contains value, and checks if it equals to a sample string
{
feedViewHolder.n1.setText("Birthday"); // <-- if it equals, party time :D , and sets text to the corresponding TextView in the RecyclerView
}
}
Hope it helps :)
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "android, listview, android recyclerview"
}
|
Is there a way to see when someone stops viewing your video using PHP or JavaScript?
If I were to have a video on a webpage, and have someone watch it but stop midway through, is there a way to see where they stopped? (i.e. 42 seconds into it.) Either using HTML5, PHP, JavaScript, or any combination thereof?
|
This is possible with HTML 5 and JavaScript. You need to register an event handler for the video's `pause` event, then read the `currentTime` playback attribute:
<video id="myVideo" width="320" height="240" controls="controls">
<source src="movie.mp4" type="video/mp4" />
Your browser does not support the video tag.
</video>
<script type="text/javascript">
document.getElementById("myVideo").addEventListener("pause", function() {
alert("Video paused at " + vid.currentTime);
});
</script>
`currentTime` will be the time at which the video was paused in seconds.
Of course, the `pause` event won't fire if they navigate away from the page before the video finishes.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "php, video, web analytics"
}
|
Export interface as Partial<OtherInterface>
I have an interface defined like below:
export interface Iface {
id: string;
foo: string;
}
I want to create an interface that's a partial of `Iface` and export it. I tried
export interface PartialIface = Partial<Iface>;
but typescript complains of a partial error. If I change the `interface` keyword to `type` it works. How come I have to declare it as a `type` alias and not an `interface`?
export type PartialIface = Partial<Iface>;
|
Please take a look:
export interface Iface {
id: string;
foo: string;
}
export type PartialFace=Partial<Iface>
Also You can copy paste your interface and make all properties optional:
export interface Iface {
id?: string;
foo?: string;
}
I'm not aware about other approaches
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 3,
"tags": "typescript"
}
|
Entity Framework AutoDetectChangesEnabled = false and .Find
Recently I've found about option AutoDetectChangesEnabled in EF, and in official documentation it is stated that manually handling AutoDetectChangesEnabled could cause "subtle bugs".
As I understand things could go wrong when saving changed entities to database, so my question is: is this piece of code safe (By default, the Entity Framework performs Detect Changes automatically when Find is called):
using (var context = new DbContext())
{
context.Configuration.AutoDetectChangesEnabled = false;
var user = context.users.Find(id);
context.Configuration.AutoDetectChangesEnabled = true;
return user;
}
So, as you can see, I'm not making any changes to my entities, just returning them, and if AutoDetectChangesEnabled is set to false will Find still hit Cache firstly and then database ?
|
Disabling `AutoDetectChangesEnabled` is not a problem, you are just disabling a feature. Entity Framework will not track changes in your entities and you'll have to flag them manually before `SaveChanges`.
Activating it and deactivating it the way you did makes no sense because your are creating a context in a using block. That means that after you use it, you are disposing it. So, you don't need to activate it again.
On the other hand, instead of deactivating change detection, you can use `AsNoTracking()` when you get objects from the database. That will speed up your queries but you still have the change detection feature available for other entities. It's something like this:
dbContext.Users.AsNoTracking().ToList();
|
stackexchange-stackoverflow
|
{
"answer_score": 8,
"question_score": 5,
"tags": "c#, entity framework"
}
|
Loosen or even eliminate vote-change lockdown window for Community Wiki posts
I understand the danger of tactical downvoting. It's clearly gaming the system. But what about Community Wiki posts (on Meta, at least)? Nobody is there to gain rep; there is no reason anyone would possibly want to tactically downvote anything.
After witnessing active Meta activity in Area 51 sites, where the environment of the entire newly-formed website can change and shift _drastically_ within the time span of even a few days, **very** important Community Wiki meta questions can see answers shift from extremely relevant and helpful to horribly irrelevant and even destructive to the progress of the developing community.
I'd perhaps like the ability to be able to change positions that I support over time, as the landscape of the issue changes drastically around me. And I really don't see any downside, honestly. If anyone has any, please point them out.
|
I would just like to point out: If it is community wiki, you can edit it (changing nothing) and change your vote.
|
stackexchange-meta
|
{
"answer_score": 1,
"question_score": 6,
"tags": "discussion, feature request, community wiki, meta"
}
|
Select other window in Emacs at startup
Suppose I have two text files `A.txt` and `B.txt`. I choose to open both from Emacs using
emacs -no-splash -mm A.txt B.txt
Now the frame is split in two parts vertically, and file A is shown in the left window and file B in the right window. However file B is automatically selected by Emacs. I can move the point to the other window by entering `C-x o` or `ESC-: (other-window 1)`. But I would like to do this automatically, for instance at the command line or in the `.emacs` file.
I tried
emacs -no-splash -mm --eval `(other-window 1)` A.txt B.txt
but it did not work..
|
The following seems to work: Enter in `.emacs` :
(add-hook 'emacs-startup-hook '(lambda () (other-window 1)))
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 1,
"tags": "emacs"
}
|
Differing scrambling parameter generation methods in Secure Remote Protocol
RFC 2945 (The SRP Authentication and Key Exchange System) states,
> The parameter u is a 32-bit unsigned integer which takes its value from the first 32 bits of the SHA1 hash of B, MSB first.
whereas the original publication describing SRP states that u is random.
What benefit is gained from using bits from a hash of B and restricting the size, rather than straight pseudorandom data?
|
The original article also states that: "For example, both sides can compute _u_ as a simple function of _B_ ", which is what occurs in RFC 2945. _u_ could be generated randomly and also transmitted, but deriving _u_ from _B_ (which is already transmitted) is harmless (security wise) and saves a few bytes (which is always good).
|
stackexchange-security
|
{
"answer_score": 4,
"question_score": 3,
"tags": "cryptography, key exchange"
}
|
Visual Studio 2010 - IDE command to find extension method namespace?
I make heavy use of + <.> to find the namespace of types and have VS.NET import those types into my class files. Similar to that, suppose I have a DateTime extension method called `ToWebsiteString()`. I'd like to be able to type `myDateTime.ToWebsiteString`, and then hit the equivalent of + <.> and have the IDE display a list of all available namespaces with that extension method, so that I can simply select the namespace and have VS.NET import it into the class file that I'm working in. Does that already exist?
If not, what is the most productive way you've found to import your extension method namespaces?
Edit: Are there any free solutions for this?
Edit: Other than the pay for Resharper, it doesn't appear that there are any free solutions for this, so I've closed this question.
Thanks
|
Resharper can do this for you.
Type `myDateTime.ToWebsiteString`, hit `Alt+Enter` and Resharper will show a list of namespaces to select from.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 3,
"tags": "visual studio 2010, ide, extension methods"
}
|
How to use Querystring with $location.path() in AngularJS
I want to redirect user to another page after successful login using query string. If I copy & paste to browser's address bar ` it works fine. But if I use
$location.path("/login?ref=/path/to/redirect");
url looks like
How can I decode %3F to '?' ? Thanks
|
It should be
$location.path('/login').search('ref', '/path/to/redirect')
|
stackexchange-stackoverflow
|
{
"answer_score": 46,
"question_score": 21,
"tags": "javascript, angularjs"
}
|
C# Coding Style - Fields
First of all, I don't want to start a coding styles war, so please only reply if you are answering the question.
I've encountered a couple of people who put their fields at the top of the class. Could anyone who does this explain the rationale behind it?
Many thanks
|
One rationale (at least before auto-properties came into existance) was to group all the state information at the top of the class because it goes a long way towards summarizing what the methods that follow will accomplish.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 2,
"tags": "c#, coding style"
}
|
How can select a particular field of table stored in SQL server
i am working on asp.net mvc3. i am using database designed in sql server. i have added my database in App_Data using Ado.connection.
This is my table:
!enter image description here
I want to access Code where ID=2
I am using this query:
ViewBag.pc = db.Product.Where(r => r.ID == p);
but this returns whole row. So what should i do to select particular column(here code). Please help me.
|
`var code = db.Product.Where(r => r.ID == 2).Single().Code` should work.
If there could be more than one row (or none), you can use `FirstOrDefault()`
var row = db.Product.Where(r => r.ID == 2).FirstOrDefault();
if(row != null)
{
var code = row.Code;
}
If there can only be one(or none), you can replace `FirstOrDefault()` with `SingleOrDefault()` above.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 1,
"tags": "asp.net mvc, linq to sql"
}
|
Why does it take more energy to go faster to the same place?
Edit: to people asking about details, I am not asking about drag. Take it to happen in vacuum, space, no drag, no other forces. I would like a general rule of thumb. This guy with e equals mv squared answered already.
This is NOT about relativistic speeds. To go from point A to point B, in theory (maybe) I could use a certain amount of energy. If I go twice as fast, I will use energy at a double rate but only for half the time. So integrating over time the energy expenditure would seem to be identical. Of course in the real world, it does not work like this. Cars consume far more oil per mile when they go faster. I can understand that certain aspects of engines might not react in a linear way to what is asked of them. However my question is more general. Is there a universal law of physics that makes it more costly to go faster to the same destination?
|
> If I go twice as fast, I will use energy at a double rate
This is not quite correct. First, in the absence of any external force, going at constant speed doesn't require any energy consumption. However, energy is needed to reach a certain speed even in the absence of external forces.
If you move with speed $v$, your (kinetic) energy is $E=\frac 12 mv^2$. However, if you move with speed $v'=2v$, your energy will be $$E'=\frac 12 mv'^2=\frac 12 m(2v)^2=2mv^2=4E.$$
These amounts of energy, $E$ and $E'$, need to be provided for reaching speeds $v$ and $v'$, respectively (assuming you start from rest). In other words, reaching twice the speed, requires four times the energy.
**Edit** : after reading the comments I've realized my answer was incomplete and made a mistake.
|
stackexchange-physics
|
{
"answer_score": 2,
"question_score": -2,
"tags": "energy, speed"
}
|
Are some emergent properties non-falsifiable by science?
Are some emergent properties non-falsifiable as a causal necessity by science? Since we cannot determine why emergent properties are what they are from physics and chemistry laws, I am guessing that we cannot determine what other alternatives there can exist or be in this world or another world. Is this correct? One example, is whether there can be silicon-based lifeform on other planets by just looking at the laws of physics and chemistry alone. The only way to falsify it would be to observe a silicon-based lifeform, but aside that from the "higher" sciences, it's not falsifiable.
|
If you clarify what you mean by 'every emergent property' your question will answer itself.
Clearly every observable emergent property is non-falsifiable because it exists.
So what remains are proposed or imaginary emergent properties that have never been observed. We can certainly rule some of those out from fundamental scientific considerations- to take an extreme example, we can rule out the possibility of aliens made only of protons. If you rule that out as a silly example, then you must clarify what you mean by 'every emergent property'. If you say to me that you didn't intend the phrase to include emergent properties that are clearly impossible, then what you seem to be asking is whether possible emergent properties are falsifiable, and the answer to that seems to be no by definition.
|
stackexchange-philosophy
|
{
"answer_score": 6,
"question_score": 3,
"tags": "philosophy of science, emergence"
}
|
Catch all routing with params
I want to make a simple application and one of the requirements is to capture everything after the URL. But these params will contain slashes/dots and what not. Like:
`localhost:3030/file1.html+css/test.css`
I basically want to put everything after `localhost:3000/` into the params and then deal with that individually. How do I do so? I've used `app.get('/:string')` but that doesn't work if there is a slash in the URL.
Thanks
|
Use `req.url`:
var express = require('express');
var app = module.exports = express();
var http = require('http');
http.createServer(app).listen(3000);
app.use(express.logger('dev'));
app.use(app.router);
app.all('*', function(req, res, next){
console.log('req.url');
console.log(req.url);
// from here you might want to use url.parse:
//
res.send(200)
});
//Output:
$ curl
req.url
/foo?bar=baz
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 1,
"tags": "express"
}
|
In Repository, a filter function returns dynamic vector or another Repository
I am currently learning the OOP paradigm in C++ (my program must have a class for an object - ex: TrenchCoat, Repository- list of trench coats, Controller and User Interface). I must make a method in the Repository class that returns the trench coats with a given size. I have 2 choices:
1) I return an STL vector with the wanted objects ex: std::vector filterBySize(int size);
2) In the method, I create another Repository and the wanted objects I add to this second Repository and return the Repository. ex: Repository filterBySize(int size);
I don't know which choice is right.
|
To me, there is not a correct answer, the better solution depends on what do you want to do after the filter operation.
Returning a Repository objects, it makes easier further and different operations (for example another filtering by color). In fact, supposing that another method `Repository filterbyColor(String color)` exists in the Repository class, it could be called directly from the previous filter operation, as below:
Repository filteredRepo=repo.filterBySize(40).filterByColor('yellow');
Instead, if you don't need to perform further operations, you can simply return a vector.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "c++, oop, repository"
}
|
How can I add values to a column that show the ranking by a random value?
I can't see what is going wrong here:
DECLARE @cData TABLE(cID NVARCHAR(1), cSeed DECIMAL(8,8), cRank INT)
INSERT INTO @cData (cID, cSeed) SELECT 'W', RAND()
INSERT INTO @cData (cID, cSeed) SELECT 'X', RAND()
INSERT INTO @cData (cID, cSeed) SELECT 'Y', RAND()
INSERT INTO @cData (cID, cSeed) SELECT 'Z', RAND()
SELECT cID, cSeed, (RANK() OVER (ORDER BY cSeed)) AS cRank FROM @cData
UPDATE @cData
SET cRank = (SELECT (RANK() OVER (ORDER BY cSeed)))
SELECT * FROM @cData
Why am I getting different results from my first select statement than I am from my second--why didn't my update statement put the same data into the table that my first select statement displayed?
 OVER (ORDER BY cSeed))
>
This is a statement on its own, correlated by a column used only in `OVER / ORDER BY` clause.
It operates over an implied rowset of exactly one record (the current record from @cData) and hence always returns 1, as the rank of the only record in a set is 1 by definition.
I believe you want to run this instead:
WITH t AS
(
SELECT *,
RANK() OVER (ORDER BY cSeed) rnk
FROM @cData
)
UPDATE t
SET cRank = rnk
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 2,
"tags": "tsql"
}
|
Missing Eid prayer
Here is U.K. I have a brother who has exam on the same date it’s eid and the timing clash. They are one of final exams. What can one do? If missing eid namaz will his Ramadan be accepted as school won’t let him be late as it’s final exam.
|
Eid prayer is an optional prayer he may do it or leave it.
Note that he even can pray it later (alone) as qada'. I've read that some scholars accept it even one day later others say it must be performed before noon of the Eid day.
Praying Eid or leaving it has no impact on the validity of fast or the acceptance of it. What is necessary to complete the fast is to pay the zakat al-fitr or sadqah of fitr. This a mandatory act on each Muslim, each Muslim must pay it for each person he is in charge of unless he can't afford to survive that day if paying it. And it must be paid or at least leave his hands before the Imam starts the prayer! One could pay it during Ramadan however delaying it until the night before the Eid is the most recommended.
|
stackexchange-islam
|
{
"answer_score": 3,
"question_score": 0,
"tags": "salat, eid"
}
|
Slang usage of das Glück
Is the word _das Glück_ ever used in German to describe the euphoric state arising from the consumption of mind-altering substances?
Why do I need to know? In Russian, there is a slang word _глюк_ , which sounds similar to _Glück_ and means "a hallucination". Some say it has a German origin; I'm wondering if there may be any truth to that.
|
I have never heard of "Glück" being used in that sense. However, it is used with a similar meaning in compound words:
"Glücksgefühl" is used to describe an euphoric feeling in general. The word "Glückspillen" colloquially means antidepressants like Prozac (Fluctin in Germany). "Glückshormone" are serotonine and dopamine.
By the way, "Glückspilz" is something entirely different and has nothing to do with hallucinogenic mushrooms. Also, a "Glückskeks" is just a Chinese fortune cookie.
|
stackexchange-german
|
{
"answer_score": 7,
"question_score": 3,
"tags": "meaning, slang"
}
|
Recurring non-scheduled transactions in GnuCash
Does GnuCash have a similar mechanism to MYOB where a transaction can be made into a template for posting when needed?
I can see a transaction can be made into a template for automated scheduled posting, but can't see how to "post now".
I've just been duplicating a previous instance of the desired transaction and changing the date, but sometimes a previous instance of the desired transaction isn't that quick to find.
|
As described in a comment to my question, typing in the same transaction description as previous has been the only way I've seen to duplicate a previous transaction.
The issue with this of course is finding what the previous transaction was called, but the autocompletion helps somewhat.
|
stackexchange-money
|
{
"answer_score": 3,
"question_score": 6,
"tags": "gnucash"
}
|
The functionality of isinstance(...); but without an instance?
At runtime, I want to check whether a specified child class is derived from a specified parent class.
With an object instance, it's easy:
def is_related(child_instance, parent_type):
return isinstance(child_instance, parent_type)
Is there some way to do this without having (or creating) an instance of the child but, instead, having a reference to the child's type?
Something like...
def is_related(child_type, parent_type):
return is_child_class(child_type, parent_type)
Provide an implementation for `is_child_class` will answer this question.
(By comparison, types in C# know about their supertypes. I don't know whether this is also true in Python.)
|
Let's say that `ChildClass` is a subclass of `ParentClass`. Then
issubclass(ChildClass, ParentClass)
would return `True`
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 1,
"tags": "python, python 3.x, inheritance, types"
}
|
Why do we need mocking frameworks?
I have worked with code which had NUnit test written. But, I have never worked with mocking frameworks. What are they? I understand dependency injection and how it helps to improve the testability. I mean all dependencies can be mocked while unit testing. But, then why do we need mocking frameworks? Can't we simply create mock objects and provide dependencies. Am I missing something here? Thanks.
|
* It makes mocking easier
* They usually allow you to express testable assertions that refer to the interaction between objects.
Here you have an example:
var extension = MockRepository
.GenerateMock<IContextExtension<StandardContext>>();
var ctx = new StandardContext();
ctx.AddExtension(extension);
extension.AssertWasCalled(
e=>e.Attach(null),
o=>o.Constraints(Is.Equal(ctx)));
You can see that I explicitly test that the Attach method of the IContextExtension was called and that the input parameter was said context object. It would make my test fail if that did not happen.
|
stackexchange-stackoverflow
|
{
"answer_score": 12,
"question_score": 17,
"tags": "c#, .net, nunit, mocking, moq"
}
|
How to import Android contacts to Windows Phone 7.8 via VCF file?
I exported all of my contacts from my Android device to a VCF file but I don't see how I can import this on my Windows Phone 7.8 device.
The file is 251KB but appears empty in notepad and GMail doesn't accept the file. Is there a place where I can import this on my phone to transfer all of my contacts?
|
It appears that the vcf file is damaged.There was an error in the export.All of my contacts are lost! Advice : Check your export before it is late ...
|
stackexchange-windowsphone
|
{
"answer_score": 0,
"question_score": 0,
"tags": "contacts, 7.8"
}
|
Using extension variables for plugin versions in gradle
I'm trying to use extension variables with Gradle to configure the versions of the plugins but it is not possible to use `apply from: versions.gradle` before the `plugins` block in gradle.
Is this possible to do?
Example of what I would like to do.
`versions.gradle`:
ext.libraries = [
plugins: [
coveralls: 'com.github.kt3k.coveralls'
]
]
build.gradle
buildscript {
repositories{}
dependencies{}
}
plugins {
id libraries.plugins.coveralls versions 'versionhere'
}
|
You can't do it.
Applying a plugin with the `plugins` DSL has to be declared **as the first statement** in a Gradle build script. This behavior is mandatory.
You can check the official guide:
> The plugins {} block must also be a top level statement in the buildscript. It cannot be nested inside another construct (e.g. an if-statement or for-loop)
>
> This requires that plugins be specified in a way that Gradle can easily and quickly extract, before executing the rest of the build script.
|
stackexchange-stackoverflow
|
{
"answer_score": 4,
"question_score": 1,
"tags": "gradle, plugins"
}
|
Possible to play 2x2 with 1 core set and data pack in Netrunner?
I have just purchased the Android Netrunner Core Set, played a few games, and am now excited to play more.
The problem is that our usual gaming group consists of 4 people, and to my knowledge the Core Set only allows you to build up to 2 playable decks (1 corp, 1 runner) for play at the same time, because of the number of neutral cards.
I would like to know what would be the most economical way to extend the Core Set with enough cards to build 2 enjoyable Runner and Corp decks for play at the same time without actually shelling out another 40$ for a second core set?
|
Most data packs won't meet this requirement on their own (for the exception, see this answer on this question). From the rulebook, page 7:
> To make a starter deck, take all the cards of a single Corporate or Runner faction and shuffle in all of the neutral cards for the chosen side.
That's 22 neutral cards on the corp side, and 15 for the runners. On average let's assume you can make up 5 of them by pulling in other-color cards, you still need a few more cards. A data pack is going to have maybe 3 neutral cards and 6 of each color typically, so by the time you have 2 data packs you could probably technically pull off 2 separate simultaneous games, as long as nobody is playing the same faction. However, this will limit what you can do in terms of deckbuilding - both runners fighting over Sure Gamble, for example. That will become less and less annoying as the number of data packs you own goes up, but won't likely stop being a topic of conversation. :)
|
stackexchange-boardgames
|
{
"answer_score": 3,
"question_score": 3,
"tags": "android netrunner"
}
|
Exibir média salarial por anos de serviço
Tenho a tabela FUNCIONARIO que tem como colunas matricula, nome, anoServico, salario.
Gostaria de exibir a média salarial por anoServico.
Como fazer?
Obrigada!
|
Santana,
Em SQL existe a função AVG, que retorna a média de valores.
Você pode utilizar a função AVG no campo salario e agrupar pelo anoServico, seria mais ou menos da seguinte forma:
SELECT AVG(salario) media_salaria, anoServico
FROM FUNCIONARIO
GROUP BY anoServico
<
|
stackexchange-pt_stackoverflow
|
{
"answer_score": 2,
"question_score": -1,
"tags": "sql"
}
|
What are the Y_TFT, C_TFT and BL_EN pins used for?
The display controller board for Philips PET 714 has a 16 pin connector like this:
;
}
and the output should be:
.myClass {
color: var(--color-primary-light);
}
my RegEx to capture the values is : `@include themify\("(.*)", "(.*)"\);`
you can try it right here: <
however, webstorm does not seem to recognize it in find / replace. RegEx checkbox is enabled.
|
In your example you provide this code:
.myClass {
@include themify('color', 'color-primary-light');
}
Which will be matched by
@include themify\('(.*)', '(.*)'\);
In < you provide this code:
@include themify("color", "color-primary-light");
which will be matched by
@include themify\("(.*)", "(.*)"\);
Maybe you are looking for the regex with single quotes in you webstorm?
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": -1,
"tags": "regex, sass"
}
|
"our own developed" or "own developed"
I am not sure if I should use our We use a combination of our own developed and existing programs.
> We use a combination of our own developed and existing programs.
OR
> We use a combination of own developed and existing programs.
|
The short answer is that you can't say **of own**. If you want to use **own** , you have to say **our own**.
But your sentence is ambiguous.
Does the adjective **own** modify just the **developed programs** or the whole phrase **developed and existing programs**? If you had developed some programs and had acquired other programs, it could easily modify both.
Other ways of phrasing the sentence to avoid this ambiguity might be:
> We use a combination of existing programs and those developed in-house
or, if you wanted to emphasise that all the programs belonged to you:
> We use a combination of proprietary existing programs and those developed in-house.
or
> We use a combination of (proprietary) existing programs and those developed by us/ourselves
|
stackexchange-ell
|
{
"answer_score": 1,
"question_score": 0,
"tags": "sentence construction, sentence meaning, sentence structure"
}
|
PANDAS reading dataframe from file properly
my file(text file) looks like:
-1 1 2.99988E-02-4.93580E-17 4.28928E-17-2.01725E-16 4.57184E-18 1.54030E-16
-1 2 2.99988E-02-4.93581E-17-3.85396E-17-2.02655E-16-4.41397E-17-2.23963E-16
-1 3 2.99988E-02 2.47173E-17 4.28930E-17 1.60350E-16 5.28503E-17 1.53007E-16
...
i want to create a dataframe with header and index, so that it looks like:
0 1 2 3 4 5 6
0 1 2.99988E-02-4.62001E-17 3.51002E-17-1.90612E-16 1.52704E-17 1.41065E-16
1 2 2.99988E-02-4.62001E-17-2.81042E-17-1.88765E-16-3.45762E-17-2.06278E-16
...
i tried this but it didnt work out:
df = pd.read_table(file_dir, delim_whitespace=True, header=None)
and
df = pd.read_table(file_dir, sep='s+', header=None)
|
This is not a delimited file, but a fixed widths one. It used to be a common format in the 80' when we used the Fortran IV language...
But it is still supported by pandas with the `read_fwf` function:
df = pd.read_fwf(file_dir, header=None, widths=(3,10) + 6 * (12,))
It should directly give:
0 1 2 ... 5 6 7
0 -1.0 1.0 0.029999 ... -2.017250e-16 4.571840e-18 1.540300e-16
1 -1.0 2.0 0.029999 ... -2.026550e-16 -4.413970e-17 -2.239630e-16
2 -1.0 3.0 0.029999 ... 1.603500e-16 5.285030e-17 1.530070e-16
...
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "python, pandas"
}
|
jQuery Causing Invisible Bullets in IE8 Radio Buttons
I've created a simple quiz that i'm using in Plone (that's why I use 'jQuery' instead of '$') and for some reason my javascript code for calculating the score on the fly causes the radio buttons to appear incorrectly in IE 8. By appear incorrectly I mean that after clicking the button the value is calculated correctly, but the bullet doesn't appear to show that the button has been clicked. I'm having a heck of a time trying to correct this. It works perfectly in all other browsers. This is a fiddle with my simple quiz code. In IE8 the radio buttons don't work as expected when the jquery is loaded, but if you comment out all of the javascript the radio buttons work fine.
Any Help would be greatly appreciated.
|
jQuery('input').change(function() {
// ... [snip] ...
return false;
});
Why are you returning `false`? This usually tells the browser to "cancel" the default behaviour of the event. If anything, I'm surprised that Firefox _doesn't_ exhibit this behaviour.
Remove `return false`; unless I'm missing something, your application logic doesn't need it at all.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "javascript, jquery, internet explorer 8"
}
|
Running exe from commandline with parameter using c++
I am pretty new to this programming field and am stuck at a place. This is wat i wanna do
I want to run an .exe from command line with parameters in Windows 7 through c++ and get the output produced by the command into the program.
the problem I am having is with changing the current directory of command prompt to the path of the exe and getting the output from the executed command into the program..
hope some one has ran into something such previously.. Thank you.
|
You can use System function or ShellExecute function for running exe from command line with parameters using Cpp. You can read about System function **here** and ShellExecute function **here**. As far as getting the output is concerned you can redirect the output to a file and read the file, or create pipes and redirect the output to pipe. You can provide the exe name along with the path so cd to directory wont be necessary, but I am not sure if its mandatory for you to run the exe from inside the same directory.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": -1,
"tags": "visual c++, command line arguments"
}
|
cone of a $C^*$-algebra
Let $A$ be a $ C^*$-algebra.The cone of $A$ is defined to be $CA:=\\{f\in C([0,1]):f(0)=0\\}$,the suspension of $A$ is defined to be $SA:=\\{f\in C([0,1]): f(0)=f(1)=0\\}$,then $0\longrightarrow SA\overset{\iota}{\longrightarrow} CA\overset{\psi}{\longrightarrow} A\longrightarrow 0.$ is an exact sequence.
My question is: why the map$CA\overset{\psi}{\longrightarrow} A$ is surjective? For any $a\in A$,how to show that there must exist a map $f\in CA$ such that $f(1)=a$?
|
Simply take the mapping given by $f(t) = ta$.
|
stackexchange-math
|
{
"answer_score": 2,
"question_score": 0,
"tags": "operator theory, operator algebras, c star algebras, k theory"
}
|
Scala: Read a text file and filter on list of values
I want to read in a text file and filter lines that contain only certain values in a particular column. So "if line 1, column 2 contains "Bob" or "Tom" or "Fred", then return that line. The result would only contain lines where the second element of each line is either Bob, Tom, or Fred.
It thought this would work:
val trans = io.Source.fromFile(inputFile).getLines.map(x => x.split("\11")).filter(line =>("Bob", "Tom", "Fred").contains.line(2)).toArray
but after looking at it, it doesn't really make sense that it would work (and it doesn;t). I can do it with a single value like this:
val trans = io.Source.fromFile(inputFile).getLines.map(x => x.split("\11")).filter(line =>line(2) contains "Bob").toArray
but can't figure how do multiple values.
Any help is appreciated.
|
You want to check whether one column of a line—a _single string_ —is contained in _a sequence_ of strings:
val names = Seq("Bob", "Tom", "Fred")
Then your `filter` call becomes
...filter(line => names.contains(line(2)))
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 2,
"tags": "scala, filter, text files"
}
|
how to inject javascript without using script tags?
I cant use the script tags It alerts when I do , which is only useful for testing. It filters them out:
script > *
SCRIPT > SCRIPT
sCriPt > sCriPt
so, i try to use capital script tags but it turns to:
*CRIPT>alert(1)</SCRIPT>
I have tried using multiple tags.
How can I inject regular javascript with this? Oh, and I cant use quotes.
|
Just so you know, there is an XSS Cheat Sheet you can refer to.
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 5,
"tags": "javascript, xss"
}
|
Show a color gradient in a SAS graph
I would like to draw a box using SAS/GRAPH with a color gradient (say going from red to green). I've found references online to a macro called `%colorscale` that apparently helps with this, but can't find the code itself. Is there a way to do this?
For example, the following draws a green box. But how can I make the color blend from one color to another?
data box;
length function style color $ 8 text $ 15;
xsys="3"; ysys="3";
color="green";
function="move"; x=10; y=65; output;
function="bar"; x=30; y=95; style="solid"; output;
run;
proc ganno annotate=box;
run;
quit;
|
I've used this with good results before:
<
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "graph, sas"
}
|
Lost access to Desktop Help of ArcMap 10.5?
Today I found that I can't aceess help on system tools through " **Tool Help** " button. It opens help window which says:
> Can’t reach this page
>
> * Make sure the web address //ieframe.dll/dnserrordiagoff.htm# is correct
> * Search for this site on Bing
> * Refresh the page
>

I want to delete every day folder with "Yesterday name" LIKE "2014-12-14"
Here is my ubuntu /var/log/syslog when I execute "grep CRON" command
> Dec 16 00:01:01 {SERVERNAME} CRON[21031]: (root) CMD (rm -R /path/to/my/folder/$(date +') Dec 16 00:01:01 {SERVERNAME} CRON[21030]: (CRON) info (No MTA installed, discarding output)
|
The manpage (`man 5 crontab`) says:
> The entire command portion of the line, up to a newline or % character, will be executed by /bin/sh or by the shell specified in the SHELL variable of the crontab file. Percent-signs (%) in the command, unless escaped with backslash (), will be changed into newline characters, and all data after the first % will be sent to the command as standard input.
So you have to replace every `%` in your date format with `\%`:
1 0 * * * rm -R /path/to/my/folder/$(date +'\%Y-\%m-\%d' -d "yesterday")
|
stackexchange-askubuntu
|
{
"answer_score": 2,
"question_score": 2,
"tags": "14.04, server, cron"
}
|
apachebench aborts with a strange error message
I run a very simple php file on apache. Then I benchmark apache, using
ab -n 10000 -c 5
But I get this error message, depending on c (for c=1, things are fine):
apr_socket_connect(): Operation already in progress (37)
I'm using ApacheBench, Version 2.3 on OSX 10.5.7.
The very simple PHP file would be this one:
<h1>Hello <?=$_REQUEST['name']?></h1>
|
This might be connected with <
This might be it. The post says:
> fixed in trunk
>
> Changes were significant, so I have no plans to propose for backport to the 2.2.x branch in the short term. With some testing/everyday use in trunk on various platforms, it may be appropriate to backport later.
Well. That means I would have to wait for 2.3 or work straight with the trunk. I'm just doing hobby stuff, so: no thanks.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 3,
"tags": "apache, apache2, benchmarking"
}
|
PerfTrack to measure system responsiveness to user actions in Windows
Is Perftrack mentioned here just used internally at Microsoft ? Are they any similar benchmark programs ?
|
Short answer yes. It is a dll that runs in the background and to be used by Microsoft. Maybe at some point benchmark software will be able to utilise this DLL but right now you only have you bog standard bench mark programs
|
stackexchange-superuser
|
{
"answer_score": 1,
"question_score": 2,
"tags": "windows 7, benchmarking"
}
|
C# Write text to another program, from the background
Hello I am doing a program that will notice when a specific key is pressed and write an specific letter where the person is writing. I had thought of doing it in a Console app or should i do it in an Windows Forms? I don't either now how to get it to work in the background or how to to write it out where the user do write?
the code i have done until now looks like:
static void Main(string[] args)
{
while (true)
{
ConsoleKeyInfo cki;
cki = Console.ReadKey();
Console.WriteLine(cki.Key.ToString());
if (cki.Key.ToString() == "F" && (cki.Modifiers & ConsoleModifiers.Control) != 0)
{
//typ something where the person is writing
}
}
}
thanks for all help
|
If you add a reference to `System.Windows.Forms` then you can do this:
//outside namespace:
using TSendKeys = System.Windows.Forms.SendKeys;
//To type a key:
TSendKeys.Send("Put whatever you want here");
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 1,
"tags": "c#, background"
}
|
What should i chose to save my data? Eclipse, android programming
I am new to programming in Eclipse and I want to make a note application in android, where i can click on a button to make a new edit text and then i want to save that edit text by pushing save. What is the best way to save this data? Is it by using Shared Preference or with File Output Stream? What is easiest. And also, how can I program the button to make new edit texts which can be saved afterwards?
One last question, if i want these notes to automatically get the date, so i can recall all the notes for a month how do i do that? what types of method should i use?
I hope you will help me, thanks..
|
This question is like a "Chinese Box", composed by more hidden questions... without code, of course!
BTW: use **SQLite** , IMHO is the better one for what you want. In your main activity, add a "New note" button, wich let you create a new note. In your "SaveNote" method, add also some code wich take the time when you created the note.
Start with this official tutorial.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "java, android, eclipse, fileoutputstream"
}
|
Spectral Methods in time
I was reading up on Spectral Methods for PDEs. In all the descriptions I read, while the position component is approximated via a Fourier series or other methods, the time component is still discretized and solved via a time-step procedure (finite difference, etc.).
Is there any reason why the time component is also not approximated via a closed form solution?
Edit: I found one paper which does use a polynomial approximation even for the time dimension but my question remains as to why it's not done in general. Is it because chaotic dynamics means the number of terms required for the representation will be too large?
|
The reason is that with the exception of linear problems, if you do a Fourier (or other) decomposition in time, you end up with a significant number of problems that are coupled globally in time. In other words, you have to solve lots of problems on the entire time interval concurrently. That will typically bust your computational or memory budget. The beauty of time stepping schemes is that you only need to consider one (or a very small number) if time steps at the same time and can forget everything about the more recent past.
|
stackexchange-scicomp
|
{
"answer_score": 10,
"question_score": 7,
"tags": "pde, discretization, time integration, spectral method, collocation"
}
|
How to extract the version from the name of a NuGet package file using PowerShell?
I have a file that contains the name of the nuget package like `rmp2.<version>.nupkg`. I want to take the `<version>` part alone. I have tried many things. One such snippet is below:
Get-Content version.txt | ForEach-Object { $_.split("nupkg")[1]} | cut -f 2,3 -d 2
It is not working.
|
if it is not working because of the dot at the end of version, try this:
$version = Get-Content version.txt | ForEach-Object { $_.split("nupkg")[1]}
$version.Substring(0,$version.Length-1)
or try using -split instead of .split
(((Get-Content version.txt) -split('.nupkg')) -split('rmp2.'))[1]
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "windows, powershell, nuget"
}
|
How to show a running total in a DevExpress PivotGrid?
I need to show totals like the total plus the last total in a DevExpress PivotGrid.
Example:
Taking this values: March: 25
April: 10
May: 30
Resulting in this:
March April May
25 35 65
How do I configure my PivotGrid to this?
Thanks in advance.
|
You should set the Field's RunningTotal property to true.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "delphi, grid, devexpress"
}
|
Google Cloud SQL: Can I change machine type with zero downtime on my database clients?
I want to update the machine type of my Google Cloud instance, but this takes several minutes to update (second generation instance). The instance will be unavailable until the instance has restarted. Because of this downtime, we have to update the machine type at night time, so our visitors are the least troubled by this update.
Is there a workflow how we can minimise this downtime to zero or maybe a few seconds? I already thought about possible solutions like adding a temporary failover or maybe make use of read replica.
|
I contacted the support of Google Cloud about this question and they told me that Cloud SQL isn't build to perform this change without downtime. If I want to be able to make these changes, I should look at Cloud Spanner which is a horizontal scalable SQL solution provided by Google.
|
stackexchange-devops
|
{
"answer_score": 2,
"question_score": 1,
"tags": "google cloud platform"
}
|
AssertEquals dosen't work
I have a problem with AssertEquals in JUnit because i try to compare two istance of objects , i get this error :
java.lang.AssertionError: expected: com.euris.Price<Price [1p 19s 2d -2a]> but was: com.euris.Price<Price [1p 19s 2d -2a]>
at org.junit.Assert.fail(Assert.java:88)
at org.junit.Assert.failNotEquals(Assert.java:834)
at org.junit.Assert.assertEquals(Assert.java:118)
at org.junit.Assert.assertEquals(Assert.java:144)
at com.euris.exercise.ExerciseApplicationTests.contextLoads(ExerciseApplicationTests.java:31)
mework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190)
Can anyone help me ?
|
I think the problem here is Price is a custom Object you have to override equals method for AssertEquals to work . I hope this link helps.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "java, junit"
}
|
SQL sales report by calendar week
I've been Googling for a few hours... thought this would be easy, but clearly not for me :)
I've got sales data in two tables and I want to generate a weekly sales report for a specific item. For this purpose, I don't care about dollar values, just number of units. An a "week" is either a calendar week (whatever start day, I don't care) or just 7-day chunks back from current (so week 1 is the last 7 days, week 2 is 8 - 15 days ago, etc) - whichever is easier. I'm simply trying to monitor sales trends over time. Preferably it would span back over years so that if its the first week of January, for example, it wouldn't show just one record.
The data comes from ZenCart. The relevant tables/column structure is here:
Table "orders" has columns: orders_id, date_purchased
Table "orders_products" has columns: orders_id, products_id, product_quantity
Where I'm having trouble is with the joins and syntax.
|
This worked for my needs:
SELECT o.date_purchased, CONCAT(YEAR(o.date_purchased), LPAD(WEEK(o.date_purchased), 2, '0')) as weekyear, op.products_id, SUM( op.products_quantity )
FROM orders_products op
LEFT JOIN orders o ON op.orders_id = o.orders_id
WHERE op.products_id = 331
GROUP BY weekyear
ORDER BY weekyear
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 1,
"tags": "mysql, sql, zen cart"
}
|
Which condition is true? and why? in JavaScript
**Which condition is true?**
1 == false
1 === false
'1' == false
none of the above?
|
JavaScript will automatically convert the Boolean into an integer and then attempt to compare the two sides.
For real equality, use the === operator.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": -3,
"tags": "javascript"
}
|
Declare string constants for date formats instead of explicitly having to write string values
Is it advisable / good programming practice to store date formats as string constants which can then be used throughout a web application?
For instance, instead of writing `.ToString("dd.MM.yyyy")` in code-behind, one would use `.ToString(MyDateClass.DateFormat1)`. If `.ToString("yyyy.MM.dd")` is used elsewhere, we would create MyDateClass.DateFormat2 and use `.ToString(MyDateClass.DateFormat2)`.
For JS code one could for instance have global string variables for `"dd.MM.yyyy"` and `"yyyy.MM.dd"` and these will be used instead.
|
It's standard practice and should be extended to other "magic strings" that are used in your application, such as regular expressions. I tend to use constant files in my projects where I can group together logically related constants and refer to them in other classes and projects.
If a constant is used widely the scope of the constants file should reflect that - if the scope is more narrow, consider using a more localised file, or in some cases just put the constants in the class file itself, if the use of it is limited to that class.
I would also advise that the names you use reflect the meaning, e.g., instead of DateFormat1 and DateFormat2 use something like DateFormatDDMMYYYY and DateFormatYYYYMMDD.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 1,
"tags": "java, c#, date, datetime, design patterns"
}
|
Android: box shadow and border radius layout
I want `box shadow` and `radius` like below image, but in android `box shadow` not work

I have a layer with rule based labelling enabled. There are two label styles: a base style for all labels (no filter) and a highlight style which is intended to apply to features with a particular attribute value only ("Class" = 'Review').
Sometimes it works, sometimes it doesn't. Each time the map canvas is refreshed each feature with the 'Review' value randomly chooses either the base label style or the intended highlight label style.
Have I failed to set this up properly or is this a bug?
* * *
` under the Rule for the Base label, it is better to use ELSE. Without providing an ELSE statement,the labels will be assigned random styles as you have noticed already. But with `ELSE` as a rule you are restricting other labels to use a common specific style that you have defined to them.
|
stackexchange-gis
|
{
"answer_score": 1,
"question_score": 0,
"tags": "qgis, labeling, rule"
}
|
Log4Net Dynamic logging folder path by exception
How can I configure logging folder path by specified exception using log4net ?
I wanna specify logging folder at exception level, not at Appender level. Something like that : "_log.Error(exception, {LogFolder});"
|
It won't be really doable unless you write a custom appender for it. This appender could work on context variables to retrieve the desired folder: in this case you would need to use an event context
Another way would be to create as many appenders as needed for exceptions you're interested in and filter each appender by an exception. For that you would need to create a custom filter based on a `FilterSkeleton`
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 2,
"tags": "c#, log4net"
}
|
Can I get an outlet from this section of the open wall?
There is a hole in one of the cabinets of the vanity, and I'd like to see if I can get an outlet installed through here. As a newbie who's never done electrical work, is it safe, and possible?
 in my .emacs.el in Ubuntu?
I tried following the advice gathered from Google searches but I am not able to get it to work. My `~/.emacs.el` file contains the following:
;; Set color scheme
(require 'color-theme)
(load-file "/home/manoj/Dropbox/conf/themes/color-theme-chocolate-rain.el")
(color-theme-chocolate-rain)
;; Set font
;; (set-default-font "-unknown-Inconsolata-normal-normal-normal-*-12-*-*-*-m-0-iso10646-1")
;; Insert four spaces on tab
(setq-default indent-tabs-mode nil)
(setq-default tab-width 4)
(setq indent-line-function 'insert-tab)
I've commented out the font configuration line as it doesn't work. I'm using **GNU Emacs 23.1.50.1** (i486-pc-linux-gnu, GTK+ Version 2.18.0) of 2009-09-27 on palmer, modified by Debian on Ubuntu Karmic.
|
Judging from the emacs version, it appears you've installed `emacs-snapshot` (good).
So this should work:
sudo apt-get install ttf-inconsolata
Then put in your ~/.emacs file something like
(set-frame-font "Inconsolata-12")
(The 12 refers to the font size, and can be changed.)
|
stackexchange-stackoverflow
|
{
"answer_score": 26,
"question_score": 14,
"tags": "emacs, fonts, customization"
}
|
Elasticsearch search analyzer
I am playing with indexing an articlenumber in Elasticsearch.
Here i provide a working example: <
i dont understand why i get a different score if i change the value for "product_number.search"
if i change the value from "ak454" to "ak 454" the score changes.
i thought that if i am using a search_analyzer the value "ak 454" will be transformed to "ak454" (its mapped using the searchable_id).
you can also look at the analyses tab to see my tokenizer: <
thanks.
|
The `term`-query (and filter) does not do any text analysis.
The `match`-query does, and can achieve what you want.
I adapted the example: <
Setting `explain` to `true` is very useful when working with problems like this, as you see exactly what Lucene is doing when it's scoring.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 3,
"tags": "lucene, elasticsearch, tokenize, analyzer"
}
|
Retrieve acolumn name from in underlying dataset (Before it got renamed in Power BI)
I'm trying to build a dynamic data dictionary for my Power BI data set. To do that, I am querying the DMVs in DAX studio to get the objects names and descriptions from the model directly.
Used query for the columns details:
SELECT * from $SYSTEM.TMSCHEMA_COLUMNS
However, when I run this query, I'm getting ExplicitName = SourceColumn. I had assumed that the SoruceColumn would contain the column name before any transformation in PowerQuery. Does anyone have any idea on how to get the original column name (the name of the column in the SQL Server DB per example)?
|
I have found a solution for this. You can find the technical column names in:
select * from $SYSTEM.DISCOVER_STORAGE_TABLE_COLUMNS where [COLUMN_TYPE] = 'BASIC_DATA'
If building this type of dynamic data dictionary interests anyone, do let me know. I can share the end result when I'm done.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "powerbi, daxstudio"
}
|
Find inverse $z$-transform of $\frac{5}{z^{2}-z-6}$
How can I find inverse z transform of $$X(z)=\frac{5}{z^{2}-z-6}$$
What I did:
first i factored denominator and i got (z+2)(z-3), now we get A(-2^{n}) + b(3^{n}). To get A and B i used Partial Fraction Decomposition and got A=-1 and B=1. But Wolframalpha gave me another answer! $$=\frac{1}{6}(3(-2^{n}+2*3^{n}))$$ what i did wrong?
|
Doing partial fractions as per usual, $$\frac{5}{(z+2)(z-3)}= \frac{A}{z+2} + \frac{B}{z-3} \implies 5 = A(z-3)+ B(z+2).$$ Equating coefficients, we see that $$A+B=0 \mbox{ and } 2B-3A=5.$$ This linear system has the unique solution $A=-1$, $B=1$. Therefore, we see that $$\frac{5}{(z+2)(z-3)}=\frac{1}{z-3} - \frac{1}{z+2}.$$
So the poles of $X(z)$ are encircled, choose $C$ to be $\\{z\in\mathbb{C}:|z|=4\\}$ with standard orientation.
Therefore, by definition, the inverse $Z$-transform of $X(z)$ is \begin{align*} \frac{1}{2\pi j} \int_C X(z)z^{n-1} dz &= \frac{1}{2\pi j} \int_C \left(\frac{1}{z-3} - \frac{1}{z+2}\right)z^{n-1} dz \\\ &= \frac{1}{2\pi j} \left(\int_C \frac{z^{n-1}}{z-3}dz - \int_C\frac{z^{n-1}}{z+2} dz\right). \\\ \end{align*} We then apply Cauchy's Integral Formula to get $$\frac{1}{2\pi j} \left(\int_C \frac{z^{n-1}}{z-3}dz - \int_C\frac{z^{n-1}}{z+2} dz\right)=3^{n-1} - (-2)^{n-1}.$$
|
stackexchange-math
|
{
"answer_score": 2,
"question_score": 1,
"tags": "inverse, transformation, z transform"
}
|
Разный ответ на запрос баланса
При запросе баланса с помощью USSD команды Мегафон выдает разные результаты, на запрос введенный руками `*100#` и на запрос выполняемый программно `'at+cusd=1,*100#,15\r\n'`. Баланс всегда разный на пару рублей, в моем случае это крайне критично. Такая проблема только с Мегафоном.
Что может подсказать?
**Обновление**
Есть прошивка для модема, написанная на Lua. В ней есть функция проверки баланса на разных операторах связи. Запрос выполняется USSD командой. Поскольку метки USSD нет, а я еще не обладаю правами создания новой метки, ближайшая метка была Телефония.
|
Да, походу только с Мегафон'ом. Предполагаю, что у них базы разные и обновления происходят с задержкой.
|
stackexchange-ru_stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "телефония"
}
|
Overlay content areas in Bootstrap 3 site when responsive menu is opened
How can I overlay the content areas of a Bootstrap 3 site with a semi opaque [50% alpha] overlay when someone opens the nav-stacked menu, only when the site is viewed on a phone [i.e. only for @media (max-width: 767px)]
Is this even possible with CSS or will I have to use some jQuery?
**UPDATE**
Thanks guys - you provided the clues, what I ended up doing was :
$(".navbar-toggle").click(function(){
$("<div class='overlay'></div>").appendTo($(".content, .footer").css("position", "relative"));
})
// and some css
/* navigation overlay */
div.overlay {
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
background: rgba(0,0,0,0.5);
}
|
I haven't tested it, but maybe something like this?
**JS**
$(".navbar-toggle").click(function(){
$("body").toggleClass("nav-open")
})
**CSS**
@media (max-width: 767px) {
body.nav-open:after {
content: '';
display: block;
position: fixed;
top: 0; bottom: 0; left: 0; right: 0;
width: 100%;
height: 100%;
z-index: 10000;
background: rgba(0,0,0,0.5);
}
}
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "jquery, css, twitter bootstrap, twitter bootstrap 3"
}
|
Take Twelve to Total Twenty Two
Without repeating the numbers 1 to 12,
Fill the grid below to total 22 in both directions.
$$\def\X{\smash{\rlap{\Space{7pt}{0px}{0px}\llap{\Huge{\times}}}}} \Large\begin{array}{|c|c|c|c|}\hline &&5&\\\\\hline \rlap{10}~~~&\X&\X&\\\\[-2px]\hline &\X&\X&7~\\\\[-5px]\hline &9&&\\\\[-10pt]\hline \end{array}$$
|
Answer
> `2 12 5 3`
> `10 - - 11`
> `6 - - 7`
> `4 9 8 1`
Explanation
> In the column containing 10 in order to make 22, the remaining three should be such that the sum is even. So we can have 2 odd and 1 even or 3 even numbers.
> In the rows with 5 and 9 and in the column with 7, in order to make the sum even, we need 3 odd or 1 odd and 2 even numbers. But we have only 3 odd numbers left.
> So I decided to place all the three in the right most column. So the left most column should have all even and the sum not exceeding 22.
> This made me to place 2,4,6 in the left most column.
> At last the numbers were to be arranged such that the sum is 22
|
stackexchange-puzzling
|
{
"answer_score": 4,
"question_score": 6,
"tags": "mathematics, calculation puzzle"
}
|
How should I host the servers for my project?
I have started work on a game project which is expected to have a very high load on the servers. My original plan was going with a general main server which hosts general game data and using a collection of servers hosting a node (or game world) server, being balanced with more CPU/network intensive worlds being hosted in less numbers on the machine. Now I was wondering how it's best for me to set up the actual servers. Should I go with a cloud like Microsoft Azure, should I host it all myself on own bought hardware or should I use dedicated hosting from some hosting company?
|
Windows Azure actually has a Toolkit for Social Games which might provide some good guidance. <
On Github the architecture section might also help you think about an Azure Solution <
Re: Servers, the cloud is a perfect match for this workload/use case, you can grow quickly or fail fast depending on how successful you are and only ever pay for what you use. Azure has a IaaS and PasS offering which should meet all your needs (inc Windows and Linux on IaaS)
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "azure, hosting, cloud, distributed computing"
}
|
c++: instantiate object
> **Possible Duplicate:**
> C++ Object Instantiation vs Assignment
I am quite new to C++ and was wondering what is the difference(if any) between instantiating an object as
int main () {
vector< int > x(2);
}
or
int main () {
vector< int > x = vector< int > (2);
}
except for the fact that the latter takes longer to write. Thanks in advance!
|
The difference is largely grammatical:
* `vector<int> x(2);` is _direct initialization_.
* `vector<int> x = vector<int>(2);` is _copy initialization_.
The latter formally requires that the class have an accessible copy constructor, but in practice the copy will be elided and the two versions produce exactly the same code.
You should always prefer direct initialization.
You can also go insane:
* `vector<int> x = vector<int>(vector<int>(vector<int>(2)));`
|
stackexchange-stackoverflow
|
{
"answer_score": 7,
"question_score": 2,
"tags": "c++, object, instantiation"
}
|
bash + return in the bash script only from function or also in the script
in bash as all know we can use return 0 , to exit the function and 0 is the std 0
function fun1(){
return 0
}
but can we also use return 0 in the script itself not in function ?
as
#!/bin/bash
function fun1(){
return 0
}
function fun2(){
return 0
}
function fun3(){
return 0
}
.
.
.
.
.
fun1
fun2
fun3
echo " script ended "
return 0
|
Yes you can if that script is sourced. You might want to do this instead of exit because if you used exit it would also exit out of the shell you are sourcing from where return would not. If you execute the script directly it would throw an error for the `return` line and continue to execute the rest of the script.
|
stackexchange-unix
|
{
"answer_score": 2,
"question_score": 1,
"tags": "linux, bash, shell script"
}
|
Return number of rows in select command - stored procedure
I am Executing One query using stored procedure object. i want to retreive number of rows returns in Select Statement after executing the query.
I am Confused between using `ExecuteReader() & ExecuteScalar()`
public static int getDuplicateEvent(string ATM, string Fault1, string Fault2, ref SqlConnection Connection)
{
string sQuery = "";
int result = 0;
try
{
sQuery = /*Query With Format Select Code From A Union Select Code From B */
using (SqlStoredProcedure sspObj = new SqlStoredProcedure(sQuery, Connection, CommandType.Text))
{
result = (int)sspObj.ExecuteScalar();
sspObj.Dispose();
}
}
catch (Exception xObj)
{
result = 0;
}
return result;
}
|
`ExecuteScalar` returns the first column of the first row of the results
`ExecuteReader` returns a datareader that can be iterated through
You could also use `ExecuteNonQuery` or `Fill` into a `DataSet` or `DataTable`
Assuming you want the rows and the count, I would fill a DataTable and count the rows using `Rows.Count`
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 0,
"tags": "c#, sql, sql server"
}
|
Fast software color interpolating triangle rasterization technique
I'm implementing a software renderer with this rasterization method, however, I was wondering if there is a possibility to improve it, or if there exists an alternative technique that is much faster. I'm specifically interested in rendering small triangles, like the ones from this 100k poly dragon:
!Dragon
As you can see, the method I'm using is not perfect either, as it leaves small gaps from time to time (at least I think that's what's happening).
I don't mind using assembly optimizations. Pseudocode or actual code (C/C++ or similar) is appreciated.
|
Rasterizing triangles in software is commonly done using either Bresenham's algorithm or using a differential digital analyzer (DDA) with fixed point math to interpolate the values. Bresenham uses a lot of branching, so is probably less efficient than a fixed-point DDA on modern CPUs.
The tutorial you have linked uses an odd mix of C++ classes, floating point math, and a per-pixel function call to set the colors. You can do a lot better than that example by just writing less inefficient code! Both Bresenham and DDA will get you more numerical stability than mixing floats and ints haphazardly as in the linked tutorial (a probable cause of the gaps you see).
|
stackexchange-gamedev
|
{
"answer_score": 2,
"question_score": 1,
"tags": "optimization, computational geometry, software rendering, rasterization"
}
|
How to hide keyboard after edittext click
I have a edittext in my android app where I can put a person birthdate. When I click on it a dialog fragment appears, but I have to click two times. After first click there is an keyboard and I don't want it.
I know that I can use button instead, but i prefer editext, because it looks better :) How can I change it? Can I open diagram in first edittext click? Thanks in advance!
|
You can make your EditText not focusable by adding `android:focusable="false"` in XML declaration and then use simple onClickListener on the EditText.
Else, you can also use the following method to hide the keyboard:
public void hideSoftKeyBoard(Activity activity) {
// Check if no view has focus:
View view = activity.getCurrentFocus();
if (view != null) {
InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}
}
This can be invoked as follows: `hideSoftKeyBoard(this)` from an activity or `hideSoftKeyBoard(getActivity())` from a fragment.
Hope this helps!
|
stackexchange-stackoverflow
|
{
"answer_score": 4,
"question_score": 0,
"tags": "android, dialog, keyboard, fragment"
}
|
how to connect points after identifying them in cvgoodfeaturesTotrack
I want to identify an object and draw a shape around it ...
I used previously the color identification but wasn't a good option since color change dramatically from place to place .. so I though why not identifying objects by features such as edges .. and I did that using this function in openCV
cvgoodfeaturesTotrack
it returns the (x,y)-coordinates of the points .. now I want to connect those points.. well not all of them but the one who are close to each other to draw a shape around the different objects. Any ideas ?
|
I don't think there is a free lunch in this case. You are trying to reconstruct a polygon if you only know the corner points of the polygon. There is no unique solution to this problem: you can draw all sorts of polygons through the corners. If you are certain the shape you are after is convex, then you can construct the convex span of the corner points, but the result will be horrible if you include any corners that were not part of the original object.
It seems to me that detecting corners is not the way to segment an object that is more or less delimited by lines. You probably want to try an edge detector instead, or a proper segmentation technique such as watershed.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 1,
"tags": "opencv, video processing"
}
|
what is difference between 1/3 and 1./3 in python
print (1/3)
print (1./3)
I don't see difference between (1/3) and (1./3). When should I use one or the other, and why?
|
This is done to make sure the output is a floating point number. 1./3 means 1.0 / 3 which would return 0.33333...
1/3 would produce 0 as an integer
EDIT: This is only valid in Python 2
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "python, python 2.7, python 3.x"
}
|
Removing all instances of items from array
I have an array which may have duplicate values
$array1 = [value19, value16, value17, value16, value16]
I'm looking for an efficient little PHP function that could accept either an array or a string (whichever makes it easier)
$array2 = ["value1", "value16", "value17"];
or
$string2 = "value1 value16 value17";
and removes each item in array2 or string2 from array1.
**The right output for this example would be:**
$array1 = [value19]
For those more experienced with PHP, is something like this available in PHP?
|
you're looking for array_diff
$array1 = array('19','16','17','16','16');
$array2 = array('1','16','17');
print_r(array_diff($array1,$array2));
Array ( [0] => 19 )
|
stackexchange-stackoverflow
|
{
"answer_score": 13,
"question_score": 8,
"tags": "php, arrays"
}
|
How can i arrange button location on Dash Plotly?
I am making a dashboard using Dash by Plotly. It is really fast and useful for me. But I could not find how can i arrange the location of for example a button. For example i want button to be x=5, y=150. But I could not find a solution on documentation. Additionally I examined the dash core components in github and I can not find somewhere like x coordinates or location etc. Do I need to add react.js codes somehow? Thanks in advance.
|
I'm assuming that you don't mean to create your entire layout this way and just want to place a particular button at your desired x and y.
You can use the Affix component that comes with dash-mantine-components.
> PS: I'm the author of this library.
import dash_mantine_components as dmc
from dash import Dash, html
app = Dash(__name__)
app.layout = html.Div(
[
dmc.Affix(
dmc.Button("I'm in an affix component!"), position={"top": 5, "left": 150}
)
]
)
if __name__ == "__main__":
app.run_server(debug=True)
Output
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "python, plotly dash"
}
|
Unbiased Estimator test
I'm in need of help with this problem. I've been reviewing for an exam and I'm terrible with estimations.
$X_1,X_2,\dots,X_n$ be an i.i.d sample from continuous uniform distribution on the interval $(0,\theta)$ with parameter $\theta>0$. Let us consider $Y=\max(X_1,X_2,\dots,X_n)$ has a c.d.f $F(y) = P(Y \le y) = (\frac y \theta)^n$; $0<y<\theta$.
Is $Y$ an unbiased estimator for $\theta$?
I've made attempts but I think I'm going the opposite directions.
My attempt so far:
$$n\over{(n-r)!(r-1)!}[F(y)^{r-1}][(1-F(y))^{n-r}]f(y)$$
|
Your question amounts to asking whether $E[Y]=\theta$. But $E[Y]$ can just be calculated, now that you have the CDF:
$$E[Y]=\int_0^\theta x f(x) dx = \int_0^\theta x F'(x) dx = \int_0^\theta \frac{n}{\theta^n} x^n dx.$$
Now calculate this integral. You will necessarily find that it is strictly less than $\theta$; one way to see this without doing the calculation is to notice that $P(Y \leq \theta)=1$ and $P(Y<\theta/2)>0$.
The application of this calculation is that $E[Y]$ is not $\theta$, but is $k_n \theta$ for some number $k_n$. This means that $E[Y/k_n]=\theta$, which gets you an unbiased estimator for $\theta$. This is much like how we correct the "obvious" biased estimator for $\sigma^2$ into the unbiased estimator that is customarily used.
|
stackexchange-math
|
{
"answer_score": 0,
"question_score": 1,
"tags": "statistics"
}
|
Start Unix screen command in middle of process
If I've started a process, e.g. `java hello.java`, is it possible to switch to `screen`, so I can disconnect from the server, but have the process continue to run?
|
Its possible to move a process under screen using reptyr, here is an example. But be sure to do (as root):
echo 0 > /proc/sys/kernel/yama/ptrace_scope
on recent Ubuntu systems.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "unix, gnu screen"
}
|
Suppose you pay 3.00 dollars to roll a fair die with the understanding that you will get back 5.00 dollars...
I am really lost on these two question just wondering if someone could lend me a helping hand..
Suppose you pay 3.00 dollars to roll a fair die with the understanding that you will get back 5.00 dollars for rolling a 3 or a 6, nothing otherwise. What is your expected value?
|
The expected value is the sum of the probablity of each outcome multiplied by the "value" of each outcome.
Its sort of like a special average.
In your case each outcome has probability $\frac{1}{6}$. and you get 5 dollars when you roll 3 or 6 when you roll something else.
So the expected value is
$\frac{0}{6}+\frac{0}{6}+\frac{5}{6}+\frac{0}{6}+\frac{0}{6}+\frac{5}{6}=\frac{10}{6}=\frac{5}{3}$.
This means loosely that if you played this game a lot you should expect to win on average about 1.66 dollars, while you payed 3 to play it. Clearly this is a great idea if you want to lose money.
|
stackexchange-math
|
{
"answer_score": 1,
"question_score": 0,
"tags": "probability"
}
|
Why is Android looking for QVGA resources in the wrong order mdpi > hdpi > ldpi?
I'm trying to do some testing with a QVGA emulator and I find that it looks for an image resource in the mentioned order.
drawable-mdpi 1st
drawable-hdpi 2nd
drawable-ldpi 3rd
(it does get found only after I change the name of the image in the other two dirs for testing)
I would expect it to be ldpi first.
When running other emulators (HVGA and WVGA) they use their appropriate drawable dirs... it's only QVGA. The only code that I see could affect this is here (based on the docs)
I have tested this with a 2.0 emulator and a 1.6, I get the same result.
Any ideas? Thank you very much.
|
It appears that I have to enter the density manually.
If I just select QVGA as a Skin from the "Built-in" drop down list it puts 120 as the value for the Abstracted LCD density, but it doesnt seem to work...
So I delete that property and add it back, then change the value to 120. Thank you much Dave for your direction.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 5,
"tags": "android, resources, resolution"
}
|
How to get and store the date and time of a post in MySQL?
I'm currently doing a program that when a user posts or orders an item then the date and time will be posted in a html and stored in a MySQL table. As of now, i tried displaying the current date and time in my HTML file but it isn't stored in my MySQL table. Can anyone help me? And yes, i'm new at PHP and MySQL programming. :p
|
For that create a column in your table and take datetype like datetime and on displaying it retrieve that column value.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "mysql"
}
|
IHP - How to connect IHP's Postgres instance with Moodle?
I'm trying to connect IHP's Postgres instance with Moodle. The IHP Guide uses `postgresql:///app?host=YOUR_PROJECT_DIRECTORY/build/db` with the development server running to connect however Moodle further requires Database host, name, user, password, port, Tables prefix and Unix Socket to connect.
|
IHP uses a Postgres socket file to connect, the socket file is located at `YOUR_PROJECT_DIRECTORY/build/db/.s.PGSQL.5432`. The database name is `app`, there is no password. For example, with `psql` you can connect to the database as: `psql -h $PWD/build/db -d app`.
I'm not sure why are you trying to connect IHP with Moodle? IHP dev server starts and restarts the Postgres database as you are developing, `./start` would start the database, and as soon as you exit, the database is stopped. However, it seems Moodle requires a database running forever in order to function.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "postgresql, moodle, ihp"
}
|
Is This Wood Still Good? (Water Stained or Rotten)
I have an attachment on the side of my house, basically an enclosed porch but could also be a mudroom. One of the doors leads to a deck where the prior owners let the gutter downspout fall out of place, which let water collect on the deck and get into this small room. I'm wondering if the floor is still good (just stained) or rotting. I was planning on finishing the room which includes tiling the floor. Do I need to replace the wood prior to doing this?
|
It looks like water stains. Take a screwdriver and press it into the surface especially in the groves. If the wood is rotten the screwdriver will dig in. If the wood is sound it will just leave a mark. This is how home inspectors test around suspected areas for rot.
|
stackexchange-diy
|
{
"answer_score": 6,
"question_score": 2,
"tags": "wood, tile, floor, replacement"
}
|
How do I access Django running on a Google Compute Engine VM from my browser?
I have a Django dashboard application I wish to view from my browser. Django is running in a Docker container on one of Google's Compute Engine instances. The GCE instance is on a Google VPC, on which I've added firewall rules to open Django's port 8000. I've added my IP to Django's ALLOWED_HOSTS in settings.py. The container's logs indicate that it is running fine, yet when I access the GCE instance's IP from my browser, I am immediately unable to connect. I can ping the instance from my command line just fine. Is there something I'm missing here? Been stuck on this for a few hours now.
Note: I have the Django container running on a "Docker network" in order for Celery to communicate with a RabbitMQ container. This was recommended to me somewhere, but I am unfamiliar with Docker networks or if they are causing the issue.
|
I have found the solution after a bit more trial-and-error. It was not very intuitive so I'll post here in case I can help anyone else.
What fixed the issue for me was exposing the port (8000) on the command line when running the app's container: `docker run -p 8000:8000 ...`
The reason this eluded me for so long was because I already expose the port in the Dockerfile: `EXPOSE 8000`, and when I run `docker ps` to list the ports exposed on each container, the container appeared to already be port-exposed: `8000/tcp`. However, what I didn't know is that it is supposed to look like: `0.0.0.0:8000->8000/tcp`.
Anyways, hope this helps someone else out.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 2,
"tags": "python, django, docker, google cloud platform, google compute engine"
}
|
If A = diag(1, 3) and B = diag(3, 1) show that A and B are similar (find an M).
Please show me steps how you would solve it. I'm really lost and detailed explanation would help me learn and understand it better.
|
If $A=\left(\begin{array}{cc}1 & 0\\\0 & 3\end{array}\right)$ and $B=\left(\begin{array}{cc}3 & 0\\\0 & 1\end{array}\right)$, find an invertible $2\times 2$ matrix $M$ such that $MAM^{-1}=B$. Hint: Use an $M$ whose entries are only $1$'s and $0$'s.
|
stackexchange-math
|
{
"answer_score": 2,
"question_score": -1,
"tags": "matrices"
}
|
iOS equivalent for Android BOOT_COMPLETED and ACTION_SHUTDOWN
In an Android application the app can "listen" to ACTION_BOOT_COMPLETED and ACTION_SHUTDOWN events.
Is that possible under iOS? If it is - how can iOS app listen to those events?
|
The application lifecycle and application states on iOS are described in the iOS Application Programming Guide
Essentially there are notifications for your app starting, moving to the background, moving back to the foreground and terminating (there are also some background execution modes) but as Dekel said in comments, an app doesn't receive any direct notifications that the device is shutting down or was restarted.
 $$\langle Tv, Tv \rangle=\langle v, T^{*}Tv \rangle=\langle v, TT^{*}v \rangle=\langle T^{*}v, T^{*}v \rangle.$$
**Claim 2 If $T$ is normal then $T-\lambda I$** is also normal.
See if you can show $$(T-\lambda I)(T-\lambda I)^{*}= \dotsb=(T-\lambda I)^{*}(T-\lambda I).$$
Now use **claim 1** for the normal operator $T-\lambda I$ to get $$\|(T-\lambda_i I)v_i\|=\|(T-\lambda_i I)^{*}v_i\|.$$ So if $v_i$ is the eigenvector for $T$, then the norm on LHS is $0$. This means $\|(T-\lambda_i I)^{*}v_i\|=0 \implies (T-\lambda_i I)^{*}v_i=0 \implies (T^{*}-\bar{\lambda_i}I)v_i=0$
|
stackexchange-math
|
{
"answer_score": 1,
"question_score": 0,
"tags": "linear algebra"
}
|
How to get screen shot of webpage using javascript or jquery?
Likes to add screen shot submission for any bugs in my web application which developed using J2EE.That is if there is any bugs then client has the ability to take the screen shot of bug and submit for bug maintains.
So want a efficient mechanism to capture screen shot using JavaScript or Jquery since i want the screen shot of client using my web application.
Already tried with html2canvas.js but it doesn't work in IE8.Wants efficient solution that supports in IE8.
So please help me to find a solution for this.
|
`excanvas.js` can be used in html to support canvas.Even though you can't solve it for html2canvas in IE8.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 1,
"tags": "java, javascript, jquery, html, jakarta ee"
}
|
WIFI thermostat no C wire
I hooked up a Honeywell WiFi thermostat last fall. There is no C wire in the furnace & the Honeywell rep suggested I wire up a small separate transformer with new wires going to the C and RC terminals (no jumper between R and RC) on the new thermostat. Heat worked fine all winter & I just switched the thermostat over to cool, but the AC will not come on. "Cool on" is flashing on the thermostat but there is no fan or compressor action.
The furnace is a 1986 Trane model BLU162E960B1. Natural gas - forced air. AC is much newer. The transformer is wired up for 24 volts.
The existing wiring includes a G, W, Y, and R. The C and RC wires go to the small (doorbell-type) transformer. There is no C wire marked on the furnace wires or on the schematic.
What am I missing? No help from Honeywell.
!furnace schematic
|
Get rid of the external transformer, and pull a proper `C` wire.
It's not working because you have one side of the contactor coil connected to one transformer, and the other side connected to another transformer. There's not a complete circuit.
When the thermostat is calling for cool, your circuit looks like this
!external transformer diagram
If you follow the circuit, you can see that it's not a complete circuit.
!external transformer diagram highlighted
* * *
I've highlighted the `R` wire in red, and the `C` wire in blue.
!Highlighted image
|
stackexchange-diy
|
{
"answer_score": 2,
"question_score": 1,
"tags": "hvac, thermostat c wire"
}
|
Set temporary text in a EditText/TextView in Android?
I'm looking to build a simple input form for username/password, and I was wondering if it was possible to mimic the functionality that many websites offer, namely a temporary string within a text input displaying what the field's purpose is. Essentially, I need something like this:
!enter image description here
When the user hasn't yet focused in on the text input, it should display "USERNAME" in a different format. When the user has focused in on the text field, the field is cleared and focus is set and the style is changed. Is there a way to do this easily?
|
look at the properties of the edittext - there is a "hint" property that does just that.
android:hint="Enter Username"
|
stackexchange-stackoverflow
|
{
"answer_score": 5,
"question_score": 4,
"tags": "android, textview, android edittext"
}
|
using sql nvarchar(50) as date variable in sql server
hi guys i have column that is Nvarchar(50) that i use it as a date type column because i use Persian calendar now i want to select times from two different time for example show me data s that are between 2012/12/18 and 2012/12/20 how could i do that please help and by the way i want use Stored Procedures for these actions i try this but it dose not return any thing
ALTER proc [dbo].[sel_monthReport] @fdate nvarchar(50),@sdate nvarchar(50),@para nvarchar(50)
as
begin
declare @parametr nvarchar(50)
set @parametr=@para
select * from main where @parametr>=@fdate and @parametr <=@sdate
end
|
Let's say you have a column in your `main` table called RecordDate, and this column is of type nvarchar, with the date format yyyy/mm/dd.
In that case, you don't need the @para parameter in your stored procedure. Change it to something like this:
ALTER PROC [dbo].[Sel_monthreport] @fdate NVARCHAR(50),
@sdate NVARCHAR(50)
AS
BEGIN
SELECT *
FROM main
WHERE main.recorddate BETWEEN @fdate AND @sdate
END
Note, that this is a NVARCHAR comparison, ant it only works because your dates are stored in the format yyyy/mm/dd. In general, a better approach would be to compare DATETIME datatypes (better performance and less error-prone).
You can convert an NVARCHAR value to a DATETIME datatype using the CONVERT function: <
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "sql server, tsql, date, nvarchar"
}
|
How elevate and get admin rights on-demand in a .NET application?
I have an .NET application which is run with default rights as the current user, then at some point I need to perform an action which requires admin rights.
How can I get admin rights on-demand in a .NET application?
Requiring that the application is run with admin rights from the beginning is not appropriate as it may be that such action may not be called.
|
I don't think this is possible. One way to get around it would be to split your application in two, one for all the operations that doesn't need elevation and one for the ones that do. Then you run the non elevated app as normal but start up the elevated one when needed.
|
stackexchange-stackoverflow
|
{
"answer_score": 4,
"question_score": 7,
"tags": ".net, uac, elevation, admin rights"
}
|
How to precisely set position in edit mode by typing in numbers?
In Object Mode, I can type in xyz coordinates using this menu:
!object menu
What is the equivalent in Edit Mode, so I can precisely position the parts of an object?
|
Both in Object Mode and in Edit Mode, you can use the _Transform_ menu of the _Properties Panel_ on the right-hand side of the 3D View (shortcut `N`).
If you have only one vertex selected, it will position that vertex precisely. If you have more than one selected, it will affect the median position of all the selected vertices.
**Edit Mode:**

: i_(std::move(i))
{
}
void printNum()
{
std::cout << i_ << std::endl;
}
private:
int&& i_;
};
int main()
{
Foo f{5};
f.printNum(); // Outputs 5 every time
}
In what scope does the integer 5 exist in this example? The rvalue passed to the Foo-constructor has surely been destructed when the next line is called, so why doesn't the call to `printNum` warrant undefined behavior? Are we not trying to access memory that's no longer in use?
|
The `int` is destroyed at the end of the expression `Foo f{5};` so the program has undefined behavior.
|
stackexchange-stackoverflow
|
{
"answer_score": 4,
"question_score": 2,
"tags": "c++, rvalue"
}
|
Access pixels with Mat OpenCV
I would like to access pixels in RGB with OpenCV 2.3. I'm trying like this but it's like every pixels are equal frame after frame because I got no output. Images are from my webcam and I can see them. Btw RED = 0;
THX
Mat frame;
Mat oldFrame;
VideoCapture cap(0);
cap >> oldFrame;
sumFramePix = oldFrame.cols * oldFrame.rows;
nbChannels = oldFrame.channels();
cout << "NbcHANNELs : " << nbChannels << endl;
imshow("Video 1", oldFrame);
while(1)
{
cap >> frame;
imshow("Video 1", frame);
for(int i=0; i<frame.rows; i++)
{
for(int j=0; j<frame.cols; j++)
{
if (frame.ptr<uchar>(i)[nbChannels*j+RED] < oldFrame.ptr<uchar>(i)[nbChannels*j+RED])
{
cout << "==============-";
}
}
}
oldFrame = frame;
if(waitKey(300) >= 0) break;
}
|
Change
oldFrame = frame;
to
oldFrame = frame.clone();
You are creating two Mat objects that point to the same data. `clone()` makes a deep copy.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 3,
"tags": "c++, image, opencv, rgb, pixel"
}
|
Injective map of schemes that is not a monomorphism
I know that it is not true that for a map $f \colon X \rightarrow Y$ of schemes, injectivity (on underlying sets) of $f$ gives a monomorphism in the category of schemes.
Stronger assumptions are required, see e.g. Tag 01L6 in the Stacks project.
But I have not come up with a counterxample yet. So can someone provide me with some concrete counterexample, preferrably some well-known class of such morphisms?
|
Let $L/K$ be any proper extension of fields. The inclusion $K\to L$ gives a map of affine schemes $\mathrm{Spec}(L)\to\mathrm{Spec}(K)$. Since both schemes have just one point, this map is a bijection on underlying sets. But it is not a monomorphism, since $K\to L$ is not an epimorphism of rings. For example (using Galois theory if $L/K$ is algebraic or transcendence bases if $L/K$ is transcendental), $L$ admits multiple distinct embeddings into its algebraic closure $\overline{L}$ which all restrict to the identity on $K$.
|
stackexchange-math
|
{
"answer_score": 10,
"question_score": 5,
"tags": "general topology, algebraic geometry, category theory, monomorphisms"
}
|
Check if object declared const
I would like to break the compilation if the object is declared const.
The following doesn't work :
#include <type_traits>
struct A {
A() : v(0)
{
static_assert( ! std::is_const<decltype(*this)>::value, "declared as const" );
}
int& AccessValue() const
{
return const_cast< int& >( v );
}
int v;
};
int main()
{
A a1; // ok, this compiles
const A a2; // no, this break the compilation
a1.AccessValue() = 5; // ok
a2.AccessValue() = 6; // OPS
}
So, is there a way to break the compilation if an object of this type is declared const?
|
You are heading the wrong way.
The type of `this` is purely dictacted by the signature of the method in which you use it. That is, `this` is always of type `cv T* const` where `cv` corresponds to the CV qualifiers of the method.
Therefore, in a constructor, `this` is just `T* const`.
* * *
`const_cast` is a code smell, normally only of use when dealing with `const`-broken legacy libraries... or (sometimes) to avoid violating DRY. In new code, you should not have to use it.
You are left with a choice:
* make `AccessValue` non-const, since it is not
* declare `i` as being `mutable`.
I would advise choosing the former solution. Giving away a handle to a `private` attribute is bad already (breaks encapsulation), no need to violate `const` correctness as well.
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 2,
"tags": "c++, c++11, typetraits"
}
|
Why doesn't my Refresh header work?
I'm working on a homework assignment in Perl CGI using the CGI.pm module. In my code I am checking for a cookie. If the cookie exists, I want to initiate another CGI script. In other situations I was able to use similar code, but in this instance I merely get the following browser output, not the redirect that I was looking for.
Refresh: 1; URL=homepage.pl.cgi
Content-Type: text/html; charset=ISO-8859-1
Here's my code:
#get the cookie
my %SIDhash = cookie('SIDhash');
if ( exists $SIDhash{"SID"} ) {
print header(-refresh=>'0; homepage.pl.cgi');
}
What fundamentals am I not understanding here?
Thanks, CB
|
This should do the trick:
print header(
-refresh => '0; url=homepage.pl.cgi',
-cookie => $cookie,
);
If you are assembling the header in pieces, in various places in your code, save the header components in a variable first, e.g.:
my %headers;
# later...
$headers{-cookie} = $cookie;
# later still:
if (exists $SIDhash{SID})
{
# we want to redirect, so print all headers and we're done.
print header(%headers, -refresh => '0; url=homepage.pl.cgi');
exit;
}
# if we're still here, nothing is printed yet.. continue preparing data and print when ready.
# ...
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 2,
"tags": "cgi"
}
|
Two menu items missing from magento admin panel
Don't know when this happened. Suddenly I just noticed that two menus "mobile" and "newsletter" are missing from magento admin panel. Any clues?
|
Are the modules possibly disabled in the app/etc/modules folder? A cache clean would then have happened (later) to make them suddenly disappear.
If they are enabled, check file permissions.
|
stackexchange-magento
|
{
"answer_score": 2,
"question_score": 1,
"tags": "magento 1.7, magento 1.8, magento 1.9"
}
|
Darwin Streaming Server Log Format?
I am writing a program that will parse and manipulate logs from Darwin Streaming Servers. Where can I get a definition of what the individual fields headers mean? Are there some kind of documentation in the DSS doc files?
For example, I have this as the log output header:
> c-ip date time c-dns cs-uri-stem c-starttime x-duration c-rate c-status c-playerid c-playerversion c-playerlanguage cs(User-Agent) c-os c-osversion c-cpu filelength filesize avgbandwidth protocol transport audiocodec videocodec sc-bytes cs-bytes c-bytes s-pkts-sent c-pkts-received c-pkts-lost-client c-buffercount c-totalbuffertime c-quality s-ip s-dns s-totalclients s-cpu-util cs-uri-query c-username sc(Realm)
|
I've managed to get some information about the log format from the net, but this is not complete. Is there a link to the complete log format?
DSS Log Format (Google Docs)
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "darwin"
}
|
Resource file copied to output dir but not read by Eclipse
I got an XML file in the root of src, which is outputted in the bin folder along with the compiled classes. How can I tell Eclipse to put in the classpath all future files that will reside in bin root's folder?
I don't see such an option. I am allowed to define output dir, whether copy or not folders from source, but I thought output's root was in the classpath.
Or is this an anormal behavior and I should be seeing it?
Thanks!
EDIT:
bin folder does not show up in Project view, even if I select Java ouput folders in the customize View. It shows in Navigator but it does not have the option to add to build path.
When editing Build path, I can select it as the output folder. I also checked projects metadata, it seems is there
|
Ok sorry it was hibernate's thing.
It throws a generic message that file is not there, but if you pick another file in the bin's root, it's read. So either hibernate has some special considerations as a different classloader or basepath or they really need to change the meaning of the exception...
My apologize for not adverting a basic double-checking was obviously one possiblity.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "java, eclipse"
}
|
Dart parse full dateTime including am/pm
I have my date here `2020/07/07 09:47:54` from my API in which I'm trying to parse to `2020/07/07 09:47am`. I have tried the following method using intl package but I'm getting an error
DateFormat format = DateFormat('yyyy/MM/dd hh:mm').add_jm();
DateTime newDate = format.parse(date)
> Unhandled Exception: FormatException: Trying to read from 2020/07/07 09:47:54 at position 20
Anyone has an idea what seems wrong here?
|
**Solution**
I found a way in which i need to parse the string date into a DateTime format then reformat it again based on what I needed.
DateTime dateTime = DateFormat('yyyy/MM/dd h:m').parse(date);
final DateFormat formatter = DateFormat('yyyy-MM-dd h:m a');
final String formatted = formatter.format(dateTime);
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 1,
"tags": "flutter, dart"
}
|
The example of $m(\cap_{n=1}^\infty\cup_{k=n}^\infty E_k)>\lim\sup m(E_n)$
Let $\\{E_n\\}$ be a sequence of Borel sets on $[0,1]$. I want to construct an example of $m(\cap_{n=1}^\infty\cup_{k=n}^\infty E_k)>\lim\sup m(E_n)$.
I can prove in general $m(\cap_{n=1}^\infty\cup_{k=n}^\infty E_k)\ge\lim\sup m(E_n)$. For the example of $>$, I am trying to find a sequence of $E_n$ s.t. $\lim m(E_n)=0$ and $m(\cup_{k=n}^\infty E_k)=1$, but so far I can't construct such an example.
|
One way to do it is to find sets so that $\cup_{k=n}^\infty E_k = [0,1]$ for all $n$, yet $m(E_n) \to 0$. Try the sequence $$[0,1/2],\ [1/2,1],\ [0,1/3],\ [1/3,2/3],\ [2/3,1],\ [0,1/4],\ldots$$
|
stackexchange-math
|
{
"answer_score": 1,
"question_score": 2,
"tags": "real analysis, measure theory"
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.