text:
Q: Rotate raster before tiling I have set of referenced rasters (.tif), which need to be tiled - but each of them need to be rotated by a certain degree before that using python (gdal mainly as other routines use it as well). In QGIS, for example, I can achieve the right view by changing map rotation value at the bottom right corner of the screen - it does exactly what i want, but does not affect tiling process in any way and can't be done outside of QGIS interface, which is important too.

While using North Pole Azimuthal projection (EPSG:102016) I tried to define custom CRS similar to it, but had no sucess as +alpha and +gamma parameters work only with +omerc projections.
I would be very grateful for pointing me in the right direction. Should i use custom wkt-defined CRS-es or, perhaps, in gdal tiling instrument there is some built-in way for rotating an image..?
P.S. Using azimuthal projection for tiling is kind of weird but it has its purpose.
Thanks in advance for your help!
UPDATE:
Seems like rotation can be performed by changing affine parameters via gdal.SetGeoTransform. However with formulae provided by @MortenSickel i got following result (1 is raster before changing affines, 2 - after). Btw the order of parameters is different in gdal compared to esri world file and that can lead to errors, but i double-checked that.

A: What might work is to rotate the raster in qgis and then export it. That would by far be the easiest.
If the tif file is stored with a tfw world file, you should be able to rotate the raster by editing the tfw file. The format is relatively simple, e.g. https://en.wikipedia.org/wiki/World_file.
I would guess your tfw file looks something like
10
0
0
10
12345678
876543

Where the lines are (copied from the above mentioned wikipedia page)
Line 1: A: x-component of the pixel width (x-scale)
Line 2: D: y-component of the pixel width (y-skew)
Line 3: B: x-component of the pixel height (x-skew)
Line 4: E: y-component of the pixel height (y-scale), typically negative
Line 5: C: x-coordinate of the center of the original image's upper left pixel transformed to the map
Line 6: F: y-coordinate of the center of the original image's upper left pixel transformed to the map

So if my math serves me right, to rotate the raster n degrees, you would make your lines
cos(n)*A
sin(n)*A
-sin(n)*B
cos(n)*B
12345678
876543

If you have the file raster.tif and raster.tfw, rename both of them to e.g. raster_rotate.tif and raster_rotate.tfw and edit the new .tfw-file.
I have edited tfw files a few times, but just to move the raster around or change the resolution, so this is just something I know should be working, but it may be more difficult
If your tif-file is without a .tfw file, the same information is stored as field within the tif-file. To get an editable .tfw-file run
gdal_translate -of GTiff -co tfw=yes infile.tif outfile.tif

This will create the outfile.tfw. To be able to get any effect of this file, you need to open the outfile.tfw in an image editor that can or will delete the attributes. (I tested it in gimp and exported the file as tif, selected the advanded drop down and unchecked all meta data)
Hope this helps, but also hope there is an easier way of doing it...
Hope this helps.


text:
Q: Symfony2 and nginx web host Hello i installed symfony2 on my nginx web host but it densest show up the project I've done
http://www.instelamrketing.es its the website and i used this commands to configure the server
http://www.leaseweblabs.com/2013/05/symfony2-under-nginx-on-ubuntu-12-04/
here some error logs
tail -f logs/error_log
#4 /home/intelmarketing.es/public_html/app/cache/prod/classes.php(5519): Monolog\Logger->addRecord(500, 'Uncaught PHP Ex...', Array)
#5 /home/intelmarketing.es/public_html/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/EventListener/ExceptionL in /home/intelmarketing.es/public_html/app/cache/prod/classes.php on line 5141" while reading response header from upstream, client: 180.211.176.176, server: intelmarketing.es, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9007", host: "www.intelmarketing.es"
2013/08/14 18:15:05 [error] 2583#0: *3 FastCGI sent in stderr: "PHP Fatal error:  Uncaught exception 'UnexpectedValueException' with message 'The stream or file "C:/wamp/www/symfony/app/logs/prod.log" could not be opened: failed to open stream: No such file or directory' in /home/intelmarketing.es/public_html/app/cache/prod/classes.php:5141
Stack trace:
#0 /home/intelmarketing.es/public_html/app/cache/prod/classes.php(5089): Monolog\Handler\StreamHandler->write(Array)
#1 /home/intelmarketing.es/public_html/app/cache/prod/classes.php(5018): Monolog\Handler\AbstractProcessingHandler->handle(Array)
#2 /home/intelmarketing.es/public_html/app/cache/prod/classes.php(5204): Monolog\Handler\AbstractHandler->handleBatch(Array)
#3 /home/intelmarketing.es/public_html/app/cache/prod/classes.php(5419): Monolog\Handler\FingersCrossedHandler->handle(Array)
#4 /home/intelmarketing.es/public_html/app/cache/prod/classes.php(5519): Monolog\Logger->addRecord(500, 'Uncaught PHP Ex...', Array)
#5 /home/intelmarketing.es/public_html/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/EventListener/ExceptionL in /home/intelmarketing.es/public_html/app/cache/prod/classes.php on line 5141" while reading response header from upstream, client: 180.211.176.176, server: intelmarketing.es, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9007", host: "www.intelmarketing.es"

what might be the problem?
Thank you
/Aleksandar!

A: Clear your app/logs and app/cache directories and give your web server permissions to write to them (read the installation chapter). You left there some files from your development machine.

redpajama_set_name: RedPajamaStackExchange


text:
Q: error (string literal contains an unescaped line break app.js:5:33) products are not showing
function renderProducts() {
    products.forEach( (product) => {
        productSec.innerHTML += '

${product.name}

$${product.price}

${product.description}

        '
    });
}

renderProducts();

i am trying to display in html but products are not showing.
error (string literal contains an unescaped line break app.js:5:33)


text:
Q: prove the limit of sequence $\frac{2n}{n+1} = 2$ Please check the proof and point the mistake:
$$\frac{2n}{n+1}-2< \epsilon $$
$$\frac{2n-2n+2}{n+1}< \epsilon $$
$$\frac{2}{n+1}< \epsilon$$
Note: If we end the proof at this point I think the proof might fail if $n=1$.
I'm not sure about it.
$$2\left | \frac{1}{n+1} \right |< \epsilon $$
$$\left | \frac{1}{n+1} \right |< \frac{\epsilon }{2}$$
Then
$$\frac{2}{n+1}=2\left | \frac{1}{n+1} \right |$$
$$2\left | \frac{\epsilon }{2} \right |=\epsilon $$

A: In the second step, I think it's possible you didn't distribute the minus sign. Shouldn't it be $2n-2n-2$, not $2n-2n+2$, in the numerator? I'm not sure that this is considered rigorous, but you could simply factor out $n$ from both the numerator and denominator of the original expression. Those $n$s would then cancel and you'd be left with $\frac{2}{1 + \frac{1}{n}}$, which is a much easier limit to evaluate.

A: Just as an example this is what I would do: if our assumption is true (i.e., if $2$ is the limit of the sequence) then following the definition of limit we know that for any $\epsilon>0$ exists some $N\in\Bbb N$ such that
$$\left|\frac{2n}{n+1}-2\right|<\epsilon\implies\left|\frac{2n-2n-2}{n+1}\right|<\epsilon\implies \frac2{n+1}<\epsilon,\quad\forall n\ge N$$
Then it is enough to observe that the RHS is arbitrarily small, by example choose $N\ge\frac2{\epsilon}$ (by the archimedean property of the reals this is possible), then we will had
$$1<\frac{\epsilon}2\left(\frac2{\epsilon}+1\right)=1+\frac{\epsilon}2\le N\frac{\epsilon}2+\frac{\epsilon}2$$
what is true, because $\epsilon>0$ and for the chosen $N$ we have that $N\frac{\epsilon}2\ge 1$.

A different approach, maybe more easy, just observe that $\frac1n>\frac1{n+1}$ ( let $n\ge 1$). Then because you know that the sequence $(1/n)$ converges to zero then it is true that it does for $(1/(n+1))$, because the first is bigger than the second.
And observe that $\epsilon/2<\epsilon$, so it doenst change the truth of the inequality. If you have that
$$\left(\frac1n<\epsilon\right)\land\left(\frac1{n+1}<\frac{\epsilon}2<\epsilon\right)\land\left(\frac1{n+1}<\frac1n\right)\implies \frac1{n+1}<\frac1n<\epsilon,\quad\forall n\ge N>\frac1\epsilon$$
and then $(1/(n+1))$ converges to zero.

A: Consider the corresponding real function over the positive reals. The derivative is positive by the quotient rule and the closure of the positive reals. The function never assumes 2. It remains only to show it assumes all values slightly less than 2: Solve (2x)/(x+1)=2-2e . That is x/(x+1)=1-e, or x=x-xe+(1-e). This is a linear equation and thus has a solution as desired.


text:
Q: Angularjs display data from array in a table I want to display data from array in a table.
This is what I have:
controllers.js:
app.controller('DriverController', ['$scope', '$http',
    function ($scope, $http) {

        //Defining the $http service for getting the sources
        $http({
            method: 'GET',
            url: '/Driver/GetDrivers'
        }).
        success(function (data) {
            $scope.drivers = data;
        });
    }]);

Data I'm getting:

HTML Markup:

                        Name

                                {{driver.FirstName}}

End result:

Update
I tried this as well, just to see if angular is hooked up correctly:
app.controller('DriverController', ['$scope', '$http',
    function ($scope, $http) {

        //Defining the $http service for getting the sources
        $http({
            method: 'GET',
            url: '/Driver/GetDrivers'
        }).
        success(function (data) {
            $scope.Drivers = data;
            $scope.Test = "testt";
            console.log('data retrieved');
            console.log($scope.Drivers);
        });

    }]);

And I updated the view:
@using ui.ViewModels
@model DriversViewModel

@{
    ViewBag.Title = "Drivers List";
}

@using (Html.BeginForm())
{

Drivers List

{{Test}}

                            Id
                            First Name
                            Middle Name
                            Last Name
                            Party

                        @foreach (var p in Model.Drivers)
                        {

                                @p.Id
                                @p.FirstName
                                @p.MiddleName
                                @p.LastName
                                @p.Party.Name

                        }

                        Name

                            {{driver.firstName}}
                            {{driver.lastName}}

}

I tried a simple thing too, such as
{{driver.Test}}
 but as you can see no value is shown.
So I think there is some disconnection between angular and the mvc app, what do you think I'm doing wrong?

A: You could try adding ng-repeat on tr tags not on tbody tag.
Edit:
maybe you forgot to place ng-app outside of your table, this fiddle works
https://jsfiddle.net/xy2y1b9y/

            Name

                {{driver.FirstName}}

(although placement of ng-repeat should be on tr tags)

A: Put the ng-repeat inside the tables tr:

            First Name
            Last Name

            {{driver.firstName}}
            {{driver.lastName}}


text:
Q: Transparent Text on Bitmap I am using the following code to draw a text from the textinput on a Bitmap. It works fine except the problem that instead of drawing just the text, it draws the text inside a box with white background. How can I draw just the text without the box? I guessed its related to transparency so I set the Bitmapdata to be transparent, it still doesn't work.
                        var m:Matrix = new Matrix();
            m.tx=100;
            m.ty=100;

            var txtMatrix:Matrix= new Matrix();
            txtMatrix.tx=bmd.width;
            txtMatrix.ty=bmd.height+50;

            original= new BitmapData(bmd.width+200,bmd.height+400,true,0x00000000);
            original.draw(bmpMy,m);

            var txtMatrix:Matrix= new Matrix();
            txtMatrix.tx=100;
            txtMatrix.ty=bmd.height+105;
            original.draw(txtTitle1,txtMatrix);

Note: The BitmapData bmd that is passed to 'original' is also transparent.
bmpMy is the bitmap from the bmd BitmapData

A: You're drawing your entire TextInput component with the default TextInputSkin. Since this skin has a border and a white background, they will also be drawn.
I see 2 possible solutions:

*

*either create a plain ActionScript TextField, copy the text from the TextInput to the TextField and draw that TextField. After drawing you can dispose of the TextField.

or

*

*Create a custom skin class for TextInput without a border and with a transparent background. You may have to change the skin at runtime. You can do that like this:

.
txtTitle.setStyle("skinClass", MyCustomTextInputSkin);

When you're done drwing, restore the default skin:
txtTitle.setStyle("skinClass", TextInputSkin);


text:
Q: Merging the dictionaries d1 = {'Adam Smith':'A', 'Judy Paxton':'B+'}
d2 = {'Mary Louis':'A', 'Patrick White':'C'}
d3 = {}

for item in (d1, d2):
    d3.update(item)

print(d3)

In this Python Code, the task is to merge the dictionaries and assign the merged dictionaries to the third dictionary. They used the for loop aproach which is a bit confusing for me as I'm not able to understand the loop part.
Could you help me determine that loop-debugging part?

A: No loops needed. Just copy one of the dicts and update it with the second one:
d1 = {'Adam Smith':'A', 'Judy Paxton':'B+'}
d2 = {'Mary Louis':'A', 'Patrick White':'C'}
d3 = d1.copy()
d3.update(d2)
print(d3)


text:
Q: Button in Javascript code not computing equation I have my code all written but when I run the webpage the button simply does not compute the answer and send the string to the Monthly Payment text box.  This is a monthly payment calculator using HTML and Javascript.  I have no idea what I am doing wrong, any help is appreciated.
I am using netbeans 8 and I get an error code everytime Chrome opens it about debugging.  I'm unsure if my code is correct and the browser just isnt running the function or if my code is incorrect.  I feel like my error is something very small.
<!DOCTYPE html>

        <title>Monthly Payment Calculator</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">

        <form name="mpForm" action="">

                            Enter Loan:
                            <input id='loanAmt' type="text"  name="loanAmt" value="" />

                        Select Rate
                        <select name="Rate">
                            <option value=.04>3%</option>
                            <option value=045>3.5%</option>
                            <option value=.05 >4%</option>
                            <option value=.055>4.5%</option>
                            <option value=.06>5%</option>
                            <option value=.055>5.5%</option>
                            <option value=.06>6%</option>
                            </select>

                            Select Year
                            <input type="radio" name="Year" value=10 />10 year

                            <input type="radio" name="Year" value=15 />15 year

                            <input type="radio" name="Year" value=30 />30 year

                            Monthly Payment:
                            <input type="text" name="MP"  />

                            <input type="button" value="computeMP" name="btnCompute" onClick="computeMP()" />

        </form>

I expect the output to solve the equation as outlined in the MP variable

A: There is some error in your source code:

*

*Have strange character in button "computeMP"

*Name is MP but use as mp

*Variable is myLoan but use with Loan

Here is source code worked

  function computeMP() {
            myLoan = parseFloat(document.mpForm.loanAmt.value);
            myRate = parseFloat(document.mpForm.Rate.options[document.mpForm.Rate.selectedIndex].value);
            if (document.mpForm.Year[0].checked) { myYear = 10; }
            else if (document.mpForm.Year[1].checked) { myYear = 15; }
            else { myYear = 30; }
            MP = (myLoan * (myRate / 12)) / 1 - Math.pow(1 + (myRate / 12), -12 * myYear);
            document.mpForm.MP.value = MP.toString();
        }
<!DOCTYPE html>

    <title>Monthly Payment Calculator</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <form name="mpForm" action="">

                    Enter Loan:
                    <input id='loanAmt' type="text" name="loanAmt" value="" />

                    Select Rate
                    <select name="Rate">
                            <option value=.04>3%</option>
                            <option value=045>3.5%</option>
                            <option value=.05>4%</option>
                            <option value=.055>4.5%</option>
                            <option value=.06>5%</option>
                            <option value=.055>5.5%</option>
                            <option value=.06>6%</option>
                        </select>

                    Select Year
                    <input type="radio" name="Year" value=10 />10 year

                        <input type="radio" name="Year" value=15 />15 year

                        <input type="radio" name="Year" value=30 />30 year

                    Monthly Payment:
                    <input type="text" name="MP" />

                    <input type="button" value="computeMP" name="btnCompute" onClick="computeMP()" />

    </form>

A: You just had a few syntax errors, this should work :)
<!DOCTYPE html>

        <title>Monthly Payment Calculator</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">

        <form name="mpForm" action="">

                            Enter Loan:
                            <input id='loanAmt' type="text"  name="loanAmt" value="" />

                        Select Rate
                        <select name="Rate">
                            <option value=.04>3%</option>
                            <option value=045>3.5%</option>
                            <option value=.05 >4%</option>
                            <option value=.055>4.5%</option>
                            <option value=.06>5%</option>
                            <option value=.055>5.5%</option>
                            <option value=.06>6%</option>
                            </select>

                            Select Year
                            <input type="radio" name="Year" value=10 />10 year

                            <input type="radio" name="Year" value=15 />15 year

                            <input type="radio" name="Year" value=30 />30 year

                            Monthly Payment:
                            <input type="text" name="mp"  />

                            <input type="button" value="computeMP" name="btnCompute" onClick="computeMP()" />

        </form>


text:
Q: Como fazer com que o meu programa leia somente as linhas novas de um arquivo que atualiza a cada momento em Python Tenho um arquivo que atualiza a cada momento(um log de erros) e cada log dele é uma linha que vai aumentando o arquivo, mas não sei como fazer pro meu programa ler somente as linhas novas. (meu código lê o arquivo a cada 1min)
Precisaria armazenar a quantidade de linhas do arquivo que foi lido, e quando ler o arquivo novo atualizado, ler a quantidade de linhas e diminuir a quantidade de linhas do arquivo lido anteriormente e colocar o código pra ler somente as linhas dessa diferença.
Sei que ficou um pouco difícil de explicar mas quem puder, me da ajuda pq eu não consegui pensar uma forma de fazer isso.


text:
Q: In which time zone does the openshift server operates by default? I am scheduling my cron job for 0 0 22 * * ?. Is it going to get executed at 10 pm CST?

A: In general, this will depend on your Master Nodes:

All CronJob schedule: times are based on the timezone of the kube-controller-manager .

Source: https://v1-17.docs.kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/
So it will depend on your specific configuration of your cluster, often Master nodes are running with the UTC timezone, but they may also be configured to use your local timezone.


text:
Q: How can I download data from NYC open data into GIS? I have a data from NYC open data website and I need to download them to GIS so it will be easier to analyze
https://data.cityofnewyork.us/Public-Safety/NYPD-Motor-Vehicle-Collisions/h9gi-nx95
How can I open and explore data from NYC open data into GIS when I only have longitude and latitude figures, and there is no coordination system given?

A: There is an option on the website available to download the data into csv file. You can download the data into csv file and then add that csv file into GIS Sotware ( ESRI ArcGIS, QGIS) . There are set of tools available that can be used to display that data as points on map. e.g in ArcGIS there is tool Display XY data available that can be used to display them on map.

A: If you use the SODA 2.1 API for that dataset, you can also export it as GeoJSON:  https://data.cityofnewyork.us/api/views/qiz3-axqb/rows.geojson
I'd try that. It'll be in the WGS84 projection.


text:
Q: Set up web worker on shopify store I have created a shopify app that uses the graphql api and gets data.
I want to set up the fetch on another thread and want to use a web worker I have created the worker.js in the assets folder but the domain of this file is on the https://cdn.shopify.com and not https://mystore.myshopify.com/ domain and the worker wont work as I get the error "cannot be accessed from origin"
Here is the worker I am using to test getting data
var worker;
testWorker();
function testWorker()
{
    if (typeof(Worker) !== "undefined")
    {
        if (typeof(worker) == "undefined")
        {
            worker = new Worker("{{ 'webworkertest.js'| asset_url }}");
        }
        worker.onmessage = function(event)
        {
            document.getElementById("loopcount").innerHTML = event.data;
        }
    }
    else
    {
        document.getElementById("loopcount").innerHTML = "Web Worker not supported";
    }
}

function terminateWorker()
{
    worker.terminate();
    worker = undefined;
}

testMainThread();
function testMainThread()
{
    for (var i = 0; i < 200000; i++)
    {
        document.getElementById("loopcount").innerHTML = "Main Thread Counter: " + i;
    }
}

And here is the worker.js file
i = 0;
while (i < 200000) {
    postMessage("Web Worker Counter: " + i);
    i++;
}


text:
Q: Dynamic Binding and Overriding/Overloading in java public abstract class Vector{
    public abstract double norm();
}
public class PlanarVector extends Vector {
    protected final double x;
    protected final double y;
    public PlanarVector(double x, double y){
        this.x=x;
        this.y=y;
    }
    public double norm(){
        return Math.sqrt(x*x+y*y);
    }
    public PlanarVector sum(PlanarVector v){
        return new PlanarVector(x+v.x, y+v.y);
    }
    public String toString(){
        return "x=" + x + " y=" + y;
    }
}
public class SpaceVector extends PlanarVector {
    protected final double z;
    public SpaceVector(double x, double y,double z){
        super(x,y);
        this.z=z;
    }
    public double norm(){
        return Math.sqrt(x*x + y*y + z*z);
    }
    public SpaceVector sum(SpaceVector v){
        return new SpaceVector(x+v.x, y+v.y, z+v.z);
    }
    public String toString(){
        return super.toString() + " z=" + z;
    }
}

public class TestVector {
    public static void main ( String[] args ) {
        Vector v0 ;
        PlanarVector v1 , v2 ;
        SpaceVector v3 , v4 ;
        v1 = new PlanarVector ( 3 , 4 ) ;
        v0 = v1 ;
        v2 = new SpaceVector ( 2 , 3 , 6 ) ;
        v3 = new SpaceVector ( 2 , 1 , 0 ) ;
        v4 = v3 ;
        System.out.println(v1.sum(v2)) ; //expected output: x=5 y=7 realoutput: x=5 y=7 (v1 can only use PlanarVectorMethods because its dynamic and static type is PlanarVector)

        System.out.println(v2.sum(v1)) ; //expected output: x=5 y=7 realoutput: x=5 y=7
        System.out.println(v2.sum(v3)) ; //expected output: 'x=4 y=4 z=6'  realoutput: 'x=4 y=4'
        System.out.println(v3.sum(v2)) ; //expected output: 'x=4 y=4 z=6'  realoutput: 'x=4 y=4'
        System.out.println(v3.sum(v4)) ;
        System.out.println(v1.norm()) ;
        System.out.println(v2.norm()) ; //expected output: sqrt(13) realoutput: 7

    }
}

Can someone explain me why v2.sum(v3) in "System.out.println(v2.sum(v3))" doesn't use the subclass method ?
I know the static type of v2 is PlanarVector but its dynamic type is SpaceVector
same goes for  System.out.println(v3.sum(v2)),  static and dynamic type of v3 is SpaceVector and v2 is considered planarVector here ? Why?!
and the last System.out.println(v2.norm()) considers v2 as SpaceVector this time ... what is happening ?!
I have a last question too, Superclasses cannot use subclasses methods even tho it is an instance of the subclass right ? what happens if the method is an overrided method in the subclass, why the superclass can now use it (and uses the subclass implementation)?
I'm asking a question about java fundamentals, expecting simple and clear answers with examples.

A: The method
SpaceVector sum (SpaceVector)
in SpaceVector isn't an override of
PlanarVector sum (PlanarVector)
in PlanarVector, but just an overload.
Both methods exists in SpaceVector.
It isn't an override because the signature are different (the argument passed isn't of the same type).
Secondly, Java doesn't implement multiple argument dispatch but only single argument dispatch, by using simple virtual tables. In clear, it means that it look only at the first argument to decide dynamically which method to call, and
in Java, the first argument of a (non-static) method is always the implicit this reference. The this reference basically determines in which method virtual table to look at.
Other arguments are always resolved at compile time and never dynamically.
Some languages implement multiple argument dispatch, but not Java.
If you put both information together, you can understand why the actual method called isn't the one you expected:
you pass an object of declared type PlanarVector, so the method called is PlanarVector sum(PlanarVector). The compiler don't know, and in fact can't know if you have a reference to a PlanarVector or a subclass.
Try to change the declarations of v2 and v3 and you will see the difference. Also try with the var keyword and observe what happens. It's interesting to experiment by yourself to understand.
If you want your code to work like multiple argument dispatch, you will need to implement the well known visitor pattern.


text:
Q: jquery - change image according to text input I have a mysql table with the name of a team in one column (club_name) and an id on another (club_id).
Every team has a logo named with their respective id .png.
Then I have a text input where the user can write the name of a team. There is a jQuery function that shows the possible team names found in the database according to what the user is typing so that it can autocomplete. Once the user selects one of the options the focus moves out of the text input. At this point, I would like the image to change to the logo corresponding to the team. When the text input is empty or the name does not match any team in the database the image should be 0.png
How can I achieve this? My code so far is below:
EDIT:
I have three problems right now:

*

*The method suggested to store the club id in the json object is only
returning the first row of the table.

The method is below (although it only returns one row of the table it does work, the image changes to the appropriate one - I ran a little test by replacing 'thisclub' with the name of the club):

Using another method I was able to have all the rows in the json object but this one did not work when I ran the same test by replacing 'thisclub' with the name of one club):

*The second problem is I don't know what to replace 'thisclub' with.
In other words, how to get the value returned by the function.

*I am now using two vars - one to store the name of the clubs only, for the original function, the other one for the name of the clubs and respective id, for the function that makes the image change. This is because I don't know what changes to make in the original function so that it searches for the names in the new var (which contains club_id too)

The full code is below.

<input type="text" class="club-name" name="home" autocomplete="off"/>

A: I would get the club_id from the original SELECT that you do.
Then on the focus out you can do something along the lines of:
$("#team-logo").attr("src", club_id+".png");

And that will set the image src to the new image.
Edit:
To expand a bit, storing the results of the sql query in a json object using json_encode() would allow you to use something like:

// Run the following code inside the focus.out section and set thisclub to the returned clubname

clubid = "";
$.each(clublist, function (i, elem) {
    if (elem.club_name === thisclub) {
        clubid = elem.club_id;
        $("#team-logo").attr("src", clubid+".png");
    }
});
if(clubid == "") {
    // show default image
    $("#team-logo").attr("src", "0.png");
}

Second Edit (Complete working example):
I've tested the following and I believe it includes everything you're looking for. The problem seemed to be in the formatting of the php array when passed to json encode. Pay close attention to the HTML changes.
$sql = " SELECT club_id, club_name FROM clubs ORDER BY club_id DESC";

$result_clubs = mysql_query($sql);
if (!$result_clubs) {
    echo "Could not successfully run query ($sql) from DB: " . mysql_error();
    exit;
}
$clubs = array();
while($row = mysql_fetch_assoc($result_clubs)){
    $clubs[] = array('club_id' => $row['club_id'], 'club_name' => $row['club_name']);
}
?>

<input id="clubname" type="text" class="club-name" name="home" autocomplete="off"/>


text:
Q: Change contents of submitted form on submit I have a form, and I'd like to do special processing on it before it is submitted.
I know I can catch the "submit" event using JQuery, but how do I change the values that are actually submitted from within the callback?

A: A couple of options: you could replace the form fields prior to the actual submit taking place. You could use added hidden fields for this. I don't like this option particularly since you might have validation issues where you'd have to undo your changes.
You could do the post via AJAX, posting only your values, then take some appropriate action based on the result.  In this case, the original post never happens.  That's what I would probably do.  In this way your original form stays the same and you can handle server-side validation without having to undo anything on the form.
$(function() {
     $('form').submit( function() {
         var $form = $(this);
         var data = // ... generate your custom data ...;
         $.post( $form.attr('action'), data, function(result) {
              // ... do something based on result
         });
         return false; //cancel original submit
     });
});


text:
Q: Free web service to determine IP address zip code Does anyone know of a free web service to determine the zip code of an IP address?

A: MaxMind GeoLite City
http://www.maxmind.com/app/geolitecity

A: I realize this question is old, but this may still help other people.  I found a free / open source (so you can even run your own instance and not be subject to their hourly limit of 10,000 requests) IP geolocation database:
http://freegeoip.net/

A: I don't know of any that will return a zipcode, but this one is free and returns city/state
http://www.hostip.info/

A: http://tuq.in/tools/geo
is a free geolocation service also it is way awsome in quality


text:
Q: Task.Factory.StartNew - ContinueWith using .Wait() I am declaring a task using TaskFactory, and I have a serious doubt.
I am creating the task declaring the continueWith on creation, I am not assigning
it too a second task who will be started later.
The declaration is like this:
Dim taskConta = Tasks.Task(Of DataSet).Factory.StartNew(
                Function() FunctionToLaunch(parameter), TokenCancel.Token,  Tasks.TaskCreationOptions.LongRunning)

taskConta.ContinueWith(New Action(Sub() Throw New TimeoutException("Exception Error"), System.Threading.Tasks.TaskContinuationOptions.OnlyOnFaulted)

As you can see. This task is declared with :

TaskContinuationOptions.OnlyOnFaulted

The task is executed and then my next line of code is:
 taskConta.Wait()

The question is:
If my task exits faulted and I have used .Wait().
 Will the ContinueWith Action be started before the code continues execution?
 Or would it be queued and started later?
If it is started later, How long would it take more or less?
 That could do that my Throw Exception could be launched out of the scope.
I know I could do something like:
  taskConta.Wait()

  If taskConta.Status <> Tasks.TaskStatus.RanToCompletion Then
         Throw New TimeoutException("Message")
  End If

Would I would like to know how the TaskFactory continueWith queue works.

A:
If my task exits faulted and I have used .Wait(). Will the ContinueWith Action be started before the code continues execution? Or would it be queued and started later?

The two actions (the ContinueWith() method starting and the Wait()ing thread resuming) can happen in any order. All you can be sure about is that they both happen only after the taskConta Task completes.
If you want to wait until the continuation completes, you can do that by waiting on the Task returned from ContinueWith().

But you also seem to be confused about how Task behave with regards to exceptions. What you're doing in your continuation is a bad idea. In .Net 4.5, it won't do anything, because exceptions from unobserved Tasks are ignored there. In .Net 4.0, the exception is going to be thrown when the continuation Task is finalized, which means it will happen at some unspecified point in the future and you can't use a normal Catch to deal with the exception.
Also, if you Wait() on a faulted exception, Wait() throws the exception enclosed in AggregateException. This means if you want to handle a specific exception from the Task, you can use Catch. For example:
Try
    taskConta.Wait()
Catch e as AggregateException
    If TypeOf e.InnerException Is SomeSpecificException
        Throw New TimeoutException("message", e.InnerException)
    Else
        Throw
    End If
End Try


text:
Q: How to output values in array? Hello I have the following variable in my PHP:
$art= [
        'places' => ['America','Paris','Italy','Japan'],
        'photographer' => ['Samantha','Hannah','David','Albert'],
    ];

I am just trying to output 'places' only into my HTML code. Keep getting "Illegal String Offset" warning.
Why is my following code not working?
<?php foreach($art as $value): ?>
      <?= $value['places'] ?>
    <?php endforeach ?>

A: <?php foreach ($art["places"] as $value): ?>
<?= $value ?>
<?php endforeach; ?>

you should loop the $art["places"];


text:
Q: ANDROID: Not able to add the android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" to manifest file I want to get rid of the Activity Title Bar and have tried just adding
@android:style/Theme.NoTitleBar to activity and
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" to the manifest file.
But I keep getting the error:
java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
Nothing seems to help.
Any help would be wonderful :)
Thanks.

A: https://developer.android.com/training/basics/actionbar/styling.html

Note: If you are using the Support Library APIs for the action bar,
  then you must use (or override) the Theme.AppCompat family of styles
  (rather than the Theme.Holo family, available in API level 11 and
  higher). In doing so, each style property that you declare must be
  declared twice: once using the platform's style properties (the
  android: properties) and once using the style properties included in
  the Support Library (the appcompat.R.attr properties—the context for
  these properties is actually your app). See the examples below for
  details.


text:
Q: Unable to read intents using Actions SDK I've got the following action in my action.json file,
{
    "description": "Recommend movies",
    "initialTrigger": {
        "intent": "GIVE_RECOMMENDATION",
        "queryPatterns": [
            {"queryPattern": "What should I watch?"},
            {"queryPattern": "Give me a recommendation"},
            {"queryPattern": "Tell me a good ($String:genre)? movie"}
        ]
    },
    "httpExecution": {
        "url":"my webhook URL here"
    }
}

On my API, I've got:
app.post('/', function(req, res){
    let assistant = new ActionsSdkAssistant({request: req, response: res});
    console.log('Current intent: ' + assistant.getIntent());
}

When I simulate my action, and say "What should I watch?", the current intent is ALWAYS 'assistant.intent.action.TEXT'. Why is it never 'GIVE_RECOMMENDATION', like its supposed to be?

A: I'm assuming you're testing your skill as such:

open ACTION NAME
What should I watch?

Chances are you're having the same issue I had, see the accepted answer and comments to
ExpectedInputs / possible_intents only works with "assistant.intent.action.TEXT"?
In short: After the initial intent was triggered (i.e. after you opened your skill) the Actions SDK only supports the assistant.intent.action.TEXT intent and no longer does any intent matching.
Intent matching only works for the very first invocation of the action:

ask ACTION_NAME What should I watch?

The above should give you the correct intent name.
Google recommends using http://api.ai if you do not have your own system in place for natural language processing and need to have intent-based dialog with your user


text:
Q: dojo stop dropdown button from closing on checkbox select here is the html:
<button data-dojo-attach-point="pinFilterButton" data-dojo-type="dijit/form/DropDownButton">
    Proj. PIN
    <select multiple="true" name="multiselect" data-dojo-attach-point="pinFilter" data-dojo-type="dojox.form.CheckedMultiSelect"></select>
</button>

I just want to stop the dropdown from closing when a checkbox is selected.
Here is what I tried:
on(t.pinFilterButton.dropDownContainer, 'close', function (e) {
    e.stopPropogation();
})

among other variations.


text:
Q: Cant get the private ip from an EC2 result Trying to create a playbook that will let me choose if i want spot or On-demand EC2 with passing external var, all going fine except the part of getting the private ip from the result and settings it as fact for further usage.
i've tried different paths like item.instances[0].private_ip
and just cant seems to get the right one.
---

- hosts: localhost
  tasks:
  - name: when true
    ec2:
      region: us-east-1
      instance_type: t2.nano
      key_name: test_key
      instance_type: t2.micro
      image: ami-0aec0138b2*****
      wait: yes
      count: 1
      vpc_subnet_id: subnet-00fdda1452d****
      assign_public_ip: no
      spot_price: 1
    register: ci_ec2_true
    when: var == "true"

  - name: when false
    ec2:
      region: us-east-1
      instance_type: t2.nano
      key_name: test_key
      instance_type: t2.micro
      image: ami-0aec0138b2****
      wait: yes
      count: 1
      vpc_subnet_id: subnet-00fdda1452d0****
      assign_public_ip: no
    register: ci_ec2_false
    when: var == "false"

  - name: ci_ec2_true
    debug:
      msg: "{{ ci_ec2_true }}"

  - name: Spot / On-demand var router
    set_fact:
      ci_ec2: "{{ ci_ec2_true if ci_ec2_false is skipped else ci_ec2_false }}"

  - name: debug ci_ec2
    debug:
      msg: "{{ ci_ec2 }}"

  - name: ec2_prov - set fact for all ci_machine_ips
    set_fact: private_ips="{{ item.instances[0].private_ip }}"
    with_items: "{{ ci_ec2 }}"
    register: ci_ec2_ip_results

  - debug:
      msg: "{{ ci_ec2_ip_results }}"

The expected result should be the private ip value, instead im getting this error:
TASK [ec2_prov - set fact for all ci_machine_ips] ******************************
**********
fatal: [localhost]: FAILED! => {"failed": true, "msg": "the field 'args' has an invalid value, which appears to include a variable that is undefined. The error was: 'ansible.vars.unsafe_proxy.AnsibleUnsafeText object' has no attribute 'instances'\n\nThe error appears to have been in '/root/test/when-create.yml': line 50, column 5, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n  - name: ec2_prov - set fact for all ci_machine_ips\n    ^ here\n"}

the command used to run the playbook is:
ansible-playbook when-create.yml -e var=true

TASK [debug ci_ec2] ************************************************************

ok: [localhost] => {
    "msg": {
        "changed": true,
        "instance_ids": [
            "i-0485794cd8a299b27"
        ],
        "instances": [
            {
                "ami_launch_index": "0",
                "architecture": "x86_64",
                "block_device_mapping": {
                    "/dev/xvda": {
                        "delete_on_termination": true,
                        "status": "attached",
                        "volume_id": "vol-0cd42f8696aef9bbd"
                    }
                },
                "dns_name": "",
                "ebs_optimized": false,
                "groups": {
                    "sg-07c7177c": "default"
                },
                "hypervisor": "xen",
                "id": "i-0485794cd8a299b27",
                "image_id": "ami-0aec0138b2a5****",
                "instance_type": "t2.micro",
                "kernel": null,
                "key_name": "test_Key",
                "launch_time": "2019-05-11T16:41:10.000Z",
                "placement": "us-east-1a",
                "private_dns_name": "ip-10-220-129-224.ec2.internal",
                "private_ip": "10.220.129.224",
                "public_dns_name": "",
                "public_ip": null,
                "ramdisk": null,
                "region": "us-east-1",
                "root_device_name": "/dev/xvda",
                "root_device_type": "ebs",
                "state": "running",
                "state_code": 16,
                "tags": {
                    "Created_By": "InstanceLaunch"
                },
                "tenancy": "default",
                "virtualization_type": "hvm"
            }
        ],
        "tagged_instances": []
    }
}

A: so eventually i found the way...
- name: ec2_prov - set fact for all ci_machine_ips
  set_fact: private_ips="{{ item.private_ip }}"
  with_items: "{{ ci_ec2.instances }}"
  register: ci_ec2_ip_results


text:
Q: How can I do something on display or visibility change with jquery I want to excecute an action on display or visibility change (really in display:block or visibility:visible) with jquery if posible or javascript, but I've researched a lot in this forum and I couldn't acomodate any of the suggested solutions for similar problems.
The more near that I've been was:
if($('.class').css('display') == 'none'){ // do something }

But obviously this is only an if, and doesn't catch the event and nothing...
Someone could please help me?
Thanks

A: give your div element a unique class and check the length of that div, if the length of that div is greater than 0, it means that div exists or vice versa.

if($(".HideDiv").length <1){
<--HideDiv doesnot exist-->

do your code here
}else{
<--HideDiv exists-->

}
<--suppose-->

A: You can use MutationObserver
It would look like this:
var observer = new MutationObserver(function(mutations) {
   if (mutations[0].oldValue.contains('display: none')) {
      alert('The element got visible')
   }
   else if (mutations[0].oldValue.contains('visibility: hidden')) {
      alert('The element got visible')
   }
   else if (mutations[0].oldValue.contains('visibility: visible')) {
      alert('The element got hidden')
   }
   else if (mutations[0].oldValue.contains('display: ')) {
      alert('The element got hidden')
   }
})

observer.observe(document.querySelector('#someselector'), {attributes: true, attributeOldValue: true})

If you need help for your specific case check the docu:
Mozilla MutationObserver Documentation

A:

<button id="btn" style="display: block;">btn</button>

Or

<button id="btn">btn</button>

*

*if display not set than js return "" empty string


text:
Q: Quasi-isometry of Schreier coset graphs Let $G$ be a finitely generated group and $H$ a subgroup. For any choice of a generating set $X$ we can form the Schreier coset graph. Is this graph independent of the generating set up to quasi-isometry?
I know the corresponding question for the Cayley graph has positive answer, but the proof I know relies on the Svarc-Milnor Lemma; this lemma requires in particular a proper action of $G$ on the spaces involved, but here the stabilizer of a vertex $Hg$ is the whole $H$, so the action is not proper when $H$ is infinite. Anyway the lemma implies that $G$ is quasi-isometric to any of its Cayley graphs, but surely $G$ is not quasi-isometric to any of its Schreier graphs (for $H\neq 1$). So this is really not the way to try to prove this thing (assuming it's true).

A: Yes.  This is essentially the proof that studiosus suggests:
Let $X_1$ and $X_2$ be two finite generating sets of $G$, and $S_1$ and $S_2$ the associated Schrier graphs.  Map the vertices of $S_1$ to the vertices of $S_2$ via the identity map (the vertices in both cases are just cosets of $H$).  Note that any graph is quasi-isometric to its set of vertices (leaving the same metric on the vertices), so it suffices to show this vertex mapping is a quasi-isometry.
Express each $x_i \in X_1$ as a word $w_i$ in elements of $X_2$.  Let $K_1$ be the maximum length among the $w_i$.  Similarly, let $K_2$ be the maximum length needed to express an element of $X_2$ as a word in elements of $X_1$.
Then for any two adjacent vertices $Hg$ and $Hg'$ in $S_1$, we have $Hg = Hg'x$ for some $x \in X_1$.  But we can express $x$ as a product $y_1...y_n$, where each $y_i \in X_2$ and $n \leq K_1$.  Thus $Hg = Hg'x_1...x_n$, which means the distance between $Hg$ and $Hg'$ in $S_2$ is no more than $K_1$, since in $S_2$ the cosets $Hg'$, $Hg'x_1$, $Hg'x_1x_2$, etc. are a sequence of adjacent vertices.
A similar argument shows that vertices which are adjacent in $S_2$ are of distance no more than $K_2$ in $S_1$.
Thus, for any two cosets $Hg, Hg'$, we have
$$
\frac{1}{K_2}d_{S_1}(Hg, Hg') \leq d_{S_2}(Hg, Hg') \leq K_1d_{S_1}(Hg, Hg')
$$
Which shows that mapping cosets under the $S_1$ metric to the same cosets under the $S_2$ metric is a quasi-isometry, thus $S_1$ and $S_2$ are isometric.


text:
Q: R count consecutive days with condition = 0 I have this question:
If I have the next dataframe
                      time      y     x PREC Month
   1: 2015-01-01 01:00:00 4905.5 660.5    0     1
   2: 2015-01-01 01:00:00 4905.5 661.5    0     1
   3: 2015-01-01 01:00:00 4905.5 662.5    0     1
   4: 2015-01-01 01:00:00 4905.5 663.5    0     1
   5: 2015-01-01 01:00:00 4905.5 664.5    0     1

   ---

   21894996: 2015-12-31 22:00:00 4954.5 705.5    0    12
   21894997: 2015-12-31 22:00:00 4954.5 706.5    0    12
   21894998: 2015-12-31 22:00:00 4954.5 707.5    0    12
   21894999: 2015-12-31 22:00:00 4954.5 708.5    0    12
   21895000: 2015-12-31 22:00:00 4954.5 709.5    0    12

and I want to add a new column in my dataframe that count the consecutive days with a condition: Count the consecutive days if the "PREC" is equal to 0.
I try with:
     setDT(data)
     data[, Consec_Days := ifelse(PREC = 0, 1:.N, 0L), by = rleid(PREC = 0)]

but dosn't work...
Any ideas?
Thank you very much in advance!

A: You can try -
library(data.table)

data <- data.frame(row = 1:10, PREC = c(0, 0, 0, 1, 1, 0, 0, 0, 0, 1))
setDT(data)
data[, Consec_Days := seq_len(.N),rleid(PREC == 0)]
data[PREC != 0, Consec_Days := NA]

data
#    row PREC Consec_Days
# 1:   1    0           1
# 2:   2    0           2
# 3:   3    0           3
# 4:   4    1          NA
# 5:   5    1          NA
# 6:   6    0           1
# 7:   7    0           2
# 8:   8    0           3
# 9:   9    0           4
#10:  10    1          NA


text:
Q: php: how to execute script from other script over and over everyone
Is there a way to make this piece of code work:
<?php
    while (1) {
        include('third_party_script.php');
    }
?>

I don't know what's in third_party_script.php.
It could look something like this:
<?php
    function some() { return 0;}
    some();
?>

If there is a function declaration in a third_party_script.php, I will get a "cannot redeclare" error. So I cannot use "include" o "require". Is there a solution?
Thanks in advance.

A: As others have said, you probably don't want to be doing this.
A possible solution, however is something like this:
<?php
    while (1) {
        passthru('php third_party_script.php');
    }
 ?>

but it depends on what the third party script is doing, something like this will work:
<?php

function print_something()
{
        print "hey";
}

print_something();

?>

(although it'll lock things up if you run something like inside while(1))
but, something which needs to get at _GET variables and such-like won't.
There are loads of concerns I'd have about doing the above but it is one possible solution to the specific question you had (rather than the more general problem you're trying to solve).
Another place to look to achieve esoteric things like this is runkit:
http://www.php.net/manual/en/intro.runkit.php
but I don't have enough experience with it to "recommend" it.

A: If there is a class or a function inside you should simply call the function or instantiate the class. I wonder however why you want to run something from a script which contents you are unfamiliar with.
If you would know however, it would work like below:
<?php
    while (1) {
        include('third_party_script.php');
        //call some_function which is defined in file above
        some_function();
        //instantiate object and call some_function
        $Object = new ThirdPartyClass();
        $Object->some_function();
    }
?>

Looping code over and over without an escape will kill you're processes eventually. Eventually might not be that long in 'time' too. All in all, this sounds like a direction you do not want to pursue...

A: I'm not sire what you would be trying to do, however I'm assuming that you are trying to write a script that can run a external code segment such as a plugin, for some kind of framework.
really what you should do in such a case is inforce some structure on the plugins i.e.
the plugin code will look like
<?php
   pluginname_exec($args) {
      ...
      Plugin Code gose here
      ...
   }
?>

your script should then import the script when loading
then when ever you want to run the plugin you would call
call_user_func("{$thisplugin}_exec",$args)

where $thisplugin is a variable containing you plugin name, most likely the file name, with out the .php
this way you only include the file once, but can call the code as many times as you need.
If your trying to execute some unknown code for reasons other the a plugin system, it's most likely a bad idea.


text:
Q: Stop Delivery Status Notification (Failure) messages with Windows 2003 Server SMTP Server How do I stop the SMTP Service on Windows 2003 (not exchange) from sending "Delivery Status Notification (Failure)" messages?
I'm trying to prevent a trick that spammers use of sending a message to a bogus user on my server's domain, with the sender's address as the Spam victim's address.
The result is that the SMTP Service will send back to the listed "sender" a "Delivery Status Notification (Failure)" message, which contains the spam message.

A: Configure your server to not accept mails for noon-existant recipient addresses. I don't have an Exchange right now to test that, but probably something like:
From Exchange System Manager, Global Settings, Internet Message Format, double click on your right. Advanced tab. Uncheck Allow non-delivery reports.
Also see here.

A: I found a discussion about this topic on Coding Horror. I went with the scripted solution by Alex Feinman. The things I ran into is that if you have more than one domain, you can only have one catch all for all domains. Also, this doesn't cleanup the catch all folder, so you need another script to do that, or do it manually.


text:
Q: How do I delete an Input from a Dictionary? My code:
print("Please enter your favourite foods")
a = input("Food 1: ")
b = input("Food 2: ")
c = input("Food 3: ")
d = input("Food 4: ")

food = {1:a, 2:b, 3:c, 4:d}
print(food)

Q = input("Which food would you like to remove?: ")

food.pop(Q)
sorted(food)

print(food)

I want the user to remove one item from the dictionary but every time they input what they want to remove I keep getting the error:
KeyError: 'whatever the user inputted'
(P.S I'm not allowed to make it into a list)

A: You should convert the user input into an int, because the dictionary keys are ints. Here's an example implementation:
print("Please enter your favourite foods")
a = input("Food 1: ")
b = input("Food 2: ")
c = input("Food 3: ")
d = input("Food 4: ")

food = {1:a, 2:b, 3:c, 4:d}
print(food)

Q = int(input("Which food would you like to remove?: "))

food.pop(Q)
sorted(food)

print(food)


text:
Q: Filtering product collection by combination of attributes I have two sets of product attributes:
Att1 {a, b, c, d}
Att2 {e, f, g, h}

These attributes are multiple select fields.
Then I have a collection of 3 products:
Prod1 (Att1: {b, d, a}, Att2: {g})
Prod2 (Att1: {a, c},    Att2: {h, f})
Prod3 (Att1: {a, d},    Att2: {e, f, g})

From this collection I'd like to extract product with these attribute combination
Att1 LIKE 'a, d' AND Att2 LIKE 'g'
so that the result would be Prod1 and Prod3
$_productCollection->addAttributeToFilter

accepts only one attribute but I'd like to add a combinaiton of two.
How can I do this?


text:
Q: Assigning multiple Children to Grid and visualizing them I'm setting up an Xamarin.Forms app where i am trying to add a "Module", saving it in a list and then visualizing it on Android via grid cells.
The problem is within the visualization. The problem is that i am trying to add multiple children to the same grid cell, but they are overlaying with each other.
public void CreateModuleGrids()
    {

        foreach (Module item in _mm.ModulesList)
        {
             gOut.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(100) });
                gOut.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(100) });
                gOut.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(100) });

                Label lblBez = new Label();
                lblBez.Text = item.Name.ToString();
                lblBez.VerticalOptions = LayoutOptions.Center;
                lblBez.HorizontalOptions = LayoutOptions.Center;

                lblBez.WidthRequest = 151;
                lblBez.HeightRequest = 25;

                Label lblStatus = new Label();
                lblStatus.WidthRequest = 151;
                lblStatus.HeightRequest = 25;
                if (item.Type == "blind")
                {
                    lblStatus.Text = "100 %";
                    lblStatus.VerticalOptions = LayoutOptions.Center;
                    lblStatus.HorizontalOptions = LayoutOptions.Center;

                }
                else
                {
                    lblStatus.Text = "Closed";
                    lblStatus.VerticalOptions = LayoutOptions.Center;
                    lblStatus.HorizontalOptions = LayoutOptions.Center;
                }

                if (item.Type == "blind")
                {
                    bmp100.WidthRequest = (119);
                    bmp100.HeightRequest = (117);
                    bmp100.Aspect = Aspect.AspectFit;
                    bmp100.VerticalOptions = LayoutOptions.Center;
                    bmp100.HorizontalOptions = LayoutOptions.Center;

                    gOut.Children.Add(bmp100, 0, 0);
                }
                else
                {
                    bmpClosed.WidthRequest = (119);
                    bmpClosed.HeightRequest = (117);
                    gOut.Children.Add(bmpClosed, 0, 0);
                }

                if (item.Type == "blind")
                {
                    ImageButton btnArrowUp = new ImageButton();

                    btnArrowUp.WidthRequest = 37;
                    btnArrowUp.HeightRequest = 50;
                    btnArrowUp.Source = "ArrowUp.png";
                    btnArrowUp.Aspect = Aspect.AspectFit;
                    btnArrowUp.VerticalOptions = LayoutOptions.Start;
                    btnArrowUp.HorizontalOptions = LayoutOptions.Start;

                    btnArrowUp.Clicked += new EventHandler(this.btnArrowUp_click);

                    ImageButton btnArrowDown = new ImageButton();
                    btnArrowDown.WidthRequest = 37;
                    btnArrowDown.HeightRequest = 50;
                    btnArrowDown.Source = "ArrowDown.png";
                    btnArrowDown.Aspect = Aspect.AspectFit;
                    btnArrowDown.VerticalOptions = LayoutOptions.End;
                    btnArrowDown.HorizontalOptions = LayoutOptions.End;
                    btnArrowDown.Clicked += new EventHandler(this.btnArrowDown_click);

                    gOut.Children.Add(lblBez, 0, 0);
                    gOut.Children.Add(lblStatus, 0, 0);
                    gOut.Children.Add(btnArrowDown, 0, 0);
                    gOut.Children.Add(btnArrowUp, 0, 0);

                }
                else
                {
                    ImageButton btnOut = new ImageButton();
                    btnOut.Measure(37, 50);
                    btnOut.Source = "ArrowLeft.png";
                    btnOut.Clicked += new EventHandler(this.btnTipOpen_click);

                    ImageButton btnIn = new ImageButton();
                    btnIn.Measure(37, 50);
                    btnIn.Source = "ArrowRight.png";
                    btnIn.Clicked += new EventHandler(this.btnTipClose_click);

                    gOut.Children.Add(lblBez, 0, 0);
                    gOut.Children.Add(lblStatus, 0, 0);
                    gOut.Children.Add(btnIn, 0, 0);
                    gOut.Children.Add(btnOut, 0, 0);

                }

            }

My expectation is having a grid instance that contains a label with the name of the module on the upper part, an imagebutton on the left side, an imagebutton on the right side, an image in the center and last a label under the image that shows the status. Thanks in advance!

A:
The problem is that i am trying to add multiple children to the same
  grid cell, but they are overlaying with each other.

The items are overlaying with each other because you add them to the same position in Grid.
To place views in a Grid you'll need to add them as children to the grid, then specify which row and column they belong in.
The last two parameter in function grid.Children.Add specify the position of the item in Grid. For example, there is a Grid with two rows and two Columns, then (0,0) means top left, and (1,1) means bottom right.
// left, top
grid.Children.Add(topLeft, 0, 0);
grid.Children.Add(topRight, 1, 0);
grid.Children.Add(bottomLeft, 0, 1);
grid.Children.Add(bottomRight, 1, 1);

Back to your code, you add all your elements to (0,0), so they will appear in the same position.
gOut.Children.Add(lblBez, 0, 0);
gOut.Children.Add(lblStatus, 0, 0);
gOut.Children.Add(btnIn, 0, 0);
gOut.Children.Add(btnOut, 0, 0);

Another problem in your code is you need a Layout container(Like stacklayout or other layouts) as Jason said to manage your elements. Because you create them in a foreach loop, and  in each loop you add the same thing with same position to the gOut.
I think the RIGHT way is create a Grid with your labels and imageButtons with right position in each loop.Then add this Grid to a Layout container(This layout container is use to layout the Grid created in each loop). At last, set this layout container as ContentPage's content, Content = layout container to display your elements.
Have a look at this document may help you and there is also a sample there.


text:
Q: Extracting element in R according to a pattern I have the variable 'qualification' in a df with observations like this:

*

*a bachelor's degree and 6 years of experience. At least 3 years of experience in the implementation and management...

*at least 3 years of professional experience with strong recommendations from previous supervisors.    experience in procurement, office administration, logistics management, and event/meeting coordination.

*a ba/s or equivalent in relevant field; ma/s preferred. minimum 5 years' ngo...

*bachelor's degree required.•  2 years of relevant work experience...

I would like to create the variable exp (year of experience) substracting the number of years form qualification as  for the example above:
exp:
6
3
5
2
How can this be done?

A: Use str_extract from stringr library:
library(stringr)
df <- data.frame(qualification = c("a bachelor's degree and 6 years of experience. At least 3 years of experience in the implementation and management...", "at least 3 years of professional experience with strong recommendations from previous supervisors. experience in procurement, office administration, logistics management, and event/meeting coordination.", "non-matching string"))
df$exp <- as.numeric(str_extract(df$qualification, "(\\d+)(?=\\s+year)"))
print(df$exp)
## [1]  6  3 NA


text:
Q: How to determine all the complex structures on torus $T^2$? I have known that the lattice given by the pair $(\tau_1,\tau_2)$ can determine a complex structures on torus $T^2$.
But how to prove that all the complex structures of torus can be obtained in this way?

A: This follows from the Riemann mapping theorem.
If you consider a compatible Riemannian metric on the torus, the claim can be expressed as follows: every metric on the torus has a flat metric in its conformal class.


text:
Q: Given $A \subset U$ and $B \subset U$. Prove or disprove $A - B \ = \emptyset \implies A \subset B$
Given $A \subset U$ and $B \subset U$. Prove or disprove $A - B \ = \emptyset \implies A \subset B$

I think this is the way to do it: $$ A = B \implies A \subset B \implies A' = B' \implies A-B = \emptyset  $$


text:
Q: Text change on a edit box I am using an edit box as a round counter.  I would like when the text = 5 or 10 for it to show this message then it does some functions. but even when the round is 5 or 10, i never get this message  ERoundChange is the OnChange event for the ERound(edit box) ;  Any idea why its not working?  I assume i am using Self wrong?
{Check if round is 5 or 10}
//-----------------------------------------------------
procedure TBaseGameForm.ERoundChange(Sender: TObject);
//-----------------------------------------------------
begin
 if (self.Text = '5') or (self.Text = '10') then
   begin
      showmessage('checking stats for gryph locations on round: '+self.Text);

    end;
end;

Also I change the round at the beginning of each players turn like so
ERound.Text := inttostr(Strtoint(ERound.Text)Mod 10+1);

A: Since ERoundChange is a method of TBaseGameForm, Self refers to the current instance of TBaseGameForm, that is, to the form, and not the edit box inside it.
Hence, Self.Text is the caption of the form, and not the text inside the edit box. If the edit box is named Edit1, you should do
procedure TBaseGameForm.ERoundChange(Sender: TObject);
begin
  if (Edit1.Text = '5') or (Edit1.Text = '10') then
    ShowMessage('checking stats for gryph locations on round: '+ Edit1.Text);
end;

You could also do
procedure TBaseGameForm.ERoundChange(Sender: TObject);
begin
  if ((Sender as TEdit).Text = '5') or ((Sender as TEdit).Text = '10') then
    ShowMessage('checking stats for gryph locations on round: '+ (Sender as TEdit).Text);
end;

since the control that caused the event is stored in the Sender argument. But since Sender is declared as TObject, you need to cast it to the actual TEdit which it is.
[You could have figured this out yourself. Indeed, the procedure  TBaseGameForm.ERoundChange itself has nothing to do with the edit control -- sure, it is assigned to an event of this control, but of course you can assign it to other controls as well, and use it in any other way you like. Hence, by itself, it is only associated with TBaseGameForm, so really, Self couldn't logically refer to anything else.]

A: That method is an instance method of the form and so Self.Text refers to the text, or caption, of the form. You need to use
(Sender as TEdit).Text

instead.
Although, to avoid duplication you should use a local variable to hold the edit control reference:
procedure TBaseGameForm.ERoundChange(Sender: TObject);
var
  Edit: TEdit;
begin
  Edit := (Sender as TEdit);
  if (Edit.Text = '5') or (Edit.Text = '10') then
    ShowMessage('checking stats for gryph locations on round: ' + Edit.Text);
end;


text:
Q: Flex: Sending parameters to Alert closeHandler Is it possible to send parameters to a closeHandler Alert function?
The fisrt parameter the function gets is the CloseEvent, but how to send another one?
<s:Button id="btnLoadLocalData" label="Load data"
          click="Alert.show('Populate list with local data?', '', Alert.YES | Alert.CANCEL, this, loadLocalData(???parameters???), null, Alert.OK);"/>

Thank you!

A: I usually use an anonymous function to wrap a function call with parameters:
Alert.show("Are you sure?", Alert.YES | Alert.CANCEL, null, function(event:CloseEvent):void{doSomething(event.detail, param1, param2);}, null, Alert.CANCEL)

A: An approach might be to create the closeHandler in the scope of the alert creation.
Here's an example:
<s:Button id="btnLoadLocalData" label="Load data" click="btnLoadLocalData_clickHandler(event)"/>

function btnLoadLocalData_clickHandler(event:Event):void {
  var someVar:Object = someCalculation();
  var closeHandler:Function = function(closeEvent:CloseEvent):void {
    // someVar is available here
  };
  Alert.show('Populate list with local data?', '', Alert.YES | Alert.CANCEL, this, closeHandler, null, Alert.OK);
}

A: This should be possible using Flex's dynamic function construction. A similar question was asked here.
Here's an example:
The parameters and handler:
var parameters:String = "Some parameter I want to pass";

private function loadLocalData(e:Event, parameter:String):void
{
  // voila, here's your parameter
}

private function addArguments(method:Function, additionalArguments:Array):Function
{
  return function(event:Event):void {method.apply(null, [event].concat(additionalArguments));}
}

Your component:
<s:Button id="btnLoadLocalData" label="Load data"
          click="Alert.show('Populate list with local data?', '', Alert.YES | Alert.CANCEL, this, addArguments(loadLocalData, [parameters])), null, Alert.OK);"/>

A: My typical method of handling this use case is to add the data to the Alert form.  For example
var o:Object = new Object();
o["stuff"] = "quick brown fox";

var alert:Alert = Alert.show("Message", "Title", mx.controls.Alert.YES | mx.controls.Alert.NO, null, OnAlertResult);
alert.data = o;

And then in the close handler for the Alert
private function OnAlertResult(event:CloseEvent):void {
    trace(event.target.data);
}


text:
Q: A concrete example of involution in group theory I am reading the textbook "Introduction to Modern Algebra, Joyce 2017" and in the Cyclic groups and subgroups section, there is a following sentence about involution.

An involution $a$ is an element of a group which is its own inverse, $a^{-1} = a$. Clearly, the order of an involution $a$ is $2$ unless $a = 1$, in which case the order of $a$ is $1$.

I was trying to come up with a concrete example, but I am having difficulties. Maybe when $a = \frac{1}{2}, \frac{1}{2}^2 = 1$? I also searched the wikipedia page for a concrete example, but wasn't able to find anything.
Can someone provide an example with numbers for me please? I want to understand why the author writes "clearly" that the order of an involution $a$ is $2$. Thank you

A: Example: in the cyclic group $\mathbb{Z}_{12}$, $6$ is an involution since $6+6=0$ in $\mathbb{Z}_{12}$. More generally, in $\mathbb{Z}_{2n}$, the element $n$ is an involution.
Notice that the requirement $a=a^{-1}$ is equivalent to $aa=1$ (just multiply both sides by $a$). Therefore an involution must satisfy $a^2=1$. So the only way it does not have order $2$ is if it has order smaller than $2$, i.e., $a=1$.

A: An involution in a group is any non-trivial element of order two (not a subset of them, as the phrase you mention suggests, and also the identity is explicitly omitted). That is, $a$ is an involution if and only if $a\neq1$ and $a^2=1$:
$$
\begin{align*}
a&=a^{-1}\\
\Leftrightarrow a\cdot a&=a\cdot a^{-1}&\text{(left multiply by $a$)}\\
\Leftrightarrow a^2&=1
\end{align*}
$$
For a concrete example of an involution, consider the set $\{0, 1\}$ under addition modulo $2$. Here, the identity is $0$, and $1+1=2=0\pmod2$.

A: An involution is, in essence, anything that undoes itself. For example, flipping a coin over by one axis, the action of turning a key for certain padlocks, or adding one modulo two.

A: Take the general linear group $G=GL_n(K)$ and the element $A=-I_n$. It has order $2$ because of $A^2=I_n$ and hence is an involution.


text:
Q: How we get close event of local notification? I need to schedule local notification on receiving previously scheduling local notification. I have schedule another notification on close event of local notification.

A: Do you want to create a new local notification if "close" button in alert of UILocalnotification is clicked?
If so, you can't handle that close button event.


text:
Q: JSF 2: how to pass an action including an argument to be invoked to a Facelets sub view (using ui:include and ui:param)? This is basically an extension to this answer.
I am trying to get an argument into a method/action call (for a delete button in a list/data table).
Client:
<ui:include src="...">
  <ui:param name="acceptButtonBean" value="#{repoHome}" />
  <ui:param name="acceptButtonAction" value="removeIndividualDocument(#{doc.id})" />
</ui:include>

Sub view:
<h:commandButton value="Continue"
                 action="#{acceptButtonBean[acceptButtonAction]}" />
  ...
</h:commandButton>

However, JSF fails with an exception saying:
...yadda, yadda
02:46:02,431 ERROR [stderr] (http--127.0.0.1-8080-5) Caused by: javax.el.MethodNotFoundException: /subviews/remove-doc-clink-popup.xhtml @37,98 action="#{acceptButtonBean[acceptButtonMethod]}": Method not found: com.company.project.beans.RepoHome@34b183e7.removeExternalDocument(89)()
02:46:02,431 ERROR [stderr] (http--127.0.0.1-8080-5)    at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:109)
02:46:02,431 ERROR [stderr] (http--127.0.0.1-8080-5)    at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
02:46:02,431 ERROR [stderr] (http--127.0.0.1-8080-5)    ... 31 more

Note the
....RepoHome@34b183e7.removeExternalDocument(89)()

It can't work that way. JSF seems to append parentheses no matters what.
Can it be achieved differently, but still with the above technique? If so, how?
If not, why isn't it working? Is it specified? Is it a bug with Mojarra 2.0.x? I see no problem to omit the parentheses in case of the presence of other parentheses...
Note I'm not looking for alternative solutions like using f:param, f:attribute, or f:setPropertyActionListener.
Thanks in advance

A: That's indeed not valid EL. You cannot mix method names and arguments in a single variable. This should work:
<ui:include src="...">
  <ui:param name="acceptButtonBean" value="#{repoHome}" />
  <ui:param name="acceptButtonAction" value="removeIndividualDocument" />
  <ui:param name="acceptButtonArgument" value="#{doc.id}" />
</ui:include>

with
<h:commandButton value="Continue"
    action="#{acceptButtonBean[acceptButtonAction](acceptButtonArgument)}" />

Note that this is not exactly related to JSF, but to EL. If it were a bug or a feature, you'd need to read up the EL specification or report to the EL guys, not the JSF one. JSF is nothing to blame here. EL is an entirely standalone API which JSF just happens to use.

Update: it turns out that it works on Tomcat 7 (and likely any other container with org.apache.el.* implementation), but not on Glassfish 3 (with com.sun.el.* implementation). It fails as follows while displaying the page:
Caused by: javax.el.ELException: Error Parsing: #{p1[p2](p3)}
    at com.sun.el.lang.ExpressionBuilder.createNodeInternal(ExpressionBuilder.java:174)
    at com.sun.el.lang.ExpressionBuilder.build(ExpressionBuilder.java:191)
    at com.sun.el.lang.ExpressionBuilder.createMethodExpression(ExpressionBuilder.java:242)
    at com.sun.el.ExpressionFactoryImpl.createMethodExpression(ExpressionFactoryImpl.java:81)
    at org.jboss.weld.util.el.ForwardingExpressionFactory.createMethodExpression(ForwardingExpressionFactory.java:43)
    at org.jboss.weld.el.WeldExpressionFactory.createMethodExpression(WeldExpressionFactory.java:62)
    at com.sun.faces.facelets.tag.TagAttributeImpl.getMethodExpression(TagAttributeImpl.java:222)
    ... 63 more
Caused by: com.sun.el.parser.ParseException: Encountered "(" at line 1, column 9.
Was expecting one of:
        (*snip*)

I checked chapter 1.19 of the EL 2.2 spec:
 ValueSuffix      ::= '.' Identifier MethodParameters?
                    | '[' Expression ']' MethodParameters?          <-- Look here
 MethodParameters ::= '(' (Expression (',' Expression )* )? ')'

and I am pretty confident that Tomcat is right. It's time to report a bug to Glassfish boys: GLASSFISH-17628.

Update 2: you seem to be actually using JBoss 7. I don't know what fork of Tomcat 7 exactly it uses, but I can confirm that I can reproduce your problem with Tomcat 7.0.19; it fails as follows after pressing the button:
Caused by: javax.el.MethodNotFoundException: /test.xhtml @22,62 action="#{p1[p2](p3)}": Method not found: com.example.Bean@2616aa35.submit(java.lang.String)
    at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:109)
    at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
    ... 24 more

I was using Tomcat 7.0.22 when it ran successfully, so it has been fixed somewhere between Tomcat 7.0.20 and 7.0.22.


text:
Q: Set color on GradientDrawable not working from Fragment I have a background drawable like this:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >

<item android:bottom="80dp"
      android:id="@+id/card_background">
    <shape>
        <solid android:color="@color/x_card_color_pink"
               android:height="100dp"/>
        <corners
            android:topLeftRadius="10dp"
            android:topRightRadius="10dp"/>
    </shape>
</item>

<item android:top="120dp">
    <shape>
        <solid android:color="@color/white"
            android:height="100dp"/>
        <corners
            android:bottomLeftRadius="10dp"
            android:bottomRightRadius="10dp"/>
    </shape>
</item>

</layer-list>

I want to change the color of card_background. When I set the new color from the activities onCreate it works:
    LayerDrawable layerDrawable = (LayerDrawable) ContextCompat.getDrawable(this, R.drawable.card_background);
    GradientDrawable gradientDrawable = (GradientDrawable) layerDrawable.findDrawableByLayerId(R.id.card_background);
    gradientDrawable.setColor(0xFFEBC51B); //Successfully set to yellow from activity

However If try setting it from the fragment that also is showing the background I cant make it change. I want to be able to do this in a clickhandler later on but right now I use the same code in the fragments onCreate:
    LayerDrawable layerDrawable = (LayerDrawable) ContextCompat.getDrawable(getActivity(), R.drawable.card_background);
    GradientDrawable gradientDrawable = (GradientDrawable) layerDrawable.findDrawableByLayerId(R.id.card_background);
    gradientDrawable.setColor(0xFF5ABC63); //Fail to set to green from fragment

Im thinking since I am showing the fragment at the same time as I update it I have to refresh it or something? I tried the method invalidateSelf but with no effect.
Any ideas on how I can change the background color from the Fragment?

A: Oh, I found a solution:
    LayerDrawable layerDrawable = (LayerDrawable) ContextCompat.getDrawable(getActivity(), R.drawable.card_background);
    GradientDrawable gradientDrawable = (GradientDrawable) layerDrawable.findDrawableByLayerId(R.id.card_background);
    gradientDrawable.setColor(0xFF5ABC63);

    RelativeLayout layout = (RelativeLayout) rootView.findViewById(R.id.card_layout);
    layout.setBackground(layerDrawable);

If I set the drawable again to my layout it updates the background.


text:
Q: Is this the right way to loop through Arrays? #include <iostream>
#include <Windows.h>
#include <string>
using namespace std;

int main(){
    string Whitelist[4] = {"Stian", "Mathias", "Modaser"};
    for (int x = 0; x < 3; x++){
        cout << x + 1<< ". " << Whitelist[x] << endl;
        if (Whitelist[x] == "Stian" && "Mathias" && "Modaser"){
            cout << "" << Whitelist[x] << " is here" <<  endl;
        }
        else{ cout << "no one is here" << endl; }
    }
    cin.get();
    return 0;
}

//so yeah basically im just trying to loop through my array and see if any of these names are there. so i guess u can pretty much read what the code does since most of u are pros :P. but when i asked my friend, whos been coding for 1-2 years, he said that i couldnt loop through arrays like this and told me to use a vector. what does he mean by that? and my code works?

A: This set of code is wrong
if (Whitelist[x] == "Stian" && "Mathias" && "Modaser"){
    cout << "" << Whitelist[x] << " is here" <<  endl;
}

Why? because suppose the first condition of the if statement evaluates  to true like this:
if (true && "Mathias" && "Modaser")
{
    //...
}

Then the code wouldn't make sense. In an if statement, you have to check for every condition separately, like this:
if (Whitelist[x] == "Stian" && Whitelist[x] =="Mathias" && Whitelist[x] =="Modaser"){
    cout << "" << Whitelist[x] << " is here" <<  endl;
}

But since any 1 string cannot be three names at the same time, this condition will fail, (you used &&). Fix your code using the || operator, like this, for your final code (Also, remove << "", that is just redundant, and unnecessary):
if (Whitelist[x] == "Stian" || Whitelist[x] =="Mathias" || Whitelist[x] =="Modaser"){
    cout << Whitelist[x] << " is here" <<  endl;
}

BTW: As a recommendation, use a std::vector<std::string>, not a raw array, so you get easier and more capabilities than an array.
Lastly, you also have 4 elements in your array, of which one is unused. It might be a typo, so make your array size 3.

A: There is nothing fundamentally wrong with looping over an array like this.
We can only guess what your friend meant, but I can perform my own review of your code.
However, you have four array elements and only loop over three of them, which may be a mistake; if it is, it's evidence that you'd be better off using iterators, rather than hard-coding numbers that you can get wrong.
Furthermore, your if conditional is wrong: did you mean || ("or"), instead of && ("and")? And you have to write out the adjoined conditions in full, so:
if (Whitelist[x] == "Stian" || Whitelist[x] =="Mathias" || Whitelist[x] =="Modaser")

I'm not sure why you're comparing against all these values, when they're the only ones in the array. Well, except for that empty fourth element; perhaps you're trying to catch that. We don't know, because you didn't tell us. Did you mean to search Whitelist while iterating over some other array? We have no way of knowing. Maybe that's what your friend really meant? Again, I couldn't say.
Streaming "" to std::cout just waits resources and does literally nothing else. Remove it.
Finally, and somewhat tangentially, it would be better not to block waiting for input as a means to keep your console window open. That is not your program's job.


text:
Q: Continuity of f where f(x) =d(u,x) maps the metric space M into the real numbers How do I prove that the function $f(x) = d(u,x)$ who maps the metric space $M$ into the real numbers are continuous? u is a fixed point of the metric space $M$.

A: Hint: $d(u,x) \leq d(u,y) + d(x,y)$ and $d(u,y) \leq d(u,x) + d(x,y)$ yields that $|d(u,x) - d(u,y)| \leq d(x,y)$. Conclude.


text:
Q: Error handling system.outofmemoryexception I am using multithreading to post content to 1 url. My error is that when I run 300 threads, after 10 to 15 minutes, I will be pushed out and get the message "system.outofmemoryexception". According to my attention, the configuration of my computer is: Ram 32G, 12 Core, 24 Threads ...! I'm new so I don't know how to handle it. Can you help me? I would like to thank anyway.
Code:
int sothread = 100;
for (int ii = 0; ii < sothread; ii++)
    Thread t2 = new Thread(() => {
        while (true) {
            string url = "https://phamnhi.net";
            string data = "id=123213&view=333";
            html = PostData(http, url, data, "application/x-www-form-urlencoded; charset=UTF-8").ToString();
            try {
                if (html.Contains("OK")) {
                    row.Cells[status].Value = "ok...";
                    Thread.Sleep(20000);
                    http.Close();
                }
            } catch (OverflowException) { break; }
        }
    });
     t.IsBackground = true;
     t.Start();
     Thread.Sleep(1000);
}

A: Sounds like you need to release the resources of your program after they execute. If every thread spins up more work without coming to completion, you're going to run out of memory eventually.
Please post some of the code for analysis.


text:
Q: Same width for all cols Boostrap4 I am using Bootstrap since a while, but I am stuck with the problem.
After the Bootstrap 4 npm installation, I have col-xs-1 and col-xs-12 same width:100%
I inspected library files I installed and I have same width for all elements (xs, md, lg etc.).
What should I do?
Bootstrap v.4.5.3
Bootstrap.min.css image here
frontend inspection here

A: Thanks to  Ahmed Tag Amer, the solution is:
col-xs-12 must be in row class


text:
Q: Forward aliases to child process I have some aliases which are defined in /etc/zprofile (or /etc/profile for bash). Also $PATH gets manipulated there.
I want to start an interactive shell from a shell which avoids the $PATH manipulation. I do this by starting it with the -f option. Yet, the aliases which are defined in the parent shell are useful and I'd like to forward them to the child process.
Copy and pasting the aliases which are defined by /etc/zprofile once into a text file and sourcing it every time I start another shell is not what I'm looking for as the definitions in /etc/zprofile get maintained and may change over time.
Do you have a recommendation how to forward aliases to the second shell?
(My main interest are zsh solutions, but I'm curious about bash solutions as well)
This is how the situation looks to me
# log in with ssh
shell1 > echo "here aliases are the way I want them to be"
shell1 > VARIABLE1=value1 VARIABLE2=value2 PATH=some_paths zsh
shell2 > echo "/etc/zprofile prepended something to PATH, which I don't like"
shell2 > echo "aliases are good"
shell2 > exit
shell1 > VARIABLE1=value1 VARIABLE2=value2 PATH=some_paths zsh -f
shell2 > echo "/etc/zprofile did not prepend something to PATH. This is good!"
shell2 > echo "but all aliases from shell 1 are \"forgotten\""
shell2 > exit

Continuing to provide information; the things in /etc are more involved than I initially thought:
/etc/zprofile contains the following, which I traced down to be what defines my aliases and $PATH
_src_etc_profile()
{
    #  Make /etc/profile happier, and have possible ~/.zshenv options like
    # NOMATCH ignored.
    #
    emulate -L ksh

    # source profile
    if [ -f /etc/profile ]; then
        source /etc/profile
    fi
}
_src_etc_profile

unset -f _src_etc_profile

but I missed that /etc/zshrc contains
_src_etc_profile_d()
{
    #  Make the *.sh things happier, and have possible ~/.zshenv options like
    # NOMATCH ignored.
    emulate -L ksh

    # from bashrc, with zsh fixes
    if [[ ! -o login ]]; then # We're not a login shell
        for i in /etc/profile.d/*.sh; do
        if [ -r "$i" ]; then
            . $i
        fi
        done
        unset i
    fi
}
_src_etc_profile_d

unset -f _src_etc_profile_d

so it's not only zprofile which goes through /etc/profile.d but also zshrc. One of the files in /etc/profile.d does then (with comments added by me for how it goes on)
if [ -n "$SHLVL" ]; then
    if [ $SHLVL = 1 ]; then
            source /some/group/path/profile
            # calls "source /some/group/path/env"
            # -> see else branch
    else
            source /some/group/path/env
            # calls "source /some/group/path/${SHELL}rc"
            # which then calls
            # "source /my/group/path/group_zshrc"
    fi
else
    echo 'No $SHLVL available, assuming login shell.'
    source /some/group/path/profile
fi

and ultimately /my/group/path/group_zshrc calls a python program which writes a temporary file in which aliasses and environment variables are defined / manipulated, which is then sourced in the end.

A: You shouldn't define aliases in /etc/zprofile or ~/.zprofile. These files is only loaded in login shells ("shells" meaning zsh of course). The proper place to define aliases is in /etc/zshrc or ~/.zshrc, which is read by all interactive shells.
To run zsh without loading /etc/zprofile, just run zsh with no option. The option -f tells zsh not to read configuration files at all, but since you want to read your alias definitions, that's not the right option. Since /etc/zprofile is only read by a login shell, just don't pass the -l option (and don't set a zeroth argument that begins with a dash).
Zsh has no option or environment variable to read one extra file on startup. If you want to prepare for that, you can add eval $ZSH_EXTRA_STARTUP_CODE to your .zshrc.
You can set the ZDOTDIR environment variable to make it read all of its user configuration files from a different directory, e.g. ZDOTDIR=/tmp/foo zsh reads /etc/zshenv, /tmp/foo/.zshenv, /etc/zshrc and /tmp/foo/zshrc. So to export aliases from the current instance to a child instance, you can run something like
tmp=$(mktemp -d)
alias -L >$tmp/.zshenv
echo ". ~/.zshenv; unset ZDOTDIR; rm -r ${(q)tmp}" >>$tmp/.zshenv
zsh

A: In bash
You can abuse the --rcfile option like so:
bash --noprofile --rcfile <(alias)

But the --noprofile is pretty useless without the -l option to make it a login shell.


text:
Q: Making C# class working VB6 I want to create a VS2010 c# class that can be used in a Vb6 project. I've done simple C# class below and ticked the "register for com interop" in the build properties. In the Vb6 project I can see a reference for ComTestC but when I run the vb6 code I get:
run-time error '429' ActiveX component can't create object
I'm I missing an obvious step to getting this Com object working?
Vb6 Code
Private Sub Command1_Click()

Dim foo As Object
Set foo = CreateObject("ComTestC.Numbers")

End Sub

C# Code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;

namespace ComTestC
{
    public class ComTestC
    {

        [Guid("8b8d1e17-fc8e-4316-afb7-394a5da56801")]
        [InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
        public interface _Numbers
        {
            [DispId(1)]
            int GetDay();

        }

        [Guid("68d6c981-66dd-4731-93a0-2c39bd86495f")]
        [ClassInterface(ClassInterfaceType.None)]
        [ProgId("ComTestC.Numbers")]
        public class Numbers : _Numbers
        {
            public Numbers() { }

            public int GetDay()
            {
                return (DateTime.Today.Day);
            }

        }

    }
}

A: Exposing .NET Components to COM


text:
Q: android - Place imageview next to two textviews under each other
How do i create above layout in android studio ?

A: First add  dependencies in your gradle file for circular image view
 compile 'de.hdodenhof:circleimageview:2.1.0'

now you can use below code as per your requirement
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:weightSum="3">

    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:gravity="center">

        <de.hdodenhof.circleimageview.CircleImageView
            android:id="@+id/meal_image_order"
            android:layout_width="96dp"
            android:layout_height="96dp"
            android:src="@color/colorAccent"
            app:civ_border_color="@color/colorPrimaryDark"
            app:civ_border_width="2dp" />

    </LinearLayout>

    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="2"
        android:gravity="center"
        android:orientation="vertical">

        <TextView
            android:id="@+id/tv1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Textview 1" />

        <TextView
            android:id="@+id/tv2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Textview 2" />

    </LinearLayout>
</LinearLayout>
</LinearLayout>

sample output

A: First add line in your app level build.gradle file following line of code in dependencies
 compile 'de.hdodenhof:circleimageview:2.1.0'

after try following code
   <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:weightSum="3">

        <LinearLayout
            android:layout_weight="1"
            android:layout_width="0dp"
            android:layout_height="match_parent">

            <de.hdodenhof.circleimageview.CircleImageView
                xmlns:app="http://schemas.android.com/apk/res-auto"
                android:id="@+id/meal_image_order"
                android:layout_width="80dp"
                android:layout_height="80dp"
                android:src="@mipmap/profile" />

        </LinearLayout>

        <LinearLayout
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:orientation="vertical"
            android:layout_weight="2">

            <TextView
                android:id="@+id/tv1"
                android:textSize="15sp"
                android:textStyle="bold"
                android:textColor="#000"
                android:gravity="start"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="Broad Bean" />

            <TextView
                android:id="@+id/tv2"
                android:textColor="#000"
                android:gravity="start"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="3dp"
                android:text="Broad" />

        </LinearLayout>
    </LinearLayout>

A:   [<RelativeLayout
                    android:layout_width="match_parent"
                    android:layout_height="100dp"
                    android:background="@drawable/view"
                    android:gravity="fill_horizontal|center">

                    <ImageView
                        android:id="@+id/dp"
                        android:layout_width="60dp"
                        android:layout_height="60dp"
                        android:layout_marginLeft="15dp"
                        app:srcCompat="@drawable/lea" />

                    <TextView
                        android:id="@+id/s_name"
                        android:layout_width="wrap_content"
                        android:layout_height="30dp"
                        android:layout_alignParentStart="true"
                        android:layout_alignTop="@+id/imageView"
                        android:layout_marginStart="85dp"
                        android:gravity="fill_vertical"
                        android:text="Mathan"
                        android:textColor="#78038A"
                        android:textSize="18.5dp"
                        android:textStyle="bold" />

                    <TextView
                        android:id="@+id/s_code"
                        android:layout_width="wrap_content"
                        android:layout_height="30dp"
                        android:layout_alignStart="@+id/s_name"
                        android:layout_below="@+id/s_name"
                        android:fontFamily="serif"
                        android:gravity="fill_vertical"
                        android:text="4320 - XXXXXXXXXXXXXXXXXXX"
                        android:textColor="#000000"
                        android:textSize="16dp"
                        android:textStyle="bold" />

                </RelativeLayout>][1]

  [1]: https://i.stack.imgur.com/Yzg8V.jpg


text:
Q: Deploying spring-beans 3.0.7 overrides somehow xml factory classes which are slower than the default We are currently implementing cxf services (separate WAR) into a legacy system (EAR file) on JBoss 5 eap.
But if we deploy spring-beans.3.0.7 (needed by cxf) on the WAR, it provides different xml factory classes which are slower, so that we have no performance issues.
Is it possible to prevent spring from populating different factory classes?
Or would it be possible to get all factory classes provided by spring, so that we can overrid them back?
I'm not able to find out which spring lib is causing this behaviour.


text:
Q: NullReferenceException when initializing MVCxGridViewColumn with null At line 233 I get a NullReferenceException, how is that possible?
Zeile 231:            foreach (var str in array)
Zeile 232:            {
Zeile 233:                MVCxGridViewColumn found = null;
Zeile 234:                foreach (MVCxGridViewColumn col in myresults.allcolumns)
Zeile 235:                {

I can provide other code if needed, but I don't have a clue where this error might come from.
I changed the code to test where the error comes from:
Zeile 232:            string[] array3 = {"A", "B"};
Zeile 233:
Zeile 234:            foreach (var str in array3)
Zeile 235:            {
Zeile 236:                //MVCxGridViewColumn found = new MVCxGridViewColumn();

Now the NullReferenceException appears in line 234. But the array can not be null because of line 232, right?


text:
Q: Child theme not being picked up on product detail page I'm using Porto theme. I have created a child theme and its working everywhere but the product detail pages.
On those pages it falls back to the default porto theme for all of its templates.
For example there is a template file that is in all pages: /app/design/frontend/smartwave/porto_childtheme/template/page/html/header_type3.phtml but on the product detail page it's not using that child theme template, the first one it see is /app/design/frontend/smartwave/porto/template/page/html/header_type3.phtml. There are also css amends I've made in a copy of layout.xml in the child theme.
I don't have any exceptions set up:

I have turned on the debug template path hints and I can see that there is no mention of the child theme in any of its normal places.
I have turned off all caching.
The site works with my child theme throughout the site except on the product detail pages. On these product detail pages the theme default "header_type3.phtml" is being loaded from "porto" instead of "porto_childtheme", the customisations I have made in local.xml to add css files are being skipped, it's like the child theme isn't being checked first.
Is there a setting that could make the product detail templates some kind of special case when selecting the template files?

A: It turns out that certain products had custom designs set up.
To fix the problem:

*

*Go to admin > Catalog > Manage Products

*Find the product that's not displaying correctly

*Go to the Design tab and then reset the Custom Design option back to "-- Please Select --" and press Save.

Repeat for each product and then flush caches.
Thanks to this thread - https://magento.stackexchange.com/a/67053/48154