text:
Q: Fail before command was complete I'd like my new command works even with a multiparagraph or tikz picture as parameter.
\documentclass{article}
\usepackage{paralist,xparse,calc}

\NewDocumentCommand{\HorsListe}{sO{1}m}{%
    \IfBooleanTF{#1}{%
    \par\nopagebreak[4]\addvspace{1\itemsep}%
        \hspace{-#2\leftmargin}}{%
    \par\nopagebreak[4]\addvspace{2\itemsep}%
        \hspace{-#2\leftmargin}}%
    \begin{minipage}[t]{\linewidth+#2\leftmargin}
    #3

    \addvspace{3\itemsep}
    \end{minipage}%
    \nopagebreak[2]}

\begin{document}
\begin{itemize}
\item This works

\HorsListe{Something wide}

\item This doesn't work.

\HorsListe{Something wide

    with paragraph}

\item This doesn't work too

\HorsListe{\begin{tikzpicture}

\draw (0,0) rectangle (\linewidth,0) ;

\end{tikzpicture}}

\end{itemize}
\end{document}

A: Arguments of \NewDocumentCommand are assumed to be short. You need + to make them long:
\NewDocumentCommand{\HorsListe}{sO{1}+m}{ CODE HERE }


text:
Q: How to have a button visible as soon as chatbot starts I have a bot framework chatbot which uses QnA Maker. The bot is primarily for product support FAQ type questions. I have built a series of follow on prompts which allow the user to navigate to different questions/answers via the buttons which appear.
Currently, you have to type a question such as "I have an issue" before you see the prompts, but I would (somehow) like the particular prompt pair ("Search by Issue Type" / "Search by Product Category" shown in red in the diagram below), to automatically appear as soon as the conversation starts, so that the user doesn't have to type anything to see the prompts.

I found a real-life example of a similar type of behaviour, in a microsoft bot , which can be accessed by clicking this link, and then clicking the "Chat with Sales" button which appears in the bottom right of the page.
In this real life microsoft example, the bot automatically comes up with a message and then a button which says "Start", which then takes the user down a series of prompts.  I would be happy to have a "Start" button on my bot if it could then take my user into the prompt pair "Search by Issue Type" / "Search by Product Category":

My bot (as it happens) has a "Hello and Welcome!" message (highlighted in purple in the first screenshot), which was implemented via c# in the bot code. [I'm not at all skilled in C# as it happens].
Can I achieve my objective just within QnAMaker ? or do I have to do something in the c# code to bring up prompt(s). If I do have to go down the c# route, any pointers would be great.

A:
Let's begin with your questions

"Can I achieve my objective just within QnAMaker ? or do I have to do something in the c# code to bring up prompt(s)?"

No you cannot do it only within  QnAMaker. You have to write your custom C# bot code.

"If I do have to go down the c# route, any pointers would be great"

As you might know bot conversation started from OnMembersAddedAsync method. so if you want to prompt a button card at the very begining of your conversation you could try something like below:

Starting Point:
protected override async Task OnMembersAddedAsync(IList<ChannelAccount> membersAdded, ITurnContext<IConversationUpdateActivity> turnContext, CancellationToken cancellationToken)
        {

            foreach (var member in membersAdded)
            {
                if (member.Id != turnContext.Activity.Recipient.Id)
                {
                    var productProactivePromptCardEvening = ProductAndCategoryPromptCard();
                    await turnContext.SendActivityAsync(productProactivePromptCardEvening);

                }
            }
        }

ProductAndCategoryPromptCard:
public IMessageActivity ProductAndCategoryPromptCard()
        {
            try
            {
                //Break in Segment
                var productCategoryInfoCard = Activity.CreateMessageActivity();
                //Bind to Card
                var heroCard = new HeroCard
                {
                    Title = "Try to search using the type of issue, or type of device",

                    Images = new List<CardImage> { new CardImage("") },
                    Buttons = new List<CardAction> {
                        new CardAction(ActionTypes.ImBack, "Search By Issue Type", value: "SearchByIssueType") ,
                        new CardAction(ActionTypes.ImBack, "Search By Product Category", value: "SearchByProductCategory")
                    },
                };

                // Create the attachment.
                var attachment = heroCard.ToAttachment();

                productCategoryInfoCard.Attachments.Add(attachment);
                productCategoryInfoCard.AttachmentLayout = AttachmentLayoutTypes.Carousel;
                return timeInfoCard;
            }
            catch (Exception ex)
            {
                throw new NotImplementedException(ex.Message, ex.InnerException);
            }

        }

Output:

Hope this is what exactly you are loking for. For details project example you could have a look here. You can modify the
project with this code.

Hopefully it would fulfil your requirement accordingly

redpajama_set_name: RedPajamaStackExchange


text:
Q: How to prevent svcutil processing a type I wanted to prevent svcutil to process a type in my assembly and have used the /excludeType:{NameSpace}.{Type} parameter. This has no effect and the tool process the type and create a error saying Duplicate contract XmlQualifiedNames are not supported. Is my assumption correct that this parameter /et should prevent processing a type inside the assembly?
Command Line:
svcutil /noconfig /namespace:,{NameSpace}.Automation.Runtime.Notifications.Proxy "wsdl\service\NotificationService{NameSpace}.Automation.Runtime.Notifications.wsdl" "wsdl\service\NotificationService{NameSpace}.Automation.Runtime.Notifications.xsd" "wsdl\service\NotificationService{NameSpace}.BusinessEntities.xsd" "wsdl\service\NotificationService{NameSpace}.BusinessEntities.Queue.xsd" "wsdl\service\NotificationService{NameSpace}.Diagnostics.xsd" "wsdl\service\NotificationService\schemas.microsoft.com.2003.10.Serialization.xsd"  /r:"{NameSpace}.dll" /r:"{NameSpace}.Notifications.dll" /r:"{NameSpace}.Diagnostics.dll" /r:"{NameSpace}.BusinessEntities.Core.dll" /r:"{NameSpace}.BusinessEntities.Workflow.dll" /excludeType:"{NameSpace}.Automation.Runtime.Notifications.Proxy.INotificationService"*  /ct:"{NameSpace}.Diagnostics.ErrorMessageCollection"   /o:E:\NotificationService.Proxy.cs /language:C#


text:
Q: How do I use the pyplot module of matplotlib in anaconda/Spyder? I keep getting this error:
 runfile('/Users/janani/Documents/TextbooksandResources/ComputationalPhysics/Projects/Summer 2016/Simple Pendulm Problem/simplependulum2.py', wdir='/Users/janani/Downloads')
    Traceback (most recent call last):

  File "<ipython-input-9-c2ed32828571>", line 1, in <module>
    runfile('/Users/janani/Documents/TextbooksandResources/Computational Physics/Projects/Summer 2016/Simple Pendulm Problem/simplependulum2.py', wdir='/Users/janani/Downloads')

  File "/Users/janani/anaconda/lib/python2.7/site-packages/spyderlib/widgets/externalshell/sitecustomize.py", line 714, in runfile
    execfile(filename, namespace)

  File "/Users/janani/anaconda/lib/python2.7/site-packages/spyderlib/widgets/externalshell/sitecustomize.py", line 81, in execfile
    builtins.execfile(filename, *where)

  File "/Users/janani/Documents/TextbooksandResources/Computational Physics/Projects/Summer 2016/Simple Pendulm Problem/simplependulum2.py", line 12, in <module>
    import matplotlib.pyplot as plt

  File "/Users/janani/anaconda/lib/python2.7/site-packages/matplotlib/pyplot.py", line 27, in <module>
    import matplotlib.colorbar

  File "/Users/janani/anaconda/lib/python2.7/site-packages/matplotlib/colorbar.py", line 34, in <module>
    import matplotlib.collections as collections

  File "/Users/janani/anaconda/lib/python2.7/site-packages/matplotlib/collections.py", line 27, in <module>
    import matplotlib.backend_bases as backend_bases

  File "/Users/janani/anaconda/lib/python2.7/site-packages/matplotlib/backend_bases.py", line 56, in <module>
    import matplotlib.textpath as textpath

  File "/Users/janani/anaconda/lib/python2.7/site-packages/matplotlib/textpath.py", line 22, in <module>
    from matplotlib.mathtext import MathTextParser

  File "/Users/janani/anaconda/lib/python2.7/site-packages/matplotlib/mathtext.py", line 63, in <module>
    import matplotlib._png as _png

    ImportError: dlopen(/Users/janani/anaconda/lib/python2.7/site-packages/matplotlib/_png.so, 2): Library not loaded: @loader_path/../../../libpng15.15.dylib
  Referenced from: /Users/janani/anaconda/lib/python2.7/site-packages/matplotlib/_png.so
  Reason: image not found

I tried upgrading matplotlib but it said that it's already upgraded (for Python 2.7).
I have Mac OSX 10.9.5
Edit:
I can import matplot lib, but I can't use pyplot.
So import matplotlib as mpl doesn't give an error but import matplotlib.pyplot as plt brings the above error


text:
Q: Cocoapods + storyboard + images So what I'm trying to do is put a component used across couple of apps as a private cocoapod. It has a storyboard, and couple of images with @1x and @2x versions. Storyboard uses those images in UIImageViews.
Works fine if images are placed as plain resources (not as part of an Asset library).
If images are located within an Asset Library - in IB the images shows fine, however app crashes during runtime when that scene loads, and it complains it can't see the images. Any ideas how to fix that?
--- UPD
I have resource specified like this in the podspec: s.resource_bundle = { 'PodResources' => 'Pod/resource/*.*' }. It copies images in separate bundle PodResources; images are just copied, and Asset Libraries are compiled into .car file.


text:
Q: How to take multiple values from a python list? I am creating a program that takes user input stores it in a list and then multiplies by either 5 or 1 alternating between each number. eg the first value is multiplied by 5 and the next 1 and so on. I want to remove all the values that i would multiply by 5 and add them to a separate list. How would this be done?
list1=[1,2,3,4]
list2=List1[???]

A: Here you go:
list1=[1,2,3,4]
list2 = [i*5 for i in list1[1::2]]

Two methods are used here slicing and list comprehension.

A: To get every other element, you could use a slice with a stride of two:
>>> list1 = [1,2,3,4]
>>> list2 = list1[::2]
>>> list2
[1, 3]

You can use a similar technique to get the remaining elements:
>>> list3 = list1[1::2]
>>> list3
[2, 4]

For further information, see Explain Python's slice notation


text:
Q: Amazon EC2 + S3 + Python + Scraping - The cheapest way of doing this? I tapped in to Amazons AWS offerings and please explain this in high level - if I am thinking right.
So I have few Python scraping scripts on my local machine. I want to use AWS for super fast internet connectivity and cheaper price - win / win!

*

*I understand that I can deploy a centOS/Ubuntu instance on EC2.
Install the necessary Python libraries. Start and stop instances
using boto (Python) to save costs. Am I thinking right so far? (Is it
feasible?)

*I will CRON some scripts that will start fetching (scraping) HTML
files for parsing later on. So these HTML files are copied over to S3
for storage (or shall I dump them to my local machine since that is
how I will be parsing and storing in MySQL?).
Please advise if I make any sense with my assumptions and the little knowledge I have of AWS with my few hours of reading/Googling about the service.

A: The basic premise of your setup seems fine, however, there are a few items that you may want to factor in.
Firstly, EC2 network (and I/O) bandwidth is dependant on instance type. If you are hoping to use t1.micro instances do not expect 'super fast internet connectivity' - even with an m1.small, you may not see the performance you are looking for. Also, keep in mind that you pay for bandwidth used on EC2 (and not just for instance time).
With regard to your first point, there should be no real difficulty in setting up Python on an EC2 instance. However, the potential difficulty arises from coordinating your instances. For example, if you have 2 instances running, how will you split the task between them? How will each instances 'know' what the other has done (presuming you aren't going to manually partition a list of URLs). Moreover, if you are launching an instance, will one of the EC2 instances be responsible for handling that or will your local machine deal with it (if it is one of the EC2 instances, how do you determine which instance will be responsible for the task (i.e. to prevent the 'launch' task being executed by every instance) and how do you redistribute the tasks to include the new instance? How do you determine which instance(s) to terminate automatically?
Undoubtedly, all of the above are possible (corosync/heartbeat, pacemaker, auto-scaling, etc.) but easy to overlook initially. Regardless, if you are looking for the 'best price' you will probably want to go with spot instances (as opposed to on-demand), however, for that to work, you do need a fairly robust architecture. (It is worth noting that the spot prices fluctuates significantly - at times exceeding the on-demand price; depending on the time-scale over which you are working, you will either want to set a low upper spot price, or determine the best approach (spot/on-demand) on a regular (hourly) basis to minimize your costs.) Although, I can't confirm it at the moment, the simplest (and cheapest) option may be AWS' auto-scaling. You need to setup Cloudwatch alarms (but Cloudwatch does provide 10 free alarms) and auto-scaling itself does not have a cost associated with it (other than the cost of new instances and the Cloudwatch costs).
Given that I really have no idea of the scope of your undertaking, I might ask why not simply use EC2 for the parsing and processing. Especially if the parsing is complex, the pages can be fetched faster than they can be processed, and you have a large number of pages (presumable, otherwise you wouldn't be going to through the effort of setting up AWS), it might be more efficient to simply process the pages on EC2, and when everything is done, download a dump of the database. Arguably, this might simplify things a bit - have one instance running MySQL (with the data stored on an EBS volume), each instance queries the MySQL instance for the next set of records (and perhaps marks those as reserved), fetches and processes, and saves the data to MySQL.
If you are not going to run MySQL on EC2, you can either store your HTML files on S3, as you have mentioned, or can go with saving them on an EBS volume. The advantage of S3 is that you don't need to pre-allocate storage (especially useful if you don't know the size of the data you are dealing with) - you pay for PUTs/GETs and storage; the downside is speed - S3 is not meant to be used as a filesystem, and (even though you can mount it as a filesystem) it would be fairly inefficient to be saving each individual file to S3 (as in you will want to accumulate a few pages and them upload them to S3). Additionally, if you have a large volume of files (tens of thousands) the processing of fetching all the filenames, etc. can be slow. EBS volumes are meant to be used as storage attached to an instance - the advantage is in speed - both transfer rates and the fact it has a 'filesystem' (so reading a list of files, etc. is quick) - EBS volumes persist beyond instance termination (except for EBS root volumes, which do not by default (but can be made to)). The downsides of EBS volumes are that you have to pre-allocate a quantity of storage (which cannot be modified on the fly) - and you pay for that amount of storage (regardless of whether all of it is in use); you also pay for I/O operations (also, the performance of EBS volumes is dependent on network speed - so larger instances get better EBS performance). The other advantage of EBS is that, being a filesystem, you can perform a task like gzipping the files very easily (and I imagine that if you are downloading a lot of html pages you will not want to be fetching individual files of S3 later on).
I am not really going to speculate on the possibilities (keeping in mind that at a very large scale, something like map-reduce/hadoop would be used to manage this kind of task), but as long as you have an approach for partitioning the task (e.g. MySQL instance) and managing the scaling of instances (e.g. auto-scaling), the idea you have should work fine.

A: You can interact with different instance via SQS. Its a queueing service. You can queue the input url to SQS. Each instance will take url from SQS sequentially. But SQS wont give same input to multiple instance. Thats the main advantage here..


text:
Q: PHP Foreach and jQuery I am working on a piece of code that I am wanting to "spice" up with jQuery but I can't think of a way to actually make it work. I am sure its simple, I just need a little advice to get me going.
I am wanting to create a piece of code that makes an Ajax request out to start a big loop that will download files and then upload them to an S3 bucket of mine. The place where I am stuck is I am wanting to send back a request back to the browser everytime a file is uploaded and output a string of text to the screen upon completion.
I don't have any of the frontend code working... just trying to get my head wrapped around the logic first... any ideas?
PHP Backend Code:
<?php
    public function photos($city) {
        if(isset($city))
            $this->city_name = "{$city}";

        // grab data array from Dropbox folder
        $postcard_assets = $this->conn->getPostcardDirContent("{$this->city_name}", "Photos", TRUE);
        $data = array();

        foreach($postcard_assets['contents'] as $asset) {
            //only grab contents in root folder... do not traverse into sub folders && make sure the folder is not empty
            if(!$asset['is_dir'] && $asset['bytes'] > 0) {
                // get information on file
                $file = pathinfo($asset['path']);

                // download file from Dropbox
                $original_file = $this->conn->downloadFile(str_replace(" ", "%20", $asset['path']));

                // create file name
                $file_name = $this->cleanFileName($file['basename']);

                // write photo to TMP_DIR ("/tmp/photos/") for manipulation
                $fh = fopen(self::TMP_DIR . $file_name, 'w');
                fwrite($fh, $original_file);
                fclose($fh);

                // Resize photo
                $this->resize_photo($file_name);

                // hash file name
                $raw_file = sha1($file_name);
                // create S3 hashed name
                $s3_file_name = "1_{$raw_file}.{$file['extension']}";
                // Upload manipulated file to S3
                $this->s3->putObject($s3_file_name, file_get_contents(self::TMP_DIR . $file_name), $this->photo_s3_bucket, 'public-read');

                // check to see if file exists in S3 bucket
                $s3_check = $this->s3->getObjectInfo($s3_file_name, $this->photo_s3_bucket);

                // if the file uploaded successully to S3, load into DB
                if($s3_check['content-length'] > 0) {
                    $data['src'] = $s3_file_name;
                    $data['width'] = $this->width;
                    $data['height'] = $this->height;
                    Photo::create_postcard_photo($data, "{$this->city_name}");
                    // Now that the photo has been uploaded to S3 and saved in the DB, remove local file for cleanup
                    unlink(self::TMP_DIR . $file_name);
                    echo "{$file_name} uploaded to S3 and resized!<br />";
                }
            }
        }
        // after loop is complete, kill script or nasty PHP header warnings will appear
        exit();
    }
?>

A: The main problem is that with PHP, the output is buffered so it won't return a line at a time. You can try and force the flush but it's not always reliable.
You could add an entry to the DB for each file that is exchanged and create a seperate API to get the details of what has completed.
Generally, Jquery will wait till the request has finished before it allows you to manipulate data from a HTTP request.


text:
Q: Materialize CSS modal getting cropped inside another modal I have a modal (datepicker) inside another modal but it is getting cropped because the parent modal is not big enough to display the second modal. Is there a way to make it pop out of the parent modal and be relative to the window and not the parent modal?
By inspecting the datepicker modal I can see that it is bigger than it appears. How is it possible if it's position is set to "fixed"?

Screenshot:

A: Try:
$('.datepicker').pickadate({
    container: 'body' //this will append to body
});


text:
Q: Finding distinct relations in neo4j I've got a neo4j database with users, tracks and DJs, where users have a similarity with a DJ, and DJs play tracks. Now I'd like to find all the tracks that are played by the DJ which has a similarity with the user, something like
MATCH (u:User {userId:'6'})-[s:SIMILARITY]->(dj:Dj)-[p:PLAYED]->(t:Track)
return COUNT(t)*s.similarity AS count,t order by count;

Problem is that dj's can play tracks multiple times, which I have represented by multiple PLAYED relations between a DJ and a track. So if a dj plays a track multiple times, it gets more weight by this query, and I'd only like to have those multiple relations count once.
The solution is probably something with DISTINCT, yet I don't know where to place it (count(distinct t) doesn't give the desired result). An alternative would be to restructure the database to only one PLAYED relation, and store the timestamp property of PLAYED as an array.
In that case I'd like to perform a query (somewhere else) asking "find all tracks this dj played after this timestamp", which would also solve this problem, yet I don't know how.
Thanks in advance

A: Your cypher statement is already pretty close to the solution. However you're aggregating for the track and want to use the count of the relationships to that track was weight, note that I've changed count(t) to count(p):
MATCH (u:User {userId:'6'})-[s:SIMILARITY]->(dj:Dj)-[p:PLAYED]->(t:Track)
return t, COUNT(p)*s.similarity AS weight order by weight;


text:
Q: How can I write data from 100 different file to the same csv? a=np.array(h5py.File('/Users/D/Desktop/Files500/1/FIELD-3D.h5', 'r')['Zone']['TOp']['data'])

np.savetxt('merged.csv',a.flatten(order='C'),delimiter=',')

I have 100 different 'Field-3d.h5' file in 100 different folder, how could I write TOp from all of them to the same csv with a delimiter?


text:
Q: Ctrl+Z does not exit Python 3.10 in Git Bash I just downloaded the latest Git Bash (2.36.1 64-bit) and installed Python 10. I'm running Windows 11. Among a couple of other unexpected changes from my earlier setup using a previous version of Git Bash and mostly running Python 3.9 (i.e. I now have to run python -i for the interactive python interpreter, for all 2.x and 3.x versions, instead of just running python), the most frustrating is that ctrl+z followed by Enter no longer quits from the interpreter. Instead I must call exit(). Ex:
user@User MINGW64 ~
$ python -i
Python 3.10.4 (tags/v3.10.4:9d38120, Mar 23 2022, 23:13:41) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> # ctrl+z, Enter pressed here
  File "<stdin>", line 1

    ^
SyntaxError: invalid syntax
>>> exit()

user@User MINGW64 ~
$

The same is true for my other installations of python 3 (3.7, 3.8, 3.9), but python 2.7 still has the expected behavior:
user@User MINGW64 ~
$ $PYTHON\\Python27\\python -i
Python 2.7.18 (v2.7.18:8d21aa21f2, Apr 20 2020, 13:25:05) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> # ctrl+z, Enter pressed here

user@User MINGW64 ~
$

What I've tried
I've done quite a bit of research but can't figure out what may have changed. In the earlier version of Git Bash, I remember that ^Z, ^X, ^C, and ^V characters (and maybe more) would display explicitly in the console when typed. Curiously, pressing ctrl+c followed by Enter comes with the error message below. Did some sort of character encoding change in the newer versions of Git Bash?
user@User MINGW64 ~
$ python
Python 3.10.4 (tags/v3.10.4:9d38120, Mar 23 2022, 23:13:41) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> # ctrl+c, Enter pressed here
Traceback (most recent call last):
  File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\encodings\cp1252.py", line 14, in decode
    def decode(self,input,errors='strict'):
KeyboardInterrupt

The above exception was the direct cause of the following exception:

KeyboardInterrupt: decoding with 'cp1252' codec failed (KeyboardInterrupt: )
>>>

I am too lazy to constantly type exit(). How can I restore the functionality where pressing ctrl+z, then Enter quits the interpreter for my python 3 versions?

A: After stumbling upon this answer, I've found a solution that restores the functionality I wanted. Instead of:
alias python3='.../Python310/python
in which case you must get to the interactive interpreter using python3 -i, and ctrl+Z keystrokes are not recognized, use:
alias python3='winpty .../Python310/python
If it's helpful to anyone, here's how I've set up my ~/.bash_aliases:
alias python2='winpty C:\Users\<user>\AppData\Local\Programs\Python/Python27/python'
alias python3.7='winpty C:\Users\<user>\AppData\Local\Programs\Python/Python37/python'
alias python3.8='winpty C:\Users\<user>\AppData\Local\Programs\Python/Python38-32/python'
alias python3.9='winpty C:\Users\<user>\AppData\Local\Programs\Python/Python39/python'
alias python3.10='winpty C:\Users\<user>\AppData\Local\Programs\Python/Python310/python'

alias python3='python3.10'
alias python='python2'

and these lines must be in ~/bashrc:
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi

Now you can open the python interpreter without requiring -i (just run python), and ctrl+Z, Enter exits it.
Edit: After reading this answer, I reinstalled Git Bash with "Enable experimental support for pseudo consoles" checked and functionality is restored without needing to run Python through winpty.


text:
Q: Update x rows from a MySQL table I've this table:
Table ___Units
|--------|------------|
| UNI_Id | UNI_Status |
|--------|------------|
|      1 |     active |
|      2 |     active |
|      3 |     active |
|      4 |     active |
|      5 |     active |
|      6 |     active |
|--------|------------|

How can I update the status to inactive for the two last created rows (so the highest UNI_Id) only if the current status is active.
This is what I tried:
UPDATE ___Units SET UNI_Status='inactive' WHERE (
    SELECT * FROM ___Units ORDER BY UNI_Id DESC LIMIT 2
) sub
ORDER BY UNI_Id ASC

Thanks.

A: Join with a subquery that returns the two highest IDs.
UPDATE ___Units AS u1
JOIN (
    SELECT UNI_Id
    FROM ___Units
    ORDER BY UNI_Id DESC
    LIMIT 2) AS u2 ON u1.UNI_Id = u2.UNI_Id
SET u1.UNI_Status = 'inactive'
WHERE u1.UNI_Status = 'active'


text:
Q: querying online database of free server via android app I am creating an app which queries an online database. I am using a mySql db hosted on a free web server. Can I create web services on free servers? Also can I query a database from my app directly without using web services?

A: From what I understand you need a .php file on the server that you will Http post to. That will talk to the MySQL database and return the information. This may not be 100% accurate but I tried it on a small local server and it worked. You cannot directly talk to a MYSQL database from my understanding.
What else have you tried so far?

A: No you cant query the database from android with out some webservice or some sort of application that will be in the middle between the android application and the database .
and you can create a web service in your free host
Hope that Helps

A: as RED_ has stated, you need Http POST to query your database. For the answer for free web server is Yes you can.
You can create some PHP file to execute and query specific functions Such as select and display list on your android App.
As far as i know, You are NOT able to query database directly and you need gateway to do this.  what i mean gateway is some files that bridging your app and the server's db. This gateway can send and receive JSON or XML objects then your android app can consume it.
Some good tutorial to begin with:
http://www.codeproject.com/Articles/267023/Send-and-receive-json-between-android-and-php
or call webservice in android
http://androidexample.com/WEBSERVICE/index.php?view=examplecloud&scat=26
if you need more detailed description, just create another question thread.
hope this helps.


text:
Q: change img source based on time of day using date("h:i:sa") Good afternoon.
I want to change the background color and two images based on the time of day, specifically sunrise and sunset.
I wrote this code, thinking that getting the comparison for sunrise/sunset would be easy, but I've hit a snag in how to best check for the correct time range in my if - else statement. Essentially I cannot seem to find anything to show how to represent those time ranges. I have the
I think also that the else is redundant because the default will be the first variable anyway.
My code:
<?php

    $pic1 = "images/full_top_bg_01.png";
    $pic2 = "images/full_top_bg_02.png";
    $bgcolor = "#3E7B98";

    $hour = date('G');

    if( $hour < 13 ){

    $pic1 = "images/full_top_bg_01.png";
    $pic2 = "images/full_top_bg_02.png";
    $bgcolor = "#3e7b98";

  } else if( $hour < 15 ){

    $pic1 = "images/full_top_bg_01-night.png";
    $pic2 = "images/full_top_bg_02_night.png";
    $bgcolor = "#333333";

  }
  else {
    $pic1 = "images/full_top_bg_01.png";
    $pic2 = "images/full_top_bg_02.png";
    $bgcolor = "#333333";
  }
?>

Then the variables are set in the code:
<div class="container-fluid top_container" style="background-color:<?php echo $bgcolor;?>">
    <img src="<?php echo $pic1;?>" class="img-responsive" alt="clouds1">
    <img src="<?php echo $pic2;?>" class="img-responsive" alt="clouds2">

So my question here is essentially: a) do I need an array to represent the time range and b) is my else if statement even necessary?

A: All you need to do is check the hour of the day.
<?php

// Using "G" in the date to get the 24-hour hour of the day
// instead of the 12-hour (am/pm) hour.
$hour = date('G');

if ( $hour < 12 ) {
  // Morning picture
}
else if ( $hour < 18 ) {
  // Afternoon
}
else {
 // Evening
}

?>

You can add as many conditions as you would like to pinpoint many more hours of the day.

A: In case anyone else is reading this - here is a solution for a time range that worked:
$hour = date('G');

if( $hour < 6 && $hour > 18 ){

$pic1 = "images/full_top_bg_01.png";
$pic2 = "images/full_top_bg_02.png";
$bgcolor = "#3E7B98";

} else if( $hour > 18 && $hour < 6 ){

$pic1 = "images/full_top_bg_01-night.png";
$pic2 = "images/full_top_bg_02_night.png";
$bgcolor = "#333333";

}

using the range $hour < 6 && $hour > 18 combined with the other range, I was able to create a time range.


text:
Q: Restore to SQL Server 6.5 and Migrate to SQL Server 2014 I have a database backup file from SQL Server 6.5. The file size is 52GB.
How can I restore this database file?
How can I migrate it to SQL Server 2014?

A: If you only have access to a backup file, to do this without using any third party tools (if even are any) requires you to move from version to version, which of course means that you have to have access to servers running three different versions, and unless you have the installation media at least SQL Server 2000 will probably be hard to get hold on.
If you have access to the server from where the backup originated you might be better off trying to export the data to some format that later versions can use.
If you choose the restore backup route a path that should work is this:
6.5 -> 2000
2000 (sp4) -> 2008
2008 -> 2014

A couple relevant of TechNet articles:
Migration SQL Server 2000 to SQL Server 2012
Copying Databases from SQL Server 7.0 or Earlier
There might be other and potentially better ways to do this, and I would consider asking this on Database Administrators.

A: check the directory (C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA) on your computer and copy the your database files of the older sql server system,for example if your databaase name is(test) you will copy the files test.ldf and test.mdf then go to the sql server system (2014)
to the same directory (C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA) and paste youur files, after that open your sql server management studio and right click on ( Databases )
then select attach then click add to browse to your database files and select test.mdf and press ok


text:
Q: Code new variable based on grep list of genes in R I have a problem with r.
This is a Snapshot of my real dataset:

I want to create a variable which indicates if at least one gene from a list of genes that I have is present in column D of my dataset(if its there=1, if not=0).
-an example of a list of genes that interest me : gene<-c("gene1|gene2|gene3|gene4")
the column D in my data set matches a variable that indicates the genes present in each individual(a set of genes per individual per line, separated by ,).
in my real dataset the genes in column D are separated by ,
Which function can I use?

A: You really shouldn't store multiple words in the same element. Make vectors like this:
genes <- c("gene1","gene2","gene3","gene4","gene5")

Anyway, assuming that you work with a data frame called df and assuming that your fourth column entries are indeed one single string where genes are separated by commas:
lis <- strsplit(df[,4], ",")

This will give is a list instead of a data frame, where every element contains all the genes separately. Next, make a list of the genes you are interested in (like above). Finally, do:
tab <- sapply(lis,function(x) any(genes %in% x))

Basically, for each row, %in% will check for each genes if it is in there. Next, the any command will return TRUE if any of the comparisons returns TRUE. So, if any of the genes is found in x, then it returns the value TRUE.
For example:
df <- structure(list(col1 = 1:10, col2 = 1:10, col3 = 1:10, col4 = c("gene1,gene2,gene3",
"gene2,gene3", "gene6,gene8", "gene9,gene10", "gene1,gene2,gene10",
"gene5", "gene3,gene6", "gene1,gene2,gene8", "gene6,gene7", "gene1,gene4"
)), .Names = c("col1", "col2", "col3", "col4"), row.names = c(NA,
-10L), class = "data.frame")

genes <- c("gene1","gene2","gene3","gene4","gene5")

lis <- strsplit(df[,4], ",")
tab <- sapply(lis,function(x) any(genes %in% x))
tab
# [1]  TRUE  TRUE FALSE FALSE  TRUE  TRUE  TRUE  TRUE FALSE  TRUE

df
#    col1 col2 col3               col4
# 1     1    1    1  gene1,gene2,gene3
# 2     2    2    2        gene2,gene3
# 3     3    3    3        gene6,gene8
# 4     4    4    4       gene9,gene10
# 5     5    5    5 gene1,gene2,gene10
# 6     6    6    6              gene5
# 7     7    7    7        gene3,gene6
# 8     8    8    8  gene1,gene2,gene8
# 9     9    9    9        gene6,gene7
# 10   10   10   10        gene1,gene4

Edit: Adjusted script according to clearer description.


text:
Q: How to construct dynamic query string in ReactJS I have a React app which I want to have this query string /contacts?page=${pageNumber}
where page number have to change when I go to the next page, I use newer version of react-router-dom which doesn't have useHistory hook. Now my URL is only http://localhost:3000/.
I have this code:
const Contact = (props) => {
let array = Object.values(props);
const navigate = useNavigate();
const [pageNumber, setPageNumber] = useState(1);
const [contacts, setContacts] = useState([]);
const [entry, setEntry] = useState([]);
const [searchTerm, setSearchTerm] = useState('');
const [isSynchronizedClicked, setIsSynchronizedClicked] = useState(false);

const handlePaging = (params) => {
    setPageNumber(params + 1);
    //navigate(`/contacts?page=${pageNumber}`);
};

useEffect(() => {
    setTimeout(() => {
        if (searchTerm !== '') {
            search();
        }
    }, 500);
}, [searchTerm, search]);

return (
    <>

            <DataGrid
                id={() => searchTerm === '' ? array.map((contact) => contact.id) : contacts.map((contact) => contact.id)}
                rows={searchTerm === '' ? array : contacts}
                sx={{
                    '.MuiDataGrid-columnHeaderTitle': {
                        fontWeight: 'bold',
                    },
                    '.MuiDataGrid-columnHeaders': {
                        backgroundColor: '#d3d3d3'
                    },
                    '.MuiDataGrid-row': {
                        maxHeight: '51px !important',
                        minHeight: '51px !important'
                    },
                    '.MuiDataGrid-virtualScroller': {
                        overflow: 'hidden'
                    }
                }}
                onPageChange={handlePaging}
                columns={columns}
                pageSize={10}
                rowsPerPageOptions={[10]}
                checkboxSelection
                onRowDoubleClick={e => navigateToDetails(e)}
                onSelectionModelChange={e => setEntry(e)}
            />

        {isSynchronizedClicked && <ClickAwayListener onClickAway={() => setIsSynchronizedClicked(false)}>

                Do you want to synchronize all contacts ?

This will take a while.

                    <button className='buttons reject' onClick={() => setIsSynchronizedClicked(false)}>No</button>
                    <button className='buttons approve' onClick={synchronize}>Yes</button>

</ClickAwayListener>}
    </>
);
};

And this code in App.js:
function App() {
return (
<BrowserRouter>

    <Routes>
      <Route path='/' element={<RenderContacts />} />
      <Route path='/details/:id' element={} />
    </Routes>

</BrowserRouter>
);
}

If someone knows how to do that, I'll be grateful.

A: This is a common gotcha with React setState.
https://reactjs.org/docs/state-and-lifecycle.html
Read the section:
State Updates May Be Asynchronous
I assume this is the failure: pageNumber likely will not be ready when used.
setPageNumber(params + 1);
navigate(`/contacts?page=${pageNumber}`);

Instead, just use params + 1 inside the navigate function.
After navigation, you will want to use useSearchParams() (assuming router v6?) to get the updated value.


text:
Q: example of totally inaccessible stopping time.: Why $S_n$ must be constant on {$S_n$
Can you explicitly explain why any s.t. $S_n$ must be constant on $\{S_n<T\}$?
I understand that $S_n$ to be a s.t. $\{S_n\leq t\}\in F_t$ and $F_t$ is generated by sets of omegas for which ${T\leq s}$ for any $s\leq t$. Can't understand how they are related.

A: This is example 6.2.5 from Stochastic Calculus and Applications by
Cohen & Elliott (http://dx.doi.org/10.1007/978-1-4939-2867-5).
I can't give a precise proof, and I don't know what Cohen and
Elliott had in mind, but I think I can illustrate why this is the case.
Since $\mathcal{F}_t$ is generated by the nested sets $\{T\le u\}$
for $u\le t$, and sigma algebras are closed under complements, it

*

*contains $\{T>t\}$, and

*the only subsets of $\{T>t\}$ in $\mathcal{F}_t$ differ from it by
sets of measure zero.

Since $S_n$ is a stopping time, $\{S_n \le t\}\in \mathcal{F}$.
Suppose $\{S_n \le t\} \nsubseteq \{T \le t\}$.  Then $\{S_n \le t\}
\cap \{T > t\}$ is nonempty.  If it has positive measure, then it must
be the case (by point 2 above) that $\{S_n \le t\} \cap \{T > t\} = \{T > t\}$ up to a
set of measure zero.  In particular, then $S_n \le t$ (because $\{T >
t\}$ and $\{T \le t\}$ partition $\Omega$).
Let $u$ be the infimum of the set of $t$ for which $\{S_n \le t\}
\cap \{T > t\}$ is of positive measure.  Then $S_n \le u$, and for $u'<u$, it
must be the case that $\{S_n \le u'\} \subset \{T \le u'\}$, so in
fact, $S_n = u$ on $\{T>u\}$ and the latter set in fact equals $\{S_n
< T\}$.


text:
Q: IBM Websphere MQ - UI Login Issue I have installed the IBM MQ version mqadv_dev901_linux_x86-64.tar.gz in my ubuntu system by following the link: https://hub.docker.com/r/ibmcom/mq/~/dockerfile/ which has MQSeriesWeb-9.0.1-0.x86_64.rpm also installed. I am able to open the UI but not able to Login into it. Checked the user id and password available in file at following location but unable to login:
/opt/mqm/web/mq/samp/configuration/basic_registry.xml.
Default Userid and password is admin and admin respectively.
Another userid and password is reader and reader also.
Please suggest how to proceed.

A: The user is "admin" but the password should be "passw0rd"

A: Follow the steps listed in the below link.That should help you.I tried on windows and it worked for me.The same should apply for linux as well
https://www.ibm.com/support/knowledgecenter/SSFKSJ_9.0.0/com.ibm.mq.adm.doc/q127580_.htm


text:
Q: How to access the control identifiers in pywinauto i am trying to access the control identifiers that gets displayed but i am unable to do so. when a Open window gets popped up only the OK and Cancel button i am able to access.. not able to acccess othe options. Please help

A: Once you have the dialog open and assigned to a variable then the print_control_identifiers() (also aliased as PrintControlIdentifiers) method should print all the available controls.
>>> app = Application.Start('Notepad')
>>> app.UntitledNotepad.MenuItem("Edit -> Replace").Select()
>>> app.Replace.print_control_identifiers()
Control Identifiers:
Static - 'Fi&nd what:'   (L1456, T336, R1528, B349)
        'Fi&nd what:' 'Fi&nd what:Static' 'Static' 'Static0' 'Static1'
Edit - ''   (L1531, T332, R1702, B352)
        'Edit' 'Edit0' 'Edit1' 'Fi&nd what:Edit'
Static - 'Re&place with:'   (L1456, T363, R1528, B376)
        'Re&place with:' 'Re&place with:Static' 'Static2'
Edit - ''   (L1531, T360, R1702, B380)
        'Edit2' 'Re&place with:Edit'
Button - 'Match &case'   (L1458, T422, R1547, B442)
        'CheckBox2' 'Match &case' 'Match &caseCheckBox'
Button - '&Find Next'   (L1711, T328, R1786, B351)
        '&Find Next' '&Find NextButton' 'Button' 'Button0' 'Button1'
Button - '&Replace'   (L1711, T355, R1786, B378)
        '&Replace' '&ReplaceButton' 'Button2'
Button - 'Replace &All'   (L1711, T383, R1786, B406)
        'Button3' 'Replace &All' 'Replace &AllButton'
Button - 'Cancel'   (L1711, T410, R1786, B433)
        'Button4' 'Cancel' 'CancelButton'
>>> app.Replace.PrintControlIdentifiers()
Control Identifiers:
Static - 'Fi&nd what:'   (L1456, T336, R1528, B349)
        'Fi&nd what:' 'Fi&nd what:Static' 'Static' 'Static0' 'Static1'
Edit - ''   (L1531, T332, R1702, B352)
        'Edit' 'Edit0' 'Edit1' 'Fi&nd what:Edit'
Static - 'Re&place with:'   (L1456, T363, R1528, B376)
        'Re&place with:' 'Re&place with:Static' 'Static2'
Edit - ''   (L1531, T360, R1702, B380)
        'Edit2' 'Re&place with:Edit'
Button - 'Match &case'   (L1458, T422, R1547, B442)
        'CheckBox2' 'Match &case' 'Match &caseCheckBox'
Button - '&Find Next'   (L1711, T328, R1786, B351)
        '&Find Next' '&Find NextButton' 'Button' 'Button0' 'Button1'
Button - '&Replace'   (L1711, T355, R1786, B378)
        '&Replace' '&ReplaceButton' 'Button2'
Button - 'Replace &All'   (L1711, T383, R1786, B406)
        'Button3' 'Replace &All' 'Replace &AllButton'
Button - 'Cancel'   (L1711, T410, R1786, B433)
        'Button4' 'Cancel' 'CancelButton'

The 2nd line output for each control are the different identifiers (though things like spaces and ampersands (&) should be removed.
It is quite possible that Windows Media Player does not use 'standard' Win32 dialogs. But the Open dialog should be easy enough..
Here is the output of my testing of this (with errors and mistakes removed to protect the guilty :))
>>> wmp = Application.Start(r'C:\Program Files (x86)\Windows Media Player\wmplayer.exe')
>>> wmp.WindowsMediaPlayer.TypeKeys("^O")
<pywinauto.controls.win32_controls.DialogWrapper object at 0x027CCDB0>
>>> wmp.Open.PrintControlIdentifiers()
Control Identifiers:
DUIViewWndClassName - ''   (L200, T187, R1152, B590)
        'DUIViewWndClassName' 'Files of &type:DUIViewWndClassName'
DirectUIHWND - ''   (L200, T187, R1152, B590)
        'DirectUIHWND' 'DirectUIHWND0' 'DirectUIHWND1' 'Files of &type:DirectUIHWND' 'Files of &type
:DirectUIHWND0' 'Files of &type:DirectUIHWND1'
CtrlNotifySink - ''   (L201, T217, R426, B590)
        'CtrlNotifySink' 'CtrlNotifySink0' 'CtrlNotifySink1' 'Files of &type:CtrlNotifySink' 'Files
of &type:CtrlNotifySink0' 'Files of &type:CtrlNotifySink1'
NamespaceTreeControl - 'Namespace Tree Control'   (L201, T217, R426, B590)
        'Namespace Tree Control' 'Namespace Tree Control0' 'Namespace Tree Control1' 'Namespace Tree
 ControlNamespaceTreeControl' 'NamespaceTreeControl'
SysTreeView32 - 'Tree View'   (L201, T217, R426, B590)
        'Tree View' 'Tree ViewTreeView' 'TreeView'
CtrlNotifySink - ''   (L429, T217, R1152, B590)
        'CtrlNotifySink3' 'Files of &type:CtrlNotifySink2'
SHELLDLL_DefView - 'ShellView'   (L429, T217, R1152, B590)
        'SHELLDLL_DefView' 'ShellView' 'ShellViewSHELLDLL_DefView'
DirectUIHWND - ''   (L429, T217, R1152, B590)
        'DirectUIHWND2' 'Files of &type:DirectUIHWND2'
Static - 'File &name:'   (L330, T603, R384, B618)
        'File &name:' 'File &name:Static' 'Static2'
ComboBoxEx32 - ''   (L389, T599, R935, B623)
        'ComboBoxEx' 'File &name:ComboBoxEx'
ComboBox - ''   (L389, T599, R935, B623)
        'ComboBox' 'ComboBox0' 'ComboBox1' 'File &name:ComboBox' 'File &name:ComboBox0' 'File &name:
ComboBox1'
Edit - ''   (L393, T604, R917, B619)
        'Edit' 'File &name:Edit'
Static - 'Files of &type:'   (L200, T152, R200, B152)
        'Files of &type:' 'Files of &type:Static' 'Files of &type:Static0' 'Files of &type:Static1'
'Static3'
ComboBox - 'Media files (all types)'   (L947, T599, R1135, B622)
        'ComboBox2' 'File &name:ComboBox2' 'Files of &type:ComboBox'
Button - '&Open'   (L947, T628, R1035, B654)
        '&Open' '&OpenButton' 'Button' 'Button0' 'Button1'
Button - 'Cancel'   (L1047, T628, R1135, B654)
        'Button2' 'Cancel' 'CancelButton'
ScrollBar - ''   (L1137, T651, R1152, B666)
        'CancelScrollBar' 'ScrollBar3'
WorkerW - ''   (L200, T152, R1152, B187)
        'Files of &type:WorkerW' 'WorkerW'
ReBarWindow32 - ''   (L200, T152, R1152, B187)
        'Files of &type:ReBar' 'ReBar'
TravelBand - ''   (L200, T152, R270, B184)
        'Files of &type:TravelBand' 'TravelBand'
ToolbarWindow32 - ''   (L202, T154, R270, B184)
        'Files of &type:Toolbar' 'Files of &type:Toolbar0' 'Files of &type:Toolbar1' 'Toolbar' 'Tool
bar0' 'Toolbar1'
Address Band Root - ''   (L270, T156, R944, B179)
        'Address Band Root' 'Files of &type:Address Band Root'
msctls_progress32 - ''   (L272, T157, R942, B178)
        'Files of &type:Progress' 'Progress'
Breadcrumb Parent - ''   (L272, T157, R898, B178)
        'Breadcrumb Parent' 'Files of &type:Breadcrumb Parent'
ToolbarWindow32 - 'Address: C:\\Program Files (x86)\\Windows Media Player'   (L272, T157, R898, B178
)
        'Address: C:\\Program Files (x86)\\Windows Media Player' 'Address: C:\\Program Files (x86)\\
Windows Media PlayerToolbar' 'Toolbar2'
ToolbarWindow32 - ''   (L898, T157, R942, B178)
        'Files of &type:Toolbar2' 'Toolbar3'
UniversalSearchBand - ''   (L948, T156, R1152, B179)
        'Files of &type:UniversalSearchBand' 'UniversalSearchBand'
Search Box - ''   (L948, T156, R1152, B179)
        'Files of &type:Search Box' 'Search Box'
SearchEditBoxWrapperClass - ''   (L953, T156, R1147, B179)
        'Files of &type:SearchEditBoxWrapperClass' 'SearchEditBoxWrapperClass'
DirectUIHWND - ''   (L953, T156, R1147, B179)
        'DirectUIHWND3' 'Files of &type:DirectUIHWND3'
>>>
>>> wmp.Open.FilenameEdit.TypeKeys(r"c:\your_file_name.mp3")
<pywinauto.controls.win32_controls.EditWrapper object at 0x027CCC50>
>>> wmp.Open.Open.Click()

You can see (hopefully) that the FilenameEdit came from
Edit - ''   (L393, T604, R917, B619)
        'Edit' 'File &name:Edit'

A: I get access to the "File Name" in the "Select File to Export"in 3ds max 2015:

I first received information about the dialog box controls with "print_control_identifiers()":
import pywinauto
from time import sleep

 pwa_app = pywinauto.application.Application()
    # pwa_app.start('{app} {path}\{scene}'.format(app=BINARY_PATH, path=TEST_PATH, scene=TEST_SCENE))
export_dlg_handles = pywinauto.findwindows.find_windows(title=u'Select File to Export', class_name='#32770')
if export_dlg_handles:
    export_dlg = pwa_app.window_(handle=export_dlg_handles[0])
export_dlg.print_control_identifiers()

The output:
Control Identifiers:
Static - 'Save &in:'   (L172, T146, R258, B159)
        'Save &in:' 'Save &in:Static' 'Static' 'Static0' 'Static1'
ComboBox - 'export'   (L265, T142, R526, B166)
        'ComboBox' 'ComboBox0' 'ComboBox1' 'Save &in:ComboBox'
ToolbarWindow32 - ''   (L538, T142, R800, B165)
        ' Toolbar' 'Toolbar' 'Toolbar0' 'Toolbar1'
ToolbarWindow32 - ''   (L172, T171, R259, B705)
        'Save &in:Toolbar' 'Toolbar2'
SHELLDLL_DefView - ''   (L265, T171, R857, B650)
        'SHELLDLL_DefView' 'Save &in:SHELLDLL_DefView'
SysListView32 - 'FolderView'   (L265, T171, R857, B650)
        'FolderView' 'FolderViewListView' 'ListView'
SysHeader32 - ''   (L265, T171, R857, B190)
        'Header' 'Save &in:Header'
Static - 'File &name:'   (L267, T664, R354, B677)
        'File &name:' 'File &name:Static' 'Static3'
ComboBoxEx32 - ''   (L361, T659, R762, B681)
        'ComboBoxEx' 'File &name:ComboBoxEx'
ComboBox - ''   (L361, T659, R762, B681)
        'ComboBox2' 'File &name:ComboBox'
Edit - ''   (L365, T664, R742, B677)
        'Edit' 'File &name:Edit'
Static - 'Save as &type:'   (L267, T690, R354, B703)
        'Save as &type:' 'Save as &type:Static' 'Static4'
ComboBox - 'Autodesk (*.FBX)'   (L361, T687, R762, B708)
        'ComboBox3' 'Save as &type:ComboBox'
Button - '&Save'   (L782, T659, R857, B682)
        '&Save' '&SaveButton' 'Button' 'Button0' 'Button1'
Button - 'Cancel'   (L782, T685, R857, B708)
        'Button2' 'Cancel' 'CancelButton'
ScrollBar - ''   (L848, T699, R865, B716)
        'CancelScrollBar' 'ScrollBar'
#32770 - ''   (L166, T102, R865, B716)
        '#32770' 'Save &in:#32770'
Static - ' '   (L166, T135, R721, B520)
        ' ' ' Static2' 'Static5'
Static - ''   (L715, T165, R715, B188)
        ' Static3' 'Static6'
Static - 'Thumbnail'   (L906, T144, R957, B157)
        'Static7' 'Thumbnail' 'ThumbnailStatic'
ComboBox - 'C:\\Users\\stas\\Documents\\3dsMax\\export'   (L265, T109, R857, B130)
        'ComboBox4' 'History:ComboBox'
Static - 'History:'   (L219, T113, R255, B126)
        'History:' 'History:Static' 'Static8'

Then i find a strings:
Edit - ''   (L365, T664, R742, B677)
        'Edit' 'File &name:Edit'
Button - '&Save'   (L782, T659, R857, B682)
        '&Save' '&SaveButton' 'Button' 'Button0' 'Button1'

'Edit' and 'Button' - names of controls for access.
And I run:
# Endter file name
export_dlg.Edit.SetText(SAVE_FILE_NAME)
# Wait one second
sleep(1.0)
# Click to "Save" button
export_dlg.Button.Click()

For help view the docs:
https://pywinauto.googlecode.com/hg/pywinauto/docs/controls_overview.html
For example  'SetText' for all controls:
SetText(text, pos_start=None, pos_end=None)
Set the text of the edit control


text:
Q: Label Product of a Graph with itself
Defn Let $\mathcal{G}=(\mathcal{V},\mathcal{E})$ and $\mathcal{G}' = (\mathcal{V}', \mathcal{E}')$ be two labeled graphs with alphabet $\mathcal{A}$. The labeled graph product $\mathcal{G} * \mathcal{G}'$ is defined as follows:

*

*The vertex set of $\mathcal{G} * \mathcal{G}'$ is the Cartesian product $\mathcal{V} \times \mathcal{V}'$.

*Given $(g, g')$ and $(h, h') \in \mathcal{V} \times \mathcal{V}'$ and $a \in \mathcal{A}$, there is a labeled edge $(g,g') \overset{a}{\longrightarrow} (h,h')$ if and only if there is an edge $g \overset{a}{\longrightarrow} h$ in $\mathcal{G}$ and an edge $g' \overset{a}{\longrightarrow} h'$ in $\mathcal{G}'$.

Given a labeled graph $\mathcal{G}$, I am trying to efficiently implement the labeled graph product $\mathcal{G}*\mathcal{G}$. If it helps, the graphs I'm concerned with will always have the following properties:

*

*$\mathcal{G}$ will be right-resolving (aka a Shannon graph), that is, all edges leaving a given vertex bear distinct labels.

*For each label $a \in \mathcal{A}$ and each vertex $v \in \mathcal{V}$, there is an edge leaving $v$ with label $a$, i.e., $v \overset{a}{\longrightarrow} \dots$.

For example, consider the graph
graph= {{1 -> 3, "a"}, {1 -> 5, "b"}, {2 -> 1, "a"}, {3 -> 2, "a"}, {3 -> 4, "b"}, {4 -> 1, "a"}, {5 -> 6, "a"}, {5 -> 4, "b"}, {6 -> 1,"a"}, {0 -> 0, "a"}, {0 -> 0, "b"}, {2 -> 0, "b"}, {4 -> 0,  "b"}, {6 -> 0, "b"}}

I have approached this problem by first defining a function that, given a vertex and a label, returns the target of the corresponding edge:
 leavingEdgeTarget[vertex_, edgeLabel_, graph_] := Select[Select[graph, #[[1, 1]] == vertex &], #[[2]] == edgeLabel &][[ 1, 1, 2]]

and then using the following function:
 labelProduct[graph_] := With[
  {vertexList = VertexList@Graph@graph[[All, 1]],
  alphabet = Union@graph[[All, 2]]},
    Flatten[#, 2] &@
     ParallelTable[{{v1,v2} ->
      {leavingEdgeTarget[v1, label,graph],
       leavingEdgeTarget[v2, label, graph]},
      label},
       {v1, vertexList},
       {v2, vertexList},
       {label, alphabet}
      ]
  ]

So for example, labelProduct[graph] returns the following graph with 49 vertices and 98 edges:
{{{1,1}->{3,3},"a"}, {{1,1}->{5,5}, "b"}, {{1,3}->{3,2},"a"},...,{{0,0}->{0,0},"b"}}

Q: How can I speed this up?
For small graphs, this runs reasonably fast (and seems to get a very nice speedup from the use of ParallelTable). However, it starts to take quite a while for larger graphs (100+ vertices). Consider the graph
SeedRandom[0];
n = 100;
randomGraph =
  Flatten[#, 1]&@
   Table[{i -> RandomInteger[{1, n}], label},
         {i, 1, n},
         {label, Range[3]}
        ];

On my machine (32GB memory, 8 logical cores @3.7GHz) I get the following values for labelProduct[randomGraph];//AbsoluteTiming different values of n:
  n   AbsoluteTiming
 10   0.022
 20   0.072
 50   0.600
100   4.418
150  14.524
200  34.193
250  66.879
500  529.8=8m49.8s

I can achieve a small timing benefit by only generating the edges $(i,j)\overset{a}{\longrightarrow}(i', j')$ with $i \leq j$ and then find the remaining edges in the label product by noting that there is also an edge $(j,i)\overset{a}{\longrightarrow}(j',i')$, but this only has a speedup by a factor of roughly $1/2$.

A: Why not just group vertices by their labels, and then use Tuples to generate the new vertices? For example:
grp = GroupBy[graph, Last -> First, Replace[Tuples[#,2], t_ :> Thread[t, Rule], {1}]&]

<|"a" -> {{1, 1} -> {3, 3}, {1, 2} -> {3, 1}, {1, 3} -> {3, 2}, {1, 4} -> {3,
       1}, {1, 5} -> {3, 6}, {1, 6} -> {3, 1}, {1, 0} -> {3, 0}, {2, 1} -> {1,
       3}, {2, 2} -> {1, 1}, {2, 3} -> {1, 2}, {2, 4} -> {1, 1}, {2, 5} -> {1,
       6}, {2, 6} -> {1, 1}, {2, 0} -> {1, 0}, {3, 1} -> {2, 3}, {3, 2} -> {2,
       1}, {3, 3} -> {2, 2}, {3, 4} -> {2, 1}, {3, 5} -> {2, 6}, {3, 6} -> {2,
       1}, {3, 0} -> {2, 0}, {4, 1} -> {1, 3}, {4, 2} -> {1, 1}, {4, 3} -> {1,
       2}, {4, 4} -> {1, 1}, {4, 5} -> {1, 6}, {4, 6} -> {1, 1}, {4, 0} -> {1,
       0}, {5, 1} -> {6, 3}, {5, 2} -> {6, 1}, {5, 3} -> {6, 2}, {5, 4} -> {6,
       1}, {5, 5} -> {6, 6}, {5, 6} -> {6, 1}, {5, 0} -> {6, 0}, {6, 1} -> {1,
       3}, {6, 2} -> {1, 1}, {6, 3} -> {1, 2}, {6, 4} -> {1, 1}, {6, 5} -> {1,
       6}, {6, 6} -> {1, 1}, {6, 0} -> {1, 0}, {0, 1} -> {0, 3}, {0, 2} -> {0,
       1}, {0, 3} -> {0, 2}, {0, 4} -> {0, 1}, {0, 5} -> {0, 6}, {0, 6} -> {0,
       1}, {0, 0} -> {0, 0}},
   "b" -> {{1, 1} -> {5, 5}, {1, 3} -> {5, 4}, {1, 5} -> {5, 4}, {1, 0} -> {5,
       0}, {1, 2} -> {5, 0}, {1, 4} -> {5, 0}, {1, 6} -> {5, 0}, {3, 1} -> {4,
       5}, {3, 3} -> {4, 4}, {3, 5} -> {4, 4}, {3, 0} -> {4, 0}, {3, 2} -> {4,
       0}, {3, 4} -> {4, 0}, {3, 6} -> {4, 0}, {5, 1} -> {4, 5}, {5, 3} -> {4,
       4}, {5, 5} -> {4, 4}, {5, 0} -> {4, 0}, {5, 2} -> {4, 0}, {5, 4} -> {4,
       0}, {5, 6} -> {4, 0}, {0, 1} -> {0, 5}, {0, 3} -> {0, 4}, {0, 5} -> {0,
       4}, {0, 0} -> {0, 0}, {0, 2} -> {0, 0}, {0, 4} -> {0, 0}, {0, 6} -> {0,
       0}, {2, 1} -> {0, 5}, {2, 3} -> {0, 4}, {2, 5} -> {0, 4}, {2, 0} -> {0,
       0}, {2, 2} -> {0, 0}, {2, 4} -> {0, 0}, {2, 6} -> {0, 0}, {4, 1} -> {0,
       5}, {4, 3} -> {0, 4}, {4, 5} -> {0, 4}, {4, 0} -> {0, 0}, {4, 2} -> {0,
       0}, {4, 4} -> {0, 0}, {4, 6} -> {0, 0}, {6, 1} -> {0, 5}, {6, 3} -> {0,
       4}, {6, 5} -> {0, 4}, {6, 0} -> {0, 0}, {6, 2} -> {0, 0}, {6, 4} -> {0,
       0}, {6, 6} -> {0, 0}}|>

Then, your desired edges can be obtained with:
gproduct = Catenate @ KeyValueMap[Function[{k, v}, Thread[{v,k}]]] @ grp

{{{1, 1} -> {3, 3}, "a"}, {{1, 2} -> {3, 1}, "a"}, {{1, 3} -> {3, 2},
    "a"}, {{1, 4} -> {3, 1}, "a"}, {{1, 5} -> {3, 6}, "a"}, {{1, 6} -> {3, 1},
    "a"}, {{1, 0} -> {3, 0}, "a"}, {{2, 1} -> {1, 3}, "a"}, {{2, 2} -> {1, 1},
    "a"}, {{2, 3} -> {1, 2}, "a"}, {{2, 4} -> {1, 1}, "a"}, {{2, 5} -> {1, 6},
    "a"}, {{2, 6} -> {1, 1}, "a"}, {{2, 0} -> {1, 0}, "a"}, {{3, 1} -> {2, 3},
    "a"}, {{3, 2} -> {2, 1}, "a"}, {{3, 3} -> {2, 2}, "a"}, {{3, 4} -> {2, 1},
    "a"}, {{3, 5} -> {2, 6}, "a"}, {{3, 6} -> {2, 1}, "a"}, {{3, 0} -> {2, 0},
    "a"}, {{4, 1} -> {1, 3}, "a"}, {{4, 2} -> {1, 1}, "a"}, {{4, 3} -> {1, 2},
    "a"}, {{4, 4} -> {1, 1}, "a"}, {{4, 5} -> {1, 6}, "a"}, {{4, 6} -> {1, 1},
    "a"}, {{4, 0} -> {1, 0}, "a"}, {{5, 1} -> {6, 3}, "a"}, {{5, 2} -> {6, 1},
    "a"}, {{5, 3} -> {6, 2}, "a"}, {{5, 4} -> {6, 1}, "a"}, {{5, 5} -> {6, 6},
    "a"}, {{5, 6} -> {6, 1}, "a"}, {{5, 0} -> {6, 0}, "a"}, {{6, 1} -> {1, 3},
    "a"}, {{6, 2} -> {1, 1}, "a"}, {{6, 3} -> {1, 2}, "a"}, {{6, 4} -> {1, 1},
    "a"}, {{6, 5} -> {1, 6}, "a"}, {{6, 6} -> {1, 1}, "a"}, {{6, 0} -> {1, 0},
    "a"}, {{0, 1} -> {0, 3}, "a"}, {{0, 2} -> {0, 1}, "a"}, {{0, 3} -> {0, 2},
    "a"}, {{0, 4} -> {0, 1}, "a"}, {{0, 5} -> {0, 6}, "a"}, {{0, 6} -> {0, 1},
    "a"}, {{0, 0} -> {0, 0}, "a"}, {{1, 1} -> {5, 5}, "b"}, {{1, 3} -> {5, 4},
    "b"}, {{1, 5} -> {5, 4}, "b"}, {{1, 0} -> {5, 0}, "b"}, {{1, 2} -> {5, 0},
    "b"}, {{1, 4} -> {5, 0}, "b"}, {{1, 6} -> {5, 0}, "b"}, {{3, 1} -> {4, 5},
    "b"}, {{3, 3} -> {4, 4}, "b"}, {{3, 5} -> {4, 4}, "b"}, {{3, 0} -> {4, 0},
    "b"}, {{3, 2} -> {4, 0}, "b"}, {{3, 4} -> {4, 0}, "b"}, {{3, 6} -> {4, 0},
    "b"}, {{5, 1} -> {4, 5}, "b"}, {{5, 3} -> {4, 4}, "b"}, {{5, 5} -> {4, 4},
    "b"}, {{5, 0} -> {4, 0}, "b"}, {{5, 2} -> {4, 0}, "b"}, {{5, 4} -> {4, 0},
    "b"}, {{5, 6} -> {4, 0}, "b"}, {{0, 1} -> {0, 5}, "b"}, {{0, 3} -> {0, 4},
    "b"}, {{0, 5} -> {0, 4}, "b"}, {{0, 0} -> {0, 0}, "b"}, {{0, 2} -> {0, 0},
    "b"}, {{0, 4} -> {0, 0}, "b"}, {{0, 6} -> {0, 0}, "b"}, {{2, 1} -> {0, 5},
    "b"}, {{2, 3} -> {0, 4}, "b"}, {{2, 5} -> {0, 4}, "b"}, {{2, 0} -> {0, 0},
    "b"}, {{2, 2} -> {0, 0}, "b"}, {{2, 4} -> {0, 0}, "b"}, {{2, 6} -> {0, 0},
    "b"}, {{4, 1} -> {0, 5}, "b"}, {{4, 3} -> {0, 4}, "b"}, {{4, 5} -> {0, 4},
    "b"}, {{4, 0} -> {0, 0}, "b"}, {{4, 2} -> {0, 0}, "b"}, {{4, 4} -> {0, 0},
    "b"}, {{4, 6} -> {0, 0}, "b"}, {{6, 1} -> {0, 5}, "b"}, {{6, 3} -> {0, 4},
    "b"}, {{6, 5} -> {0, 4}, "b"}, {{6, 0} -> {0, 0}, "b"}, {{6, 2} -> {0, 0},
    "b"}, {{6, 4} -> {0, 0}, "b"}, {{6, 6} -> {0, 0}, "b"}}

which is the same as your result up to ordering.

A: I am not 100% sure whether my thinking is correct. But let's see.
Let's start with two random labeled graphs.
SeedRandom[0];
n = 100;
G = Flatten[#, 1] &@ Table[{i -> RandomInteger[{1, n}], label}, {i, 1, n}, {label,Range[3]}];
H = Flatten[#, 1] &@ Table[{i -> RandomInteger[{1, n}], label}, {i, 1, n}, {label, Range[3]}];

Personally, I don't like lists of rules. I prefer packed arrays for their efficiency. Moreover, I'd like to have the labels in front for later use. So, let's reorder.
Gpat = Developer`ToPackedArray[Block[{Rule = Sequence}, G]][[All, {3, 1, 2}]];
Hpat = Developer`ToPackedArray[Block[{Rule = Sequence}, H]][[All, {3, 1, 2}]];

Now let's create some "adjacency matrices".
m = Max[Max[Gpat[[All, 1]]], Max[Hpat[[All, 1]]]];
Gn = Max[Gpat[[All, 2 ;;]]];
Hn = Max[Hpat[[All, 2 ;;]]];
GA = SparseArray[Gpat -> 1, {m, Gn, Gn}];
HA = SparseArray[Hpat -> 1, {m, Hn, Hn}];

More precisely, GA[[i]] is the adjacency matrix of the subgraph of G that consists precisely of those edges with label i. Same for HA[[i]]. In my understanding, the respective adjacency matrix HA[[i]] of the labeled product graph is essentially the Kronecker product of GA[[i]] with HA[[i]]. So, let's generate it, extract its "NonzeroPositions" (these correspond to labeled edges in the new graph) and reorder again in order to obtain a list with entries of the form {{i1,i2}->{j1,j2}, label}.
GHA = ArrayReshape[
 SparseArray@MapThread[KroneckerProduct, {GA, HA}],
 {m, Gn, Gn, Hn, Hn}
 ];
GHpat = GHA["NonzeroPositions"];
GH = Transpose[{Thread[GHpat[[All, 2 ;; 3]] -> GHpat[[All, 4 ;; 5]]],
GHpat[[All, 1]]}];

My Haswell Quad Core laptop performs this task in 0.0346 seconds. However, 0.0313 seconds (more than 90%!) are used just for transforming from and into the inefficient data format (list of rules). So, the actual computation needs less than 0.0033 seconds. For n = 500, the pure computation needs 0.113 seconds while the final transformation into GH takes 0.926 seconds.
As I said in the beginning, I am not sure whether this is correct. But you have already an implementation, so that checking it should be easier for you than for me.


text:
Q: JUnit 5 console launcher does not find tests inside JAR I have a shaded uber JAR containing test classes and all dependencies.  But the JUnit 5 console launcher fails to find any tests:
java -jar junit-platform-console-standalone.jar --scan-classpath=/path/to/test-suite-all.jar
╷
├─ JUnit Jupiter ✔
└─ JUnit Vintage ✔

Test run finished after 33 ms
[         2 containers found      ]
[         0 containers skipped    ]
[         2 containers started    ]
[         0 containers aborted    ]
[         2 containers successful ]
[         0 containers failed     ]
[         0 tests found           ]
[         0 tests skipped         ]
[         0 tests started         ]
[         0 tests aborted         ]
[         0 tests successful      ]
[         0 tests failed          ]

Test class names end in Test, matching the default --include-classname regex.
Should I expect this to work?  What am I doing wrong?
These attempts also fail in the same way:
java -jar junit-platform-console-standalone.jar --scan-classpath -cp=/path/to/test-suite-all.jar
java -cp junit-platform-console-standalone.jar:/path/to/test-suite-all.jar org.junit.platform.console.ConsoleLauncher --scan-classpath

Update
Minimal example repository, run with ./gradlew junitConsoleLauncher.  This repo now works correctly thanks to johanneslink's suggestions.

A: After cloning your repo and adding a repo to the build file, the following worked for me:
gradle wrapper
./gradlew shadowJar
java -cp ./build/libs/junit-console-launcher-shaded-jar-all.jar org.junit.platform.console.ConsoleLauncher --scan-classpath ./build/libs/junit-console-launcher-shaded-jar-all.jar

Output:
╷
└─ JUnit Jupiter ✔
   └─ ExampleTest ✔
      └─ test() ✔

Test run finished after 50 ms
[         2 containers found      ]
[         0 containers skipped    ]
[         2 containers started    ]
[         0 containers aborted    ]
[         2 containers successful ]
[         0 containers failed     ]
[         1 tests found           ]
[         0 tests skipped         ]
[         1 tests started         ]
[         0 tests aborted         ]
[         1 tests successful      ]
[         0 tests failed          ]

Using -jar option does not work, probably because the manifest is not correctly set in the shadow jar.


text:
Q: How to add color picker to widgets? I have some problems adding the wpColorPicker to a Widget. Does anyone have a working sample? It only works when I click on 'Save' or reload the page, but when I drag a new widget to the area it will not activate. Anyone any ideas? Below you can find my code so far.
class SampleWidget extends WP_Widget
    {

        /**
         * Register widget with WordPress.
         */
        public function __construct ()
        {
            parent::__construct
            (
                'sample_widget',
                'Sample',
                array( 'description' => __( 'A sample description'), )
            );

            add_action( 'admin_enqueue_scripts', array( &$this, 'admin_enqueue_scripts' ) );
        }

        public function admin_enqueue_scripts ( $hook_suffix )
        {
            if ( $hook_suffix != 'widgets.php' ) return;

            wp_enqueue_style( 'wp-color-picker' );
            wp_enqueue_script( 'wp-color-picker' );
        }

        /**
         * Front-end display of widget.
         *
         * @see WP_Widget::widget()
         *
         * @param array $args     Widget arguments.
         * @param array $instance Saved values from database.
         */
        public function widget( $args, $instance )
        {
            extract( $args );

            echo $before_widget;
            echo $after_widget;
        }

        /**
         * Sanitize widget form values as they are saved.
         *
         * @see WP_Widget::update()
         *
         * @param array $new_instance Values just sent to be saved.
         * @param array $old_instance Previously saved values from database.
         *
         * @return array Updated safe values to be saved.
         */
        public function update( $new_instance, $old_instance )
        {
            $instance = array();
            return $instance;
        }

        /**
         * Back-end widget form.
         *
         * @see WP_Widget::form()
         *
         * @param array $instance Previously saved values from database.
         */
        public function form ( $instance )
        {
            ?>
            <p>
                <label for="<?php echo $this->get_field_id( 'background-color' ); ?>">Achtergrondkleur:</label>
                <input type="text" id="<?php echo $this->get_field_id( 'background-color' ); ?>" name="<?php echo $this->get_field_name( 'background-color' ); ?>" value="<?php echo esc_attr( $backgroundColor ); ?>" />
            </p>

            <script type="text/javascript">
            jQuery(document).ready(function($){
                $('#<?php echo $this->get_field_id( 'background-color' ); ?>').wpColorPicker();
            });
            </script>
            <?php
        }
    }

A: Here is the code I used for one of my projects:
<?php
function load_color_picker_style() {
    wp_enqueue_style( 'wp-color-picker' );
}
    add_action('admin_print_scripts-widgets.php', 'load_color_picker_script');
    add_action('admin_print_styles-widgets.php', 'load_color_picker_style');
?>

///Javascript

jQuery(document).ready(function($){
    function updateColorPickers(){
        $('#widgets-right .wp-color-picker').each(function(){
            $(this).wpColorPicker({
                // you can declare a default color here,
                // or in the data-default-color attribute on the input
                defaultColor: false,
                // a callback to fire whenever the color changes to a valid color
                change: function(event, ui){},
                // a callback to fire when the input is emptied or an invalid color
                clear: function() {},
                // hide the color picker controls on load
                hide: true,
                // show a group of common colors beneath the square
                // or, supply an array of colors to customize further
                palettes: ['#ffffff','#000000','#ff7c0b']
            });
        });
    }
    updateColorPickers();
    $(document).ajaxSuccess(function(e, xhr, settings) {

        if(settings.data.search('action=save-widget') != -1 ) {
            $('.color-field .wp-picker-container').remove();
            updateColorPickers();
        }
    });
 });

The only requirement is that the input you want to be a colorpicker has to have the class name of, well, color-picker.

A: I think what you really want to be doing is binding to the "sortstop" event which is triggered after a widget is dropped into a droppable sidebar area.
jQuery('div.widgets-sortables').bind('sortstop', function(event,ui) {
    // This javascript code within here will be run after you've dropped a sidebar widget
});

This hasn't been tested, but I reckon is probably the right avenue to pursue.


text:
Q: Scipy erfcinv unexpectedly blows up near 1e-16 I've been using scipy.special.erfcinv to calculate Z scores from pvalues. However, when the pvalues become very small, erfcinv gets unexpectedly large. Any ideas?
Example:
In [1]: import numpy as np
In [2]: from scipy.special import erfcinv
In [3]: erfcinv(2e-16) * np.sqrt(2)
Out[3]: 8.2095361516013874
In [4]: erfcinv(1e-16) * np.sqrt(2)
Out[4]: 1.7976931348623155e+308

I'm running python 2.6.6 with scipy 0.10.1.

A: Short answer: the closer you get to the limits of floating point arithmetic precision the weirder things happens: (http://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html, http://www.seas.ucla.edu/~vandenbe/103/lectures/flpt.pdf)
A little bit longer. First lets look at erfcinv function:
def erfcinv(y):
    return ndtri((2-y)/2.0)/sqrt(2)

If we take y = 2e-16:
In [96]: (2 - 2e-16) / 2
Out[96]: 0.9999999999999999

When we take y = 1e-16:
In [97]: (2 - 1e-16) / 2
Out[97]: 1.0

Now we look at ndtri:
x=ndtri(y) returns the argument x for which the area udnder the
Gaussian probability density function (integrated from minus infinity
to x) is equal to y.

Now everything should be clear, am I right? As you can suspect:
In [99]: ndtri(1)
Out[99]: inf

Your results can be a little bit different - in my case:
In [101]: erfcinv(1e-16) * np.sqrt(2)
Out[101]: inf

A: If you want to calculate quantiles or p-values, the you could use the stats.distributions which find in most cases the most appropriate special function, in this case I always use stats.norm.isf for the upper tail pvalue (also because I don't want to remember what erf or erfcinv is).
>>> for y in 10.**(-np.arange(5, 30, 2)):
    print y, special.erfcinv(y) * np.sqrt(2), stats.norm.isf(y/2.), -special.ndtri(y/2)

1e-05 4.41717341347 4.41717341347 4.41717341347
1e-07 5.32672388628 5.32672388638 5.32672388638
1e-09 6.10941019166 6.10941020487 6.10941020487
1e-11 6.80650247883 6.80650249074 6.80650249074
1e-13 7.4410077655 7.44090215064 7.44090215064
1e-15 8.01401594878 8.02685888253 8.02685888253
1e-17 inf 8.57394407672 8.57394407672
1e-19 inf 9.08895010083 9.08895010083
1e-21 inf 9.57690145543 9.57690145543
1e-23 inf 10.0416376122 10.0416376122
1e-25 inf 10.4861701796 10.4861701796
1e-27 inf 10.9129127092 10.9129127092
1e-29 inf 11.3238345582 11.3238345582

The floating point problems pointed out by zero323 will still show up in many other cases.


text:
Q: How to discard overlapping rectangles in an image? I used the openCV library to detect an object of the image (Fig 1), see below.
To do this, I have written the following codes:
import matplotlib.pyplot as plt
import cv2

# source data
img_file= "Fig1.jpg"

# create an OpenCV image
img= cv2.imread(img_file)

# convert color image to grey image
gray_img=cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)

im_gauss = cv2.GaussianBlur(gray_img, (5, 5), 0)
ret, thresh = cv2.threshold(im_gauss, 127, 255, 0)
# get contours
contours, hierarchy = cv2.findContours(thresh, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)

margin = 40
# calculate area and filter
for con in contours:
    area = cv2.contourArea(con)
    if 100 < area < 500:
        x,y,w,h = cv2.boundingRect(con)
        cv2.rectangle(img, (x-margin, y-margin), (x + w+margin, y + h+margin), (0,255,0), 2)

plt.imshow(img, cmap='gray')

These codes will able to give you an image with the detected object see below figure .
Now here you can see, while detecting objects, some rectangles are overlapping. This is not the expected outcome. I want a Figure which discards all overlap rectangles and comes with another figure that includes only those rectangle which is not overlapping. Any idea how to do this? Thanks in advance.

A: Assuming you have x, y, width, and height for each rectangle, you'll need pairwise comparisons for each two rectangles, checking for overlaps by comparing if

*

*x of rectangle #1 is between x and x + width of rectangle #2, or

*y of rectangle #1 is between y and y + height of rectangle #2, or

*...

Fortunately, you can use NumPy's vectorization abilities to avoid nested loops.
In the following code, I generate some random rectangles, and filter out those overlapping:
import cv2
import numpy as np

# Randomly generate n white rectangles on black background
n = 20
rects = [[np.random.randint(0, 350),
          np.random.randint(0, 250),
          np.random.randint(10, 50),
          np.random.randint(10, 50)] for i in range(n)]

img = np.zeros((300, 400), np.uint8)

for rect in rects:
    img = cv2.rectangle(img, (rect[0], rect[1]),
                        (rect[0] + rect[2], rect[1] + rect[3]), 255, 1)

# Calculate left, right, top, bottom limits
rects = np.array(rects)
left = np.expand_dims(rects[:, 0], axis=1)
right = np.expand_dims(rects[:, 0] + rects[:, 2], axis=1)
top = np.expand_dims(rects[:, 1], axis=1)
bottom = np.expand_dims(rects[:, 1] + rects[:, 3], axis=1)

# Check for left limit intrusions, right limit intrusions, ...
check_l = (left <= left.T) & (left.T <= right)
check_r = (left <= right.T) & (right.T <= right)
check_t = (top <= top.T) & (top.T <= bottom)
check_b = (top <= bottom.T) & (bottom.T <= bottom)

# Check for combinations of left-top intrusions, left-bottom intrusions, ...
check_lt = check_l & check_t
check_lb = check_l & check_b
check_rt = check_r & check_t
check_rb = check_r & check_b

# Get all combinations; get rid of self identical matches
check = check_lt | check_lb | check_rt | check_rb
check = np.bitwise_xor(check, np.eye(n).astype(bool))
check = np.argwhere(check)

# Get unique indices of corrupted rectangles
corrupted = np.unique(check)

# Draw cleaned image
img_clean = np.zeros_like(img)
for i, rect in enumerate(rects):
    if i not in corrupted:
        img_clean = cv2.rectangle(img_clean, (rect[0], rect[1]),
                                  (rect[0] + rect[2], rect[1] + rect[3]), 255, 1)

# Output
cv2.imshow('Original image', img)
cv2.imshow('Cleaned image', img_clean)
cv2.waitKey(0)
cv2.destroyAllWindows()

First, let's have a look at the "input" and "output":

Basically, the left, right, top, and bottom limit of each rectangle is computed. Then, each combination of rectangle #1 "intrudes" into rectangle #2 from the left, or from the top, or from the right, and so on, is calculated.
Several bool matrices of size (n, n), with n is the number of rectangles,
are stored intermediately, but I guess, for n <= 2000 or so, the memory consumption should be negligible. Due to the vectorization, this approach is quite fast.
----------------------------------------
System information
----------------------------------------
Platform:      Windows-10-10.0.16299-SP0
Python:        3.9.1
NumPy:         1.20.2
OpenCV:        4.5.1
----------------------------------------


text:
Q: Are the tense and syntax in this sentence correct?
Possible Duplicate:
Future tense usage: "When you see it …"

When he will arrive, he will call you.

Please let me know if the tense and syntax in this sentence are correct. If not, then why not?

A: The fragment "when he will arrive" does not carry the proper tense in this case. Proper alternatives would be:

When he arrives, he will call you.

or, better yet:

He will call you when he arrives.

The original sentence does not work because of mixed tense. "He will call you" is a statement of fact, and the word will indicates that the call is going to happen at some time in the future. "He will call you" has future tense. To specify the time at which the call is going to take place, you would say: "He will call you [at 4:00]" or "He will call you [tomorrow]". I used this same construction to come up with my sentence #2: "He will call you [when he arrives]". "When he arrives" indicates an exact time. Sentence #1 is a simple re-ordering of the two phrases in sentence #2. The two sentences have the same meaning.

A: When he arrives, he will call you is the correct form, as e.James says.  It may seem like this is wrong because arrives is present tense while will call is future tense (instead of seemingly agreeing, as in your question).  But English uses this pattern for future conditionals, as this structure is called.  The conditional part (after the when) is given in the present tense, while the resulting phrase is in the future tense.  This page has a good explanation of this form.


text:
Q: Remove items from xml with specific date through linq to xml in C# I have xml file that looks like this..
<RecentInformation>
  <User Id="99">
    <Customers>
      <Customer>
        <CustomerId>7</CustomerId>
        <Date>1/20/2010</Date>
      </Customer>
      <Customer>
        <CustomerId>67</CustomerId>
        <Date>1/20/2010</Date>
      </Customer>
    </Customers>
    <Suppliers>
      <Supplier>
        <SupplierId>11619</SupplierId>
        <Date>1/20/2010</Date>
      </Supplier>
      <Supplier>
        <SupplierId>16274</SupplierId>
        <Date>1/20/2011</Date>
      </Supplier>
    </Suppliers>
    <Enquiries>
      <Enquiry>
        <EnquiryId>136202</EnquiryId>
        <Date>1/20/2010</Date>
      </Enquiry>
      <Enquiry>
        <EnquiryId>134507</EnquiryId>
        <Date>1/20/2011</Date>
      </Enquiry>
    </Enquiries>
    <Quotes>
      <Quote>
        <QuoteId>34008</QuoteId>
        <Date>1/20/2010</Date>
      </Quote>
      <Quote>
        <QuoteId>37356</QuoteId>
        <Date>1/20/2011</Date>
      </Quote>
    </Quotes>
    <Bookings>
      <Booking>
        <BookingId>3070</BookingId>
        <Date>1/20/2011</Date>
      </Booking>
      <Booking>
        <BookingId>3251</BookingId>
        <Date>1/20/2011</Date>
      </Booking>
    </Bookings>
  </User>
</RecentInformation>

I want to remove all the nodes that should be less then say 15 days old.
I am using this code but it is not working for me..
xdoc.Descendants("User").Descendants().Descendants().Where(x => DateTime.Parse(x.Element("Date").Value) < date)
                            .Remove();

any idea??

A: This is your line fixed
xdoc.Descendants("Date").Where(x => DateTime.Parse(x.Value) < date).Select(x=>x.Parent).Remove();


text:
Q: What hypothesis are needed to support the following argument on a three phase system? Given the following three-phase system:

simulate this circuit – Schematic created using CircuitLab
Suppose to set 2 wattmeters as follows:

*

*\$P_{21}\$ which measures current \$I_2\$ and voltage \$V_{21}\$

*\$P_{23}\$ which measures current \$I_2\$ and voltage \$V_{23}\$

Show that
$$P_{21} + P_{23} = 3 P_2 = 3V_{20}*I_2$$ holds true.
Here is the proof with the necessary assumptions:
$$V_{21}*I_2+V_{23}*I_2 = (V_{20}-V_{10})*I_2 + (V_{20} - V_{30})*I_2
= 2V_{20}*I_2 -(V_{10}+V_{30})*I_2$$
Now, assuming that $$V_{10}+V_{20}+V_{30} = 0$$ (from here named assumption 1)
The above equation yelds $$P_{21} + P_{23} = 3V_{20}*I_2 = 3P_2 $$
My question is: what assumptions on the three phase system should hold true in order for the above assumption 1 and, consequently, the proof, to be true? For instance, should it be symmetrical? Should it be balanced? Or both?
My reasoning is that since assumption 1 should hold true, the system should be symmetrical since the vector sum of phase voltages in a symmetrical system is always equal to zero (check the triangle of voltages below where in my case N=o and E1 = V10 and so on...)

I guess the real question boils down to this: since the o point is the centroid of the triangle of line voltage phasors, and the phase voltages is a half median, is there a property of a generic triangle that states that the sum of half of each median (the half closer to the median's angle) is always zero for each triangle?
I hope I made my question clear. If not please let me know in the comments, I'll try to explain better.
Note 1: * is used to express the dot product.
Note 2: All the voltages and currents are phasors.

A: I found the answer! Since for a generic triangle it can be shown that the sum of E1, E2 and E3 is equal to zero (check here for the proof), assumption 1 is always true and therefore no assumptions are needed on the three phase system in order for the above proof to hold true.


text:
Q: Why are some columns truncated in my table output? I have a latex table generated, it has 12 columns, but it is displaying only 11 columns...why is it so? Is there any mistake I am doing? Should I work something with the font size because I have another table with 12 columns but its displaying only 8 cols..it has more cell contents than this...
\documentclass{article}\begin{document}

\begin{table}[ht]
\begin{center}
\begin{tabular}{rrrrrrrrrrrrr}
\hline
& 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 11 & 12 \\
\hline
1 & 186.30 & 101.52 & 128.33 & 148.02 & 132.08 & 138.63 & 107.98 & 133.09 & 134.12 & 119.23 & 133.21 & 165.73 \\
2 & 104.03 & 184.67 & 184.07 & 169.27 & 117.85 & 107.67 & 169.89 & 111.93 & 185.41 &  134.30 & 198.12 & 120.83 \\
3 & 170.20 & 189.47 & 142.98 & 106.06 & 116.85 & 120.74 & 100.51 & 195.18 & 196.31 & 189.16 & 180.00 & 191.78 \\
4 & 176.23 & 187.77 & 127.99 & 194.66 & 135.87 & 152.42 & 137.35 & 109.88 & 162.07 & 171.81 & 136.07 & 122.29 \\
\hline
\end{tabular}
\end{center}
\end{table}
\end{document}

A: As frabjous said in his comment, you may "[e]ither shrink the font, rotate the table, or rearrange the data some other way so it fits". Shrinking the font seems to be out of the question for your example table, as even a switch to \tiny is not sufficient to fit it into the page margins. For rotating, use the rotating package and its sidewaystable environment. (And use \centering instead of \begin{center} ... \end{center} -- here's why.)
\documentclass{article}

\usepackage{rotating}

\begin{document}

\begin{sidewaystable}
\centering
\begin{tabular}{*{13}{r}}
\hline
& 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 11 & 12 \\
\hline
1 & 186.30 & 101.52 & 128.33 & 148.02 & 132.08 & 138.63 & 107.98 & 133.09 & 134.12 & 119.23 & 133.21 & 165.73 \\
2 & 104.03 & 184.67 & 184.07 & 169.27 & 117.85 & 107.67 & 169.89 & 111.93 & 185.41 &  134.30 & 198.12 & 120.83 \\
3 & 170.20 & 189.47 & 142.98 & 106.06 & 116.85 & 120.74 & 100.51 & 195.18 & 196.31 & 189.16 & 180.00 & 191.78 \\
4 & 176.23 & 187.77 & 127.99 & 194.66 & 135.87 & 152.42 & 137.35 & 109.88 & 162.07 & 171.81 & 136.07 & 122.29 \\
\hline
\end{tabular}
\end{sidewaystable}

\end{document}

A: Here are some more suggestions to make the tabular fit within your margins:

You could resize the entire table using the graphicx package command \resizebox{<h-len>}{<v-len>}{<stuff>} in the following way:
\usepackage{graphicx}% http://ctan.org/pkg/graphicx
\resizebox{\linewidth}{!}{%
  \begin{tabular}{*{13}{r}}
  ...
  \end{tabular}%
}

The <h-len>=\linewidth will stretch/shrink the entire table to width \linewidth, while <v-len>=! keeps the aspect ratio in tact.

Modify the inter-column spacing either manually via
\begin{tabular}{*{13}{@{\hspace{<len>}}r@{\hspace{<len>}}}}% Inter-column spacing of <len>

or via setting lengths like \tabcolsep or \extracolsep. See the fixed-width table entry on the TeX FAQ for more details.
There are plenty more, of course. But all depend on your preference and eventual document use.


text:
Q: Memory issue when importing parquet files in Spark I am trying to query data from parquet files in Scala Spark (1.5), including a query of 2 million rows ("variants" in the following code).
val sqlContext = new org.apache.spark.sql.SQLContext(sc)
sqlContext.sql("SET spark.sql.parquet.binaryAsString=true")

val parquetFile = sqlContext.read.parquet(<path>)

parquetFile.registerTempTable("tmpTable")
sqlContext.cacheTable("tmpTable")

val patients = sqlContext.sql("SELECT DISTINCT patient FROM tmpTable ...)

val variants = sqlContext.sql("SELECT DISTINCT ... FROM tmpTable ... )

This runs fine when the number of rows fetched is low, but fails with a "Size exceeds Integer.MAX_VALUE" error when lots of data is requested.
The error looks as follows:
User class threw exception: org.apache.spark.SparkException:
Job aborted due to stage failure: Task 43 in stage 1.0 failed 4 times,
most recent failure: Lost task 43.3 in stage 1.0 (TID 123, node009):
java.lang.RuntimeException: java.lang.IllegalArgumentException:
Size exceeds Integer.MAX_VALUE at
sun.nio.ch.FileChannelImpl.map(FileChannelImpl.java:828) at
org.apache.spark.storage.DiskStore$$anonfun$getBytes$2.apply(DiskStore.scala:125) at
org.apache.spark.storage.DiskStore$$anonfun$getBytes$2.apply(DiskStore.scala:113) at ...

What can I do to make this work?
This looks like a memory issue, but I have tried using up to 100 executors with no difference (the time it takes to fail stays the same no matter the number of executors involved, too). It feels like the data isn't getting partitioned across the nodes?
I have attempted to force higher parallelization by naively replacing this line, to no avail:
val variants = sqlContext.sql("SELECT DISTINCT ... FROM tmpTable ... ).repartition(sc.defaultParallelism*10)

A: I don't believe the issue is parquet specific. You are "hitting" a limitation on the maximum size of a partition in Spark.

Size exceeds Integer.MAX_VALUE at
  sun.nio.ch.FileChannelImpl.map(FileChannelImpl.java:828) at ...

The Integer.MAX_VALUE detected that you have a size of (I believe) a partition that is more than 2GB (requires more than an int32 to index it).
The comment from Joe Widen is spot on. You need to repartition your data even more. Try 1000 or more.
E.g.,
val data = sqlContext.read.parquet("data.parquet").rdd.repartition(1000).toDF


text:
Q: Android Studio 3.0.1( Error:The 'java' plugin has been applied, but it is not compatible with the Android plugins.) I recently updated my android studio to 3.0.1 release and i have been having trouble with my gradle app compiling.
I am having this error while trying to build my gradle on android studio 3.0.1 Error:The 'java' plugin has been applied, but it is not compatible with the Android plugins.
I have updated my Java Development kit to the latest realese
please help me out am a newbie. Below is my build script. I have updated my Java Development kit to the latest realese
 apply plugin: 'com.android.application'
 apply plugin: 'kotlin'

buildscript {
repositories {
    google() // Gradle 4.0+////////
    maven { url "https://maven.google.com" } // Gradle < 4.0
}

dependencies {
    classpath "com.android.tools.build:gradle:3.0.1"
}
}
android {
compileSdkVersion 26
defaultConfig {
    applicationId "com.example.android.happybirthday"
    minSdkVersion 16
    targetSdkVersion 26
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
 }
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
     }
  }
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.0.0-beta1'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:0.5'
androidTestImplementation 'com.android.support.test.espresso:espresso-
core:2.2.2'
compile "org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlin_version"
}
buildscript {
ext.kotlin_version = '1.2.0'
repositories {
    mavenCentral()
}
dependencies {
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
repositories {
mavenCentral()
}
compileKotlin {
kotlinOptions {
    jvmTarget = "1.8"
}
}
compileTestKotlin {
kotlinOptions {
    jvmTarget = "1.8"
}
}

A: Try with this build scripts:
//Your root Gradle file
buildscript {
    ext.kotlin_version = '1.2.21'
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

// Your application Gradle file
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

    android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.example.android.happybirthday"
        minSdkVersion 16
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
     }

    buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }

        testOptions {
            unitTests.returnDefaultValues = true
        }

        compileKotlin {
            sourceCompatibility = JavaVersion.VERSION_1_8
            targetCompatibility = JavaVersion.VERSION_1_8

            kotlinOptions {
                jvmTarget = "1.8"
                apiVersion = "1.2"
                languageVersion = "1.2"
            }
        }
    }
    }

    dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:26.0.0-beta1'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:0.5'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:2.2.2'
    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
    implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
    }


text:
Q: Remote machine node unable to connect to hub on Selenium Webdriver using Ruby I have been trying to register a node to the hub, but I am getting "couldn't register this node : Hub is down or not responding".
But I already started the hub. I can see hub started from
<http://localhost:4444/grid/console>

C:\Ruby200>java -jar selenium-server-standalone-2.43.1.jar -role hub -port 4444
10:45:37.304 INFO - Launching a selenium grid server
2014-10-24 10:45:38.324:INFO:osjs.Server:jetty-7.x.y-SNAPSHOT
2014-10-24 10:45:38.363:INFO:osjsh.ContextHandler:started o.s.j.s.ServletContext
Handler{/,null}
2014-10-24 10:45:38.375:INFO:osjs.AbstractConnector:Started SocketConnector@0.0.
0.0:4444

On the node (which is a remote machine which I am accessing from remote desktop connection), I tried the following:
c:\Ruby201>java -jar selenium-server-standalone-2.43.1.jar -role node -hub http://<ip address ofhub>:4444/grid/register

I tried different methods (after searching on google and this website) but all of them giving same error..coulnd't connect to the hub
I tried :
java -jar selenium-server-standalone-2.43.1.jar -role node -port 5555 -hub http://<ip of hub>:4444/grid/register -browser browserName=chrome,platform=WINDOWS

java -jar selenium-server-standalone-2.43.1.jar -role node -port 5555 -hub http://<ip of hub>:4444/grid/register -browser browserName=chrome,platform=WINDOWS -hubHost "ip address of hub"

If my node is on same machine as hub, then it is working. But not if node is on remote machine.  Should I be checking for something else like firewalls on node or hub or anything else?
Any help is greatly appreciated.

A: I was able to figure it out after few more searches:
Started the hub (on local machine):
java -jar selenium-server-standalone-2.43.1.jar  -role hub
Started the node (on remote machine):
java -jar selenium-server-standalone-2.43.1.jar -role node -hub http://ipofhub:4444/grid/register -Dwebdriver.chrome.driver="C:\Ruby21\bin\chromedriver.exe"
I had to specify the path of chromedriver while starting the server. I defined in the PATH on remote machine, but only the above method worked.
I have the following code in the test script that I executed from local machine:
caps = Selenium::WebDriver::Remote::Capabilities.chrome
@driver = Selenium::WebDriver.for(:remote, :url => "<http://localhost:4444/wd/hub>",:desired_capabilities => caps)


text:
Q: How to insert data larger than maximum capacity of specific column without changing its datatype in Oracle 11g I have large data (more than 4000 characters) and I have a column of type VARCHAR2(4000) in Oracle 11g.
Is there any way to insert that data in this column without changing its data type?

A: If you are referring to a variable defined in a PL/SQL package, function, or procedure, then the maximum length of a VARCHAR2 variable is 32k. If the value must be persisted then you have to decide if you want to keep the data contiguous. If you do, then you must change the column's datatype to CLOB. If it does not need to be contiguous, then simply create a child relation to store the pieces.

A: No, your data will get truncated, if it is more than the value you specified in the data type. The best way you can resolve this issue is by changing varchar2(4000) to varchar2(max) . MAX will allow you to insert data upto 32000 characters.


text:
Q: AWK automatically rounds off numbers during multiplication I try to execute the exercise

f) For the input file table.txt, calculate and display the product of
numbers in the last field of each line. Consider space as the field
separator for this file.

from https://learnbyexample.github.io/learn_gnuawk/awk-introduction.html#exercises. My solution is the following:
awk 'BEGIN{prod=1} {prod *= $NF} END{print prod}' table.txt

but when I run it, I get -882 instead of -923.16.
The full output is the following:
andrii@andrii-VirtualBox:~/git/learn_gnuawk/exercises$ cat table.txt
brown bread mat hair 42
blue cake mug shirt -7
yellow banana window shoes 3.14
andrii@andrii-VirtualBox:~/git/learn_gnuawk/exercises$ awk 'BEGIN{prod=1} {prod *= $NF} END{print prod}' table.txt
-882

It seems, the number 3.14 is automatically rounded off to 3. I can't understand, why does this happen. Moreover, my solution is almost identical to the solution from the author(s) of the exercise (https://learnbyexample.github.io/learn_gnuawk/Exercise_solutions.html) and it also outputs -882 on my PC. I use Kubuntu 20.04.
UPD. I found out that the problem is with mawk which is used in my system by default, while gawk returns the correct result.

A: Changing the locale for numbers to en_US in settings solved the problem for me for both gawk and mawk.


text:
Q: How to convert this small PHP code to Python I have the following PHP function:
function x($t, $k) {
    $c = strlen($k);
    $l = strlen($t);
    $o = "";
    for ($i = 0; $i < $l;) {
        for ($j = 0; ($j < $c && $i < $l); $j++, $i++) {
              $o.=$t{$i}^$k{$j};
            }
    }
    return $o;
}

I need it on Python 3, the second loop is one I am stuck at:
def x(t, k):
    c = len(k)
    l = len(t)
    o = ""
    for i in range(0, l):
        # ??

A: you can try this:
from operator import xor

def x(t, k):
    c = len(k)
    l = len(t)
    o = ''

    for i in range(l):
        j=0
        while((j<c) and  (i<l)):
            #If you really want to do XOR operation
            o += '1' if xor(bool(t[i]), bool(k[j])) else '0'
            j+=1
            i+=1

    return o


text:
Q: Adding literals to json from PHP I'm using a PHP Controller to format an options array for jqPlot on the front end.
Essentially, it takes the data from the database via a model, and formats it into a way jqPlot can understand, then passes it to the view.
I have a bit of a conundrum whereby some fields are required to be literals rather than strings.
Example, from my controller:
$formatted['seriesDefaults'] = array(
    'renderer' => "$j.jqplot.BarRenderer",
     'rendererOptions' => array(
         'fillToZero' => true
     )
 );

This is then run through json_encode to get the JSON output.
The command $j.jqplot.BarRenderer is a jQuery instruction which needs to be rendered on the front end without quotes.
The JSON is rendered like this:
{
    "seriesDefaults":{
        "renderer":"$j.jqplot.BarRenderer",
        "rendererOptions"
            ...
    }
}

Ideally, to be interpreted correctly by jQuery in the view, it needs to be like this:
{
    "seriesDefaults":{
        "renderer": $j.jqplot.BarRenderer,
        "rendererOptions"
            ...
    }
}

Is there a way I could achieve this without adjusting my methodology?

A: Essentially what you're asking for is to not just pass data between two different systems (PHP and JS), but in fact to dynamically produce source code of one language (JS) in another. Yes, trying to pass one "literal" crosses over that line. And it's not a good idea IMO. Data is independent of its context, it can be evaluated as needed. Source code only works in a specific context (e.g. you have to include the jqplot library before this code, or it will break). Wanting to produce and pass source code instead of data makes your code less flexible and more brittle. Not to mention that it just makes it more difficult to produce, since json_encode explicitly does not allow anything but pure data.
I'd suggest simply post-processing your data in JavaScript a bit:
var data = <?php echo json_encode(['renderer' => 'bar', ...]); ?>;

var renderers = {
    bar : $j.jqplot.BarRenderer,
    ...
};

data.renderer = renderers[data.renderer];


text:
Q: Issues with this website in responsive design Im changing this website currently to responsive design.
Everything works fine on my PC and also on online responsive checker.
But If I Access the site on my actual Iphone 5/7 or Ipad 2 the slider has huge
issues which switching to the next image.
The website is: http://gsa.taheri-create.com/
Could any of you please check it and advice me what could be wrong?
I re-checked everything basically like 3x but couldnt find an issue.
On Responsinator.com etc it works well, just not on the actual devices....
Thanks for the help.