text:
Q: Parsing an xml list, null error <items>
  <item id="2" value="100"/>
  <item id="3" value="50"/>
</items>

I want to put this into List<Item>, where Item is a class with Id and Value properties.
However the following code:
XDocument xmlDoc = XDocument.Load(@"itemsdata.xml");
List<Item> items= xmlDoc.Descendants("items").Select(x => new Transfer()
{
    FromId = (uint) x.Element("id"),
    Amount = (uint) x.Element("value")
}).ToList();

Throws the following exception:

"Value cannot be null.\r\nParameter name: element"

A: You probably should be searching for the "item" descendants (and not the "items" descendants) and then query for the respective attributes:
List<Item> items = xmlDoc.Descendants("item").Select(x => new Item()
{
    FromId = (uint) x.Attribute("id"),
    Amount = (uint) x.Attribute("value")
}).ToList();


text:
Q: Javascript regex: only match the end of text I would like to find out multiline texts ending with "Tr ", "Br " and linebreak ("\n") without " _" (none-whitespace and underscore) preceded. Exmples
Text 1:
Command1 Br
Command2 Tr

"Command1 Br \nCommand2 Tr " //match "Tr " at the end

Text 2:
Command3 con Tr
Command4 Br

"Command3 con Tr \nCommand4 Br " //match "Br " at the end

Text 3:
Command2 Tr
Command3 con Br
Command4 C_

"Command2 Tr \nCommand3 con Br \nCommand4 C_\n" //match "\n" at the end after C_

Text 4:
Command1 Tr
Command1 Br
Command2 Tr _

"Command1 Tr \nCommand1 Br \nCommand2 Tr _\n" //no match because of " _" preceded "\n"

Text 5:
Command1 Tr
Command1 Br
Command2 mt

"Command1 Tr \nCommand1 Br \nCommand2 mt\n" //match \n at the end after "mt"

Text 6:
Command2 ht

"\n\nCommand2 ht\n" //match \n at the end after "ht"

A: You may use the following regex to extract those matches:
/(?:^| [^_]|[^ ]_|[^ ][^_])([BT]r|\n)[\t ]*$/

See the regex demo.
Details:

*

*(?:^| [^_]|[^ ]_|[^ ][^_]) - a non-capturing group matching one of the three alternatives:

*

*^ - start of a line

*| - or

* [^_] - space and any char but _

*| - or

*[^ ]_  - any char but space and _

*|  - or

*[^ ][^_] - any char but space and then any char but _ (thus, no space+_)

*([BT]r|\n) - Capturing group 1: either Br, Tr or  a newline symbol

*[\t ]* - 0+ horizontal whitespaces (may be replaced with [^\S\r\n] for better hor. whitespace coverage)

*$ - the very end of the string.

var ss = ["Command1 Br \nCommand2 Tr ", "Command3 con Tr \nCommand4 Br ", "Command2 Tr \nCommand3 con Br \nCommand4 C_\n",
"Command1 Tr \nCommand1 Br \nCommand2 Tr _\n", "Command1 Tr \nCommand1 Br \nCommand2 mt\n", "\n\nCommand2 ht\n"];
var rx = /(?:^| [^_]|[^ ]_|[^ ][^_])([BT]r|\n)[\t ]*$/;
for (var s of ss) {
console.log("Looking for a match in: " + s);
  m = rx.exec(s);
  if (m) {
     console.log("Found: " + JSON.stringify(m[1], 0, 4));
  } else {
     console.log("No Match Found.");
  }
}

redpajama_set_name: RedPajamaStackExchange


text:
Q: Reference request for a translated Complex Analysis book I'm currently trying to self-learn Complex Analysis as it isn't available for me to take as a course at university in my current year.
I'm trying to decide with which textbook I should use that would help me learn best without having a lecturer.
I asked one of my professors, and he recommended me a list of books, but he noted that there is one book written in German by Klaus Jänich for real and complex analysis "Funktionentheorie: Eine Einführung" (As seen here: Funktionentheorie ) . Unfortunately, I do not speak German and thus would not be able to learn from it.
He mentioned that he wasn't very knowledgeable about many other textbooks, but he felt like this was a go-to book for him, as he found it most intuitive and well thought.
Some of the authors he described were D.N Arnold and M. Taylor.
My question is: Does anyone know where I can find a translated version of the text by Jänich? Or for anyone who has worked with this text, if you could suggest an English text that teaches in a similar manner? Or in general, your thoughts and opinions on this text, or if another textbook might be better suited for me to learn Complex Analysis on my own (Possibly Rudin, Palka, Needham, Ahlfors, Conway)?
I'm currently using the following website to decide which textbook would be best to pursue: https://www.ocf.berkeley.edu/~abhishek/chicmath.htm
If it's any help, I also self-learned Real Analysis, so that might hinder me a bit delving further into Analysis.
Many thanks for the insight and help =)


text:
Q: preventDefault and pass parameter for click event listener I want to stop the submit event for a button, but also pass a parameter into a function that is triggered from the click. Here's what I thought could work:
function NL(line, event){
  event.preventDefault();
  document.getElementsByClassName('new-line')[1].innerHTML=line;
}
document.getElementsByClassName('new-line')[0].addEventListener('click', function(){NL('add new line');});

Here's the HTML:
<form class='myform'>

    1
    <button class='new-line'>New Line</button>
    <button class='new-line'>New 2nd Line</button>

</form>

I can't change the HTML, I can only edit the JS. Thanks in advance!!!

A:

function NL(line, event) {
  event.preventDefault();
  document.getElementsByClassName('new-line')[1].innerHTML = line;
}
document.getElementsByClassName('new-line')[0].addEventListener('click', function(event) {
  NL('add new line', event);
});
<form class='myform'>

    1
    <button class='new-line'>New Line</button>
    <button class='new-line'>New 2nd Line</button>

</form>

A: Your function accepts two parameters function NL(line, event){...} but you're calling it with only one parameter NL('add new line');.
You're not sending the event to the NL function.
This should work:
function NL(line, event){
    event.preventDefault();
    document.getElementsByClassName('new-line')[1].innerHTML=line;
}
document.getElementsByClassName('new-line')[0].addEventListener('click', function(event){
    NL('add new line', event);
});

A: Declare the event with addEventlistener()

function NL(line, event){
  event.preventDefault();
  document.getElementsByClassName('new-line')[1].innerHTML=line;
}
document.getElementsByClassName('new-line')[0].addEventListener('click', function(){NL('add new line',event);});
Here's the HTML:

<form class='myform'>

    1
    <button class='new-line'>New Line</button>
    <button class='new-line'>New 2nd Line</button>

</form>


text:
Q: Python - writing print I'm trying to learn Python and going through some exercises, it's all going good and I've learned some new stuff.
But I came across this code over the internet and it wants me to write out what the new Max and Min is supposed to become also B will be after the run.
I have tried to look for the correct answer but no one has printed it. I've tried to run it in my IDE but actually I never get an output. I've also tried writing "print(b)" but I get no result.
min = 5
max = 10
b = 0
a = -2

if a < min:
  min = a
elif a > max:
  max = a
else:
  b += 1

What I've thought the answer should be is Min will be -2 since a is declared as -2 and the first statement "if a < min:" says if -2 is less than 5, 5 will become -2.
Other statement "a > max:" asks if -2 is higher than 10, 10 will be –2 but since -2 is not higher we go to the else which says that we should plus 1 to 0 and that will give b = 1. So my answer is min = -2 , max = 10 , and b = 1.
Is my answer correct and if not what have I done wrong? Also, is there any way I can run it in python and get the answer through print(b, max, min) I've tried that but it's not working.

A: I guess the second condition should be if not elif. An if-elif-else block exits as soon as any of them satisfies the condition. So, as in your code the first condition if a < min is True, the next conditions are not going to be checked.
min = 5
max = 10
b = 0
a = -2
if a < min:
  min = a
if a > max:
  max = a
else:            <-- this is executed only if: `a > max`: is `False`
  b += 1
print b, max, min
#1 10 -2


text:
Q: Retrieving data from EditText and storing it in a variable, What should be the data type of the variable? searchField.getText()

I want to store data of a EditText field in a variable. I know it returns string data but when I tried to store that in string type variable that didn't work.
As in java variables declared according to the class name,
I tried that way too. I tried EditText varibleName = searchField.getText(); But didn't work.
can anyone explain why it didn't work and what should be the correct data type to store it?
I need an explanation how does it works. I mean What if I don't convert it to string. and What if I want to store it as row.

A: you can simply use
String var = searchField.getText().toString();

A: You need to convert it to String
String.valueOf(searchField.getText())


text:
Q: Is it legal to integrate the Ubuntu system in my software product? I developed a software product which integrates the Ubuntu system. I want to sell this software someday. Is it legal to integrate the Ubuntu system in this software product?
Do I need to pay? Or write an application to Ubuntu?
"integrate" means that I distribute my software product by a CD. And I need to integrate the Ubuntu in the CD too. And my software is run on Ubuntu system. It is an App on Ubuntu. I will not modify Ubuntu. I think I do not need to make my software open source.

A: Refer to the Ubuntu licensing information. If you are still unsure it would be best to email Canonical to confirm. It seems to depend on individual packages involved and their licences, so you may need to read each piece of software's license you use to check that they do not rule out commercial uses.

A: Software within Ubuntu is widely GPL compatible and various essential base components are certainly GPL2 or GPL3. Those are the licenses you're going to have to abide by.
The core understanding is that if you include this software, you need to make the source code available. I'm not sure if that stretches to your software (if it just sits on top) but if you've customised any of the Ubuntu system by modifying existing files, you must provide source for that.
I would strongly suggest talking to a professional about this. The FSF might be able to help but either way, I would start just by reading through what the GPL is and how it effects you:

*

*http://www.gnu.org/licenses/

*http://www.gnu.org/licenses/gpl-faq.html
People take these licenses seriously. Don't ignore them.
Just to express this again: GPL is not the only license in use (there are a myriad of various open source licenses in use in the default install of Ubuntu) but adhering to GPL should (talk to a lawyer about how you do that and to indemnify yourself that if this is true) mean you're also complying with their licenses. Aka, GPL is the fussiest license.
If you install other things (including things from the repo, or software that Ubuntu offers to install like drivers), these may have different licenses and you'll need to audit that. See the comments for some questions on dealing with that aspect. The rest of my answer assumes a clean Ubuntu install.


text:
Q: divisible by all standard prime numbers This question is about prime numbers in nonstandard models of Peano Arithmetic. Every such model looks like N+AxZ, where A is a dense linear order without end points.
There are many nonstandard numbers that are divisible by all standard prime numbers (there is exactly one standard number with this property).
Question: does every copy of Z contain a number with this property?

A: The answer is no.

Proposition: Let $f$ be a recursive function. If $M\models\mathrm{PA}$, then every interval $[a,b]$ in $M$ of nonstandard length contains an $x$ such that
$$x\equiv f(p)\pmod p$$
for all standard primes $p$.

Proof: Let $\phi(u,v)$ be a $\Sigma_1$ formula representing $f$. The formula
$$\psi(w)=\exists x\in[a,b]\,\forall u<w\,\forall v\,(\mathrm{Prime}(u)\land\phi(u,v)\to x\equiv v\pmod u)$$
holds for all standard $w$, hence it holds for some nonstandard $w$ by overspill. QED

Corollary: If $M\models\mathrm{PA}$, then any interval $[a,b]$ in $M$ of nonstandard length contains

*

*an $x$ divisible by all standard primes;

*a copy of $\mathbb Z$ not containing any element divisible by all standard primes.

Proof: Use $f(p)=0$ for 1, and e.g. $f(p_n)=n$ for 2. QED
In fact, we do not need anything as strong as PA for the argument to work. Recall that $E_1$ is the class of all bounded existential formulas.

Proposition: The previous two results hold for $IE_1$ in place of PA.

Rather than giving a direct proof, let me mention that this is an immediate consequence of the following more general result:

Theorem (Wilmers [1]): If $M$ is a nonstandard model of $IE_1$, then the Presburger reduct $(M,+,<)$ is recursively saturated.

On the other hand, the situation is different for theories on the weaker side of the Tennenbaum barrier.

Theorem: There is a nonstandard model $M\models\mathit{IOpen}$ such that every copy of $\mathbb Z$ in $M$ contains an element divisible by all standard primes.

In fact, it is easy to see that this holds in the Shepherdson model, consisting of Puiseux polynomials
$$a_nx^{n/m}+a_{n-1}x^{(n-1)/m}+\dots+a_0,$$
where $a_i\in\mathbb R$, $a_0\in\mathbb Z$: namely, every such polynomial with $a_0=0$ is divisible by all standard integers.
Reference:
[1] George Wilmers, Bounded existential induction, Journal of Symbolic Logic 50 (1985), no. 1, pp. 72–90. JSTOR

A: Here is a construction of a $\mathbb{Z}$-chain none of whose elements are divisible by every standard prime:
Let $p_1,p_2,\ldots$ be the sequence of positive (standard) primes. It follows from the Chinese Remainder Theorem that for each standard positive $N$ there is a standard $a$ satisfying the following equations:
\begin{align*}
a&\equiv 1\mod p_1\\
a+1&\equiv 1\mod p_2\\
a-1&\equiv 1\mod p_3\\
&\ldots\\
a+N&\equiv 1\mod p_{2N}\\
a-N&\equiv 1\mod p_{2N+1}
\end{align*}
Therefore by compactness there is a single non-standard $a$ (in some nonstandard model of PA) satisfying the above equations for every standard $N$. Therefore no element of the chain $a+\mathbb{Z}$ is  divisible by every standard prime.


text:
Q: Declaring strings public static readonly versus public const versus public static const In each project we have there is a file used to store the various SQL statements used in that project. There are a handful of variations on how the class is declared and how the strings are declared.
Example class declartions:
internal sealed class ClassName
internal static class ClassName
public sealed class ClassName
public static class ClassName
internal class ClassName

Example string declarations:
internal const string stringName
internal static string stringName
public static readonly string stringName
public static string stringName
public const string stringName

I don't understand what the performance implications are between the different declarations. Is there a best practice for this situation/scenario?

A: You should choose an access modifier (public or internal) based on which code uses the strings.

*

*static const is a compiler error.

*A static readonly field is a normal field which cannot be set after the static ctor.

*A const string will be replaced by its literal value at compile time.
Therefore, it will give slightly better performance (since the runtime doesn't use the field).
However, since it's substituted at compile-time, any changes to the definition in one assembly will not be picked up by other assemblies until they're all recompiled.
If your code is only used in one assembly, you might as well use const strings.
However, if your strings are used by other assemblies (or might be in the future), you should use static readonly strings for maintainability.
Also note that a const string is a compile-time constant.
If you need to incldue things like the machine name or username in the string, you need to make it static readonly.

A:
I don't understand what the performance implications are between the different declarations

The cost of evaluating the database query is probably going to be millions or billions of times the cost difference of changing from a constant to a readonly field or vice versa. Don't even worry about performance of something that takes a couple of nanoseconds when you have database operations that have latency measured in milliseconds.
What you should be worrying about is semantics, not performance. The question boils down to "readonly, constant or neither?"
Get the semantics right.  A "readonly" field means "this field changes exactly once per time this program is executed", from null to its value.  A "const" field means "this value never changes, not now, not in the next version, not ever, it is constant for all time."  An ordinary field can change value at any time.
A readonly field is something like a version number. It changes over time, but does not change over the execution of the program. A constant is something like pi, or the atomic number of lead; it is fixed, eternal, never changes. An ordinary field is good for something that changes over the course of the program, like the price of gold. Which is your query like?  Will it be constant throughout the course of this program, constant for all time, or not constant at all?

A: On const vs static readonly:
const can have better performance since it's a compiletime constant
But on the other hand it has problems with binary versioning. The constant gets inlined into the assembly that uses it, so if the assembly that declares it gets changed the other assembly needs to be recompiled or it will use an outdated constant.
For structs I typically use a static property instead of a readonly field, since the jitter can optimize it, but I still don't have versioning problems.

A: Speedwise the difference between public static string and public const string is negligible.
In IL it's a difference between
ldsfld someaddr.field

and
ldstr "your const here"

Here lies the answer though. By using const you're literally make your assembly to use that literal every time you use it, so the assembly will be ridden with those literals. With static the will be "pointers" to the central location.
The biggest gotcha lies in the following: you can't perfrom switch case against static strings, but you can against const (as you should).
So, my take on this: if you need to use switch - you have to use use const; if you don't - I'd prolly go with static.
HTH
Nikolai

A: Given that you're using Visual Studio, a small benefit for using public const over public static readonly is the ability to use IntelliSense to "peak" at the const value.
e.g.
Given:
public class Constants
{
     public const string ConstString = "Visible!";
     public static readonly string StaticReadonlyString = "Invisible!";
}


text:
Q: How to aggregate data by a dynamic time interval with psql I want to count every unique visitor.
A unique visitor is a visitor who did not visit less than an hour previously.
So for the following rows of users and timestamps we'd get a total count of 4 unique visitors with user1 and user2 counting as 2 respectively.
Please note that I do not want to aggregate by hour in a 24 hour day. I want to aggregate by an hour after the time stamp of the users first visit.
I'm guessing a straight up sql expression won't do it.
user1,"2015-07-13 08:28:45.247000"
user1,"2015-07-13 08:30:17.247000"
user1,"2015-07-13 09:35:00.030000"
user1,"2015-07-13 09:54:00.652000"
user2,"2015-07-13 08:28:45.247000"
user2,"2015-07-13 08:30:17.247000"
user2,"2015-07-13 09:35:00.030000"
user2,"2015-07-13 09:54:00.652000"

So user1 arrives at 8:28, that counts as one hit. He comes back at 8:30 which counts as zero. He then comes back at 9:35 which is more than an hour from 8:30, so he gets another hit. Then he comes back at 9:35 which is only 5 minutes from the last time 9:30 so this counts as zero. The total is 2 hits for user1. The same thing happens for user2 meaning two hits each bringing it to a final total of 4.

A: Here is one method:
select count(*)
from t
where not exists (select 1
                  from t t2
                  where t2.user = t.user and
                        t2.timestamp < t.timestamp and
                        t2.timestamp > t.timestamp - interval '1 hour'
                 );

EDIT:
If duplicate timestamps are a potential issue, you can use count(distinct user, timestamp).
Note:  user and timestamp are both keywords and user is reserved.  Hopefully your actual columns are named something else.
The where clause only keeps records where there is no other record for the user in the hour before.  That is your definition of a "new" user, so aggregating the count should be what you are looking for.

A: Corner cases in your definition aside (see comment), this query is many times faster than the one @Gordon provided in my local test on Postgres 9.4, with or without index:
SELECT count(ct)
FROM  (
   SELECT user_id, CASE WHEN lead(created_at, 1, 'infinity' )
                      OVER (PARTITION BY user_id ORDER BY created_at)
                 > created_at + interval '1h' THEN true ELSE NULL END AS ct
   FROM   tbl
   ) sub;

The core feature is the window function lead() looking up the "next" row for the current user. If the next row is more than an hour away, this row counts.
lead() has the often overlooked capability to provide a default for missing rows. Filling in 'infinity' to cover the corner case.
This query works for NULL values (not counted) or duplicate values (only 1 row counts) in the timestamp column created_at.
Key to top performance is a multicolumn index:
CREATE INDEX tbl(user_id, created_at);

For a bullet-proof definition of "unique visitor" different query styles might be superior.


text:
Q: THREE JS Mouse input Lag I am creating a game where mouse input delay should be minimal. However I have noticed when you alt tab to a different window (Notepad for example) and come back there seems to be a large delay of the mouse position. When I refresh the page it will work fine again. This may be an issue exclusive to THREEJS, however I don't know for sure. Sometimes is will lag even after I refresh, but ALT + TAB seems to trigger the problem all the time for me.
Here is the code that makes the object follow the mouse to illustrate the problem:
function onMouseMove(event) {
    event.preventDefault();
    mouse.x = (event.clientX / window.innerWidth) * 2 - 1;
    mouse.y = - (event.clientY / window.innerHeight) * 2 + 1;
    var vector = new THREE.Vector3(mouse.x, mouse.y, 0.5);
    vector.unproject( camera );
    var dir = vector.sub( camera.position ).normalize();
    var distance = - camera.position.z / dir.z;
    var pos = camera.position.clone().add( dir.multiplyScalar( distance ) );
    mouseMesh.position.copy(pos);
    mouseMesh.position.set(event.clientX, event.clientY, 0);
};

Here is a fiddle that shows the problem I am having: https://jsfiddle.net/atwfxdpd/10/
To replicate the issue, simply run the fiddle. Hit Alt+Tab to change to any other window on your computer. Click on said window. Then come back.
Now when you move the mouse, the object lags behind it. Sometimes it also does it when you first run it.
My version of chrome is: Version 55.0.2883.87 m (64-bit) (Latest)
I am on a 4K Screen. So that may have something to do with it.
EDIT: Resizing also seems to cause the issue


text:
Q: Windows 7 boot failure after Ubuntu 14.04 installation I installed Ubuntu 14.04 on my Acer netbook a week or two ago which ran Windows 7 before the Ubuntu installation. I know that my question isn't the first of it's kind but I'm not the most seasoned when it comes to Ubuntu, or Windows for that matter, installation or repair. From what I can tell I must have either partitioned my HDD incorrectly or installed Ubuntu or a part there of in a way that blocks grub from Windows 7. I have already attempted to repair grub using boot-repair (through Grub Customizer) and even though the repair via the repair report was successful I still can not boot Windows 7.
Here is the boot-repair report itself
http://paste.ubuntu.com/9553822/
I will keep reading through the already answered questions but for now any advice or help would be appreciated.
Thank you,
Eli

A: I don't claim to be expert interpreting the boot-repair reports, but I don't see a surviving windows partition, so I honestly don't think you have windows anymore.  If it helps I can tell you a lot of things to make you feel better about that, and I can offer significant assistance helping you to set up WINE such that you will actually be able to run windows software under ubuntu BETTER than it ever ran under windows.
Now, just in case I misread that boot-repair report, please open the Ubuntu utility known as "disk utility" to verify the windows partition still exists.  If it does, it ought to be possible to fix it with boot repair, although personally I disliked the version of boot repair you install on the drive you are trying to fix.  I recommend that which runs from a live boot CD, as that's the only type which has worked for me.
Personally I suspect that as many such complaints I've read, you accidentally wiped out your windows partition and there's no getting it back, short of a restore from a full backup.


text:
Q: Update column in table where a specific character appears I'm trying to update a table in my database where a specific character appears but can't get it to work correctly. So where '/' appears add an additional '/'.
I have added my code below.
Here is the table that I want to update.
Table1

FirstName
LastName
Address

Sam
Smith
25 /Long Lane/ Surrey

Desired Output:

FirstName
LastName
Address

Sam
Smith
25 //Long Lane// Surrey

SQL that isn't working:
I have the below update statement which isn't working. It just adds '/' a the start of the column which isn't correct. It is not getting me the desired output.
update table
set Address = '/' + Address
where Address like '%/%'

A: Seems simple enough:
(Assuming Microsoft SQL Server)
UPDATE yourtable
SET Address = REPLACE(Address, '/', '//')
WHERE Address Like '%/%';

However, you should consider what happens if you run this against an already-escaped value. Each // will be replaced with ////.

A: Why not REPLACE() instances of / with //…?
update table
set Address = REPLACE(Address, '/', '//')


text:
Q: Why does isFinite() return true for strings containing numbers? I have multiple arrays containing different data; some numbers and strings.
As I'm trying to filter through the array list I was expecting the strings to return false, (unfortunately) the last test case array is returning true.
I can't find any information easily which could explain why this happens.

function filter_list(l) {
  const filtered_l = l.filter(idx => isFinite(idx));
  console.log(filtered_l);
}

// test cases
filter_list([1,2,'a','b'])// == [1,2]
filter_list([1,'a','b',0,15])// == [1,0,15]

// this test case returns the strings too.
filter_list([1,2,'aasf','1','123',123])// == [1,2,"1","123",123] I expected [1,2,123]

A: Actually, isFinite() determine if a value is finite, and convert it to int or float if is necessary with parseInt or parseFloat, if u try parseInt with '123' the result will be 123 number but if u try with 'adf' for example the result will be NaN (Not a Number). You can use Number.isFinite('value') that is stronger and will cover your need.
Regards!


text:
Q: Include last commit index in project I'm working on a game project in Uninty with some friends, and since we're going to make each one his own branches i would like to include in the project some of the versioning info, e.g. to get track of the current build beeing tested, so i've tought to the current branch and commit index.
When i say "include in the project" i mean to display those info somwhere in the ui during gameplay.
I would like to do so to avoid using "custom version number" like ver.0.1.2 etc, because those versioning number are totally arbitrary and must be manually updated during development, while branches and commit are indipendent and automatic.
I'm currently working with SourceTree, so when i say "comomit index" i mean the short descriptor displayed in SourceTree under the Commit column, like in linked figure.
I've looked into the .git folder but i couldn't find the info I need.
Mine could not be the best idea ever, so i'm open to suggestion to get a unique identifier for the current build.
Anyone can help?
p.s.: i think my question is independent from the repository, the versioning software and the project itself, i'm not looking for a better versioning software or custom Unity solution.

A: Get the last tag in the branch: git describe --abbrev=0 --tags
Get the last commit's abbreviated id: git log -1 --format=%h; full commit id: git log -1 --format=%H.
Get the last commit's subject (first line): git log -1 --format=%s.
See git help log for the full list of available placeholders.


text:
Q: Date comparison Logic / in Liquid Template Filter I'm attempting to create a "Pre-Order" Like mechanic where certain elements of my Shopify Liquid Template only show if the current date is more or less than the date specified in a Metafield.
As of current this is what I have including logic:

Today: {{'now' | date: '%d-%m-%Y' }}

Release Date: {{ product.metafields.Release-Date.preOrder }}

{% assign today_date = 'now' | date: '%d-%m-%Y' %}

{% assign pre_date = product.metafields.Release-Date.preOrder %}
{% if today_date > pre_date %}
  Today's date is greater than PreOrder Date
{% else %}
  Today's date is not greater than PreOrder Date
{% endif %}

However, even when I set the PreOrder date to 01-01-2018 it still shows the "Is greater than".
How do I correctly query this?

A: You can't compare strings this way. (The dates are strings.)
You have to use the %s date filter instead.
So it will become:
{% assign today_date = 'now' | date: '%s' %}
{% assign pre_date = product.metafields.Release-Date.preOrder | date: '%s' %}
{% if today_date > pre_date %}

We use %s because it will return the current unix timestamp number instead of a string. This way you will be able to compare the different timestamps.


text:
Q: Trying to use df to find the shortest distance to all nodes from a source node in a directed graph def networkDelay(self,times,n,k):
    graph=collections.defaultdict(list)
    for u,v,w in times:
        graph[u].append((v,w))
    dist = [sys.maxsize] * (n + 1)
    dist[k] = 0
    visited=set()
    def dfs(graph,u,prev):
        visited.add((prev,u))
        for v,w in graph[u]:
            dist[v] = min(dist[v], dist[u] + w)
            if (u,v) not in visited:
                dfs(graph,v,u)
    dfs(graph,k,k)
    return dist[1:]

times[i] = (ui, vi, wi). //edge

times = [[2,1,1],[2,3,1],[3,4,1]], n = 4, k = 2

The above code works for almost all of the cases, but
failing for below test
Input
times= [[2,7,63],[4,3,60],[1,3,53],[5,6,100],[1,4,40],[4,7,95],[4,6,97],[3,4,68],[1,7,75],[2,6,84],[1,6,27],[5,3,25],[6,2,2],[3,7,57],[5,4,2],[7,1,53],[5,7,35],[4,1,60],[5,2,95],[3,5,28],[6,1,61],[2,5,28]]
n=7,k=3

Result
dist[]=[90, 123, 0, 30, 28, 117, 57]. // 123 should be 119

Could someone help identifying what's wrong with the above program?

A: def networkDelay(self,times,n,k):
    graph=collections.defaultdict(list)
    for u,v,w in times:
        graph[u].append((v,w))
    dist = [sys.maxsize] * (n + 1)
    dist[k] = 0
    def dfs(graph,u):
        for v,w in graph[u]:
            if dist[u]+w<dist[v]:
                dist[v] = dist[u] + w
                dfs(graph,v)
    dfs(graph,k)
    mx=max(dist[1:])
    return mx if mx<sys.maxsize else -1


text:
Q: Facebook API redirect after post is made, not during/before Alright, I have this piece of code, straight from the documents which works fine if I leave the setTimeout out of the equation of which redirects a user to where I want them on my service there after.
However if I put the setTimeout in, during the process of the post actually occuring, or right before (not sure which) either way a race condition is created where the post never gets made, and the script redirects accordingly. I am wondering is there another method of handling this where I know the post did/didn't actually make it then redirect. Or how do others handle this situation?
FB.api('/me/feed', 'post', obj.data.fb_post, function(response) {
    console.log(response);
    if (!response || response.error) {
        alert('Error occured');
    } else {
        //setTimeout(function(){window.location = obj.data.whereTo;}, 3000);
    }
});


text:
Q: Install scipy and numpy on Win 64 machine (python 2.7) I know there have been questions similar to this one before - I read them all and tried what they suggested
Hi,
I'm trying to install the scipy and numpy modules on my win 64 machine so I could call them from my IDE of choice. Alas, all my efforts were in vein.
Here's what I tried:
1) according to this thread I tried installing with pip. Even though the comments praise the solution is one with longevity, when I ran
pip install git+http://github.com/scipy/scipy/

I got an error:
C:\Python27>pip install git+http://github.com/scipy/scipy/
Downloading/unpacking git+http://github.com/scipy/scipy/
  Cloning http://github.com/scipy/scipy/ to c:\users\____\ap
\pip-vguqfv-build
Cleaning up...
Cannot find command 'git'
Storing debug log for failure in C:\Users\____\pip\pip.log

and when I tried:
pip install git+http://github.com/scipy/scipy/

I got:
Downloading/unpacking scipy
  Running setup.py (path:c:\users\XXXX\appdata\local\temp\pip_build_XXXX
\scipy\setup.py) egg_info for package scipy

    warning: no previously-included files matching '*_subr_*.f' found under dire
ctory 'scipy\linalg\src\id_dist\src'
    no previously-included directories found matching 'doc\build'
    no previously-included directories found matching 'doc\source\generated'
    no previously-included directories found matching '*\__pycache__'
    warning: no previously-included files matching '*~' found anywhere in distri
bution
    warning: no previously-included files matching '*.bak' found anywhere in dis
tribution
    warning: no previously-included files matching '*.swp' found anywhere in dis
tribution
    warning: no previously-included files matching '*.pyo' found anywhere in dis
tribution
Installing collected packages: scipy
  Running setup.py install for scipy
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "c:\users\XXXX\appdata\local\temp\pip_build_XXXX\scipy\setup.
py", line 237, in <module>
        setup_package()
      File "c:\users\XXXX\appdata\local\temp\pip_build_XXXX\scipy\setup.
py", line 225, in setup_package
        from numpy.distutils.core import setup
    ImportError: No module named numpy.distutils.core
    Complete output from command C:\Python27\python.exe -c "import setuptools, t
okenize;__file__='c:\\users\\XXXX\\appdata\\local\\temp\\pip_build_XXXX\
\scipy\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().
replace('\r\n', '\n'), __file__, 'exec'))" install --record c:\users\XXXX\ap
pdata\local\temp\pip-xpcgro-record\install-record.txt --single-version-externall
y-managed --compile:
    Traceback (most recent call last):

  File "<string>", line 1, in <module>

  File "c:\users\XXXX\appdata\local\temp\pip_build_XXXX\scipy\setup.py",
 line 237, in <module>

    setup_package()

  File "c:\users\XXXX\appdata\local\temp\pip_build_XXXX\scipy\setup.py",
 line 225, in setup_package

    from numpy.distutils.core import setup

ImportError: No module named numpy.distutils.core

----------------------------------------
Cleaning up...
Command C:\Python27\python.exe -c "import setuptools, tokenize;__file__='c:\\use
rs\\XXXX\\appdata\\local\\temp\\pip_build_XXXX\\scipy\\setup.py';exec(co
mpile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __
file__, 'exec'))" install --record c:\users\XXXX\appdata\local\temp\pip-xpcg
ro-record\install-record.txt --single-version-externally-managed --compile faile
d with error code 1 in c:\users\XXXX\appdata\local\temp\pip_build_XXXX\s
cipy
Storing debug log for failure in C:\Users\XXXX\pip\pip.log

2) Tried to grab the 64 bit installers from Christoph Gohlke's page like so many places suggest, including scipy.org itself, but I tried multiple times, from multiple machines at multiple locations, the downloads always ultimately failed.
3) Installed Anaconda. Scipy and Numpy are available in IPython now, which is better than nothing but in all honestly I'm not used to the IPython interface and like pyscripter better. Even though I can import Scipy and Numpy alright in IPython, I can in pyscripter or even in the cmd console. Similar results with Canopy, where it's only available within the Canopy IDE.
4) Can't download the binaries directly from sourceforge (e.g. scipy on sourceforge), as they are all for win 32.
So, to get to my question..... what can I do (if anything?).
Would appreciate your help.
Thanks!

A: I recommend using Winpython or Python (x,y). These distributions provide full functionality for your purpose, have all neccessary packages precompiled (I you install them via pip, you need to compile C and Fortran code) and the packages included are all checked for compatibility with each other.


text:
Q: Cursor moves slightly during trackpad click I've noticed this on a few laptops, but this question is specifically for the Dell XPS 13 with the precision touchpad. Often if I attempt to click using the trackpad, the cursor will move slightly during the click. This causes the cursor to select the wrong item. It only seems to move about 10 pixels or less, but it's often enough to cause a click at the wrong location. Is there a setting to fix this, or to change the sensitivity? I do not have this problem on my current laptop with Synaptics drivers.

A: I'm not aware that Microsoft has provided any controls to tune that kind of behavior.
Looking at some images, it looks like that touchpad is a "clickpad" meaning you "click" by pressing the whole touchpad down, which sounds like the issue you are having.
A possible workaround is to use a different finger to click, than the one you are using to move the cursor.  Generally, you can press with a second finger and it doesn't change the effect of the first finger, and even keep the extra finger resting over the button area.
It is probably most intuitive to press in the lower left touchpad area (southwest) for left ie primary click, and in the right (southeast) for right ie secondary cick, but generally, any click that is not southeast will result in primary click.


text:
Q: Hard to debug "Mysql server has gone away" I'm running a MsAccess with Mysql background database and today I am experiencing some problems.
Depending on how far I can get into the program I am able to get a list of all the names and entry. But once I go into the edit form of any entry I get a variety of results. Sometimes I am lucky and I can see the first entry. But any entry after that will always get a MsAccess error: Object invalid or no longer set and then any subsequent calls after will yield a Mysql ODBC error of Mysql server has gone away.
I've looked around at several websites and even all the stack overflow sites with the same question and I've tried a variety of solutions. (Keep in mind that this database has been running for years and this is the first time I am getting this message) It also takes about 2m14s to 2m59s before it displays any error messages.
Here is what I tried so far:

*

*I've tried changing a few of the ODBC connection settings.

*

*Checked Allow Big Results - FAILED

*Checked Enable Auto Reconnect - FAILED

*I've Checked and repaired tables - FAILED

*

*A good number of tables resulted in, "table needs update please repair table"

*I've Doubled the numbers in the my.cnf configuration and restarted the mysql service as well as the msaccess software. FAILED

*

*These were the settings of my my.cnf after I made the changes.

Here:
set-variable = max_connections=500
safe-show-database
log-error=/var/log/mysqld.log
connect_timeout=1000
interactive_timeout=28800
wait_timeout=288000          <**This was changed**

join_buffer_size=6M
key_buffer_size=300M         <**THIS WAS CHANGED **
max_allowed_packet=300M      <**THIS WAS CHANGED **
myisam_sort_buffer_size=300M <**THIS WAS CHANGED **
read_buffer_size=6M
sort_buffer_size=6M
table_cache=12288
thread_cache_size=24
tmp_table_size=132M
query_cache_limit=3M
query_cache_size=64M
query_cache_type=1

Basically I've tried every suggestion I could find so far and I can't seem to figure out the problem.
I've also had a look at MYSQL: Has gone away
If I go through the bulleted list there

*

*Nobody has killed the running thread

*I don't think the query was ran after the connection was closed (since it ran for years fine)

*Client application does have the privileges needed

*I don't know how to figure out if I had a timeout from the TCP/IP connection on client side

*I don't know if I've encounted a timeout on the server side, but I do know that automatic reconnection in client is disabled

*???

*The query could potentially be large since it is a form with many subforms

*???

*DNS should be ok, since I can connect to it with a real sql viewer (HeidiSQL)

*???Child forks???

*???

I think this is one of those bugs that is hard to figure out since I'm exhausted :/ I'm probably missing some info but I am not sure what else to include.
---EDIT---
Thank you all for your comments, I'm still debugging this issue. It seems that it's not all the forms that are causing some issues. So I'm starting to think that this is a MSAccess issue more than it is an MySql issue. The forms that do break all have the same line in their VBA code:
Private Sub Form_Error(DataErr As Integer, Response As Integer)
    If Screen.ActiveControl.Name = "UnboundTextBox" Then
       Response = acDataErrContinue
    End If
End Sub

I don't recall putting this code in, so I assume it's an automatic thing, but I'm still going through all my forms to see which ones cause this error and which do not. So more in a few.
---Today I'm doing some debugging trying to find whatever I can from whatever log I can muster ----
 MSACCESS        17ec-b10   EXIT  SQLStatisticsW  with return code -1 (SQL_ERROR)
    HSTMT               0AF82920
    WCHAR *             0x00000000 [      -3] <empty string>
    SWORD                       -3
    WCHAR *             0x00000000 [      -3] <empty string>
    SWORD                       -3
    WCHAR *             0x0013AAE8 [      -3] "location\ 0"
    SWORD                       -3
    UWORD                        1 <SQL_INDEX_ALL>
    UWORD                        0 <SQL_QUICK>

    DIAG [08S01] [MySQL][ODBC 3.51 Driver][mysqld-5.0.92-community]Lost
 connection to MySQL server during query (2013)

----------------------------- FINAL EDIT --------------------------
The past week or so, my boss has been working hard to install a new internal server for our office. We also switched IPs several times and ISP providers. Turns out, as a result he created for me an administrative nightmare, as I attempted to debug issues with the server, and issues with the software ect.. ect.. when the issue was in the settings the ISP providers established with the router settings etc... etc... SO basically this whole headache was nothing wrong with server, nor software but hardware inbetween.
So now, I have to backwards engineer everything I did and try to get it to work on both ips. It works on the important one now. But it's not working on the old one so... I guess I just have to figure that out. [Waving imaginary fist in the air] Lol

A: The problem is that the connection is timing out. This is not a setting that you can change at the ODBC level. My MySQL provider had set the timeout at 30 seconds (you can find out what yours is set at my running the PassThrough query "SELECT @@wait_timeout"). I got round it by polling the connection every 10 seconds with a simple form. That keeps the connection alive. Make sure you have an AutoExec macro which opens the form.
Private Sub Form_Open(Cancel As Integer)
    Me.TimerInterval = 1000 ' 10 seconds
End Sub

Private Sub Form_Timer()
    Me.Requery
End Sub

A: I have not used MySQL with Access in a production environment, but the problem you are having sounds suspiciously similar to one I've encountered with SQL Server. Basically, if the client workstation has incorrect DNS settings, it can get confused about how to resolve the connection to the SQL Server and lose the connection. In the cases where I've encountered this, the workstations were incorrectly configured with the Internet provider's DNS as primary DSN, but the SQL Server was a local server, available only on the local LAN (and not mapped by the ISPs DNS).
The solution is to use the local domain controller as the primary DNS. It will look up the local SQL Server's IP and pass off any non-local lookups to the Internet provider's DNS.
If you don't have a Windows/Samba domain controller, then you need to use whatever the local LAN's authorative name server is. Alternatively, you could connect to the MySQL server by IP address and avoid the problem, or map it in the client workstation's HOSTS file (which is not recommended -- it's a great way to cause really hard to troubleshoot problems when the IP addresses change).

A: [mysqld-5.0.92-community]Lost
connection to MySQL server during query (2013)

This genary means you have found a bug in MySQL-Server
can you post a tail of your mysqld.err and mysqd.log
this makes the server restart and will effectefly shut down all open connections


text:
Q: What is the right way to sort my ArrayList? I have a custom class called "ergebnisse" with several fields, one of them is score of type Long.
I want to sort an ArrayList<ergebnisse> by score.
I tried a lot of things, but most most are fore one or two columns.
ArrayList<ergebnisse> list = new ArrayList<ergebnisse>();
Cursor data = mDatabaseHelper.fetchNamesByConstraint(filter);
while(data.moveToNext()){
    //get the value from the database in column 1
    //then add it to the ArrayList
    String name = data.getString(1);
    String scorestring = data.getString(2);
    Long score=Long.parseLong(scorestring);
    String timestring = data.getString(3);
    Double time= Double.parseDouble(timestring);
    String mode = data.getString(5);
    String game = data.getString(4);
    String levstring = data.getString(6);
    Integer lev=Integer.parseInt(levstring);
    list.add(new ergebnisse(name,score,time,mode,lev,game));
}

I want to sort from highest to lowest score.

A: You can pass a custom comparison function to sort:
Collections.sort(
    list,
    (a, b) -> Integer.compare(b.score, a.score)
);

You'll notice b.score is the first arg to Integer.compare. That reverses the meaning of the comparison so that the list will be in descending order.

A: For example, if we have a class:
  private class Person{
    private String name;
    private Long score;
  }

Then we can compare like:
list.sort(Comparator.comparing(Person::getScore));

or
list.sort((person1, person2) -> person1.getScore().compareTo(person2.getScore()));

A: This can be done in many ways.
Method 1(Traditional):
your custom class
public class Ergebnisse {

    private String name;
    private Long score;

   //standard getters and setters
}

implement comparator interface by overriding compare method
class SortbyScore implements Comparator<Ergebnisse> {
    @Override
    public int compare(Ergebnisse a, Ergebnisse b) {
    return b.getScore() - a.getScore();
    }
}

Then whenever you want list to be sorted by score use
Collections.sort(list, new SortbyScore());

Method 2(Java 8 or above):
Simply use lambda expresson
list.sort((o1, o2) -> o2.getScore().compareTo(o1.getScore()));

*Do note that its important to use wrapper class of primitive type long(Long) to store score variable for this to work!


text:
Q: Augment Reality for Android I have quite strange augment reality case to implement. Most AR frameworks I've found can be classified on 2 groups:

*

*GPS based ones

*Based on visual markers (something like a QR code) located in real world.

Basically here is a list:

*

*AndAr    https://code.google.com/p/andar/

*Mixare https://code.google.com/p/mixare/

*DroidAr https://code.google.com/p/droidar/
But this does not fit my case, in simple words, I do need to place visual marker flying in a room near by one or several physical assets. I do have all needed coordinates, but I don't sure how I can show marker flying 2 meters in front of a phone, because all above mentioned frameworks positioning api based on degrees, minutes and seconds. Don't sure how I can correlate those 2 coordinates system.

A: I use BeyondAR for this. is small, simple, free and open source.

A: The Wikitude SDK allows you to put markers (so called GeoObjects) relative to a position. The position could be the user's position or any position defined by latitude, longitude, altitude (in your case this could be the initial user's position). The relative position is defined in meters north/east of the initial position.
For more information have a look at the documentation at: http://www.wikitude.com/external/doc/documentation/3.0/Reference/JavaScript%20Reference/index.html
It includes both Geo-based AR and Image Recognition & Tracking.
Disclaimer: I'm working for Wikitude

A: I use BeyondAR for this. is small, simple, free and open source. Here the linke
BeyondAR Framework


text: Q: Decreasing the Size of Mediator I am using mediator pattern with 10 clients. It happens that the mediator class size go beyond three digit numbers. I think it is a bad practice to have such big classes. Is this size an indication of using false design pattern? Do you have any recommendation to decrease the code size of this single mediator? Other design pattern recommendations are welcomed as well.


text:
Q: Is the function differentiable at $0$?
Let $$f(x) = \begin{cases}\begin{align*}&\cos{\dfrac{1}{x}}, &x \neq0 \\ &0, &x=0. \end{align*}\end{cases}$$
Is the function $F(x) = \displaystyle \int_{0}^x f dx$ differentiable at $0$?

We can see that the function $f(x)$ is continuous everywhere except $x=0$. In order to show differentiability we will need to show the derivatives from the left and right are equal. So we need to show that $$\lim_{h \to 0^+} \dfrac{F(x+h)-F(x)}{h} = \lim_{h \to 0^-} \dfrac{F(x+h)-F(x)}{h}.$$ The derivative from the right is $$\lim_{h \to 0^+} \dfrac{F(x+h)-F(x)}{h} = \lim_{h \to 0^+} \dfrac{\displaystyle \int_{0}^x\cos{\dfrac{1}{x+h}}-\int_{0}^x\cos{\dfrac{1}{x}}}{h}$$ and the derivative from the left is $$\lim_{h \to 0^-} \dfrac{F(x+h)-F(x)}{h} = \lim_{h \to 0^-} \dfrac{\displaystyle \int_{0}^x\cos{\dfrac{1}{x+h}}-\int_{0}^x\cos{\dfrac{1}{x}}}{h}.$$ I am not sure how to proceed.

A: The problem is slightly tricky because we don't know the anti-derivative of $\cos (1/x)$ but we do know that function $g(x) = x^{2}\sin(1/x), g(0) = 0$ is continuous and differentiable for all $x$ and $$g'(x) = 2x\sin (1/x) - \cos(1/x),g'(0) = 0$$ and hence $$g(h) = \int_{0}^{h}(2t\sin (1/t) - \cos (1/t))\,dt$$ or $$\int_{0}^{h}\cos(1/t)\,dt = 2\int_{0}^{h}t\sin(1/t)\,dt - g(h)$$ and hence
\begin{align}
F'(0) &= \lim_{h \to 0}\frac{1}{h}\int_{0}^{h}\cos(1/t)\,dt\notag\\
&= \lim_{h \to 0}\frac{2}{h}\int_{0}^{h}t\sin(1/t)\,dt - \frac{g(h)}{h}\notag\\
&= 2\lim_{h \to 0}\frac{1}{h}\int_{0}^{h}t\sin(1/t)\,dt\notag\\
\end{align}
Now $t\sin(1/t)$ has a removable discontinuity at $t = 0$ and its limit is $0$ as $t \to 0$ hence by Fundamental Theorem of Calculus the limit $$\lim_{h \to 0}\frac{1}{h}\int_{0}^{h}t\sin(1/t)\,dt$$ above is $0$ and therefore $F'(0) = 0$.

A: For $x\geq 0$, let $[x]$ denote the largest element of $\mathbb{Z}\pi+\pi/2$ not greater than $x$.
$$\left|\int_0^x \cos(1/t)dt\right|=\left|\int_{1/x}^\infty \frac{ \cos(t)}{t^2}dt\right|\leq \left|\sum_{n=0}^\infty\int_{[1/x]+n\pi}^{[1/x]+(n+1)\pi}\frac{ \cos(t)}{t^2}dt\right|\leq \left|\int_{[1/x]}^{[1/x]+\pi}\frac{ \cos(t)}{t^2}dt\right|\leq$$
$$\left| [1/x]^{-2}\int_{[1/x]}^{[1/x]+\pi}\cos(t)dt\right|= 2[1/x]^{-2}\leq 2(1/x-\pi)^{-2}\leq cx^{2}$$
for some $c>0$ and all small enough $x$.
So $|F(x)|$ goes to zero like $x^2$ as $x\rightarrow 0^+$.  So it has a right derivative which is zero. By symmetry the left derivative is also zero.

A: What you have is the derivative of f, not the derivative of F which is what you want.  The derivative of F at x= 0, from the right, is $\lim_{h\to 0^+}\frac{F(h)- F(0)}{h}= \lim_{h\to 0^+}\frac{\int_0^h f(t)dt}{h}$.

A: Since $\cos(1/x)$ is an even function, it suffices to compute
$$\lim_{h\to0^+}{1\over h}\int_0^h\cos(1/x)\,dx=\lim_{k\to\infty}k\int_k^\infty{\cos x\over x^2}\,dx=\lim_{k\to\infty}\left(-{\sin k\over k^2}-k\int_k^\infty{\sin x\over x^3}\,dx \right)$$
Now $\lim_{k\to\infty}(\sin k/k^2)=0$ and
$$\left|k\int_k^\infty{\sin x\over x^3}\,dx \right|\le k\int_k^\infty{dx\over x^3}={k\over2k^2}={1\over2k}\to0$$
It follows that $F'(0)=0$.


text:
Q: What's the best way to geolocate a walkie talkie broadcasting on FRS channels using a UAV? I'm researching methods to geolocate a fixed walkie talkie broadcasting on FRS channels. I need  to detect its location using a UAV. The UAV is fixed-wing, so it can not remain stationary. From what I've read so far, it seems like the best way to do this is probably to fly a pattern,  periodically take measurements of the signal strength and use trilateration to get a location to some accuracy. Can anyone give details on whether they think this is the best method, or if they would recommend a different method? What kind of location accuracy could I expect to have with that method? Are there any outside resources you could recommend related to this?
Thanks.

A: At ~460 MHz, a wavelength is less than 1 meter -- small enough to detect phase differences between multiple antennas at spacings that could be supported by a UAV.
From the phase differences between multiple antennas, you can calculate the direction to the source.  When you're far away, you could fly towards it.  When you get close enough to be mostly above the source, the direction vector will point to a spot on the ground, indicating the location.  Alternatively, if you fly around it enough to get significantly different directions, you can triangulate the location.  You'll have to get pretty close either way, since you can't expect the direction to be super accurate.


text:
Q: How to select multiple container in flutter? For now I'm able to select one item at a time but I want to select multiple item. I found some package for multiple selection, but want to achieve without using any packages.

  int? selectedIndex;
  final List<String> _wordName = [
    "Engaged in my Life",
    "Feel Alive",
    "Happy",
    "Love my Life",
  ];

GridView.builder(
                      scrollDirection: Axis.vertical,
                      gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
                        crossAxisCount: 2,
                        crossAxisSpacing: 3,
                        mainAxisSpacing: 2,
                        childAspectRatio: (16 / 8),
                      ),
                      itemCount: _wordName.length,
                      itemBuilder: (context, index) {
                        return GestureDetector(
                          onTap: () {
                            setState(() {
                              print("now selected ===>>> $index");
                              selectedIndex = index;
                              showButton = true;
                            });
                          },
                          child: Container(
                            margin: EdgeInsets.all(10),
                            decoration: BoxDecoration(
                              color: selectedIndex == index
                                  ? Color(0xffDEB988).withOpacity(0.2)
                                  : Color(0xffF4F4F6).withOpacity(0.5),
                              borderRadius: BorderRadius.circular(5.0),
                              border: Border.all(
                                  color: selectedIndex == index
                                      ? Color(0xffDEB988)
                                      : Colors.transparent,
                                  width: 0.5),
                              image: const DecorationImage(
                                image: AssetImage('assets/images/bg2.png'),
                                fit: BoxFit.cover,
                              ),
                            ),
                            child: Row(
                              children: [
                                Flexible(
                                  child: Center(
                                    child: Text(
                                      _wordName[index].toUpperCase(),
                                      textAlign: TextAlign.center,
                                      style: TextStyle(
                                        color: selectedIndex == index
                                            ? Color(0xffDEB988)
                                            : Colors.black,
                                        fontWeight: selectedIndex == index
                                            ? FontWeight.bold
                                            : FontWeight.normal,
                                        fontFamily: "Poppins",
                                      ),
                                  }

A: You can have selected items in an array
Example:
List<int> selectedItems = [];

GestureDetector(
   onTap: () {
     setState(() {
        if (selectedItems.contains(index)){
           selectedItems.remove(index);
        } else {
           selectedItems.add(index);
        }
     }
   },
   child: Container(
       color: selectedItems.contains(index) ? Colors.red : Colors.blue,
       child: Something(),
   ),
),

A: Use a list to store the selected indexes
final List<int> selectedIndexes = [];
  final List<String> _wordName = [
    "Engaged in my Life",
    "Feel Alive",
    "Happy",
    "Love my Life",
  ];

GridView.builder(
                      scrollDirection: Axis.vertical,
                      gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
                        crossAxisCount: 2,
                        crossAxisSpacing: 3,
                        mainAxisSpacing: 2,
                        childAspectRatio: (16 / 8),
                      ),
                      itemCount: _wordName.length,
                      itemBuilder: (context, index) {
                        return GestureDetector(
                          onTap: () {
                            setState(() {
                              if(selectedIndexes.contains(index)){
                                selectedIndexes.remove(index);
                              } else {
                                selectedIndexes.remove(index);
                              }
                              showButton = true;
                            });
                          },
                          child: Container(
                            margin: EdgeInsets.all(10),
                            decoration: BoxDecoration(
                              color: selectedIndex == index
                                  ? Color(0xffDEB988).withOpacity(0.2)
                                  : Color(0xffF4F4F6).withOpacity(0.5),
                              borderRadius: BorderRadius.circular(5.0),
                              border: Border.all(
                                  color: selectedIndex == index
                                      ? Color(0xffDEB988)
                                      : Colors.transparent,
                                  width: 0.5),
                              image: const DecorationImage(
                                image: AssetImage('assets/images/bg2.png'),
                                fit: BoxFit.cover,
                              ),
                            ),
                            child: Row(
                              children: [
                                Flexible(
                                  child: Center(
                                    child: Text(
                                      _wordName[index].toUpperCase(),
                                      textAlign: TextAlign.center,
                                      style: TextStyle(
                                        color: selectedIndex == index
                                            ? Color(0xffDEB988)
                                            : Colors.black,
                                        fontWeight: selectedIndex == index
                                            ? FontWeight.bold
                                            : FontWeight.normal,
                                        fontFamily: "Poppins",
                                      ),
                                  }


text:
Q: How the intelisense for std::make_shared() know the default constructor arguments? Is it Visual Studio or C++? If C++, how can I implement it myself std::make_shared() is used to construct an object directly as shared_ptr and to call the constructor of given type it takes the arguments of the type's constructor. How can it know the arguments and definitions of the type's constructors? when using templates and ... operator visual studio intellisense can't show the definitions of type's constructors but will only show the generic definition of template, but std::make_shared() can show the precise definition of the constructors. is it a feature of visual studio intellisense and specific for standard library functions or is it something I couldn't guess in c++ implementation of std::make_shared()? is so, how can I recreate it?
template<typename T, typename... types>
std::shared_ptr<T> my_make_shared(types... args) {
    return std::shared_ptr<T>(new T(args...));
}

here is how it looks like for std::make_shared()
std::make_shared()'s intellisense
here is how it looks like for my example my example's intellisense

A: The feature is hard coded into intellisense. You could refer to the release note.

Added completion for make_unique, make_shared, emplace and
emplace_back which provides completion based on the type parameter
specified.

Below is  intellisense in Visual Studio 2017.


text:
Q: Curious behavior of java.awt.Component, setVisible(), LayoutManager I was trying to create a GUI and found some curious behavior of java.awt.Component. I wanted to setVisible(true)/setVisible(false) an java.awt.Component by an external Event. But this only works when the to be switched Component was already visible in the first place. Attached, I provided a minimal replica of my problem.
package test;

import java.awt.Button;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.Menu;
import java.awt.MenuBar;
import java.awt.MenuItem;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

public final class Test {
    public static void main(String[] args) {
        Button testButton = new Button("Test Button");
        testButton.setVisible(false); /* Removing this line makes the code to work as intended, but why? */

        Frame mainFrame = new Frame("Test");
        mainFrame.setMinimumSize(new Dimension(640, 480));
        mainFrame.setVisible(true);
        mainFrame.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent event) {
                System.exit(0);
            }
        });

        mainFrame.add(testButton);

        mainFrame.setMenuBar(new MenuBar());
        mainFrame.getMenuBar().add(new Menu("Test"));
        mainFrame.getMenuBar().getMenu(0).add(new MenuItem("Show/Hide \"Test Button\""));
        mainFrame.getMenuBar().getMenu(0).getItem(0).addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {
                if(testButton.isVisible()) testButton.setVisible(false);
                else testButton.setVisible(true);
                System.out.println("testButton.getBounds()" + testButton.getBounds()); /* EDIT: Added this line for debugging. */
                System.out.println("testButton.isVisible() " + testButton.isVisible());
            }
        });
    }
}

When you remove line testButton.setVisible(false);, testButton is viewable and also switchable in its state of visibility, otherwise not. Does anyone know why? Maybe the layout-manager doesn't work with invisible components?
EDIT: It seems the layout-manager doesn't setBounds(...) for invisible components, but why?

A:
Maybe the layout-manager doesn't work with invisible components?

Correct, it depends on the rules of the layout manager.
For example the FlowLayout and BoxLayout, ignore invisible components when doing the layout. However, a GridLayout will reserve space.
When using Swing changing a property of a component should automatically invoke the layout manager. So invoking setVisible() should cause a new layout.
However, if layout is not done automatically then you would use code like:
testButton.getParent().revalidate();

I haven't used AWT for over a decade now but as I recall AWT is not as smart as Swing so you need to use:
testButton.getParent().validate();

after setting the visible state of the button. At least it works in the MRE you provided.


text:
Q: For nested list my app crashes while generating pdf in flutter I am using pdf package for creating a PDF file in my app. I am trying to show transaction list of a month based on day. I was able to create pages for the first list using Wrap() widget. But for the inner transaction list it shows me error for more then 8 element. It doesn't break page automatically for list overflow.
So is there any solution for this problem?
Here is my code
class PdfParagraphApi {
static Future<File> generate(title) async {
final pdf = Document();

final customFont = Font.ttf(await rootBundle.load('assets/OpenSans-Regular.ttf'));

pdf.addPage(
  MultiPage(
    build: (context) => <Widget>[
      Wrap(
        children: List<Widget>.generate(7, (index) {
          return Container(
            margin: EdgeInsets.only(top: 3),
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Header(child: Text(
                  "08 Sep, 2021",
                  style: TextStyle(
                    color: PdfColors.purple300,
                    fontWeight: FontWeight.bold,
                    fontSize: 17
                  )
                  )),
                  ///////////////////////// error starts here ////////////////
                Container(
              child: Wrap(
                children: List<Widget>.generate(9, (ind) {
                return cards();
                }))
                 ////////////////////////////////////////////////////////
               )
              ]
            )
          );
        })
      )
    ],

  ),
);
return PdfApi.saveDocument(name: 'my_example.pdf', pdf: pdf);
}

static Widget cards() => Container(
    decoration: BoxDecoration(
      color: PdfColors.grey300,
      borderRadius: BorderRadius.circular(5)
    ),
    margin: EdgeInsets.only(bottom: 8),
    child: Container(
      // width: 300,
      margin: EdgeInsets.all(8.0),
      child: Row(
        crossAxisAlignment: CrossAxisAlignment.center,
        children: [
          Flexible(
            child: Container(
              margin: EdgeInsets.only(left: 10),
              child: Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                crossAxisAlignment: CrossAxisAlignment.center,
                children: [
                  Container(
                    child: Column(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        Container(
                          child: Text(
                            "VISA",
                            style: TextStyle(
                              fontSize: 16
                            )
                          ),
                        ),
                        SizedBox(height: 5),
                        Container(
                          child: Text(
                            "Token: 435645tRER3  Time: 12:45",
                          ),
                        ),
                      ],
                    ),
                  ),
                  Container(
                    child: Column(
                      mainAxisAlignment: MainAxisAlignment.spaceAround,
                      crossAxisAlignment: CrossAxisAlignment.end,
                      children: [
                        Row(
                          children: [
                            Text(
                              "GBP 56.07",
                              maxLines: 1,
                              style: TextStyle(
                                fontWeight: FontWeight.bold
                              )
                            ),
                            Text(
                              // " - ${charge.refundDetails.refundedAmount}",
                              " - 45.87",
                              style: TextStyle(
                                fontSize: 12,
                                color: PdfColors.red,
                              ),
                            )
                          ],
                        ),
                        SizedBox(height: 5),

                        Text(
                          "refunded",
                          style: TextStyle(
                              color: PdfColors.green),
                        ),
                        SizedBox(height: 5),
                        Text(
                           "Captured",
                        ),
                      ],
                    ),
                  ),
                ],
              ),
            ),
          ),
        ],
      ),
    ),
  );

}


text:
Q: 'RLMException', reason: 'Opening Realm files of format version 11 is not supported by this version of Realm' I am trying to login into realm but it keeps throwing the RLMException error.
This my pod file
# Uncomment the next line to define a global platform for your project
platform :ios, '9.0'

target 'App' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!

# Pods for App
pod 'RealmSwift'

target 'AppUITests' do
  # Pods for testing
end

end

This is the login function
func login(){

    let usernameCredentials = SyncCredentials.usernamePassword(username: "user", password: "password")
    // Create the configuration
    let syncServerURL = URL(string: "realms://jaffjf.faf.cloud.realm.io/default")!
    SyncUser.logIn(with: usernameCredentials, server: syncServerURL) { user, error in
            if let user = user {
                print("logged in",user)
                 let config = user.configuration(realmURL: syncServerURL);

            // Open the remote Realm
            let realm = try! Realm(configuration: config)

              Realm.asyncOpen(configuration: config) { realm, error in
                        if let realm = realm {

                            let results = realm.objects(Temp.self)
                            print("This is the results......", results)

                        } else if let error = error {

                            print("No realm found....")
                        }
                    }

        } else if let error = error {

        }
    }

Terminating app due to uncaught exception 'RLMException', reason: 'Opening Realm files of format version 11 is not supported by this version of Realm'
*** First throw call stack:

what is causing the error and how can I fix it?

A: This error indicates you need to be using Realm Cocoa 5.4.x, at this moment in time the latest version is 5.4.5.

A: Just open finder of file path and remove realm files.
Then build you project again.
I resolved same problem this way.


text:
Q: Center a large table and make text fit in a cell I have created two tables but I can't make them look as I desire, and also they are larger than the page margins so they aren't even centered. I want them to look like the pictures attached, but can't make it work. Well the first table I think is relatively ok, just only I would like to center it, and if there is any way that I could center the content of an entire column?
The second table has given me more trouble.

Table 1:
\begin{table}[htb]
\centering
\begin{tabular}{|l|l|l|l|}
\hline
\multirow{5}{2cm}{Casos Aceptables} & Casos & N\'umero de tarjetas & Porcentaje\\ \cline{2-4}
& \'Optimos & 49 & 49\% \\ \cline{2-4}
& Errores atribuibles al OCR & 9 & 9\%\\ \cline{2-4}
& Errores atribuibles a la tarjeta & 15 & 15\%\\ \cline{2-4}
& Total & 73 & 73\% \\ \cline{2-4} \hline
Casos no aceptables & No Aceptables & 27 & 27\% \\ \cline{1-4}
& Total & 100 & 100\% \\ \cline{2-4} \hline
\end{tabular}
\caption{Tabla 1.}
\label{tabla:final}
\end{table}

Table 2:
\begin{table}[htb]
\centering
\begin{tabular}{|l|l|l|l|}
\hline
\multirow{4}{2cm}{Casos Aceptables} & Casos & Error en caracteres & Tipo de Error\\ \cline{2-4}
& \'Optimos & Error menor al 4\% & Caracteres \\ \cline{2-4}
& Errores atribuibles al OCR & Error menor al 8\% & Caracteres\\ \cline{2-4}
& Errores atribuibles a la tarjeta & Error menor al 5\% & Caracteres e informaci\'on en los campos \\ \cline{2-4}
\hline
\end{tabular}
\caption{Tabla 2.}
\label{tabla:final}
\end{table}

A: Both tables are too wide to fit fully inside the text block.
To fix this problem, I suggest you employ tabularx environments instead of tabular environments for both tables. The tabularx environment provides a column type named X for automatic wrapping of a cell's contents. Set the width of both tabularx environments to \textwidth. For the first table, I use a modified (viz., centered) form of the X column type for columns 3 and 4 in the code shown below. For the second table, one could use another modified (viz., ragged-right) form of X for columns 2, 3, and 4.
I would further like to suggest that you (a) provide a lot more visual structure to the respective headers and left-hand columns of the tables and (b) also give the tables a more "open" look. To generate such a look, get rid of all vertical bars (trust me: they won't be missed) and most horizontal bars, and use the line-drawing macros of the booktabs package -- \toprule, \midrule, \cmidrule, and \bottomrule -- for the remaining horizontal lines.

\documentclass{article}
\usepackage[spanish]{babel}
\usepackage{booktabs,tabularx}
\newcolumntype{C}{>{\centering\arraybackslash}X}
\newcolumntype{L}{>{\raggedright\arraybackslash}X}
\begin{document}
\begin{table}[ht!]
\setlength\tabcolsep{5pt} % default: 6-py
\begin{tabularx}{\textwidth}{@{}llCC@{}}
\toprule
& Casos & N\'umero de tarjetas & Porcentaje\\
\cmidrule(l){2-4}
Casos aceptables & \'Optimos & 49 & 49\% \\
& Errores atribuibles al OCR & 9 & 9\%\\
& Errores atribuibles a la tarjeta & 15 & 15\%\\
& Total & 73 & 73\% \\
\addlinespace
Casos no aceptables & No Aceptables & 27 & 27\% \\
\addlinespace
Total & & 100 & 100\% \\
\bottomrule
\end{tabularx}
\caption{Tabla 1.}
\label{tabla:final}
\end{table}

\begin{table}[h!]
\setlength\tabcolsep{4pt} % default: 6pt
\begin{tabularx}{\textwidth}{@{}lLLL@{}}
\toprule
 & Casos & Error en caracteres & Tipo de Error\\
\cmidrule(l){2-4}
Casos Aceptables
& \'Optimos & Error $<$ 4\% & Caracteres \\
& Errores atribuibles al OCR & Error $<$ 8\% & Caracteres\\
& Errores atribuibles a la tarjeta & Error $<$ 5\% & Caracteres e informaci\'on en los campos \\
\bottomrule
\end{tabularx}
\caption{Tabla 2.}
\label{tabla:final}
\end{table}
\end{document}

A: In the second table use\begin{tabular}{|l |p{3.2cm}|p{3cm}|p{3.2cm}|} and compile. You will get what you want.
[

A: Code for my solution
\documentclass{article}
\usepackage{multirow}
\begin{document}
\begin{table}[htb]
\centering
\begin{tabular}{|l|l|l|l|}
\hline
\multirow{5}{2cm}{Casos Aceptables} & Casos & N\'umero de tarjetas & Porcentaje\\ \cline{2-4}
& \'Optimos & 49 & 49\% \\ \cline{2-4}
& Errores atribuibles al OCR & 9 & 9\%\\ \cline{2-4}
& Errores atribuibles a la tarjeta & 15 & 15\%\\ \cline{2-4}
& Total & 73 & 73\% \\ \cline{2-4} \hline
Casos no aceptables & No Aceptables & 27 & 27\% \\ \cline{1-4}
& Total & 100 & 100\% \\ \cline{2-4} \hline
\end{tabular}
\caption{Tabla 1.}
\label{tabla:final}
\end{table}
\begin{table}[htb]
 \centering
\begin{tabular}{|l |p{3.2cm}|p{3cm}|p{3.2cm}|}
\hline
\multirow{4}{*}{Casos Aceptables} & Casos & Error en caracteres & Tipo de Error\\ \cline{2-4}
& \'Optimos & Error menor al 4\% & Caracteres \\ \cline{2-4}
 & Errores atribuibles al OCR & Error menor al 8\% & Caracteres\\ \cline{2-4}
& Errores atribuibles a la tarjeta & Error menor al 5\% & Caracteres e informaci\'on en los campos \\ \cline{2-4}
\hline
\end{tabular}
 \caption{Tabla 2.}
\label{tabla:final}
\end{table}
\end{document}


text:
Q: Mobiscroll - Selected Item Index How would I get the index of the selected Mobiscroll Item? I am using the 'select' option.  onClose calls function(valueText, btn, inst) and onChange calls function(valueText, inst). I can get the 'display' text, button, inst, etc., but not the index of the selected item.
On the Scroller I am displaying the file names in a formatted manner. I need to use the index to get the correct filename from an array. How do I get the index? :-)
Any suggestions?
Thanks a ton.
M&M

A: Ok I found an easy way out. When I am adding items to Mobiscroll, I also populate an array with the same values. Then all I need to do is "var selected_index = myArray.indexOf(valueText);" and I can get the index of the selected item. The first item index will be a 0. And I can use this in both onClose as well as onSelect events of Mobiscroll. Thanks a ton anyways guys!


text:
Q: CIE (Chromatically / Kelvin Temperature) Gamut in Javascript How to have a CIE (Chromatically / Kelvin Temperature) Gamut in Javascript?
I have plotted the XYZ to RGB Triangle of Color on canvas like graph plotting .
But i also need the whole CIE Gamut curve like this .

A: You can find the coordinates of the tongue right here:
http://cvrl.ioo.ucl.ac.uk/
under CIE x,y chromaticity coordinates
The following matrix contains the xyz coordinates for visibles wavelengths, starting at 380nm with increment steps of 5nm, ie wavelength=5*i+380,where i is the row index.
var color_spectrum = [[0.177552, 0.013201, 0.809246],
[0.177442, 0.013217, 0.809341],
[0.177229, 0.013151, 0.809620],
[0.176994, 0.013158, 0.809848],
[0.176762, 0.013031, 0.810207],
[0.176444, 0.013008, 0.810548],
[0.175992, 0.013031, 0.810976],
[0.175495, 0.013063, 0.811442],
[0.174805, 0.013330, 0.811865],
[0.173682, 0.014013, 0.812305],
[0.172229, 0.015121, 0.812651],
[0.170219, 0.016771, 0.813010],
[0.167698, 0.019066, 0.813236],
[0.164333, 0.021995, 0.813673],
[0.159806, 0.025895, 0.814300],
[0.154044, 0.030918, 0.815038],
[0.146902, 0.037868, 0.815230],
[0.138285, 0.048035, 0.813681],
[0.126680, 0.065950, 0.807371],
[0.111852, 0.094990, 0.793158],
[0.093162, 0.140862, 0.765976],
[0.070070, 0.208877, 0.721053],
[0.046225, 0.303041, 0.650733],
[0.023805, 0.420426, 0.555768],
[0.008188, 0.545406, 0.446406],
[0.003783, 0.660625, 0.335592],
[0.013933, 0.754417, 0.231650],
[0.039217, 0.814541, 0.146243],
[0.075015, 0.834925, 0.090060],
[0.115171, 0.826390, 0.058440],
[0.155958, 0.805392, 0.038649],
[0.194252, 0.780704, 0.025043],
[0.231059, 0.753119, 0.015822],
[0.267224, 0.722956, 0.009820],
[0.303004, 0.690898, 0.006098],
[0.338659, 0.657490, 0.003851],
[0.374237, 0.623227, 0.002536],
[0.409656, 0.588587, 0.001757],
[0.444712, 0.553963, 0.001325],
[0.479106, 0.519776, 0.001119],
[0.512455, 0.486535, 0.001010],
[0.544366, 0.454774, 0.000861],
[0.574321, 0.424986, 0.000693],
[0.601689, 0.397671, 0.000640],
[0.625405, 0.374058, 0.000537],
[0.646238, 0.353329, 0.000433],
[0.663443, 0.336271, 0.000287],
[0.677497, 0.322271, 0.000232],
[0.688698, 0.311093, 0.000209],
[0.697619, 0.302233, 0.000148],
[0.704787, 0.295104, 0.000109],
[0.710779, 0.289129, 0.000092],
[0.715674, 0.284243, 0.000083],
[0.719586, 0.280341, 0.000073],
[0.722479, 0.277458, 0.000063],
[0.724574, 0.275369, 0.000057],
[0.725939, 0.274007, 0.000053],
[0.727227, 0.272723, 0.000050],
[0.728210, 0.271742, 0.000048],
[0.728919, 0.271035, 0.000046],
[0.729413, 0.270542, 0.000044],
[0.729714, 0.270242, 0.000044],
[0.729876, 0.270081, 0.000043],
[0.730037, 0.269920, 0.000043],
[0.730100, 0.269857, 0.000043],
[0.730065, 0.269892, 0.000043],
[0.729957, 0.270000, 0.000043],
[0.729795, 0.270162, 0.000043],
[0.729586, 0.270370, 0.000044],
[0.729331, 0.270624, 0.000045],
[0.729049, 0.270906, 0.000045],
[0.728739, 0.271215, 0.000046],
[0.728408, 0.271545, 0.000047],
[0.728063, 0.271889, 0.000048],
[0.727689, 0.272262, 0.000049],
[0.727304, 0.272646, 0.000050],
[0.726901, 0.273048, 0.000051],
[0.726463, 0.273485, 0.000052],
[0.726021, 0.273925, 0.000053],
[0.725564, 0.274381, 0.000054],
[0.725083, 0.274861, 0.000056],
[0.724592, 0.275351, 0.000057],
[0.724094, 0.275848, 0.000058],
[0.723582, 0.276359, 0.000060],
[0.723065, 0.276874, 0.000061],
[0.722533, 0.277405, 0.000062],
[0.721995, 0.277941, 0.000064],
[0.721458, 0.278476, 0.000065],
[0.720898, 0.279035, 0.000067],
[0.720345, 0.279587, 0.000068]];


text:
Q: Does exist any way to convert TIFF image from little-endian byte order to big-endian? I have .dll library which use tiff image in big-endian (MM) byte order, but image scanner create image in little-endian (II) byte order.
How to convert tiff from little-endian (II) to big-endian (MM)?
Will be great, watch how it make in java

A: You can do that with ImageMagick like this:
convert image.tif -define tiff:endian=msb msb.tif

Here is the before image with Intel byte ordering (II):
xxd image.tif| more
0000000: 4949 2a00 0800 0600 ffff 0000 0000 ffff  II*.............

And here is the after image with Motorola ordering (MM):
xxd msb.tif| more
0000000: 4d4d 002a 0006 0008 ffff 0000 0000 ffff  MM.*............

A: The ImageMagick package's convert tool seems to be able to do this.
The command line would be something like:
convert myllfile.tiff -endian MSB mymmfile.tiff


text:
Q: 4-Bit Adder Subtractor Quartus Prime Lite I designed a 4-bit adder/subtractor circuit in Quartus Prime Lite. I am struggling with getting the correct output on the waveform. It is supposed to take the unsigned decimal numbers and add or subtract them according to the control input M.  When M=0 it is addition & when M=1 it is subtraction. I have changed the inputs A & B to unsigned decimals and entered the numbers provided to add or subtract. Any help to allow me to get the correct output would be greatly appreciated. I have included my circuit, waveform and the correct waveform I am trying to achieve.

A: The sense of the carry out is inverted for subtraction: COUT=1 means that the result of a subtraction is correct. Note that all of the cases you simulated yielded a correct result for subtraction...try swapping the operands and see what happens.


text:
Q: Adding a bootstrap button removes all previous CSS positioning I tried adding a bootstrap button to my webpage and it shifted all the elements to the left side of the page.
I have tried changing the position of the button.
Back

I was trying to get the button to just appear on the screen without it affecting any of the other elements but right now it appears on the screen but shifts all other things to the left of the screen.

A: This kind of thing happen when your existing class overlap any class of bootstrap.So, first check if you had used any class which was already declared in bootstrap.
Secondly, you can use a div for all content of your website and use a class named "container".

    //your contents

Hope that will help.

A: First of all put your custom css stylesheet after the bootstrap. Like this:
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<link rel="stylesheet" href="your_custom.css">

So your CSS overwrites anything that was styled before. Also try using !important at the end of css calls like - float: right !important; and if this doesn't help either just use another class name for the button and style it yourself.


text:
Q: How to takeover an selenium chrome driver that has not exited from previous testcase in c#? During debugging it is possible to exit test script before running cleanup code that would normally close the running chrome driver. Is it possible to take control of the existing chrome driver with a new script? If so what code is required?
What I've looked at and tried:
Get WebDriver of already opened Chrome Browser
http://testerstories.com/2015/10/using-c-with-selenium-webdriver/
Get WebDriver of already opened Chrome Browser


text:
Q: Delete list of files with BFG-repo-cleaner We are trying to shrink our git repository to under 500MB due to deployment issues.
To achieve that, we have created a new branch where we have moved all old images, videos and fonts to AWS S3.
I can easily get the list of files with git diff --name-only --diff-filter=D master -- public/assets/.
Now, I have tried to run BFG-repo-cleaner 1.14.0 on each file. But I have 400 files and it is taking ages to delete each files separately (still running as I'm writing this).
git diff --name-only --diff-filter=D master -- public/assets/ | xargs -i basename '{}' | xargs -i bfg --delete-files '{}'
Since each file is distinct, I can not really use a glob pattern, as suggested at Delete multiple files from multiple branch using bfg repo cleaner.
I tried to separate each file with a comma but that resulted in BFG-repo-cleaner telling me:

BFG aborting: No refs to update - no dirty commits found??

Is there a way to provide multiple files to BFG-repo-cleaner without a glob pattern?
PS. The command I tried with multiple files is: git diff --name-only --diff-filter=D master -- public/assets/ | xargs -i basename '{}' | sed -z 's/\n/,/g;s/,$/\n/' | xargs -i bfg --delete-files '{}' && git reflog expire --expire=now --all && git gc --prune=now --aggressive
PPS. The bfg command is on my PATH as a simple bash script with java -jar /tools/BFG-repo-cleaner/bfg-1.14.0.jar "$@"

A:
But I have 400 files and it is taking ages to delete each files separately

That is why the tool to use (python-based) is newren/git-filter-repo (see installation)
That way, you can feed that tool a file, with the list of files in it:
git filter-repo --paths-from-file <filename> --invert-paths

From the documentation:

Similarly, you could use --paths-from-file to delete many files.
For example, you could run git filter-repo --analyze to get reports, look in one such as .git/filter-repo/analysis/path-deleted-sizes.txt and copy all the filenames into a file such as /tmp/files-i-dont-want-anymore.txt, and then run:
git filter-repo --invert-paths \
                --paths-from-file /tmp/files-i-dont-want-anymore.txt

to delete them all.


text:
Q: BAT :~ syntax for strings I see the ':~' symbols used pretty often in BAT files, I presume it gets a character at a position, but I couldn't find any confirmation of this, nor on how/when to use it (it appears it can get a range as well).
Please if you could shed some light on this, thanks.
SET STRING=C:\MyDocuments\
IF "%STRING:~-1%"=="\" SET STRING=%STRING:~0,-1%
ECHO String: %STRING%

Also should %%A:~-1 work? or would I need to enclose it in ""?

A: Type
help set

in the commandline and you'll get a full description. Some is also documented in the help of the for command. So help for will give you additional information.
This is part of the output of the "help set" command:
May also specify substrings for an expansion.

    %PATH:~10,5%

would expand the PATH environment variable, and then use only the 5
characters that begin at the 11th (offset 10) character of the expanded
result.  If the length is not specified, then it defaults to the
remainder of the variable value.  If either number (offset or length) is
negative, then the number used is the length of the environment variable
value added to the offset or length specified.

    %PATH:~-10%

would extract the last 10 characters of the PATH variable.

    %PATH:~0,-2%

would extract all but the last 2 characters of the PATH variable.


text:
Q: Sharepoint and Blazor wasm I am trying to set a blazor wasm app in sharepoint.
.Net 7 with a empty blazor template.
in index.html I have:
base href="/sites/ContosoDemo/ferias/SiteAssets/blazorpoint/"
script src="/sites/ContosoDemo/ferias/SiteAssets/blazorpoint/_framework/blazor.webassembly.js
I add this index.html in a content container webpart.
But the running aspx is different where the assets are.

Any Help?


text:
Q: Would it be a security compromise to place the object exported from socket.io-client on the window object? Motivation: I'm trying to test my (React) app using Cypress.
Although Cypress supports http mocking OOTB, it does not support Websockets mocking and moreover socket.io is not supported.
Instead they recommend accessing (and possibly stubbing) a global window.io.
So the question is: Is it safe to do something like:
import io from 'socket.io-client';
window.io = io;

in the production code.
PS - the client authenticate itself by sending a token to the server and all is done over wss.


text:
Q: JSON web token error when authorising a Github Action I'm trying to create a Github action to authorise a Github action and then create a scratch org to run tests against, but I keep getting the below error when trying to authorise. How can I debug this?
I created the certificate following the steps here using openssl
- name: Authenticate Against Dev Hub
  run: sfdx force:auth:jwt:grant --clientid ${{ secrets.SF_APP_KEY_PROD }} --jwtkeyfile keys/server.key --username ${{ secrets.SF_USERNAME_PROD }} --instanceurl ${{ secrets.SF_INSTANCE_URL_PROD }} --setdefaultdevhubusername -a DevHub

ERROR running auth:jwt:grant:  We encountered a JSON web token error,
which is likely not an issue with Salesforce CLI. Here's the error:
error:1E08010C:DECODER routines::unsupported

A: Figured it out, was missing -----BEGIN RSA PRIVATE KEY----- & -----END RSA PRIVATE KEY----- in my server.key as I'd copied it into an environment variable.


text:
Q: How open app chooser when user click on dynamic link I would like to use dynamic link (https://firebase.google.com/docs/dynamic-links) in my app. This tool has lots of advantages but I noticed that if the application is not installed, the system automatically redirects to the playstore without asking the user anything.
I would like the user to be able to choose to open the link in their browser rather than download the application
Is there a way to force the system to display the app chooser (playstore/web browser) when the user click on the dynamic link ?
Thanks in advance


text:
Q: Chome push notifications disappearing after a couple seconds I am building a system to send web push notifications with chrome.  When someone receives my push notification on their desktop PC they see the notification for about 10 seconds.  If they don't click on the notification it will then disappear after about 10 seconds.
I see other websites sending push notifications that do not disappear. I believe there is some setting I am not using to make my messages stay on the screen until clicked or exited.  Does anyone know this setting or parameter?

A: It looks like you need to use the 'requireInteraction' option creating the notification in your service worker. Just set it to 'true' to say the browser you need the user interaction. Here is how you do this.
...in your service worker script when you create a notification:
self.addEventListener('push', function(e) {
    var notification = self.registration.showNotification(
        "Hi! Click me!",
        {
            requireInteraction: true,
            body: "I'm not going to disappear"
        }
    );
    e.waitUntil(notification);
});

Also don't forget to close it on click event:
...later in the service worker script:
self.addEventListener('notificationclick', function(e) {
    e.preventDefault();
    e.notification.close();

    // Do click actions
});

Browser comparability: unfortunately not everybody supports this option yet: Firefox doesn't. See the Mozilla reference for details: https://developer.mozilla.org/en-US/docs/Web/API/notification/requireInteraction
But it works fine in Chrome.

A: You may want to try the suggested solution in this SO post which consists the following steps:

*

*Register listeners for all the events mentioned in chrome.notifications.

*Register a timeout after a few seconds (e.g. 30) -after the notification is hidden- that will delete and re-create the notification (so it effectively stays visible on the screen.

*If any of the listeners set on step 1 fires, it means the user interracted with the notification, so cancel the timeout (you don't need to re-create the notification).

See the post for more information.


text:
Q: Java Debugging over 2 machines I am working in Linux environment where my java process is running on Machine C.
in order to connect to Machine C from my machine A i need to connect through B for security reason and there is no option to connect directly to machine C.
is there any way to debug the java process that running on machine C.?
Thanks in advance

A: You can set up a tunnel through machine B. You can use ssh tunneling by issuing this command from machineA:
ssh root@machineB -L 5005:machineC:5005

You will need to configure your IDE to debug remotely, pointed at machineA port 5005, and configure the remote JVM on machineC for remote debugging on port 5005, something like this:
-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005

Assuming your IDE is running on the same machine as the ssh client, that is, machineA, you can point your IDE to localhost:5005 and the ssh command will attempt to tunnel all connections you make to localhost:5005 through to machineC:5005.


text:
Q: WP8 InvalidOperation I am getting a:
An exception of type 'System.InvalidOperationException' occurred in Microsoft.Phone.ni.dll but was not handled in user code
When I do:
ApplicationBarIconButton nextButton = new ApplicationBarIconButton(new Uri("/Images/next.png", UriKind.Relative));
nextButton.Text = "Next";

ApplicationBarIconButton backButton = new ApplicationBarIconButton(new Uri("/Images/back.png", UriKind.Relative));
nextButton.Text = "Previous";

ApplicationBar.Buttons.Add(nextButton);
ApplicationBar.Buttons.Add(backButton); //<---- Error when adding this

Can anyone see where I am going horribly wrong?

A: It's because you haven't set the Text property for the backbutton.
ApplicationBarIconButton backButton = new ApplicationBarIconButton(new Uri("/Images/back.png", UriKind.Relative));
backButton.Text = "Previous"; //<< you have nextButton.Text

A: Hey the problem is your not actually setting the text for the back button, youve set nextButton.Text on both :)


text:
Q: 'Not a function' error with setInterval I am trying to make a function run 60 times per second. So I've declared setInterval(this.updateAt60, 1/60*1000); in this class' constructor.
This is the function that should be called repeatedly:
LightingScene.prototype.updateAt60 = function(){
   this.controlSubmarine();
   this.submarine.setPosition();
}

Yet, I'm getting the error Uncaught TypeError: this.controlSubmarine is not a function and I can call it everywhere on the code except on there. The order of function declaration is constructor/ controlSubmarine/ updateAt60.
What am I doing wrong?
Thank you in advance.


text:
Q: internal stylesheet with media attribute I'm trying to use the media attribute for internal style sheet. I am using media=print and media=handheld for mobile devices. However this is not working. Not to sure why?
EDIT: The outcome I am trying to get is, media="print, test text = blue and picture to be static. Media="handheld" , test text= red and picture to be responsive/dynamic.

     test

A: It works fine, but you can't test "print" and "handheld" on jsfiddle. (It doesn't accept media-attributes, and you can't define

     test