text:
Q: Why most of Sql Injection need url like this "index.asp?id=123" I am trying to learn "SQL Injection" concepts and also trying to practice some Kali tools to learn, but there is a question that I do not understand and my question is why do most tools need URL's that end with "AAA.BBB?id=000" as a input string for injection.

A: When you see URL's that have that kind of syntax id=123, there is a good chance the underlying code will use 123 as input to some kind of dynamic SQL statement.  Unless the underlying code is written to prevent SQL injection, you can gain additional information from the database (or cause harm) by simply adding additional information to the url directly in the browser window.
Have a look at SQL Injection Walkthrough
What is SQL Injection?
It is a trick to inject SQL query/command as an input possibly via web pages. Many web pages take parameters from web user, and make SQL query to the database. Take for instance when a user login, web page that user name and password and make SQL query to the database to check if a user has valid name and password. With SQL Injection, it is possible for us to send crafted user name and/or password field that will change the SQL query and thus grant us something else.
What do you need?
Any web browser.
Try to look especially for URL that takes parameters, like:
http://duck/index.asp?id=10
There are numerous examples of SQL injection in the post I referenced above.


text:
Q: Combining result of mssql queries I am currently using this mssql client and I am trying to make 2 queries and passing both results in a function but I can't get the result of my query outside of the scope, even if i use a global variable. I am guessing it is because I only have a reference and I lose it when the function returns? How should I go about this? Here is my code of 1 working query but I am not able to add a 2nd one:
function Query() {
    var err, result, sql = require('mssql');

    const connection = new sql.ConnectionPool(config);
    var req = new sql.Request(connection);
    var queryString = // String of my query //

    connection.connect(function (err) {
        if (err) {
            console.log(err);
            return;
        }
        req.query(queryString, function (err, result){
            if (err) {
                console.log(err);
            }
            else {
                someFunc(result);
            }
            connection.close();
            return;
        });
    });
}

To clarify, I would like to be able to make a 2nd query, combine both results and call someFunc() passing both results. Anyone have an idea how to go about this?

redpajama_set_name: RedPajamaStackExchange


text:
Q: Replicating child elements in JavaScript [Bug] I am trying to solve a problem for an assignment, where the objective is to build a game. The game loads with smiley faces shown across two columns(divs) laid out side by side. There is one extra smiley on the left div, and if the user clicks on that extra smiley, the next run of the game should:

*

*Increase the number of smileys by 5, for the next run

*Generate a whole new set of smileys for the second run(by removing existing smileys from the current run).

The code I have so far has a bug. If I include the code for removing child nodes from the current run of the game, in the next run 5 more smileys are not added. If I remove this code, then in the next run, 5 more smileys are added but the previous smileys are at the same position (meaning they are not removed).
Here's the JS code:
var numberOfFaces = 5;
    var theLeftSide = document.getElementById("leftSide");
    var theRightSide = document.getElementById("rightSide");
    var theBody = document.getElementsByTagName("body")[0];

    function generateFaces() {

        //remove current children
        while(theLeftSide.firstChild){
                theLeftSide.removeChild(theLeftSide.firstChild);
            }

        while(theRightSide.firstChild){
                theRightSide.removeChild(theRightSide.firstChild);
            }

        while(numberOfFaces > 0) {
            var face = document.createElement("img");
            face.src = "http://home.cse.ust.hk/~rossiter/mooc/matching_game/smile.png";
            var topValue = generateRandomNumber(0,400);
            face.style.top = topValue+"px";
            var leftValue = generateRandomNumber(0,400);
            face.style.left = leftValue+"px";
            theLeftSide.appendChild(face);

            //changes
            var leftSideImages = theLeftSide.cloneNode(true);
            var leftSideLastImage = leftSideImages.lastChild;
            leftSideImages.removeChild(leftSideLastImage);
            theRightSide.appendChild(leftSideImages);

            //4th - generate 5 more faces for correct click in left side
            theLeftSide.lastChild.onclick = function nextLevel(event){
                event.stopPropagation();
                numberOfFaces += 5;
                generateFaces();
            };

            theBody.onclick = function gameOver() {
                alert("Game Over!");
                theBody.onclick = null;
                theLeftSide.lastChild.onclick = null;
            };

            numberOfFaces--;
        }

    }

    function generateRandomNumber(min, max) {
        return Math.floor(Math.random() * (max-min + 1));
    }

And this is the link to the Fiddle.
I also made a Codepen pen that has the same code.
Would appreciate any help.

Update -
My function structure was somewhat different in earlier attempts. I revised it based on some forum comments. Here's the earlier structure-
function generateFaces() {

    //remove current children
    while(theLeftSide.firstChild){
            theLeftSide.removeChild(theLeftSide.firstChild);
        }

    while(theRightSide.firstChild){
            theRightSide.removeChild(theRightSide.firstChild);
        }

    while(numberOfFaces > 0) {
        var face = document.createElement("img");
        face.src = "http://home.cse.ust.hk/~rossiter/mooc/matching_game/smile.png";
        var topValue = generateRandomNumber(0,400);
        face.style.top = topValue+"px";
        var leftValue = generateRandomNumber(0,400);
        face.style.left = leftValue+"px";
        theLeftSide.appendChild(face);
        numberOfFaces--;
    }

        //changes
        var leftSideImages = theLeftSide.cloneNode(true);
        var leftSideLastImage = leftSideImages.lastChild;
        leftSideImages.removeChild(leftSideLastImage);
        theRightSide.appendChild(leftSideImages);

        //4th - generate 5 more faces for correct click in left side
        theLeftSide.lastChild.onclick = function nextLevel(event){
            event.stopPropagation();
            numberOfFaces += 5;
            generateFaces();
        };

        theBody.onclick = function gameOver() {
            alert("Game Over!");
            theBody.onclick = null;
            theLeftSide.lastChild.onclick = null;
        };

        //numberOfFaces--;

}

A: You are decrementing numberOfFaces to zero in the while loop and add 5 again, so the value is always 5.
Change the while loop to
for(var n = 0; n < numberOfFaces; n++) {
    var face = document.createElement("img");
    face.src = "http://home.cse.ust.hk/~rossiter/mooc/matching_game/smile.png";
    var topValue = generateRandomNumber(0,400);
    face.style.top = topValue+"px";
    var leftValue = generateRandomNumber(0,400);
    face.style.left = leftValue+"px";
    theLeftSide.appendChild(face);

    ...
}

and each run adds an extra 5 smiley set. Altered fiddle here

A: Append your right child after while loop:
    var numberOfFaces = 5;
    var theLeftSide = document.getElementById("leftSide");
    var theRightSide = document.getElementById("rightSide");
    var theBody = document.getElementsByTagName("body")[0];

    function generateFaces() {

        //remove current children
        while(theLeftSide.firstChild){
                theLeftSide.removeChild(theLeftSide.firstChild);
            }

        while(theRightSide.firstChild){
                theRightSide.removeChild(theRightSide.firstChild);
            }

        while(numberOfFaces > 0) {
            var face = document.createElement("img");
      face.setAttribute("src", "http://home.cse.ust.hk/~rossiter/mooc/matching_game/smile.png");
            //face.src = "http://home.cse.ust.hk/~rossiter/mooc/matching_game/smile.png";
            var topValue = generateRandomNumber(0,400);
            face.style.top = topValue+"px";
            var leftValue = generateRandomNumber(0,400);
            face.style.left = leftValue+"px";
            theLeftSide.appendChild(face);

            //changes
            var leftSideImages = theLeftSide.cloneNode(true);
            var leftSideLastImage = leftSideImages.lastChild;
            leftSideImages.removeChild(leftSideLastImage);

            //4th - generate 5 more faces for correct click in left side
            theLeftSide.lastChild.onclick = function nextLevel(event){
                event.stopPropagation();
                numberOfFaces += 5;
                generateFaces();
            };

            theBody.onclick = function gameOver() {
                alert("Game Over!");
                theBody.onclick = null;
                theLeftSide.lastChild.onclick = null;
            };

            numberOfFaces--;
        }
        theRightSide.appendChild(leftSideImages);
    }

    function generateRandomNumber(min, max) {
        return Math.floor(Math.random() * (max-min + 1));
    }

Check out codepen


text:
Q: How to find the processor queue length in linux Trying to determine the Processor Queue Length (the number of processes that ready to run but currently aren't) on a linux machine. There is a WMI call in Windows for this metric, but not knowing much about linux I'm trying to mine /proc and 'top' for the information. Is there a way to determine the queue length for the cpu?
Edit to add: Microsoft's words concerning their metric: "The collection of one or more threads that is ready but not able to run on the processor due to another active thread that is currently running is called the processor queue."

A: sar -q will report queue length, task list length and three load averages.
Example:
matli@tornado:~$ sar -q 1 0
Linux 2.6.27-9-generic (tornado)    01/13/2009  _i686_

11:38:32 PM   runq-sz  plist-sz   ldavg-1   ldavg-5  ldavg-15
11:38:33 PM         0       305      1.26      0.95      0.54
11:38:34 PM         4       305      1.26      0.95      0.54
11:38:35 PM         1       306      1.26      0.95      0.54
11:38:36 PM         1       306      1.26      0.95      0.54
^C

A: vmstat
procs -----------memory---------- ---swap-- -----io---- -system-- ----cpu----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa
 2  0 256368  53764  75980 220564    2   28    60    54  774 1343 15  4 78  2

The first column (r) is the run queue - 2 on my machine right now
Edit: Surprised there isn't a way to just get the number
Quick 'n' dirty way to get the number (might vary a little on different machines):
  vmstat|tail -1|cut -d" " -f2

A: The metrics you seek exist in /proc/schedstat.
The format of this file is described in sched-stats.txt in the kernel source. Specifically, the cpu<N> lines are what you want:
CPU statistics
--------------
cpu<N> 1 2 3 4 5 6 7 8 9

First field is a sched_yield() statistic:
     1) # of times sched_yield() was called

Next three are schedule() statistics:
     2) This field is a legacy array expiration count field used in the O(1)
    scheduler. We kept it for ABI compatibility, but it is always set to zero.
     3) # of times schedule() was called
     4) # of times schedule() left the processor idle

Next two are try_to_wake_up() statistics:
     5) # of times try_to_wake_up() was called
     6) # of times try_to_wake_up() was called to wake up the local cpu

Next three are statistics describing scheduling latency:
     7) sum of all time spent running by tasks on this processor (in jiffies)
     8) sum of all time spent waiting to run by tasks on this processor (in
        jiffies)
     9) # of timeslices run on this cpu

In particular, field 8. To find the run queue length, you would:

*

*Observe field 8 for each CPU and record the value.

*Wait for some interval.

*Observe field 8 for each CPU again, and calculate how much the value has increased.

*Dividing that difference by the length of the time interval waited (the documentation says it's in jiffies, but it's actually in nanoseconds since the addition of CFS), by Little's Law, yields the mean length of the scheduler run queue over the interval.

Unfortunately, I'm not aware of any utility to automate this process which is usually installed or even packaged in a Linux distribution. I've not used it, but the kernel documentation suggests http://eaglet.rain.com/rick/linux/schedstat/v12/latency.c, which unfortunately refers to a domain that is no longer resolvable. Fortunately, it's available on the wayback machine.

Why not sar or vmstat?
These tools report the number of currently runnable processes. Certainly if this number is greater than the number of CPUs, some of them must be waiting. However, processes can still be waiting even when the number of processes is less than the number of CPUs, for a variety of reasons:

*

*A process may be pinned to a particular CPU.

*The scheduler may decide to schedule a process on a particular CPU to make better utilization of cache, or for NUMA optimization reasons.

*The scheduler may intentionally idle a CPU to allow more time to a competing, higher priority process on another CPU that shares the same execution core (a hyperthreading optimization).

*Hardware interrupts may be processable only on particular CPUs for a variety of hardware and software reasons.

Moreover, the number of runnable processes is only sampled at an instant in time. In many cases this number may fluctuate rapidly, and the contention may be occurring between the times the metric is being sampled.
These things mean the number of runnable processes minus the number of CPUs is not a reliable indicator of CPU contention.

A: uptime will give you the recent load average, which is approximately the average number of active processes. uptime reports the load average over the last 1, 5, and 15 minutes. It's a per-system measurement, not per-CPU.
Not sure what the processor queue length in Windows is, hopefully it's close enough to this?


text:
Q: How to mathematically describe sampling from a CDF? Is there a concise way to mathematically write the following statement:

$\zeta$ is a randomly sampled value from a cumulative distribution
  function $F_X$ of a random variable $X$.

$\zeta~=~?$
More precisely, I want to have a function $\Psi$ that associates each element from a set $S$ with a randomly sampled value from a given CDF $F_X$.
$\Psi : S~\to~?$
Thanks in advance for your answer(s).
NS

A: You would say $X_1, X_2,\ldots$ are independent and identically distributed samples from the distribution whose CDF is $F_X.$ It is ok for this sequence to be infinite. If $\xi$ is one of these samples and you want to write $\xi=?,$ you need to say which one and write $\xi =X_i.$ If you want each element of the set $S$ to be associated with one of the $X_i,$ (presumably uniquely) then let $A =\{X_1,X_2,\ldots\}$ and consider one to one functions $S\to A.$
The issue is that "a random sample" is underspecified, at least it is when there are multiple random samples under consideration. But we have a mathematically precise way of defining a sequence of iid samples, and we can proceed to treat the random variables in that sequence as ordinary mathematical objects.
If there is a name for the distribution, like $N(0,1),$ it is common to abbreviate like $$X\sim N(0,1)$$ for a single sample or $$ X_i \sim_{i.i.d.} N(0,1)$$ for an independent identically distributed sequence. I wouldn't consider it too grave an abuse of notation to substitute $F_X$ for $N(0,1),$ effectively naming the distribution by its CDF.


text:
Q: Packages.config and binding redirects We're having some build issues due to package issues, but one of our devs got a green build by downgrading a package in the project's packages.config:
<package id="Microsoft.Data.Edm" version="5.6.2" targetFramework="net451" />

This was also added to the project's config file:
<dependentAssembly>
    <assemblyIdentity name="Microsoft.Data.Edm" publicKeyToken="31bf3856ad364e35" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-5.6.4.0" newVersion="5.6.4.0" />
  </dependentAssembly>

If we have amended the version in the packages.config to 5.6.2, but still point to 5.6.4 in our binding redirect, what version of the Microsoft.Data.Edm assembly is the project going to use?


text:
Q: How to use react-phone-number-input with Formik's Field component I'm using Formik and trying to use this package, but Formik can't see the value of the input and thus doesn't validate or submit the form.
Here's the PhonInputField component that I'm using ...
import PhoneInput from "react-phone-number-input";

const PhoneInputField = ({
    field,
    form
}) => {
    return (

            <PhoneInput
                placeholder="Enter phone number"
                name={field.name}
                value={field.value}
                onChange={field.onChange}
                onBlur={field.onBlur}
            />

    );
};

export default PhoneInputField;

And here's how I'm using it in Formik ...
<Formik
    initialValues={initialValues}
    validationSchema={signInSchema}
    onSubmit={handleFormSubmit}
>
    {({
        isValid,
        isSubmitting,
        handleChange,
        handleBlur
    }) => (
        <Form>

                <Field
                    type="tel"
                    name="phone_number"
                    component={PhoneInputField}
                />

                <button
                    type="submit"
                    disabled={!isValid || isSubmitting}
                    className="btn btn-primary big"
                >Submit</button>

        </Form>
    )}
</Formik>

What am I doing wrong here?
=======================================================
I tried to ask this question on the Github repo page for this project but with no luck.
I also tried to do it like this ...
<PhoneInput
        placeholder="Enter phone number"
        name={field.name}
        value={field.value}
        onChange={value => field.onChange({ value })}
        onBlur={value => field.onBlur({ value })}
/>

But still, Formik can't see the field value.

A: For those of you who may come across this question, it was answered in the Github repo page here ...
https://github.com/catamphetamine/react-phone-number-input/issues/298#issuecomment-557746103

A: onChange={(phone, country) =>
    setValues({
    ...values,
    phone: phone,
    countryCode: country.countryCode
    })
}


text:
Q: Problems with Z80 Assembler I trying to write in Z80 Assembler in a CP/M 2.2 Emulator (z80pack) in Debian:
A>dir
A: DUMP     COM : SDIR     COM : SUBMIT   COM : ED       COM
A: STAT     COM : BYE      COM : RMAC     COM : CREF80   COM
A: LINK     COM : L80      COM : M80      COM : SID      COM
A: WM       COM : WM       HLP : ZSID     COM : MAC      COM
A: TRACE    UTL : HIST     UTL : RESET    COM : LIB80    COM
A: HIST     COM : DDT      COM : Z80ASM   COM : CLS      COM
A: SLRNK    COM : MOVCPM   COM : ASM      COM : LOAD     COM
A: XSUB     COM : LIB      COM : PIP      COM : SYSGEN   COM
A>
A>z80asm

Z80 ASSEMBLER Copyright (C) 1983 by SLR Systems Rel. 1.30 #F10268

%STROUT EQU 9
STROUT EQ
A>Z80ASM

Z80 ASSEMBLER Copyright (C) 1983 by SLR Systems Rel. 1.30 #F10268

%A
A
A.Z80 - File Not Found Line 00000

%adc a,R
adc a,
ADC.Z80 - File Not Found Line 00000

R
R.Z80 - File Not Found Line 00000

%ORG 100h
ORG 1Command Syntax Error - Abort

A>

It just says "File Not Found" everytime I try to write a line. I looked for the manual, but it don't say how to start. Is there a especial command I should type? Because M80 (Macro-Assembler 80) also gives error in every line.

A: You need to create a file containing your Z80 code called whatever.Z80, then provide whatever at the % prompt.
Hence, you can edit your code to alter your program rather than having to retype the entire code perfectly every time.

A: Given your assembly source file named CONFI.Z80 this command will generate a CONFI.COM binary and a CONFI.LST program listing with a symbol list at the end:
z80asm confi/fxs

Sample run under RunCPM emulator:
A>z80asm confi/fxs

Z80ASM Copyright (C) 1983-86 by SLR Systems Rel. 1.32 #RunCPM

 CONFI/FXS
End of file Pass 1
End of file Pass 2
 0 Error(s) Detected.
 6784 Absolute Bytes. 137 Symbols Detected.

Full manual at
https://oldcomputers.dyndns.org/public/pub/manuals/z80asm.pdf


text:
Q: Turning One Raspberry Pi I2C Connected Relay On Turns the Other Relay Off Currently, I have two, 2-Channel 1 Amp SPDT Signal Relay Controllers connected to my Raspberry Pi 3 via I2C, and when I currently run the function to turn one relay on, the other one will shut off at the same time (one or the other is on). In addition, my button to shut off relay 1 and my button to shut off relay 2 will shut both relays off.
My program is written in a windows form (visual studio), and I am accessing a C Shared Library via Dll Import, but I know for a fact my problem is within my C library. I am very new to C and how shifting works, so the root of my problem lies within the logic and structure of my code. Frankly, I'm confused on how to properly code this.
This is currently the method to turn Relay 1 On. It turns the relay on properly, but this also turns Relay 2 Off at the same time.
void Relay1On() ***CURRENTLY TURNS OTHER OFF WHEN ACTIVATED***
{
    // Create I2C bus
    int file;
    char *bus = "/dev/i2c-1";
    if ((file = open(bus, O_RDWR)) < 0)
    {
        printf("Failed to open the bus. \n");
        exit(1);
    }
    // Get I2C device, MCP23008 I2C address is 0x20(32)
    ioctl(file, I2C_SLAVE, 0x20);

    // Configure all pins of port as output (0x00)
    char config[2] = {0};
    config[0] = 0x00;
    config[1] = 0x00;
    write(file, config, 2);

    //Turn the first relay on
    char data = 0x01;
    config[0] = 0x09;
    config[1] = data;
    write(file, config, 2);

}

Here is the code for Relay 1 Off, I will not post Relay 2 On/Off because it is basically the same, Relay2On just has an added data += 1; after char data = 0x01;. Both 'Off' methods result in both relays shutting off.
void Relay1Off()
{
    // Create I2C bus
    int file;
    char *bus = "/dev/i2c-1";
    if ((file = open(bus, O_RDWR)) < 0)
    {
        printf("Failed to open the bus. \n");
        exit(1);
    }
    // Get I2C device, MCP23008 I2C address is 0x20(32)
    ioctl(file, I2C_SLAVE, 0x20);

    // Configure all pins of port as output (0x00)
    char config[2] = {0};
    config[0] = 0x00;
    config[1] = 0x00;
    write(file, config, 2);

    //Turn the first relay off *****Turns all off at the moment******
    char data = 0xFE;
    data = (data << 1);
    config[0] = 0x09;
    config[1] = data;
    write(file, config, 2);
}

All I want is the methods to do as described, turn Relay 1 On when the method is called. When Relay1Off is called, shut only Relay 1 off. I'm sure it is simple, but as I've stated above C is quite new to me.
Thank you in advance for any contribution.

A: I don't know how the fancy ioctl stuff works, but I'd try to do all initialization outside of this function, including setting all the GPIO's to output.
You should probably just have one function call to set/clear a relay. I'd do something like this to start:
void RelayOnOff(unsigned char relay, unsigned char enable)
{
    //Init to all off
    static unsigned char data = 0x00;
    ...
    if (enable){
        data |= ( 1 << relay );
    }
    else{
        data &= ~( 1 << relay );
    }
    config[0] = 0x09;
    config[1] = data;
    write(file, config, 2);
}

You pass in what relay you want to control, and a boolean value for enable/disable. If you make the data variable static, it'll "remember" that value from function call to function call. The enable/disable sets/clears the bit for whatever relay you pass in (0-7).


text:
Q: How do you delete lines in a file when more than one character needs be compared in a file in different lines? Eg:
Content of a file xx.txt is:
Hi
How Are You Doing
Its Been Long Time
Hope Everything Is Fine

So if i need to remove the lines which contain word Doing or Fine.
The output of the file xx.txt must look like:
Hi
Its Been Long Time

Is it possible to do this using a single sed or awk command?

A: Try this,
To print the output:
sed '/Doing\|Fine/d' xx.txt

To remove the line directly in a file:
sed -i '/Doing\|Fine/d' xx.txt

A: grep -vE "Doing|Fine" xx.txt

it will print all the lines which is not having the "Doing and Fine" word

A: awk '$0 !~/Fine|Doing/' i.txt

ouput
Hi
Its Been Long Time

A: To remove all lines that has the words Doing or Fine in them, you may use grep in the following manner:
grep -Fw -v -e 'Doing' -e 'Fine' file

The -F option makes grep use the given expressions as strings rather than as regular expressions, while -w makes it match whole words (not substrings of other words, like Doings or Fines).  The -v option inverts the sense of the test so that lines matching the given expressions are removed from the output.  The two strings are given with -e, which is used to give the expression to query with (this option is often left out, but is needed here as we have two of them).

With sed, you could do
sed -e '/\<Doing\>/d' -e '/\<Fine\>/d' file

or
sed '/\<Doing\>/d; /\<Fine\>/d' file

or
sed -E '/\<(Doing|Fine)\>/d' file

Each of of these matches the two string as words.  The \< and \> special patterns matches the zero-width space at the beginning and end of a word respectively (the space between a word-character and a non-word-character).  With GNU sed, you could use \b in place of both \< and \>.
The last sed command uses an alternation to match either word.  Alternations is a feature of extended regular expressions, so we enable these using -E on the command line.
In all cases, the pattern is matched against every line of input, and if it matches, it is deleted with the d command. All other lines are printed.
The inverse, printing all lines that does not match, and ignoring the rest, could be done with
sed -n -E '/\<(Doing|Fine)\>/!p' file

That is, turn off the default outputting of the data with -n and then only print (p) the lines that does not match (!) the pattern.

The awk code would look very similar to the sed code using extended regular expressions, at least if using GNU awk (which understands \< and \>):
awk '!/\<(Doing|Fine)\>/' file

or
awk '!/\<Doing\>/ && !/\<Fine\>/' file

These both tries to match the two words against the input data, and would not print the data if the words are present.
You may also use the index() function in awk, but this would also find the words as substrings (just like using /(Doing|Fine)/ would do):
awk '!index($0, "Doing") && !index($0, "Fine")' file

index($0, string) returns zero if the string is not found in $0 (the whole line), so negating the result with ! would give you a true value if the string wasn't found.
The long-handed way to do it in awk is to check every field separately:
awk '{ for (i = 1; i <= NF; ++i) if ($i == "Doing" || $i == "Fine") next; print }' file

This tests each field against the two words and skips immediately to the next input line if one of them is found.  Otherwise, the line is printed.
This would give different results from using /\<(Doing|Fine)\>/ if a word like A-Doing was present in the text.  The loop would not spot it (because the fields are divided on whitespace), but the regular expression would (because - is a non-word-character).


text:
Q: How to find the previous two Sundays from the current day in Scala? If current time is `2015-05-16 13:05:06+1793` then I should get `2015-05-03 00:00:00+0000` and `2015-05-10 00:00:00+0000`

If current time is `2015-05-10 00:00:00+0000` then I should get `2015-05-03 00:00:00+0000` and `2015-05-10 00:00:00+0000`

And so forth... How can I compute these two dates in scala?
EDIT:
As I mentioned, I would prefer a solution which is not at all based on external libraries. In addition, please mention explicitly all necessary imports I have to made cause I am a newby both in Java and Scala.

A: If you're on Java 8, you can do pretty well without joda-time.
import java.time.LocalDate
val today = new LocalDate()
val lastSunday = today minusDays ( today.getDayOfWeek.getValue % 7 )  // Monday = 1 ... Sunday = 7
val twoSundaysAgo = lastSunday minusDays 7

A: You can have a look at joda-time. It is the best library to manage dates.
In your case, you could create a LocalTime and use something like this:
d.plusWeeks(-2).withDayOfWeek(DateTimeConstants.SUNDAY))

A: For starters you probably want to be using joda-time, as Carlos suggested. One way to look at the problem would be to filter the right days out of a set of possible days. This would look something like the following:
val today: LocalDate = new LocalDate()
val sundays: Seq[LocalDate] = (1 to 13) map {date.minusDays(_)} filter {_.dayOfWeek() == DateTimeConstants.SUNDAY}


text:
Q: How to center large figures in LaTeX and how to fix short justified lines? I have 2 questions:

*

*I am trying to center a figure in LaTeX, but above a certain size it just starts at the left margin and goes beyond the right. How can I make it actually center, so the amount it goes over the left margin is the same as the right?

*Some short lines justify to fill the whole page width, which makes it look really bad. Is there a way I can fix these lines, or maybe set the width for justification to be considered?
Thanks in advance.

A: Another possible solution is to use a picture environment and then \put the included graphic way left:
\begin{figure}[htbp]
  \centering
  \setlength{\unitlength}{\textwidth}
    \begin{picture}(1,0.5)%in case your image is twice as wide as it is high
                          %(otherwise change the 0.5 to your file's height/width).
       \put(-0.1,0){\includegraphics[width=1.2\unitlength]{image.jpg}}
    \end{picture}
\end{figure}

A: *

*\centerline{\includegraphics{foo}}

*Can you provide an example? You can use \raggedright or even ragged2e package to control the paragraph. However, I wonder how the short lines fill the whole page width.

A: Re: 1.: I've been using this excellent tip by Stefan Kottwitz for very large figures in my PhD-Thesis. Essentially, it boils down to using a
\noindent\makebox[\textwidth]{%
  very wide figure or very wide table%
}

around your figure- or table-code.


text:
Q: If $a, b$ are positive integers such that $a|b^2, b^2|a^3,....$ then $a=b$. The following is a well known problem
If $a|b^2; b^2|a^3; a^3|b^4; ....$ then $a=b$.
I started with $a$ is a prime $p$ and the conclusion immediately holds.
So I was comparing powers of primes but can't get anything useful.
 Please help.

A: Hint $\quad\ \forall n\in\mathbb N: \ \color{#c00}a\:\!\left(\dfrac{a}b\right)^{2n}\!\!\in\mathbb Z\,\Rightarrow \color{#c00}a\,$ is a denominator for unbounded powers of $\,\dfrac{a}b\,$ so $\,\dfrac{a}b\in\Bbb Z$
Likewise $\forall n\in\mathbb N:\ b\:\!\left(\dfrac{b}a\right)^{2n+1}\!\!\in \mathbb Z\ \ \Rightarrow\ \dfrac{b}a\in \Bbb Z.\ $ Thus $\ b\mid a\mid b\ $ so $\,a = b.$
Remark $ $ This generalizes to any Noetherian integrally-closed domain $D,\,$ e.g. any PID, since if unbounded powers of a fraction $f$ over $D$ have a common denominator then $\,f\in D\,$ (Proof)

A: Write:
$$a = \prod_1^m p_i ^{t_i}$$
$$b=\prod_1^m p_i ^{s_i}$$
where $t_i \ge 0$ and $s_i \ge 0$.
The given says that given any $i$,
$$\forall n\in \mathbb N: \begin{cases} t_i \le \frac{2n}{2n-1} s_i \\ s_i \le \frac{2n+1}{2n} t_i\end{cases}$$
Taking $n \to \infty$, we get $t_i \le s_i \le t_i$, i.e. $s_i = t_i$.

A: Hint:  that is a good start.  Now can you prove it for $a=p^k$ with any prime $p$?  $b$ has to again be a power of $p$.  After that, claim that it is multiplicative, so when you factor $a$ you get the two cases you have proved.


text:
Q: Type 'Foo' is not assignable to type 'T extends string ? string | Foo : Foo' I have the following code:
class Foo<T> {
  x?: T extends string ? string | Foo<T> : Foo<T>
}

function bar<T>(): Foo<T> {
  const x: Foo<T> = { }
  return { x }
}

Why does the compiler yield the following error for return { x }?
Type 'Foo<T>' is not assignable to type 'T extends string ? string | Foo<T> : Foo<T>'. ts(2322)

Foo<T> should satisfy both string | Foo<T> and Foo<T>, so it should also satisfy the type of Foo.x regardless of whether T extends string or not, right?

A: I agree that, no matter what T is, the type Foo<T> should be assignable to T extends string ? string | Foo<T> : Foo<T>.  This is actually a little tricky to verify, since  if T is a union type (e.g., number | Date), then Foo<T> will not be a union type (e.g., Foo<number | Date>), but T extends string ? string | Foo<T> : Foo<T> will be a union type (e.g., Foo<number> | Foo<Date>).  That's because T extends string ? ... : ... is a distributive conditional type which splits unions into their members before evaluation, and reunites into a new union afterward.  So the fact that the conditional type is always assignable to Foo<T> independently of T depends specifically on the definition of Foo<T>, and the fact that it is covariant in T (see this Q/A for a discussion of variance).
But the compiler does not see this.  Why?

Well, generally speaking, the evaluation of conditional types that depend on generic type parameters is deferred by the compiler.  There was some work done in microsoft/TypeScript#46429 to allow a type to be assignable to a conditional type if it was assignable to both the true and false branches of that type, but this only works for non-distributive types that don't use the infer keyword.  Since you have a distributive type, it doesn't work here.
So, evaluation of T extends string ? string | Foo<T> : Foo<T> is deferred until such time as T is specified.  Inside the body of bar(), T is unspecified, so the conditional type is not evaluated there.  It is essentially opaque to the compiler, and it won't be able to verify that you can assign a value to it, unless that value is also of the identical conditional type.  And Foo<T> is not.  So the compiler complains.

Playground link to code


text:
Q: Github Actions - use PullRequest Label Names as Values in Workflow if conditions I'm trying to retrieve Pull Request label name and use it as app version value in further workflow steps. The difficult part is that label name is not fixed, I want to pass it as a placeholder/structure and if it matches the workflow starts
I have tried setting up like this
name: sandbox

on:
  pull_request:
    branches: [ "master" ]
    types: [ closed ]

jobs:

  job1:
    if: contains(github.event.pull_request.labels.*.name, 'v*.*.*')
    runs-on: [ self-hosted ]
    steps:
      - id: app-ver
        run: |
          APP_VERSION=${{ toJson(github.event.pull_request.labels.*.name) }}
          echo $APP_VERSION
          echo "::set-output name=app_version::$APP_VERSION" >> $GITHUB_ENV
    outputs:
      app_version: ${{ steps.app-ver.outputs.app_version }}

  job2:
    needs: job1
    if: ${{ needs.job1.outputs.app_version}} != ''
    # continue if version label is set/exists

But the workflow skips checks and workflow fails when I add label named v1.0.0 and merge,close pull request.
I want to achieve something like this
1. (job1 - checks if 'app version' label with structure 'v*.*.*' exists in closed pull request)
2. (job2 - extracts version and uses it in building app)
3. (job3 - checks if 'testing approval' label has been added to closed pull request)
4. (job4 - when approval label been added deploy the app)


text:
Q: printing style attribute dynamically with Angular 6 I'm trying to display a tournament tree:
Initially, I have a lot of  like:

But I get :
WARNING: sanitizing unsafe style value top: -72px; left: 168px; height: 54px; (see http://g.co/ng/security#xss).

Now, I tried to change it like that:

But now, I have:
Cannot find a differ supporting object

And this error is much less explicit...
What should I do???

A:
Simple style binding

It's great for single value

  Lorem Ipsum

Using ngStyle directive

Better option for multiple css property binding

  Lorem Ipsum

With TS content
export class AppComponent  {
  match = {};

  constructor() {
      this.match['matchWrapperTop'] = 10
      this.match['matchWrapperLeft'] = 10
      this.match['matchWrapperWidth'] = 100
  }
}

A: Without seeing a full example it is a bit hard to tell. Based on the code you shared above and the Angular docs, it looks like you would want the following:
[style.top.px]="match['matchWrapperTop']"


text:
Q: Java multiple repaint() calls getting ignored For my algorithms class, our assignment is to perform mergesort on an array and show what is happening as an animation. I have the code (in theory) working, but when I call repaint() many times rapidly (to animate the array) they are getting ignored. No animation is being shown, just the final array. There should be one '-' after every ' * ' in the console but that is not the case, there are many ' * ' (as there should be) but only one '-'. The ' * ' denotes when the repaint method should be called, and the '-' denotes when it actually is called.
package a2;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Arrays;
import java.util.Random;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;

public class GraphicalSort extends JFrame implements ActionListener {
    int[] data = new int[200];
    int[] helper = new int[200];
    JPanel panel = new JPanel(); //Panel to hold graphical display of array
    JPanel buttonsPanel = new JPanel();
    JButton mButton = new JButton("Mergesort");
    JButton sButton = new JButton("Scramble");

    //Constants to scale the width and height
    int barWidth = 8;
    int barHeight = 1;

    public GraphicalSort() {
        setLayout(new BorderLayout());
        mButton.addActionListener(this);
        sButton.addActionListener(this);
        buttonsPanel.add(sButton);
        buttonsPanel.add(mButton);
        for (int i = 0; i < data.length; i++) {
            data[i] = (int) (500 * Math.random() + 1);
            helper[i] = data[i];
        }
        setSize(barWidth * data.length, barHeight * 500 + buttonsPanel.getHeight());
        panel = new ArrayPanel();
        add(buttonsPanel, BorderLayout.NORTH);
        add(panel, BorderLayout.CENTER);

        repaint();
        validate();
    }

    public static void main(String[] args) {
        GraphicalSort gs = new GraphicalSort();
        gs.setTitle("Graphical Sort");
        gs.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        gs.setLocationRelativeTo(null);
        gs.setResizable(false);
        gs.setVisible(true);
    }

    @SuppressWarnings("serial")
    class ArrayPanel extends JPanel {
        public void paintComponent(Graphics g) {
            super.paintComponent(g);
            g.setColor(Color.BLACK);
            System.out.println("-"); //when repaint is actually called
            int xPos = 0;
            for (int i = 0; i < data.length; i++) {
                g.fillRect(xPos, (barHeight * 500) - (barHeight * data[i]), barWidth, barHeight * data[i]);
                xPos += barWidth;
            }
        }
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        if (e.getSource() == mButton) {
            mergesort(0, data.length - 1);
        } else if (e.getSource() == sButton) {
            Random r = new Random();
            for (int i = 0; i < data.length; i++) {
                int index = r.nextInt(data.length);
                int temp = data[i];
                data[i] = data[index];
                data[index] = temp;
                panel.repaint();
            }
        }
    }

    private void mergesort(int low, int high)  {
        // Check if low is smaller then high, if not then the array is sorted
        if (low < high) {
            // Get the index of the element which is in the middle
            int middle = (low + high) / 2;
            // Sort the left side of the array
            mergesort(low, middle);
            // Sort the right side of the array
            mergesort(middle + 1, high);
            // Combine them both
            merge(low, middle, high);
            System.out.println("*"); //When the repaint should be called
            panel.repaint();
        }
    }

    private void merge(int low, int middle, int high) {

        // Copy both parts into the helper array
        for (int i = low; i <= high; i++) {
            helper[i] = data[i];
        }

        int i = low;
        int j = middle + 1;
        int k = low;
        // Copy the smallest values from either the left or the right side back
        // to the original array
        while (i <= middle && j <= high) {
            if (helper[i] <= helper[j]) {
                data[k] = helper[i];
                i++;
            } else {
                data[k] = helper[j];
                j++;
            }
            k++;
        }
        // Copy the rest of the left side of the array into the target array
        while (i <= middle) {
            data[k] = helper[i];
            k++;
            i++;
        }

    }
}

A: Your merge sort is happening quicker than you think, and the repaints are being called so close together that they are getting "stacked" and when this happens, yes, they can get ignored. Even if they aren't being ignored, again the speed of the code would result in no visible change to the GUI, and even if the process did take a lot of time, the GUI would be locked since the Swing event thread would be too busy to paint.
The solution is to slow down your code, but not with Thread.sleep(...) which again would tie up the Swing event thread if not called in a background thread, but rather with a Swing Timer. This would allow the code to progress in a slower step-wise fashion, but without tying up the Swing event thread.

A: To see animation during "scramble", you can replace your action preformed method with the following.  Optionally add code to limit scrambling to one scramble at a time.
public void actionPerformed(final ActionEvent e) {
    if (e.getSource() == mButton) {
        mergesort(0, data.length - 1);
    } else if (e.getSource() == sButton) {
        new Thread(new Runnable() {
            public void run() {
                final Random r = new Random();
                for (int i = 0; i < data.length; i++) {
                    try {Thread.sleep(10);}
                    catch (final InterruptedException e)
                    { e.printStackTrace(); }
                    final int index = r.nextInt(data.length);
                    final int temp = data[i];
                    data[i] = data[index];
                    data[index] = temp;
                    panel.repaint();
                }
            }
        }).start();
    }
}


text:
Q: SLICK2D game state not registered I have a slick2d JavaGame called I hate Christmas. The game will not let me transition to the next state. It says No game state registered with id of 1. When I run the same exact code in Game.java, It works fine. Here is my code
Game.java
package com.hurricane996.IHateChristmas;

import java.util.logging.Level;
import java.util.logging.Logger;

import org.newdawn.slick.AppGameContainer;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.SlickException;

import org.newdawn.slick.state.GameState;
import org.newdawn.slick.state.StateBasedGame;

public class Game extends StateBasedGame{
public static String name="I Hate Christmas";
public static Game instance=new Game(name);

public static final int MAIN_MENU=0;
public static final int GAME=1;
public Game(String name) {
    // TODO Auto-generated constructor stub
    super(name);
}

public static void main(String[] args) {
    // TODO Auto-generated method stub
    try{
        AppGameContainer agc=new AppGameContainer(new Game("Simple Slick Game"));
        agc.setDisplayMode(640, 480, false);
        agc.setShowFPS(false);
        agc.start();
    }catch(Exception e){
        Logger.getLogger(Game.class.getName()).log(Level.SEVERE, null, e);
    }

}

@Override
public void initStatesList(GameContainer arg0) throws SlickException {
    // TODO Auto-generated method stub
    this.addState( (GameState) new MainMenu());
    this.addState( (GameState) new GameScreen());
    this.enterState(GAME);
    this.enterState(MAIN_MENU);
}

}

MainMenu.java
package com.hurricane996.IHateChristmas;

import java.awt.Font;

import org.newdawn.slick.Color;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Input;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.TrueTypeFont;
import org.newdawn.slick.geom.Rectangle;
import org.newdawn.slick.state.GameState;
import org.newdawn.slick.state.StateBasedGame;

public class MainMenu implements GameState {
Font font = new Font("Verdana", Font.BOLD, 32);
TrueTypeFont ttf = new TrueTypeFont(font, true);
public MainMenu() {
    // TODO Auto-generated constructor stub
}

@Override
public void mouseClicked(int button, int x, int y, int arg3) {
        Game.instance.enterState(Game.GAME);

}

@Override
public void mouseDragged(int arg0, int arg1, int arg2, int arg3) {
    // TODO Auto-generated method stub

}

@Override
public void mouseMoved(int arg0, int arg1, int arg2, int arg3) {
    // TODO Auto-generated method stub

}

@Override
public void mousePressed(int arg0, int arg1, int arg2) {
    // TODO Auto-generated method stub

}

@Override
public void mouseReleased(int arg0, int arg1, int arg2) {
    // TODO Auto-generated method stub

}

@Override
public void mouseWheelMoved(int arg0) {
    // TODO Auto-generated method stub

}

@Override
public void inputEnded() {
    // TODO Auto-generated method stub

}

@Override
public void inputStarted() {
    // TODO Auto-generated method stub

}

@Override
public boolean isAcceptingInput() {
    // TODO Auto-generated method stub
    return true;
}

@Override
public void setInput(Input arg0) {
    // TODO Auto-generated method stub

}

@Override
public void keyPressed(int arg0, char arg1) {
    // TODO Auto-generated method stub

}

@Override
public void keyReleased(int arg0, char arg1) {
    // TODO Auto-generated method stub

}

@Override
public void controllerButtonPressed(int arg0, int arg1) {
    // TODO Auto-generated method stub

}

@Override
public void controllerButtonReleased(int arg0, int arg1) {
    // TODO Auto-generated method stub

}

@Override
public void controllerDownPressed(int arg0) {
    // TODO Auto-generated method stub

}

@Override
public void controllerDownReleased(int arg0) {
    // TODO Auto-generated method stub

}

@Override
public void controllerLeftPressed(int arg0) {
    // TODO Auto-generated method stub

}

@Override
public void controllerLeftReleased(int arg0) {
    // TODO Auto-generated method stub

}

@Override
public void controllerRightPressed(int arg0) {
    // TODO Auto-generated method stub

}

@Override
public void controllerRightReleased(int arg0) {
    // TODO Auto-generated method stub

}

@Override
public void controllerUpPressed(int arg0) {
    // TODO Auto-generated method stub

}

@Override
public void controllerUpReleased(int arg0) {
    // TODO Auto-generated method stub

}

@Override
public void enter(GameContainer arg0, StateBasedGame arg1) throws SlickException {
    // TODO Auto-generated method stub

}

@Override
public int getID() {
    // TODO Auto-generated method stub
    return 0;
}

@Override
public void init(GameContainer arg0, StateBasedGame arg1) throws SlickException {
    // TODO Auto-generated method stub

}

@Override
public void leave(GameContainer arg0, StateBasedGame arg1) throws SlickException {
    // TODO Auto-generated method stub

}

@Override
public void render(GameContainer arg0, StateBasedGame arg1, Graphics g) throws SlickException {
    // TODO Auto-generated method stub

    g.setBackground(Color.white);
    g.setColor(Color.black);
    Rectangle button=new Rectangle(640/2-20, 480/2-10, 40, 20);
    g.fill(button);
    g.draw(button);

    ttf.drawString(640/2-ttf.getWidth("I hate Christmas")/2,480/3,"I hate Christmas",Color.black);
    g.setColor(Color.white);
    g.drawString("Play",640/2-20 ,480/2-10);

}

@Override
public void update(GameContainer arg0, StateBasedGame arg1, int arg2) throws SlickException {
    // TODO Auto-generated method stub

}

}

GameScreen.java
package com.hurricane996.IHateChristmas;

import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Input;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.state.GameState;
import org.newdawn.slick.state.StateBasedGame;

public class GameScreen implements GameState {

public GameScreen() {
    // TODO Auto-generated constructor stub
}
@Override
public void mouseClicked(int arg0, int arg1, int arg2, int arg3) {
    // TODO Auto-generated method stub

}

@Override
public void mouseDragged(int arg0, int arg1, int arg2, int arg3) {
    // TODO Auto-generated method stub

}

@Override
public void mouseMoved(int arg0, int arg1, int arg2, int arg3) {
    // TODO Auto-generated method stub

}

@Override
public void mousePressed(int arg0, int arg1, int arg2) {
    // TODO Auto-generated method stub

}

@Override
public void mouseReleased(int arg0, int arg1, int arg2) {
    // TODO Auto-generated method stub

}

@Override
public void mouseWheelMoved(int arg0) {
    // TODO Auto-generated method stub

}

@Override
public void inputEnded() {
    // TODO Auto-generated method stub

}

@Override
public void inputStarted() {
    // TODO Auto-generated method stub

}

@Override
public boolean isAcceptingInput() {
    // TODO Auto-generated method stub
    return true;
}

@Override
public void setInput(Input arg0) {
    // TODO Auto-generated method stub

}

@Override
public void keyPressed(int arg0, char arg1) {
    // TODO Auto-generated method stub

}

@Override
public void keyReleased(int arg0, char arg1) {
    // TODO Auto-generated method stub

}

@Override
public void controllerButtonPressed(int arg0, int arg1) {
    // TODO Auto-generated method stub

}

@Override
public void controllerButtonReleased(int arg0, int arg1) {
    // TODO Auto-generated method stub

}

@Override
public void controllerDownPressed(int arg0) {
    // TODO Auto-generated method stub

}

@Override
public void controllerDownReleased(int arg0) {
    // TODO Auto-generated method stub

}

@Override
public void controllerLeftPressed(int arg0) {
    // TODO Auto-generated method stub

}

@Override
public void controllerLeftReleased(int arg0) {
    // TODO Auto-generated method stub

}

@Override
public void controllerRightPressed(int arg0) {
    // TODO Auto-generated method stub

}

@Override
public void controllerRightReleased(int arg0) {
    // TODO Auto-generated method stub

}

@Override
public void controllerUpPressed(int arg0) {
    // TODO Auto-generated method stub

}

@Override
public void controllerUpReleased(int arg0) {
    // TODO Auto-generated method stub

}

@Override
public void enter(GameContainer arg0, StateBasedGame arg1) throws SlickException {
    // TODO Auto-generated method stub

}

@Override
public int getID() {
    return 1;
}

@Override
public void init(GameContainer arg0, StateBasedGame arg1) throws SlickException {
    // TODO Auto-generated method stub

}

@Override
public void leave(GameContainer arg0, StateBasedGame arg1) throws SlickException {
    // TODO Auto-generated method stub

}

@Override
public void render(GameContainer arg0, StateBasedGame arg1, Graphics arg2) throws SlickException {
    // TODO Auto-generated method stub

}

@Override
public void update(GameContainer arg0, StateBasedGame arg1, int arg2) throws SlickException {
    // TODO Auto-generated method stub

}

}

The Traceback:
java.lang.RuntimeException: No game state registered with the ID: 1
at org.newdawn.slick.state.StateBasedGame.enterState(StateBasedGame.java:153)
at org.newdawn.slick.state.StateBasedGame.enterState(StateBasedGame.java:131)
at com.hurricane996.IHateChristmas.MainMenu.mouseClicked(MainMenu.java:21)
at org.newdawn.slick.state.StateBasedGame.mouseClicked(StateBasedGame.java:488)
at org.newdawn.slick.Input.fireMouseClicked(Input.java:1526)
at org.newdawn.slick.Input.considerDoubleClick(Input.java:1111)
at org.newdawn.slick.Input.poll(Input.java:1233)
at org.newdawn.slick.GameContainer.updateAndRender(GameContainer.java:641)
at org.newdawn.slick.AppGameContainer.gameLoop(AppGameContainer.java:411)
at org.newdawn.slick.AppGameContainer.start(AppGameContainer.java:321)
at com.hurricane996.IHateChristmas.Game.main(Game.java:31)

A: Your static Game instance is not equal to what is created in the main method. You create 2 Game instances and try to use the one that has no states initialized.
You can't do this:
public static Game instance = new Game(name);

and this:
AppGameContainer agc = new AppGameContainer(new Game("Simple Slick Game"));

Do this instead:
AppGameContainer agc = new AppGameContainer(instance);

When your click method is called, it uses a game instance with no states, since states aren't initialized in the creation of the game instance.


text:
Q: I Have 4-5 py file all of which uses same import libraries and Login using selenium python, Is their a better way for managing the import statement Consider 3 file, a.py, b.py, c.py
a.py file
import time
import selenium
Login()
xyz

b.py file
import time
import selenium
Login()
abc,

c.py file
import time
import selenium
Login()
efg

what is the better way of managing the above file so that it should not repeat import statement and function.

A: You can do like this:
# a.py
import time
import selenium

# b.py
from a import time, selenium #You can do like this...

# c.py
from b import * #...or like this

Anyway both the way of doing this are not recommended, you should better import al the needed modules at the beginning of your single files.


text:
Q: How to control the crashing of my app when i switch between tabs I have created a music application in iphone .
The App crashes if i keep on switching between the tabs while the song is playing.
How can i solve this problem .Please anybody help me regarding this problem

A: A common cause for crashes when something repetitive happens (eg switching between tabs, screens etc) is memory problems. Make sure you are releasing the correct objects in the right place. It could very well be that every switch you are allocating objects - without freeing them when switching again. This will eventually consume your memory and crash the application.

A: Generally such kind of issues are memory related.......just check whether ur releasing the objects at proper place or not..
Other u can put some code snippet to have a look so that we can know actually what's happening with your code..


text:
Q: How to enable "Allow access to file URLs" in google chrome to use some extensions on local files? I'm trying to use this extension link on my local file. But the option "Allow access to file URLs" is not available on the extension page. Is there any way for the extensions to work on local files?

A: That extension's manifest only has *://*/* which allows only http/https schemes, but not file. You can suggest the author to replace it with <all_urls>. Or you can download the extension, unpack, remove _metadata folder inside, and install it as a local extension (might wanna do it in Canary or you'll have to suppress the warning). – wOxxOm


text:
Q: Network not functioning on an ARM Linux rootfs with fakeroot/fakechroot I have created a rootfs using buildroot, but using a crosstool-ng tool chain with glibc.  This showed me the minimal set of files necessary.  I then replaced all the libraries with ones pulled straight from the squeeze .deb packages for armel.  I then added fakeroot and fakechroot to the mix (also from .deb packages).  I also modified the resolv.conf, hosts, and nsswitch.conf files to my liking.  After uploading this to my device, a lot is working.  cd / takes me to the correct place.  whoami returns root.  But, anything DNS related is not working.  For example ping google.com returns bad address.  I have copied the libnss_* and libresolv libraries over and everything else I think is necessary.  Entering the same setup, but using qemu and chroot on my host machine works, but I am trying to figure out what it is not working on my target device.
When I run strace ping google.com I get the following:
open("/data/local/target/bin/ping", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\2\0(\0\1\0\0\0\0\314\0\0004\0\0\0"..., 4094) = 4094
close(3)                                = 0
execve("/data/local/target/bin/ping", ["ping", "google.com"], [/* 20 vars */]) = 0
brk(0)                                  = 0xb5000
uname({sys="Linux", node="localhost", ...}) = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
mmap2(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x4001d000
open("/data/local/target/usr/lib/fakechroot/libfakechroot.so", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\364\32\0\0004\0\0\0"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0666, st_size=45540, ...}) = 0
mmap2(NULL, 77628, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x40026000
mprotect(0x40031000, 28672, PROT_NONE)  = 0
mmap2(0x40038000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0xa) = 0x40038000
close(3)                                = 0
open("/data/local/target/usr/lib/libfakeroot/libfakeroot-sysv.so", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\340'\0\0004\0\0\0"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0666, st_size=29092, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x4001f000
mmap2(NULL, 60672, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x40039000
mprotect(0x40040000, 28672, PROT_NONE)  = 0
mmap2(0x40047000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x6) = 0x40047000
close(3)                                = 0
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("tls/v7l/neon/vfp/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory)
...
open("/data/local/target/lib/libc.so.6", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\374V\1\0004\0\0\0"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0777, st_size=1209660, ...}) = 0
mmap2(NULL, 1246468, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x40048000
mprotect(0x4016b000, 32768, PROT_NONE)  = 0
mmap2(0x40173000, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x123) = 0x40173000
mmap2(0x40176000, 9476, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x40176000
close(3)                                = 0
open("tls/v7l/neon/vfp/libdl.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
...
open("/data/local/target/lib/libdl.so.2", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0$\t\0\0004\0\0\0"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0777, st_size=9808, ...}) = 0
mmap2(NULL, 41136, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x40179000
mprotect(0x4017b000, 28672, PROT_NONE)  = 0
mmap2(0x40182000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1) = 0x40182000
close(3)                                = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40020000
set_tls(0x40020170, 0x40020847, 0x40020848, 0x40020170, 0x40025000) = 0
mprotect(0x40182000, 4096, PROT_READ)   = 0
mprotect(0x40173000, 8192, PROT_READ)   = 0
mprotect(0xb1000, 4096, PROT_READ)      = 0
mprotect(0x40024000, 4096, PROT_READ)   = 0
brk(0)                                  = 0xb5000
brk(0xd6000)                            = 0xd6000
socket(PF_FILE, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) = 3
connect(3, {sa_family=AF_FILE, path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory)
close(3)                                = 0
socket(PF_FILE, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) = 3
connect(3, {sa_family=AF_FILE, path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory)
close(3)                                = 0
open("/etc/nsswitch.conf", O_RDONLY)    = -1 ENOENT (No such file or directory)
open("tls/v7l/neon/vfp/libnss_compat.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
...
open("/data/local/target/lib/libnss_compat.so.2", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0|\r\0\0004\0\0\0"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0777, st_size=26480, ...}) = 0
mmap2(NULL, 57952, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x40184000
mprotect(0x4018a000, 28672, PROT_NONE)  = 0
mmap2(0x40191000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x5) = 0x40191000
close(3)                                = 0
open("tls/v7l/neon/vfp/libnsl.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
...
open("/data/local/target/lib/libnsl.so.1", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0x/\0\0004\0\0\0"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0777, st_size=75732, ...}) = 0
mmap2(NULL, 116488, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x40193000
mprotect(0x401a5000, 28672, PROT_NONE)  = 0
mmap2(0x401ac000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x11) = 0x401ac000
mmap2(0x401ae000, 5896, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x401ae000
close(3)                                = 0
mprotect(0x401ac000, 4096, PROT_READ)   = 0
mprotect(0x40191000, 4096, PROT_READ)   = 0
open("/etc/nsswitch.conf", O_RDONLY)    = -1 ENOENT (No such file or directory)
open("tls/v7l/neon/vfp/libnss_nis.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
...
open("/data/local/target/usr/lib/libnss_nis.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/data/local/target/lib/libnss_nis.so.2", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0X\30\0\0004\0\0\0"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0777, st_size=38608, ...}) = 0
mmap2(NULL, 70236, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x401b0000
mprotect(0x401b9000, 28672, PROT_NONE)  = 0
mmap2(0x401c0000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x8) = 0x401c0000
close(3)                                = 0
open("tls/v7l/neon/vfp/libnss_files.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
...
open("/data/local/target/lib/libnss_files.so.2", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\330\31\0\0004\0\0\0"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0777, st_size=42688, ...}) = 0
mmap2(NULL, 74492, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x401c2000
mprotect(0x401cc000, 28672, PROT_NONE)  = 0
mmap2(0x401d3000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x9) = 0x401d3000
close(3)                                = 0
mprotect(0x401d3000, 4096, PROT_READ)   = 0
mprotect(0x401c0000, 4096, PROT_READ)   = 0
open("/data/local/target/etc/passwd", O_RDONLY|O_CLOEXEC) = 3
fcntl64(3, F_GETFD)                     = 0x1 (flags FD_CLOEXEC)
_llseek(3, 0, [0], SEEK_CUR)            = 0
fstat64(3, {st_mode=S_IFREG|0666, st_size=596, ...}) = 0
mmap2(NULL, 596, PROT_READ, MAP_SHARED, 3, 0) = 0x40021000
_llseek(3, 596, [596], SEEK_SET)        = 0
munmap(0x40021000, 596)                 = 0
close(3)                                = 0
getpid()                                = 9034
socket(PF_NETLINK, SOCK_RAW, 0)         = 3
bind(3, {sa_family=AF_NETLINK, pid=0, groups=00000000}, 12) = 0
getsockname(3, {sa_family=AF_NETLINK, pid=9034, groups=00000000}, [12]) = 0
gettimeofday({1366748508, 414909}, NULL) = 0
sendto(3, "\24\0\0\0\26\0\1\3\\\355vQ\0\0\0\0\0\0\0\0", 20, 0, {sa_family=AF_NETLINK,     pid=0, groups=00000000}, 12) = 20
recvmsg(3, {msg_name(12)={sa_family=AF_NETLINK, pid=0, groups=00000000}, msg_iov(1)=[{"0\0\0\0\24\0\2\0\\\355vQJ#\0\0\2\10\200\376\1\0\0\0\10\0\1\0\177\0\0\1"..., 4096}], msg_controllen=0, msg_flags=0}, 0) = 108
recvmsg(3, {msg_name(12)={sa_family=AF_NETLINK, pid=0, groups=00000000}, msg_iov(1)=[{"@\0\0\0\24\0\2\0\\\355vQJ#\0\0\n\200\200\376\1\0\0\0\24\0\1\0\0\0\0\0"..., 4096}], msg_controllen=0, msg_flags=0}, 0) = 128
recvmsg(3, {msg_name(12)={sa_family=AF_NETLINK, pid=0, groups=00000000}, msg_iov(1)=[{"\24\0\0\0\3\0\2\0\\\355vQJ#\0\0\0\0\0\0\1\0\0\0\24\0\1\0\0\0\0\0"..., 4096}], msg_controllen=0, msg_flags=0}, 0) = 20
close(3)                                = 0
open("/etc/resolv.conf", O_RDONLY)      = -1 ENOENT (No such file or directory)
uname({sys="Linux", node="localhost", ...}) = 0
socket(PF_FILE, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) = 3
connect(3, {sa_family=AF_FILE, path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory)
close(3)                                = 0
socket(PF_FILE, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) = 3
connect(3, {sa_family=AF_FILE, path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory)
close(3)                                = 0
open("/etc/nsswitch.conf", O_RDONLY)    = -1 ENOENT (No such file or directory)
open("tls/v7l/neon/vfp/libnss_dns.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
...
open("/data/local/target/lib/libnss_dns.so.2", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0000\v\0\0004\0\0\0"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0777, st_size=18040, ...}) = 0
mmap2(NULL, 49316, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x401d5000
mprotect(0x401d9000, 28672, PROT_NONE)  = 0
mmap2(0x401e0000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x3) = 0x401e0000
close(3)                                = 0
open("tls/v7l/neon/vfp/libresolv.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
...
open("/data/local/target/lib/libresolv.so.2", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0H$\0\0004\0\0\0"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0777, st_size=71524, ...}) = 0
mmap2(NULL, 79772, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x401e2000
mmap2(0x401f2000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x10) = 0x401f2000
mmap2(0x401f4000, 6044, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x401f4000
close(3)                                = 0
mprotect(0x401f2000, 4096, PROT_READ)   = 0
mprotect(0x401e0000, 4096, PROT_READ)   = 0
open("/etc/host.conf", O_RDONLY)        = -1 ENOENT (No such file or directory)
stat64("/etc/resolv.conf", 0xbed0eee8)  = -1 ENOENT (No such file or directory)
gettimeofday({1366748508, 437074}, NULL) = 0
socket(PF_INET, SOCK_DGRAM|SOCK_NONBLOCK, IPPROTO_IP) = 3
connect(3, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("127.0.0.1")}, 16) = 0
gettimeofday({1366748508, 438028}, NULL) = 0
poll([{fd=3, events=POLLOUT}], 1, 0)    = 1 ([{fd=3, revents=POLLOUT}])
send(3, "\234\32\1\0\0\1\0\0\0\0\0\0\6google\3com\0\0\1\0\1", 28, MSG_NOSIGNAL) = 28
poll([{fd=3, events=POLLIN}], 1, 5000)  = 1 ([{fd=3, revents=POLLERR}])
close(3)                                = 0
socket(PF_INET, SOCK_DGRAM|SOCK_NONBLOCK, IPPROTO_IP) = 3
connect(3, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("127.0.0.1")}, 16) = 0
gettimeofday({1366748508, 440124}, NULL) = 0
poll([{fd=3, events=POLLOUT}], 1, 0)    = 1 ([{fd=3, revents=POLLOUT}])
send(3, "\234\32\1\0\0\1\0\0\0\0\0\0\6google\3com\0\0\1\0\1", 28, MSG_NOSIGNAL) = 28
poll([{fd=3, events=POLLIN}], 1, 5000)  = 1 ([{fd=3, revents=POLLERR}])
close(3)                                = 0
gettimeofday({1366748508, 441638}, NULL) = 0
socket(PF_INET, SOCK_DGRAM|SOCK_NONBLOCK, IPPROTO_IP) = 3
connect(3, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("127.0.0.1")}, 16) = 0
gettimeofday({1366748508, 442345}, NULL) = 0
poll([{fd=3, events=POLLOUT}], 1, 0)    = 1 ([{fd=3, revents=POLLOUT}])
send(3, "\302\373\1\0\0\1\0\0\0\0\0\0\6google\3com\0\0\1\0\1", 28, MSG_NOSIGNAL) = 28
poll([{fd=3, events=POLLIN}], 1, 5000)  = 1 ([{fd=3, revents=POLLERR}])
close(3)                                = 0
socket(PF_INET, SOCK_DGRAM|SOCK_NONBLOCK, IPPROTO_IP) = 3
connect(3, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("127.0.0.1")}, 16) = 0
gettimeofday({1366748508, 444280}, NULL) = 0
poll([{fd=3, events=POLLOUT}], 1, 0)    = 1 ([{fd=3, revents=POLLOUT}])
send(3, "\302\373\1\0\0\1\0\0\0\0\0\0\6google\3com\0\0\1\0\1", 28, MSG_NOSIGNAL) = 28
poll([{fd=3, events=POLLIN}], 1, 5000)  = 1 ([{fd=3, revents=POLLERR}])
close(3)                                = 0
open("/data/local/target/etc/hosts", O_RDONLY|O_CLOEXEC) = 3
fcntl64(3, F_GETFD)                     = 0x1 (flags FD_CLOEXEC)
fstat64(3, {st_mode=S_IFREG|0666, st_size=40, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40021000
read(3, "127.0.0.1\tlocalhost\n127.0.1.1\tbu"..., 4096) = 40
read(3, "", 4096)                       = 0
close(3)                                = 0
munmap(0x40021000, 4096)                = 0
write(2, "ping: bad address 'google.com'\n", 31) = 31
exit_group(1)                           = ?

A lot went right.  It knew to add /data/local/target to the path when searching for executables and libraries.  You can see it finds the various libnss_* libraries and it figured out that the host file wasn't simply at /etc/hosts, but why do you think it didn't look in the correct location for nsswitch.conf and resolv.conf? This seems like a fakechroot issue or an issue with how I am using it.

A: Looks like the use of fopen in other libraries/executables can be intercepted by the use of LD_PRELOAD pointing at libfakechroot, but not fopen called from within eglibc itself. You will have to manually edit the eglibc source and build it. Looks like they did a good job making this easy.
This has been tested and works.


text:
Q: How do I import the necessary Jinterface packages in Java? I understand that I need to import the packages in
import com.ericsson.otp.erlang.*;

To run Jinterface in Java, this is not included in Java's default libraries but in Erlang's. How do I access this library? Which path should I use? I've google it but found nothing. I am using Ubuntu 13.10. The above code is not enough for this to work.

A: If you have done any Java development before, then you know that you should add OtpErlang.jar to your application's class path.
You can do this in the command line, Ant, Maven, Gradle or even in your IDE.
Command line example:
javac -classpath OtpErlang.jar YourGame.java

I use OS X and OtpErlang.jar is under:

/usr/local/Cellar/erlang/R16B03-1/lib/erlang/lib/jinterface-1.5.8/priv/OtpErlang.jar

Keep in mind that you need to include OtpErlang.jar also when you run your game.

A: Try looking in the Jinterface users Guide, they give an example of compiling the Java code.


text:
Q: Condition based click event in Angular 2 In my application I would like to have conditional based click event ,

 0) {removeSelected(item.spId)}">

In the above code removeSelected function should be executed only when idx >0 , any idea how to implement

A: Simply use a ternary:

 0 ? removeSelected(item.spId) : false">

This will only call removeSelected function when the condition is true, if it's false then it won't do anything.

A: (click)="idx > 0 && removeSelected(item.spId)"


text:
Q: Equivalence of the Dirac representation of the Lorentz algebra and its conjugate in even dimensions - Polchinski In Polchinski's String Theory, Appendix B.1 we look at the smallest irreps of the Clifford algebra in even-dimensional spacetimes $d=2k+2$. In (B.1.16) he defines two operators from the gamma matrices $\Gamma^{\mu}$
$$ B_1 = \Gamma^3 \Gamma^5\ldots \Gamma^{d-1} \quad , \quad B_2 = \Gamma B_1 $$
where $ \Gamma = i^{-k} \Gamma^0 \Gamma^1 \ldots \Gamma^{d-1}$ is the chirality operator.
In (B.1.18) Polchinski then writes that for either $B_1$ or $ B_2$ and only for these two matrices the following holds:
$$ B \Sigma^{\mu \nu} B^{-1} = - \Sigma^{\mu \nu *} \tag{B.1.18} \label{1}$$
where $\Sigma^{\mu \nu} = - \tfrac{i}{4} [\Gamma^{\mu},\Gamma^{\nu}] $ are the Lorentz generators and $*$ denotes complex conjugation. In other words this signifies the equivalence with the conjugate of the Dirac representation of the Lorentz algebra.
Question: How do you show that \eqref{1} indeed holds only for $B_1$ or $B_2$?
Any help much appreciated.

A: I have found my answer. It requires a little bit of knowledge of gamma matrices. Of course, as the question is stated, we can find more than $2$ matrices which satisfy $~(\rm B.1.18)~$, as for example $~\lambda B~$ for any $~0\neq\lambda~$ also works and most linear combinations of these matrices work as well. What is meant here is that $~B_{1,2}~$ are the independent generators. We will show this now.
Assume we have some $ B_1 $ and $B_2$ such that $~(\rm B.1.18)~$ holds. Defining $~X= B_2 B_1^{-1} ~$, this implies that
$$ [X,\Gamma^{\mu \nu}]=0 \tag{1}$$
where $~\Gamma^{\mu \nu}=\Gamma^{[\mu} \Gamma^{\nu]} \equiv \frac{1}{2}[\Gamma^{\mu},\Gamma^{\nu}] ~$. Below we show that this fact implies that
$$ X=a\mathbf{1}+b\Gamma ~. \tag{2} $$
This then answers our question, as $~B_2=aB_1+b\Gamma B_1~$ so the generators indeed are $~B_1~$ and $~\Gamma B_1~$.
Proof of $(2)$ from $(1)$
This assumes basic knowledge of gamma matrices which can be found e.g. in Chapter 3 of the book Supergravity by Freedman and van Proeyen. First define $~\Gamma^{\mu_1\ldots\mu_r}=\Gamma^{[\mu_1}\ldots\Gamma^{\mu_r]}~$ to be the completely antisymmetrized products of gamma matrices. It can be shown that the set
$$ \{\mathbf{1},\Gamma^{\mu},\Gamma^{\mu_1\mu_2},\ldots,\Gamma^{\mu_1\ldots\mu_d} \} $$
where the index values satisfy $~\mu_1<\ldots<\mu_r~$ forms a basis of the space of (complex) matrices of dimension $~2^{k+1} \times 2^{k+1}~$ where $~d=2k+2~$. Any such matrix $~M~$ can thus be expanded as
$$ M=\sum_{k=0}^{d} \frac{1}{k!} m_{\mu_1\ldots\mu_k} \Gamma^{\mu_1\ldots\mu_k} ~.$$
Expanding in this way our matrix $~X=B_2 B_1^{-1}~$ the condition $(1)$ becomes
$$0= \sum_{k=0}^{d} \frac{1}{k!} x_{\mu_1\ldots\mu_k} [\Gamma^{\mu_1\ldots\mu_k}, \Gamma^{\nu \rho}] \tag{3} $$
Using the algorithm explained in Chapter 3 of Supergravity we can show that
$$ [\Gamma^{\mu_1\ldots\mu_k}, \Gamma_{\nu \rho}] = 4k \Gamma^{[\mu_1\ldots\mu_{k-1}}_{\phantom{[\mu_1\ldots\mu_{k-1}}[\rho} \delta^{\mu_k]}_{\nu]}~. \tag{4}$$
Note that $~[\mathbf{1},\Gamma_{\nu \rho}]=0~$ as well as
$~[\Gamma^{\mu_1 \ldots \mu_d} ,\Gamma_{\nu \rho}]=0~$, which also follows from $(4)$ because we have only $d$ distinct indices. Note that $~\Gamma^{\mu_1 \ldots \mu_d} \propto \varepsilon^{\mu_1\ldots\mu_d}\Gamma ~$ where $~\varepsilon^{\mu_1\ldots\mu_d}~$ is the Levi-Civita tensor. Altogether $(3)$ and $(4)$ imply that
$$ x_{\mu_1\ldots\mu_k}=0 \qquad \text{for} \quad 1\leq k < d ~.$$
This gives $(2)$, quod erat demonstrandum.


text:
Q: Database.SetInitializer is not seeding the database? I am using enitity framework version 6.1.0 code first approch. The database is just creating fine but when come to seeding part it is not seeding the override Seed Method.
How do i make to seed my data?
My testing implementation is as
public class Products
{
    public Products()
    {
        this.Categories = new HashSet<Categories>();
    }

    [ScaffoldColumn(false)]
    [Key()]
    [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
    public int ProductId { get; set; }

    [Required,StringLength(100),Display(Name="Product Name")]
    public string Name { get; set; }

    public int? CategoryId { get; set; }
    public virtual ICollection<Categories>  Categories{ get; set; }
}

public class Categories
{
    [ScaffoldColumn(false)]
    [Key()]
    [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
    public int CategoryId { get; set; }

    [Required,StringLength(100),Display(Name="Category")]
    public string Name { get; set; }
    public virtual ICollection<Products> Products { get; set; }

}

The ProductsInitializer is inherited from DropIfModelchanges
 public class ProductsDatabaseInitializer : DropCreateDatabaseIfModelChanges<ETestContext>
 {
    protected override void Seed(ETestContext context)
    {
        GetCategories().ForEach(c => context.Categories.Add(c));
        GetProducts().ForEach(p => context.Products.Add(p));
        context.SaveChanges();

        base.Seed(context);
    }

    private static List<Categories> GetCategories()
    {
        var categories = new List<Categories>{
            new Categories{
                CategoryId=101,
                Name="Electronics"
            },
            new Categories{
                CategoryId=102,
                Name="Clothing"
            }
        };
        return categories;
    }

    private static List<Products> GetProducts()
    {
        var products = new List<Products>{
           new Products{
             CategoryId = 101,
             ProductId=1,
             Name="Laptops"
           },
           new Products{
             CategoryId = 101,
             ProductId=2,
             Name="Desktops"
           },
           new Products{
             CategoryId = 102,
             ProductId=3,
             Name="Male Clothing"
           },
           new Products{
             CategoryId = 102,
             ProductId=4,
             Name="Female Clothing"
           }
       };
        return products;
    }

}

And My DBcontext class is as
public class ETestContext : DbContext
{

    public ETestContext()
        : base("ETest")
    {

    }

    public DbSet<Categories> Categories { get; set; }
    public DbSet<Products> Products { get; set; }

    protected override void OnModelCreating(DbModelBuilder modelBuilder)
    {
        modelBuilder.Entity<Categories>().HasMany<Products>(c => c.Products).WithMany(p => p.Categories)
            .Map(c =>
            {
                c.MapLeftKey("CategoryId");
                c.MapRightKey("ProductId");
                c.ToTable("CategoryProduct");
            });
        base.OnModelCreating(modelBuilder);
    }
}

In the global.asax I am implementing as
protected void Application_Start(object sender, EventArgs e)
{
   Database.SetInitializer(new Wb1.Model.ProductsDatabaseInitializer());
   using (var dbContext = new Wb1.Model.ETestContext())
   {
     if (!dbContext.Database.Exists())
     {
       dbContext.Database.Create();
     }
     dbContext.Database.Initialize(true);
   }
}

A: You should call Initialize instead of Create, it has different implementation with the initializer.

Creates a new database on the database server for the model defined in
  the backing context. Note that calling this method before the database
  initialization strategy has run will disable executing that strategy. - MSDN

And since ProductsDatabaseInitializer is DropCreateDatabaseIfModelChanges, the moment you call Initialize, the database has been created so that the Seed method will not be executed, but if there is a model change, the Seed method will be executed because it's dropped and recreated.
The proper way should be just calling the Initialize without checking if it exists or not, because it's already derived from DropCreateDatabaseIfModelChanges, which means create if it doesn't exists and execute the Seed method, or drop and create if model's changed and execute the Seed method, otherwise do nothing.
Database.SetInitializer(new Wb1.Model.ProductsDatabaseInitializer());
using (var dbContext = new Wb1.Model.ETestContext())
{
    dbContext.Database.Initialize(true);
}


text:
Q: Groovy - map without assigned to any variable I am using grails framework and there is these line codes in service groovy file. I see in this code, it look like map had been implemented but I don't understand how it will work without it being assigned to any variable in this file.
class ApprovalHeaderLEADEDService extends ApprovalHeaderService {
    def generateTable(ApprovalHeader ah,BondingDiagram bd){

        def waferMountOrientation= findApprovalHeaderKitName(ah,bd,"WaferMountOrientation");
        def sawForModels = findApprovalHeaderKitName(ah,bd,"SawForModels");
        def sawBladeType1= findApprovalHeaderKitName(ah,bd,"SawBladeType1");

        [
            waferMountOrientation:waferMountOrientation,
            sawForModels:sawForModels,
            sawBladeType1:sawBladeType1

        ]
    }

I expect a map would look like this
def map = [waferMountOrientation:waferMountOrientation, sawForModels:sawForModels, sawBladeType1:sawBladeType1]

Could anyone explain to me how this will work or suggest me any reference where I can read about this kind of map case?

A: It's the return value of the function.
http://groovy-lang.org/semantics.html#_optional_return_keyword

A: This:
def generateTable(ApprovalHeader ah,BondingDiagram bd){

    def waferMountOrientation= findApprovalHeaderKitName(ah,bd,"WaferMountOrientation");
    def sawForModels = findApprovalHeaderKitName(ah,bd,"SawForModels");
    def sawBladeType1= findApprovalHeaderKitName(ah,bd,"SawBladeType1");

    [
        waferMountOrientation:waferMountOrientation,
        sawForModels:sawForModels,
        sawBladeType1:sawBladeType1

    ]
}

Is the same as this:
def generateTable(ApprovalHeader ah,BondingDiagram bd){

    def waferMountOrientation= findApprovalHeaderKitName(ah,bd,"WaferMountOrientation");
    def sawForModels = findApprovalHeaderKitName(ah,bd,"SawForModels");
    def sawBladeType1= findApprovalHeaderKitName(ah,bd,"SawBladeType1");

    def someMap = [
        waferMountOrientation:waferMountOrientation,
        sawForModels:sawForModels,
        sawBladeType1:sawBladeType1

    ]
    return someMap
}

A more simple example demonstrating the same thing (all of the following methods behave the same way):
def someMethod() {
    42
}

def someMethod() {
    return 42
}

def someMethod() {
    def value = 42
    value
}

def someMethod() {
    def value = 42
    return value
}


text:
Q: iOS MQTT Client Framework : 'SocketRocket/SRWebSocket.h' file not found I am trying to add MQTT Client framework to my project by copying source files to project. It gives me SocketRocket/SRWebSocket.h file not found errors. I tried including socketRocket Library and changing SocketRocket/SRWebSocket.h to SRWebSocket.hthen I got errors on following line in MQTTWebsocketTransport.h file:
urlRequest.SR_SSLPinnedCertificates = self.pinnedCertificates;

What am I doing wrong?

A: "SocketRocket/SRWebSocket.h file not found" caused by you did "pod install" with incorrect target or maybe you didn't copy "SocketRocket" folder into your project.
Let follow steps again:

*

*Download iOS MQTT Client Framework again

*Open podfile and update it:

Change target from "MQTTClienttvOS" to "MQTTClientiOS"
Change platform to "ios"

*Do "pod install".

*Open workspace and build target "MQTTClientiOS"

*Copy and import MQTTClient.frameworkd and folder "SocketRocket" into your project.

P/S: If you want to use "MQTTWebsocketTransport" instead, you let set MQTTWebsocketTransport.h into Headers and MQTTWebsocketTransport.m into Compile Sources.


text:
Q: Upload file to HttpConnection - BLACKBERRY/ JavaME I like to upload a file to a http server. This is the code I have so far. The problem is the file is not being uploaded at all. What wrong with the code?
update: I have managed to solve it. Anyone having same problem, maybe this code might help.
try{
   FileConnection path = (FileConnection)Connector.open(main_directory + "status.zip");
                if (!path.exists()) {path.create();}

                 byte[] buf ;
                 buf = new byte[(int) path.fileSize()];

                in = path.openInputStream();
                in.read(buf);

                Logger.logEventInfo("FILE INPUT: " + in);
                ByteArrayOutputStream outputstream = new ByteArrayOutputStream(buf.length);
                Base64OutputStream base64 = new Base64OutputStream( outputstream );
                    base64.write(buf);

String upload= null;
                    upload= outputstream.toString();

A: You're calling InputStream.read( byte[] ) with a zero-length byte array, which by definition always returns 0 (no bytes read), which is why your while loop never exits.
Well, that's your first problem. There are many other issues with this code.


text:
Q: Erasing elements from generic (void *) list in C I'm writing a generic doubly linked list in C.
typedef struct ListNode {
    void *data;
    struct ListNode *prev;
    struct ListNode *next;
} ListNode;

typedef struct List {
    struct ListNode *head;
    struct ListNode *tail;
} List;

Inserting element into list is done simply by
listNode->data = data;

where listNode is some list element, and data is a data to be inserted. So I'm doing a shallow copy. Now, when I want to delete something from list, I want to be able to perform a deep copy, so I have a function performing deep delete of objects I pass to the list. I would like to pass a pointer to this function as a parameter to function deleting member of list. An example is given below.
typedef struct Object {
    int *ptr;
} Object;

void removeObject(Object *object) {
    free(object->ptr);
    free(object);
}

void removeListNodeFromList(List *list, ListNode *listNode,
                               void (*removeEntry)(void *data)) {
    // Code handling removing listNode from list
    // ...

    removeEntry(listNode->data);
    free(listNode);
}

void fun() {
    List *list = NULL;
    ListNode *listNode = NULL;
    // Some code giving specific value to list and listNode
    // ...

    removeListNodeFromList(list, listNode, removeObject);
}

This code won't compile because (the last line of code) removeObject is incompatible with removeEntry. How can I overcome this issue?

A: To make the function signatures compatible, your removeObject must accept a generic pointer and cast it appropriately:
void removeObject(void *vptr) {
    Object *object = (Object *)vptr;
    free(object->ptr);
    free(object);
}


text:
Q: how to add multiple clients discord.py code import discord
import os
from discord.ext import commands
from keep_alive import keep_alive

client=commands.Bot(command_prefix=':', self_bot=True, help_command=None)

GUILD_ID = 952514037596438588
CHANNEL_ID = 977851845722664980

@client.event
async def on_ready():
    os.system('clear')
    print(f'Logged in as {client.user} ({client.user.id})')
    vc = discord.utils.get(client.get_guild(GUILD_ID).channels, id = CHANNEL_ID)
    await vc.guild.change_voice_state(channel=vc, self_mute=False, self_deaf=False)
    print(f"Successfully joined {vc.name} ({vc.id})")

keep_alive()
client.run(os.getenv("TOKEN"))

in this code i can only add one token, one channel id and one server id and i want to multiply this to add other tokens


text:
Q: В android'e при парсинге jsoup'ом загружается не весь html текст Доброго. В android'e парсится html сайта. Вот такое примитивный код:
class Description extends AsyncTask<Void, Void, Void> {
public String desc;

@Override
protected void onPreExecute() {
    super.onPreExecute();
}

@Override
protected Void doInBackground(Void... params) {
    try {
        Document document = Jsoup.connect("http://www.google.ru").get();
        desc = document.html();
    } catch (IOException e) {
        e.printStackTrace();
    }
    return null;
}

@Override
protected void onPostExecute(Void result) {
    Log.i("test", desc);
}
}

При этом загружается только часть html кода, прерывается на случайном месте. При проверке в Eclipse всё хорошо отображается.

@ЮрийСПБ
@metalurgus
Не думаю, что проблема с выводом текста.

Причем при получении html'a посредством HttpUrlConnection'а та же самая несуразица :с
Дело не в том, что в странице отсутствуют какие-то блоки. Код прерывается на случайном месте, может вообще на половине названия тега. Вряд ли, это это из-за особенностей String'а или логов. Делал построчное выведение в логи с помощью InputStream'a - результат тот же. (!) К тому же, посмотрите, пожалуйста, на последний скрин, там я делал выборку по тегу 'а'. Ничего не нашлось. (!) В eclipse всё прекрасно работает.

A: Document document = Jsoup.connect("http://www.google.ru").maxBodySize(0).get();

Решает проблему maxBodySize(0) который снимает ограничение на размер страницы, так же можно убрать timeout(0).

A: Страница, находящаяся по адресу, который вы загружаете (http://www.google.ru) не имеет HTML кода(кроме тегов html, head, sctipt), а все содержимое на ней генерируется при помощи JavaScript динамически. Это значит, что вы получаете весь код страницы, но JSOUP не запускает работу JavaScript.

A: Скорее всего дело тут не в том, что не весь HTML загрузился, а в том, что Log просто не весь текст вывел.
Попробуйте разбить полученную строку на небольшие части и вывести их в цикле, по очереди.
Ну или просто попробуйте через Jsoup обратиться к последнему тегу в загруженной HTML-ке.

A: Metalurgus Прав, сам сталкивался с такой проблемой. Проблема в том, что вы скачиваете HTML страничку, но JS скрипты не выполняются и поэтому вы не видите полной картины

A: Мне один только maxBodySize(0) не помог. У меня появился весь код когда прописала:
doc = Jsoup.connect(mLink).maxBodySize(0).userAgent("Mozilla/5.0 (Windows NT 5.1)" +
      "AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.110 Safari/537.36")
      .timeout(0).get();


text:
Q: MySQL measure full table scan time I have a 5TB table. All I want to know is how much time it takes to do a full table scan. I don't care about the data getting returned. I tried to run select * from mytable; but for some reason the client got killed. Not sure if it is caused by some sort of timeout or too much data to handle. Is there a reliable way to get the time consumption of the query? Not sure if this is gonna help but my table schema looks like this: create table datatable (a integer, name varchar(200), class varchar(200), reason varchar(200));

A: Try this:
set profiling = 1;
select count(*) from datatable where a = 1;
show profiles;

Assuming you don't have any indexes on column a this should force a full table scan and it will return only one row, with minimum overhead for data transfer.

A: I also had the same problem when I tried to do it with mysql workbench(as it gives execution time) but connection to mysql server failed whenever the data was large.
So since I was using java and springboot, I made an Api, service and repository for it to interact with the database where I had to make classes as entity for each table
and then I just let the spring jpa give command to mysql to scan the required database, I used nanosecond library of java to calculate time difference and converted that into seconds. It went quite smooth. I understand that some extra time is added due to being spring jpa in between me executing the call to run the scan and mysql database actual scan, but I think that is very negligible.
So maybe you can do the same in your preference of language or framework.


text:
Q: Data Structure which can maintain insertion order, filter out duplicate elements and easily remove first element? I need to use a data structure which can maintain the insertion order, do not store any duplicates and I can easily remove first element from it efficiently.
public static LinkedHashSet<String> getData(TypeEnum flowType) {
    LinkedHashSet<String> listOfPaths = new LinkedHashSet<String>();
    String prefix = flowType.equals(TypeEnum.PARTIAL) ? TypeEnum.PARTIAL.value() : TypeEnum.UNPARTIAL.value();
    listOfPaths.add(prefix + LOCAL_PATH); // first element in the list is always LOCAL PATH
    for (String path : REMOTE_PATH) {
        listOfPaths.add(prefix + path);
    }
    return listOfPaths;
}

Earlier, I was using LinkedList from which I can easily remove the first element by using removeFirst() method and it also maintains the insertion order but it can store duplicate elements which is I don't want.
Can I easily get the first element by removing it from LinkedHashSet with my above solution?
What are the options I can have here which will be efficient?
Below is how I was using when getData method returns LinkedList but it doesn't filter out duplicates.
LinkedList<String> data = getData(flowType);

String local_path = data.removeFirst(); // this is my local path
// use local_path here

// now iterate all the remote path
for(String remotePath : data) {
    // do something with remotePath
}

A: You can get the first element using iterator, and remove it.
    String localpath = null;
    Iterator itr = listOfPaths.iterator();
    if(itr.hasNext()){
      localpath = itr.next()
      listOfPaths.remove(localpath);
    }


text:
Q: The response from the remote server was: Message rejected when sending mail via xampp localhost i'm trying to send mail via PHP code
I'm using Xampp v3.2.2,
I have configured XAMPP to send mail from localhost just like this:
in php.ini :
extension=php_openssl.dll
SMTP=smtp.gmail.com
smtp_port=587
sendmail_from = my_id@gmail.com
sendmail_path ="\"C:\xampp\sendmail\sendmail.exe\" -t"
in sendmail function, in sendmail.ini:
smtp_server=smtp.gmail.com
smtp_port=587
error_logfile=error.log
debug_logfile=debug.log
auth_username=my_id@gmail.com
auth_password=my_id_password
force_sender=my_id@gmail.com
i'm very sure that this configuration is right, my code is:

<?php
$to = "another_id@hotmail.com";
$subject = "wa a5iran zobtet";
$txt = "Hello world! My first mail with PHP";
$headers = "From: Someone" . "\r\n";

mail($to,$subject,$txt,$headers);
?>

the message is sent but i got this :
Message blocked
Your message has been blocked by another_id@hotmail.com. See technical details below for more information.
The response from the remote server was:
Message rejected. See https://support.google.com/mail/answer/69585 for more information.


text:
Q: Model fitting random data as well as highly correlated data I have a TensorFlow program that tries to predict a person's total compensation based on their salary. The program's accuracy tops out at about $65,000 mean squared error.
This level of inaccuracy was strange because salary is highly correlated with total compensation in my data set. So, I decided to change salary to random numbers. My model still topped out at $65,000 mean squared error. Why is my highly correlated input giving results on par with random numbers?
Here is my program:
DATA = pd.read_csv ('compensation.csv')

GOAL = DATA['Total Compensation']
INPUT_DATA = (DATA['Salaries'])

model_inputs = tf.keras.Input (shape=(1))
x = tf.keras.layers.Dense (20, activation=tf.nn.relu) (model_inputs)
x = tf.keras.layers.Dense (50,activation='softmax') (x)

outputs = tf.keras.layers.Dense (1) (x)

my_model = tf.keras.Model (inputs=model_inputs, outputs=outputs)

my_model.compile (loss=tf.keras.losses.MeanSquaredLogarithmicError(), optimizer=tf.keras.optimizers.Adam(learning_rate=.1), metrics=tf.metrics.MeanAbsoluteError())

my_model.fit (x=INPUT_DATA,y=GOAL,batch_size=1000,epochs=1000)


text:
Q: Как правильно сделать рекурсию формулы в C++. Возведение в степень не через pow() есть формула, которую надо сделать через рекурсию. Число n заданно в файле под названием input.txt
Формула:
Сумма от i=1 до n = 2i/2^i+1
Моя проблема в том что не могу сделать возведение степень не через pow()
Код программы
#include <iostream>
#include <fstream>
using namespace std;
double series(int n)
{
  double sum;
  if (n == 0)
  {return 0;}                             //    2i/1+2^i
  else
  {
      sum = ((double)(2*n) / (double)(2*n + 1)) + series(n - 1);
      return sum;
  }
}
int main()
{
  ifstream fin;
  fin.open("input.txt");
  if (!fin) return 1;
int n;
fin >> n;
double sum = series(n);
cout << sum;
fin.close();
return 0;
}

По моим расчетам если n=2 то ответ будет 1.466666 приблизительно

A: Вот как пример кода:
double series_step(int i, int n, int fact)
{
    if (i > n)
        return 0;
    return ((double)i * 2) / ((double)fact + 1) + series_step(i + 1, n, fact * 2);
}

double series(int n) {
    return series_step(1, n, 2);
}

То есть начинаем с i = 1 и fact = 2 и каждую итерацию мы увеличиваем i на 1, а fact умножаем на 2
Результат программы при n = 2:
1.46667


text:
Q: How to fill ACF meta key with custom taxonomy term under publish_post hook? Hy everybody.
With the Advanced Custom Fields plugin, I've created a meta key (price_ord) for a custom post type (marca).
Whereas the values for this meta key have to be the same as the terms of a taxonomy (prezzo) attached to marca post,
I like to fill automatically this meta key when I pubblish a new post, avoiding a double insertion.
My idea was to retrieve the term of the taxonomy and use it to update the meta key, when I click the Upload button on new custom post type page.
I've tried this solution, but doesn't work, because the meta key remains empty.
Do I mistake the use of that hook?
Could someone give me some advice, please?
function update_post_price() {
    global $post;
    $id = $post->ID;
    $price_terms = get_the_terms( $id, 'prezzo' );
    if ($price_terms) {
      foreach($price_terms as $price_term) {
        if ($price_term->parent != 0) { // avoid parent categories
            $updated_meta = $price_term;
        }
      }
    }
    if ($updated_meta) {
        update_field( 'prezzo_ord', $updated_meta, $post_id);
    }
}
add_action( 'publish_marca', 'update_post_price', 10, 2 );